local-operator-ui 0.50.1 → 0.50.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 +96 -8
- package/out/renderer/assets/{_basePickBy-Bsv7r9Jb.js → _basePickBy-B0CGodz5.js} +1 -1
- package/out/renderer/assets/{_baseUniq-jyJ-i_Ny.js → _baseUniq-8ysZQvmz.js} +1 -1
- package/out/renderer/assets/{agent-details-page-DQXYu_PL.js → agent-details-page-CdnNoAG1.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-1bRH8Gbz.js → agent-hub-page-DzJe_j6z.js} +1 -1
- package/out/renderer/assets/{agents-page-3iHF3oFj.js → agents-page-B8ehgi1r.js} +3 -3
- package/out/renderer/assets/appearance-DxToWtVc.js +65 -0
- package/out/renderer/assets/{approvalsOverlay-fAKBFaaS.js → approvalsOverlay-C-vFFJMh.js} +1 -1
- package/out/renderer/assets/{arc-D4FKhFvF.js → arc-C6vMPnZo.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-D2Wm66Ss.js → architectureDiagram-IEHRJDOE-BaKmVFd8.js} +1 -1
- package/out/renderer/assets/{avatar-cropper-BxTkXnUv.js → avatar-cropper-CCvczwaj.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-Dhx8qL4I.js → blockDiagram-JOT3LUYC-DNJTzz0-.js} +1 -1
- package/out/renderer/assets/{book-open-DjYEoRKl.js → book-open-AjJXGzb6.js} +1 -1
- package/out/renderer/assets/browser-page-B1LNZlf_.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-DhewWTHJ.js → browser-webauthn-prompt-D7ldFLmy.js} +1 -1
- package/out/renderer/assets/{building-2-D7Uxv0cT.js → building-2-DrbuKv4e.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-D78faDhy.js → c4Diagram-VJAJSXHY-CFvnENAF.js} +1 -1
- package/out/renderer/assets/channel-C0mudVZF.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-DRKhJ_j1.js → chunk-4BMEZGHF-DSSF88xF.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-DGSwfWb0.js → chunk-A2AXSNBT-DW2Smd4N.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-B42qalpB.js → chunk-AEK57VVT-vmOkmkFl.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-wUxOb9HP.js → chunk-D6G4REZN-C-1gQ6dD.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-Dne7UctW.js → chunk-RZ5BOZE2-CvkHOneP.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-DXwYr08U.js → chunk-XZIHB7SX-DtVS8cQp.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DfsohnxP.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DfsohnxP.js +1 -0
- package/out/renderer/assets/clone-DogRJTvD.js +1 -0
- package/out/renderer/assets/{console-mirror-BQHgtoeJ.js → console-mirror-CUiw0R0Z.js} +1 -1
- package/out/renderer/assets/{consoleCapture-BZ1Iqw5E.js → consoleCapture-CEIY9xSK.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-D820Mg9t.js → conversation-input-sync-BGfWeOqy.js} +4 -4
- package/out/renderer/assets/{dagre-OKDRZEBW-DH78Ufhs.js → dagre-OKDRZEBW-CWzXBwaH.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-CaO0hoO4.js → diagram-SSKATNLV-t868hyXW.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-PrdUVU14.js → diagram-VNBRO52H-DUoOE-bt.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-Bz3wOSZb.js → erDiagram-Q7BY3M3F-DYWVOUdq.js} +1 -1
- package/out/renderer/assets/{error-boundary-DEGyIgpt.js → error-boundary-CtkXM619.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-DSLF5rPX.js → flowDiagram-4HSFHLVR-BswlGsLM.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-BYPDtZuf.js → ganttDiagram-APWFNJXF-CCEe3Tdm.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-CG1HY2FR.js → gitGraphDiagram-7IBYFJ6S-Bl10LWvi.js} +1 -1
- package/out/renderer/assets/{graph-B8PSktuT.js → graph-DKQjDGox.js} +1 -1
- package/out/renderer/assets/{heart-CYS0Evlh.js → heart-mTaKHtD-.js} +1 -1
- package/out/renderer/assets/{index-C6QnCGp0.js → index-BcwoLiEJ.js} +1 -1
- package/out/renderer/assets/{index-DH5u3QDS.js → index-Bh3nSSKU.js} +3 -3
- package/out/renderer/assets/{index-CxIdeYfQ.js → index-CWP3MhTA.js} +1 -1
- package/out/renderer/assets/{index-DAPMXH_k.js → index-CfE0tEz7.js} +1 -1
- package/out/renderer/assets/infoDiagram-PH2N3AL5-BOATky3y.js +2 -0
- package/out/renderer/assets/{installer-CiMEp27D.js → installer-D-_8CWoh.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-CwL5RIgy.js → journeyDiagram-U35MCT3I-B5JRH6pA.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-YjvJCrvZ.js → kanban-definition-NDS4AKOZ-BMQ51i2A.js} +1 -1
- package/out/renderer/assets/{layout-MLQtp9YQ.js → layout-BlYEyiLa.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-noAFJiLG.js → legacy-agents-page-Ca9aGS2m.js} +1 -1
- package/out/renderer/assets/{library-page-B9cQw_XV.js → library-page-1Q4ToZpC.js} +3 -3
- package/out/renderer/assets/{log-in-E6HfPJn1.js → log-in-Cz3YBOsh.js} +1 -1
- package/out/renderer/assets/{mermaid.core-CyqGNrTg.js → mermaid.core-D7HsriVr.js} +5 -5
- package/out/renderer/assets/{mesh-page-5KrCdgRG.js → mesh-page-B2xAXfjA.js} +1 -1
- package/out/renderer/assets/{messages-DRkjMKBJ.js → messages-CvRfSjnp.js} +8 -8
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-DxOaGeQS.js → mindmap-definition-ALO5MXBD-CMk15Uui.js} +1 -1
- package/out/renderer/assets/{mini-x7Qw7umA.js → mini-lkT5V9WE.js} +1 -1
- package/out/renderer/assets/{notebook-pen-D4l7rOnf.js → notebook-pen-DadCKhKK.js} +1 -1
- package/out/renderer/assets/{notifications-page-C23kRJcC.js → notifications-page-DLvG89Rx.js} +1 -1
- package/out/renderer/assets/{org-access-CyJbTo13.js → org-access-mvMfl6RO.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-gYrpsVF3.js → org-surface-gate-DG0gOjUM.js} +1 -1
- package/out/renderer/assets/{page-header-DhaFiERt.js → page-header-CyxvZBjK.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-CL81fv2F.js → pieDiagram-IB7DONF6-B5VgM5cu.js} +1 -1
- package/out/renderer/assets/{project-markdown-B0jRuZju.js → project-markdown-C7j9JEv7.js} +1 -1
- package/out/renderer/assets/{projects-page-BWH8MFcf.js → projects-page-Cy7ci4iQ.js} +1 -1
- package/out/renderer/assets/{publication-validation-DI7vbv0d.js → publication-validation-LHyYGXxk.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-D_sJILsv.js → quadrantDiagram-7GDLP6J5-CabDBOXn.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-CuxaL0km.js → radar-MK3ICKWK-Bs5DDyVg.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-WMi92Nbu.js → radient-auth-buttons-CjpUv3nP.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-ChHTRRQC.js → requirementDiagram-KVF5MWMF-s_UB9693.js} +1 -1
- package/out/renderer/assets/{roles-KXyR--wS.js → roles-D1pcbxAx.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-Br2FU_Mu.js → sankeyDiagram-QLVOVGJD-FBDT6-L8.js} +1 -1
- package/out/renderer/assets/{schedules-page-Dtrb4iqB.js → schedules-page-DWG-H1tc.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-BYeAipI4.js → sequenceDiagram-X6HHIX6F-Dk2LRARF.js} +1 -1
- package/out/renderer/assets/settings-page-Cc3TAlMl.js +296 -0
- package/out/renderer/assets/{smartart-DK4xklXS.js → smartart-CZP-KJQm.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-HfPPSL57.js → stateDiagram-DGXRK772-nAeHi0Q3.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CdCpeeGq.js +1 -0
- package/out/renderer/assets/{team-bridge-page-D--3lHyk.js → team-bridge-page-DyGy6Kbj.js} +1 -1
- package/out/renderer/assets/{team-bridge-scope-preference-jREmpkHn.js → team-bridge-scope-preference-DMVpYrdA.js} +1 -1
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-4WbDfFTG.js → timeline-definition-BDJGKUSR-pJTYZrUl.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-CYiV_Si3.js → use-download-agent-mutation-BimCWRpf.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-CEZUdpvo.js → use-session-snapshot-D90Nwywl.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-ClLC2IYI.js → xychartDiagram-VJFVF3MP-CNYZmTD0.js} +1 -1
- package/out/renderer/browser-approvals-overlay.html +3 -3
- package/out/renderer/console-capture.html +6 -6
- package/out/renderer/index.html +8 -8
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +8 -8
- package/package.json +1 -1
- package/out/renderer/assets/appearance-1qSymuJE.js +0 -65
- package/out/renderer/assets/browser-page-CbE2J46g.js +0 -1
- package/out/renderer/assets/channel-CbmsDNIR.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-Br3BiPxU.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-Br3BiPxU.js +0 -1
- package/out/renderer/assets/clone-BUSzjx2V.js +0 -1
- package/out/renderer/assets/infoDiagram-PH2N3AL5-CDml2IbJ.js +0 -2
- package/out/renderer/assets/settings-page-D68agRqU.js +0 -296
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BP4m3n3G.js +0 -1
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import{r as o,j as e,c as ge,f as st,t as ze,i as Be}from"./index-C6QnCGp0.js";import{h as Te,u as St,at as Ki,aq as Bi,au as Hi,av as We,a as Ct,c as at,aw as qi,a8 as Vi,ax as Gi,ay as Wi,az as Yi,aA as Qi,d as je,aB as Dn,aC as Zi,aD as Ji,aE as Xi,aF as er,E as ue,aG as Fn,aH as tr,aI as nr,aJ as sr,aK as ar,aL as Na,aM as ir,aN as ht,aO as tn,aP as gn,aQ as pn,aR as rr,aS as Ns,aT as or,aU as cr,aV as Ss,aW as lr,L as ts,aX as dr,w as ft,aY as ur,o as Sa,ah as mr,J as Ce,r as gr,q as pr,aZ as zn,a_ as hr,a$ as Cs,b0 as fr,b1 as Ca,a4 as _r,a5 as xr}from"./appearance-1qSymuJE.js";import{o as yr}from"./console-mirror-BQHgtoeJ.js";import{eZ as Pn,e_ as br,e$ as Ms,f0 as Ke,cD as vr,b6 as Ma,b7 as ns,aH as Aa,bx as kr,aA as ss,f1 as jr,f2 as wr,f3 as Nr,f4 as Sr,f5 as Ea,f6 as as,b4 as Ia,f7 as Cr,f8 as Mr,f9 as Bt,fa as Ra,fb as Ar,bz as $n,fc as As,fd as Er,fe as et,ff as nn,c5 as is,fg as rs,cS as Ht,cg as Ir,fh as Ta,fi as os,fj as sn,fk as Rr,fl as Tr,fm as Lr,fn as hn,fo as cs,fp as Or,fq as Dr,aW as La,bB as Un,bC as Kn,a2 as Oa,aB as Bn,fr as Fr,fs as zr,ft as Hn,fu as Pr,fv as $r,fw as Ur,fx as Da,fy as Kr,fz as Br,fA as Hr,dv as tt,eu as qr,dj as Fa,dw as Vr,b as Es,dk as Gr,dl as ls,a1 as za,bw as Wr,fB as Pa,bA as $a,fC as Ua,fD as Yr,fE as Qr,fF as Zr,fG as Jr,fH as Xr,fI as eo,dS as to,b3 as no,fJ as so,fK as ao,ca as Ka,cc as io,fL as ut,fM as Is,fN as ro,fO as oo,fP as co,fQ as lo,fR as uo,r as mo,fS as fn,fT as Tt,fU as go,fV as po,fW as ho,fX as fo,fY as _o,fZ as xo,f_ as _n,f$ as Rs,g0 as yo,cy as bo,g1 as vo,g2 as ko,cF as jo,g3 as wo,g4 as No,g5 as So,g6 as Co,ey as xn,g7 as Mo,g8 as Ao}from"./conversation-input-sync-D820Mg9t.js";import{df as Ba,dg as Eo,dh as Io,di as Ha,dj as Ro,cd as To,dk as Fe,N as Lo,S as qa,bE as Mt,bF as ke,dl as vt,dm as ye,dn as yn,dp as Oo,R as Do,bj as Va,a as qn,c1 as Fo,dq as zo,dr as Po,cb as $o,ds as Uo,dt as Lt,du as Ot,dv as Ko,dw as Bo,bS as Ho,bD as qo,bP as Vo,dx as Go,dy as Wo,dz as Yo,dA as Qo,bt as Ts,dB as Zo,bA as Ls,bZ as Jo,bB as Xo,bC as ec,dC as tc,dD as nc,bs as sc,dE as ac}from"./index-DH5u3QDS.js";import{P as ic}from"./page-header-DhaFiERt.js";import{c as W,u as te,B as D,S as Ee,_ as Ga,w as Pe,N as kt,O as jt,P as Ye,A as me,q as an,x as Oe,f as Ae,R as ds,U as us,V as ms,W as gs,Y as nt,L as De,K as Ne,a6 as rn,$ as Wa,i as wt,h as Vn,af as rc,a as cn,Z as oc,aa as Ya,a7 as cc,a8 as lc,a9 as dc,ar as Gn,r as uc,G as Qa,at as mc,au as Os,T as ps,D as Za,b as Ja,d as Xa,I as gc,e as Xe,E as pc,am as hc,ag as fc,ah as _c,av as xc,aw as yc,n as qt,o as Vt,p as Gt,z as Wt}from"./error-boundary-DEGyIgpt.js";import{t as n,L as bn}from"./messages-DRkjMKBJ.js";import{u as bc,a as vc,D as kc,b as jc,d as wc,S as Nc}from"./team-bridge-scope-preference-jREmpkHn.js";import{R as Sc}from"./radient-auth-buttons-WMi92Nbu.js";import{u as Cc,A as Mc,d as Ac}from"./avatar-cropper-BxTkXnUv.js";import{N as Ec}from"./notebook-pen-D4l7rOnf.js";import{p as ei}from"./roles-KXyR--wS.js";import{B as Ic}from"./book-open-DjYEoRKl.js";import{i as Rc,a as Ve,b as Tc,p as vn,f as Lc}from"./parseISO-CxPiCKvF.js";import{t as Oc}from"./en-US-CW_dDnkH.js";/**
|
|
2
|
-
* @license lucide-react v0.507.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Dc=[["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"}]],Fc=W("aperture",Dc);/**
|
|
7
|
-
* @license lucide-react v0.507.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const zc=[["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"}]],Pc=W("atom",zc);/**
|
|
12
|
-
* @license lucide-react v0.507.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const $c=[["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"}]],Uc=W("audio-waveform",$c);/**
|
|
17
|
-
* @license lucide-react v0.507.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Kc=[["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"}]],Bc=W("binary",Kc);/**
|
|
22
|
-
* @license lucide-react v0.507.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const Hc=[["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"}]],qc=W("candy",Hc);/**
|
|
27
|
-
* @license lucide-react v0.507.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const Vc=[["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"}]],Gc=W("car-front",Vc);/**
|
|
32
|
-
* @license lucide-react v0.507.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const Wc=[["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"}]],Yc=W("cassette-tape",Wc);/**
|
|
37
|
-
* @license lucide-react v0.507.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const Qc=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Zc=W("chart-line",Qc);/**
|
|
42
|
-
* @license lucide-react v0.507.0 - ISC
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the ISC license.
|
|
45
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const Jc=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],Xc=W("circle-plus",Jc);/**
|
|
47
|
-
* @license lucide-react v0.507.0 - ISC
|
|
48
|
-
*
|
|
49
|
-
* This source code is licensed under the ISC license.
|
|
50
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const el=[["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"}]],tl=W("circuit-board",el);/**
|
|
52
|
-
* @license lucide-react v0.507.0 - ISC
|
|
53
|
-
*
|
|
54
|
-
* This source code is licensed under the ISC license.
|
|
55
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const nl=[["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"}]],sl=W("cloud-lightning",nl);/**
|
|
57
|
-
* @license lucide-react v0.507.0 - ISC
|
|
58
|
-
*
|
|
59
|
-
* This source code is licensed under the ISC license.
|
|
60
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const al=[["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"}]],il=W("cloud-moon",al);/**
|
|
62
|
-
* @license lucide-react v0.507.0 - ISC
|
|
63
|
-
*
|
|
64
|
-
* This source code is licensed under the ISC license.
|
|
65
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const rl=[["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"}]],ol=W("cloud-snow",rl);/**
|
|
67
|
-
* @license lucide-react v0.507.0 - ISC
|
|
68
|
-
*
|
|
69
|
-
* This source code is licensed under the ISC license.
|
|
70
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const cl=[["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"}]],ll=W("cloud-sun",cl);/**
|
|
72
|
-
* @license lucide-react v0.507.0 - ISC
|
|
73
|
-
*
|
|
74
|
-
* This source code is licensed under the ISC license.
|
|
75
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const dl=[["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"}]],ul=W("coffee",dl);/**
|
|
77
|
-
* @license lucide-react v0.507.0 - ISC
|
|
78
|
-
*
|
|
79
|
-
* This source code is licensed under the ISC license.
|
|
80
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const ml=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]],ti=W("contrast",ml);/**
|
|
82
|
-
* @license lucide-react v0.507.0 - ISC
|
|
83
|
-
*
|
|
84
|
-
* This source code is licensed under the ISC license.
|
|
85
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const gl=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],pl=W("credit-card",gl);/**
|
|
87
|
-
* @license lucide-react v0.507.0 - ISC
|
|
88
|
-
*
|
|
89
|
-
* This source code is licensed under the ISC license.
|
|
90
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const hl=[["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"}]],fl=W("cup-soda",hl);/**
|
|
92
|
-
* @license lucide-react v0.507.0 - ISC
|
|
93
|
-
*
|
|
94
|
-
* This source code is licensed under the ISC license.
|
|
95
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const _l=[["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"}]],xl=W("disc-3",_l);/**
|
|
97
|
-
* @license lucide-react v0.507.0 - ISC
|
|
98
|
-
*
|
|
99
|
-
* This source code is licensed under the ISC license.
|
|
100
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const yl=[["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"}]],bl=W("droplet",yl);/**
|
|
102
|
-
* @license lucide-react v0.507.0 - ISC
|
|
103
|
-
*
|
|
104
|
-
* This source code is licensed under the ISC license.
|
|
105
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const vl=[["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"}]],kl=W("droplets",vl);/**
|
|
107
|
-
* @license lucide-react v0.507.0 - ISC
|
|
108
|
-
*
|
|
109
|
-
* This source code is licensed under the ISC license.
|
|
110
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const jl=[["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"}]],wl=W("fish",jl);/**
|
|
112
|
-
* @license lucide-react v0.507.0 - ISC
|
|
113
|
-
*
|
|
114
|
-
* This source code is licensed under the ISC license.
|
|
115
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
-
*/const Nl=[["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"}]],Sl=W("flame",Nl);/**
|
|
117
|
-
* @license lucide-react v0.507.0 - ISC
|
|
118
|
-
*
|
|
119
|
-
* This source code is licensed under the ISC license.
|
|
120
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const Cl=[["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"}]],Ml=W("flower-2",Cl);/**
|
|
122
|
-
* @license lucide-react v0.507.0 - ISC
|
|
123
|
-
*
|
|
124
|
-
* This source code is licensed under the ISC license.
|
|
125
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
-
*/const Al=[["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"}]],El=W("flower",Al);/**
|
|
127
|
-
* @license lucide-react v0.507.0 - ISC
|
|
128
|
-
*
|
|
129
|
-
* This source code is licensed under the ISC license.
|
|
130
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
-
*/const Il=[["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"}]],Rl=W("ghost",Il);/**
|
|
132
|
-
* @license lucide-react v0.507.0 - ISC
|
|
133
|
-
*
|
|
134
|
-
* This source code is licensed under the ISC license.
|
|
135
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
-
*/const Tl=[["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"}]],Ll=W("github",Tl);/**
|
|
137
|
-
* @license lucide-react v0.507.0 - ISC
|
|
138
|
-
*
|
|
139
|
-
* This source code is licensed under the ISC license.
|
|
140
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
-
*/const Ol=[["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"}]],Dl=W("guitar",Ol);/**
|
|
142
|
-
* @license lucide-react v0.507.0 - ISC
|
|
143
|
-
*
|
|
144
|
-
* This source code is licensed under the ISC license.
|
|
145
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
-
*/const Fl=[["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"}]],zl=W("hexagon",Fl);/**
|
|
147
|
-
* @license lucide-react v0.507.0 - ISC
|
|
148
|
-
*
|
|
149
|
-
* This source code is licensed under the ISC license.
|
|
150
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
-
*/const Pl=[["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"}]],$l=W("ice-cream-bowl",Pl);/**
|
|
152
|
-
* @license lucide-react v0.507.0 - ISC
|
|
153
|
-
*
|
|
154
|
-
* This source code is licensed under the ISC license.
|
|
155
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
-
*/const Ul=[["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"}]],Kl=W("joystick",Ul);/**
|
|
157
|
-
* @license lucide-react v0.507.0 - ISC
|
|
158
|
-
*
|
|
159
|
-
* This source code is licensed under the ISC license.
|
|
160
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
-
*/const Bl=[["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"}]],Hl=W("leaf",Bl);/**
|
|
162
|
-
* @license lucide-react v0.507.0 - ISC
|
|
163
|
-
*
|
|
164
|
-
* This source code is licensed under the ISC license.
|
|
165
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
-
*/const ql=[["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"}]],Vl=W("lightbulb",ql);/**
|
|
167
|
-
* @license lucide-react v0.507.0 - ISC
|
|
168
|
-
*
|
|
169
|
-
* This source code is licensed under the ISC license.
|
|
170
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
-
*/const Gl=[["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"}]],Wl=W("milk",Gl);/**
|
|
172
|
-
* @license lucide-react v0.507.0 - ISC
|
|
173
|
-
*
|
|
174
|
-
* This source code is licensed under the ISC license.
|
|
175
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
176
|
-
*/const Yl=[["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"}]],Ql=W("moon-star",Yl);/**
|
|
177
|
-
* @license lucide-react v0.507.0 - ISC
|
|
178
|
-
*
|
|
179
|
-
* This source code is licensed under the ISC license.
|
|
180
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
-
*/const Zl=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],Jl=W("moon",Zl);/**
|
|
182
|
-
* @license lucide-react v0.507.0 - ISC
|
|
183
|
-
*
|
|
184
|
-
* This source code is licensed under the ISC license.
|
|
185
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
186
|
-
*/const Xl=[["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"}]],ed=W("mountain-snow",Xl);/**
|
|
187
|
-
* @license lucide-react v0.507.0 - ISC
|
|
188
|
-
*
|
|
189
|
-
* This source code is licensed under the ISC license.
|
|
190
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
-
*/const td=[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]],nd=W("mountain",td);/**
|
|
192
|
-
* @license lucide-react v0.507.0 - ISC
|
|
193
|
-
*
|
|
194
|
-
* This source code is licensed under the ISC license.
|
|
195
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
196
|
-
*/const sd=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],ad=W("palette",sd);/**
|
|
197
|
-
* @license lucide-react v0.507.0 - ISC
|
|
198
|
-
*
|
|
199
|
-
* This source code is licensed under the ISC license.
|
|
200
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
201
|
-
*/const id=[["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"}]],rd=W("radio",id);/**
|
|
202
|
-
* @license lucide-react v0.507.0 - ISC
|
|
203
|
-
*
|
|
204
|
-
* This source code is licensed under the ISC license.
|
|
205
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
206
|
-
*/const od=[["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"}]],cd=W("sailboat",od);/**
|
|
207
|
-
* @license lucide-react v0.507.0 - ISC
|
|
208
|
-
*
|
|
209
|
-
* This source code is licensed under the ISC license.
|
|
210
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
-
*/const ld=[["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"}]],dd=W("shirt",ld);/**
|
|
212
|
-
* @license lucide-react v0.507.0 - ISC
|
|
213
|
-
*
|
|
214
|
-
* This source code is licensed under the ISC license.
|
|
215
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
216
|
-
*/const ud=[["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"}]],md=W("skull",ud);/**
|
|
217
|
-
* @license lucide-react v0.507.0 - ISC
|
|
218
|
-
*
|
|
219
|
-
* This source code is licensed under the ISC license.
|
|
220
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
221
|
-
*/const gd=[["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"}]],pd=W("snowflake",gd);/**
|
|
222
|
-
* @license lucide-react v0.507.0 - ISC
|
|
223
|
-
*
|
|
224
|
-
* This source code is licensed under the ISC license.
|
|
225
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
226
|
-
*/const hd=[["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"}]],fd=W("sparkle",hd);/**
|
|
227
|
-
* @license lucide-react v0.507.0 - ISC
|
|
228
|
-
*
|
|
229
|
-
* This source code is licensed under the ISC license.
|
|
230
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
231
|
-
*/const _d=[["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"}]],xd=W("sun-dim",_d);/**
|
|
232
|
-
* @license lucide-react v0.507.0 - ISC
|
|
233
|
-
*
|
|
234
|
-
* This source code is licensed under the ISC license.
|
|
235
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
236
|
-
*/const yd=[["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"}]],bd=W("sun",yd);/**
|
|
237
|
-
* @license lucide-react v0.507.0 - ISC
|
|
238
|
-
*
|
|
239
|
-
* This source code is licensed under the ISC license.
|
|
240
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
241
|
-
*/const vd=[["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"}]],kd=W("sunrise",vd);/**
|
|
242
|
-
* @license lucide-react v0.507.0 - ISC
|
|
243
|
-
*
|
|
244
|
-
* This source code is licensed under the ISC license.
|
|
245
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
246
|
-
*/const jd=[["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"}]],wd=W("sunset",jd);/**
|
|
247
|
-
* @license lucide-react v0.507.0 - ISC
|
|
248
|
-
*
|
|
249
|
-
* This source code is licensed under the ISC license.
|
|
250
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
251
|
-
*/const Nd=[["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"}]],Sd=W("tent",Nd);/**
|
|
252
|
-
* @license lucide-react v0.507.0 - ISC
|
|
253
|
-
*
|
|
254
|
-
* This source code is licensed under the ISC license.
|
|
255
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
256
|
-
*/const Cd=[["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"}]],Md=W("tree-deciduous",Cd);/**
|
|
257
|
-
* @license lucide-react v0.507.0 - ISC
|
|
258
|
-
*
|
|
259
|
-
* This source code is licensed under the ISC license.
|
|
260
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
261
|
-
*/const Ad=[["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"}]],Ed=W("tree-palm",Ad);/**
|
|
262
|
-
* @license lucide-react v0.507.0 - ISC
|
|
263
|
-
*
|
|
264
|
-
* This source code is licensed under the ISC license.
|
|
265
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
266
|
-
*/const Id=[["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"}]],Rd=W("tree-pine",Id);/**
|
|
267
|
-
* @license lucide-react v0.507.0 - ISC
|
|
268
|
-
*
|
|
269
|
-
* This source code is licensed under the ISC license.
|
|
270
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
271
|
-
*/const Td=[["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"}]],Ld=W("trees",Td);/**
|
|
272
|
-
* @license lucide-react v0.507.0 - ISC
|
|
273
|
-
*
|
|
274
|
-
* This source code is licensed under the ISC license.
|
|
275
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
276
|
-
*/const Od=[["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"}]],Dd=W("umbrella",Od);/**
|
|
277
|
-
* @license lucide-react v0.507.0 - ISC
|
|
278
|
-
*
|
|
279
|
-
* This source code is licensed under the ISC license.
|
|
280
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
281
|
-
*/const Fd=[["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"}]],zd=W("waves",Fd);/**
|
|
282
|
-
* @license lucide-react v0.507.0 - ISC
|
|
283
|
-
*
|
|
284
|
-
* This source code is licensed under the ISC license.
|
|
285
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
286
|
-
*/const Pd=[["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"}]],$d=W("wheat",Pd);/**
|
|
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 Ud=[["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"}]],Kd=W("wind",Ud),Bd=({appVersion:t=null,slowWaitHintMs:s})=>{te();const a="https://local-operator.com/download",[i,r]=o.useState(!1),c=Ba(i,s??Eo),[l,d]=o.useState(!1),[u,m]=o.useState(null),[p,g]=o.useState("info"),[_,x]=o.useState(null),[k,b]=o.useState(null),S=t?.trim()?t.trim():null,I=o.useRef(!1),M=Pn(T=>T.openDetail),L=o.useRef(!1),E=o.useRef(0),O=o.useRef(!1),y=o.useCallback((T,v)=>{L.current=!1,m(T),g(v),d(!0)},[]),F=o.useCallback(T=>{L.current=!0,m(T),g("success"),d(!0)},[]),K=o.useCallback(()=>{L.current&&(L.current=!1,d(!1),m(null))},[]),{clearDeferredUpdate:P}=br();o.useEffect(()=>{const T=window.api.updater.onUpdateError(h=>{I.current&&h.includes("manually")&&(x({message:n("ui.common.updates.check_for_updates_button.the_server_is_installed_outside_the_app_so_use_the_tool_you_insta"),command:""}),L.current=!1,m(null),g("warning"),d(!0))}),v=window.api.updater.onBackendUpdateDevMode(h=>{I.current&&y(h,"info")}),H=()=>{O.current=!0,K()},z=window.api.updater.onUpdateAvailable(H),q=window.api.updater.onUpdateNpxAvailable(H),Z=window.api.updater.onBackendUpdateAvailable(H);return()=>{T(),v(),z(),q(),Z()}},[K,y]),o.useEffect(()=>{let T=!1;const v=()=>{window.api.updater.getLastInstallAttempt().then(z=>{T||b(z)}).catch(()=>{})};v();const H=window.api.updater.onUpdateInstallFailed(()=>v());return()=>{T=!0,H()}},[]);const f=async()=>{const T=++E.current;K(),O.current=!1;try{r(!0),I.current=!0,P(Ke.UI),P(Ke.BACKEND);const v=await window.api.updater.checkForAllUpdates({manual:!0});if(T!==E.current)return;v.app==="available"&&M(Ke.UI),v.server==="available"&&M(Ke.BACKEND),v?.affirmation&&!O.current?F(v.affirmation):K()}catch(v){if(T!==E.current)return;console.warn(`Update check failed; the app-level alert owns the report: ${Io(v)}`)}finally{T===E.current&&r(!1),setTimeout(()=>{I.current=!1},2e3)}},A=()=>{L.current=!1,d(!1),m(null)};return e.jsxs(e.Fragment,{children:[k&&e.jsxs("div",{className:"mb-3 rounded-sm bg-sunken p-3",children:[e.jsxs("p",{className:"text-body-sm text-ink",children:[n("ui.common.updates.check_for_updates_button.the_last_update_to_version"),k.targetVersion," ",n("ui.common.updates.check_for_updates_button.didn_t_finish"),k.attempts>1?n("ui.common.updates.check_for_updates_button.detail",{attempts:k.attempts,attemptsText:String(k.attempts)}):"",".",S?n("ui.common.updates.check_for_updates_button.version",{liveversion:String(S)}):null]}),e.jsxs("p",{className:"mt-1 text-meta text-ink-dim",children:[n("ui.common.updates.check_for_updates_button.detected")," ",k.detectedAt?new Date(k.detectedAt).toLocaleString():n("ui.common.updates.check_for_updates_button.at_an_unknown_time"),". ",k.detail]}),e.jsx(D,{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")})]}),e.jsxs(D,{variant:"outline",onClick:()=>void f(),disabled:i,children:[i?e.jsx(Ee,{size:"sm"}):null,i?n("ui.common.updates.check_for_updates_button.checking"):n("ui.common.updates.check_for_updates_button.check_for_updates")]}),c&&e.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")}),_&&e.jsxs(Ms,{open:l,autoHideDuration:1e4,onClose:A,variant:"warning",children:[e.jsx("p",{className:"text-body-sm",children:_.message}),_.command&&e.jsx("code",{className:"mt-2 block rounded-sm bg-sunken p-2 text-mono-sm text-ink",children:_.command})]}),u&&p!=="danger"&&e.jsx(Ms,{open:l,autoHideDuration:6e3,onClose:A,variant:p,children:u})]})},Yt=["system-prompt"],Hd=()=>{const{shouldEnableQuery:t}=vr();return Te({enabled:t({bypassInternetCheck:!0}),queryKey:Yt,queryFn:async()=>{try{const a=await Ma(ns.baseUrl).config.getSystemPrompt();if(a===null)return null;if(a.status>=400)throw new Error(a.message||n("ui.common.errors.system_prompt_fetch"));return a.result}catch(s){const a=s instanceof Error?s.message:n("ui.common.errors.system_prompt_fetch_unknown");throw Aa(a),s}},refetchOnWindowFocus:!1,staleTime:5e3})},qd=()=>{const t=St(),s=Ma(ns.baseUrl);return kr({mutationFn:async a=>{try{const i=await s.config.updateSystemPrompt(a);if(i.status>=400)throw new Error(i.message||n("ui.common.errors.system_prompt_update"));return i.result}catch(i){const r=i instanceof Error?i.message:n("ui.common.errors.system_prompt_update_unknown");throw Aa(r),i}},onSuccess:async a=>{await t.invalidateQueries({queryKey:Yt,refetchType:"none"}),t.setQueryData(Yt,i=>i&&{...i,...a}),await t.refetchQueries({queryKey:Yt,type:"all"}),ss(n("ui.notices.settings.system_prompt_updated"))},onError:a=>{console.error("Error updating system prompt:",a)}})},ni=({searchRow:t,value:s,label:a,description:i,onChange:r,icon:c,isSaving:l=!1,disabled:d=!1})=>{te();const[u,m]=o.useState(s),p=o.useId(),g=`${p}-label`,_=`${p}-description`,x=async k=>{if(!(l||d)){m(k);try{await r(k)}catch(b){m(!k),console.error("Error toggling setting:",b)}}};return e.jsxs("div",{"data-search-row":t,"data-search-control":t?"":void 0,className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("span",{id:g,"data-search-label":"",className:"flex min-h-6 items-center gap-2 text-body text-ink",children:[c&&e.jsx(c,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),a]}),i&&e.jsx("p",{id:_,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:i})]}),e.jsx("div",{className:"flex h-6 shrink-0 items-center",children:l?e.jsx(Ee,{size:"md",label:n("ui.common.forms.toggle_setting.saving",{label:a})}):e.jsx(Ga,{checked:u,onCheckedChange:x,disabled:d,"aria-labelledby":g,"aria-describedby":i?_:void 0})})]})};function Ds(t,s){const a=Oc(t,s?.in);if(!Rc(a))throw new RangeError("Invalid time value");const i=Ve(a.getDate(),2),r=Ve(a.getMonth()+1,2),c=a.getFullYear(),l=Ve(a.getHours(),2),d=Ve(a.getMinutes(),2),u=Ve(a.getSeconds(),2);let m="",p="";const g=a.getTimezoneOffset();if(g!==0){const _=Math.abs(g),x=Ve(Math.trunc(_/60),2),k=Ve(_%60,2);p=`${g<0?"+":"-"}${x}:${k}`}else p="Z";return`${c}-${r}-${i}T${l}:${d}:${u}${m}${p}`}function Vd(t,s,a){return Tc(t,-30,a)}var Gd=jr({chartName:"LineChart",GraphicalChild:Ea,axisComponents:[{axisType:"xAxis",AxisComp:wr},{axisType:"yAxis",AxisComp:Nr}],formatAxisMap:Sr});const Wd=["radient","creditBalance"],Yd=t=>{const{user:s,isAuthenticated:a}=as(),i=s?.account?.tenant_id,r=a&&!!i&&t?.enabled;return Te({queryKey:[Wd,i],queryFn:async()=>{if(!i)throw new Error(n("ui.common.errors.tenant_missing"));const c=await Ia({operation:"credits",tenantId:i});if(!c||typeof c.balance!="number")throw new Error(n("ui.common.errors.credit_balance_invalid"));return c},enabled:r,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},Qd=["radient","usageRollup"],Zd=(t,s)=>{const{user:a,isAuthenticated:i}=as(),r=a?.account?.tenant_id,c=i&&!!r&&s?.enabled;return Te({queryKey:[...Qd,r,t],queryFn:async()=>{if(!r)throw new Error(n("ui.common.errors.tenant_missing"));const l={};for(const[u,m]of Object.entries(t))m!=null&&(l[u]=String(m));const d=await Ia({operation:"usage",tenantId:r,query:l});if(!d)throw new Error(n("ui.common.errors.usage_rollup_invalid"));return d},enabled:c,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},Jd=t=>t==="sidebars"?n("ui.settings.appearance.window_glass.coverage_sidebars"):n("ui.settings.appearance.window_glass.coverage_full"),Xd=t=>{switch(t){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")}},eu=t=>{switch(t){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")}},Fs=({label:t,description:s,value:a,onValueChange:i,options:r})=>{const c=o.useId();return e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{id:c,className:"flex min-h-6 items-center text-body text-ink",children:t}),e.jsx("p",{className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:s})]}),e.jsx("div",{className:"flex h-6 shrink-0 items-center",children:e.jsx(kt,{value:a,onValueChange:i,children:e.jsx(jt,{"aria-labelledby":c,children:r.map(l=>e.jsx(Ye,{value:l.value,children:l.label},l.value))})})})]})},tu=({state:t,onChange:s,searchRow:a})=>{te();const i=o.useId(),r=`${i}-description`,[c,l]=o.useState(null),d=o.useRef(!1),u=o.useRef(null),m=t?.settings.intensity??0;if(!t)return null;const p=!t.capability.supported,g=p?eu(t.capability.reason):null,_=async b=>{if(d.current){u.current=b;return}d.current=!0;try{await s({intensity:b})}finally{d.current=!1;const S=u.current;u.current=null,S!==null&&S!==b?_(S):l(null)}},x=t.settings.enabled,k=c??m;return e.jsxs("div",{"data-search-row":a,"data-search-control":a?"":void 0,className:"flex flex-col gap-4","data-window-glass":"","data-glass-gate":t.capability.reason,children:[e.jsx(Pe,{content:g,disabled:!p,children:e.jsx("div",{className:p?"opacity-60":void 0,children:e.jsx(ni,{value:p?!1:x,disabled:p,label:n("ui.settings.appearance.window_glass.label"),description:n("ui.settings.appearance.window_glass.description"),onChange:async b=>s({enabled:b})},p?"unavailable":"available")})}),g&&e.jsx("p",{"data-glass-unsupported":t.capability.reason,className:"max-w-2xl text-body-sm text-ink-muted",children:g}),t.restartRequired&&e.jsx("output",{className:"block max-w-2xl text-body-sm text-ink","data-glass-restart":"",children:n("ui.settings.appearance.window_glass.restart_needed")}),x&&!p&&e.jsxs(e.Fragment,{children:[e.jsx(Fs,{label:n("ui.settings.appearance.window_glass.coverage_label"),description:n("ui.settings.appearance.window_glass.coverage_description"),value:t.settings.coverage,onValueChange:b=>void s({coverage:b}),options:Cr.map(b=>({value:b,label:Jd(b)}))}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex min-h-6 items-center justify-between gap-3",children:[e.jsx("label",{htmlFor:i,className:"text-body text-ink",children:n("ui.settings.appearance.window_glass.intensity_label")}),e.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(k)})})]}),e.jsx("p",{id:r,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n("ui.settings.appearance.window_glass.intensity_description")}),e.jsx("input",{id:i,type:"range",min:0,max:100,step:5,value:k,"aria-describedby":r,"aria-valuetext":n("ui.settings.appearance.window_glass.intensity_value",{value:String(k)}),onChange:b=>{const S=Number(b.target.value);l(S),_(S)},style:{"--fill":`${k}%`},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"}),e.jsxs("div",{"aria-hidden":"true",className:"mt-1 flex justify-between text-meta text-ink-dim",children:[e.jsx("span",{children:n("ui.settings.appearance.window_glass.intensity_start")}),e.jsx("span",{children:n("ui.settings.appearance.window_glass.intensity_end")})]})]}),e.jsx(Fs,{label:n("ui.settings.appearance.window_glass.material_label"),description:n("ui.settings.appearance.window_glass.material_description"),value:t.settings.material,onValueChange:b=>void s({material:b}),options:t.capability.materials.map(b=>({value:b,label:Xd(b)}))})]})]})},nu=new Set(["B","C","D","E","F"]);function su(t){const{status:s,refused:a,everVisible:i,checking:r=!1}=t;return s?s.update_required||s.state==="signed_out"?"absent":s.state==="unavailable"?s.error?.code==="messaging_unavailable"?"dark":i?"error":"absent":s.surface_state==="G"?s.error===null||s.error?.code==="messaging_unavailable"?"dark":"error":s.capability<1||s.state!=="ready"||!s.visibility.settings?"absent":s.surface_state&&nu.has(s.surface_state)?"visible":"absent":r&&i?"visible":a&&i?"error":"absent"}function au(t,s){return t!=="absent"}function mt(t,s){if(t.surface_state==="F")return"F";const a=s.endpoint;return a?a.state==="paused"?"D":a.state==="disabled"?"E":"C":"B"}const iu="open_chief_of_staff";function ru(t){const s=t?.delivery_hold;if(!s||s.code!==iu||s.count<=0)return null;const a=s.session||t?.local.session||null;return{count:s.count,sessionId:a}}function si(t){return Ki(t)}function ou(t){return t.target.endpoint_id?{kind:"endpoint",id:t.target.endpoint_id}:{kind:"account",id:t.target.account_id??""}}function Wn(t){return t.map((s,a)=>{const i=ou(s);return{key:`${s.direction}:${s.effect}:${i.kind}:${i.id}:${a}`,direction:s.direction,effect:s.effect,kind:i.kind,id:i.id}})}function Yn(t,s){return t.filter(i=>i.effect==="deny"||s[i.direction]==="listed_only").map(i=>({direction:i.direction,effect:i.effect,target:i.kind==="endpoint"?{endpoint_id:i.id}:{account_id:i.id}})).sort((i,r)=>i.direction.localeCompare(r.direction)||i.effect.localeCompare(r.effect)||JSON.stringify(i.target).localeCompare(JSON.stringify(r.target)))}function ai(t){return JSON.stringify(t)}function cu(t){return t.saving?{disabled:!0,reason:"saving"}:["send","receive"].some(i=>t.modes[i]==="listed_only"&&!t.entries.some(r=>r.direction===i&&r.effect==="allow"))?{disabled:!0,reason:"needs_entry"}:ai(Yn(t.entries,t.modes))===t.savedSignature?{disabled:!0,reason:"unchanged"}:{disabled:!1}}const lu=/^[^\s\p{Cc}]{1,128}$/u;function du(t){return t===""?n("ui.agentMessages.settings.allowlist.identifier_empty"):t.length>128?n("ui.agentMessages.settings.allowlist.identifier_long"):lu.test(t)?null:n("ui.agentMessages.settings.allowlist.identifier_invalid")}function Qt(t){switch(t.code){case"bridge_signin_required":return n("ui.agentMessages.settings.refusal.sign_in");case"bridge_not_available":return n("ui.agentMessages.settings.refusal.not_available");case"bridge_disabled":return n("ui.agentMessages.settings.refusal.disabled");case"rate_limited":return n("ui.agentMessages.settings.refusal.rate_limited");case"invalid_request":return n("ui.agentMessages.settings.refusal.invalid_request");case"consent_version_unknown":return n("ui.agentMessages.settings.consent.changed");case"messaging_unavailable":return n("ui.agentMessages.settings.dark.body");default:return t.message||n("ui.agentMessages.settings.refusal.generic")}}const uu=['[data-agent-messages-action="turn_on_again"]','[role="switch"]','[data-agent-messages-action="enable"]'],kn="__none__";function mu({availability:t,status:s,accountId:a,refusal:i=null,api:r=To,onRefreshStatus:c,sessions:l=[],onOpenSession:d,focus:u=!1,focusNonce:m}){te();const[p,g]=o.useState({kind:"loading"}),[_,x]=o.useState(0),[k,b]=o.useState(null),[S,I]=o.useState(null),[M,L]=o.useState(s?.local.enabled??!1),[E,O]=o.useState(s?.local.session??""),y=s?.tenant_id??void 0,F=t==="visible",K=s?.account_id??null,P=K!==null&&K===a;o.useEffect(()=>{if(!F)return;let h=!1;return g({kind:"loading"}),I(null),(async()=>{try{const R=await r.settings(y);if(h)return;if(!R){g({kind:"error",refusal:{code:"invalid_response",message:n("ui.agentMessages.settings.error.unreadable")}});return}let j=null;if(R.endpoint){if(j=await r.allowlist(R.settings.tenant_id),h)return;if(!j){g({kind:"error",refusal:{code:"invalid_response",message:n("ui.agentMessages.settings.error.unreadable")}});return}}g({kind:"ready",settings:R,allowlist:j})}catch(R){if(h)return;g({kind:"error",refusal:Fe(R)})}})(),()=>{h=!0}},[F,a,K,y,_,r]),o.useEffect(()=>{if(!F||p.kind!=="ready"||!p.settings.endpoint||p.allowlist)return;let h=!1;return(async()=>{try{const R=await r.allowlist(p.settings.settings.tenant_id);if(h||!R)return;g(j=>j.kind==="ready"&&!j.allowlist?{...j,allowlist:R}:j)}catch(R){h||I(Fe(R))}})(),()=>{h=!0}},[F,p,r]),o.useEffect(()=>{s&&(L(s.local.enabled),O(s.local.session))},[s]);const f=()=>x(h=>h+1),A=p.kind==="ready"?p.settings:null,T=bc(s,A,K),v=vc({api:r,accountId:P?K:null,tenantId:A?.settings.tenant_id??null,markerTenantId:s?.tenant_id??null,onSettings:h=>g(R=>R.kind==="ready"?{...R,settings:h}:R),onChanged:()=>c(!0)}),H=o.useRef(null),z=o.useRef(!1),q=o.useRef(m);if(o.useEffect(()=>{m!==q.current&&(q.current=m,z.current=!1)},[m]),o.useEffect(()=>{if(!u){z.current=!1;return}if(z.current||p.kind!=="ready"||k!==null)return;const h=H.current,R=uu.map(j=>h?.querySelector(`${j}:not(:disabled)`)).find(j=>j!=null);R&&(R.focus(),z.current=!0)},[u,m,p,k,s]),t==="absent")return null;if(t==="dark")return e.jsxs("div",{"data-agent-messages-section":"",className:"flex flex-col gap-2",children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.agentMessages.settings.dark.title")}),e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.dark.body")}),e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.dark.nothing_enabled")})]});if(t==="error")return e.jsx("div",{"data-agent-messages-section":"",children:e.jsxs(me,{variant:"warning",children:[e.jsx(an,{children:n("ui.agentMessages.settings.error.title")}),e.jsxs(Oe,{children:[i?Qt(i):n("ui.agentMessages.settings.refusal.generic"),e.jsx(D,{className:"mt-3",variant:"secondary",onClick:()=>{f(),c(!0)},children:n("ui.agentMessages.settings.error.retry")})]})]})});if(!s||!a)return null;const Z=ru(s);return e.jsxs("div",{ref:H,"data-agent-messages-section":"",className:"flex flex-col gap-6",children:[Z&&e.jsx(pu,{count:Z.count,onMessage:Z.sessionId&&d?()=>d(Z.sessionId):void 0}),T&&e.jsx(kc,{consentText:Bi(s,A),pending:v.pending,failure:v.failure,onTurnOff:()=>void v.turnOff(),onDismiss:()=>void v.dismiss()}),S&&e.jsx(me,{variant:"warning",children:e.jsx(Oe,{children:Qt(S)})}),p.kind==="loading"&&e.jsx(gu,{}),p.kind==="error"&&e.jsxs(me,{variant:"warning",children:[e.jsx(an,{children:n("ui.agentMessages.settings.error.title")}),e.jsxs(Oe,{children:[p.refusal.code!=="client_unavailable"&&e.jsx("span",{className:"block",children:Qt(p.refusal)}),e.jsx("span",{className:"block",children:n("ui.agentMessages.settings.error.no_changes")}),e.jsx(D,{className:"mt-3",variant:"secondary",onClick:f,children:n("ui.agentMessages.settings.error.retry")})]})]}),p.kind==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx(_u,{state:mt(s,p.settings),status:s,settings:p.settings,accountId:K??a,accountMatches:P,api:r,pending:k,localEnabled:M,onActionRefusal:I,onSettings:h=>g(R=>R.kind==="ready"?{...R,settings:h}:R),onLocalEnabled:L,onRefreshStatus:c,setPending:b}),e.jsx(yu,{value:E,sessions:l,pending:k==="session",disabled:k!==null,onSave:async h=>{b("session"),I(null);try{await r.localSetting("team_bridge.session",h),O(h),await c(!0)}catch(R){I(Fe(R))}finally{b(null)}}}),p.allowlist&&(mt(s,p.settings)==="C"||mt(s,p.settings)==="D"||mt(s,p.settings)==="F")&&e.jsx(bu,{allowlist:p.allowlist,accountId:K??a,accountMatches:P,readOnly:s.read_only===!0&&mt(s,p.settings)==="F",pending:k!==null,onSaving:h=>b(h?"allowlist":null),onRefusal:I,onSaved:h=>g(R=>R.kind==="ready"?{...R,allowlist:h}:R),api:r},p.allowlist.view.tenant_id??"tenant")]})]})}function gu(){return e.jsxs("div",{className:"flex flex-col gap-3","aria-busy":"true",children:[e.jsx(Ae,{className:"h-5 w-40"}),e.jsx(Ae,{className:"h-4 w-full max-w-xl"}),e.jsx(Ae,{className:"h-9 w-36"}),e.jsx(Ae,{className:"h-4 w-64"})]})}const pu=({count:t,onMessage:s})=>e.jsx("output",{className:"block","data-agent-messages-hold":"open_chief_of_staff",children:e.jsx(me,{variant:"info",className:ge(Lo,"border-transparent"),children:e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-3",children:[e.jsx("p",{className:"min-w-0 flex-1 text-body-sm text-ink",children:s?n("ui.agentMessages.settings.hold.chief_of_staff",{count:t}):n("ui.agentMessages.settings.hold.chief_of_staff_unlinked",{count:t})}),s&&e.jsx(D,{variant:"ghost",size:"sm",className:"shrink-0 text-ink",onClick:s,children:n("ui.agentMessages.settings.hold.open")})]})})}),zs=({text:t})=>e.jsx("div",{className:"rounded-md border border-hairline bg-sunken p-3",children:e.jsx("p",{className:"whitespace-pre-wrap text-body-sm text-ink-muted",children:t})}),ii={B:"ui.agentMessages.settings.state.b_title",C:"ui.agentMessages.settings.state.c_title",D:"ui.agentMessages.settings.state.d_title",E:"ui.agentMessages.settings.state.e_title",F:"ui.agentMessages.settings.state.f_title"},ri={B:"ui.agentMessages.settings.state.b_body",C:"ui.agentMessages.settings.state.c_body",D:"ui.agentMessages.settings.state.d_body",E:"ui.agentMessages.settings.state.e_body",F:"ui.agentMessages.settings.state.f_body"};function hu(t){return t==="B"?"ui.agentMessages.settings.default_on.b_title":ii[t]}function fu(t){return t==="B"?"ui.agentMessages.settings.default_on.b_body":t==="E"?"ui.agentMessages.settings.default_on.e_body":ri[t]}const _u=({state:t,status:s,settings:a,accountId:i,accountMatches:r,api:c,pending:l,localEnabled:d,onActionRefusal:u,onSettings:m,onLocalEnabled:p,onRefreshStatus:g,setPending:_})=>{const x=si(s),k=a.settings.tenant_id,b=l!==null||!r,S=Hi(s);async function I(y,F={}){if(!r)return null;_(y),u(null);try{const K=await c.updateSettings({expected_account_id:i,tenant_id:k,state:y,...F});if(m(K),y==="disabled"&&!S)try{await c.localSetting("team_bridge.enabled",!1),p(!1)}catch(P){u(Fe(P))}return K}catch(K){const P=Fe(K);return u(P),P.code==="consent_version_unknown"&&await g(!0),null}finally{_(null)}}async function M(){if(!(!x||!r||!await I("active",{consent_version:x.version,consented_via:"settings"}))){_("local");try{await c.localSetting("team_bridge.enabled",!0),p(!0),await g(!0)}catch(F){u(Fe(F))}finally{_(null)}}}if(t==="F")return e.jsxs("div",{"data-agent-messages-state":t,className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"rounded-md border border-hairline bg-sunken p-3",children:[e.jsx("p",{className:"text-body-sm text-ink",children:s.state_note?.trim()?s.state_note:n("ui.agentMessages.settings.state.turned_off_title")}),e.jsx("p",{className:"mt-1 text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.state.turned_off_org")})]}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.state.read_only")}),e.jsx(jn,{settings:a,status:s,readOnly:!0}),e.jsx(wn,{searchRow:"agent-messages.enabled",searchTerms:"team bridge team_bridge enabled devices",value:d,disabled:b,description:n("ui.agentMessages.settings.local.stays_enrolled"),onChange:async y=>{_("local"),u(null);try{await c.localSetting("team_bridge.enabled",y),p(y),await g(!0)}catch(F){u(Fe(F))}finally{_(null)}}})]});const L=a.endpoint?.label?.trim(),E=a.endpoint?.consent??null,O=E!==null&&!E.current;return e.jsxs("div",{"data-agent-messages-state":t,className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-heading text-ink",children:n(S?hu(t):ii[t])}),L&&e.jsx("span",{className:"text-body-sm text-ink-muted",children:L})]}),e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted",children:n(S?fu(t):ri[t])}),S&&t==="E"&&e.jsxs("div",{className:"flex flex-col gap-3",children:[x?e.jsx(zs,{text:x.text}):e.jsx(me,{variant:"warning",children:e.jsx(Oe,{children:n("ui.agentMessages.settings.consent.unavailable")})}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx(D,{"data-agent-messages-action":"turn_on_again","data-search-row":"agent-messages.enabled","data-search-control":!0,onClick:()=>void M(),disabled:b||!x,children:n("ui.agentMessages.settings.action.turn_on_again")})})]}),!S&&(t==="B"||t==="E")&&e.jsxs("div",{className:"flex flex-col gap-3",children:[x?e.jsx(zs,{text:x.text}):e.jsx(me,{variant:"warning",children:e.jsx(Oe,{children:n("ui.agentMessages.settings.consent.unavailable")})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(D,{"data-agent-messages-action":"enable","data-search-row":"agent-messages.enabled","data-search-control":!0,onClick:()=>void M(),disabled:b||!x,children:t==="B"?n("ui.agentMessages.settings.action.enable"):n("ui.agentMessages.settings.action.enable_again")}),e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.agentMessages.settings.off_by_default")})]})]}),t==="C"&&a.endpoint&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(D,{"data-agent-messages-action":"pause",variant:"secondary",disabled:b,onClick:()=>void I("paused"),children:n("ui.agentMessages.settings.action.pause")}),e.jsx(D,{"data-agent-messages-action":"turn_off",variant:"secondary",disabled:b,onClick:()=>void I("disabled"),children:n("ui.agentMessages.settings.action.turn_off")})]}),e.jsx(jn,{settings:a,status:s}),O&&!S&&e.jsx(Ps,{onRenew:()=>void M(),disabled:b||!x}),e.jsx(wn,{searchRow:"agent-messages.enabled",searchTerms:"team bridge team_bridge enabled devices",value:d,disabled:b,description:n("ui.agentMessages.settings.local.stays_enrolled"),onChange:async y=>{_("local"),u(null);try{await c.localSetting("team_bridge.enabled",y),p(y),await g(!0)}catch(F){u(Fe(F))}finally{_(null)}}})]}),t==="D"&&a.endpoint&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(D,{"data-agent-messages-action":"resume",disabled:b||a.settings.consent_required&&x===null,onClick:()=>void I("active",a.settings.consent_required&&x?{consent_version:x.version,consented_via:"settings"}:{}),children:n("ui.agentMessages.settings.action.resume")}),e.jsx(D,{"data-agent-messages-action":"turn_off",variant:"secondary",disabled:b,onClick:()=>void I("disabled"),children:n("ui.agentMessages.settings.action.turn_off")})]}),a.settings.consent_required&&!x&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.consent.unavailable")}),e.jsx(jn,{settings:a,status:s}),O&&!S&&e.jsx(Ps,{onRenew:()=>void M(),disabled:b||!x}),e.jsx(wn,{searchRow:"agent-messages.enabled",searchTerms:"team bridge team_bridge enabled devices",value:d,disabled:b,description:n("ui.agentMessages.settings.local.stays_enrolled"),onChange:async y=>{_("local"),u(null);try{await c.localSetting("team_bridge.enabled",y),p(y),await g(!0)}catch(F){u(Fe(F))}finally{_(null)}}})]})]})},Ps=({onRenew:t,disabled:s})=>e.jsx(me,{variant:"warning",children:e.jsxs(Oe,{children:[n("ui.agentMessages.settings.consent.renew"),e.jsx(D,{"data-agent-messages-action":"enable",className:"mt-3",variant:"secondary",disabled:s,onClick:t,children:n("ui.agentMessages.settings.action.enable_again")})]})});function xu(t){switch(t){case"dialog":return n("ui.agentMessages.settings.consent.via_dialog");case"settings":return n("ui.agentMessages.settings.consent.via_settings");case"default_on":return n("ui.agentMessages.settings.consent.via_default_on");default:return t}}const jn=({settings:t,status:s,readOnly:a=!1})=>{const i=t.endpoint?.consent??null,r=si(s);return i?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs(Mt,{children:[e.jsx(ke,{label:n("ui.agentMessages.settings.consent.version"),value:i.version}),e.jsx(ke,{label:n("ui.agentMessages.settings.consent.via"),value:xu(i.consented_via)}),e.jsx(ke,{label:n("ui.agentMessages.settings.consent.at"),value:i.consented_at})]}),!a&&r&&e.jsxs("details",{children:[e.jsx("summary",{className:"cursor-pointer text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.consent.show")}),e.jsx("p",{className:"mt-2 whitespace-pre-wrap text-body-sm text-ink-muted",children:r.text})]})]}):e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.consent.no_record")})},wn=({value:t,disabled:s,description:a,onChange:i,searchRow:r,searchTerms:c})=>{const l=o.useId();return e.jsxs("div",{"data-search-row":r,"data-search-control":r?"":void 0,"data-search-terms":c,className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{id:l,className:"text-body-sm text-ink",children:n("ui.agentMessages.settings.local.label")}),e.jsx("p",{className:"mt-0.5 text-meta text-ink-dim",children:a})]}),e.jsx(Ga,{"aria-labelledby":l,checked:t,disabled:s,onCheckedChange:d=>void i(d)})]})},yu=({value:t,sessions:s,pending:a,disabled:i,onSave:r})=>{const c=s.some(l=>l.session_id===t);return e.jsxs("div",{"data-search-row":"agent-messages.session","data-search-control":!0,"data-search-terms":"team bridge team_bridge session",className:"flex flex-col gap-2",children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.agentMessages.settings.session.title")}),e.jsx("p",{className:"max-w-2xl text-meta text-ink-dim",children:n("ui.agentMessages.settings.session.help")}),e.jsxs(ds,{value:t===""?kn:t,disabled:i,onValueChange:l=>void r(l===kn?"":l),children:[e.jsx(us,{className:"w-full max-w-md","aria-label":n("ui.agentMessages.settings.session.title"),children:e.jsx(ms,{})}),e.jsxs(gs,{children:[e.jsx(nt,{value:kn,children:n("ui.agentMessages.settings.session.none")}),s.map(l=>e.jsx(nt,{value:l.session_id,children:l.title?.trim()||l.session_id},l.session_id)),t!==""&&!c&&e.jsx(nt,{value:t,children:t})]})]}),t!==""&&!c&&e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.agentMessages.settings.session.unavailable")}),a&&e.jsx("p",{className:"text-meta text-ink-dim","aria-live":"polite",children:n("ui.agentMessages.settings.saving")})]})},bu=({allowlist:t,accountId:s,accountMatches:a,readOnly:i,pending:r,api:c,onSaving:l,onRefusal:d,onSaved:u})=>{const[m,p]=o.useState(()=>Wn(t.allowlist.entries)),[g,_]=o.useState(()=>({send:t.view.directions.send.mode,receive:t.view.directions.receive.mode})),x=r||i||!a,k=ai(Yn(vu(t),ku(t))),b=cu({entries:m,modes:g,savedSignature:k,saving:r}),S=o.useRef(0),I=E=>p(O=>[...O,{...E,key:`${E.direction}:${E.effect}:${S.current++}`}]),M=E=>p(O=>O.filter(y=>y.key!==E)),L=async()=>{if(!x){l(!0),d(null);try{const E=await c.updateAllowlist({expected_account_id:s,tenant_id:t.allowlist.tenant_id,entries:Yn(m,g)}),O=Wn(E.allowlist.entries);p(O),_({send:E.view.directions.send.mode,receive:E.view.directions.receive.mode}),u(E)}catch(E){d(Fe(E))}finally{l(!1)}}};return e.jsxs("div",{"data-agent-messages-allowlist":"",className:"flex flex-col gap-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.agentMessages.settings.allowlist.title")}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.allowlist.description")})]}),e.jsx($s,{direction:"receive",title:n("ui.agentMessages.settings.allowlist.receive"),mode:g.receive,cues:t.view.cues,entries:m.filter(E=>E.direction==="receive"),disabled:x,onMode:E=>_(O=>({...O,receive:E})),onAdd:E=>I({...E,direction:"receive"}),onRemove:M}),e.jsx($s,{direction:"send",title:n("ui.agentMessages.settings.allowlist.send"),mode:g.send,cues:t.view.cues,entries:m.filter(E=>E.direction==="send"),disabled:x,onMode:E=>_(O=>({...O,send:E})),onAdd:E=>I({...E,direction:"send"}),onRemove:M}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(D,{onClick:()=>void L(),disabled:b.disabled||x,children:[e.jsx(qa,{size:14}),n("ui.agentMessages.settings.allowlist.save")]}),b.disabled&&b.reason==="needs_entry"&&e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.agentMessages.settings.allowlist.needs_entry")}),b.disabled&&b.reason==="unchanged"&&e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.agentMessages.settings.allowlist.unchanged")}),i&&e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.agentMessages.settings.allowlist.read_only")}),r&&e.jsx("span",{className:"text-meta text-ink-dim","aria-live":"polite",children:n("ui.agentMessages.settings.saving")})]})]})};function vu(t){return Wn(t.allowlist.entries)}function ku(t){return{send:t.view.directions.send.mode,receive:t.view.directions.receive.mode}}const $s=({direction:t,title:s,mode:a,cues:i,entries:r,disabled:c,onMode:l,onAdd:d,onRemove:u})=>{const m=r.filter(g=>g.effect==="allow"),p=r.filter(g=>g.effect==="deny");return e.jsxs("fieldset",{"data-agent-messages-direction":t,"data-agent-messages-level":a,className:"flex flex-col gap-3 rounded-md border border-hairline p-3",children:[e.jsx("legend",{className:"px-1 text-body-sm text-ink",children:s}),e.jsx(ju,{mode:a,disabled:c,onMode:l}),e.jsxs("div",{className:"flex flex-col gap-1 text-meta text-ink-dim",children:[i.allow_entry_switches_direction_to_listed_only&&e.jsx("p",{children:n("ui.agentMessages.settings.allowlist.cue_listed_only")}),i.removing_allow_does_not_stop_open_thread&&e.jsx("p",{children:n("ui.agentMessages.settings.allowlist.cue_remove")}),i.deny_stops_pair_both_directions&&e.jsx("p",{children:n("ui.agentMessages.settings.allowlist.cue_deny")})]}),a==="listed_only"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.agentMessages.settings.allowlist.allowed_heading")}),m.length===0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.allowlist.allowed_empty")}),m.map(g=>e.jsx(Us,{entry:g,disabled:c,onRemove:()=>u(g.key)},g.key)),e.jsx(Ks,{label:n("ui.agentMessages.settings.allowlist.add_allowed"),disabled:c,onAdd:g=>d({...g,effect:"allow"})})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.agentMessages.settings.allowlist.blocked_heading")}),p.length===0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.allowlist.blocked_empty")}),p.map(g=>e.jsx(Us,{entry:g,disabled:c,onRemove:()=>u(g.key)},g.key)),e.jsx(Ks,{label:n("ui.agentMessages.settings.allowlist.add_blocked"),disabled:c,onAdd:g=>d({...g,effect:"deny"})})]})]})},ju=({mode:t,disabled:s,onMode:a})=>{const i=[{value:"class_default",label:n("ui.agentMessages.settings.allowlist.anyone")},{value:"listed_only",label:n("ui.agentMessages.settings.allowlist.listed_only")}];return e.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:n("ui.agentMessages.settings.allowlist.level")}),e.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:i.map(r=>e.jsx(D,{variant:"ghost",size:"sm","aria-pressed":t===r.value,disabled:s,onClick:()=>a(r.value),className:ge(t===r.value&&"bg-surface text-ink hover:bg-surface"),children:r.label},r.value))})]})},Us=({entry:t,disabled:s,onRemove:a})=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded border border-hairline px-2 py-1",children:[e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:t.kind==="endpoint"?n("ui.agentMessages.settings.allowlist.agent_id"):n("ui.agentMessages.settings.allowlist.person_id")}),e.jsx("span",{className:"break-all font-mono text-body-sm text-ink",children:t.id})]}),e.jsx(D,{variant:"secondary",size:"sm",disabled:s,"aria-label":`${n("ui.agentMessages.settings.allowlist.remove")} ${t.id}`,onClick:a,children:n("ui.agentMessages.settings.allowlist.remove")})]}),Ks=({label:t,disabled:s,onAdd:a})=>{const[i,r]=o.useState("endpoint"),[c,l]=o.useState(""),[d,u]=o.useState(null),m=o.useId(),p=`${m}-help`,g=()=>{const _=du(c.trim());u(_),!_&&(a({kind:i,id:c.trim()}),l(""))};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(De,{htmlFor:m,children:t}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(ds,{value:i,disabled:s,onValueChange:_=>r(_),children:[e.jsx(us,{className:"w-32","aria-label":n("ui.agentMessages.settings.allowlist.kind"),children:e.jsx(ms,{})}),e.jsxs(gs,{children:[e.jsx(nt,{value:"endpoint",children:n("ui.agentMessages.settings.allowlist.kind_agent")}),e.jsx(nt,{value:"account",children:n("ui.agentMessages.settings.allowlist.kind_person")})]})]}),e.jsx(Ne,{id:m,"aria-describedby":p,className:"max-w-xs",value:c,disabled:s,placeholder:n("ui.agentMessages.settings.allowlist.identifier"),onChange:_=>l(_.target.value),onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),g())}}),e.jsx(D,{variant:"secondary",size:"sm",disabled:s,onClick:g,children:n("ui.agentMessages.settings.allowlist.add")})]}),e.jsx("p",{id:p,className:"text-meta text-ink-dim",children:i==="endpoint"?n("ui.agentMessages.settings.allowlist.identifier_help_agent"):n("ui.agentMessages.settings.allowlist.identifier_help_person")}),d&&e.jsx("p",{className:"text-meta text-danger",children:d})]})};function wu(){const{snapshot:t}=Ha(),[s,a]=o.useState(!1),i=su({status:t.status,refused:t.refusal!==null,everVisible:s,checking:t.checking});return o.useEffect(()=>{i!=="absent"&&a(!0)},[i]),o.useEffect(()=>{Ro()},[]),i}function hs(t){const s=a=>typeof a=="string"?vt(a):vt((a??[]).join(" "));return{label:s(t.label),synonym:s(t.synonym),key:s(t.key),choice:s(t.choice),section:s(t.section),description:s(t.description)}}function Nu(t){const s=new Map;for(const a of t??[])s.set(a.name,{label:a.title||a.name,folded:vt([a.title,a.name].join(" "))});return s}function Su(t,s={}){if(!t)return[];const{startOrder:a=0,sections:i=[]}=s,r=Nu(t.sections),c=new Map(i.map(l=>[l.id,l.label]));return t.settings.map((l,d)=>{const u=r.get(l.section),m=Bt(l.key,"backend");return{id:`setting:${l.key}`,source:"registry",label:l.label||l.key,description:l.help??"",sectionId:m,sectionLabel:c.get(m)??"",detail:u?.label??l.section,order:a+d,settingKey:l.key,fields:hs({label:l.label,synonym:l.synonyms??[],key:l.key,choice:(l.choices??[]).flatMap(p=>[p.label,p.description??""]),section:u?.folded??l.section,description:l.help})}})}function Cu(t,s=0){return t.map((a,i)=>({id:`section:${a.id}`,source:"section",label:a.label,sectionId:a.id,sectionLabel:a.label,order:s+i,fields:hs({label:a.label})}))}function Mu(t){const s=t.getAttribute("data-search-label");if(s?.trim())return s.trim();const a=t.querySelector("[data-search-label]");if(a?.textContent?.trim())return a.textContent.trim();const i=t.querySelector("h2, h3, h4, legend");if(i?.textContent?.trim())return i.textContent.trim();const r=t.getAttribute("aria-label");return r?.trim()?r.trim():((t.firstElementChild??t).textContent??"").trim()}function Au(t){const s=t.replace(/\s+/g," ").trim();if(s.length<=80)return s;const a=s.slice(0,80),i=a.lastIndexOf(" ");return`${(i>40?a.slice(0,i):a).trimEnd()}…`}function Eu(t){return t.closest("[data-search-section]")}function Iu(t,s){const a=(t.textContent??"").trim();if(!s)return a;const i=a.indexOf(s);return i<0?a:`${a.slice(0,i)} ${a.slice(i+s.length)}`.trim()}function Ru(t,s=0){return Array.from(t.querySelectorAll("[data-search-row]")).map((i,r)=>{const c=Eu(i),l=c?.getAttribute("data-search-section")??"",u=(c?.getAttribute("data-search-section-label")?.trim()??"")||c?.querySelector("[data-search-section-label], h2")?.textContent?.trim()||"",m=Mu(i),p=i.getAttribute("data-search-terms")??"",g=Iu(i,m);return{id:`page:${i.getAttribute("data-search-row")??r}`,source:"page",label:Au(m),sectionId:l,sectionLabel:u,order:s+r,fields:hs({label:m,synonym:p,section:[u,l],description:g})}})}function Tu(t){const s=Su(t.registry,{startOrder:0,sections:t.sections}).filter(i=>!(i.settingKey&&i.settingKey in Mr)),a=[...t.rendered??[]].map((i,r)=>({...i,order:s.length+r}));return[...s,...a,...Cu(t.sections??[],s.length+a.length)]}const Lu=12,Bs="input, textarea, select, button, [role='switch'], [role='tab'], [role='combobox'], [tabindex]";function Ou(t,s){return t.querySelector(`[data-search-row="${CSS.escape(s)}"]`)}function Du(t){const a=(t.matches("[data-search-control]")?t:null)??t.querySelector("[data-search-control]");return a?a.matches(Bs)?a:a.querySelector(Bs)??a:t}function oi(t){return t.isConnected&&t.closest("[hidden]")===null}function Fu(t,s,a={}){const i=a.frames??Lu,r=a.paint??Ra;return new Promise(c=>{let l=0;const d=()=>{const u=Ou(t,s);if(u&&oi(u)){const m=Du(u);m===u&&(u.tabIndex=-1),m.scrollIntoView({block:"center"}),m.focus(),r(u),c("landed");return}if(l+=1,l>=i){c("missing");return}requestAnimationFrame(d)};requestAnimationFrame(d)})}function zu(t,s,a={}){const i=t.querySelector(`[data-search-section="${CSS.escape(s)}"]`);return!i||!oi(i)?"missing":(i.scrollIntoView({block:"start"}),i.tabIndex<0&&(i.tabIndex=-1),i.focus(),(a.paint??Ra)(i),"landed")}const Hs={get[Ke.UI](){return n("ui.settings.updates.update_following.application_updates")},get[Ke.BACKEND](){return n("ui.settings.updates.update_following.server_updates")}},Dt={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")}}},qs=({type:t})=>{te();const s=Pn(i=>i.followed[t]),a=Pn(i=>i.setFollowedSegment);return e.jsxs("div",{className:"flex flex-col gap-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-body-sm text-ink",children:Hs[t]}),e.jsx("div",{className:"mt-0.5 text-meta text-ink-muted",children:Dt[s].description})]}),e.jsxs(ds,{value:s,onValueChange:i=>a(t,i),children:[e.jsx(us,{"aria-label":n("ui.settings.updates.update_following.surface_choice",{surface:Hs[t],choice:Dt[s].label}),className:"w-full sm:w-56","data-followed-segment":t,children:e.jsx(ms,{})}),e.jsx(gs,{children:Ar.map(i=>e.jsx(nt,{value:i,title:Dt[i].description,children:Dt[i].label},i))})]})]})},Pu=()=>(te(),e.jsxs("div",{className:ge("flex flex-col gap-3"),children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.updates.update_following.update_notifications")}),e.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")})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(qs,{type:Ke.UI}),e.jsx(qs,{type:Ke.BACKEND})]})]})),$u=({appVersion:t})=>e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Pu,{}),e.jsx(Bd,{appVersion:t})]}),Uu=t=>{if(!t)return null;try{return new URL(t).host}catch{return null}},Ku=()=>{te();const[t,s]=o.useState(null),[a,i]=o.useState({value:"Loading...",detail:null,degraded:!1}),[r,c]=o.useState({platform:"Loading...",arch:"...",nodeVersion:"Loading...",electronVersion:"Loading...",chromeVersion:"Loading..."});o.useEffect(()=>{let d=!0;const u=x=>{if(!d)return;const k=Uu(x.url);if(x.state==="connecting"){i({value:"Loading...",detail:null,degraded:!1});return}if(x.state==="detached"){i({value:"Not connected",detail:x.detail||null,degraded:!1});return}if(x.state==="wedged"){i({value:"Not attached",detail:x.detail||null,degraded:!1});return}const b=x.version||"Version unknown";i({value:k?`${b} · ${k}`:b,detail:x.detail||null,degraded:x.state==="degraded"})};let m=!1;const p=window.api?.backend?.onStatusChange(x=>{m=!0,u(x)}),g=async()=>{try{const[x,k]=await Promise.all([window.api.systemInfo.getAppVersion(),window.api.systemInfo.getPlatformInfo()]);d&&(s(x),c(k))}catch(x){console.error("Error fetching app information:",x)}},_=async()=>{try{const x=window.api?.backend;if(x){const S=await x.getStatus();m||u(S);return}const k=await As.healthCheck(ns.baseUrl),b=As.getServerVersion(k);d&&i({value:b,detail:null,degraded:!1})}catch(x){console.error("Error fetching server version:",x),d&&i({value:"Unavailable",detail:null,degraded:!1})}};return g(),_(),()=>{d=!1,p?.()}},[]);const l=(d,u,m,p={})=>e.jsx(ke,{label:e.jsx(Pe,{content:m,children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(rn,{size:12,className:"shrink-0"}),d]})}),valueClassName:p.valueClassName,value:e.jsxs(e.Fragment,{children:[p.valueTooltip?e.jsx(Pe,{content:p.valueTooltip,children:e.jsx("span",{"data-backend-version":p.valueHoverTarget?"":void 0,children:u})}):u,p.statusNote?e.jsx("span",{className:"mt-0.5 block text-meta text-ink-dim",children:p.statusNote}):null]})});return e.jsx(ye,{title:n("ui.settings.updates.app_updates_section.application_updates_and_info"),icon:$n,description:n("ui.settings.updates.app_updates_section.check_for_updates_and_view_information_about_your_local_operator_"),dataTourTag:"settings-app-updates-section",children:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs(Mt,{children:[l(n("ui.settings.updates.app_updates_section.application_version"),t??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")),l(n("ui.settings.updates.app_updates_section.server_version"),yn(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}),l(n("ui.settings.updates.app_updates_section.platform"),`${r.platform} (${r.arch})`,n("ui.settings.updates.app_updates_section.the_operating_system_and_architecture_your_application_is_running")),l(n("ui.settings.updates.app_updates_section.node_js_version"),yn(r.nodeVersion),n("ui.settings.updates.app_updates_section.the_javascript_runtime_environment_version")),l(n("ui.settings.updates.app_updates_section.electron_version"),yn(r.electronVersion),n("ui.settings.updates.app_updates_section.the_framework_version_enabling_this_desktop_application"))]}),e.jsx($u,{appVersion:t})]})})};function ci(t){const s={id:"",name:n("ui.settings.model.default_effort.model_default")};return t.resolvedLevel&&t.stored.trim()===""&&fs(t.resolvedLevel,t.storable)!==null&&(s.description=n("ui.settings.model.default_effort.model_default_resolves",{level:We(t.resolvedLevel)})),[s,...li(t.ladder,t.storable)]}function fs(t,s){const a=t.trim().toLowerCase();return a===""?null:s.find(i=>i.trim().toLowerCase()===a)??null}function li(t,s){return t.flatMap(a=>{const i=fs(a,s);return i===null?[]:[{id:i,name:We(a)}]})}function Bu(t,s){const a=t.trim().toLowerCase();return a!==""&&s.some(i=>i.toLowerCase()===a)?s.find(i=>i.toLowerCase()===a)??"":""}function Hu(t){if(!t.resolved||t.ladder===null)return null;const s=t.stored.trim().toLowerCase();if(s===""||t.ladder.some(r=>r.toLowerCase()===s))return null;const a=(t.resolvedLevel??"").trim(),i=a===""?"":fs(a,t.storable)??"";return i.trim().toLowerCase()===s?null:i}const Zt="\0unread";function Ft(t){return t.trim()===""?"":Zt}function qu(t){if(!t.supported)return{kind:"unsupported",options:[],selectedId:"",disabled:!0,helper:""};if(!t.hasHome)return Ue("no-home",n("ui.settings.model.default_effort.no_home"));if(!t.hasModel)return Ue("no-model",n("ui.settings.model.default_effort.no_model"),Zt);if(t.settings==="loading")return Ue("settings-loading",n("ui.settings.model.default_effort.settings_loading"),Zt);if(t.settings==="error")return Ue("settings-error",n("ui.settings.model.default_effort.settings_error"),Zt);if(t.preview==="loading")return Ue("loading",n("ui.settings.model.default_effort.loading"),Ft(t.stored));if(t.preview==="error")return Ue("error",n("ui.settings.model.default_effort.error"),Ft(t.stored));if(t.ladder===null||!t.specResolved)return Ue("unresolved",n("ui.settings.model.default_effort.unresolved"),Ft(t.stored));const s=t.ladder;if(s.length===0)return Ue("empty",n("ui.settings.model.default_effort.empty"),Ft(t.stored));const a=li(s,t.storable);if(a.length===0){const i=We(s[0]),r=s.length===1&&s[0].trim().toLowerCase()==="auto";return{kind:"one-level",options:[{id:"",name:i}],selectedId:"",disabled:!0,helper:r?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:ci({ladder:s,resolvedLevel:t.resolvedLevel,stored:t.stored,storable:t.storable}),selectedId:Bu(t.stored,a.map(i=>i.id)),disabled:!1,helper:n("ui.settings.model.default_effort.helper_ready")}}function Ue(t,s,a=""){return{kind:t,options:ci({ladder:[],resolvedLevel:null,stored:"",storable:[]}),selectedId:a,disabled:!0,helper:s}}const Vu=({hosting:t,modelName:s,focus:a=!1,focusNonce:i})=>{te();const r=Ct(),c=at(r.data,"draft_preview"),l=Er(),d=t!==""&&s!=="",u=Te({queryKey:nn.all,queryFn:()=>je({op:"settings.list"}),enabled:c,staleTime:1e4}),m=u.data?.settings.find(ce=>ce.key===et),p=typeof m?.value=="string"?m.value:"",g=(m?.choices??[]).map(ce=>ce.value).filter(ce=>typeof ce=="string"),_={cwd:l??"",model:d?{provider:t,model_id:s,reasoning_effort:null}:null},x=u.isSuccess?p:null,k=Te({...Vi(_,at(r.data,"draft_fast")),queryKey:[...qi(_),"model_effort",x],enabled:c&&!!l&&d}),b=k.isSuccess&&!k.isPlaceholderData,S=b?Gi(k.data?.snapshot,null).effort:null,I=b&&Array.isArray(S?.reasoning_efforts)?Wi(S):null,M=b?Yi(S):null,L=S!==null&&!Qi(S),[E,O]=o.useState(!1),[y,F]=o.useState(!1),[K,P]=o.useState(null),[f,A]=o.useState(null),T=`${t}\0${s}`,v=St(),H=o.useRef(null),z=o.useRef(!1),q=o.useRef(i);o.useEffect(()=>{i!==q.current&&(q.current=i,z.current=!1)},[i]);const Z=o.useCallback(async(ce,de)=>{O(!0),P(ce),F(!1),de===null&&A(null);try{await je({op:"settings.edit",key:et,value:ce}),await v.invalidateQueries({queryKey:nn.all}),de!==null&&A(de)}catch{F(!0)}finally{O(!1),P(null)}},[v]),h=typeof S?.display_name=="string"&&S.display_name.trim()||s,R=qu({supported:c,hasHome:!!l,hasModel:d,settings:u.isError?"error":u.isSuccess?"ready":"loading",preview:k.isError?"error":b?"ready":"loading",ladder:I,specResolved:L,stored:p,resolvedLevel:M,storable:g}),j=Hu({stored:p,ladder:I,resolvedLevel:M,resolved:b&&L&&u.isSuccess,storable:g}),U=o.useRef(null);o.useEffect(()=>{if(j===null||E)return;const ce=`${t}\0${s}\0${p}\0${j}`;if(U.current===ce)return;U.current=ce;const de=j===""?n("ui.settings.model.default_effort.clamped_unset",{level:We(p),model:h}):n("ui.settings.model.default_effort.clamped",{level:We(p),model:h,resolved:We(j)});Z(j,{text:de,model:T})},[j,p,E,Z,t,s,h,T]);const ne=o.useMemo(()=>R.options.map(Gu),[R.options]);o.useEffect(()=>{if(!a){z.current=!1;return}R.disabled||z.current||(H.current?.querySelector("[role=combobox]")?.focus(),z.current=!0)},[a,i,R.disabled]);const Y=K??R.selectedId,X=ne.find(ce=>ce.id===Y)??(K!==null?{id:K,name:We(K)}:null),re=e.jsxs("span",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{children:R.helper}),y&&e.jsx("span",{className:"text-danger",children:n("ui.settings.model.default_effort.save_failed")}),e.jsx("output",{"aria-live":"polite",children:f?.model===T?f.text:""})]});return R.kind==="unsupported"?null:e.jsx("div",{ref:H,"data-setting-key":et,children:e.jsx(Wa,{label:n("ui.settings.model.default_effort.label"),icon:e.jsx(Oo,{size:16,"aria-hidden":"true"}),placeholder:n("ui.settings.model.default_effort.placeholder"),options:ne,selected:X,onSelect:ce=>{Z(ce.id,null)},helperText:re,busy:E,busyLabel:n("ui.settings.model.default_effort.busy"),disabled:R.disabled||E})})};function Gu(t){return{id:t.id,name:t.name,description:t.description}}const Wu=t=>t.replace(/[\p{Co}\p{Cc}]/gu," ").replace(/\s+/g," ").trim(),di=(t,s)=>{const a=s.trim().toLocaleLowerCase();return a?t.filter(i=>`${i.title} ${i.cwd} ${i.sourceId}`.toLocaleLowerCase().includes(a)):t},Yu=(t,s)=>`${t??""}\0${[...s].sort().join("\0")}`,ui=5e3,Qu=(t,s,a,i=ui)=>{const r=new Set(a);let c=!1;for(const l of di(t,s))if(!r.has(l.sourceId)){if(r.size>=i){c=!0;break}r.add(l.sourceId)}return{selected:r,capped:c}},Zu=/cancel/i,Ju=new Set(["done","failed","cancelled"]),Vs=t=>{switch(t){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"}},Nn=t=>{switch(t){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"}},Xu=t=>{switch(t){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"}},em=t=>{switch(t){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"}},tm=t=>t==="failed"?"danger":t==="metadata_only"||t==="skipped_already_imported"?"neutral":t==="cancelled"?"warning":"success",Qn=t=>Wu(t.title)||t.sourceId,Gs=({path:t,label:s,onCopyPath:a})=>{const[i,r]=o.useState(!1);return e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-hairline bg-surface p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-body-sm text-ink",children:s}),e.jsx("p",{className:"mt-1 break-all font-mono text-meta text-ink-muted",children:t})]}),e.jsxs(D,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{a(t).then(c=>{c&&(r(!0),window.setTimeout(()=>r(!1),1500))})},children:[i?e.jsx(cn,{size:14}):e.jsx(Ta,{size:14}),i?n("ui.settings.imports.copied"):n("ui.settings.imports.copy_path")]})]})},nm=({progress:t,sessions:s,selected:a})=>{const i=new Map(t.results.map(d=>[d.sourceId,d])),r=t.sessionId,c=Math.max(0,t.total-t.completed-(r&&!i.has(r)?1:0)),l=s.filter(d=>a.has(d.sourceId));return e.jsxs("div",{className:"flex flex-col gap-2",children:[t.results.map(d=>e.jsx(mi,{row:d,jobCancelled:t.state==="cancelled"},`${d.source}:${d.sourceId}`)),l.filter(d=>!i.has(d.sourceId)&&d.sourceId!==r).map(d=>e.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:[e.jsx("span",{className:"min-w-0 truncate",children:Qn(d)}),e.jsx(wt,{variant:"neutral",children:n("ui.settings.imports.session_pending")})]},d.sourceId)),r&&!i.has(r)&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-hairline bg-surface p-2 text-body-sm text-ink-muted",children:[e.jsx(Ht,{size:14,className:"animate-spin"}),e.jsx("span",{children:n("ui.settings.imports.session_importing")}),e.jsx("span",{className:"min-w-0 truncate",children:r})]}),c>0&&e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.progress_pending",{count:c})}),t.warnings.map(d=>e.jsx("p",{className:"text-meta text-warning",children:d.message},`${d.code}:${d.sessionId}:${d.message}`))]})},mi=({row:t,jobCancelled:s=!1})=>{const i=s&&t.outcome==="failed"&&t.warnings.some(r=>Zu.test(r))?"cancelled":t.outcome;return e.jsxs("div",{className:"rounded-md border border-hairline bg-surface p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-body-sm text-ink",children:t.sourceId}),e.jsx(wt,{variant:tm(i),children:n(em(i))}),e.jsx("span",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.session_meta",{messages:t.messages,compactions:t.compactions})})]}),t.targetSessionId&&(t.messages>0||t.outcome==="skipped_already_imported")&&e.jsx("p",{className:"mt-1 break-all font-mono text-meta text-ink-muted",children:n("ui.settings.imports.result_target",{target:t.targetSessionId})}),t.warnings.map(r=>e.jsx("p",{className:"mt-1 text-meta text-warning",children:r},r))]})},sm=({sources:t,activeSource:s,sessions:a,query:i,selected:r,preview:c,previewStale:l,previewError:d,confirmed:u,busy:m,error:p,progress:g,result:_,cancelling:x,onSelectSource:k,onQueryChange:b,onToggleSession:S,onSelectAll:I,onClearSelection:M,onConfirmChange:L,onImport:E,onCancel:O,onRetry:y,onImportAnother:F,onRefresh:K,selectionNotice:P,onCopyPath:f})=>{te();const A=t.find(h=>h.source===s),T=g!==null&&!Ju.has(g.state),v=g?.total??r.size,H=o.useMemo(()=>di(a,i),[i,a]),z=H.length>0&&H.every(h=>r.has(h.sourceId)),q=r.size,Z=q>0&&c!==null&&!l&&u&&!m&&!g&&!_;return e.jsx(ye,{title:n("ui.settings.imports.title"),icon:$n,description:n("ui.settings.imports.description"),dataTourTag:"settings-import-section",children:e.jsxs("div",{className:"flex flex-col gap-5",children:[p&&e.jsxs(me,{variant:"warning",children:[e.jsx(an,{children:n("ui.settings.imports.title")}),e.jsx(Oe,{children:e.jsxs("span",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("span",{children:p}),e.jsx(D,{variant:"secondary",size:"sm",onClick:y,children:n("ui.settings.imports.retry")})]})})]}),m==="sources"&&t.length===0?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ae,{className:"h-20 w-full"}),e.jsx(Ae,{className:"h-20 w-full"}),e.jsx(Ae,{className:"h-20 w-full"}),e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.loading_sources")})]}):t.length===0?e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_sources")}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.source_heading")}),e.jsxs(D,{variant:"ghost",size:"sm",onClick:K,disabled:T||m==="sources"||m==="sessions",children:[e.jsx(Do,{size:14,className:ge(m==="sources"&&"animate-spin")}),n("ui.settings.imports.refresh")]})]}),!t.some(h=>h.detected)&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_sources")}),e.jsx("div",{className:"grid gap-2 lg:grid-cols-3",children:t.map(h=>{const R=h.source===s,j=h.detected?n(Vs(h.availability)):n("ui.settings.imports.source_not_found");return e.jsxs("button",{type:"button","aria-pressed":R,disabled:T,onClick:()=>k(h.source),className:ge("rounded-lg border p-3 text-start transition-colors disabled:cursor-not-allowed disabled:opacity-60","focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",R?"border-accent bg-accent-wash":"border-hairline bg-surface hover:bg-sunken"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-body-sm font-medium text-ink",children:h.label}),e.jsx(wt,{variant:h.detected&&h.availability==="full"?"success":"neutral",children:j})]}),e.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:n("ui.settings.imports.source_sessions",{count:h.sessionCount})}),e.jsx("p",{className:"mt-1 break-all text-meta text-ink-dim",children:h.detail||h.root})]},h.source)})})]}),A&&!g&&!_&&e.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("h3",{className:"text-heading text-ink",children:[n("ui.settings.imports.source_heading")," · ",A.label]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{variant:"secondary",size:"sm",onClick:z?M:I,disabled:H.length===0,children:z?n("ui.settings.imports.clear_all"):n("ui.settings.imports.select_all")}),e.jsx("span",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.selected",{count:q})})]})]}),P&&e.jsx("output",{className:"text-meta text-warning",children:P}),e.jsxs("div",{className:"relative",children:[e.jsx(is,{size:15,className:"pointer-events-none absolute top-1/2 start-3 -translate-y-1/2 text-ink-dim"}),e.jsx(Ne,{value:i,onChange:h=>b(h.target.value),placeholder:n("ui.settings.imports.search_placeholder"),className:"ps-9"})]}),m==="sessions"?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ae,{className:"h-12 w-full"}),e.jsx(Ae,{className:"h-12 w-full"}),e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.loading_sessions",{source:A.label})})]}):a.length===0?e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_sessions",{source:A.label})}):H.length===0?e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_filter")}):e.jsx("div",{className:"flex max-h-80 flex-col gap-1 overflow-y-auto",children:H.map(h=>{const R=`import-session-${h.source}-${h.sourceId}`;return e.jsxs("div",{className:ge("flex items-start gap-3 rounded-md border p-3",r.has(h.sourceId)?"border-accent bg-row-selected":"border-hairline bg-surface hover:bg-sunken"),children:[e.jsx(Vn,{id:R,checked:r.has(h.sourceId),onCheckedChange:()=>S(h.sourceId),"aria-label":Qn(h),className:"mt-0.5"}),e.jsxs("label",{htmlFor:R,className:"min-w-0 flex-1 cursor-pointer text-start",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-body-sm text-ink",children:Qn(h)}),e.jsx(wt,{variant:h.availability==="full"?"neutral":"warning",children:n(Vs(h.availability))})]}),e.jsxs("span",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1 text-meta text-ink-muted",children:[e.jsx("span",{children:n("ui.settings.imports.session_meta",{messages:h.messageCount??0,compactions:h.compactionCount})}),e.jsx("span",{children:n("ui.settings.imports.session_updated",{date:rs(new Date((h.updatedTs||h.createdTs)*1e3))})})]}),h.cwd&&e.jsx("span",{className:"mt-1 block break-all font-mono text-meta text-ink-dim",children:h.cwd}),h.availability==="metadata_only"&&e.jsx("span",{className:"mt-1 block text-meta text-warning",children:n("ui.settings.imports.metadata_only_explain")}),h.availability==="unsupported"&&e.jsx("span",{className:"mt-1 block text-meta text-warning",children:n("ui.settings.imports.session_index_only")})]})]},h.sourceId)})})]}),A&&q>0&&!g&&!_&&e.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.preview_heading")}),(m==="preview"||l||c===null&&!d)&&e.jsxs("p",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[e.jsx(Ht,{size:14,className:"animate-spin"}),n("ui.settings.imports.loading_preview")]}),c&&!l&&e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border border-hairline bg-surface p-4",children:[e.jsx("p",{className:"text-body-sm text-ink",children:n("ui.settings.imports.preview_summary",{sessions:c.totalSessions,messages:c.totalMessages,compactions:c.totalCompactions})}),e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.preview_memory",{records:c.totalMemoryRecords,tokens:c.projectedMemoryTokens.toLocaleString()})}),c.warnings.slice(0,4).map((h,R)=>e.jsx("p",{className:"text-meta text-warning",children:h.message},`${h.code}:${h.sessionId}:${R}`)),c.warnings.length>4&&e.jsx("p",{className:"text-meta text-warning",children:n("ui.settings.imports.warnings_heading",{count:c.warnings.length})}),e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.preview_confirm")})]}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-hairline bg-surface p-4",children:[d&&e.jsx(me,{variant:"warning",children:e.jsx(Oe,{children:e.jsxs("span",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("span",{children:d}),e.jsx(D,{variant:"secondary",size:"sm",onClick:y,children:n("ui.settings.imports.retry")})]})})}),e.jsxs("div",{className:"flex items-start gap-2 text-body-sm text-ink",children:[e.jsx(Vn,{checked:u,onCheckedChange:h=>L(h===!0),disabled:!c||l,"aria-label":n("ui.settings.imports.confirm_label"),className:"mt-0.5"}),e.jsx("span",{children:n("ui.settings.imports.confirm_label")})]}),e.jsxs(D,{variant:"primary",onClick:E,disabled:!Z,className:"self-start",children:[m==="start"?e.jsx(Ht,{size:14,className:"animate-spin"}):e.jsx($n,{size:14}),n("ui.settings.imports.import_button",{count:q})]})]})]}),g&&!_&&e.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.progress_heading")}),e.jsxs(D,{variant:"secondary",size:"sm",onClick:O,disabled:x||g.state==="done"||g.state==="cancelled"||g.state==="failed",children:[e.jsx(Ir,{size:12}),x?n("ui.settings.imports.cancelling"):n("ui.settings.imports.cancel")]})]}),e.jsxs("p",{className:"text-meta text-ink-muted",children:[n("ui.settings.imports.progress_job",{job:g.jobId,state:n(Nn(g.state))})," · ",n(Xu(g.phase))]}),e.jsx(rc,{value:g.total?g.completed/g.total*100:0,className:"h-1.5"}),e.jsx(nm,{progress:g,sessions:a,selected:r})]}),_&&e.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.result_heading")}),e.jsx(D,{variant:"secondary",size:"sm",onClick:F,children:n("ui.settings.imports.import_another")})]}),e.jsx("p",{className:"text-body-sm text-ink",children:_.state==="cancelled"?n("ui.settings.imports.result_summary_cancelled",{state:n(Nn(_.state)),sessions:_.sessions.length,total:v,messages:_.messages}):n("ui.settings.imports.result_summary",{state:n(Nn(_.state)),sessions:_.sessions.length,messages:_.messages})}),_.sessions.map(h=>e.jsx(mi,{row:h,jobCancelled:_.state==="cancelled"},`${h.source}:${h.sourceId}:${h.targetSessionId}`)),(_.instructionReviewPath||_.memoryReviewPath)&&e.jsxs("div",{className:"flex flex-col gap-2",children:[_.instructionReviewPath&&e.jsx(Gs,{path:_.instructionReviewPath,label:n("ui.settings.imports.review_instructions"),onCopyPath:f}),_.memoryReviewPath&&e.jsx(Gs,{path:_.memoryReviewPath,label:n("ui.settings.imports.review_memory"),onCopyPath:f})]}),_.warnings.length>0&&e.jsx(me,{variant:"warning",children:e.jsx(Oe,{children:e.jsxs("span",{className:"flex flex-col gap-1",children:[e.jsx("span",{children:n("ui.settings.imports.warnings_heading",{count:_.warnings.length})}),_.warnings.slice(0,4).map((h,R)=>e.jsx("span",{children:h.message},`${h.code}:${R}`))]})})}),_.error&&e.jsx(me,{variant:"danger",children:e.jsx(Oe,{children:_.error})}),e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.rerun_safe")})]}),m==="start"&&!g&&e.jsxs("p",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(Ht,{size:14,className:"animate-spin"}),n("ui.settings.imports.importing")]})]})})},_s=t=>({source:t.source,sessionId:t.session_id,code:t.code,message:t.message}),gi=t=>({source:t.source,sourceId:t.source_id,targetSessionId:t.target_session_id,outcome:t.outcome,messages:t.messages,compactions:t.compactions,redactions:t.redactions,skipped:t.skipped,warnings:t.warnings}),am=t=>({jobId:t.job_id,state:t.state,sessions:t.sessions.map(gi),messages:t.messages,compactions:t.compactions,memoryImported:t.memory_imported,memorySkipped:t.memory_skipped,memoryReviewPath:t.memory_review_path,instructionReviewPath:t.instruction_review_path,redactions:t.redactions,warnings:t.warnings.map(_s),error:t.error});async function im(){return(await je({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 rm(t,s=!1){return(await je({op:"imports.sessions",source:t,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 om(t){const s=await je({op:"imports.preview",sources:t.sources,sessionIds:t.sessionIds,includeMemory:t.includeMemory??!0,includeInstructions:t.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(_s),instructionReviewPaths:s.instruction_review_paths}}async function cm(t){return(await je({op:"imports.start",sources:t.sources,sessionIds:t.sessionIds,includeMemory:t.includeMemory??!0,includeInstructions:t.includeInstructions??!0})).job_id}async function lm(t){const s=await je({op:"imports.status",jobId:t});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(gi),warnings:s.warnings.map(_s),error:s.error,startedAt:s.started_at,updatedAt:s.updated_at,result:s.result?am(s.result):void 0}}async function dm(t){await je({op:"imports.cancel",jobId:t})}const zt=new Set(["done","failed","cancelled"]),Je=t=>t instanceof Error?t.message:String(t),um=()=>{te();const[t,s]=o.useState([]),[a,i]=o.useState(null),[r,c]=o.useState([]),[l,d]=o.useState(""),[u,m]=o.useState(new Set),[p,g]=o.useState(null),[_,x]=o.useState(null),[k,b]=o.useState(!1),[S,I]=o.useState(null),[M,L]=o.useState(null),[E,O]=o.useState(null),[y,F]=o.useState(null),[K,P]=o.useState(!1),[f,A]=o.useState(null),[T,v]=o.useState(0),H=o.useRef(0),z=o.useRef(0),[q,Z]=o.useState(null),[h,R]=o.useState(null),j=o.useRef(null),U=E!==null&&!zt.has(E.state),ne=o.useCallback(async()=>{I("sources"),L(null);try{const ee=await im();s(ee),i(ie=>ee.some(se=>se.source===ie&&se.detected)?ie:ee.find(se=>se.detected)?.source??null)}catch(ee){L(n("ui.settings.imports.error_sources",{reason:Je(ee)}))}finally{I(null)}},[]);o.useEffect(()=>{ne()},[ne]);const Y=o.useCallback(async ee=>{const ie=++H.current;I("sessions"),L(null);try{const V=await rm(ee);if(ie!==H.current)return;c(V)}catch(V){if(ie!==H.current)return;c([]),L(n("ui.settings.imports.error_sessions",{source:ee,reason:Je(V)}))}finally{ie===H.current&&I(null)}},[]);o.useEffect(()=>{if(!a){c([]);return}c([]),m(new Set),g(null),x(null),Z(null),R(null),b(!1),F(null),O(null),Y(a)},[a,Y]);const X=o.useCallback(ee=>{m(ee),b(!1),Z(null),R(null),A(null)},[]),re=o.useCallback(ee=>{U||(i(ee),d(""))},[U]),ce=o.useCallback(ee=>{const ie=new Set(u);ie.has(ee)?ie.delete(ee):ie.add(ee),X(ie)},[X,u]),de=o.useCallback(()=>{const ee=Qu(r,l,u);X(ee.selected),ee.capped&&A(n("ui.settings.imports.selection_limit",{max:ui}))},[l,X,u,r]),be=o.useCallback(()=>{X(new Set)},[X]),pe=o.useMemo(()=>Yu(a,u),[a,u]),B=p!==null&&_!==pe,N=o.useCallback(async()=>{if(!a||u.size===0)return;const ee=++z.current,ie=pe;I("preview"),L(null),R(null);try{const V=await om({sources:[a],sessionIds:{[a]:[...u].sort()}});if(ee!==z.current)return;g(V),x(ie)}catch(V){if(ee!==z.current)return;g(null),x(null),Z(ie),R(n("ui.settings.imports.error_preview",{reason:Je(V)}))}finally{ee===z.current&&I(null)}},[a,pe,u]);o.useEffect(()=>{if(!a||u.size===0||E||y||p&&_===pe||!p&&q===pe)return;const ee=setTimeout(()=>{N()},250);return()=>clearTimeout(ee)},[a,u,pe,p,_,q,E,y,N]);const G=o.useCallback(async()=>{if(!(!a||u.size===0||!p||B||!k||E)){I("start"),L(null),F(null);try{const ee=await cm({sources:[a],sessionIds:{[a]:[...u].sort()}}),ie=Date.now()/1e3;O({jobId:ee,state:"queued",phase:"queued",source:a,sessionId:"",completed:0,total:u.size,results:[],warnings:[],error:"",startedAt:ie,updatedAt:ie})}catch(ee){L(n("ui.settings.imports.error_start",{reason:Je(ee)}))}finally{I(null)}}},[a,k,p,B,E,u]),ae=E?.jobId??null,J=E?.state??null;o.useEffect(()=>{if(!ae||!J||zt.has(J))return;let ee=!0,ie;const V=async()=>{try{const se=await lm(ae);if(!ee)return;if(j.current){const oe=j.current;j.current=null,L(Me=>Me===oe?null:Me)}O(se),se.result&&F({...se.result,jobId:se.jobId}),zt.has(se.state)||(ie=setTimeout(V,900))}catch(se){if(!ee)return;const oe=n("ui.settings.imports.error_job",{reason:Je(se)});j.current=oe,L(oe),ie=setTimeout(V,2e3)}};return ie=setTimeout(V,T>0?0:700),()=>{ee=!1,ie&&clearTimeout(ie)}},[ae,J,T]);const _e=o.useCallback(async()=>{if(!(!E||zt.has(E.state))){P(!0),L(null);try{await dm(E.jobId)}catch(ee){L(n("ui.settings.imports.error_cancel",{reason:Je(ee)}))}finally{P(!1)}}},[E]),le=o.useCallback(()=>{m(new Set),g(null),x(null),Z(null),R(null),b(!1),A(null),F(null),O(null),L(null),a&&Y(a)},[a,Y]),we=o.useCallback(async ee=>{try{return await navigator.clipboard.writeText(ee),!0}catch{return!1}},[]),Ie=o.useCallback(async()=>{U||(A(null),Z(null),R(null),await ne(),a&&await Y(a))},[a,U,Y,ne]),fe=o.useCallback(()=>{if(U){L(null),v(ee=>ee+1);return}Z(null),R(null),Ie()},[U,Ie]);return e.jsx(sm,{sources:t,activeSource:a,sessions:r,query:l,selected:u,preview:p,previewStale:B,previewError:h,confirmed:k,busy:S,error:M,progress:E,result:y,cancelling:K,onSelectSource:re,onQueryChange:d,onToggleSession:ce,onSelectAll:de,onClearSelection:be,onConfirmChange:b,onImport:()=>void G(),onCancel:()=>void _e(),onRetry:fe,onImportAnother:le,onRefresh:Ie,selectionNotice:f,onCopyPath:we})},_t="ui.settings.appearance.agent_avatar_size_setting",mm=t=>t==="small"?n(`${_t}.small`):t==="medium"?n(`${_t}.medium`):n(`${_t}.large`),Ws={className:"size-4",glyphClassName:"size-2"},gm=({size:t})=>{const s=Ji[t],a=Xi[t],i=er[t],r=(c,l)=>e.jsx(oc,{className:ge("items-center justify-center text-ink-muted",c),children:e.jsx(Va,{className:l,"aria-hidden":"true"})});return e.jsxs("div",{"aria-hidden":"true","data-agent-size-sample":t,className:"mt-3 flex items-start gap-6 rounded-md border border-hairline bg-surface p-3",children:[e.jsxs("div",{className:"flex h-10 items-center gap-2",children:[r(s.className,s.glyphClassName),e.jsx("span",{className:"h-2 w-16 rounded-full bg-sunken"})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:ge("flex",i.className),children:r(a.className,a.glyphClassName)}),e.jsx("span",{className:"h-2 w-28 rounded-full bg-sunken"})]}),e.jsxs("div",{"data-agent-size-sample-fixed":"",className:"flex h-10 items-center gap-2",children:[r(Ws.className,Ws.glyphClassName),e.jsx("span",{className:"h-2 w-12 rounded-full bg-sunken"})]})]})},pm=({value:t,onChange:s,searchRow:a})=>{te();const i=o.useId();return e.jsxs("div",{"data-search-row":a,"data-search-control":a?"":void 0,className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{id:i,className:"flex min-h-6 items-center text-body text-ink",children:n(`${_t}.agent_picture_size`)}),e.jsx("p",{className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n(`${_t}.how_large_the_agent_s_picture_appears_in_the_chat_window_and_the_chat`)}),e.jsx(gm,{size:Dn(t)})]}),e.jsx("div",{className:"flex h-6 shrink-0 items-center",children:e.jsx(kt,{value:t,onValueChange:r=>s(Dn(r)),children:e.jsx(jt,{"aria-labelledby":i,children:Zi.map(r=>e.jsx(Ye,{value:r,children:mm(r)},r))})})})]})},pi=()=>{const t=ue(i=>i.themeName),s=ue(i=>i.customThemeId),a=os();return o.useMemo(()=>{const i=a.themes.find(c=>c.id===s),r=st(i?.base??t)?.palette;return{palette:r&&i?sn(r,i):r,name:i?.name??ze[t].name}},[t,s,a])},Sn=t=>{const s=[1,3,5].map(g=>Number.parseInt(t.slice(g,g+2),16)/255).map(g=>g<=.04045?g/12.92:((g+.055)/1.055)**2.4),[a,i,r]=s,c=Math.cbrt(.4122214708*a+.5363325363*i+.0514459929*r),l=Math.cbrt(.2119034982*a+.6806995451*i+.1073969566*r),d=Math.cbrt(.0883024619*a+.2817188376*i+.6299787005*r),u=.2104542553*c+.793617785*l-.0040720468*d,m=1.9779984951*c-2.428592205*l+.4505937099*d,p=.0259040371*c+.7827717662*l-.808675766*d;return{l:u,c:Math.hypot(m,p),h:(Math.atan2(p,m)*180/Math.PI+360)%360}},Cn=({l:t,c:s,h:a})=>{const i=s*Math.cos(a*Math.PI/180),r=s*Math.sin(a*Math.PI/180),c=(t+.3963377774*i+.2158037573*r)**3,l=(t-.1055613458*i-.0638541728*r)**3,d=(t-.0894841775*i-1.291485548*r)**3;return[4.0767416621*c-3.3077115913*l+.2309699292*d,-1.2684380046*c+2.6097574011*l-.3413193965*d,-.0041960863*c-.7034186147*l+1.707614701*d]},Ys=t=>{const s={l:Math.max(0,Math.min(1,t.l)),c:Math.max(0,Math.min(.4,t.c)),h:(t.h%360+360)%360},a=c=>c.every(l=>l>=-1e-7&&l<=1+1e-7),i=!a(Cn(s));if(i){let c=0,l=s.c;for(let d=0;d<22;d++){const u=(c+l)/2;a(Cn({...s,c:u}))?c=u:l=u}s.c=c}return{hex:`#${Cn(s).map(c=>{const l=c<=.0031308?12.92*c:1.055*c**.4166666666666667-.055;return Math.round(Math.max(0,Math.min(1,l))*255).toString(16).padStart(2,"0")}).join("").toUpperCase()}`,clipped:i}},hm=t=>t.length===3&&t.every(s=>Number.isFinite(s)&&s>=0&&s<=255)?`#${t.map(s=>Math.round(s).toString(16).padStart(2,"0")).join("").toUpperCase()}`:null,hi="lo-recent-colours-v1",fi=()=>{try{const t=JSON.parse(localStorage.getItem(hi)??"[]");return Array.isArray(t)?t.filter(s=>typeof s=="string"&&/^#[0-9A-Fa-f]{6}$/.test(s)).slice(0,8):[]}catch{return[]}},_i=t=>{try{localStorage.setItem(hi,JSON.stringify([t,...fi().filter(s=>s!==t)].slice(0,8)))}catch{}},xi=({value:t,onChange:s,onValidityChange:a,swatches:i=[]})=>{te();const r=o.useId(),c=o.useRef(t),[l,d]=o.useState(()=>Sn(t)),[u,m]=o.useState(t),[p,g]=o.useState("hex"),[_,x]=o.useState(!1),[k,b]=o.useState(!1),[S,I]=o.useState(!1),M=o.useCallback((f,A,T=p)=>T==="rgb"?[1,3,5].map(v=>Number.parseInt(f.slice(v,v+2),16)).join(", "):T==="oklch"?`${(A.l*100).toFixed(2)} ${A.c.toFixed(4)} ${A.h.toFixed(2)}`:f,[p]);o.useEffect(()=>{if(t===c.current)return;c.current=t;const f=Sn(t);d(f),m(M(t,f)),b(!1),x(!1),a?.(!0)},[t,M,a]);const L=f=>{const A={l:Math.max(0,Math.min(1,f.l)),c:Math.max(0,Math.min(.4,f.c)),h:(f.h%360+360)%360},T=Ys(A);d(A),c.current=T.hex,b(T.clipped),m(M(T.hex,A)),x(!1),a?.(!0),s(T.hex)},E=f=>{const A=Sn(f);c.current=f,d(A),m(M(f,A)),b(!1),x(!1),a?.(!0),s(f)},O=()=>{const f=u.trim().split(/[\s,]+/).map(Number),A=p==="hex"?Fn(u):p==="rgb"?hm(f):null;if(p==="oklch"&&f.length===3&&f.every(Number.isFinite)&&f[0]>=0&&f[0]<=100&&f[1]>=0&&f[1]<=.4&&f[2]>=0&&f[2]<=360){L({l:f[0]/100,c:f[1],h:f[2]});return}if(!A){x(!0),a?.(!1);return}E(A)},y=f=>{const A=f.currentTarget.getBoundingClientRect();L({...l,c:(f.clientX-A.left)/A.width*.4,l:1-(f.clientY-A.top)/A.height})},F=f=>{const A=f.shiftKey?.1:.01,T={...l};switch(f.key){case"ArrowLeft":T.c-=A*.4;break;case"ArrowRight":T.c+=A*.4;break;case"ArrowUp":T.l+=A;break;case"ArrowDown":T.l-=A;break;case"Home":T.c=0;break;case"End":T.c=.4;break;case"PageUp":T.l+=.1;break;case"PageDown":T.l-=.1;break;default:return}f.preventDefault(),L(T)},K=o.useMemo(()=>Array.from({length:48},(f,A)=>{const T=1-(A+.5)/48;return`linear-gradient(to right, ${Array.from({length:17},(v,H)=>Ys({l:T,c:H/16*.4,h:l.h}).hex).join(", ")})`}),[l.h]),P=globalThis.EyeDropper;return e.jsxs("div",{className:"flex min-w-0 flex-col gap-3","data-colour-picker":"",children:[e.jsx("div",{id:`${r}-help`,className:"sr-only",children:n("ui.settings.appearance.editor.picker.area_description")}),e.jsxs("div",{role:"slider",tabIndex:0,"aria-label":n("ui.settings.appearance.editor.picker.area"),"aria-describedby":`${r}-help`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(l.l*100),"aria-valuetext":n("ui.settings.appearance.editor.picker.area_value",{lightness:String(Math.round(l.l*100)),chroma:l.c.toFixed(3),hue:String(Math.round(l.h))}),onKeyDown:F,onPointerDown:f=>{f.currentTarget.setPointerCapture(f.pointerId),y(f)},onPointerMove:f=>{f.currentTarget.hasPointerCapture(f.pointerId)&&y(f)},className:"relative h-40 touch-none rounded-md border border-control focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",children:[e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 flex flex-col",children:K.map((f,A)=>e.jsx("div",{className:"min-h-0 flex-1",style:{background:f}},String(A)))}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute size-3 rounded-full border-2 border-white outline-1 outline-black",style:{left:`calc(${l.c/.4*100}% - 6px)`,top:`calc(${(1-l.l)*100}% - 6px)`,background:t}})]}),e.jsxs("label",{className:"flex flex-col gap-1 text-meta",children:[n("ui.settings.appearance.picker.hue"),e.jsx("input",{type:"range",dir:"ltr",min:0,max:360,step:1,value:l.h,onChange:f=>L({...l,h:Number(f.target.value)}),"data-colour-hue":"",className:"h-6 w-full focus-visible:outline-2 focus-visible:outline-accent"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("label",{className:"flex flex-col gap-1 text-meta",children:[n("ui.settings.appearance.editor.picker.lightness"),e.jsx("input",{type:"range",dir:"ltr",min:0,max:100,value:l.l*100,onChange:f=>L({...l,l:Number(f.target.value)/100}),className:"h-6 w-full accent-accent"})]}),e.jsxs("label",{className:"flex flex-col gap-1 text-meta",children:[n("ui.settings.appearance.editor.picker.chroma"),e.jsx("input",{type:"range",dir:"ltr",min:0,max:.4,step:.001,value:l.c,onChange:f=>L({...l,c:Number(f.target.value)}),className:"h-6 w-full accent-accent"})]})]}),e.jsxs("div",{className:"flex min-w-0 gap-2",children:[e.jsxs("select",{"aria-label":n("ui.settings.appearance.editor.picker.format"),value:p,onChange:f=>{g(f.target.value),m(M(t,l,f.target.value)),x(!1)},className:"min-w-0 rounded-sm border border-control bg-sunken px-2 text-body-sm",children:[e.jsx("option",{value:"hex",children:n("ui.settings.appearance.picker.hex")}),e.jsx("option",{value:"rgb",children:n("ui.settings.appearance.editor.picker.rgb")}),e.jsx("option",{value:"oklch",children:n("ui.settings.appearance.editor.picker.oklch")})]}),e.jsx("input",{dir:"ltr","aria-label":p==="hex"?n("ui.settings.appearance.picker.hex"):p==="rgb"?n("ui.settings.appearance.editor.picker.rgb"):n("ui.settings.appearance.editor.picker.oklch"),value:u,"aria-invalid":_,"aria-describedby":_?`${r}-error`:void 0,onChange:f=>{m(f.target.value),x(!0),a?.(!1)},onBlur:O,onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),O())},className:"min-w-0 flex-1 rounded-sm border border-control bg-sunken px-2 py-1.5 font-mono text-meta"}),e.jsx("span",{"aria-hidden":"true",className:"size-8 shrink-0 rounded-sm border border-control",style:{backgroundColor:t}})]}),_&&e.jsx("p",{id:`${r}-error`,role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.picker.invalid_channels")}),k&&e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.appearance.editor.picker.gamut")}),[{key:"theme",label:n("ui.settings.appearance.editor.picker.theme_swatches"),items:i},{key:"recent",label:n("ui.settings.appearance.editor.picker.recent"),items:fi()}].map(f=>e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-meta text-ink-muted",children:f.label}),e.jsx("div",{className:"flex flex-wrap gap-1",children:[...new Set(f.items)].map(A=>e.jsx("button",{type:"button","aria-label":n("ui.settings.appearance.editor.picker.swatch",{hex:A}),className:"size-7 rounded-sm border border-control focus-visible:outline-2 focus-visible:outline-accent",style:{background:A},onClick:()=>E(A)},A))}),!f.items.length&&e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.settings.appearance.editor.picker.recent_empty")})]},f.key)),P&&e.jsx(D,{type:"button",variant:"secondary",onClick:async()=>{try{const f=await new P().open(),A=Fn(f.sRGBHex);A&&E(A),I(!1)}catch(f){f instanceof DOMException&&f.name==="AbortError"||I(!0)}},children:n("ui.settings.appearance.picker.eyedropper")}),S&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.picker.eyedropper_error")})]})},fm=5,_m={red:"ui.settings.appearance.hue.red",orange:"ui.settings.appearance.hue.orange",amber:"ui.settings.appearance.hue.amber",yellow:"ui.settings.appearance.hue.yellow",lime:"ui.settings.appearance.hue.lime",green:"ui.settings.appearance.hue.green",teal:"ui.settings.appearance.hue.teal",cyan:"ui.settings.appearance.hue.cyan",blue:"ui.settings.appearance.hue.blue",indigo:"ui.settings.appearance.hue.indigo",violet:"ui.settings.appearance.hue.violet",pink:"ui.settings.appearance.hue.pink",neutral:"ui.settings.appearance.hue.neutral"},Qs=t=>n(_m[nr(t)]),Zs=(t,s)=>t.kind!==s.kind?!1:t.kind==="palette"&&s.kind==="palette"?t.id===s.id:t.kind==="custom"&&s.kind==="custom"?t.hex===s.hex:!0,xm=t=>{te();const{themeName:s,themeAccent:a,themeAccentAlt:i,curated:r,all:c,paletteName:l,custom:d,customNames:u,selected:m,paintedAccent:p,adjusted:g,applied:_}=t,[x,k]=o.useState(!1),b=o.useRef(null),S=o.useRef(null),[I,M]=o.useState(null),L=x?c:r,E=o.useMemo(()=>[{key:"theme",ref:{kind:"theme"},hex:a,label:n("ui.settings.appearance.accent.theme_accent",{theme:s})},{key:"theme-alt",ref:{kind:"theme-alt"},hex:i,label:n("ui.settings.appearance.accent.theme_second_accent",{theme:s})},...L.map(v=>({key:`palette:${v.id}`,ref:{kind:"palette",id:v.id},hex:v.hex,label:n("ui.settings.appearance.accent.from_theme",{theme:l(v.id),hue:Qs(v.hex)})}))],[s,a,i,L,l]),O=d.map(v=>({key:`custom:${v}`,ref:{kind:"custom",hex:v},hex:v,custom:v,label:n("ui.settings.appearance.accent.custom_swatch",{name:u[v]??v})})),y=[...E];if(m.kind==="palette"&&!E.some(v=>Zs(v.ref,m))){const v=c.find(H=>H.id===m.id);v&&y.push({key:`palette:${v.id}`,ref:m,hex:v.hex,label:n("ui.settings.appearance.accent.from_theme",{theme:l(v.id),hue:Qs(v.hex)})})}const F=[...y,...O],K=Math.max(0,F.findIndex(v=>Zs(v.ref,m))),P=m.kind!=="theme"&&_&&g>fm?n("ui.settings.appearance.accent.adjusted"):null,f=o.useRef(null),A=v=>{if(!["ArrowRight","ArrowDown","ArrowLeft","ArrowUp"].includes(v.key)&&v.key!=="Home"&&v.key!=="End")return;const z=[...f.current?.querySelectorAll('[role="radio"]')??[]],q=z.indexOf(v.target);if(q<0)return;v.preventDefault();const Z=getComputedStyle(v.currentTarget).direction==="rtl",h=v.key==="ArrowDown"||v.key==="ArrowRight"&&!Z||v.key==="ArrowLeft"&&Z,R=v.key==="Home"?0:v.key==="End"?z.length-1:(q+(h?1:-1)+z.length)%z.length;z[R]?.focus(),z[R]?.click()},T=(v,H)=>{const z=H===K,q=e.jsx("button",{type:"button",role:"radio","aria-checked":z,"aria-label":v.label,tabIndex:z?0:-1,"data-accent-swatch":v.key,onClick:()=>t.onSelect(v.ref),className:ge("group relative flex size-8 shrink-0 items-center justify-center rounded-full"),children:e.jsx("span",{"aria-hidden":"true",style:{backgroundColor:v.hex},className:ge("flex size-6 items-center justify-center rounded-full border border-hairline transition-colors group-hover:border-hairline-strong",z&&"outline-2 outline-ink outline-offset-2"),children:z&&e.jsx(cn,{size:14,strokeWidth:3,style:{color:v.hex.toUpperCase()===p.toUpperCase()?"var(--color-on-accent)":sr(v.hex).ink}})})}),Z=z&&P?`${v.label}. ${P}`:v.label,h=e.jsx(Pe,{side:"bottom",content:Z,children:q},v.key);if(!v.custom)return h;const R=v.custom;return e.jsxs(Rr,{children:[e.jsx(Tr,{asChild:!0,children:e.jsx("span",{className:"inline-flex",onContextMenuCapture:j=>{b.current=j.currentTarget.querySelector("button")},onKeyDown:j=>{if(j.key!=="ContextMenu"&&!(j.key==="F10"&&j.shiftKey))return;j.preventDefault();const U=j.currentTarget.getBoundingClientRect();j.currentTarget.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,clientX:U.left,clientY:U.bottom}))},children:h})}),e.jsxs(Lr,{onCloseAutoFocus:j=>{const U=S.current;U&&(j.preventDefault(),S.current=null,requestAnimationFrame(()=>M(U)))},children:[e.jsx(hn,{onSelect:()=>{S.current={kind:"edit",hex:R}},children:n("ui.settings.appearance.accent.edit_colour")}),e.jsx(hn,{onSelect:()=>{S.current={kind:"rename",hex:R}},children:n("ui.settings.appearance.accent.rename")}),e.jsx(hn,{destructive:!0,onSelect:()=>t.onRemove(R),children:n("ui.settings.appearance.accent.remove")})]})]},v.key)};return e.jsx(Ya,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(cc,{open:I!==null,onOpenChange:v=>{v||M(null)},children:[e.jsxs("div",{ref:f,role:"radiogroup","aria-label":n("ui.settings.appearance.accent.row_label"),onKeyDown:A,className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[y.map((v,H)=>T(v,H)),O.length>0&&e.jsx("span",{"aria-hidden":"true",className:"mx-1 h-6 w-px shrink-0 bg-hairline"}),O.map((v,H)=>T(v,y.length+H)),e.jsx(lc,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:e.jsx(Pe,{side:"bottom",content:n("ui.settings.appearance.accent.add"),children:e.jsx("button",{type:"button","aria-label":n("ui.settings.appearance.accent.add"),"data-accent-add":"",onClick:v=>{b.current=v.currentTarget,M({kind:"add"})},className:"flex size-8 shrink-0 items-center justify-center rounded-full text-ink-muted hover:text-ink",children:e.jsx("span",{className:"flex size-6 items-center justify-center rounded-full border border-control border-dashed",children:e.jsx(qn,{size:14})})})})})})]}),e.jsx(dc,{onCloseAutoFocus:v=>{v.preventDefault(),b.current?.focus()},align:"start",className:"w-66","aria-label":I?.kind==="rename"?n("ui.settings.appearance.picker.rename_dialog"):I?.kind==="edit"?n("ui.settings.appearance.picker.edit_dialog"):n("ui.settings.appearance.picker.dialog"),children:I?.kind==="rename"?e.jsx(bm,{initial:u[I.hex]??"",onCancel:()=>M(null),onSave:v=>{t.onRename(I.hex,v),M(null)}}):I?e.jsx(ym,{initial:I.kind==="edit"?I.hex:p,submitLabel:I.kind==="edit"?n("ui.settings.appearance.picker.save"):n("ui.settings.appearance.picker.add"),onCancel:()=>M(null),onSubmit:v=>{I.kind==="edit"?t.onReplace(I.hex,v):t.onAdd(v),M(null)}},I.kind==="edit"?I.hex:"add"):null})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-1",children:[e.jsx(D,{variant:"linkQuiet",size:"sm","aria-expanded":x,onClick:()=>k(v=>!v),children:x?n("ui.settings.appearance.accent.show_fewer"):n("ui.settings.appearance.accent.show_all")}),d.length>=tr&&e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.settings.appearance.accent.limit")})]}),!_&&m.kind!=="theme"&&e.jsx("output",{className:"block px-1 text-meta text-warning",children:n("ui.settings.appearance.accent.not_applied")}),P&&e.jsx("p",{className:"px-1 text-meta text-ink-muted",children:P})]})})},ym=({initial:t,submitLabel:s,onSubmit:a,onCancel:i})=>{const[r,c]=o.useState(Fn(t)??"#3B82F6"),[l,d]=o.useState(!0);return e.jsxs("form",{onSubmit:u=>{u.preventDefault(),l&&(_i(r),a(r))},className:"flex flex-col gap-3",children:[e.jsx(xi,{value:r,onChange:c,onValidityChange:d}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(D,{type:"button",variant:"ghost",size:"sm",onClick:i,children:n("ui.settings.appearance.picker.cancel")}),e.jsx(D,{type:"submit",variant:"primary",size:"sm",disabled:!l,children:s})]})]})},bm=({initial:t,onSave:s,onCancel:a})=>{const[i,r]=o.useState(t),c=o.useId();return e.jsxs("form",{className:"flex flex-col gap-3",onSubmit:l=>{l.preventDefault(),s(i)},children:[e.jsxs("label",{htmlFor:c,className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-meta text-ink-muted",children:n("ui.settings.appearance.picker.name")}),e.jsx(Ne,{id:c,inputSize:"sm",autoFocus:!0,maxLength:ar,value:i,onChange:l=>r(l.target.value)})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(D,{type:"button",variant:"ghost",size:"sm",onClick:a,children:n("ui.settings.appearance.picker.cancel")}),e.jsx(D,{type:"submit",variant:"primary",size:"sm",children:n("ui.settings.appearance.picker.save")})]})]})},vm=({previewTheme:t,className:s})=>(te(),e.jsx("section",{"aria-label":n("ui.settings.appearance.layers.preview_label"),"data-appearance-preview":"",className:ge("rounded-md border border-hairline",s),children:e.jsxs("div",{"data-theme":t,ref:km,"aria-hidden":"true",className:ge("grid min-h-42 grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-3 rounded-md bg-canvas p-3 text-ink"),children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[e.jsx("div",{className:"self-end rounded-md bg-message-surface px-2.5 py-1.5 text-body-sm",children:n("ui.settings.appearance.layers.preview.user_message")}),e.jsxs("p",{className:"text-body-sm text-ink-muted",children:[n("ui.settings.appearance.layers.preview.agent_reply")," ",e.jsx("code",{className:"rounded-xs bg-sunken px-1 font-mono text-meta text-token-command",children:n("ui.settings.appearance.layers.preview.code")})]}),e.jsxs("div",{className:"mt-auto flex items-center gap-2 rounded-md border border-control bg-sunken px-2 py-1.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink-dim",children:n("ui.settings.appearance.layers.preview.composer_placeholder")}),e.jsx("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-sm bg-accent text-on-accent",children:e.jsx(Fo,{size:14})})]})]}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5 rounded-md bg-surface p-1.5",children:[e.jsx("div",{className:"flex items-center rounded-sm px-2 py-1 text-body-sm text-ink-muted",children:e.jsx("span",{className:"truncate",children:n("ui.settings.appearance.layers.preview.row_inbox")})}),e.jsxs("div",{className:"flex items-center rounded-sm bg-row-hover px-2 py-1 text-body-sm text-ink",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:n("ui.settings.appearance.layers.preview.row_research")}),e.jsx(Gn,{count:3})]}),e.jsx("div",{className:"flex items-center rounded-sm bg-row-selected px-2 py-1 text-body-sm text-ink",children:e.jsx("span",{className:"truncate",children:n("ui.settings.appearance.layers.preview.row_release")})})]}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx("span",{className:"rounded-sm bg-accent px-2 py-0.5 text-meta text-on-accent",children:n("ui.settings.appearance.layers.preview.primary")}),e.jsx("span",{className:"rounded-sm border border-control bg-surface px-2 py-0.5 text-meta text-ink",children:n("ui.settings.appearance.layers.preview.secondary")}),e.jsx("span",{className:"rounded-sm bg-sunken px-2 py-0.5 text-ink-disabled text-meta",children:n("ui.settings.appearance.layers.preview.disabled")})]}),e.jsx(Mn,{tone:"success"}),e.jsx(Mn,{tone:"warning"}),e.jsx(Mn,{tone:"danger"})]})]})})),km=t=>{t?.setAttribute("inert","")},jm={success:{icon:mc,className:"border-success-border bg-success-wash text-success",key:"ui.settings.appearance.layers.preview.success"},warning:{icon:Qa,className:"border-warning-border bg-warning-wash text-warning",key:"ui.settings.appearance.layers.preview.warning"},danger:{icon:uc,className:"border-danger-border bg-danger-wash text-danger",key:"ui.settings.appearance.layers.preview.danger"}},Mn=({tone:t})=>{const{icon:s,className:a,key:i}=jm[t];return e.jsxs("div",{className:ge("flex items-center gap-1.5 rounded-sm border px-2 py-0.5 text-meta",a),children:[e.jsx(s,{size:12,className:"shrink-0"}),e.jsx("span",{className:"truncate text-ink",children:n(i)})]})},wm={soft:"ui.settings.appearance.contrast.soft",gentle:"ui.settings.appearance.contrast.gentle",standard:"ui.settings.appearance.contrast.standard",strong:"ui.settings.appearance.contrast.strong",high:"ui.settings.appearance.contrast.high"},Nm={soft:"ui.settings.appearance.contrast.soft_description",gentle:"ui.settings.appearance.contrast.gentle_description",standard:"ui.settings.appearance.contrast.standard_description",strong:"ui.settings.appearance.contrast.strong_description",high:"ui.settings.appearance.contrast.high_description"},xt=t=>n(wm[t]),Js=t=>t>0?`+${t}`:String(t),Xs=t=>{const s=Na(t);if(s)return xt(s);const a=rr(t);return a?n("ui.settings.appearance.contrast.value_between",{from:xt(a[0]),to:xt(a[1]),value:Js(t)}):Js(t)},Sm=({committed:t,effective:s,mode:a,pending:i=!1,backgroundAtCeiling:r=!1,onDraft:c,onCommit:l})=>{te();const[d,u]=o.useState(null),m=d??t,p=o.useId(),g=o.useId(),_=o.useRef(m);_.current=m;const x=o.useRef(!1),[k,b]=o.useState({committed:t,mode:a,pending:i});(k.committed!==t||k.mode!==a||k.pending!==i)&&(b({committed:t,mode:a,pending:i}),(k.committed!==t||k.mode!==a||k.pending&&!i)&&u(null));const S=f=>{u(f),c(f)},I=f=>{f!==t?(S(f),l(f)):(u(null),c(null))},M=Na(m),L=M?null:ir(m),E=s!==void 0&&!i&&d===null?s!==t:!1,O=f=>{if(f.button!==0)return;x.current=!0;const A=()=>{window.removeEventListener("pointerup",A),window.removeEventListener("pointercancel",A),x.current=!1,I(_.current)};window.addEventListener("pointerup",A),window.addEventListener("pointercancel",A)},y=f=>{let A=null;if(f.key==="PageUp")A=Ns(m,1);else if(f.key==="PageDown")A=Ns(m,-1);else if(f.key==="Home")A=-100;else if(f.key==="End")A=100;else if(f.key.startsWith("Arrow")){const T=getComputedStyle(f.currentTarget).direction==="rtl",v=f.key==="ArrowUp"||f.key==="ArrowRight"&&!T||f.key==="ArrowLeft"&&T,H=f.key==="ArrowDown"||f.key==="ArrowLeft"&&!T||f.key==="ArrowRight"&&T;v?A=pn(m+gn,{snap:!1}):H&&(A=pn(m-gn,{snap:!1}))}A!==null&&(f.preventDefault(),S(A))},F=f=>{(f.key.startsWith("Arrow")||f.key==="PageUp"||f.key==="PageDown"||f.key==="Home"||f.key==="End")&&I(_.current)},K=f=>{if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown"].includes(f.key))return;f.preventDefault();const T=ht.findIndex(h=>h.name===(M??L)),v=getComputedStyle(f.currentTarget).direction==="rtl",H=f.key==="ArrowDown"||f.key==="ArrowRight"!==v,z=Math.max(0,Math.min(ht.length-1,T+(H?1:-1))),q=ht[z];I(q.value),f.currentTarget.querySelectorAll("[role=radio]")[z]?.focus()},P=(m+100)/200*100;return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("h3",{id:g,className:"px-1 text-meta text-ink-dim",children:n("ui.settings.appearance.contrast.title")}),t!==0&&e.jsx(D,{variant:"link",size:"sm",onClick:()=>I(0),className:"min-h-6 min-w-6 text-meta",children:n("ui.settings.appearance.contrast.reset")})]}),e.jsx("div",{role:"radiogroup","aria-labelledby":g,onKeyDown:K,className:"grid grid-cols-5 gap-2",children:ht.map(({name:f,value:A})=>{const T=M===f,v=L===f,H=T||M===null&&v;return e.jsx(Pe,{content:n(Nm[f]),side:"bottom",children:e.jsxs("button",{type:"button",role:"radio","aria-checked":T,tabIndex:H?0:-1,"data-contrast-chip":f,onClick:()=>I(A),className:ge("relative flex h-13 min-w-0 flex-col gap-1 rounded-md p-1 text-start transition-colors duration-fast ease-out-quart max-[900px]:h-12",T?"bg-[color-mix(in_srgb,var(--color-accent)_8%,var(--color-accent-wash))]":"hover:bg-surface"),children:[e.jsxs("span",{className:ge("relative block h-6 overflow-hidden rounded-sm border",T?"border-accent":"border-hairline"),children:[e.jsxs("span",{"data-theme":tn.chip(f),"aria-hidden":"true",className:"flex h-full flex-col justify-center gap-0.5 bg-canvas px-1.5",children:[e.jsx("span",{className:"block h-0.5 w-3/4 rounded-full bg-ink"}),e.jsx("span",{className:"block h-0.5 w-1/2 rounded-full bg-ink-muted"}),e.jsx("span",{className:"mt-0.5 block h-px w-full bg-border-control"})]}),T&&e.jsx("span",{className:"absolute end-0.5 top-0.5 flex size-3.5 items-center justify-center rounded-full bg-accent text-on-accent",children:e.jsx(cn,{size:10,strokeWidth:3})})]}),e.jsx("span",{className:ge("truncate px-0.5 text-meta",T?"text-ink":"text-ink-muted"),children:v?n("ui.settings.appearance.contrast.adjusted",{preset:xt(f)}):xt(f)})]})},f)})}),e.jsx("output",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:Xs(m)}),e.jsxs("div",{className:"flex items-center gap-3 px-1",children:[e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:n("ui.settings.appearance.contrast.softer")}),e.jsx("input",{type:"range",min:-100,max:100,step:gn,value:m,"aria-label":n("ui.settings.appearance.contrast.slider"),"aria-valuetext":Xs(m),"aria-describedby":p,"data-contrast-slider":"",onPointerDown:O,onKeyDown:y,onKeyUp:F,onChange:f=>{const A=pn(Number(f.target.value),{snap:x.current});x.current?S(A):I(A)},style:{"--fill":`${P}%`},className:"h-4 min-w-0 flex-1 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"}),e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:n("ui.settings.appearance.contrast.deeper")})]}),e.jsx("p",{id:p,"aria-live":"polite",className:"px-1 text-meta text-ink-muted",children:i?n("ui.settings.appearance.contrast.applying"):E&&s!==void 0?n("ui.settings.appearance.contrast.capped_hint"):r?n("ui.settings.appearance.contrast.background_ceiling"):a==="dark"?n("ui.settings.appearance.contrast.applies_dark"):n("ui.settings.appearance.contrast.applies_light")})]})},ea="lo-appearance-preview",ta=t=>{let s=document.getElementById(ea);if(!t){s?.remove();return}s||(s=document.createElement("style"),s.id=ea,document.head.appendChild(s)),s.textContent!==t&&(s.textContent=t)},Cm=t=>{if(t.identity)return null;const s=t.palette,a={};for(const i of lr)a[i]=s[i];return a},Zn=new Set;let on=null;const yi=t=>{on=t;for(const s of Zn)s(t)},Mm=()=>{const[t,s]=o.useState(on);return o.useEffect(()=>(Zn.add(s),()=>{Zn.delete(s)}),[]),t},Am=t=>{const s=Mm(),a=pi().palette,i=o.useMemo(()=>Cm(t),[t]),r=o.useMemo(()=>a?Ss(a,ht.map(({name:l,value:d})=>({id:tn.chip(l),contrast:d})),i):"",[a,i]),c=o.useRef(null);return o.useLayoutEffect(()=>{if(!a)return;const l=()=>{c.current=null;const d=on===null?"":Ss(a,[{id:tn.strip,contrast:on}],i);ta(r+d)};c.current!==null&&cancelAnimationFrame(c.current),s===null?l():c.current=requestAnimationFrame(l)},[a,i,s,r]),o.useEffect(()=>()=>{c.current!==null&&cancelAnimationFrame(c.current),ta("")},[]),s},Em=()=>{const t=cs(),s=Am(t);return e.jsx("div",{className:"sticky top-0 z-10 -mx-1 border-hairline border-b bg-canvas px-1 pb-3",children:e.jsx(vm,{previewTheme:s===null?void 0:tn.strip})})},Im=({title:t,action:s})=>e.jsxs("div",{className:"flex min-h-7 items-center justify-between gap-2 px-1 pb-2",children:[e.jsx("h3",{className:"text-meta text-ink-dim",children:t}),s]}),Rm=()=>{const t=ue(r=>r.setContrast),[s,a]=o.useState(!1);return{commit:o.useCallback((r,c)=>{a(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>{t(r,c),yi(null),a(!1)}))},[t]),pending:s}},Tm=()=>{te();const t=cs(),s=ue(y=>y.themeName),a=ue(y=>y.contrast),i=ue(y=>y.accent),r=ue(y=>y.customAccents),c=ue(y=>y.customAccentNames),l=ue(y=>y.setAccent),d=ue(y=>y.addCustomAccent),u=ue(y=>y.replaceCustomAccent),m=ue(y=>y.renameCustomAccent),p=ue(y=>y.removeCustomAccent),{commit:g,pending:_}=Rm(),x=pi(),k=x.palette,b=k?.mode??"dark",S=a[b]??0,I=i[b]??{kind:"theme"},M=o.useMemo(()=>Object.keys(ze).map(y=>{const F=st(y)?.palette;return F?{id:y,palette:F}:null}).filter(y=>!!y),[]),L=o.useMemo(()=>or(M,b,s),[M,b,s]),E=o.useMemo(()=>cr(M,b),[M,b]);if(!k)return null;const O=x.name;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("section",{"data-appearance-layer":"contrast",children:e.jsx(Sm,{committed:S,effective:t.effectiveContrast,backgroundAtCeiling:b==="light"&&S>0&&t.palette.canvas.toUpperCase()===k.canvas.toUpperCase(),mode:b,pending:_,onDraft:yi,onCommit:y=>g(b,y)})}),e.jsxs("section",{"data-appearance-layer":"accent",children:[e.jsx(Im,{title:n("ui.settings.appearance.accent.title"),action:I.kind!=="theme"?e.jsx(D,{type:"button",variant:"link",size:"sm",className:"min-h-6 min-w-6",onClick:()=>l(b,{kind:"theme"}),children:n("ui.settings.appearance.accent.reset")}):null}),e.jsx(xm,{themeName:O,themeAccent:k.accent,themeAccentAlt:k.accentAlt,curated:L,all:E,paletteName:y=>ze[y]?.name??y,custom:r,customNames:c,selected:I,paintedAccent:t.palette.accent,adjusted:t.accentAdjusted,applied:t.accentApplied,onSelect:y=>l(b,y),onAdd:y=>d(y,b),onReplace:u,onRename:m,onRemove:p})]})]})},Lm=()=>{te();const t=ue(d=>d.themeName),s=ue(d=>d.accent),a=ue(d=>d.customAccentNames),i=ue(d=>d.setAccent),r=st(t)?.palette.mode??"dark",c=s[r],l=cs();return!c||c.kind==="theme"||c.kind==="theme-alt"?null:e.jsxs("p",{className:"flex flex-wrap items-center gap-1.5 text-meta text-ink-muted",children:[e.jsx("span",{"aria-hidden":"true",className:"inline-block size-3 rounded-full border border-hairline",style:{backgroundColor:l.palette.accent}}),e.jsx("span",{children:c.kind==="custom"?n("ui.settings.appearance.accent.override_notice",{colour:a[c.hex]??c.hex}):n("ui.settings.appearance.accent.palette_override_notice",{theme:ze[c.id]?.name??c.id})}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx(D,{type:"button",variant:"link",size:"sm",className:"min-h-6 min-w-6",onClick:()=>i(r,{kind:"theme"}),children:n("ui.settings.appearance.accent.use_theme_accent")})]})},Om=()=>(te(),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h3",{className:"px-1 text-meta text-ink-dim",children:n("ui.settings.appearance.layers.theme")}),e.jsx("div",{className:"px-1",children:e.jsx(Lm,{})})]})),Dm=({gallery:t})=>e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Em,{}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Om,{}),t]}),e.jsx(Tm,{})]}),Fm=[[[".claude.json"],"Claude Code"],[[".claude",".mcp.json"],"Claude Code"],[[".cursor","mcp.json"],"Cursor"],[[".vscode","mcp.json"],"VS Code"],[[".codex","config.toml"],"Codex CLI"]];function bi(t){if(!t)return null;const s=t.split("\\").join("/").split("/").filter(Boolean);for(const[a,i]of Fm)if(!(s.length<a.length)&&s.slice(-a.length).join("/")===a.join("/"))return i;return null}const Jt=t=>n("ui.settings.integrations.integration_model.tool_count",{count:t}),zm=t=>n("ui.settings.integrations.integration_model.integration_count",{count:t}),Pm=["connected","needs_sign_in","not_started","connecting","error"],vi=t=>Pm.includes(t),it=(t,s)=>[...s].filter(a=>a.name===t&&a.status==="running").sort((a,i)=>i.created_at-a.created_at)[0]??null,$m={connectedAt:null,connectedToolCount:null,settledGroup:null,pinnedGroup:null,pinnedOperationId:null,needsKey:!1,needsSignIn:!1,disconnectedAt:null,holdUntil:null,lastDecisive:null},Um=1e12,Km=1e9,Bm=60*60*1e3,ki=(t,s=Date.now())=>{if(typeof t!="number"||!Number.isFinite(t))return null;const a=t>=Um?t:t<Km?null:t*1e3;return a===null||a>s+Bm?null:Math.min(a,s)},Qe=(t,s)=>t?.[s]??$m,At=(t,s,a)=>Vm(t,s)??a?.lastDecisive??null,Hm=t=>({id:t.id,name:t.name,action:t.action,status:t.status,created_at:t.created_at,credential_removed:t.credential_removed,...t.message?{message:t.message}:{}}),xs=(t,s)=>t.status==="not_started"&&typeof t.tool_count=="number"&&(s.connectedAt!==null||t.status_basis==="stored"&&t.tool_count_basis==="last_seen"),qm=(t,s)=>[...s].filter(a=>a.name===t).sort((a,i)=>i.created_at-a.created_at)[0]??null,Vm=(t,s)=>qm(t,s.filter(a=>a.status!=="cancelled")),ln=t=>t.actions.includes("set_key")||t.actions.includes("add_key");function Gm(t,s){const a=Math.max(0,Math.round((t-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 r=Math.round(i/60);return r<24?n("ui.settings.integrations.integration_model.hours_h_ago",{hours:r}):n("ui.settings.integrations.integration_model.days_ago",{days:Math.round(r/24)})}function An(t){if(!t)return null;const s=t.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 r=a.replace(/^(?:connection (?:closed|error|refused)|error|closed|failed)\s*:\s*/i,"").trim();if(r===a)break;a=r}return a=a.replace(/\s*\(\s*\d{3}\s*\)/g,"").replace(/\s+([.,;])/g,"$1").replace(/\s{2,}/g," ").trim(),a||null}function Wm(t,s=[],a,i=Date.now()){const r=Qe(a,t.name),c=it(t.name,s);if(c){if(c.action==="login"||c.action==="reauth")return{label:n("ui.settings.integrations.integration_model.signing_in"),tone:"info",detail:null,busy:!0};if(c.action==="logout")return{label:n("ui.settings.integrations.integration_model.signing_out"),tone:"info",detail:null,busy:!0}}if(!vi(t.status))return{label:n("ui.settings.integrations.integration_model.status_unavailable"),tone:"neutral",detail:null,busy:!1};const l=At(t.name,s,r),d=dn(l)&&t.status!=="connected",u=xs(t,r),m=vs(l)&&t.status!=="connected",p=(l?.action==="login"||l?.action==="reauth")&&l.status==="failed";if(r.disconnectedAt!==null)return{label:n("ui.settings.integrations.integration_model.not_connected"),tone:"neutral",detail:null,busy:!1,explanation:n(na)};switch(t.status){case"connected":return{label:typeof t.tool_count=="number"?n("ui.settings.integrations.integration_model.connected_with_tools",{tools:String(Jt(t.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:t.auth.kind==="api_key"||yt(t,s,r)?n("ui.settings.integrations.integration_model.needs_a_key"):n("ui.settings.integrations.integration_model.needs_sign_in"),tone:"warning",detail:An(t.status_reason),busy:!1};case"error":return{label:n("ui.settings.integrations.integration_model.couldn_t_start"),tone:"danger",detail:An(t.status_reason)??n("ui.settings.integrations.integration_model.no_reason_was_given"),busy:!1};default:if(d)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(yt(t,s,r))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(r.needsSignIn)return{label:t.auth.kind==="api_key"||yt(t,s,r)?n("ui.settings.integrations.integration_model.needs_a_key"):n("ui.settings.integrations.integration_model.needs_sign_in"),tone:"warning",detail:An(t.status_reason),busy:!1};if(t.status_basis==="stored"&&u&&r.disconnectedAt===null){const g=r.connectedAt??ki(t.last_seen_at,i);return{label:g!==null?n("ui.settings.integrations.integration_model.worked_when_with_tools",{when:String(Gm(i,g)),tools:String(Jt(t.tool_count))}):n("ui.settings.integrations.integration_model.worked_earlier_with_tools",{tools:String(Jt(t.tool_count))}),tone:"success",detail:null,busy:!1}}return t.status_basis==="live"?{label:n("ui.settings.integrations.integration_model.not_connected"),tone:"neutral",detail:null,busy:!1,explanation:n(na)}:{label:n("ui.settings.integrations.integration_model.ready"),tone:"neutral",detail:null,busy:!1,explanation:n(Zm)}}}const ji=t=>n("ui.settings.integrations.integration_model.replace_keys",{count:t}),Ym=/[,;]?\s*(?:or|and)?\s*add (?:its|a|the) key instead\.?\s*$/i;function Qm(t,s){const a=t?.trim()??"";if(!a)return null;if(s)return a;const i=a.replace(Ym,"").trim();return i?/\.$/.test(i)?i:`${i}.`:a}const Zm="ui.settings.integrations.integration_model.copy_ready_explanation",na="ui.settings.integrations.integration_model.copy_not_connected_explanation",Jm=t=>t.transport==="local_command"?n("ui.settings.integrations.integration_model.local_command"):n("ui.settings.integrations.integration_model.remote_url");function wi(t){switch(t.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 bi(t.source.path)}}function Xm(t,s){const a=[{text:Jm(t),importSource:!1}];t.status!=="connected"&&t.tool_count_basis==="last_seen"&&typeof t.tool_count=="number"&&a.push({text:n("ui.settings.integrations.integration_model.tools_when_last_checked",{tools:String(Jt(t.tool_count))}),importSource:!1}),s&&a.push({text:t.scope==="project"?n("ui.settings.integrations.integration_model.this_project"):n("ui.settings.integrations.integration_model.global"),importSource:!1});const i=wi(t);return i?a.push({text:n("ui.settings.integrations.integration_model.imported_from_origin",{origin:String(i)}),importSource:!0}):t.source.editable||a.push({text:n("ui.settings.integrations.integration_model.imported_from_a_project_file"),importSource:!0}),a}const ys=(t,s)=>s.disconnectedAt!==null?"not_started":t.status;function bs(t,s=[],a){const i=Qe(a,t.name),r=it(t.name,s);if(r)return r.action==="login"||r.action==="reauth"?{kind:"sign_in",label:n("ui.settings.integrations.integration_model.continue_sign_in")}:null;const c=p=>t.actions.includes(p),l=ln(t),d=yt(t,s,i);if(!vi(t.status))return c("test")?{kind:"test",label:n("ui.settings.integrations.integration_model.check_again")}:null;const u=At(t.name,s,i),m=u?.status==="failed"&&Et(u);switch(ys(t,i)){case"connected":case"connecting":return null;case"needs_sign_in":return d?{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")}:c("sign_in")?{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}:l?{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")}:c("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 c("connect")?{kind:"connect",label:n("ui.settings.integrations.integration_model.reconnect")}:c("test")?{kind:"test",label:n("ui.settings.integrations.integration_model.retry")}:{kind:"fix",label:n("ui.settings.integrations.integration_model.fix")};default:{if(dn(u)&&c("sign_in"))return{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")};if(vs(u)&&c("sign_out"))return{kind:"sign_out",label:n("ui.settings.integrations.integration_model.sign_out_again")};if(i.disconnectedAt!==null&&c("connect"))return{kind:"connect",label:n("ui.settings.integrations.integration_model.connect")};if(i.needsSignIn){if(d&&l)return{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")};if(c("sign_in"))return{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}}return d&&l?{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")}:m&&c("sign_in")?{kind:"sign_in",label:n("ui.settings.integrations.integration_model.try_again")}:xs(t,i)&&!c("connect")?null:c("connect")?{kind:"connect",label:n("ui.settings.integrations.integration_model.connect"),...i.connectedAt===null&&t.status_basis!=="live"?{variant:"ghost"}:{}}:c("test")&&t.tool_count===null&&t.tool_count_basis===null?{kind:"test",label:n("ui.settings.integrations.integration_model.test"),variant:"ghost"}:null}}}const Et=t=>t.action==="login"||t.action==="reauth",dn=t=>!!(t&&t.action==="logout"&&t.status==="complete"),vs=t=>!!(t&&t.action==="logout"&&t.status!=="running"&&t.status!=="complete"),Ni=/no oauth authorization server/i;function yt(t,s,a){if(!ln(t))return!1;const i=At(t.name,s,a);return i&&Et(i)&&i.status==="failed"&&Ni.test(i.message??"")?!0:a.needsKey}function eg(t,s=[],a){const i=bs(t,s,a)?.kind,r=ys(t,Qe(a,t.name)),c=u=>t.actions.includes(u),l=[],d=it(t.name,s);if(d&&l.push({kind:"cancel",label:n("ui.settings.integrations.integration_model.cancel")}),!d&&c("test")&&i!=="test"&&l.push({kind:"test",label:n("ui.settings.integrations.integration_model.test_connection")}),c("connect")&&i!=="connect"&&r!=="connected"&&l.push({kind:"connect",label:n("ui.settings.integrations.integration_model.reconnect")}),!d&&c("sign_in")&&i!=="sign_in"&&r!=="connected"&&l.push({kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}),c("reload")&&l.push({kind:"reload",label:n("ui.settings.integrations.integration_model.reload")}),!d&&c("reauth")&&i!=="reauth"&&l.push({kind:"reauth",label:n("ui.settings.integrations.integration_model.sign_in_again")}),ln(t)&&i!=="set_key"&&l.push({kind:"set_key",label:t.auth.secret_refs.length>0?n("ui.settings.integrations.integration_model.update_key"):n("ui.settings.integrations.integration_model.add_key")}),c("sign_out")&&l.push({kind:"sign_out",label:n("ui.settings.integrations.integration_model.sign_out")}),c("disconnect")&&r==="connected"&&l.push({kind:"disconnect",label:n("ui.settings.integrations.integration_model.disconnect")}),c("copy_setup")&&t.setup_prompt&&l.push({kind:"copy_setup",label:n("ui.settings.integrations.integration_model.copy_setup_prompt")}),i!=="fix"&&l.push({kind:"open_config",label:n("ui.settings.integrations.integration_model.open_config_file")}),c("remove"))l.push({kind:"remove",label:n("ui.settings.integrations.integration_model.remove"),destructive:!0});else if(!t.source.editable){const u=wi(t);l.push({kind:"remove_elsewhere",label:u?n("ui.settings.integrations.integration_model.remove_in_origin",{origin:String(u)}):n("ui.settings.integrations.integration_model.remove_in_its_own_file"),hint:u?n("ui.settings.integrations.integration_model.defined_in_origin_s_config_remove_it_there",{origin:String(u)}):n("ui.settings.integrations.integration_model.defined_in_a_file_this_app_doesn_t_write_remove_it_there")})}return l}const tg={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 Si(t,s=[],a){const i=Qe(a,t.name),r=it(t.name,s),c=ys(t,i);if(r&&i.pinnedGroup&&i.pinnedOperationId===r.id)return i.pinnedGroup;if(c==="needs_sign_in"||c==="error")return"attention";const l=At(t.name,s,i);return dn(l)&&c!=="connected"||vs(l)&&c!=="connected"?"attention":i.disconnectedAt!==null?"ready":yt(t,s,i)||i.needsSignIn&&c!=="connected"||l?.status==="failed"&&Et(l)&&c!=="connected"?"attention":c==="connected"||t.status_basis==="stored"&&xs(t,i)?"connected":r&&r.action!=="test"?"attention":"ready"}function ng(t,s=[],a){return["attention","connected","ready"].map(r=>({id:r,title:tg[r],rows:t.filter(c=>Si(c,s,a)===r)})).filter(r=>r.rows.length>0)}function sg(t,s,a=Date.now()){if(!s)return t??{};const i={};for(const r of s.servers){const c=Qe(t,r.name),l=it(r.name,s.operations),d=At(r.name,s.operations,c),u=dn(d),m=r.status==="connected"&&(r.status_basis==="probe"||r.status_basis==="live"),p=c.holdUntil!==null&&a<c.holdUntil,g=!p&&!u&&c.connectedAt===null&&r.status_basis==="stored"&&r.tool_count_basis==="last_seen"?ki(r.last_seen_at,a):null,_=!u,x=d?.status==="failed"&&Et(d)&&Ni.test(d.message??""),k={connectedAt:m&&!p?a:g!==null?g:_?c.connectedAt:null,connectedToolCount:m&&!p||g!==null?r.tool_count??c.connectedToolCount:_?c.connectedToolCount:null,settledGroup:c.settledGroup,pinnedGroup:l&&c.pinnedOperationId===l.id?c.pinnedGroup:l?c.settledGroup:null,pinnedOperationId:l?l.id:null,needsKey:m?!1:c.needsKey||x,needsSignIn:m||u?!1:c.needsSignIn||r.status==="needs_sign_in",disconnectedAt:m&&!p?null:c.disconnectedAt,holdUntil:p?c.holdUntil:null,lastDecisive:d?Hm(d):null};l||(k.settledGroup=Si(r,s.operations,{...i,[r.name]:k})),i[r.name]=k}return i}const ag=(t,s)=>t!==null&&s===t,Jn="local-operator.settings.integrations.row-memory",Ci=(t,s)=>`${t}#${s}`;function ig(t,s){const a={};if(!s)return a;for(const i of s.servers){const r=t[i.name];r&&(a[Ci(i.source.path,i.name)]=r)}return a}function rg(t,s,a){if(!s)return t;let i=null;for(const r of s.servers){if(Object.prototype.hasOwnProperty.call(t,r.name))continue;const c=lg(a[Ci(r.source.path,r.name)]);c&&(i=i??{...t},i[r.name]=c)}return i??t}const og=["attention","connected","ready"],Mi=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),ks=t=>typeof t=="number"&&Number.isFinite(t)?t:null,sa=t=>og.includes(t)?t:null,En=t=>{const s=ks(t);return s!==null&&s>=1e12?s:null};function cg(t){if(!Mi(t)||typeof t.id!="string"||typeof t.name!="string")return null;const s=t.action,a=t.status;return s!=="login"&&s!=="logout"&&s!=="reauth"&&s!=="test"||a!=="running"&&a!=="complete"&&a!=="cancelled"&&a!=="failed"?null:{id:t.id,name:t.name,action:s,status:a,created_at:ks(t.created_at)??0,credential_removed:t.credential_removed===!0,...typeof t.message=="string"?{message:t.message}:{}}}function lg(t){if(!Mi(t))return null;const s=En(t.connectedAt),a=En(t.disconnectedAt),i=t.needsKey===!0,r=t.needsSignIn===!0,c=cg(t.lastDecisive);return s===null&&a===null&&!i&&!r&&!c?null:{connectedAt:s,connectedToolCount:ks(t.connectedToolCount),settledGroup:sa(t.settledGroup),pinnedGroup:sa(t.pinnedGroup),pinnedOperationId:typeof t.pinnedOperationId=="string"?t.pinnedOperationId:null,needsKey:i,needsSignIn:r,disconnectedAt:a,holdUntil:En(t.holdUntil),lastDecisive:c}}const Ai=2e3,aa=8e3;function dg(t){return t&&(t.servers.some(a=>a.status==="connecting")||t.operations.some(a=>a.status==="running"))?Ai:!1}const ug=/^[A-Za-z0-9_.:-]{1,100}$/,mg=/:\/\//;function gg(t,s){const a=t.trim();return a?ug.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 pg(t){const s=t.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"):mg.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 hg=t=>t.split(`
|
|
292
|
-
`).map(s=>s.trim()).filter(Boolean);function Xn(t,s){const a=!!t?.cold,i=(t?.servers??[]).map(r=>{const c=r.transport==="http",l=r.secret_refs??[],d=r.status==="connected"?"connected":r.status==="connecting"?"connecting":r.status==="auth-required"?"needs_sign_in":"not_started",u=[];d!=="connected"&&u.push("connect"),d==="connected"&&u.push("disconnect"),a||u.push("reload"),c&&r.transport_oauth_supported!==!1&&u.push("sign_in"),l.length>0&&u.push("set_key"),r.owned_scope&&u.push("remove"),r.setup?.text&&u.push("copy_setup");const m=bi(r.source);return{id:r.name,name:r.name,scope:r.owned_scope??"global",project_cwd:null,source:{kind:fg(r.source,m,r.owned_scope),path:r.source??"",editable:r.owned_scope!==null,owned_scope:r.owned_scope},transport:c?"remote_url":"local_command",endpoint:{command:null,url:null,endpoint_redacted:!1},status:d,status_reason:null,status_observed_at:null,last_seen_at:null,status_basis:a?"stored":"live",auth:{kind:l.length?"api_key":c?"unknown":"none",signed_in:null,secret_refs:l.map(p=>({id:p.id,state:"missing"}))},tool_count:typeof r.tool_count=="number"?r.tool_count:null,tool_count_basis:typeof r.tool_count=="number"?"live":null,actions:u,setup_prompt:r.setup?.text??null}});return{cwd:"",project_scope_available:i.some(r=>r.source.owned_scope==="project"),global_path:"",project_path:null,status_source:a?"config":"live",session_id:s,servers:i,operations:(t?.operations??[]).map(r=>({...r}))}}const fg=(t,s,a)=>s==="Claude Code"?"claude-code":s==="Cursor"?"cursor":s==="VS Code"?"vscode":s==="Codex CLI"?"codex":a?"local-operator":t?"project-mcp-json":"local-operator",ia={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")}},_g="ui.settings.integrations.integration_model.copy_catalog_refusal_fallback";function Pt(t,s,a){if(s instanceof ts&&s.status===409){const i=typeof s.code=="string"&&Object.prototype.hasOwnProperty.call(ia,s.code)?ia[s.code]:n(_g);return`${Or[t]}. ${i}`}return Dr(t,s,a).message}const xg="ui.settings.integrations.add_integration_form.copy_add_integration_pickup_note",yg="ui.settings.integrations.add_integration_form.copy_transport_hint",bg=({existingNames:t,projectScopeAvailable:s,projectLabel:a,onSubmit:i,onCancel:r,initial:c})=>{te();const[l,d]=o.useState(c?.name??""),[u,m]=o.useState(c?.mode??"command"),[p,g]=o.useState(c?.command??""),[_,x]=o.useState(c?.args??""),[k,b]=o.useState(c?.url??""),[S,I]=o.useState("global"),[M,L]=o.useState(c?.touched?{name:!0,command:!0,url:!0}:{}),[E,O]=o.useState(!!c?.touched),[y,F]=o.useState(!1),[K,P]=o.useState(null),f=o.useRef(null),A=o.useRef(null),T=o.useRef(null);o.useEffect(()=>{f.current?.focus()},[]);const v=gg(l,t),H=u==="command"&&!p.trim()?n("ui.settings.integrations.add_integration_form.enter_the_command_to_run"):null,z=u==="url"?pg(k):null,q=j=>E||M[j],Z=async j=>{if(j.preventDefault(),O(!0),v||H||z){v?f.current?.focus():H?A.current?.focus():T.current?.focus();return}F(!0),P(null);const U=s?S:"global",ne=u==="command"?{name:l.trim(),scope:U,mode:u,command:p.trim(),args:hg(_)}:{name:l.trim(),scope:U,mode:u,url:k.trim()},Y=await i(ne);F(!1),P(Y)},h=(j,U,ne)=>U&&q(ne)?e.jsx("p",{id:j,className:"text-body-sm text-danger",children:U}):null,R=j=>j.preventDefault();return e.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:j=>void Z(j),onKeyDown:j=>{j.key==="Escape"&&(j.stopPropagation(),r())},children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(De,{htmlFor:"integration-add-name",children:n("ui.settings.integrations.add_integration_form.name")}),e.jsx(Ne,{ref:f,id:"integration-add-name",value:l,placeholder:n("ui.settings.integrations.add_integration_form.e_g_notion"),autoComplete:"off","aria-invalid":!!(v&&q("name")),"aria-describedby":v&&q("name")?"integration-add-name-error":void 0,onChange:j=>d(j.target.value),onBlur:()=>L(j=>({...j,name:!0}))}),h("integration-add-name-error",v,"name")]}),e.jsxs(kt,{value:u,onValueChange:j=>m(j==="url"?"url":"command"),className:"flex flex-col gap-1.5",children:[e.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")}),e.jsxs(jt,{"aria-labelledby":"integration-add-transport-label",children:[e.jsx(Ye,{value:"command","data-integration-transport":"command",children:n("ui.settings.integrations.add_integration_form.local_command")}),e.jsx(Ye,{value:"url","data-integration-transport":"url",children:n("ui.settings.integrations.add_integration_form.remote_url")})]}),e.jsx("p",{className:"text-ink-dim text-meta",children:n(yg)}),e.jsxs(Os,{value:"command",className:"mt-0 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(De,{htmlFor:"integration-add-command",children:n("ui.settings.integrations.add_integration_form.command")}),e.jsx(Ne,{ref:A,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&&q("command")),"aria-describedby":H&&q("command")?"integration-add-command-error":void 0,onChange:j=>g(j.target.value),onBlur:()=>L(j=>({...j,command:!0}))}),h("integration-add-command-error",H,"command")]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs(De,{htmlFor:"integration-add-args",children:[n("ui.settings.integrations.add_integration_form.arguments")," ",e.jsx("span",{className:"font-normal text-ink-dim",children:n("ui.settings.integrations.add_integration_form.one_per_line")})]}),e.jsx(ps,{id:"integration-add-args",value:_,rows:2,className:"font-mono",onChange:j=>x(j.target.value)})]})]}),e.jsx(Os,{value:"url",className:"mt-0 flex flex-col gap-4",children:e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(De,{htmlFor:"integration-add-url",children:n("ui.settings.integrations.add_integration_form.url")}),e.jsx(Ne,{ref:T,id:"integration-add-url",type:"url",value:k,placeholder:n("ui.settings.integrations.add_integration_form.https_mcp_example_com_mcp"),autoComplete:"off",className:"font-mono","aria-invalid":!!(z&&q("url")),"aria-describedby":z&&q("url")?"integration-add-url-error":"integration-add-url-help",onChange:j=>b(j.target.value),onBlur:()=>L(j=>({...j,url:!0}))}),h("integration-add-url-error",z,"url")??e.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?e.jsxs(kt,{value:S,onValueChange:j=>I(j==="project"?"project":"global"),className:"flex flex-col gap-1.5",children:[e.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")}),e.jsxs(jt,{"aria-labelledby":"integration-add-scope-label",children:[e.jsx(Ye,{value:"global","data-integration-scope":"global",children:n("ui.settings.integrations.add_integration_form.all_chats")}),e.jsx(Ye,{value:"project","data-integration-scope":"project",children:n("ui.settings.integrations.add_integration_form.this_project")})]}),a?e.jsx("p",{className:"text-ink-dim text-meta",children:S==="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,K?e.jsx("p",{className:"text-body-sm text-danger",role:"alert",children:K}):null,e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:ge("text-body-sm text-ink-dim"),children:n(xg)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{type:"button",variant:"ghost",size:"md",onMouseDown:R,onClick:r,children:n("ui.settings.integrations.add_integration_form.cancel")}),e.jsxs(D,{type:"submit",variant:"primary",size:"md",disabled:y,onMouseDown:R,children:[y?e.jsx(Ee,{size:"xs"}):null,n("ui.settings.integrations.add_integration_form.add_integration")]})]})]})]})},vg=4;function kg(t){return t.rowMoving?t.now+t.windowMs:Math.max(t.hold.until,t.lastMovingAt+t.windowMs)}function jg(t){return t.now>t.hold.until||t.hold.reanchors>=vg?"drop":t.hold.landedOn.isConnected&&(!t.candidate||t.candidate===t.hold.landedOn)?"settled":t.active&&t.active!==t.body&&t.active!==t.hold.landedOn?"drop":t.candidate?.isConnected?"restore":"drop"}function wg(t){const s=kg({hold:t.hold,now:t.now,windowMs:t.windowMs,rowMoving:t.rowMoving,lastMovingAt:t.lastMovingAt});if(t.now>s)return{hold:null,land:null};const a=t.hold.landedOn??null,i=t.candidate;if(!i)return{hold:{until:s,reanchors:t.hold.reanchors,landedOn:a},land:null};if(!a)return{hold:{until:s,reanchors:t.hold.reanchors,landedOn:i},land:i};const r=jg({hold:{until:s,reanchors:t.hold.reanchors,landedOn:a},candidate:i,active:t.active,body:t.body,now:t.now});if(r==="settled")return{hold:{until:s,reanchors:t.hold.reanchors,landedOn:a},land:null};if(r==="drop")return{hold:null,land:null};const c=!a.isConnected;return{hold:{until:c?t.now+t.windowMs:s,reanchors:c?t.hold.reanchors+1:t.hold.reanchors,landedOn:i},land:i}}function Ng(t){const{row:s,target:a}=t;return!s||!a||typeof a.nodeType!="number"?!1:!s.contains(a)}const ra=250;function oa(t){return t?!t.disabled:!1}function Sg(t){return oa(t.primary)?t.primary??null:oa(t.overflow)?t.overflow??null:null}function Cg(t){return t.verdict==="finished"?null:t.watchMs}const Ei="key";function Mg(t){const{name:s,keyless:a,freeName:i,names:r,values:c,replace:l,canReplace:d}=t;if(a){const u=es(s,i);return{values:{[u]:(c[Ei]??"").trim()},confirmedReplace:l&&d?[u]:[],header:i.trim()}}return{values:Object.fromEntries(r.map(u=>[u,(c[u]??"").trim()])),confirmedReplace:l&&d?r:[],header:void 0}}function es(t,s){const a=ca(t),i=ca(s);if(!i)return"";const r=[a,i].filter(Boolean).join("_"),c=/^[A-Za-z_]/.test(r)?r:`K_${r}`;if(c.length<=In)return c;const l=Ag(a),d=In-i.length-l.length-2,u=[a.slice(0,Math.max(d,0)),l,i].filter(Boolean).join("_");return u.length<=In?u:u.slice(-128)}const In=128,ca=t=>t.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,""),Ag=t=>{let s=2166136261;for(let a=0;a<t.length;a+=1)s^=t.charCodeAt(a),s=Math.imul(s,16777619)>>>0;return s.toString(36).toUpperCase().slice(0,5)},Eg=({name:t,keyNames:s,keyless:a=!1,savedKeys:i=[],saving:r,failure:c,onSave:l,onClose:d})=>{te();const[u,m]=o.useState({}),[p,g]=o.useState(!1),[_,x]=o.useState(""),k=a?[es(t,_)]:[...s],b=a?[Ei]:k,S=(a?es(t,_).length>0:!0)&&b.every(M=>(u[M]??"").trim()),I=k.some(M=>i.includes(M));return e.jsx(La,{open:!0,onClose:d,maxWidth:"xs",title:n("ui.settings.integrations.integration_key_dialog.add_keys_heading",{count:a?1:s.length,name:t}),actions:e.jsxs(e.Fragment,{children:[e.jsx(Un,{onClick:d,children:n("ui.settings.integrations.integration_key_dialog.cancel")}),e.jsx(Kn,{disabled:!S||r,onClick:()=>{const M=Mg({name:t,keyless:a,freeName:_,names:k,values:u,replace:p,canReplace:I});l(M.values,M.confirmedReplace,M.header)},children:r?n("ui.settings.integrations.integration_key_dialog.saving"):n("ui.settings.integrations.integration_key_dialog.save_and_test")})]}),children:e.jsxs("div",{className:"flex flex-col gap-3 p-1.5 text-body text-ink-muted",children:[e.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?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(De,{htmlFor:"integration-key-name",children:n("ui.settings.integrations.integration_key_dialog.the_header_this_server_wants_the_key_in")}),e.jsx(Ne,{id:"integration-key-name",autoComplete:"off",placeholder:n("ui.settings.integrations.integration_key_dialog.e_g_authorization_or_x_api_key"),value:_,onChange:M=>x(M.target.value)}),e.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,b.filter(M=>a!==!0||M.trim().length>0).map(M=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(De,{htmlFor:`integration-key-${M}`,className:"font-mono",children:a?"Key":M}),e.jsx(Ne,{id:`integration-key-${M}`,type:"password",autoComplete:"off",value:u[M]??"",onChange:L=>m(E=>({...E,[M]:L.target.value}))})]},M)),I?e.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx(Vn,{id:"integration-key-replace",checked:p,onCheckedChange:M=>g(M===!0)}),e.jsx(De,{htmlFor:"integration-key-replace",className:"font-normal",children:ji(k.length)})]}):null,c?e.jsx("p",{className:"-mx-1.5 text-body-sm text-danger",role:"alert",children:c}):null]})})},Ig={success:"bg-success",warning:"bg-warning",danger:"bg-danger",info:"bg-info",neutral:"bg-ink-dim"},Rg={success:"text-ink-muted",warning:"text-warning",danger:"text-danger",info:"text-ink-muted",neutral:"text-ink-dim"},Tg=({row:t,operations:s,memories:a,now:i,projectScopeAvailable:r,highlighted:c=!1,rowRef:l,primaryRef:d,overflowRef:u,pending:m,failure:p,confirm:g,onPrimary:_,onOverflow:x,onConfirm:k,onCancelConfirm:b})=>{te();const S=Wm(t,s,a,i),I=c&&S.tone==="danger"?"text-ink":Rg[S.tone],M=bs(t,s,a),L=eg(t,s,a),E=Xm(t,r),O=L.findIndex(y=>y.kind==="remove"||y.kind==="remove_elsewhere");return e.jsxs("li",{ref:l,"data-integration":t.name,"data-search-row":`integration.${t.id}`,"data-search-control":!0,"data-status":t.status,className:ge("flex min-h-14 flex-col justify-center gap-1 px-4 py-2.5",c&&"bg-row-selected"),onKeyDown:y=>{!g||y.key!=="Escape"||(y.stopPropagation(),b())},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:S.busy?e.jsx(Ee,{size:"xs"}):e.jsx("span",{"aria-hidden":"true","data-tone":S.tone,className:ge("size-2 rounded-full",Ig[S.tone])})}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",title:t.name,children:t.name}),e.jsx("span",{className:"truncate text-ink-dim text-meta",children:E.map((y,F)=>e.jsxs("span",{children:[F>0?" · ":null,y.importSource&&t.source.path?e.jsx(Pe,{content:dr(t.source.path),children:e.jsx("span",{className:"underline decoration-dotted underline-offset-2",children:y.text})}):y.text]},y.text))})]}),S.explanation?e.jsx(Pe,{content:S.explanation,children:e.jsx("span",{className:ge("shrink-0 text-body-sm",I),children:S.label})}):e.jsx("span",{className:ge("shrink-0 text-body-sm",I),children:S.label}),M?e.jsxs(D,{ref:d,variant:M.variant??"secondary",size:"sm","aria-label":`${M.label} ${t.name}`,disabled:m,"data-integration-action":M.kind,onClick:()=>_(M),children:[m?e.jsx(Ee,{size:"xs"}):null,M.label]}):null,e.jsxs(Za,{children:[e.jsx(Ja,{asChild:!0,children:e.jsx(D,{ref:u,variant:"ghost",size:"icon-sm","aria-label":n("ui.settings.integrations.integration_row.more_actions_for_name",{name:String(t.name)}),disabled:m,children:e.jsx(Oa,{"aria-hidden":"true"})})}),e.jsx(Xa,{align:"end",className:"min-w-48",children:L.map((y,F)=>e.jsx(Lg,{item:y,separated:F===O&&F>0,onSelect:()=>x(y)},y.kind))})]})]}),S.detail?e.jsx("p",{className:ge("ps-7 text-body-sm",S.tone==="danger"?"text-ink-muted":"text-ink-dim"),children:S.detail}):null,p?e.jsx("p",{className:ge("ps-7 text-body-sm",c?"text-ink":"text-danger"),role:"alert",children:p}):null,g?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 ps-7",children:[e.jsx("span",{className:"text-body-sm text-ink",children:g.kind==="remove"?n("ui.settings.integrations.integration_row.remove_name",{name:String(t.name)}):n("ui.settings.integrations.integration_row.sign_out_of_name",{name:String(t.name)})}),e.jsx("span",{className:"text-body-sm text-ink-muted",children:g.kind==="remove"?n("ui.settings.integrations.integration_row.agents_in_every_chat_lose_access_to_name",{name:String(t.name)}):t.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")}),e.jsx(D,{variant:"danger",size:"sm",onClick:k,"data-integration-confirm":g.kind,children:g.kind==="remove"?n("ui.settings.integrations.integration_row.remove"):n("ui.settings.integrations.integration_row.sign_out")}),e.jsx(D,{variant:"ghost",size:"sm",onClick:b,children:n("ui.settings.integrations.integration_row.keep")})]}):null]})},Lg=({item:t,separated:s,onSelect:a})=>(te(),e.jsxs(e.Fragment,{children:[s?e.jsx(gc,{}):null,t.kind==="remove_elsewhere"?e.jsxs(Xe,{disabled:!0,className:"flex-col items-start gap-0.5",children:[e.jsx("span",{children:t.label}),e.jsx("span",{className:"text-meta text-ink-dim",children:t.hint})]}):e.jsx(Xe,{destructive:t.kind==="remove",onSelect:a,"data-integration-menu":t.kind,children:t.label})]}));function Og(t,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(t)}),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(t)}),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(t)}),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:Qm(s.message,a)??n("ui.settings.integrations.integration_sign_in_dialog.the_server_didn_t_say_why"),nextStep:Dg(s.message??null,a)}}function Dg(t,s){const a=(t??"").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 Fg(t,s){return t.kind==="ready"?"ready":t.kind==="running"&&s&&s.tone!=="progress"?s.tone==="success"?"success":"failure":"running"}const zg=({name:t,action:s,keyRoute:a,phase:i,onStart:r,onCancel:c,onOpenLink:l,onClose:d})=>{te();const u=i.kind==="running"?i.operation:null,m=i.kind==="running"?Og(t,u,a):null,p=i.kind==="starting"||i.kind==="running"&&m?.tone==="progress",g=m&&m.tone!=="progress",_=o.useRef(null),x=o.useRef(!1),k=Fg(i,m);o.useEffect(()=>{if(!x.current){x.current=!0;return}k&&_.current?.focus()},[k]);const b=()=>d(m?.tone==="success"?"signed-in":"dismissed");return e.jsx(La,{open:!0,onClose:b,maxWidth:"xs",fullWidth:!0,title:n("ui.settings.integrations.integration_sign_in_dialog.sign_in_to_name",{name:String(t)}),dialogProps:{onOpenAutoFocus:S=>{S.preventDefault(),_.current?.focus()}},actions:e.jsxs(e.Fragment,{children:[p&&u?e.jsx(Un,{ref:_,onClick:()=>c(u.id),children:n("ui.settings.integrations.integration_sign_in_dialog.cancel_sign_in")}):e.jsx(Un,{ref:i.kind==="ready"?void 0:_,onClick:b,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"?e.jsx(Kn,{ref:_,onClick:r,children:n("ui.settings.integrations.integration_sign_in_dialog.continue_in_browser")}):null,i.kind==="refused"||m?.tone==="failure"?e.jsx(Kn,{ref:m?.tone==="failure"?_:void 0,onClick:r,children:n("ui.settings.integrations.integration_sign_in_dialog.try_again")}):null]}),children:e.jsxs("div",{className:"flex flex-col gap-3 p-1.5 text-body text-ink-muted","aria-live":"polite",children:[i.kind==="ready"?e.jsx("p",{className:"-mx-1.5",children:n("ui.settings.integrations.integration_sign_in_dialog.browser_approval_notice",{name:t,replaces:s==="reauth"?"yes":"no"})}):null,i.kind==="starting"?e.jsxs("p",{className:"-mx-1.5 flex items-center gap-2",children:[e.jsx(Ee,{size:"xs"}),n("ui.settings.integrations.integration_sign_in_dialog.starting_sign_in")]}):null,m?e.jsxs("div",{className:"flex flex-col gap-1",role:g?"status":void 0,children:[e.jsxs("p",{className:(m.tone==="success","-mx-1.5 flex items-start gap-2 text-ink"),children:[m.tone==="progress"?e.jsx(Ee,{size:"xs",className:"mt-0.5"}):null,m.tone==="failure"?e.jsx(Qa,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-danger"}):null,e.jsx("span",{children:m.message})]}),m.reason?e.jsx("p",{className:"-mx-1.5 text-ink-muted",children:m.reason}):null,m.nextStep?e.jsx("p",{className:"-mx-1.5 text-ink-muted",children:m.nextStep}):null]}):null,m?.link&&m.tone==="progress"?e.jsxs("div",{className:"flex flex-col items-start gap-1",children:[e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-ink-dim text-mono-sm",title:m.link,children:m.link}),e.jsx(D,{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(()=>Bn(n("ui.settings.integrations.integration_sign_in_dialog.sign_in_link_copied"))).catch(()=>{})},children:e.jsx(Ta,{"aria-hidden":"true"})})]}),e.jsx(D,{variant:"link",size:"sm",onClick:()=>l(m.link??""),children:n("ui.settings.integrations.integration_sign_in_dialog.open_the_sign_in_page")})]}):null,i.kind==="refused"?e.jsx("p",{className:"text-danger",role:"alert",children:i.message}):null]})})},Pg=t=>t.reduce((s,a)=>s?(a.updated_at??0)>(s.updated_at??0)?a:s:a,null),$g=/^[A-Za-z]:[\\/]/,Xt=t=>{const s=t?.trim();return s&&(s.startsWith("/")||$g.test(s))?s:null};function Ug(t){const r=t?.payload?.frontend?.snapshot?.cwd;return typeof r=="string"&&r.trim()?r:null}const Nt="local-operator.settings.integrations.last-cwd";function Kg(t,s,a=typeof localStorage>"u"?null:localStorage){const i=Xt(s);if(!(!t||!i||!a))try{const r=a.getItem(Nt),c=r?JSON.parse(r):{};if(c[t]===i)return;a.setItem(Nt,JSON.stringify({...c,[t]:i}))}catch{}}const Ii=()=>typeof localStorage>"u"?null:localStorage;function Ri(t=Ii()){if(!t)return{};try{const s=t.getItem(Jn);if(!s)return{};const a=JSON.parse(s);return!a||typeof a!="object"||Array.isArray(a)?{}:a}catch{return{}}}const la=256;function Bg(t,s=Ii()){if(s)try{const a={...Ri(s),...t},i=Object.keys(a);if(i.length>la){const r={};for(const c of i.slice(-la))r[c]=a[c];s.setItem(Jn,JSON.stringify(r));return}s.setItem(Jn,JSON.stringify(a))}catch{}}function da(t,s,a){if(t==="saved")return null;if(t==="replace_confirmation_required"){const r=ji(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(r)})}if(t==="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 Hg(t,s=typeof localStorage>"u"?null:localStorage){if(!(!t||!s))try{const a=s.getItem(Nt);if(!a)return;const i=JSON.parse(a);if(!(t in i))return;const r={...i};delete r[t],s.setItem(Nt,JSON.stringify(r))}catch{}}const qg=t=>!!(t&&typeof t=="object"&&"code"in t&&t.code==="invalid_cwd"),Vg=(t,s)=>s!==null&&t===s?null:t;function Gg(t,s=typeof localStorage>"u"?null:localStorage){if(!t||!s)return null;try{const a=s.getItem(Nt);if(!a)return null;const r=JSON.parse(a)[t];return typeof r=="string"?r:null}catch{return null}}const Wg=t=>t.action==="disconnect"?"disconnected":"connected";function Yg(t){switch(t.action){case"cancel":return{action:"cancel",operation_id:t.operationId};case"connect":case"disconnect":case"reload":return null;case"test":return{action:"test",name:t.name};default:return{...t,confirmed:!0}}}function Qg(t){switch(t.action){case"cancel":return{action:"cancel",operation_id:t.operationId};case"test":case"connect":return{action:"connect",name:t.name};case"reload":return{action:"reload",name:t.name};case"add":return t;case"remove":return{...t,confirmed:!0};default:return{action:t.action,name:t.name,confirmed:!0}}}function Zg({sessionId:t}){const s=Ct(),a=at(s.data,"mcp_catalog"),i=at(s.data,"mcp"),r=a?"catalog":i?"session":null,[c,l]=o.useState(null),d=St(),u=ft(B=>B.sessions),m=ft(B=>B.fetchSessions),p=ft(B=>B.loading),g=o.useMemo(()=>u.find(B=>B.session_id===t)??null,[u,t]),_=o.useMemo(()=>r==="session"&&!t?Pg(u):null,[r,t,u]),x=r==="session"?t??_?.session_id??null:null;o.useEffect(()=>{r!=="session"||t||u.length>0||m(ur)},[r,t,u.length,m]);const k=r==="catalog"?Xt(g?.cwd):null,b=r==="catalog"&&!!t&&k===null,S=Te({queryKey:["desktop","session-cwd",t??""],queryFn:()=>je({op:"sessions.get",sessionId:t??""}),enabled:b,staleTime:Number.POSITIVE_INFINITY,retry:!1}),I=b&&!S.isFetched,M=k??Xt(Ug(S.data))??(S.isFetched?Xt(Gg(t)):null),L=Vg(M,c),E=r==="catalog"?L:null,O=r==="catalog"?t??null:null,y=Fr.catalog(E,O);o.useEffect(()=>{r!=="catalog"||!t||!E||Kg(t,E)},[r,t,E]);const F=o.useRef(0),[K,P]=o.useState(0),f=o.useRef(null),A=o.useCallback((B,N)=>{const G=Date.now()+aa;F.current=G,f.current={name:B,expect:N},P(G)},[]),T=o.useCallback(B=>Date.now()<F.current?Ai:dg(B),[]),v=Te({queryKey:y,queryFn:()=>$r(E,O),enabled:r==="catalog"&&!I,staleTime:1e4,refetchInterval:B=>T(B.state.data)}),H=qg(v.error);o.useEffect(()=>{!H||!M||c===M||(l(M),Hg(t))},[H,M,c,t]);const z=Te({queryKey:Hn.list(x??""),queryFn:()=>Ur(x??""),enabled:r==="session"&&!!x,staleTime:1e4,refetchInterval:B=>T(B.state.data?Xn(B.state.data,x??""):void 0)}),q=o.useMemo(()=>{if(r==="catalog")return v.data;if(r==="session"&&z.data&&x)return Xn(z.data,x)},[r,v.data,z.data,x]),Z=o.useCallback(()=>Jg({queryClient:d,route:r,catalogKey:y,sessionId:x}),[r,y,d,x]);o.useEffect(()=>{if(!K)return;const B=f.current;if(!B)return;const N=q?.servers.find(ae=>ae.name===B.name);!N||!(B.expect==="connected"?N.status==="connected":N.status_basis==="live"&&N.status!=="connected")||(F.current=0,f.current=null,P(0))},[q,K]);const h=o.useRef({}),[R,j]=o.useState(0),U=o.useMemo(()=>(h.current=sg(rg(h.current,q,Ri()),q),h.current),[q,R]),ne=o.useRef("");o.useEffect(()=>{const B=ig(U,q);if(!Object.keys(B).length)return;const N=JSON.stringify(B);N!==ne.current&&(ne.current=N,Bg(B))},[U,q]);const Y=o.useCallback(B=>{const N=Qe(h.current,B);N.needsKey||(h.current={...h.current,[B]:{...N,needsKey:!0}},j(G=>G+1))},[]),X=o.useCallback(B=>{if(B.action!=="disconnect"&&B.action!=="connect"&&B.action!=="reload")return;const N=Qe(h.current,B.name),G=Date.now()+aa,ae=B.action==="disconnect"?{...N,connectedAt:null,disconnectedAt:Date.now(),holdUntil:G}:{...N,disconnectedAt:null,holdUntil:G};h.current={...h.current,[B.name]:ae},A(B.name,Wg(B)),j(J=>J+1)},[A]),re=o.useCallback(async B=>{if(r==="catalog"){const N=Yg(B);if(!N)return null;try{const G=await zr(E,N);return d.setQueryData(y,G),X(B),G.operation?.id??null}catch(G){throw G instanceof ts&&G.status===409&&d.invalidateQueries({queryKey:y}),G}}if(r==="session"&&x){const N=await je({op:"mcp.control",sessionId:x,control:Qg(B)});X(B);const G=Hn.list(x),ae=N?.data;return ae&&"servers"in ae&&Array.isArray(ae.servers)?(d.setQueryData(G,ae),null):(d.invalidateQueries({queryKey:G}),ae&&"id"in ae&&typeof ae.id=="string"?ae.id:null)}return null},[r,E,y,d,x,X]),ce=o.useCallback(async B=>{if(r==="catalog"&&O&&(B.action==="connect"||B.action==="disconnect"||B.action==="reload")){try{await je({op:"mcp.control",sessionId:O,control:{action:B.action,name:B.name,...B.action==="disconnect"?{confirmed:!0}:{}}})}catch(N){throw d.invalidateQueries({queryKey:y}),N}return X(B),await d.invalidateQueries({queryKey:y}),null}return re(B)},[r,O,d,y,re,X]),de=o.useCallback(async(B,N,G,ae)=>{if(r==="catalog"){const J=await Pr(E,B,N,G,ae);if(J.catalog&&d.setQueryData(y,J.catalog),J.code!=="saved")return{saved:!1,message:da(J.code,J.failed_ids,N)};try{await re({action:"test",name:B})}catch{}return{saved:!0,message:null}}if(r==="session"&&x){const J=await je({op:"mcp.credentials.store",sessionId:x,name:B,values:N,confirmedReplace:G});if(J.data?.code!=="saved")return{saved:!1,message:da(J.data?.code,J.data?.failed_ids??[],N)};try{await re({action:"connect",name:B})}catch{}return{saved:!0,message:null}}return{saved:!1,message:null}},[r,E,y,d,re,x]),be=r==="catalog"?v:z,pe=o.useCallback(()=>{be.refetch()},[be]);return{enabled:r!==null,route:r,sessionId:r==="catalog"?O:x,borrowed:_,noConversation:r==="session"&&!x&&!p,document:q,isLoading:s.isLoading||r==="catalog"&&(I||v.isLoading)||r==="session"&&(x?z.isLoading:p),isError:be.isError,folderUnavailable:ag(c,M),refetch:pe,readDocument:Z,control:ce,storeKeys:de,memories:U,markNeedsKey:Y}}function Jg(t){if(t.route==="catalog")return t.queryClient.getQueryData(t.catalogKey);if(t.route==="session"&&t.sessionId){const s=t.queryClient.getQueryData(Hn.list(t.sessionId));return s?Xn(s,t.sessionId):void 0}}const Xg=(t,s)=>{const a=t?.trim();if(!a)return null;const i=Br(a,s);return i.kind==="auth"?{kind:"matched",name:i.name,unresolved:null}:{kind:"miss",asked:a}},ep=6,Rn="ui.settings.integrations.mcp_management_section.copy_section_title",tp="ui.settings.integrations.mcp_management_section.copy_section_description",np={test:"test",connect:"reconnect",disconnect:"disconnect",reload:"reload",remove:"remove",sign_out:"disconnect",cancel:"cancel",login:"grant",reauth:"grant"},sp=({sessionId:t,sectionRef:s,highlightServer:a})=>{te();const i=Zg({sessionId:t}),{document:r,control:c,readDocument:l}=i,d=Sa(),u=r?.servers??[],m=r?.operations??[],p=r?.project_scope_available??!1,[g,_]=o.useState(!1),[x,k]=o.useState(""),[b,S]=o.useState(null),[I,M]=o.useState({}),[L,E]=o.useState(null),[O,y]=o.useState(null),[F,K]=o.useState({kind:"ready"}),[P,f]=o.useState(null),[A,T]=o.useState(null),[v,H]=o.useState(!1),z=o.useRef({}),q=o.useRef({}),Z=o.useRef({}),h=o.useRef(0),R=o.useRef(null),j=o.useRef(null),U=o.useRef(null),[ne,Y]=o.useState(null),[X,re]=o.useState(null),[ce,de]=o.useState(null),be=o.useCallback(()=>{const C=U.current;U.current=null,y(null),f(null),window.setTimeout(()=>{C?.isConnected&&C.focus()},0)},[]),pe=o.useCallback(C=>{const w=window.document.activeElement;U.current=w instanceof HTMLElement?w:null,y(C)},[]),B=o.useCallback((C,w)=>{re({name:C,waitForSignIn:w==="signed-in",until:Date.now()+gt,reanchors:0}),be()},[be]),N=o.useMemo(()=>Xg(a,u.map(C=>C.name)),[a,u]),G=N?.kind==="matched"?N.name:null,ae=o.useRef(null),J=o.useRef(null),_e=x.trim().toLowerCase(),le=o.useMemo(()=>_e?u.filter(C=>C.name.toLowerCase().includes(_e)):u,[u,_e]),we=ng(le,m,i.memories),Ie=O?.kind==="sign_in"?u.find(C=>C.name===O.name)??null:null;o.useEffect(()=>{!G||J.current===G||!x||k("")},[G,x]),o.useEffect(()=>{!G||J.current===G||le.some(C=>C.name===G)&&(J.current=G,ae.current?.scrollIntoView({block:"center",behavior:"smooth"}))},[G,le]),o.useEffect(()=>{if(!P)return;const C=m.find(w=>w.id===P)??null;K({kind:"running",operation:C})},[m,P]);const fe=m.some(C=>C.status==="running"),ee=C=>{const w=window.document.activeElement;w&&w!==window.document.body&&w.isConnected||re({name:C,waitForSignIn:!1,until:Date.now()+gt,reanchors:0})},ie=async(C,w,$)=>{S(C),M(({[C]:ve,...xe})=>xe);let Q=null,he=!1;try{Q=await $()}catch(ve){he=!0,M(xe=>({...xe,[C]:Pt(np[w]??"status",ve,fe)}))}finally{S(null),w!=="sign_out"&&(w!=="remove"||he)&&ee(C)}return{operationId:Q,failed:he}},V=C=>u.find(w=>w.name===C),se=C=>{C.source.path&&Hr(C.source.path)},oe=async(C,w)=>{K({kind:"starting"}),f(null);try{const $=await c({action:w,name:C});$?f($):K({kind:"running",operation:null})}catch($){$ instanceof ts&&$.code==="oauth_unsupported"&&i.markNeedsKey(C),K({kind:"refused",message:Pt("grant",$,fe)})}},Me=(C,w)=>{switch(w.kind){case"sign_in":case"reauth":{const $=m.find(Q=>Q.name===C.name&&Q.status==="running");$&&Et($)?(K({kind:"running",operation:$}),f($.id)):(K({kind:"ready"}),f(null)),pe({kind:"sign_in",name:C.name,action:w.kind==="reauth"?"reauth":"login"});return}case"set_key":T(null),pe({kind:"key",name:C.name,keyNames:C.auth.secret_refs.map($=>$.id)});return;case"fix":se(C);return;case"sign_out":E({name:C.name,kind:"sign_out"});return;default:{const $=w.kind;ie(C.name,$,()=>c({action:$,name:C.name}))}}},rt=(C,w)=>{switch(w.kind){case"remove":case"sign_out":E({name:C.name,kind:w.kind});return;case"sign_in":case"reauth":case"set_key":Me(C,{kind:w.kind,label:w.label});return;case"open_config":se(C);return;case"copy_setup":navigator.clipboard.writeText(C.setup_prompt??"").then(()=>Bn(n("ui.settings.integrations.mcp_management_section.setup_steps_copied_paste_them_into_a_chat"))).catch(()=>{});return;case"cancel":{const $=m.find(Q=>Q.name===C.name&&Q.status==="running");$&&ie(C.name,"cancel",()=>c({action:"cancel",operationId:$.id}));return}case"test":case"connect":case"disconnect":case"reload":{const $=w.kind;ie(C.name,$,()=>c({action:$,name:C.name}));return}default:return}},Se=(C,w)=>{if(E(null),w==="remove"){const $=C.source.owned_scope;if(!$)return;const Q=le.findIndex(he=>he.name===C.name);ie(C.name,"remove",()=>c({action:"remove",name:C.name,scope:$})).then(({operationId:he,failed:ve})=>{ve||he!==null||(Bn(n("ui.settings.integrations.mcp_management_section.removed_name",{name:String(C.name)})),Q>=0&&de({index:Q}))});return}ie(C.name,"sign_out",()=>c({action:"logout",name:C.name})).then(()=>{re({name:C.name,waitForSignIn:!1,until:Date.now()+gt,reanchors:0})})},It=async C=>{try{return await c({action:"add",name:C.name,scope:C.scope,...C.mode==="command"?{command:C.command,args:C.args}:{url:C.url}}),_(!1),Y(C.name),null}catch(w){return Pt("add",w,!1)}},Rt=e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-heading text-ink",children:n(Rn)}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:n(tp)})]}),i.enabled&&u.length>0&&!g?e.jsxs(D,{ref:R,variant:"secondary",size:"sm",onClick:()=>_(!0),"data-tour-tag":"mcp-add-server",children:[e.jsx(qn,{"aria-hidden":"true"}),n("ui.settings.integrations.mcp_management_section.add_integration")]}):null]});if(!i.enabled&&!i.isLoading)return e.jsx(ye,{title:n(Rn),titleComponent:Rt,sectionRef:s,searchSection:"integrations",searchSectionLabel:n("ui.settings.navigation.settings_sidebar.integrations"),children:e.jsx(me,{variant:"warning",children:n("ui.settings.integrations.mcp_management_section.integrations_need_a_newer_local_operator_backend_update_it_and_re")})});const ot=e.jsx(bg,{existingNames:u.map(C=>C.name),projectScopeAvailable:p,projectLabel:r?.cwd?ip(r.cwd):null,onSubmit:It,onCancel:()=>{_(!1),window.setTimeout(()=>R.current?.focus(),0)}}),ct=O?V(O.name):void 0,un=Object.entries(I).filter(([C])=>!u.some(w=>w.name===C)),mn=C=>M(({[C]:w,...$})=>$);o.useEffect(()=>{if(!ne)return;const C=z.current[ne];if(!C){u.some(w=>w.name===ne)&&(q.current[ne]?.focus(),Y(null));return}C.focus(),Y(null)},[ne,u]),o.useEffect(()=>{if(!ce)return;const w=le[Math.min(ce.index,le.length-1)]??le.at(-1);if(w){const $=z.current[w.name]??q.current[w.name];if(!$)return;$.focus()}else R.current?.focus();de(null)},[ce,le]);const Ze=o.useCallback((C,w)=>{const $=l()??r,Q=$?.servers.find(He=>He.name===C.name),he=$?.operations??[],ve=Q?Q.status==="connecting"||it(Q.name,he)!==null:!1;ve&&Q&&(h.current=w);const xe=Q?bs(Q,he,i.memories):null;if(Q&&C.waitForSignIn&&(xe?.kind==="sign_in"||xe?.kind==="reauth"))return"kept";const Re=wg({hold:C,now:w,windowMs:gt,rowMoving:ve,lastMovingAt:h.current,candidate:Q?Sg({primary:xe?z.current[Q.name]:null,overflow:q.current[Q.name]}):void 0,active:window.document.activeElement,body:window.document.body});if(!Re.hold)return re(null),"finished";if(!Re.land)return"kept";re({name:C.name,waitForSignIn:!1,until:Re.hold.until,landedOn:Re.land,reanchors:Re.hold.reanchors});const Le=Re.land;return window.setTimeout(()=>{Le.isConnected&&Le.focus()},0),"landed"},[l,r,i.memories]);return o.useEffect(()=>{if(!X)return;Ze(X,Date.now());let C=0,w=!1;const $=()=>{if(w)return;const Q=Cg({verdict:Ze(X,Date.now()),watchMs:ra});Q!==null&&(C=window.setTimeout($,Q))};return C=window.setTimeout($,ra),()=>{w=!0,window.clearTimeout(C)}},[X,Ze]),o.useEffect(()=>{if(!X)return;const C=w=>{Ng({target:w.target,row:Z.current[X.name]})&&re(null)};return window.document.addEventListener("pointerdown",C,!0),()=>{window.document.removeEventListener("pointerdown",C,!0)}},[X]),e.jsxs(ye,{title:n(Rn),titleComponent:Rt,sectionRef:s,searchSection:"integrations",searchSectionLabel:n("ui.settings.navigation.settings_sidebar.integrations"),children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[i.route==="session"&&i.borrowed?e.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?e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[e.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")}),e.jsx(D,{variant:"primary",size:"sm",onClick:()=>d("/chat"),children:n("ui.settings.integrations.mcp_management_section.start_a_chat")}),e.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?e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(Ee,{size:"lg",label:n("ui.settings.integrations.mcp_management_section.loading_integrations")})}):null,i.folderUnavailable?e.jsx(me,{variant:"warning",children:e.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?e.jsx(me,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:n("ui.settings.integrations.mcp_management_section.integrations_couldn_t_be_loaded")}),e.jsx(D,{variant:"secondary",size:"sm",onClick:i.refetch,children:n("ui.settings.integrations.mcp_management_section.retry")})]})}):null,un.map(([C,w])=>e.jsx(me,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:w}),e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>mn(C),children:n("ui.settings.integrations.mcp_management_section.dismiss")})]})},C)),g&&u.length>0?ot:null,u.length>=ep?e.jsxs("div",{className:"relative",children:[e.jsx(is,{"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 start-3 size-4 -translate-y-1/2 text-ink-dim"}),e.jsx(Ne,{ref:j,value:x,onChange:C=>k(C.target.value),onKeyDown:C=>{C.key!=="Escape"||!x||(C.preventDefault(),k(""))},placeholder:n("ui.settings.integrations.mcp_management_section.search_integrations_placeholder",{integrations:zm(u.length)}),"aria-label":n("ui.settings.integrations.mcp_management_section.search_integrations"),className:"ps-9"})]}):null,N?.kind==="miss"&&u.length>0?e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.no_match_for_name",{asked:String(N.asked)})}):null,N?.kind==="matched"&&N.unresolved?e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.showing_fallback_for_unknown",{shown:String(N.name),asked:String(N.unresolved)})}):null,r&&u.length===0&&!i.isLoading?g?ot:e.jsxs("div",{className:"flex flex-col items-start gap-3 rounded-lg bg-surface p-6",children:[e.jsx(Da,{"aria-hidden":"true",className:"size-5 text-ink-muted"}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.integrations.mcp_management_section.no_integrations_yet")}),e.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")})]}),e.jsxs(D,{variant:"primary",size:"md",onClick:()=>_(!0),"data-tour-tag":"mcp-add-server",children:[e.jsx(qn,{"aria-hidden":"true"}),n("ui.settings.integrations.mcp_management_section.add_integration")]})]}):null,u.length>0&&le.length===0?e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.no_integrations_match_this_search")}),e.jsx(D,{variant:"secondary",size:"sm",onClick:()=>{k(""),window.setTimeout(()=>{(j.current??R.current)?.focus()},0)},children:n("ui.settings.integrations.mcp_management_section.clear_search")})]}):null,we.map(C=>e.jsxs("section",{"aria-labelledby":`integrations-group-${C.id}`,className:"flex flex-col gap-1.5",children:[e.jsxs("h3",{id:`integrations-group-${C.id}`,className:"px-1 text-ink-dim text-meta",children:[C.title," · ",C.rows.length]}),e.jsx("ul",{className:"flex flex-col divide-y divide-hairline overflow-hidden rounded-lg bg-surface",children:C.rows.map(w=>e.jsx(Tg,{row:w,operations:m,memories:i.memories,projectScopeAvailable:p,highlighted:w.name===G,rowRef:$=>{Z.current[w.name]=$,w.name===G&&(ae.current=$)},primaryRef:$=>{z.current[w.name]=$},overflowRef:$=>{q.current[w.name]=$},pending:b===w.name,failure:I[w.name]??null,confirm:L?.name===w.name?{kind:L.kind}:null,onPrimary:$=>Me(w,$),onOverflow:$=>rt(w,$),onConfirm:()=>L&&Se(w,L.kind),onCancelConfirm:()=>{E(null),window.setTimeout(()=>{q.current[w.name]?.focus()},0)}},w.id))})]},C.id))]}),O?.kind==="sign_in"?e.jsx(zg,{name:O.name,action:O.action,keyRoute:Ie?ln(Ie):!1,phase:F,onStart:()=>void oe(O.name,O.action),onCancel:C=>void c({action:"cancel",operationId:C}).catch(()=>{}),onOpenLink:C=>void Kr(C),onClose:C=>B(O.name,C)}):null,O?.kind==="key"?e.jsx(Eg,{name:O.name,keyNames:O.keyNames.length?O.keyNames:ct?.auth.secret_refs.map(C=>C.id)??[],keyless:O.keyNames.length===0,savedKeys:ct?.auth.secret_refs.filter(C=>C.state==="encrypted").map(C=>C.id),saving:v,failure:A,onClose:be,onSave:(C,w,$)=>{H(!0),T(null),i.storeKeys(O.name,C,w,$).then(Q=>{if(!Q.saved){T(Q.message);return}y(null),re({name:O.name,waitForSignIn:!1,until:Date.now()+gt,reanchors:0})}).catch(Q=>T(Pt("key",Q,!1))).finally(()=>H(!1))}}):null]})},gt=4e3,ap=/^\/(?:Users|home)\/[^/]+(?=\/|$)/,ip=t=>t.replace(ap,"~"),bt=new WeakMap,ua=new WeakSet;function Ti(t,s){if(!ua.has(t)){ua.add(t);let i=tt(t);qr(t,()=>{const r=tt(t);i!==r&&(i=r,bt.delete(t))})}if(!s.startsWith(`${tt(t)}:`))return;const a=bt.get(t);if(a?.key===s)return a;bt.delete(t)}function rp(t,s,a){if(s.startsWith(`${tt(t)}:`)){if(Ti(t,s),!Object.keys(a).length){bt.delete(t);return}bt.set(t,{key:s,fields:a})}}const op=Ce.object({display_name:Ce.string(),title:Ce.string(),description:Ce.string(),timezone:Ce.string()}),cp=op.extend({account_id:Ce.string(),display_label:Ce.string(),avatar_url:Ce.string().optional(),avatar:Ce.object({source:Ce.string(),hash:Ce.string(),updated_at:Ce.string().optional()}).optional()}),lp=Ce.object({scope:Ce.string().regex(/^[a-f0-9]{64}$/),profile:cp});class ma extends Error{constructor(s,a){super("Account profile request failed"),this.code=s,this.status=a}}async function $t(t,s=null){const a=await mr(t,s);if(a.kind!=="json")throw new ma(a.kind==="error"?a.code:void 0,a.kind==="error"?a.status:null);const i=lp.parse(a.body.result);if(i.profile.account_id!==t.expectedAccountId)throw new ma("account_mismatch",409);return i}const Ut={read:t=>$t({op:"account.profile",expectedAccountId:t}),update:(t,s,a)=>$t({op:"account.profile.update",expectedAccountId:t,scope:s,fields:a}),upload:(t,s,a)=>$t({op:"account.avatar.put",expectedAccountId:t,scope:s},a),remove:(t,s,a)=>$t({op:"account.avatar.delete",expectedAccountId:t,scope:s,mode:a,confirmed:!0})};function Tn(t,s){return Object.fromEntries(Object.keys(t).filter(a=>t[a]!==s[a]).map(a=>[a,s[a]]))}const Li={snapshot:(t,s)=>["account-profile",t,s]};function Ln(t,s,a){if(tt(t)!==s||Vr(t).accountId!==a.profile.account_id)throw new Error("Account authority changed");t.setQueryData(Li.snapshot(a.profile.account_id,s),a),t.setQueryData(Es.user(),i=>{if(!i||i.account.id!==a.profile.account_id)return i;const{display_name:r,title:c,description:l,timezone:d,avatar:u,avatar_url:m}=a.profile;return{...i,account:{...i.account,profile:{...i.account.profile,display_name:r,title:c,description:l,timezone:d,avatar:u},avatar_url:m}}}),t.invalidateQueries({predicate:i=>i.queryKey[0]==="team-bridge"&&i.queryKey.some((r,c)=>r==="account"&&i.queryKey[c+1]===a.profile.account_id)}),t.invalidateQueries({queryKey:Es.user()})}function dp(t=!0,s=()=>"personal"){const a=St(),i=Fa(),r=i.accountId,c=s(),l=Te({queryKey:Li.snapshot(r??"unresolved",i.token),enabled:t&&!!r,retry:!1,queryFn:()=>Gr(a,r,()=>Ut.read(r??""))}),d=()=>{if(!r||tt(a)!==i.token||s()!==c)throw new Error("Account authority changed")};return{...l,authority:i,async update(u){if(d(),!l.data||!r)throw new Error("Account profile unresolved");const m=await Ut.update(r,l.data.scope,u);return d(),Ln(a,i.token,m),m},async upload(u){if(d(),!l.data||!r)throw new Error("Account profile unresolved");const m=await Ut.upload(r,l.data.scope,u);return d(),Ln(a,i.token,m),m},async remove(u){if(d(),!l.data||!r)throw new Error("Account profile unresolved");const m=await Ut.remove(r,l.data.scope,u);return d(),Ln(a,i.token,m),m}}}const up=1024*1024;function mp(t){const s=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.length>=24&&s.getUint32(0)===2303741511&&s.getUint32(4)===218765834&&s.getUint32(12)===1229472850)return{width:s.getUint32(16),height:s.getUint32(20)};if(t.length>=4&&t[0]===255&&t[1]===216){let a=2;for(;a+3<t.length;){if(t[a++]!==255)return null;for(;t[a]===255;)a++;const i=t[a++];if(i===217||i===218||a+2>t.length)return null;if(i===1||i>=208&&i<=215)continue;const r=s.getUint16(a);if(r<2||a+r>t.length)return null;if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(i)&&r>=8)return{width:s.getUint16(a+5),height:s.getUint16(a+3)};a+=r}}if(t.length>=25&&s.getUint32(0)===1380533830&&s.getUint32(8)===1464156752&&s.getUint32(4,!0)+8===t.length){const a=s.getUint32(12);if(a===1448097880&&t.length>=30)return{width:1+t[24]+(t[25]<<8)+(t[26]<<16),height:1+t[27]+(t[28]<<8)+(t[29]<<16)};if(a===1448097824&&t.length>=30&&t[23]===157&&t[24]===1&&t[25]===42)return{width:s.getUint16(26,!0)&16383,height:s.getUint16(28,!0)&16383};if(a===1448097868&&t[20]===47)return{width:1+((t[22]&63)<<8|t[21]),height:1+((t[24]&15)<<10|t[23]<<2|(t[22]&192)>>6)}}return null}function ga(t){return!!(t&&t.width>0&&t.height>0&&t.width<=4096&&t.height<=4096&&t.width*t.height<=16e6)}async function gp(t){if(!t.size||t.size>up||!["image/png","image/jpeg","image/webp"].includes(t.type))throw new Error("Profile image refused");const s=new Uint8Array(await t.arrayBuffer());if(!ga(mp(s)))throw new Error("Profile image dimensions refused");const a=await createImageBitmap(t,{imageOrientation:"from-image"});if(!ga(a))throw a.close(),new Error("Profile decoded image dimensions refused");return a}const Kt=t=>({display_name:t.profile.display_name,title:t.profile.title,description:t.profile.description,timezone:t.profile.timezone}),en={display_name:64,title:80,description:500},pp=t=>en[t]*2,pa=8,ha=t=>t.formatToParts(new Date).find(s=>s.type==="timeZoneName")?.value;function hp(){return[...new Set(["UTC",...Intl.supportedValuesOf("timeZone")])].map(t=>{const s=ha(new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"shortOffset"})),a=ha(new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"short"})),i=[s,a].filter(r=>!!r&&r!==t);return{id:t,name:t.split("_").join(" "),description:s,keywords:i}})}function fp({snapshot:t,initialDraft:s,onDraftChange:a,photoUrl:i,onSave:r,onUpload:c,onRemove:l}){te();const d=o.useId(),[u,m]=o.useState(()=>Kt(t)),[p,g]=o.useState(()=>({...Kt(t),...s})),[_,x]=o.useState(!1),[k,b]=o.useState(!1),[S,I]=o.useState(),[M,L]=o.useState(),[E,O]=o.useState(),[y,F]=o.useState(),[K,P]=o.useState(),[f,A]=o.useState(),T={heading:o.useRef(null),photo:o.useRef(null),remove:o.useRef(null),remove_cancel:o.useRef(null),cancel:o.useRef(null),keep_editing:o.useRef(null),display_name:o.useRef(null),title:o.useRef(null),description:o.useRef(null)},v=o.useMemo(hp,[]),[H,z]=o.useState(!1),[q,Z]=o.useState(!1),[h,R]=o.useState(),j=Cc(h),U=o.useRef(null),ne=o.useRef(void 0),Y=o.useRef(!0),X=o.useRef(0),re=Object.keys(Tn(u,p)).length>0;o.useEffect(()=>{a?.(Tn(u,p))},[u,p,a]);const ce=E==="photo_invalid"?n("ui.settings.personal_profile.photo_invalid"):E?n("ui.settings.personal_profile.photo_error"):void 0,de=t.profile.avatar,be=de?.source==="uploaded"?"uploaded":"provider",pe=_||k;o.useEffect(()=>(Y.current=!0,()=>{Y.current=!1,X.current++,ne.current?.close()}),[]),o.useEffect(()=>{f&&(T[f].current?.focus(),A(void 0))});const B=()=>{X.current++,ne.current?.close(),ne.current=void 0,R(void 0),O(void 0)},N=()=>{B(),A("photo")},G=()=>{z(!1),A("cancel")},ae=()=>{Z(!1),A("remove")},J=(V,se=!1)=>oe=>{oe.key!=="Escape"||se||(oe.preventDefault(),oe.stopPropagation(),V())},_e=async V=>{if(!V||pe)return;const se=++X.current;O(void 0),b(!0),P(void 0);try{const oe=await gp(V);if(!Y.current||se!==X.current){oe.close();return}ne.current?.close(),ne.current=oe,R(oe),Z(!1)}catch{Y.current&&se===X.current&&O("photo_invalid")}finally{Y.current&&se===X.current&&b(!1)}},le=async()=>{if(!Y.current||pe||!re)return;const V=Tn(u,p),se=Object.keys(en).map(oe=>oe in V&&[...p[oe]].length>en[oe]?{field:oe,reason:"length"}:oe==="description"&&p.description.split(`
|
|
293
|
-
`).length>pa?{field:oe,reason:"lines"}:void 0).find(Boolean);if(se){L(se),A(se.field);return}x(!0),I(void 0),L(void 0),F(void 0);try{const oe=await r(V);if(!Y.current)return;m(Kt(oe)),g(Kt(oe)),F("saved"),A("heading")}catch{Y.current&&I("save_error")}finally{Y.current&&x(!1)}},we=async V=>{if(!Y.current||pe)return;b(!0),O(void 0),P(void 0);const se=X.current,oe=j.capture();try{if(V.size>1024*1024)throw new Error("Profile crop too large");if(!await Ac(j,oe,()=>V.arrayBuffer(),rt=>{if(!(!Y.current||se!==X.current))return c(new Uint8Array(rt))})||!Y.current)return;B(),P("photo_saved"),A("photo")}catch{Y.current&&O("photo_error")}finally{Y.current&&b(!1)}},Ie=async()=>{if(!(!Y.current||pe)){b(!0),O(void 0),P(void 0);try{await l(be),Y.current&&(Z(!1),P("photo_removed"),A("photo"))}catch{Y.current&&O("photo_error")}finally{Y.current&&b(!1)}}},fe=(V,se)=>{_||(g(oe=>({...oe,[V]:se})),F(void 0),I(void 0),M?.field===V&&L(void 0),z(!1))},ee=V=>M?.field!==V?void 0:M.reason==="lines"?n("ui.settings.personal_profile.description_lines",{count:String(pa)}):n("ui.settings.personal_profile.field_too_long",{count:String(en[V])}),ie=(V,se,oe)=>{const Me=ee(V);return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(De,{htmlFor:`${d}-${V}`,children:se}),oe({id:`${d}-${V}`,value:p[V],maxLength:pp(V),readOnly:_,"aria-invalid":Me?!0:void 0,"aria-describedby":Me?`${d}-${V}-error`:void 0}),Me&&e.jsx("p",{id:`${d}-${V}-error`,className:"text-meta text-danger",children:Me})]})};return e.jsxs("section",{"aria-labelledby":`${d}-heading`,className:"flex min-w-0 flex-col gap-4","data-account-profile-editor":"",children:[e.jsx("h3",{ref:T.heading,id:`${d}-heading`,tabIndex:-1,className:"text-section font-semibold text-ink focus:outline-none",children:n("ui.settings.personal_profile.heading")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("span",{className:"inline-flex size-16 shrink-0 items-center justify-center overflow-hidden rounded-full bg-sunken text-ink-muted","aria-hidden":"true",children:i?e.jsx("img",{alt:"",src:i,className:"size-full object-cover"}):t.profile.display_label.trim()[0]||"?"}),e.jsx(D,{ref:T.photo,variant:"secondary",size:"sm",disabled:pe,onClick:()=>U.current?.click(),children:de?.hash?n("ui.settings.personal_profile.replace"):n("ui.settings.personal_profile.choose")}),de?.hash&&e.jsx(D,{ref:T.remove,variant:"ghost",size:"sm",disabled:pe,onClick:()=>{Z(!0),B(),A("remove_cancel")},children:n("ui.settings.personal_profile.remove")}),e.jsx("input",{ref:U,type:"file",accept:"image/png,image/jpeg,image/webp",className:"sr-only",tabIndex:-1,"aria-hidden":"true",disabled:pe,onChange:V=>{const se=V.currentTarget.files?.[0];V.currentTarget.value="",_e(se)}})]}),e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.personal_profile.photo_help")}),e.jsx("output",{className:"text-meta text-ink-muted empty:hidden",children:K==="photo_saved"?n("ui.settings.personal_profile.photo_saved"):K==="photo_removed"?n("ui.settings.personal_profile.photo_removed"):null}),h&&e.jsx("div",{onKeyDown:J(N,k),children:e.jsx(Mc,{source:h,outputEdge:256,onSave:V=>void we(V),onCancel:N,saving:k,error:ce,previewSizes:[{id:"profile",px:64,label:n("ui.settings.personal_profile.preview"),caption:n("ui.settings.personal_profile.preview_caption")}],copy:{cropArea:n("ui.settings.personal_profile.crop_area"),instructions:(V,se)=>n("ui.settings.personal_profile.crop_instructions",{width:String(V),height:String(se)}),zoom:n("ui.settings.personal_profile.zoom"),zoomIn:n("ui.settings.personal_profile.zoom_in"),zoomOut:n("ui.settings.personal_profile.zoom_out"),zoomValue:V=>n("ui.settings.personal_profile.zoom_value",{value:V}),recenter:n("ui.settings.personal_profile.recenter"),previews:n("ui.settings.personal_profile.previews"),save:n("ui.settings.personal_profile.save_photo"),saving:n("ui.settings.personal_profile.saving"),cancel:n("ui.common.actions.cancel"),errorEncode:n("ui.settings.personal_profile.crop_error")}})}),q&&e.jsxs("fieldset",{className:"flex flex-col gap-2","aria-label":n("ui.settings.personal_profile.remove"),onKeyDown:J(ae,k),children:[e.jsx("p",{className:"text-body-sm text-ink",children:be==="uploaded"?n("ui.settings.personal_profile.remove_uploaded"):n("ui.settings.personal_profile.remove_provider")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(D,{variant:"danger",size:"sm",disabled:pe,onClick:()=>void Ie(),children:k?n("ui.settings.personal_profile.saving"):n("ui.settings.personal_profile.remove")}),e.jsx(D,{ref:T.remove_cancel,variant:"secondary",size:"sm",disabled:pe,onClick:ae,children:n("ui.common.actions.cancel")})]})]}),E&&!h&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:ce}),e.jsxs("form",{className:"flex min-w-0 flex-col gap-4",onSubmit:V=>{V.preventDefault(),le()},"aria-busy":_,children:[ie("display_name",n("ui.settings.personal_profile.display_name"),V=>e.jsx(Ne,{ref:T.display_name,...V,onChange:se=>fe("display_name",se.target.value),autoComplete:"nickname"})),ie("title",n("ui.settings.personal_profile.title"),V=>e.jsx(Ne,{ref:T.title,...V,onChange:se=>fe("title",se.target.value),autoComplete:"organization-title"})),ie("description",n("ui.settings.personal_profile.description"),V=>e.jsx(ps,{ref:T.description,...V,onChange:se=>fe("description",se.target.value),rows:3})),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(De,{asChild:!0,children:e.jsx("span",{"aria-hidden":"true",children:n("ui.settings.personal_profile.timezone")})}),e.jsx(Wa,{showLabel:!1,ariaLabel:n("ui.settings.personal_profile.timezone"),placeholder:n("ui.settings.personal_profile.timezone_placeholder"),busyLabel:n("ui.settings.personal_profile.loading"),options:v,selected:p.timezone?v.find(V=>V.id===p.timezone)??{id:p.timezone,name:p.timezone.split("_").join(" ")}:null,onSelect:V=>fe("timezone",V.id),onClear:()=>fe("timezone","")})]}),S&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.personal_profile.save_error")}),H?e.jsxs("div",{className:"flex flex-col gap-2",onKeyDown:J(G),children:[e.jsx("p",{role:"alert",className:"text-body-sm text-ink",children:n("ui.settings.personal_profile.discard")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(D,{type:"button",variant:"secondary",size:"sm",onClick:()=>{g(u),z(!1),I(void 0),L(void 0),A("heading")},children:n("ui.settings.personal_profile.discard_action")}),e.jsx(D,{ref:T.keep_editing,type:"button",variant:"primary",size:"sm",onClick:G,children:n("ui.settings.personal_profile.keep_editing")})]})]}):e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(D,{type:"submit",variant:"primary",size:"sm",disabled:!re||pe,children:_?n("ui.settings.personal_profile.saving"):n("ui.settings.personal_profile.save")}),e.jsx(D,{ref:T.cancel,type:"button",variant:"secondary",size:"sm",disabled:!re||_,onClick:()=>{z(!0),A("keep_editing")},children:n("ui.common.actions.cancel")})]})]}),e.jsx("output",{className:"text-meta text-ink-muted empty:hidden",children:y==="saved"?n("ui.settings.personal_profile.saved"):null}),e.jsxs(D,{variant:"link",size:"sm",className:"w-fit",onClick:()=>ls("https://console.radienthq.com/dashboard/account"),children:[n("ui.settings.personal_profile.manage"),e.jsx(za,{"aria-hidden":"true"})]})]})}function _p(){return te(),e.jsx("output",{className:"text-body-sm text-ink-muted",children:n("ui.settings.personal_profile.loading")})}function xp({onRetry:t}){return te(),e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:n("ui.settings.personal_profile.load_error")}),e.jsx(D,{variant:"secondary",size:"sm",onClick:t,children:n("ui.common.actions.retry")})]})}const yp=/^[a-f0-9]{16}$/;function bp(){te();const t=Ct(),s=at(t.data,"account_profile"),a=Fa(),i=o.useCallback(()=>{try{return JSON.stringify(a.accountId?jc(window.localStorage,a.accountId)??"personal":"unresolved")}catch{return"unresolved"}},[a.accountId]),r=o.useCallback(k=>{const b=S=>{(S.key===Nc||S.key===null)&&k()};return window.addEventListener("storage",b),()=>window.removeEventListener("storage",b)},[]),c=o.useSyncExternalStore(r,i,i),l=dp(s,i),d=o.useRef(null),u=l.data,m=St(),p=`${l.authority.token}:${c}:${u?.scope??""}`,g=u?Ti(m,p):void 0,_=u?.profile.avatar?.hash,x=zo(u&&_&&yp.test(_)?{accountId:u.profile.account_id,hash:_}:null,64);return o.useEffect(()=>{!u||!wc(l.authority.token)||(d.current?.scrollIntoView({block:"start"}),d.current?.focus({preventScroll:!0}))},[u,l.authority.token]),s?!l.authority.accountId||l.isPending?e.jsx(_p,{}):u?e.jsx("div",{ref:d,tabIndex:-1,"aria-label":n("ui.settings.personal_profile.heading"),className:"focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",children:e.jsx(fp,{snapshot:u,initialDraft:g?.fields,onDraftChange:k=>rp(m,p,k),photoUrl:x,onSave:l.update,onUpload:l.upload,onRemove:l.remove},p)}):e.jsx(xp,{onRetry:()=>void l.refetch()}):e.jsx(D,{variant:"secondary",size:"sm",onClick:()=>ls("https://console.radienthq.com/dashboard/account"),children:n("ui.settings.personal_profile.manage")})}const vp=({verification:t})=>{te();const{prices:s}=Yr(),a=t.grant_amount??s?.default_new_credits,{sentence:i,action:r}=Qr(t.signup_grant,Zr(a)),c=Jr(t.claim_url,Xr);return e.jsxs("div",{className:"mt-8 flex items-start gap-3 rounded-sm border border-hairline bg-surface p-3",children:[e.jsx(rn,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-2",children:[e.jsx("p",{className:"text-body-sm text-ink",children:i}),e.jsx(D,{variant:"secondary",size:"sm",onClick:()=>ls(c),children:r})]})]})},kp=({onAfterCredentialUpdate:t})=>{te();const{isAuthenticated:s,user:a,isLoading:i,accountRead:r,signOut:c}=Wr(),l=Pa(g=>g.isSigningOut),d=o.useCallback(async()=>{try{await c()}catch(g){console.error("Error signing out:",g)}},[c]),u=(()=>{if(!s||!a?.radientUser)return null;const{account:g,identity:_,verification:x}=a.radientUser,k=x!=null&&!x.email_verified&&x.signup_grant!=="claimed";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-8",children:e.jsx(bp,{})}),e.jsxs(Mt,{children:[e.jsx(ke,{label:n("ui.settings.account.radient_account_section.status"),value:e.jsxs("span",{className:"inline-flex items-center gap-2",children:[n("ui.settings.account.radient_account_section.connected"),e.jsx(wt,{variant:"success",className:"capitalize",children:g.status})]})}),e.jsx(ke,{label:n("ui.settings.account.radient_account_section.name"),value:g.name||n("ui.settings.account.radient_account_section.not_provided")}),e.jsx(ke,{label:n("ui.settings.account.radient_account_section.email"),value:g.email}),e.jsx(ke,{label:n("ui.settings.account.radient_account_section.account_id"),value:e.jsx("span",{className:"text-mono-sm",children:g.id})}),e.jsx(ke,{label:n("ui.settings.account.radient_account_section.tenant_id"),value:e.jsx("span",{className:"text-mono-sm",children:g.tenant_id})}),e.jsx(ke,{label:n("ui.settings.account.radient_account_section.provider"),value:e.jsx("span",{className:"capitalize",children:_.provider})}),e.jsx(ke,{label:n("ui.settings.account.radient_account_section.created"),value:$a(g.created_at)})]}),k&&x?e.jsx(vp,{verification:x}):null,e.jsx("div",{className:"mt-8",children:e.jsx(Po,{offerSignIn:!0})}),e.jsxs("div",{className:"mt-8",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.account.radient_account_section.need_to_sign_out_or_switch_accounts")}),e.jsxs(D,{variant:"danger",className:"mt-3",onClick:d,children:[e.jsx($o,{}),n("ui.settings.account.radient_account_section.sign_out_from_radient")]})]})]})})(),m=r==="refused"?n("ui.settings.account.radient_account_section.radient_refused_the_sign_in_this_app_is_holding_so_your_account_d"):Ua(r)?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:e.jsxs("div",{children:[e.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")]}),e.jsx("div",{className:"mt-6",children:e.jsx(Sc,{titleText:"",onAfterCredentialUpdate:t,descriptionText:"",onSignInSuccess:()=>{}})})]});return i||l?e.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center gap-3",children:[e.jsx(Ee,{size:"lg",label:n("ui.settings.account.radient_account_section.loading_account")}),!l&&e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.account.radient_account_section.loading_your_radient_account_details")})]}):s&&a?.radientUser?u:e.jsx("div",{className:"flex flex-col gap-4",children:p})},On={label:1,synonym:.8,key:.75,choice:.7,section:.6,description:.4},jp={exact:1,prefix:.92,substring:.7,subsequence:.45};function Oi(t){return t.length<4||!t.endsWith("s")?t:/(?:ch|sh|ss|x|z)es$/.test(t)?t.slice(0,-2):t.slice(0,-1)}function fa(t){let s=!1;const a=t.split(" ").map(i=>{const r=Oi(i);return r!==i&&(s=!0),r}).join(" ");return s?a:t}const _a=new WeakMap,xa={exact:3,prefix:2,substring:1};function wp(t,s,a){const i=Oi(a),r=[Lt(t,a)];i!==a&&r.push(Lt(t,i)),s!==t&&(r.push(Lt(s,a)),i!==a&&r.push(Lt(s,i)));let c=null;for(const l of r)!l||l==="subsequence"||(!c||xa[l]>xa[c])&&(c=l);return c}const Np=12,Sp=2;function Cp(t,s){let a=0,i=-1,r=null,c=_a.get(t.fields);if(!c){c={};for(const l of Object.keys(On)){const d=t.fields[l];d&&(c[l]=fa(d))}_a.set(t.fields,c)}for(const l of s){let d=-1,u=null;for(const m of Object.keys(On)){const p=t.fields[m];if(!p)continue;const g=wp(p,c[m]??fa(p),l);if(!g)continue;const _=On[m]*jp[g];_>d&&(d=_,u=m)}if(u===null)return null;a+=d,d>i&&(i=d,r=u)}return r?{score:a,reason:r}:null}function Mp(t,s,a=Np){const i=Uo(s);if(i.length===0)return{results:[],total:0};const r=vt(s),c=[];for(const l of t){const d=Cp(l,i);if(!d)continue;const u=l.fields.label!==""&&l.fields.label===r;c.push({entry:l,reason:d.reason,score:u?d.score+Sp:d.score})}return c.sort((l,d)=>d.score-l.score||l.entry.fields.label.length-d.entry.fields.label.length||l.entry.order-d.entry.order),{results:c.slice(0,Math.max(0,a)).map(({entry:l,reason:d})=>({entry:l,reason:d})),total:c.length}}function Ap(t){return vt(t)===""}function Ep(t){const s=new Map;for(const r of t){const c=r.entry.sectionId||"",l=s.get(c);if(l){l.results.push(r);continue}s.set(c,{sectionId:c,sectionLabel:r.entry.sectionLabel,results:[r]})}const a=[...s.values()],i=a.filter(r=>r.sectionId==="");return[...a.filter(r=>r.sectionId!==""),...i]}const Ip={label:"ui.settings.search.reason.label",synonym:"ui.settings.search.reason.synonym",key:"ui.settings.search.reason.key",choice:"ui.settings.search.reason.choice",section:"ui.settings.search.reason.section",description:"ui.settings.search.reason.description"};function Rp(t){const{registry:s,sections:a,build:i=Tu}=t,r=te();return o.useMemo(()=>i({registry:s,sections:a}),[i,s,a,r])}function Tp(){return no()==="mac"?"⌘F":"Ctrl+F"}const Lp=o.forwardRef(function({index:s,readRendered:a,onJump:i,onDismiss:r,className:c},l){te();const d=o.useRef(null),u=o.useRef(null),[m,p]=o.useState(null),[g,_]=o.useState(""),[x,k]=o.useState(!1),[b,S]=o.useState(-1),[I,M]=o.useState(""),L=o.useId();o.useImperativeHandle(l,()=>({focus:()=>{d.current?.focus(),k(!0)}}));const E=o.useCallback(()=>a?.()??[],[a]),O=o.useCallback(()=>{p(E())},[E]),y=o.useCallback(()=>{p(j=>j??E())},[E]),F=o.useCallback(()=>{const j=m;return j&&j.length>0?[...s,...j]:s},[s,m]),K=Ap(g),{results:P,total:f}=o.useMemo(()=>Mp(F(),g),[F,g]),A=o.useMemo(()=>Ep(P),[P]),T=b<0||P.length===0?-1:Math.min(b,P.length-1),v=T>=0?P[T]:void 0,H=o.useMemo(()=>new Map(P.map((j,U)=>[j.entry.id,U])),[P]),z=o.useCallback(j=>{j!==void 0&&_(j),k(!1),S(-1),r?.()},[r]),q=o.useCallback(async j=>{if(await i(j)==="missing"){M(n("ui.settings.search.jump.missing"));return}M(""),k(!1),S(-1)},[i]),Z=j=>`${L}-option-${j}`,h=j=>{switch(j.key){case"ArrowDown":j.preventDefault(),k(!0),S(U=>P.length===0?-1:U<0?0:(U+1)%P.length);return;case"ArrowUp":j.preventDefault(),k(!0),S(U=>P.length===0?-1:U<0?P.length-1:(U-1+P.length)%P.length);return;case"Home":if(!x)return;j.preventDefault(),S(0);return;case"End":if(!x)return;j.preventDefault(),S(Math.max(0,P.length-1));return;case"Enter":if(j.preventDefault(),!x){k(!0);return}{const U=v??P[0];U&&q(U.entry)}return;case"Escape":if(j.preventDefault(),g!==""){_(""),M(""),S(-1);return}z();return;default:return}},R=K?"":n("ui.settings.search.results.count",{count:f});return e.jsxs("div",{ref:u,className:ge("relative @container w-full",c),onBlur:j=>{const U=j.relatedTarget;U&&u.current?.contains(U)||(k(!1),S(-1),r?.())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(is,{size:14,"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2 text-ink-dim"}),e.jsx(Ne,{ref:d,role:"combobox","aria-expanded":x,"aria-controls":x?L:void 0,"aria-activedescendant":x&&v?Z(T):void 0,"aria-autocomplete":"list","aria-label":n("ui.settings.search.field.label"),placeholder:n("ui.settings.search.field.placeholder"),value:g,type:"text",className:"pl-8",onFocus:()=>{O(),k(!0)},onChange:j=>{y(),_(j.currentTarget.value),S(-1),M(""),k(!0)},onKeyDown:h})]}),x&&e.jsxs("div",{id:L,role:"listbox",tabIndex:-1,"aria-label":n("ui.settings.search.panel.label"),className:"absolute top-full right-0 z-40 mt-2 flex max-h-[min(24rem,60vh)] w-full min-w-80 flex-col overflow-y-auto rounded-md border border-hairline bg-elevated p-1 shadow-overlay",children:[I&&e.jsx("p",{"data-search-notice":"","aria-hidden":"true",className:"px-2 pt-2 pb-1 text-body-sm text-ink",children:I}),K?e.jsxs("div",{className:"flex flex-col gap-1 px-2 py-2",children:[e.jsx("p",{className:"text-body-sm text-ink",children:n("ui.settings.search.empty.summary")}),e.jsx("p",{className:"text-meta text-ink-dim",children:e.jsx(eo,{text:n("ui.settings.search.empty.shortcut",{shortcut:to(Tp())})})})]}):P.length===0?e.jsxs("div",{className:"flex flex-col gap-2 px-2 py-2",children:[e.jsx("p",{className:"text-body-sm text-ink",children:n("ui.settings.search.no_results.title",{query:g})}),e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.search.no_results.hint")}),e.jsx("button",{type:"button",className:"min-h-6 w-fit rounded-sm px-1.5 py-1 text-body-sm text-accent underline-offset-2 hover:underline focus-visible:outline-2",onMouseDown:j=>j.preventDefault(),onClick:()=>{z(""),d.current?.focus()},children:n("ui.settings.search.no_results.clear")})]}):e.jsxs(e.Fragment,{children:[A.map(j=>e.jsxs("div",{role:j.sectionLabel?"group":void 0,"aria-label":j.sectionLabel||void 0,children:[j.sectionLabel&&e.jsx("p",{className:"px-2 pt-2 pb-1 font-medium text-ink-muted text-meta",children:j.sectionLabel}),j.results.map(U=>{const ne=H.get(U.entry.id)??0,Y=ne===T;return e.jsxs("div",{id:Z(ne),role:"option","aria-selected":Y,"data-search-result-id":U.entry.id,className:ge("flex cursor-pointer flex-col gap-0.5 rounded-sm px-2 py-1.5 @[40rem]:flex-row @[40rem]:items-baseline @[40rem]:justify-between @[40rem]:gap-4",Y?"bg-accent-wash outline-solid outline-1 -outline-offset-1 outline-control":"hover:bg-row-hover"),onMouseDown:X=>X.preventDefault(),onMouseEnter:()=>S(ne),onClick:()=>q(U.entry),children:[e.jsx("span",{className:"min-w-0 text-body-sm text-ink",children:U.entry.label}),e.jsxs("span",{className:"@[40rem]:shrink-0 @[40rem]:text-right text-meta text-ink-dim",children:[U.entry.sectionLabel&&n("ui.settings.search.row.section_hint",{section:U.entry.sectionLabel}),U.entry.sectionLabel&&" · ",n(Ip[U.reason]),U.entry.detail&&U.entry.detail!==U.entry.sectionLabel&&e.jsxs(e.Fragment,{children:[" · ",U.entry.detail]})]})]},U.entry.id)})]},j.sectionId||"no-section")),f>P.length&&e.jsx("p",{"data-search-more":"",className:"px-2 pt-1 pb-2 text-meta text-ink-dim",children:n("ui.settings.search.results.more",{count:f-P.length})})]})]}),e.jsx("output",{"aria-live":"polite",className:"sr-only",children:I||R})]})});function Op({metric:t,data:s}){return te(),e.jsx(so,{title:"",heightClassName:"h-62",yAxisWidth:48,unit:t==="credits"?"credits":"tokens",srSummary:t==="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=>t==="credits"?`$${a.toFixed(2)}`:ao(a),children:e.jsx(Gd,{data:s,children:e.jsx(Ea,{type:"monotone",dataKey:"value",strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:t==="credits"?n("ui.settings.account.settings_usage_chart.credits_consumed"):n("ui.settings.account.settings_usage_chart.tokens_used")})})})}const Dp={all:["desktop","tts-path-resolution"]};function Fp(t){return Te({queryKey:Dp.all,queryFn:()=>je({op:"tts.paths"}),enabled:t,staleTime:Number.POSITIVE_INFINITY,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:gr})}const zp=["speech.voice.gender","speech.voice.tone","speech.voice.expressiveness","speech.voice.pace","speech.voice.language","speech.voice.accent","speech.voice.instructions"];function ya(t){const s=new Map(t.map(r=>[r.key,r])),a=[],i=[];for(const r of zp){const c=s.get(r);c?a.push(c):i.push(r)}return{rows:a,missing:i}}const Pp=["provider_tts_radient","provider_tts_elevenlabs","provider_tts_openai","none"];function ba(t){return typeof t=="string"&&Pp.includes(t)}function $p(t){if(t===null||typeof t!="object")return null;const s=t;if(!ba(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 r=i;if(!ba(r.path)||typeof r.available!="boolean"||typeof r.reason!="string")return null;a.push({path:r.path,available:r.available,reason:r.reason})}return{path:s.path,reason:s.reason,servable:s.servable,rungs:a}}const Up={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 Di(t){return Up[t]}function Kp(t){return{servable:t.servable,serving:t.path==="none"?null:t.path,reason:t.reason,rungs:t.rungs.map(s=>({path:s.path,name:Di(s.path),available:s.available,reason:s.reason}))}}const Bp="ui.settings.speech.speech_section.copy_backend_older_sentence",Fi="ui.settings.speech.speech_section.copy_unavailable_sentence",Hp=({resetErrorBoundary:t})=>(te(),e.jsx(me,{variant:"warning",children:e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx("span",{children:n(Fi)}),e.jsxs(D,{variant:"secondary",onClick:t,children:[e.jsx(hc,{"aria-hidden":"true"}),n("ui.settings.speech.speech_section.try_again")]})]})}));function qp(t){return t==="enabled"?"ready":t==="below-version"?"older":"pairing"}const Vp=({sectionRef:t})=>{te();const s=Ct(),a=Ka(),i=pr(s.data,"tts"),r=qp(i),c=Te({queryKey:nn.all,queryFn:()=>je({op:"settings.list"}),enabled:r==="ready",staleTime:1e4}),l=Fp(r==="ready"),{hasRadientApiKey:d,hasRadientSession:u,speechBlock:m}=io(),p=`${u}:${d}`,g=o.useRef(p),_=l.refetch;o.useEffect(()=>{g.current!==p&&(g.current=p,_())},[p,_]);const x=c.data,k=o.useMemo(()=>ya(x?.settings??[]),[x]),[b,S]=o.useState({}),[I,M]=o.useState({}),[L,E]=o.useState({});o.useEffect(()=>{x&&S(h=>{let R=!1;const j={...h};for(const U of ya(x.settings).rows){const ne=h[U.key];if(ne&&ne.value!==ut(U).value)continue;const Y=ut(U);ne&&ne.value===Y.value&&ne.cascadeBase===Y.cascadeBase||(j[U.key]=Y,R=!0)}return R?j:h})},[x]);const O=(h,R)=>M(j=>({...j,[h]:R})),y=(h,R)=>E(j=>({...j,[h]:R})),F=async h=>{const R=b[h.key];if(!R)return;const j=co(h,R);if(!j.ok){y(h.key,j.error);return}O(h.key,!0),y(h.key,null);try{await je(j.request),O(h.key,!1);const ne=(await c.refetch()).data?.settings.find(Y=>Y.key===h.key);ne&&S(Y=>{const X=Y[h.key];return X&&X.value===R.value&&X.cascadeBase===R.cascadeBase?{...Y,[h.key]:ut(ne)}:Y})}catch(U){O(h.key,!1),y(h.key,U instanceof Error?U.message:n("ui.settings.speech.speech_section.the_setting_could_not_be_saved"))}},K=async h=>{O(h.key,!0),y(h.key,null);try{await je({op:"settings.reset",key:h.key}),S(R=>({...R,[h.key]:ut({...h,value:h.default,is_default:!0})})),O(h.key,!1),await c.refetch()}catch(R){O(h.key,!1),y(h.key,R instanceof Error?R.message:n("ui.settings.speech.speech_section.the_setting_could_not_be_reset"))}},P=o.useMemo(()=>$p(l.data),[l.data]),f=P?Kp(P):null,A=l.isSuccess&&P===null,T=(s.data?null:s.error)??null,v=c.error,H=n("ui.settings.speech.speech_section.speech_voicing"),z=n("ui.settings.speech.speech_section.how_the_assistant_sounds_when_it_speaks_aloud");if(r==="pairing"){const{sentence:h}=zn(a??null,n("ui.settings.speech.speech_section.speech_settings_could_not_be_loaded"),T);return e.jsx(ye,{title:H,icon:Ot,description:z,sectionRef:t,children:e.jsx(me,{variant:"warning",children:h})})}if(r==="older")return e.jsx(ye,{title:H,icon:Ot,description:z,sectionRef:t,children:e.jsx(me,{variant:"warning",children:n(Bp)})});if(v||!x){const{sentence:h,remedy:R}=zn(a??null,n("ui.settings.speech.speech_section.speech_settings_could_not_be_loaded"),v);return e.jsx(ye,{title:H,icon:Ot,description:z,sectionRef:t,children:e.jsx(me,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:h}),R&&e.jsx(D,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{c.refetch()},children:n("ui.settings.speech.speech_section.retry")})]})})})}const q=f?!f.servable:m==="offline",Z=f?f.rungs.find(h=>h.path===f.serving)??null:null;return e.jsx(ye,{title:H,icon:Ot,description:z,sectionRef:t,searchSection:"speech",searchSectionLabel:n("ui.settings.navigation.settings_sidebar.speech_voicing"),searchIgnore:"speech rows are registry keys read from the daemon's own selection",children:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("section",{className:"flex flex-col gap-3",children:[l.isPending&&e.jsxs("p",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(Ee,{}),Is("checking")]}),(l.isError||A)&&!f&&m!=="offline"&&e.jsx(me,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{children:[n(Fi)," ",l.error instanceof Error?l.error.message:""]}),e.jsx(D,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{l.refetch()},children:n("ui.settings.speech.speech_section.retry")})]})}),e.jsx(pc,{fallbackRender:Hp,resetKeys:[l.dataUpdatedAt],children:f&&e.jsxs(e.Fragment,{children:[e.jsxs(Mt,{children:[e.jsx(ke,{label:n("ui.settings.speech.speech_section.speaks_through"),value:f.serving?Di(f.serving):n("ui.settings.speech.speech_section.nothing_yet")}),e.jsx(ke,{label:n("ui.settings.speech.speech_section.availability"),value:f.servable?n("ui.settings.speech.speech_section.ready"):n("ui.settings.speech.speech_section.no_provider")})]}),f.reason&&f.reason!==Z?.reason&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:f.reason}),e.jsx("ul",{className:"flex flex-col gap-1",children:f.rungs.map(h=>e.jsxs("li",{className:"flex flex-col gap-0.5 text-body-sm",children:[e.jsxs("span",{className:h.path===f.serving?"text-ink":"text-ink-muted",children:[h.name,e.jsxs("span",{className:h.path===f.serving?"text-ink-muted":"text-ink-dim",children:[" ",h.available?n("ui.settings.speech.speech_section.available"):n("ui.settings.speech.speech_section.not_available")]})]}),e.jsx("span",{className:"text-meta text-ink-dim",children:h.reason})]},h.path))})]})})]}),q&&e.jsx(me,{variant:"warning",children:Is(m)}),e.jsx("div",{className:"flex flex-col gap-1",children:k.rows.map(h=>e.jsx(ro,{setting:h,draft:b[h.key]??ut(h),tier:oo(h),saving:!!I[h.key],error:L[h.key]??null,onDraftChange:R=>S(j=>({...j,[h.key]:R})),onSave:()=>{F(h)},onReset:()=>{K(h)}},h.key))}),k.missing.length>0&&e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.speech.speech_section.missing_voice_rows",{count:k.missing.length,rows:k.missing.join(", ")})})]})})},zi=lo().use(uo).use(mo),va=t=>JSON.stringify(zi.parse(t),(s,a)=>{if(!(s==="position"||s==="spread"))return a}),ka=t=>{try{const s=zi.parse(t);return JSON.stringify(s).includes('"type":"html"')?!1:va(t)===va(Ko(Bo(t)))}catch{return!1}},Gp=({value:t,onChange:s,disabled:a=!1})=>{const i=o.useId(),[r,c]=o.useState(()=>ka(t)),[l,d]=o.useState(()=>!r),[u,m]=o.useState(0),[p,g]=o.useState(t),_=o.useMemo(()=>({id:`system-prompt-draft-${i}-${u}`,title:"system-prompt.md",path:"",type:"markdown",content:p}),[i,u,p]),x=o.useCallback(S=>s(S),[s]),k=o.useMemo(()=>({onChange:x,disabled:a,label:n("ui.settings.model.system_prompt.instructions")}),[x,a]),b=()=>{const S=ka(t);c(S),S&&(g(t),m(I=>I+1),d(!1))};return e.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[e.jsxs("fieldset",{className:"flex flex-wrap gap-2","aria-label":n("ui.settings.model.system_prompt.instructions"),children:[e.jsx(D,{variant:"ghost",className:l?void 0:"bg-sunken font-semibold text-ink","aria-pressed":!l,disabled:a,onClick:b,children:n("ui.settings.model.system_prompt.rich_text")}),e.jsx(D,{variant:"ghost",className:l?"bg-sunken font-semibold text-ink":void 0,"aria-pressed":l,disabled:a,onClick:()=>d(!0),children:n("ui.settings.model.system_prompt.source")})]}),!r&&e.jsx(me,{children:n("ui.settings.model.system_prompt.source_required")}),l?e.jsx(ps,{id:"app-system-prompt",name:"systemPrompt","aria-label":n("ui.settings.model.system_prompt.instructions"),value:t,disabled:a,onChange:S=>s(S.target.value),placeholder:n("ui.settings.model.system_prompt.enter_instructions_for_how_all_agents_should_behave_and_respond_t"),className:"min-h-72 max-h-[65vh] resize-y font-mono"}):e.jsx("div",{className:"h-[min(32rem,65vh)] min-h-64 min-w-0 overflow-hidden rounded-lg bg-surface",...a?{inert:""}:{},children:e.jsx(Ho,{document:_,draft:k,measure:"fill"},_.id)})]})},Wp=()=>{te();const{data:t,isLoading:s,error:a}=Hd(),i=qd(),[r,c]=o.useState(""),[l,d]=o.useState(!1),u=o.useRef(!1),m=o.useRef(""),[p,g]=o.useState(0),[_,x]=o.useState(null);o.useLayoutEffect(()=>{u.current||(m.current=t?.content??"",c(m.current),g(L=>L+1),d(!1))},[t]);const k=o.useCallback(L=>{c(L),u.current=L!==m.current,d(u.current),x(null)},[]),b=async()=>{if(!(!l||i.isPending)){x(null);try{const L={content:r};await i.mutateAsync(L),m.current=r,u.current=!1,d(!1)}catch(L){x(L instanceof Error?L.message:n("ui.common.errors.system_prompt_update_unknown"))}}},S=()=>{u.current=!1,m.current=t?.content??"",c(m.current),g(L=>L+1),x(null),d(!1)},I=i.isPending,M=()=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(De,{htmlFor:"app-system-prompt",children:n("ui.settings.model.system_prompt.instructions")}),e.jsx(Gp,{value:r,onChange:k,disabled:I},p)]}),_&&e.jsx(me,{variant:"danger",children:_}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(D,{variant:"primary",onClick:b,disabled:!l||I,children:[I?e.jsx(Ee,{size:"sm"}):e.jsx(qa,{}),I?n("ui.settings.model.system_prompt.saving"):n("ui.settings.model.system_prompt.save_changes")]}),e.jsx(D,{onClick:S,disabled:!l||I,children:n("ui.settings.model.system_prompt.cancel")})]}),t?.last_modified&&e.jsxs("p",{className:"text-ink-dim text-meta",children:[n("ui.settings.model.system_prompt.last_modified")," ",e.jsx("span",{className:"font-mono text-mono-sm",children:rs(t.last_modified)})]})]});return e.jsx(ye,{title:n("ui.settings.model.system_prompt.system_prompt"),icon:Ec,description:n("ui.settings.model.system_prompt.every_local_operator_agent_receives_this_prompt_in_addition_to_it"),children:s?e.jsx("div",{className:"flex min-h-50 items-center justify-center",children:e.jsx(Ee,{size:"lg",label:n("ui.settings.model.system_prompt.loading_system_prompt")})}):a&&!t&&!l?e.jsx(me,{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")})}):M()})},Yp=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],Qp=t=>Yp.includes(t),Zp=t=>{const s=[];let a=0;for(const i of t){const r=Math.max(0,Math.floor(i.count)),c=Math.max(1,Math.floor(i.columns));for(let l=0;l<r;l+=c)s.push({start:a+l,count:Math.min(c,r-l)});a+=r}return s},Jp=({index:t,key:s,groups:a})=>{const i=Zp(a),r=i.reduce((c,l)=>c+l.count,0);if(!Number.isInteger(t)||t<0||t>=r)return t;switch(s){case"Home":return 0;case"End":return r-1;case"ArrowLeft":return Math.max(0,t-1);case"ArrowRight":return Math.min(r-1,t+1);case"ArrowUp":case"ArrowDown":{const c=i.findIndex(u=>t>=u.start&&t<u.start+u.count),l=i[c+(s==="ArrowDown"?1:-1)];if(!l)return t;const d=t-i[c].start;return l.start+Math.min(d,l.count-1)}default:return t}},Xp=`const x = {
|
|
294
|
-
ready: true
|
|
295
|
-
};`,eh=({id:t})=>(te(),e.jsx("section",{"aria-label":n("ui.settings.appearance.editor.preview"),"data-custom-theme-preview":"",children:e.jsxs("div",{"data-theme":t,ref:s=>{s?.setAttribute("inert","")},"aria-hidden":"true",className:"grid min-w-0 grid-cols-2 gap-2 rounded-md bg-canvas p-2 text-ink",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[e.jsx("p",{className:"self-end rounded-sm bg-message-surface px-2 py-1 text-meta",children:n("ui.settings.appearance.editor.preview.user")}),e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.appearance.editor.preview.assistant")})]}),e.jsxs("div",{className:"min-w-0 rounded-sm bg-surface p-1 text-meta",children:[e.jsx("div",{className:"truncate px-1 py-0.5 text-ink-muted",children:n("ui.settings.appearance.editor.preview.sidebar")}),e.jsx("div",{className:"truncate rounded-xs bg-row-hover px-1 py-0.5",children:n("ui.settings.appearance.editor.preview.normal")}),e.jsxs("div",{className:"flex items-center justify-between gap-1 rounded-xs bg-row-selected px-1 py-0.5",children:[e.jsx("span",{className:"truncate",children:n("ui.settings.appearance.editor.preview.selected")}),e.jsx(Gn,{count:3})]})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1 rounded-sm border border-control bg-sunken px-1 py-1",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink-dim",children:n("ui.settings.appearance.editor.preview.composer")}),e.jsx(D,{variant:"primary",size:"sm",tabIndex:-1,children:n("ui.settings.appearance.editor.preview.send")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx(D,{variant:"primary",size:"sm",tabIndex:-1,children:n("ui.settings.appearance.editor.preview.primary")}),e.jsx(D,{size:"sm",variant:"secondary",tabIndex:-1,children:n("ui.settings.appearance.editor.preview.secondary")}),e.jsx(D,{size:"sm",disabled:!0,tabIndex:-1,children:n("ui.settings.appearance.editor.preview.disabled")})]}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-1 text-meta",children:[e.jsx("div",{className:"rounded-xs border border-success-border bg-success-wash px-1 text-success",children:n("ui.settings.appearance.editor.preview.success")}),e.jsx("div",{className:"rounded-xs border border-warning-border bg-warning-wash px-1 text-warning",children:n("ui.settings.appearance.editor.preview.warning")}),e.jsx("div",{className:"rounded-xs border border-danger-border bg-danger-wash px-1 text-danger",children:n("ui.settings.appearance.editor.preview.danger")})]}),e.jsxs("div",{className:"grid min-w-0 grid-cols-2 gap-1",children:[e.jsx("pre",{className:"overflow-hidden rounded-sm bg-sunken p-1 font-mono text-meta text-token-command",children:e.jsx("code",{children:Xp})}),e.jsxs("div",{className:"min-w-0 rounded-sm bg-elevated p-1 text-meta",children:[e.jsx("div",{className:"truncate rounded-xs bg-row-hover px-1",children:n("ui.settings.appearance.editor.preview.menu_item")}),e.jsx("div",{className:"truncate px-1 text-danger",children:n("ui.settings.appearance.editor.preview.menu_danger")})]})]}),e.jsx(Ne,{inputSize:"sm",readOnly:!0,tabIndex:-1,"aria-label":n("ui.settings.appearance.editor.preview.input"),value:n("ui.settings.appearance.editor.preview.input"),className:"outline-2 outline-accent"}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1 rounded-sm bg-row-selected p-1",children:[e.jsx("span",{className:"size-2 shrink-0 rounded-full bg-success"}),e.jsx("span",{className:"truncate text-meta",children:n("ui.settings.appearance.editor.preview.bridge_name")}),e.jsx(Gn,{count:3}),e.jsx("span",{className:"text-meta text-ink-dim",children:12})]}),e.jsx("div",{className:"col-span-2 rounded-xs border border-info-border bg-info-wash px-1 text-meta text-info",children:n("ui.settings.appearance.editor.preview.info")})]})})),th=()=>({canvas:n("ui.settings.appearance.editor.role.canvas"),surface:n("ui.settings.appearance.editor.role.surface"),ink:n("ui.settings.appearance.editor.role.ink"),inkMuted:n("ui.settings.appearance.editor.role.inkMuted"),accent:n("ui.settings.appearance.editor.role.accent"),borderControl:n("ui.settings.appearance.editor.role.borderControl"),elevated:n("ui.settings.appearance.editor.role.elevated"),sunken:n("ui.settings.appearance.editor.role.sunken"),messageSurface:n("ui.settings.appearance.editor.role.messageSurface"),mediaSurface:n("ui.settings.appearance.editor.role.mediaSurface"),rowHover:n("ui.settings.appearance.editor.role.rowHover"),rowSelected:n("ui.settings.appearance.editor.role.rowSelected"),inkDim:n("ui.settings.appearance.editor.role.inkDim"),inkDisabled:n("ui.settings.appearance.editor.role.inkDisabled"),tokenCommand:n("ui.settings.appearance.editor.role.tokenCommand"),hairline:n("ui.settings.appearance.editor.role.hairline"),hairlineStrong:n("ui.settings.appearance.editor.role.hairlineStrong"),accentHover:n("ui.settings.appearance.editor.role.accentHover"),accentActive:n("ui.settings.appearance.editor.role.accentActive"),chartBarHover:n("ui.settings.appearance.editor.role.chartBarHover"),accentWash:n("ui.settings.appearance.editor.role.accentWash"),onAccent:n("ui.settings.appearance.editor.role.onAccent"),accentAlt:n("ui.settings.appearance.editor.role.accentAlt"),accentAltWash:n("ui.settings.appearance.editor.role.accentAltWash"),success:n("ui.settings.appearance.editor.role.success"),successWash:n("ui.settings.appearance.editor.role.successWash"),successBorder:n("ui.settings.appearance.editor.role.successBorder"),warning:n("ui.settings.appearance.editor.role.warning"),warningWash:n("ui.settings.appearance.editor.role.warningWash"),warningBorder:n("ui.settings.appearance.editor.role.warningBorder"),danger:n("ui.settings.appearance.editor.role.danger"),dangerWash:n("ui.settings.appearance.editor.role.dangerWash"),dangerBorder:n("ui.settings.appearance.editor.role.dangerBorder"),info:n("ui.settings.appearance.editor.role.info"),infoWash:n("ui.settings.appearance.editor.role.infoWash"),infoBorder:n("ui.settings.appearance.editor.role.infoBorder"),overlayShadow:n("ui.settings.appearance.editor.role.overlayShadow"),scrim:n("ui.settings.appearance.editor.role.scrim")}),Ge=t=>th()[t]??t,pt=/^#[0-9A-Fa-f]{6}$/,nh=({initial:t,onClose:s})=>{te();const a=o.useId().replace(/[^a-z0-9]/gi,""),i=`custom-draft-${a}`,[r,c]=o.useState(t),[l,d]=o.useState(t);o.useEffect(()=>{const N=setTimeout(()=>d(r),180);return()=>clearTimeout(N)},[r]);const[u,m]=o.useState({}),[p,g]=o.useState(null),[_,x]=o.useState(!0),[k,b]=o.useState(!1),[S,I]=o.useState(!1),[M,L]=o.useState(!1),E=o.useRef(null),O=o.useRef(!1),[y,F]=o.useState(""),[K,P]=o.useState(()=>{try{return localStorage.getItem("lo-theme-editor-advanced")==="true"}catch{return!1}}),[f,A]=o.useState([]),T=os(),v=ue(N=>N.contrast),H=ue(N=>N.accent),z=st(r.base)?.palette;if(!z)throw new Error("unknown custom theme base");const q=o.useMemo(()=>sn(z,r),[z,r]),Z=o.useMemo(()=>fn(q,r.base),[q,r.base]),h=o.useMemo(()=>sn(z,l),[z,l]),R=o.useMemo(()=>fn(h,r.base).findings.length===0,[h,r.base]),j=o.useMemo(()=>R?hr(h,{contrast:v[z.mode],accent:H[z.mode],id:r.base,paletteAccent:N=>st(N)?.palette.accent}):{palette:h},[h,R,v,H,z.mode,r.base]),U=o.useMemo(()=>fn(j.palette,r.base),[j.palette,r.base]),ne=z.mode==="dark"?Cs(q.canvas).l>50:Cs(q.canvas).l<50,Y=JSON.stringify(r)!==JSON.stringify(t)||Object.keys(u).length>0,X=Object.values(u).some(N=>!pt.test(N)),re=!T.themes.some(N=>N.id===r.id)&&T.themes.length>=50,ce=N=>{A(G=>[...G.slice(-19),r]),c(N),b(!1),I(!1)},de=(N,G)=>{const ae=Object.prototype.hasOwnProperty.call(r.overrides,N)?"overrides":Tt.includes(N)?"seeds":"overrides";ce({...r,[ae]:{...r[ae],[N]:G}}),m(J=>{const _e={...J};return delete _e[N],_e})},be=()=>{M||(Y?(E.current=document.activeElement instanceof HTMLElement?document.activeElement:null,L(!0)):s())},pe=()=>{const N=ho(z,r);N?(ce(N),F(n("ui.settings.appearance.editor.validation_pass"))):I(!0)},B=N=>{const G=U.readings.filter(le=>le.foreground===N||le.background===N).sort((le,we)=>le.value/le.floor-we.value/we.floor)[0],ae=u[N]??r.overrides[N]??r.seeds[N]??q[N],J=Object.prototype.hasOwnProperty.call(r.overrides,N),_e=`${a}-${N}`;return e.jsxs("div",{className:"flex flex-col gap-2 border-hairline border-b py-2",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button","aria-label":n("ui.settings.appearance.editor.edit_role",{role:Ge(N)}),"aria-expanded":p===N,onClick:()=>{g(p===N?null:N),x(!0)},className:"size-8 shrink-0 rounded-sm border border-control focus-visible:outline-2 focus-visible:outline-accent",style:{background:q[N]}}),e.jsxs("label",{htmlFor:_e,className:"min-w-0 flex-1 text-body-sm",children:[Ge(N),J&&e.jsx("span",{className:"ms-1 text-meta text-ink-muted",children:n("ui.settings.appearance.editor.edited")})]}),e.jsx(Ne,{id:_e,inputSize:"sm",value:ae,maxLength:7,"aria-invalid":!pt.test(ae),className:"w-24 shrink-0 font-mono",onChange:le=>m(we=>({...we,[N]:le.target.value})),onBlur:()=>{pt.test(ae)&&de(N,ae.toUpperCase())},onKeyDown:le=>{le.key==="Enter"&&pt.test(ae)&&(le.preventDefault(),de(N,ae.toUpperCase()))}}),G&&e.jsx("span",{className:ge("text-meta",G.value<G.floor?"text-danger":"text-ink-muted"),title:`${n("ui.settings.appearance.editor.pair",{foreground:Ge(G.foreground),background:Ge(G.background)})} · ${n("ui.settings.appearance.editor.floor",{value:String(G.floor)})}`,children:n("ui.settings.appearance.editor.ratio",{value:G.value.toFixed(2)})}),(J||Object.prototype.hasOwnProperty.call(r.seeds,N))&&e.jsx(D,{type:"button",size:"sm",variant:"ghost","aria-label":n("ui.settings.appearance.editor.reset_role",{role:Ge(N)}),onClick:()=>{const le={...r.seeds},we={...r.overrides};J?delete we[N]:delete le[N],ce({...r,seeds:le,overrides:we}),m(Ie=>{const fe={...Ie};return delete fe[N],fe})},children:n("ui.settings.appearance.editor.reset_role",{role:Ge(N)})})]}),!pt.test(ae)&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.invalid_hex")}),p===N&&e.jsx("div",{className:"rounded-md border border-hairline bg-surface p-3",children:e.jsx(xi,{value:q[N],onChange:le=>de(N,le),onValidityChange:x,swatches:Tt.map(le=>q[le])},N)})]},N)};return e.jsxs(e.Fragment,{children:[e.jsx(fc,{open:!0,onOpenChange:N=>{N||be()},children:e.jsxs(_c,{className:"flex w-full max-w-full flex-col gap-0 overflow-hidden sm:w-140 sm:max-w-140 text-ink",onKeyDown:N=>{if((N.metaKey||N.ctrlKey)&&N.key==="z"&&!(N.target instanceof HTMLInputElement||N.target instanceof HTMLTextAreaElement||N.target instanceof HTMLElement&&N.target.isContentEditable)){N.preventDefault();const G=f.at(-1);G&&(c(G),A(ae=>ae.slice(0,-1)))}},children:[e.jsxs("div",{className:"shrink-0 border-hairline border-b pb-3 pe-8",children:[e.jsx(xc,{children:n("ui.settings.appearance.editor.edit")}),e.jsx(yc,{children:n("ui.settings.appearance.editor.preview_note")})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto py-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("label",{htmlFor:`${a}-name`,className:"flex flex-col gap-1 text-body-sm",children:[n("ui.settings.appearance.editor.name"),e.jsx(Ne,{value:r.name,id:`${a}-name`,maxLength:60,onChange:N=>ce({...r,name:N.target.value}),"aria-invalid":!r.name.trim()})]}),!r.name.trim()&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.name_required")}),e.jsxs("p",{className:"text-meta text-ink-muted",children:[n("ui.settings.appearance.editor.base",{name:Be(r.base)?ze[r.base].name:r.base})," ","·"," ",n(z.mode==="dark"?"ui.settings.appearance.editor.mode_dark":"ui.settings.appearance.editor.mode_light")]}),ne&&e.jsx("p",{className:"text-meta text-warning",children:n("ui.settings.appearance.editor.mode_warning")}),e.jsx("style",{children:ei(i,j.palette)}),e.jsx(eh,{id:i}),e.jsxs("p",{className:"text-meta text-ink-muted",children:[R&&n("ui.settings.appearance.editor.contrast_note",{value:String(v[z.mode])})," ",R&&H[z.mode].kind!=="theme"?n("ui.settings.appearance.editor.accent_note"):null]}),e.jsxs("div",{"aria-live":"polite",className:"flex flex-wrap items-center justify-between gap-2 rounded-sm border border-hairline bg-surface p-2 text-body-sm",children:[e.jsx("span",{className:X||!_||Z.findings.length?"text-danger":"text-success",children:X?n("ui.settings.appearance.editor.invalid_hex"):_?Z.findings.length?n("ui.settings.appearance.editor.validation_summary",{count:Z.findings.length}):n("ui.settings.appearance.editor.validation_pass"):n("ui.settings.appearance.editor.picker.invalid_channels")}),!X&&_&&Z.findings.length>0&&e.jsx(D,{type:"button",variant:"secondary",size:"sm",onClick:pe,children:n("ui.settings.appearance.editor.adjust")})]}),S&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.adjust_unavailable")}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-body-sm font-medium",children:n("ui.settings.appearance.editor.essentials")}),Tt.map(B)]}),e.jsxs("section",{children:[e.jsxs("button",{type:"button","aria-expanded":K,className:"flex w-full items-center justify-between text-start text-body-sm font-medium",onClick:()=>{P(!K);try{localStorage.setItem("lo-theme-editor-advanced",String(!K))}catch{}},children:[n("ui.settings.appearance.editor.advanced"),e.jsx("span",{"aria-hidden":"true",children:K?"−":"+"})]}),e.jsx("p",{className:"mt-2 text-meta text-ink-muted",children:n("ui.settings.appearance.editor.pinned_note")}),K&&e.jsxs(e.Fragment,{children:[go.filter(N=>!Tt.includes(N)).map(B),["overlayShadow","scrim"].map(N=>e.jsxs("label",{className:"flex flex-col gap-1 py-2 text-body-sm",children:[Ge(N),e.jsx("input",{type:"range",min:0,max:1,step:.01,value:r.overrides[N]??Number(/\/\s*([\d.]+)/.exec(z[N])?.[1]??.5),onChange:G=>ce({...r,overrides:{...r.overrides,[N]:G.target.value}}),className:"h-7 accent-accent"})]},N))]})]})]})}),e.jsxs("div",{className:"shrink-0 border-hairline border-t pt-3",children:[e.jsx("output",{className:"text-meta text-ink-muted",children:y}),k&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.save_error")}),re&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.limit")}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(D,{variant:"ghost",onClick:be,children:n("ui.settings.appearance.editor.cancel")}),e.jsx(D,{variant:"primary",disabled:!r.name.trim()||r.name.length>60||X||!_||Z.findings.length>0||re,onClick:()=>{try{const N={...r,name:r.name.trim(),updatedAt:Date.now()};po(N),ue.setState({themeName:Be(N.base)?N.base:"localOperatorDark",customThemeId:N.id});for(const G of Object.values(N.seeds))_i(G);ss(n("ui.settings.appearance.editor.saved")),s()}catch{b(!0)}},children:n("ui.settings.appearance.editor.save")})]})]})]})}),e.jsx(qt,{open:M,onOpenChange:L,children:e.jsxs(Vt,{onCloseAutoFocus:N=>{!O.current&&E.current?.isConnected&&(N.preventDefault(),E.current.focus({preventScroll:!0}))},children:[e.jsx(Gt,{children:n("ui.settings.appearance.editor.discard_title")}),e.jsx(Wt,{children:n("ui.settings.appearance.editor.discard_description")}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(D,{variant:"secondary",onClick:()=>L(!1),children:n("ui.settings.appearance.editor.keep_editing")}),e.jsx(D,{variant:"danger",onClick:()=>{O.current=!0,s()},children:n("ui.settings.appearance.editor.discard")})]})]})})]})},sh=({loading:t,error:s,count:a,onRetry:i})=>(te(),t?e.jsx("p",{"aria-live":"polite",className:"text-meta text-ink-muted",children:n("ui.settings.appearance.editor.loading")}):s?e.jsxs("div",{className:"text-meta text-danger",role:"alert",children:[n("ui.settings.appearance.editor.load_error")," ",e.jsx(D,{variant:"ghost",size:"sm",onClick:i,children:n("ui.settings.appearance.editor.retry")})]}):a===0?e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.appearance.editor.empty")}):null),ja=()=>`custom-${crypto.randomUUID().replace(/-/g,"").slice(0,20)}`,ah=()=>{const t=os(),s=ue(y=>y.customThemeId),a=ue(y=>y.themeName),[i,r]=o.useState(null),[c,l]=o.useState(null),[d,u]=o.useState(null),[m,p]=o.useState(!1),[g,_]=o.useState(""),[x,k]=o.useState(""),[b,S]=o.useState(""),I=y=>{const F=t.themes.find(f=>f.id===y),K=F?.base??y;if(!Be(K))return;const P=Rs(n("ui.settings.appearance.editor.new_name",{name:F?.name??ze[K].name}),t.themes);r({format:"local-operator-theme",version:1,id:ja(),name:P,base:K,seeds:{...F?.seeds},overrides:{...F?.overrides},updatedAt:Date.now()})},M=y=>{try{const F=yo(y,Be,{id:ja()});F.name=Rs(F.name,t.themes),p(!1),S(""),r(F)}catch(F){const K=F instanceof Error?F.message:"import_error",P={import_invalid_json:n("ui.settings.appearance.editor.import_invalid_json"),import_format:n("ui.settings.appearance.editor.import_format"),import_version:n("ui.settings.appearance.editor.import_version"),import_size:n("ui.settings.appearance.editor.import_size"),import_base:n("ui.settings.appearance.editor.import_base"),import_name:n("ui.settings.appearance.editor.import_name"),import_roles:n("ui.settings.appearance.editor.import_roles"),import_unsafe:n("ui.settings.appearance.editor.import_unsafe")};S(P[K]??n("ui.settings.appearance.editor.import_error"))}},L=(y,F=!0)=>{const K=t.themes.find(f=>f.id===y),P=K?.name??(Be(y)?ze[y].name:y);return e.jsxs(Za,{children:[e.jsx(Ja,{asChild:!0,children:e.jsx(D,{type:"button",variant:"ghost",size:"icon-sm",tabIndex:F?0:-1,"aria-label":n("ui.settings.appearance.editor.more",{name:P}),className:"absolute end-1 top-1 z-10 bg-canvas",children:e.jsx(Oa,{size:14})})}),e.jsxs(Xa,{align:"end",children:[K&&e.jsx(Xe,{onSelect:()=>r(K),children:n("ui.settings.appearance.editor.edit")}),e.jsx(Xe,{onSelect:()=>I(y),children:n("ui.settings.appearance.editor.duplicate")}),K&&e.jsxs(e.Fragment,{children:[e.jsx(Xe,{onSelect:()=>{u(K),S(""),k("")},children:n("ui.settings.appearance.editor.export")}),e.jsx(Xe,{onSelect:()=>{l(K),S("")},children:n("ui.settings.appearance.editor.delete")})]})]})]})},E=e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(D,{variant:"secondary",size:"sm",onClick:()=>{const y=t.themes.find(F=>F.id===s);y?r(y):I(a)},children:n("ui.settings.appearance.editor.customize")}),e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>{p(!0),S(""),_("")},children:n("ui.settings.appearance.editor.import")})]}),e.jsx(sh,{loading:t.loading,error:t.error,count:t.themes.length,onRetry:fo})]}),O=e.jsxs(e.Fragment,{children:[i&&e.jsx(nh,{initial:i,onClose:()=>r(null)},i.id),e.jsx(qt,{open:!!c,onOpenChange:y=>{y||l(null)},children:e.jsxs(Vt,{children:[e.jsx(Gt,{children:n("ui.settings.appearance.editor.delete_title",{name:c?.name??""})}),e.jsx(Wt,{children:n("ui.settings.appearance.editor.delete_description")}),b&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:b}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(D,{variant:"secondary",onClick:()=>l(null),children:n("ui.settings.appearance.editor.cancel")}),e.jsx(D,{variant:"danger",onClick:()=>{if(c)try{_o(c.id),s===c.id&&ue.setState({customThemeId:null}),l(null),ss(n("ui.settings.appearance.editor.deleted"))}catch{S(n("ui.settings.appearance.editor.save_error"))}},children:n("ui.settings.appearance.editor.delete")})]})]})}),e.jsx(qt,{open:m,onOpenChange:p,children:e.jsxs(Vt,{children:[e.jsx(Gt,{children:n("ui.settings.appearance.editor.import_title")}),e.jsx(Wt,{children:n("ui.settings.appearance.editor.import_description")}),e.jsxs("label",{className:"flex flex-col gap-1 text-body-sm",children:[n("ui.settings.appearance.editor.import_text"),e.jsx("textarea",{dir:"ltr","aria-invalid":!!b,value:g,onChange:y=>_(y.target.value),className:"min-h-48 w-full rounded-sm border border-control bg-sunken p-2 font-mono text-meta"})]}),b&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:b}),e.jsxs("div",{className:"flex flex-wrap justify-between gap-2",children:[e.jsxs("label",{className:"cursor-pointer rounded-sm border border-control px-2 py-1.5 text-body-sm focus-within:outline-2 focus-within:outline-accent",children:[n("ui.settings.appearance.editor.import_file"),e.jsx("input",{type:"file",accept:".json,application/json",className:"sr-only",onChange:async y=>{const F=y.target.files?.[0];if(F){if(F.size>xo){S(n("ui.settings.appearance.editor.import_size"));return}try{M(await F.text())}catch{S(n("ui.settings.appearance.editor.import_read"))}y.target.value=""}}})]}),e.jsx(D,{disabled:!g.trim(),onClick:()=>M(g),children:n("ui.settings.appearance.editor.import_submit")})]})]})}),e.jsx(qt,{open:!!d,onOpenChange:y=>{y||u(null)},children:e.jsxs(Vt,{children:[e.jsx(Gt,{children:n("ui.settings.appearance.editor.export_title",{name:d?.name??""})}),e.jsx(Wt,{children:n("ui.settings.appearance.editor.export_title",{name:d?.name??""})}),b&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:b}),e.jsx("textarea",{dir:"ltr","aria-label":n("ui.settings.appearance.editor.import_text"),readOnly:!0,value:d?_n(d):"",className:"min-h-48 w-full rounded-sm border border-control bg-sunken p-2 font-mono text-meta"}),e.jsx("p",{"aria-live":"polite",className:"text-meta text-success",children:x}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(D,{variant:"secondary",onClick:()=>{if(d)try{const y=URL.createObjectURL(new Blob([_n(d)],{type:"application/json"})),F=document.createElement("a");F.href=y,F.download=`${d.name.replace(/[^a-z0-9_-]/gi,"-").slice(0,60)||"theme"}.json`,F.click(),setTimeout(()=>URL.revokeObjectURL(y),1e3)}catch{S(n("ui.settings.appearance.editor.export_error"))}},children:n("ui.settings.appearance.editor.export_file")}),e.jsx(D,{onClick:async()=>{if(d)try{await navigator.clipboard.writeText(_n(d)),k(n("ui.settings.appearance.editor.export_copied"))}catch{S(n("ui.settings.appearance.editor.clipboard_error"))}},children:n("ui.settings.appearance.editor.export_copy")})]})]})})]});return{library:t,active:s,header:E,menu:L,dialogs:O}},ih={localOperatorDark:Jl,localOperatorLight:bd,dracula:md,dune:Sl,sage:Hl,monokai:Vo,tokyoNight:nd,iceberg:pd,radient:zl,neon:vo,obsidian:ti,synth:Uc,catppuccinMocha:ul,catppuccinLatte:Wl,tokyoNightStorm:sl,gruvbox:Yc,nord:Kd,oneDark:Pc,solarizedDark:xd,rosePine:El,rosePineMoon:Ql,rosePineDawn:ll,alucard:Rl,gruvboxLight:xl,tokyoNightDay:ed,oneLight:Vl,catppuccinFrappe:fl,catppuccinMacchiato:$l,palenight:bo,everforest:Ld,everforestLight:Rd,kanagawaWave:zd,kanagawaLotus:Ml,ayuDark:bl,ayuMirage:kl,ayuLight:cd,nightfox:il,duskfox:wd,synthwave:rd,matrix:Bc,tron:tl,cyberpunk:qo,vaporwave:Ed,outrun:Gc,neonNoir:Dd,arcade:Kl,forest:Md,ocean:wl,desert:Sd,autumn:$d,lavender:fd,arctic:ol,rosewood:Dl,solarizedLight:kd,githubLight:Ll,paper:Ic,linen:dd,highContrastLight:Fc,mintLight:qc},wa="bg-[color-mix(in_srgb,var(--color-accent)_8%,var(--color-accent-wash))]",rh=({id:t})=>e.jsxs("div",{"data-theme":t,"aria-hidden":"true",className:"flex h-full bg-canvas",children:[e.jsxs("div",{className:"flex w-1/4 flex-col gap-1 bg-sunken p-1",children:[e.jsx("span",{className:"flex h-2.5 items-center rounded-xs bg-accent-wash px-1",children:e.jsx("span",{className:"h-1 w-full rounded-xs bg-accent"})}),e.jsx("span",{className:"mx-1 h-1 w-2/3 rounded-xs bg-ink-dim"}),e.jsx("span",{className:"mx-1 h-1 w-1/2 rounded-xs bg-ink-dim"})]}),e.jsxs("div",{className:"flex flex-1 flex-col justify-between p-1",children:[e.jsxs("div",{className:"flex flex-col gap-1 rounded-xs bg-surface p-1",children:[e.jsx("span",{className:"h-1 w-3/5 rounded-xs bg-ink"}),e.jsx("span",{className:"h-1 w-full rounded-xs bg-ink-dim"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-2.5 w-6 rounded-xs bg-elevated"}),e.jsx("span",{className:"h-2.5 w-5 rounded-xs bg-accent"}),e.jsx("span",{className:"h-2.5 w-4 rounded-xs bg-accent-alt"}),e.jsx("span",{className:"h-2.5 w-4 rounded-xs border border-control"})]})]})]}),oh=({id:t,name:s,description:a,isSelected:i,isTabStop:r,onSelect:c,onFocusTile:l})=>{const d=ih[t]??ad;return e.jsx(Pe,{side:"bottom",align:"start",content:a,children:e.jsxs("button",{type:"button","data-theme-tile":t,"aria-pressed":i,tabIndex:r?0:-1,onFocus:l,onClick:c,className:ge("relative flex flex-col gap-1.5 rounded-md p-1 text-start transition-colors duration-fast ease-out-quart",i?wa:"hover:bg-surface"),children:[e.jsxs("span",{className:ge("relative block h-10 overflow-hidden rounded-sm border transition-colors duration-fast ease-out-quart",i?"border-accent":"border-hairline"),children:[e.jsx(rh,{id:t}),i&&e.jsx("span",{className:ge("pointer-events-none absolute top-0.5 end-0.5 flex h-4 w-4 items-center justify-center rounded-full",wa),children:e.jsx(cn,{size:12,className:"text-accent","aria-hidden":"true"})})]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(d,{size:12,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink",children:s})]})]})})},ch=t=>[...t.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(r=>Math.abs(r.getBoundingClientRect().top-i)<1).length)}}),lh=()=>{te();const{themeName:t,setTheme:s}=ue(),a=ah(),i=a.library.themes.find(g=>g.id===a.active)?.id??t,r=a.library.themes.flatMap(g=>{const _=st(g.base)?.palette;if(!_)return[];const x=sn(_,g);return[{id:g.id,name:g.name,description:n("ui.settings.appearance.editor.base",{name:Be(g.base)?ze[g.base].name:g.base}),css:ei(g.id,x)}]}),c=Object.values(ze),l=[{label:n("ui.settings.appearance.editor.custom_group"),items:r},{label:n("ui.settings.appearance.theme_selector.dark"),items:c.filter(g=>g.theme.palette.mode==="dark")},{label:n("ui.settings.appearance.theme_selector.light"),items:c.filter(g=>g.theme.palette.mode==="light")}].filter(g=>g.items.length>0),[d,u]=o.useState(null),m=o.useMemo(()=>{const g=l.flatMap(_=>_.items.map(x=>x.id));return d&&g.includes(d)?d:g.includes(i)?i:g[0]},[l,d,i]),p=g=>{if(!Qp(g.key))return;const _=[...g.currentTarget.querySelectorAll("[data-theme-tile]")],x=_.indexOf(g.target);if(x<0)return;g.preventDefault();const k=Jp({index:x,key:g.key,groups:ch(g.currentTarget)});k!==x&&_[k]?.focus()};return e.jsx(Ya,{children:e.jsxs("div",{onKeyDown:p,"data-search-ignore":"the theme picker is a grid of fifty-nine choices; the Appearance section result is its destination",className:"flex flex-col gap-6",children:[a.header,e.jsx("style",{children:r.map(g=>g.css).join(`
|
|
296
|
-
`)}),a.dialogs,l.map(g=>e.jsxs("div",{children:[e.jsx("h3",{className:"px-1 pb-2 text-meta text-ink-dim",children:g.label}),e.jsx("div",{"data-theme-grid":g.label,className:"grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2",children:g.items.map(({id:_,name:x,description:k})=>e.jsxs("div",{className:"group relative min-w-0",children:[e.jsx(oh,{id:_,name:x,description:k,isSelected:_===i,isTabStop:_===m,onSelect:()=>{const b=a.library.themes.find(S=>S.id===_);b&&Be(b.base)?ue.setState({themeName:b.base,customThemeId:_}):Be(_)&&s(_)},onFocusTile:()=>u(_)}),e.jsx("div",{className:"absolute end-1 top-1 opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",children:a.menu(_,_===m)})]},_))})]},g.label))]})})},dh=({value:t,onChange:s,searchRow:a})=>{te();const i=o.useId();return e.jsxs("div",{"data-search-row":a,"data-search-control":a?"":void 0,className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{id:i,className:"flex min-h-6 items-center text-body text-ink",children:n("ui.settings.appearance.transcript_display_mode_setting.transcript_display")}),e.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")})]}),e.jsx("div",{className:"flex h-6 shrink-0 items-center",children:e.jsx(kt,{value:t,onValueChange:r=>s(Ca(r)),children:e.jsx(jt,{"aria-labelledby":i,children:fr.map(r=>e.jsx(Ye,{value:r.value,children:r.value==="by-turn"?n("ui.settings.appearance.transcript_display_mode_setting.by_turn"):n("ui.settings.appearance.transcript_display_mode_setting.by_response")},r.value))})})})]})},uh=()=>{te();const{data:t,isLoading:s,error:a}=Yd({enabled:!0});return e.jsxs("div",{children:[e.jsxs("h3",{className:"mb-3 flex items-center gap-2 text-heading text-ink",children:[e.jsx(pl,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.radient_pass")]}),s&&e.jsx(Ae,{className:"h-6 w-36"}),a&&e.jsx(me,{variant:"warning",children:n("ui.settings.account.settings_page.credit_balance_load_failed",{reason:a.message})}),t&&!s&&!a&&e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("p",{className:"flex-1 text-body-sm text-ink-muted",children:[n("ui.settings.account.settings_page.available_credits")," ",e.jsx("span",{className:"font-medium text-ink",children:t.balance.toFixed(2)})]}),e.jsx(D,{variant:"secondary",size:"sm",asChild:!0,children:e.jsxs("a",{href:"https://console.radienthq.com/dashboard/billing",target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Xc,{}),n("ui.settings.account.settings_page.add_credits")]})})]})]})},mh=[{id:"credits",get label(){return n("ui.settings.account.settings_page.credits")}},{id:"tokens",get label(){return n("ui.settings.account.settings_page.tokens")}}],gh=()=>{te();const[t,s]=o.useState("credits"),a=o.useMemo(()=>{const d=new Date,u=Vd(d);return{start_date:Ds(u),end_date:Ds(d),rollup:"daily"}},[]),{data:i,isLoading:r,error:c}=Zd(a,{enabled:!0}),l=o.useMemo(()=>i?.data_points?[...i.data_points].sort((u,m)=>vn(u.timestamp).getTime()-vn(m.timestamp).getTime()).map(u=>({bucket:Ao(Lc(vn(u.timestamp),"yyyy-MM-dd")),value:t==="credits"?Number.parseFloat(u.total_cost.toFixed(2)):u.total_tokens})):[],[i,t]);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(Zc,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.usage_last_30_days")]}),e.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:n("ui.settings.account.settings_page.usage_metric")}),e.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:mh.map(({id:d,label:u})=>e.jsx(D,{variant:"ghost",size:"sm","aria-pressed":t===d,onClick:()=>s(d),className:ge(t===d&&"bg-surface text-ink hover:bg-surface"),children:u},d))})]})]}),r&&e.jsx(Ae,{className:"h-62 w-full"}),c&&e.jsx(me,{variant:"warning",children:n("ui.settings.account.settings_page.usage_load_failed",{reason:c.message})}),!r&&!c&&i&&l.length>0&&e.jsx(Op,{metric:t,data:l}),!r&&!c&&(!i||l.length===0)&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.account.settings_page.no_usage_recorded_in_the_last_30_days")})]})},ph=()=>(te(),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(ac,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.radient_account")]}),e.jsx(D,{variant:"secondary",size:"sm",className:"self-start sm:self-center",asChild:!0,children:e.jsxs("a",{href:"https://console.radienthq.com",target:"_blank",rel:"noopener noreferrer",children:[n("ui.settings.account.settings_page.go_to_radient_console"),e.jsx(za,{})]})})]})),Rh=()=>{te();const t=ko(),s=ue(w=>w.showAgentReasoning),a=ue(w=>w.setShowAgentReasoning),i=ue(w=>w.transcriptDisplayMode),r=ue(w=>w.setTranscriptDisplayMode),c=ue(w=>w.agentAvatarSize),l=ue(w=>w.setAgentAvatarSize),{data:d,isLoading:u,isFetching:m,error:p,refetch:g}=jo(),{needsProvider:_}=wo(),x=Ka(),{sentence:k,remedy:b}=zn(x??null,n("ui.settings.navigation.settings_page.your_settings_could_not_be_loaded"),p),S=Go(),[I,M]=o.useState(null),L=Pa(),{isAuthenticated:E,accountRead:O,isFetching:y,isRefreshing:F,refreshUser:K}=as(),P=ft(w=>w.activeSessionId),f=ft(w=>w.sessions),A=wu(),{accountId:T,snapshot:v,model:H}=Ha(),z=o.useRef(null);v.status?z.current={accountId:T,status:v.status}:v.checking||(z.current=null);const q=v.status??(z.current?.accountId===T?z.current.status:null),Z=au(A),h=o.useMemo(()=>Wo.filter(w=>w.id!=="agent-messages"||A!=="absent"),[A]),R=o.useCallback(()=>H.check("surface_open",!0),[H]),[j,U]=o.useState("general"),[ne,Y]=o.useState(!1),X=o.useRef(null),re=o.useRef(null),{startTour:ce}=Yo(),de=_r(),be=Sa(),{data:pe,refetch:B}=No(),{refreshModels:N}=So(),G=o.useMemo(()=>pe?.keys?[...pe.keys].sort():[],[pe?.keys]),ae=o.useRef({keys:"",hosting:void 0});o.useEffect(()=>{const w=G.join(","),$=d?.values?.hosting;(ae.current.keys!==w||ae.current.hosting!==$)&&(ae.current={keys:w,hosting:$},N().catch(Q=>{console.error("Failed to refresh models after credentials or hosting change:",Q)}))},[G,d?.values?.hosting,N]);const J=o.useRef({general:o.useRef(null),radient:o.useRef(null),integrations:o.useRef(null),appearance:o.useRef(null),speech:o.useRef(null),keyboard:o.useRef(null),providers:o.useRef(null),"agent-messages":o.useRef(null),backend:o.useRef(null),imports:o.useRef(null),updates:o.useRef(null)}).current,_e=o.useMemo(()=>new URLSearchParams(de.search).get("setting"),[de.search]),le=o.useMemo(()=>new URLSearchParams(de.search).get("filter")??"",[de.search]),we=o.useMemo(()=>new URLSearchParams(de.search).get("mcp")??void 0,[de.search]),Ie=o.useMemo(()=>new URLSearchParams(de.search).get("provider"),[de.search]),fe=o.useCallback(w=>{U(w),Y(!0);const $=J[w],Q=re.current;if($?.current&&Q){const ve=$.current.getBoundingClientRect().top-Q.getBoundingClientRect().top;Q.scrollHeight>Q.clientHeight?Q.scrollTo({top:Math.max(0,Q.scrollTop+ve-80),behavior:"smooth"}):window.scrollTo({top:Math.max(0,$.current.getBoundingClientRect().top+window.scrollY-80),behavior:"smooth"}),clearTimeout(X.current??void 0),X.current=setTimeout(()=>{Y(!1),X.current=null},800)}else Y(!1)},[J]),ee=o.useRef(null),ie=o.useRef(null),V=Ct(),se=at(V.data,"settings"),oe=Te({queryKey:nn.all,queryFn:()=>je({op:"settings.list"}),enabled:se,staleTime:1e4}),Me=Rp({registry:oe.data,sections:h}),rt=o.useCallback(()=>re.current?Ru(re.current):[],[]),[Se,It]=o.useState(null),Rt=o.useCallback(async w=>{ie.current=null;const $=re.current??document;if(w.source==="page")return Fu($,w.id.slice(5));if(w.source==="section")return zu($,w.sectionId);const Q=w.settingKey;if(!Q)return"missing";const he=Bt(Q,"backend");return oe.data&&!oe.data.settings.some(ve=>ve.key===Q)?"missing":(fe(he),It({key:Q,nonce:Date.now()}),$.querySelector(`[data-search-section="${he}"]`)?"landed":"missing")},[fe,oe.data]);o.useEffect(()=>{It(null)},[de.search]),o.useEffect(()=>{const w=$=>{!($.metaKey||$.ctrlKey)||$.altKey||$.key.toLowerCase()==="f"&&(xr($.target)||($.preventDefault(),ie.current=re.current?.scrollTop??null,ee.current?.focus()))};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[]),o.useEffect(()=>{const w=setTimeout(()=>{const $=re.current;if(!$)return;const Q=()=>{if(ne)return;const he=$.getBoundingClientRect(),ve=he.height;let xe="",Re=0;for(const[Le,He]of Object.entries(J))if(He.current){const $e=He.current.getBoundingClientRect(),qe=he.top,lt=$e.top-qe,dt=$e.bottom-qe,Pi=$e.height,$i=Math.max(0,lt),Ui=Math.min(ve,dt),js=Math.max(0,Ui-$i)/Pi,ws=js+(lt<ve*.3?.1:0);ws>Re&&js>.1&&(Re=ws,xe=Le)}xe&&xe!==j&&U(xe)};return Q(),$.addEventListener("scroll",Q,{passive:!0}),()=>{$.removeEventListener("scroll",Q),clearTimeout(X.current??void 0)}},100);return()=>clearTimeout(w)},[J,j,ne]),o.useEffect(()=>{const w=new URLSearchParams(de.search),$=w.get("section"),Q=w.get("setting"),he=Q?Bt(Q,"backend"):$;if(he==="agent-messages"&&!Z)return;const ve=he?J[he]:void 0;if(!he||!ve)return;let xe=!1,Re=Number.NaN,Le=0;const He=window.setTimeout(()=>{xe||(xe=!0,qe.disconnect(),fe(he))},2e3),$e=()=>{if(xe)return;const lt=ve.current;if(!lt){Le=requestAnimationFrame($e);return}const dt=Math.round(lt.getBoundingClientRect().top+window.scrollY);if(dt===Re&&dt>0){xe=!0,qe.disconnect(),window.clearTimeout(He),fe(he);return}Re=dt,Le=requestAnimationFrame($e)},qe=new ResizeObserver(()=>{xe||(cancelAnimationFrame(Le),Le=requestAnimationFrame($e))});return re.current&&qe.observe(re.current),Le=requestAnimationFrame($e),()=>{xe=!0,cancelAnimationFrame(Le),qe.disconnect(),window.clearTimeout(He)}},[de.search,J,fe,Z]);const ot=async(w,$)=>{M(w);try{await S.mutateAsync({[w]:$}),await g()}catch(Q){console.error(`Error updating ${w}:`,Q)}finally{M(null)}},ct=u,un=O==="checking",mn=Ua(O),Ze=O==="ready"||O==="checking"||y,C=Ba(ct,4e3);return p?e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(me,{variant:"warning",className:"w-full max-w-xl",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:k}),b&&e.jsx(D,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void g(),disabled:m,children:m?n("ui.settings.navigation.settings_page.retrying"):n("ui.settings.navigation.settings_page.retry")})]})})}):ct?e.jsxs("div",{role:"status",className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-canvas",children:[e.jsx(Ee,{size:"lg",label:C?void 0:n("ui.settings.navigation.settings_page.loading_settings")}),C&&e.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?e.jsxs("div",{"data-glass-region":"canvas","data-glass-split":"",className:"panel-flush flex min-h-0 flex-1 overflow-hidden bg-canvas",children:[e.jsx("div",{className:"w-12 shrink-0 overflow-y-auto min-[1040px]:w-55",children:e.jsx(Qo,{activeSection:j,onSelectSection:fe,sections:h})}),e.jsx("div",{"data-glass-region":"canvas-content",className:"panel-top-pad flex min-h-0 min-w-0 flex-1 flex-col",children:e.jsx("div",{ref:re,"data-settings-content":!0,"data-tour-tag":"settings-general-section",className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden p-4 sm:p-6 md:p-8",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-8 pb-8",children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ic,{title:n("ui.settings.page.title"),icon:Ts}),e.jsx(Lp,{onDismiss:()=>{const w=ie.current;ie.current=null,w!==null&&re.current?.scrollTo({top:w})},ref:ee,index:Me,readRendered:rt,onJump:Rt})]}),e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsxs("div",{ref:J.general,"data-search-section":"general","data-search-section-label":n("ui.settings.navigation.settings_sidebar.general_settings"),className:"flex flex-col gap-8",children:[e.jsx(Zo,{focus:_e===bn||Se?.key===bn,focusNonce:Se?.key===bn?Se.nonce:void 0}),e.jsxs(ye,{title:n("ui.settings.profile.title"),icon:Va,description:n(E?"ui.settings.profile.description_authenticated":"ui.settings.profile.description_anonymous"),children:[un&&e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.profile.account_checking")}),mn&&e.jsx(me,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:n(O==="refused"?"ui.settings.profile.account_read_failed_refused":"ui.settings.profile.account_read_failed_retry")}),e.jsx(D,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>K(),disabled:F,children:F?n("ui.settings.profile.retrying"):n("ui.settings.profile.retry")})]})}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Ls,{searchRow:"general.profile.name",value:L.profile.name,label:n("ui.settings.profile.display_name.label"),placeholder:n("ui.settings.profile.display_name.placeholder"),isSaving:I==="user_name",onSave:async w=>{M("user_name");try{L.updateName(w)}finally{M(null)}},readOnly:Ze}),e.jsx(Ls,{searchRow:"general.profile.email",value:L.profile.email,label:n("ui.settings.profile.email.label"),placeholder:n("ui.settings.profile.email.placeholder"),isSaving:I==="user_email",onSave:async w=>{M("user_email");try{L.updateEmail(w)}finally{M(null)}},readOnly:Ze})]})]}),e.jsx(ye,{title:n("ui.settings.tour.title"),description:n("ui.settings.tour.description"),children:e.jsxs(D,{variant:"secondary","data-search-row":"general.tour","data-search-control":!0,onClick:()=>{ce({forceModalCompleted:!0})},children:[e.jsx(Co,{}),n("ui.settings.tour.action")]})}),e.jsx(ye,{id:"model-settings",title:n("ui.settings.model.settings_page.model_settings"),icon:Jo,description:n("ui.settings.model.settings_page.configure_the_default_ai_model_and_hosting_providers_used_for_gen"),children:e.jsxs("div",{"data-search-row":"general.model","data-search-control":!0,"data-search-label":n("ui.settings.model.settings_page.model_settings"),"data-search-terms":[n("ui.common.models.hosting_select.hosting_provider"),n("ui.common.models.model_select.model"),n("ui.settings.model.default_effort.label")].join(" "),className:"flex flex-col gap-4",children:[e.jsx(Xo,{value:d.values.hosting,isSaving:I==="hosting",onSave:w=>ot("hosting",w),filterByCredentials:!0,allowCustom:!0,allowDefault:!1,emptyHelperText:n("ui.settings.model.settings_page.no_hosting_options")}),e.jsx(ec,{value:d.values.model_name,hostingId:d.values.hosting,isSaving:I==="model_name",onSave:w=>ot("model_name",w),allowCustom:!0,allowDefault:!1}),e.jsx(Vu,{hosting:d.values.hosting,modelName:d.values.model_name,focus:_e===et||Se?.key===et,focusNonce:Se?.key===et?Se.nonce:void 0}),_&&e.jsx(me,{variant:"neutral",icon:e.jsx(rn,{className:"size-4","aria-hidden":"true"}),children:e.jsxs("span",{children:[n("ui.settings.model.provider_callout.sentence"),e.jsx("button",{type:"button",className:"text-accent underline underline-offset-2",onClick:()=>{fe("providers"),J.providers.current?.focus({preventScroll:!0})},children:n("ui.settings.model.provider_callout.providers_link")}),"."]})})]})}),e.jsx(Wp,{}),e.jsx(ye,{title:n("ui.settings.configuration.settings_page.configuration_information"),icon:rn,description:n("ui.settings.configuration.settings_page.system_information_about_the_current_configuration"),children:e.jsxs(Mt,{children:[e.jsx(ke,{label:n("ui.settings.configuration.settings_page.version"),value:e.jsx("span",{className:"text-mono-sm",children:d.version})}),e.jsx(ke,{label:n("ui.settings.configuration.settings_page.created"),value:$a(d.metadata.created_at)}),e.jsx(ke,{label:n("ui.settings.configuration.settings_page.last_modified"),value:rs(d.metadata.last_modified)}),e.jsx(ke,{label:n("ui.settings.configuration.settings_page.description"),value:d.metadata.description||n("ui.settings.configuration.settings_page.no_description_available")})]})})]}),e.jsx(ye,{title:n("ui.settings.appearance.settings_page.appearance"),icon:ti,description:n("ui.settings.appearance.settings_page.customize_the_look_and_feel_of_local_operator"),sectionRef:J.appearance,dataTourTag:"settings-appearance-section",searchSection:"appearance",searchSectionLabel:n("ui.settings.navigation.settings_sidebar.appearance"),children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Dm,{gallery:e.jsx(lh,{})}),e.jsx(ni,{searchRow:"appearance.reasoning",value:s,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 w=>a(w)}),e.jsx(dh,{searchRow:"appearance.transcript",value:Ca(i),onChange:w=>r(w)}),e.jsx(pm,{searchRow:"appearance.agent-picture-size",value:Dn(c),onChange:w=>l(w)}),e.jsx(tu,{searchRow:"appearance.glass",state:t.state,onChange:t.set})]})}),e.jsx(Vp,{sectionRef:J.speech}),e.jsx(tc,{sectionRef:J.keyboard,focusKey:_e}),e.jsx(ye,{title:n("ui.settings.model.settings_page.model_providers"),icon:Da,description:n("ui.settings.navigation.settings_page.sign_in_to_the_services_your_agents_think_with_new_chats_use_your"),sectionRef:J.providers,searchSection:"providers",searchSectionLabel:n("ui.settings.navigation.settings_sidebar.model_providers"),id:"model-providers",className:"focus-visible:outline-none!",children:e.jsx(nc,{initialProviderId:Ie,onChangeModel:()=>fe("general")})}),e.jsx(sp,{sessionId:P??void 0,sectionRef:J.integrations,highlightServer:we}),e.jsx(ye,{title:n("ui.settings.account.settings_page.radient_account"),titleComponent:e.jsx(ph,{}),description:n("ui.settings.account.settings_page.your_radient_account_radient_pass_details_and_credits_to_use_radi"),sectionRef:J.radient,dataTourTag:"settings-radient-account-section",searchSection:"radient",searchSectionLabel:n("ui.settings.navigation.settings_sidebar.radient_account"),searchIgnore:"account, billing and usage are read-only or remote",children:e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(kp,{onAfterCredentialUpdate:()=>{N(),B()}}),E&&e.jsxs(e.Fragment,{children:[e.jsx(uh,{}),e.jsx(gh,{})]})]})}),Z&&e.jsx(ye,{title:n("ui.agentMessages.settings.section"),icon:sc,description:n("ui.agentMessages.settings.description"),sectionRef:J["agent-messages"],id:"agent-messages",searchSection:"agent-messages",searchSectionLabel:n("ui.agentMessages.settings.section"),searchIgnore:"agent messages is a consent state machine; its registry rows are searchable",className:"border-b border-hairline pb-8",children:q?e.jsx(mu,{availability:A,status:q,accountId:T,refusal:v.refusal,onRefreshStatus:R,sessions:f,focus:_e===xn||Se?.key===xn,focusNonce:Se?.key===xn?Se.nonce:void 0,onOpenSession:w=>{H.invalidateStatus(),yr(be,w)}}):v.refusal?e.jsxs(me,{variant:"warning",children:[e.jsx(an,{children:n("ui.agentMessages.settings.error.title")}),e.jsxs(Oe,{children:[v.refusal.code!=="client_unavailable"&&e.jsx("span",{className:"block",children:Qt(v.refusal)}),e.jsx("span",{className:"block",children:n("ui.agentMessages.settings.error.no_changes")}),e.jsx(D,{className:"mt-3",variant:"secondary",onClick:()=>void R(),children:n("ui.agentMessages.settings.error.retry")})]})]}):e.jsxs("div",{"aria-busy":"true",className:"flex flex-col gap-3",children:[e.jsx(Ae,{className:"h-5 w-40"}),e.jsx(Ae,{className:"h-4 w-full max-w-xl"})]})}),e.jsx(ye,{title:n("ui.settings.navigation.settings_page.backend_settings"),icon:Ts,description:n("ui.settings.navigation.settings_page.every_setting_the_backend_registry_owns_searchable_with_typed_edi"),sectionRef:J.backend,searchSection:"backend",searchSectionLabel:n("ui.settings.navigation.settings_sidebar.backend_settings"),searchIgnore:"registry rows are searched by the Backend section's own filter",children:e.jsx(Mo,{hideInterfaceLanguage:!0,hideModelEffort:!0,hideAgentMessages:!0,hideSpeechShortcuts:!0,focusKey:Se?Se.key:_e&&Bt(_e,"backend")==="backend"?_e:null,focusNonce:Se?.nonce,initialFilter:le})}),e.jsx("div",{ref:J.imports,"data-search-section":"imports","data-search-section-label":n("ui.settings.imports.title"),"data-search-ignore":"imports are a one-off task list, not a setting",children:e.jsx(um,{})}),e.jsx("div",{ref:J.updates,"data-search-section":"updates","data-search-section-label":n("ui.settings.navigation.settings_sidebar.application_updates"),"data-search-ignore":"application updates are an action surface, not a setting",children:e.jsx(Ku,{})})]})]})})})]}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(me,{variant:"warning",className:"w-full max-w-xl",children:n("ui.settings.navigation.settings_page.your_settings_could_not_be_loaded")})})};export{Rh as SettingsPage};
|