local-operator-ui 0.50.4 → 0.50.6
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 +738 -10
- package/out/preload/index.js +27 -0
- package/out/renderer/assets/{_basePickBy-BIQfMR48.js → _basePickBy-CQk765Vr.js} +1 -1
- package/out/renderer/assets/{_baseUniq-BgTVzDm4.js → _baseUniq-BMM91dUn.js} +1 -1
- package/out/renderer/assets/{agent-details-page-CK7UCkbX.js → agent-details-page-BFwj7MBP.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-CjntTfYQ.js → agent-hub-page-U89F4cv6.js} +1 -1
- package/out/renderer/assets/{agents-page-C6JEzbLk.js → agents-page-D4dQDxPy.js} +3 -3
- package/out/renderer/assets/{appearance-Cr-wz2XG.js → appearance-ttjiyqhP.js} +23 -23
- package/out/renderer/assets/{approvalsOverlay-JbQyo85G.js → approvalsOverlay-Cix_TRGn.js} +1 -1
- package/out/renderer/assets/{arc-DlEzSww-.js → arc-BeHJ2fBy.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-BHqdE7jj.js → architectureDiagram-IEHRJDOE-C2wnau2b.js} +1 -1
- package/out/renderer/assets/{avatar-cropper-Y_1k15A7.js → avatar-cropper-C7MYyYo3.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-Ct_S7g13.js → blockDiagram-JOT3LUYC-CZQQUSSd.js} +1 -1
- package/out/renderer/assets/{book-open--MyFxzqx.js → book-open-ClSEPGsA.js} +1 -1
- package/out/renderer/assets/browser-page-LXrXwqrV.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-D4MzNaMs.js → browser-webauthn-prompt-BFca5LP9.js} +1 -1
- package/out/renderer/assets/{building-2-DtAeE_Wx.js → building-2-CBF_c2AO.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-0cfxxrV1.js → c4Diagram-VJAJSXHY-B7G2rwR4.js} +1 -1
- package/out/renderer/assets/channel-BUt00fex.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-DFPtGlqQ.js → chunk-4BMEZGHF-R-JNEdCQ.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-meyStMgl.js → chunk-A2AXSNBT-BK06j_5p.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-BEdPo4ks.js → chunk-AEK57VVT-BRRb-PkX.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-DcExUv5N.js → chunk-D6G4REZN-DSl1fIJJ.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-D97bec7O.js → chunk-RZ5BOZE2-DRxBYc4t.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-DGjNqQ8a.js → chunk-XZIHB7SX-Bp_ovT9h.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-C1wDdvMJ.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-C1wDdvMJ.js +1 -0
- package/out/renderer/assets/clone-Bxvn9QQ7.js +1 -0
- package/out/renderer/assets/{console-mirror-D1SJfDTV.js → console-mirror-Cemag-IJ.js} +1 -1
- package/out/renderer/assets/{consoleCapture-BQo7ETQQ.js → consoleCapture-D0qj3IcX.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-BDpuF7C6.js → conversation-input-sync-Cx-btqGa.js} +271 -261
- package/out/renderer/assets/{dagre-OKDRZEBW-CBaDWFEt.js → dagre-OKDRZEBW-DDJX06CF.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-ispcTo5e.js → diagram-SSKATNLV-ofr17JIt.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-BDlsgMn-.js → diagram-VNBRO52H-PsqlPI6G.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-CYPeSaH3.js → erDiagram-Q7BY3M3F-hI6JSYFc.js} +1 -1
- package/out/renderer/assets/error-boundary-yvtBOcL4.js +126 -0
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CMLsGESL.js → flowDiagram-4HSFHLVR-B55V8c-n.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-BRVxsCCP.js → ganttDiagram-APWFNJXF-vqiMKEQx.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-DE5og2RV.js → gitGraphDiagram-7IBYFJ6S-sLaZbdW1.js} +1 -1
- package/out/renderer/assets/{graph-DDnRFykm.js → graph-CU_GXEHc.js} +1 -1
- package/out/renderer/assets/{heart-CCdYNI3u.js → heart-BCMq3l76.js} +1 -1
- package/out/renderer/assets/{index-Bs2AkJmK.js → index-BLsENY5W.js} +1 -1
- package/out/renderer/assets/{index-Fa4fKvzr.js → index-BedfilW6.js} +1 -1
- package/out/renderer/assets/index-C0EaWX4c.js +819 -0
- package/out/renderer/assets/{index-CiHJ3lYz.js → index-DJdDss7c.js} +1 -1
- package/out/renderer/assets/index-OkXsp8p-.css +1 -0
- package/out/renderer/assets/infoDiagram-PH2N3AL5-u0DeEXjB.js +2 -0
- package/out/renderer/assets/{installer-DvzmkQaw.js → installer-CqkWdgIR.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-go9IQj5S.js → journeyDiagram-U35MCT3I-Cm0hvFhm.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BHwLNw_X.js → kanban-definition-NDS4AKOZ-CAQEDca8.js} +1 -1
- package/out/renderer/assets/{layout-zQcTVlOl.js → layout-DazFSbd3.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-BilFWlCA.js → legacy-agents-page-Q8-OZBJI.js} +1 -1
- package/out/renderer/assets/{library-page-BCQH7-hs.js → library-page-wFHW6du7.js} +3 -3
- package/out/renderer/assets/{log-in-D60gifZq.js → log-in-5A_BDA_t.js} +1 -1
- package/out/renderer/assets/{mermaid.core-DZNLevFz.js → mermaid.core-DEAQ6Mym.js} +5 -5
- package/out/renderer/assets/{mesh-page-CLeQ-D4w.js → mesh-page-Bdf9fxRR.js} +1 -1
- package/out/renderer/assets/{messages-Be02UCki.js → messages-DDIvESIa.js} +10 -10
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-DrOY-0sS.js → mindmap-definition-ALO5MXBD-BjaSAReR.js} +1 -1
- package/out/renderer/assets/{mini-Bab6ERe8.js → mini-DEOshKXE.js} +1 -1
- package/out/renderer/assets/{notebook-pen-DTmLjGHC.js → notebook-pen-CpzCS46r.js} +1 -1
- package/out/renderer/assets/{notifications-page-BbM3mzCl.js → notifications-page-BTc5zqEA.js} +1 -1
- package/out/renderer/assets/{org-access-3xV9NsSd.js → org-access-B30NsLwq.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-JoOFLPYi.js → org-surface-gate-Cq5AXPmH.js} +1 -1
- package/out/renderer/assets/{page-header-BBtmeXz0.js → page-header-Mac4Nfpt.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-JyfdH5gn.js → pieDiagram-IB7DONF6-8dl0bJXy.js} +1 -1
- package/out/renderer/assets/{project-markdown-D6HwXefM.js → project-markdown-D8GZ_eRZ.js} +1 -1
- package/out/renderer/assets/{projects-page-D5xBEICx.js → projects-page-DImd5QTv.js} +1 -1
- package/out/renderer/assets/{publication-validation-pOLp0dos.js → publication-validation-BCjrQA4Q.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-BBtDnoHn.js → quadrantDiagram-7GDLP6J5-C3a4ETdh.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-CtHJCWrJ.js → radar-MK3ICKWK-B-MHxKEk.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-DNkhmyBv.js → radient-auth-buttons-DdSU9yCc.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-sB5SDSjY.js → requirementDiagram-KVF5MWMF-lPPBuRZG.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-CGioYe_J.js → sankeyDiagram-QLVOVGJD-cFMkflSl.js} +1 -1
- package/out/renderer/assets/{schedules-page-jothEmnC.js → schedules-page-CQD6X1g1.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-CuNhF6i-.js → sequenceDiagram-X6HHIX6F-WumQPfZ-.js} +1 -1
- package/out/renderer/assets/settings-page-D01kxOV8.js +319 -0
- package/out/renderer/assets/{smartart-CGZfbyUs.js → smartart-DqxPmKMb.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-D5ElgpJs.js → stateDiagram-DGXRK772-BpYtDIv8.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D8oxXWwh.js +1 -0
- package/out/renderer/assets/{team-bridge-page-4TgWaKxG.js → team-bridge-page-BnoiIXWH.js} +2 -2
- package/out/renderer/assets/{team-bridge-scope-preference-D5JQQEFh.js → team-bridge-scope-preference-D1R2VnPr.js} +1 -1
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-B1vy2fC7.js → timeline-definition-BDJGKUSR-iO-CQHdh.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-CHGnPs7p.js → use-download-agent-mutation-B90w6N-Z.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-BpNsrx-E.js → use-session-snapshot-DMI61uEv.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-C-K_hlon.js → xychartDiagram-VJFVF3MP-B6Y3Yj5w.js} +1 -1
- package/out/renderer/browser-approvals-overlay.html +2 -2
- package/out/renderer/console-capture.html +6 -6
- package/out/renderer/index.html +8 -8
- package/out/renderer/installer.html +5 -5
- package/out/renderer/mini.html +8 -8
- package/package.json +1 -1
- package/out/renderer/assets/browser-page-CvQaa7ZF.js +0 -1
- package/out/renderer/assets/channel-BIfd2mO_.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-u2P52chH.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-u2P52chH.js +0 -1
- package/out/renderer/assets/clone-DXgy9Qu9.js +0 -1
- package/out/renderer/assets/error-boundary-iA1OMXPz.js +0 -126
- package/out/renderer/assets/index-B-6m8CCG.css +0 -1
- package/out/renderer/assets/index-Cpnot8lK.js +0 -824
- package/out/renderer/assets/infoDiagram-PH2N3AL5-Bdk9rxy6.js +0 -2
- package/out/renderer/assets/settings-page-caFCB3St.js +0 -296
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-61oDVBom.js +0 -1
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import{r as o,j as e,c as pe,f as yt,t as Qe,i as it}from"./index-BLsENY5W.js";import{h as De,u as kt,at as vr,aq as kr,au as jr,av as lt,a as jt,c as bt,aw as wr,a8 as Nr,ax as Sr,ay as Cr,az as Mr,aA as Er,d as je,aB as ss,aC as Ar,aD as Rr,aE as Ir,aF as Tr,E as xe,aG as as,aH as Lr,aI as Or,aJ as $r,aK as Dr,aL as si,aM as zr,aN as Tt,aO as bn,aP as An,aQ as Rn,aR as Fr,aS as Qs,aT as Pr,aU as Ur,aV as Zs,aW as Kr,L as ks,aX as Br,w as Ot,aY as qr,o as ai,ah as is,q as ii,K as Hr,aZ as Ut,J as $e,r as Vr,a_ as Lt,a$ as Gr,b0 as Js,b1 as Xs,b2 as Wr,b3 as ri,a4 as Yr,a5 as Qr}from"./appearance-ttjiyqhP.js";import{o as Zr}from"./console-mirror-Cemag-IJ.js";import{e_ as rs,e$ as Jr,f0 as ea,f1 as st,cD as Xr,b6 as oi,b7 as js,aH as ci,bx as eo,aA as ws,f2 as to,f3 as no,f4 as so,f5 as ao,f6 as li,f7 as Ns,b4 as di,f8 as io,f9 as ro,fa as cn,fb as ui,fc as oo,bz as os,fd as ta,fe as co,ff as ht,fg as ut,c5 as Ss,fh as Cs,cS as ln,cg as lo,fi as mi,fj as Ms,fk as vn,fl as uo,fm as mo,fn as go,fo as In,fp as Es,fq as po,fr as fo,aW as gi,bB as cs,bC as ls,a2 as As,aB as ds,fs as ho,ft as xo,fu as us,fv as _o,fw as yo,fx as bo,fy as pi,fz as vo,fA as ko,fB as jo,fC as wo,fD as fi,fE as No,fF as So,fG as Co,fH as Mo,fI as Ct,fJ as Yt,e9 as Eo,fK as ms,fL as Ao,e8 as Ro,fM as Io,fN as To,fO as Lo,fP as Oo,fQ as $o,fR as na,ca as Rs,fS as ot,fT as Mt,fU as Do,fV as zo,fW as sa,fX as Fo,fY as Po,fZ as Uo,f_ as Ko,f$ as Bo,g0 as qo,dv as xt,ev as Ho,dj as hi,dw as Vo,b as aa,dk as Go,dl as Is,a1 as xi,bw as Wo,g1 as _i,bA as yi,g2 as bi,g3 as Yo,g4 as Qo,g5 as Zo,g6 as Jo,g7 as Xo,g8 as ec,dS as tc,b3 as nc,g9 as sc,ga as ac,cc as ic,gb as Et,gc as ia,gd as rc,ge as oc,gf as cc,gg as lc,gh as dc,r as uc,gi as Tn,gj as Qt,gk as mc,gl as gc,gm as pc,gn as fc,go as hc,gp as xc,gq as Ln,gr as ra,gs as _c,cy as yc,gt as bc,gu as vc,cF as kc,gv as jc,gw as wc,gx as Nc,ez as On,gy as Sc,gz as Cc}from"./conversation-input-sync-Cx-btqGa.js";import{dg as vi,dh as Mc,di as Ec,dj as ki,dk as Ac,cf as Rc,dl as Ve,N as Ic,S as ji,bE as Vt,bF as Te,dm as Kt,dn as Re,dp as $n,dq as Tc,R as Lc,bj as wi,a as kn,c1 as Oc,bz as $c,c as Dc,dr as zc,ds as Fc,cd as Pc,dt as Uc,du as Zt,dv as Jt,dw as oa,bS as Kc,bD as Bc,bP as qc,dx as Hc,dy as Vc,dz as Gc,dA as Wc,bt as ca,dB as Yc,bA as la,bZ as Qc,bB as Zc,bC as Jc,dC as Xc,dD as el,bs as tl,dE as nl}from"./index-C0EaWX4c.js";import{P as sl}from"./page-header-Mac4Nfpt.js";import{c as X,u as te,B as F,S as Ce,_ as Ni,w as Ze,N as Bt,O as qt,P as dt,A as ge,q as jn,x as Be,f as Pe,R as Ts,U as Ls,V as Os,W as $s,Y as _t,L as qe,K as Le,a6 as wn,$ as Si,i as vt,h as gs,af as Ci,a as Cn,Z as al,aa as Mi,a7 as il,a8 as rl,a9 as ol,ar as ps,r as Ei,G as Ai,at as cl,au as da,T as Ds,D as zs,b as Fs,d as Ps,I as ll,e as at,av as Ri,aw as dl,X as ua,al as Nn,E as Ii,ag as ul,ah as ml,ax as gl,ay as pl,n as dn,o as un,p as mn,z as gn}from"./error-boundary-yvtBOcL4.js";import{t as n,L as Dn}from"./messages-DDIvESIa.js";import{u as fl,a as hl,D as xl,b as _l,d as yl,S as bl}from"./team-bridge-scope-preference-D1R2VnPr.js";import{R as vl}from"./radient-auth-buttons-DdSU9yCc.js";import{u as kl,A as jl,d as wl}from"./avatar-cropper-C7MYyYo3.js";import{N as Nl}from"./notebook-pen-CpzCS46r.js";import{k as pt,p as Ti}from"./roles-D1pcbxAx.js";import{B as Sl}from"./book-open-ClSEPGsA.js";import{i as Cl,a as ct,b as Ml,p as zn,f as El}from"./parseISO-CxPiCKvF.js";import{t as Al}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 Rl=[["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"}]],Il=X("aperture",Rl);/**
|
|
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 Tl=[["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"}]],Ll=X("atom",Tl);/**
|
|
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 Ol=[["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"}]],$l=X("audio-waveform",Ol);/**
|
|
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 Dl=[["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"}]],zl=X("binary",Dl);/**
|
|
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 Fl=[["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"}]],Pl=X("candy",Fl);/**
|
|
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 Ul=[["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"}]],Kl=X("car-front",Ul);/**
|
|
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 Bl=[["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"}]],ql=X("cassette-tape",Bl);/**
|
|
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 Hl=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Vl=X("chart-line",Hl);/**
|
|
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 Gl=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],Wl=X("circle-plus",Gl);/**
|
|
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 Yl=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Ql=X("circle-stop",Yl);/**
|
|
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 Zl=[["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"}]],Jl=X("circuit-board",Zl);/**
|
|
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 Xl=[["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"}]],ed=X("cloud-lightning",Xl);/**
|
|
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 td=[["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"}]],nd=X("cloud-moon",td);/**
|
|
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 sd=[["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"}]],ad=X("cloud-snow",sd);/**
|
|
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 id=[["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"}]],rd=X("cloud-sun",id);/**
|
|
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 od=[["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"}]],cd=X("coffee",od);/**
|
|
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 ld=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]],Li=X("contrast",ld);/**
|
|
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 dd=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],ud=X("credit-card",dd);/**
|
|
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 md=[["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"}]],gd=X("cup-soda",md);/**
|
|
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 pd=[["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"}]],fd=X("disc-3",pd);/**
|
|
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 hd=[["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"}]],xd=X("droplet",hd);/**
|
|
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 _d=[["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"}]],yd=X("droplets",_d);/**
|
|
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 bd=[["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"}]],vd=X("fish",bd);/**
|
|
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 kd=[["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"}]],jd=X("flame",kd);/**
|
|
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 wd=[["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"}]],Nd=X("flower-2",wd);/**
|
|
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 Sd=[["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"}]],Cd=X("flower",Sd);/**
|
|
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 Md=[["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"}]],Ed=X("ghost",Md);/**
|
|
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 Ad=[["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"}]],Rd=X("github",Ad);/**
|
|
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 Id=[["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"}]],Td=X("guitar",Id);/**
|
|
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 Ld=[["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"}]],Od=X("hexagon",Ld);/**
|
|
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 $d=[["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"}]],Dd=X("ice-cream-bowl",$d);/**
|
|
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 zd=[["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"}]],Fd=X("joystick",zd);/**
|
|
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 Pd=[["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"}]],Ud=X("leaf",Pd);/**
|
|
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 Kd=[["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"}]],Bd=X("lightbulb",Kd);/**
|
|
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 qd=[["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"}]],Hd=X("milk",qd);/**
|
|
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 Vd=[["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"}]],Gd=X("moon-star",Vd);/**
|
|
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 Wd=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],Yd=X("moon",Wd);/**
|
|
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 Qd=[["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"}]],Zd=X("mountain-snow",Qd);/**
|
|
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 Jd=[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]],Xd=X("mountain",Jd);/**
|
|
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 eu=[["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"}]],tu=X("palette",eu);/**
|
|
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 nu=[["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"}]],su=X("radio",nu);/**
|
|
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 au=[["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"}]],iu=X("sailboat",au);/**
|
|
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 ru=[["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"}]],ou=X("shirt",ru);/**
|
|
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 cu=[["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"}]],lu=X("skull",cu);/**
|
|
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 du=[["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"}]],uu=X("snowflake",du);/**
|
|
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 mu=[["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"}]],gu=X("sparkle",mu);/**
|
|
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 pu=[["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"}]],fu=X("sun-dim",pu);/**
|
|
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 hu=[["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"}]],xu=X("sun",hu);/**
|
|
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 _u=[["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"}]],yu=X("sunrise",_u);/**
|
|
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 bu=[["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"}]],vu=X("sunset",bu);/**
|
|
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 ku=[["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"}]],ju=X("tent",ku);/**
|
|
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 wu=[["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"}]],Nu=X("tree-deciduous",wu);/**
|
|
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 Su=[["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"}]],Cu=X("tree-palm",Su);/**
|
|
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 Mu=[["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"}]],Eu=X("tree-pine",Mu);/**
|
|
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 Au=[["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"}]],Ru=X("trees",Au);/**
|
|
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 Iu=[["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"}]],Tu=X("umbrella",Iu);/**
|
|
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 Lu=[["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"}]],Ou=X("waves",Lu);/**
|
|
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 $u=[["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"}]],Du=X("wheat",$u);/**
|
|
292
|
+
* @license lucide-react v0.507.0 - ISC
|
|
293
|
+
*
|
|
294
|
+
* This source code is licensed under the ISC license.
|
|
295
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
296
|
+
*/const zu=[["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"}]],Fu=X("wind",zu),Pu=({appVersion:t=null,slowWaitHintMs:s})=>{te();const a="https://local-operator.com/download",[r,i]=o.useState(!1),c=vi(r,s??Mc),[d,l]=o.useState(!1),[u,m]=o.useState(null),[p,g]=o.useState("info"),[f,h]=o.useState(null),[v,_]=o.useState(null),N=t?.trim()?t.trim():null,C=o.useRef(!1),A=rs(T=>T.openDetail),D=o.useRef(!1),I=o.useRef(0),O=o.useRef(!1),b=o.useCallback((T,j)=>{D.current=!1,m(T),g(j),l(!0)},[]),z=o.useCallback(T=>{D.current=!0,m(T),g("success"),l(!0)},[]),P=o.useCallback(()=>{D.current&&(D.current=!1,l(!1),m(null))},[]),{clearDeferredUpdate:U}=Jr();o.useEffect(()=>{const T=window.api.updater.onUpdateError(y=>{C.current&&y.includes("manually")&&(h({message:n("ui.common.updates.check_for_updates_button.the_server_is_installed_outside_the_app_so_use_the_tool_you_insta"),command:""}),D.current=!1,m(null),g("warning"),l(!0))}),j=window.api.updater.onBackendUpdateDevMode(y=>{C.current&&b(y,"info")}),H=()=>{O.current=!0,P()},$=window.api.updater.onUpdateAvailable(H),q=window.api.updater.onUpdateNpxAvailable(H),W=window.api.updater.onBackendUpdateAvailable(H);return()=>{T(),j(),$(),q(),W()}},[P,b]),o.useEffect(()=>{let T=!1;const j=()=>{window.api.updater.getLastInstallAttempt().then($=>{T||_($)}).catch(()=>{})};j();const H=window.api.updater.onUpdateInstallFailed(()=>j());return()=>{T=!0,H()}},[]);const x=async()=>{const T=++I.current;P(),O.current=!1;try{i(!0),C.current=!0,U(st.UI),U(st.BACKEND);const j=await window.api.updater.checkForAllUpdates({manual:!0});if(T!==I.current)return;j.app==="available"&&A(st.UI),j.server==="available"&&A(st.BACKEND),j?.affirmation&&!O.current?z(j.affirmation):P()}catch(j){if(T!==I.current)return;console.warn(`Update check failed; the app-level alert owns the report: ${Ec(j)}`)}finally{T===I.current&&i(!1),setTimeout(()=>{C.current=!1},2e3)}},S=()=>{D.current=!1,l(!1),m(null)};return e.jsxs(e.Fragment,{children:[v&&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"),v.targetVersion," ",n("ui.common.updates.check_for_updates_button.didn_t_finish"),v.attempts>1?n("ui.common.updates.check_for_updates_button.detail",{attempts:v.attempts,attemptsText:String(v.attempts)}):"",".",N?n("ui.common.updates.check_for_updates_button.version",{liveversion:String(N)}):null]}),e.jsxs("p",{className:"mt-1 text-meta text-ink-dim",children:[n("ui.common.updates.check_for_updates_button.detected")," ",v.detectedAt?new Date(v.detectedAt).toLocaleString():n("ui.common.updates.check_for_updates_button.at_an_unknown_time"),". ",v.detail]}),e.jsx(F,{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(F,{variant:"outline",onClick:()=>void x(),disabled:r,children:[r?e.jsx(Ce,{size:"sm"}):null,r?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")}),f&&e.jsxs(ea,{open:d,autoHideDuration:1e4,onClose:S,variant:"warning",children:[e.jsx("p",{className:"text-body-sm",children:f.message}),f.command&&e.jsx("code",{className:"mt-2 block rounded-sm bg-sunken p-2 text-mono-sm text-ink",children:f.command})]}),u&&p!=="danger"&&e.jsx(ea,{open:d,autoHideDuration:6e3,onClose:S,variant:p,children:u})]})},pn=["system-prompt"],Uu=()=>{const{shouldEnableQuery:t}=Xr();return De({enabled:t({bypassInternetCheck:!0}),queryKey:pn,queryFn:async()=>{try{const a=await oi(js.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 ci(a),s}},refetchOnWindowFocus:!1,staleTime:5e3})},Ku=()=>{const t=kt(),s=oi(js.baseUrl);return eo({mutationFn:async a=>{try{const r=await s.config.updateSystemPrompt(a);if(r.status>=400)throw new Error(r.message||n("ui.common.errors.system_prompt_update"));return r.result}catch(r){const i=r instanceof Error?r.message:n("ui.common.errors.system_prompt_update_unknown");throw ci(i),r}},onSuccess:async a=>{await t.invalidateQueries({queryKey:pn,refetchType:"none"}),t.setQueryData(pn,r=>r&&{...r,...a}),await t.refetchQueries({queryKey:pn,type:"all"}),ws(n("ui.notices.settings.system_prompt_updated"))},onError:a=>{console.error("Error updating system prompt:",a)}})},$t=({searchRow:t,searchTerms:s,value:a,label:r,description:i,onChange:c,icon:d,isSaving:l=!1,disabled:u=!1,savingInPlace:m=!1})=>{te();const[p,g]=o.useState(a),f=o.useRef(0),[h,v]=o.useState(0);o.useEffect(()=>{m&&f.current>0||g(a)},[a,m,h]);const _=o.useId(),N=`${_}-label`,C=`${_}-description`,A=async D=>{if(!(l&&!m||u)){if(g(D),m){f.current+=1;try{await c(D)}catch(I){console.error("Error toggling setting:",I)}finally{f.current-=1,f.current===0&&v(I=>I+1)}return}try{await c(D)}catch(I){g(!D),console.error("Error toggling setting:",I)}}};return e.jsxs("div",{"data-search-row":t,"data-search-terms":t?s:void 0,"data-search-control":t?"":void 0,className:"flex items-start justify-between gap-4","aria-busy":m&&l?!0:void 0,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("span",{id:N,"data-search-label":"",className:"flex min-h-6 items-center gap-2 text-body text-ink",children:[d&&e.jsx(d,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),r]}),i&&e.jsx("p",{id:C,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:i})]}),e.jsxs("div",{className:"flex h-6 shrink-0 items-center gap-2",children:[m&&l&&e.jsx(Ce,{size:"xs",label:n("ui.common.forms.toggle_setting.saving",{label:r})}),l&&!m?e.jsx(Ce,{size:"md",label:n("ui.common.forms.toggle_setting.saving",{label:r})}):e.jsx(Ni,{checked:p,onCheckedChange:A,disabled:u,"aria-labelledby":N,"aria-describedby":i?C:void 0})]})]})};function ma(t,s){const a=Al(t,s?.in);if(!Cl(a))throw new RangeError("Invalid time value");const r=ct(a.getDate(),2),i=ct(a.getMonth()+1,2),c=a.getFullYear(),d=ct(a.getHours(),2),l=ct(a.getMinutes(),2),u=ct(a.getSeconds(),2);let m="",p="";const g=a.getTimezoneOffset();if(g!==0){const f=Math.abs(g),h=ct(Math.trunc(f/60),2),v=ct(f%60,2);p=`${g<0?"+":"-"}${h}:${v}`}else p="Z";return`${c}-${i}-${r}T${d}:${l}:${u}${m}${p}`}function Bu(t,s,a){return Ml(t,-30,a)}var qu=to({chartName:"LineChart",GraphicalChild:li,axisComponents:[{axisType:"xAxis",AxisComp:no},{axisType:"yAxis",AxisComp:so}],formatAxisMap:ao});const Hu=["radient","creditBalance"],Vu=t=>{const{user:s,isAuthenticated:a}=Ns(),r=s?.account?.tenant_id,i=a&&!!r&&t?.enabled;return De({queryKey:[Hu,r],queryFn:async()=>{if(!r)throw new Error(n("ui.common.errors.tenant_missing"));const c=await di({operation:"credits",tenantId:r});if(!c||typeof c.balance!="number")throw new Error(n("ui.common.errors.credit_balance_invalid"));return c},enabled:i,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},Gu=["radient","usageRollup"],Wu=(t,s)=>{const{user:a,isAuthenticated:r}=Ns(),i=a?.account?.tenant_id,c=r&&!!i&&s?.enabled;return De({queryKey:[...Gu,i,t],queryFn:async()=>{if(!i)throw new Error(n("ui.common.errors.tenant_missing"));const d={};for(const[u,m]of Object.entries(t))m!=null&&(d[u]=String(m));const l=await di({operation:"usage",tenantId:i,query:d});if(!l)throw new Error(n("ui.common.errors.usage_rollup_invalid"));return l},enabled:c,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},Yu=t=>t==="sidebars"?n("ui.settings.appearance.window_glass.coverage_sidebars"):n("ui.settings.appearance.window_glass.coverage_full"),Qu=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")}},Zu=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")}},ga=({label:t,description:s,value:a,onValueChange:r,options:i})=>{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(Bt,{value:a,onValueChange:r,children:e.jsx(qt,{"aria-labelledby":c,children:i.map(d=>e.jsx(dt,{value:d.value,children:d.label},d.value))})})})]})},Ju=({state:t,onChange:s,searchRow:a})=>{te();const r=o.useId(),i=`${r}-description`,[c,d]=o.useState(null),l=o.useRef(!1),u=o.useRef(null),m=t?.settings.intensity??0;if(!t)return null;const p=!t.capability.supported,g=p?Zu(t.capability.reason):null,f=async _=>{if(l.current){u.current=_;return}l.current=!0;try{await s({intensity:_})}finally{l.current=!1;const N=u.current;u.current=null,N!==null&&N!==_?f(N):d(null)}},h=t.settings.enabled,v=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(Ze,{content:g,disabled:!p,children:e.jsx("div",{className:p?"opacity-60":void 0,children:e.jsx($t,{value:p?!1:h,disabled:p,label:n("ui.settings.appearance.window_glass.label"),description:n("ui.settings.appearance.window_glass.description"),onChange:async _=>s({enabled:_})},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")}),h&&!p&&e.jsxs(e.Fragment,{children:[e.jsx(ga,{label:n("ui.settings.appearance.window_glass.coverage_label"),description:n("ui.settings.appearance.window_glass.coverage_description"),value:t.settings.coverage,onValueChange:_=>void s({coverage:_}),options:io.map(_=>({value:_,label:Yu(_)}))}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex min-h-6 items-center justify-between gap-3",children:[e.jsx("label",{htmlFor:r,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(v)})})]}),e.jsx("p",{id:i,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n("ui.settings.appearance.window_glass.intensity_description")}),e.jsx("input",{id:r,type:"range",min:0,max:100,step:5,value:v,"aria-describedby":i,"aria-valuetext":n("ui.settings.appearance.window_glass.intensity_value",{value:String(v)}),onChange:_=>{const N=Number(_.target.value);d(N),f(N)},style:{"--fill":`${v}%`},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(ga,{label:n("ui.settings.appearance.window_glass.material_label"),description:n("ui.settings.appearance.window_glass.material_description"),value:t.settings.material,onValueChange:_=>void s({material:_}),options:t.capability.materials.map(_=>({value:_,label:Qu(_)}))})]})]})},Xu=new Set(["B","C","D","E","F"]);function em(t){const{status:s,refused:a,everVisible:r,checking:i=!1}=t;return s?s.update_required||s.state==="signed_out"?"absent":s.state==="unavailable"?s.error?.code==="messaging_unavailable"?"dark":r?"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&&Xu.has(s.surface_state)?"visible":"absent":i&&r?"visible":a&&r?"error":"absent"}function tm(t,s){return t!=="absent"}function At(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 nm="open_chief_of_staff";function sm(t){const s=t?.delivery_hold;if(!s||s.code!==nm||s.count<=0)return null;const a=s.session||t?.local.session||null;return{count:s.count,sessionId:a}}function Oi(t){return vr(t)}function am(t){return t.target.endpoint_id?{kind:"endpoint",id:t.target.endpoint_id}:{kind:"account",id:t.target.account_id??""}}function fs(t){return t.map((s,a)=>{const r=am(s);return{key:`${s.direction}:${s.effect}:${r.kind}:${r.id}:${a}`,direction:s.direction,effect:s.effect,kind:r.kind,id:r.id}})}function hs(t,s){return t.filter(r=>r.effect==="deny"||s[r.direction]==="listed_only").map(r=>({direction:r.direction,effect:r.effect,target:r.kind==="endpoint"?{endpoint_id:r.id}:{account_id:r.id}})).sort((r,i)=>r.direction.localeCompare(i.direction)||r.effect.localeCompare(i.effect)||JSON.stringify(r.target).localeCompare(JSON.stringify(i.target)))}function $i(t){return JSON.stringify(t)}function im(t){return t.saving?{disabled:!0,reason:"saving"}:["send","receive"].some(r=>t.modes[r]==="listed_only"&&!t.entries.some(i=>i.direction===r&&i.effect==="allow"))?{disabled:!0,reason:"needs_entry"}:$i(hs(t.entries,t.modes))===t.savedSignature?{disabled:!0,reason:"unchanged"}:{disabled:!1}}const rm=/^[^\s\p{Cc}]{1,128}$/u;function om(t){return t===""?n("ui.agentMessages.settings.allowlist.identifier_empty"):t.length>128?n("ui.agentMessages.settings.allowlist.identifier_long"):rm.test(t)?null:n("ui.agentMessages.settings.allowlist.identifier_invalid")}function fn(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 cm=['[data-agent-messages-action="turn_on_again"]','[role="switch"]','[data-agent-messages-action="enable"]'],Fn="__none__";function lm({availability:t,status:s,accountId:a,refusal:r=null,api:i=Rc,onRefreshStatus:c,sessions:d=[],onOpenSession:l,focus:u=!1,focusNonce:m}){te();const[p,g]=o.useState({kind:"loading"}),[f,h]=o.useState(0),[v,_]=o.useState(null),[N,C]=o.useState(null),[A,D]=o.useState(s?.local.enabled??!1),[I,O]=o.useState(s?.local.session??""),b=s?.tenant_id??void 0,z=t==="visible",P=s?.account_id??null,U=P!==null&&P===a;o.useEffect(()=>{if(!z)return;let y=!1;return g({kind:"loading"}),C(null),(async()=>{try{const L=await i.settings(b);if(y)return;if(!L){g({kind:"error",refusal:{code:"invalid_response",message:n("ui.agentMessages.settings.error.unreadable")}});return}let M=null;if(L.endpoint){if(M=await i.allowlist(L.settings.tenant_id),y)return;if(!M){g({kind:"error",refusal:{code:"invalid_response",message:n("ui.agentMessages.settings.error.unreadable")}});return}}g({kind:"ready",settings:L,allowlist:M})}catch(L){if(y)return;g({kind:"error",refusal:Ve(L)})}})(),()=>{y=!0}},[z,a,P,b,f,i]),o.useEffect(()=>{if(!z||p.kind!=="ready"||!p.settings.endpoint||p.allowlist)return;let y=!1;return(async()=>{try{const L=await i.allowlist(p.settings.settings.tenant_id);if(y||!L)return;g(M=>M.kind==="ready"&&!M.allowlist?{...M,allowlist:L}:M)}catch(L){y||C(Ve(L))}})(),()=>{y=!0}},[z,p,i]),o.useEffect(()=>{s&&(D(s.local.enabled),O(s.local.session))},[s]);const x=()=>h(y=>y+1),S=p.kind==="ready"?p.settings:null,T=fl(s,S,P),j=hl({api:i,accountId:U?P:null,tenantId:S?.settings.tenant_id??null,markerTenantId:s?.tenant_id??null,onSettings:y=>g(L=>L.kind==="ready"?{...L,settings:y}:L),onChanged:()=>c(!0)}),H=o.useRef(null),$=o.useRef(!1),q=o.useRef(m);if(o.useEffect(()=>{m!==q.current&&(q.current=m,$.current=!1)},[m]),o.useEffect(()=>{if(!u){$.current=!1;return}if($.current||p.kind!=="ready"||v!==null)return;const y=H.current,L=cm.map(M=>y?.querySelector(`${M}:not(:disabled)`)).find(M=>M!=null);L&&(L.focus(),$.current=!0)},[u,m,p,v,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(ge,{variant:"warning",children:[e.jsx(jn,{children:n("ui.agentMessages.settings.error.title")}),e.jsxs(Be,{children:[r?fn(r):n("ui.agentMessages.settings.refusal.generic"),e.jsx(F,{className:"mt-3",variant:"secondary",onClick:()=>{x(),c(!0)},children:n("ui.agentMessages.settings.error.retry")})]})]})});if(!s||!a)return null;const W=sm(s);return e.jsxs("div",{ref:H,"data-agent-messages-section":"",className:"flex flex-col gap-6",children:[W&&e.jsx(um,{count:W.count,onMessage:W.sessionId&&l?()=>l(W.sessionId):void 0}),T&&e.jsx(xl,{consentText:kr(s,S),pending:j.pending,failure:j.failure,onTurnOff:()=>void j.turnOff(),onDismiss:()=>void j.dismiss()}),N&&e.jsx(ge,{variant:"warning",children:e.jsx(Be,{children:fn(N)})}),p.kind==="loading"&&e.jsx(dm,{}),p.kind==="error"&&e.jsxs(ge,{variant:"warning",children:[e.jsx(jn,{children:n("ui.agentMessages.settings.error.title")}),e.jsxs(Be,{children:[p.refusal.code!=="client_unavailable"&&e.jsx("span",{className:"block",children:fn(p.refusal)}),e.jsx("span",{className:"block",children:n("ui.agentMessages.settings.error.no_changes")}),e.jsx(F,{className:"mt-3",variant:"secondary",onClick:x,children:n("ui.agentMessages.settings.error.retry")})]})]}),p.kind==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx(pm,{state:At(s,p.settings),status:s,settings:p.settings,accountId:P??a,accountMatches:U,api:i,pending:v,localEnabled:A,onActionRefusal:C,onSettings:y=>g(L=>L.kind==="ready"?{...L,settings:y}:L),onLocalEnabled:D,onRefreshStatus:c,setPending:_}),e.jsx(hm,{value:I,sessions:d,pending:v==="session",disabled:v!==null,onSave:async y=>{_("session"),C(null);try{await i.localSetting("team_bridge.session",y),O(y),await c(!0)}catch(L){C(Ve(L))}finally{_(null)}}}),p.allowlist&&(At(s,p.settings)==="C"||At(s,p.settings)==="D"||At(s,p.settings)==="F")&&e.jsx(xm,{allowlist:p.allowlist,accountId:P??a,accountMatches:U,readOnly:s.read_only===!0&&At(s,p.settings)==="F",pending:v!==null,onSaving:y=>_(y?"allowlist":null),onRefusal:C,onSaved:y=>g(L=>L.kind==="ready"?{...L,allowlist:y}:L),api:i},p.allowlist.view.tenant_id??"tenant")]})]})}function dm(){return e.jsxs("div",{className:"flex flex-col gap-3","aria-busy":"true",children:[e.jsx(Pe,{className:"h-5 w-40"}),e.jsx(Pe,{className:"h-4 w-full max-w-xl"}),e.jsx(Pe,{className:"h-9 w-36"}),e.jsx(Pe,{className:"h-4 w-64"})]})}const um=({count:t,onMessage:s})=>e.jsx("output",{className:"block","data-agent-messages-hold":"open_chief_of_staff",children:e.jsx(ge,{variant:"info",className:pe(Ic,"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(F,{variant:"ghost",size:"sm",className:"shrink-0 text-ink",onClick:s,children:n("ui.agentMessages.settings.hold.open")})]})})}),pa=({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})}),Di={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"},zi={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 mm(t){return t==="B"?"ui.agentMessages.settings.default_on.b_title":Di[t]}function gm(t){return t==="B"?"ui.agentMessages.settings.default_on.b_body":t==="E"?"ui.agentMessages.settings.default_on.e_body":zi[t]}const pm=({state:t,status:s,settings:a,accountId:r,accountMatches:i,api:c,pending:d,localEnabled:l,onActionRefusal:u,onSettings:m,onLocalEnabled:p,onRefreshStatus:g,setPending:f})=>{const h=Oi(s),v=a.settings.tenant_id,_=d!==null||!i,N=jr(s);async function C(b,z={}){if(!i)return null;f(b),u(null);try{const P=await c.updateSettings({expected_account_id:r,tenant_id:v,state:b,...z});if(m(P),b==="disabled"&&!N)try{await c.localSetting("team_bridge.enabled",!1),p(!1)}catch(U){u(Ve(U))}return P}catch(P){const U=Ve(P);return u(U),U.code==="consent_version_unknown"&&await g(!0),null}finally{f(null)}}async function A(){if(!(!h||!i||!await C("active",{consent_version:h.version,consented_via:"settings"}))){f("local");try{await c.localSetting("team_bridge.enabled",!0),p(!0),await g(!0)}catch(z){u(Ve(z))}finally{f(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(Pn,{settings:a,status:s,readOnly:!0}),e.jsx(Un,{searchRow:"agent-messages.enabled",searchTerms:"team bridge team_bridge enabled devices",value:l,disabled:_,description:n("ui.agentMessages.settings.local.stays_enrolled"),onChange:async b=>{f("local"),u(null);try{await c.localSetting("team_bridge.enabled",b),p(b),await g(!0)}catch(z){u(Ve(z))}finally{f(null)}}})]});const D=a.endpoint?.label?.trim(),I=a.endpoint?.consent??null,O=I!==null&&!I.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(N?mm(t):Di[t])}),D&&e.jsx("span",{className:"text-body-sm text-ink-muted",children:D})]}),e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted",children:n(N?gm(t):zi[t])}),N&&t==="E"&&e.jsxs("div",{className:"flex flex-col gap-3",children:[h?e.jsx(pa,{text:h.text}):e.jsx(ge,{variant:"warning",children:e.jsx(Be,{children:n("ui.agentMessages.settings.consent.unavailable")})}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx(F,{"data-agent-messages-action":"turn_on_again","data-search-row":"agent-messages.enabled","data-search-control":!0,onClick:()=>void A(),disabled:_||!h,children:n("ui.agentMessages.settings.action.turn_on_again")})})]}),!N&&(t==="B"||t==="E")&&e.jsxs("div",{className:"flex flex-col gap-3",children:[h?e.jsx(pa,{text:h.text}):e.jsx(ge,{variant:"warning",children:e.jsx(Be,{children:n("ui.agentMessages.settings.consent.unavailable")})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(F,{"data-agent-messages-action":"enable","data-search-row":"agent-messages.enabled","data-search-control":!0,onClick:()=>void A(),disabled:_||!h,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(F,{"data-agent-messages-action":"pause",variant:"secondary",disabled:_,onClick:()=>void C("paused"),children:n("ui.agentMessages.settings.action.pause")}),e.jsx(F,{"data-agent-messages-action":"turn_off",variant:"secondary",disabled:_,onClick:()=>void C("disabled"),children:n("ui.agentMessages.settings.action.turn_off")})]}),e.jsx(Pn,{settings:a,status:s}),O&&!N&&e.jsx(fa,{onRenew:()=>void A(),disabled:_||!h}),e.jsx(Un,{searchRow:"agent-messages.enabled",searchTerms:"team bridge team_bridge enabled devices",value:l,disabled:_,description:n("ui.agentMessages.settings.local.stays_enrolled"),onChange:async b=>{f("local"),u(null);try{await c.localSetting("team_bridge.enabled",b),p(b),await g(!0)}catch(z){u(Ve(z))}finally{f(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(F,{"data-agent-messages-action":"resume",disabled:_||a.settings.consent_required&&h===null,onClick:()=>void C("active",a.settings.consent_required&&h?{consent_version:h.version,consented_via:"settings"}:{}),children:n("ui.agentMessages.settings.action.resume")}),e.jsx(F,{"data-agent-messages-action":"turn_off",variant:"secondary",disabled:_,onClick:()=>void C("disabled"),children:n("ui.agentMessages.settings.action.turn_off")})]}),a.settings.consent_required&&!h&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.consent.unavailable")}),e.jsx(Pn,{settings:a,status:s}),O&&!N&&e.jsx(fa,{onRenew:()=>void A(),disabled:_||!h}),e.jsx(Un,{searchRow:"agent-messages.enabled",searchTerms:"team bridge team_bridge enabled devices",value:l,disabled:_,description:n("ui.agentMessages.settings.local.stays_enrolled"),onChange:async b=>{f("local"),u(null);try{await c.localSetting("team_bridge.enabled",b),p(b),await g(!0)}catch(z){u(Ve(z))}finally{f(null)}}})]})]})},fa=({onRenew:t,disabled:s})=>e.jsx(ge,{variant:"warning",children:e.jsxs(Be,{children:[n("ui.agentMessages.settings.consent.renew"),e.jsx(F,{"data-agent-messages-action":"enable",className:"mt-3",variant:"secondary",disabled:s,onClick:t,children:n("ui.agentMessages.settings.action.enable_again")})]})});function fm(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 Pn=({settings:t,status:s,readOnly:a=!1})=>{const r=t.endpoint?.consent??null,i=Oi(s);return r?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs(Vt,{children:[e.jsx(Te,{label:n("ui.agentMessages.settings.consent.version"),value:r.version}),e.jsx(Te,{label:n("ui.agentMessages.settings.consent.via"),value:fm(r.consented_via)}),e.jsx(Te,{label:n("ui.agentMessages.settings.consent.at"),value:r.consented_at})]}),!a&&i&&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:i.text})]})]}):e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.consent.no_record")})},Un=({value:t,disabled:s,description:a,onChange:r,searchRow:i,searchTerms:c})=>{const d=o.useId();return e.jsxs("div",{"data-search-row":i,"data-search-control":i?"":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:d,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(Ni,{"aria-labelledby":d,checked:t,disabled:s,onCheckedChange:l=>void r(l)})]})},hm=({value:t,sessions:s,pending:a,disabled:r,onSave:i})=>{const c=s.some(d=>d.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(Ts,{value:t===""?Fn:t,disabled:r,onValueChange:d=>void i(d===Fn?"":d),children:[e.jsx(Ls,{className:"w-full max-w-md","aria-label":n("ui.agentMessages.settings.session.title"),children:e.jsx(Os,{})}),e.jsxs($s,{children:[e.jsx(_t,{value:Fn,children:n("ui.agentMessages.settings.session.none")}),s.map(d=>e.jsx(_t,{value:d.session_id,children:d.title?.trim()||d.session_id},d.session_id)),t!==""&&!c&&e.jsx(_t,{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")})]})},xm=({allowlist:t,accountId:s,accountMatches:a,readOnly:r,pending:i,api:c,onSaving:d,onRefusal:l,onSaved:u})=>{const[m,p]=o.useState(()=>fs(t.allowlist.entries)),[g,f]=o.useState(()=>({send:t.view.directions.send.mode,receive:t.view.directions.receive.mode})),h=i||r||!a,v=$i(hs(_m(t),ym(t))),_=im({entries:m,modes:g,savedSignature:v,saving:i}),N=o.useRef(0),C=I=>p(O=>[...O,{...I,key:`${I.direction}:${I.effect}:${N.current++}`}]),A=I=>p(O=>O.filter(b=>b.key!==I)),D=async()=>{if(!h){d(!0),l(null);try{const I=await c.updateAllowlist({expected_account_id:s,tenant_id:t.allowlist.tenant_id,entries:hs(m,g)}),O=fs(I.allowlist.entries);p(O),f({send:I.view.directions.send.mode,receive:I.view.directions.receive.mode}),u(I)}catch(I){l(Ve(I))}finally{d(!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(ha,{direction:"receive",title:n("ui.agentMessages.settings.allowlist.receive"),mode:g.receive,cues:t.view.cues,entries:m.filter(I=>I.direction==="receive"),disabled:h,onMode:I=>f(O=>({...O,receive:I})),onAdd:I=>C({...I,direction:"receive"}),onRemove:A}),e.jsx(ha,{direction:"send",title:n("ui.agentMessages.settings.allowlist.send"),mode:g.send,cues:t.view.cues,entries:m.filter(I=>I.direction==="send"),disabled:h,onMode:I=>f(O=>({...O,send:I})),onAdd:I=>C({...I,direction:"send"}),onRemove:A}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(F,{onClick:()=>void D(),disabled:_.disabled||h,children:[e.jsx(ji,{size:14}),n("ui.agentMessages.settings.allowlist.save")]}),_.disabled&&_.reason==="needs_entry"&&e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.agentMessages.settings.allowlist.needs_entry")}),_.disabled&&_.reason==="unchanged"&&e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.agentMessages.settings.allowlist.unchanged")}),r&&e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.agentMessages.settings.allowlist.read_only")}),i&&e.jsx("span",{className:"text-meta text-ink-dim","aria-live":"polite",children:n("ui.agentMessages.settings.saving")})]})]})};function _m(t){return fs(t.allowlist.entries)}function ym(t){return{send:t.view.directions.send.mode,receive:t.view.directions.receive.mode}}const ha=({direction:t,title:s,mode:a,cues:r,entries:i,disabled:c,onMode:d,onAdd:l,onRemove:u})=>{const m=i.filter(g=>g.effect==="allow"),p=i.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(bm,{mode:a,disabled:c,onMode:d}),e.jsxs("div",{className:"flex flex-col gap-1 text-meta text-ink-dim",children:[r.allow_entry_switches_direction_to_listed_only&&e.jsx("p",{children:n("ui.agentMessages.settings.allowlist.cue_listed_only")}),r.removing_allow_does_not_stop_open_thread&&e.jsx("p",{children:n("ui.agentMessages.settings.allowlist.cue_remove")}),r.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(xa,{entry:g,disabled:c,onRemove:()=>u(g.key)},g.key)),e.jsx(_a,{label:n("ui.agentMessages.settings.allowlist.add_allowed"),disabled:c,onAdd:g=>l({...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(xa,{entry:g,disabled:c,onRemove:()=>u(g.key)},g.key)),e.jsx(_a,{label:n("ui.agentMessages.settings.allowlist.add_blocked"),disabled:c,onAdd:g=>l({...g,effect:"deny"})})]})]})},bm=({mode:t,disabled:s,onMode:a})=>{const r=[{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:r.map(i=>e.jsx(F,{variant:"ghost",size:"sm","aria-pressed":t===i.value,disabled:s,onClick:()=>a(i.value),className:pe(t===i.value&&"bg-surface text-ink hover:bg-surface"),children:i.label},i.value))})]})},xa=({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(F,{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")})]}),_a=({label:t,disabled:s,onAdd:a})=>{const[r,i]=o.useState("endpoint"),[c,d]=o.useState(""),[l,u]=o.useState(null),m=o.useId(),p=`${m}-help`,g=()=>{const f=om(c.trim());u(f),!f&&(a({kind:r,id:c.trim()}),d(""))};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(qe,{htmlFor:m,children:t}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Ts,{value:r,disabled:s,onValueChange:f=>i(f),children:[e.jsx(Ls,{className:"w-32","aria-label":n("ui.agentMessages.settings.allowlist.kind"),children:e.jsx(Os,{})}),e.jsxs($s,{children:[e.jsx(_t,{value:"endpoint",children:n("ui.agentMessages.settings.allowlist.kind_agent")}),e.jsx(_t,{value:"account",children:n("ui.agentMessages.settings.allowlist.kind_person")})]})]}),e.jsx(Le,{id:m,"aria-describedby":p,className:"max-w-xs",value:c,disabled:s,placeholder:n("ui.agentMessages.settings.allowlist.identifier"),onChange:f=>d(f.target.value),onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),g())}}),e.jsx(F,{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:r==="endpoint"?n("ui.agentMessages.settings.allowlist.identifier_help_agent"):n("ui.agentMessages.settings.allowlist.identifier_help_person")}),l&&e.jsx("p",{className:"text-meta text-danger",children:l})]})};function vm(){const{snapshot:t}=ki(),[s,a]=o.useState(!1),r=em({status:t.status,refused:t.refusal!==null,everVisible:s,checking:t.checking});return o.useEffect(()=>{r!=="absent"&&a(!0)},[r]),o.useEffect(()=>{Ac()},[]),r}function Us(t){const s=a=>typeof a=="string"?Kt(a):Kt((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 km(t){const s=new Map;for(const a of t??[])s.set(a.name,{label:a.title||a.name,folded:Kt([a.title,a.name].join(" "))});return s}function jm(t,s={}){if(!t)return[];const{startOrder:a=0,sections:r=[]}=s,i=km(t.sections),c=new Map(r.map(d=>[d.id,d.label]));return t.settings.map((d,l)=>{const u=i.get(d.section),m=cn(d.key,"backend");return{id:`setting:${d.key}`,source:"registry",label:d.label||d.key,description:d.help??"",sectionId:m,sectionLabel:c.get(m)??"",detail:u?.label??d.section,order:a+l,settingKey:d.key,fields:Us({label:d.label,synonym:d.synonyms??[],key:d.key,choice:(d.choices??[]).flatMap(p=>[p.label,p.description??""]),section:u?.folded??d.section,description:d.help})}})}function wm(t,s=0){return t.map((a,r)=>({id:`section:${a.id}`,source:"section",label:a.label,sectionId:a.id,sectionLabel:a.label,order:s+r,fields:Us({label:a.label})}))}function Nm(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 r=t.querySelector("h2, h3, h4, legend");if(r?.textContent?.trim())return r.textContent.trim();const i=t.getAttribute("aria-label");return i?.trim()?i.trim():((t.firstElementChild??t).textContent??"").trim()}function Sm(t){const s=t.replace(/\s+/g," ").trim();if(s.length<=80)return s;const a=s.slice(0,80),r=a.lastIndexOf(" ");return`${(r>40?a.slice(0,r):a).trimEnd()}…`}function Cm(t){return t.closest("[data-search-section]")}function Mm(t,s){const a=(t.textContent??"").trim();if(!s)return a;const r=a.indexOf(s);return r<0?a:`${a.slice(0,r)} ${a.slice(r+s.length)}`.trim()}function Em(t,s=0){return Array.from(t.querySelectorAll("[data-search-row]")).map((r,i)=>{const c=Cm(r),d=c?.getAttribute("data-search-section")??"",u=(c?.getAttribute("data-search-section-label")?.trim()??"")||c?.querySelector("[data-search-section-label], h2")?.textContent?.trim()||"",m=Nm(r),p=r.getAttribute("data-search-terms")??"",g=Mm(r,m);return{id:`page:${r.getAttribute("data-search-row")??i}`,source:"page",label:Sm(m),sectionId:d,sectionLabel:u,order:s+i,fields:Us({label:m,synonym:p,section:[u,d],description:g})}})}function Am(t){const s=jm(t.registry,{startOrder:0,sections:t.sections}).filter(r=>!(r.settingKey&&r.settingKey in ro)),a=[...t.rendered??[]].map((r,i)=>({...r,order:s.length+i}));return[...s,...a,...wm(t.sections??[],s.length+a.length)]}const Rm=12,ya="input, textarea, select, button, [role='switch'], [role='tab'], [role='combobox'], [tabindex]";function Im(t,s){return t.querySelector(`[data-search-row="${CSS.escape(s)}"]`)}function Tm(t){const a=(t.matches("[data-search-control]")?t:null)??t.querySelector("[data-search-control]");return a?a.matches(ya)?a:a.querySelector(ya)??a:t}function Fi(t){return t.isConnected&&t.closest("[hidden]")===null}function Lm(t,s,a={}){const r=a.frames??Rm,i=a.paint??ui;return new Promise(c=>{let d=0;const l=()=>{const u=Im(t,s);if(u&&Fi(u)){const m=Tm(u);m===u&&(u.tabIndex=-1),m.scrollIntoView({block:"center"}),m.focus(),i(u),c("landed");return}if(d+=1,d>=r){c("missing");return}requestAnimationFrame(l)};requestAnimationFrame(l)})}function Om(t,s,a={}){const r=t.querySelector(`[data-search-section="${CSS.escape(s)}"]`);return!r||!Fi(r)?"missing":(r.scrollIntoView({block:"start"}),r.tabIndex<0&&(r.tabIndex=-1),r.focus(),(a.paint??ui)(r),"landed")}const ba={get[st.UI](){return n("ui.settings.updates.update_following.application_updates")},get[st.BACKEND](){return n("ui.settings.updates.update_following.server_updates")}},Xt={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")}}},va=({type:t})=>{te();const s=rs(r=>r.followed[t]),a=rs(r=>r.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:ba[t]}),e.jsx("div",{className:"mt-0.5 text-meta text-ink-muted",children:Xt[s].description})]}),e.jsxs(Ts,{value:s,onValueChange:r=>a(t,r),children:[e.jsx(Ls,{"aria-label":n("ui.settings.updates.update_following.surface_choice",{surface:ba[t],choice:Xt[s].label}),className:"w-full sm:w-56","data-followed-segment":t,children:e.jsx(Os,{})}),e.jsx($s,{children:oo.map(r=>e.jsx(_t,{value:r,title:Xt[r].description,children:Xt[r].label},r))})]})]})},$m=()=>(te(),e.jsxs("div",{className:pe("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(va,{type:st.UI}),e.jsx(va,{type:st.BACKEND})]})]})),Dm=({appVersion:t})=>e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx($m,{}),e.jsx(Pu,{appVersion:t})]}),zm=t=>{if(!t)return null;try{return new URL(t).host}catch{return null}},Fm=()=>{te();const[t,s]=o.useState(null),[a,r]=o.useState({value:"Loading...",detail:null,degraded:!1}),[i,c]=o.useState({platform:"Loading...",arch:"...",nodeVersion:"Loading...",electronVersion:"Loading...",chromeVersion:"Loading..."});o.useEffect(()=>{let l=!0;const u=h=>{if(!l)return;const v=zm(h.url);if(h.state==="connecting"){r({value:"Loading...",detail:null,degraded:!1});return}if(h.state==="detached"){r({value:"Not connected",detail:h.detail||null,degraded:!1});return}if(h.state==="wedged"){r({value:"Not attached",detail:h.detail||null,degraded:!1});return}const _=h.version||"Version unknown";r({value:v?`${_} · ${v}`:_,detail:h.detail||null,degraded:h.state==="degraded"})};let m=!1;const p=window.api?.backend?.onStatusChange(h=>{m=!0,u(h)}),g=async()=>{try{const[h,v]=await Promise.all([window.api.systemInfo.getAppVersion(),window.api.systemInfo.getPlatformInfo()]);l&&(s(h),c(v))}catch(h){console.error("Error fetching app information:",h)}},f=async()=>{try{const h=window.api?.backend;if(h){const N=await h.getStatus();m||u(N);return}const v=await ta.healthCheck(js.baseUrl),_=ta.getServerVersion(v);l&&r({value:_,detail:null,degraded:!1})}catch(h){console.error("Error fetching server version:",h),l&&r({value:"Unavailable",detail:null,degraded:!1})}};return g(),f(),()=>{l=!1,p?.()}},[]);const d=(l,u,m,p={})=>e.jsx(Te,{label:e.jsx(Ze,{content:m,children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(wn,{size:12,className:"shrink-0"}),l]})}),valueClassName:p.valueClassName,value:e.jsxs(e.Fragment,{children:[p.valueTooltip?e.jsx(Ze,{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(Re,{title:n("ui.settings.updates.app_updates_section.application_updates_and_info"),icon:os,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(Vt,{children:[d(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")),d(n("ui.settings.updates.app_updates_section.server_version"),$n(a.value),n("ui.settings.updates.app_updates_section.the_version_of_the_local_operator_api_server_backend_and_the_addr"),{valueTooltip:a.detail,valueHoverTarget:!0,statusNote:a.degraded?n("ui.settings.updates.app_updates_section.not_answering"):void 0,valueClassName:a.degraded?"text-ink-muted":void 0}),d(n("ui.settings.updates.app_updates_section.platform"),`${i.platform} (${i.arch})`,n("ui.settings.updates.app_updates_section.the_operating_system_and_architecture_your_application_is_running")),d(n("ui.settings.updates.app_updates_section.node_js_version"),$n(i.nodeVersion),n("ui.settings.updates.app_updates_section.the_javascript_runtime_environment_version")),d(n("ui.settings.updates.app_updates_section.electron_version"),$n(i.electronVersion),n("ui.settings.updates.app_updates_section.the_framework_version_enabling_this_desktop_application"))]}),e.jsx(Dm,{appVersion:t})]})})};function Pi(t){const s={id:"",name:n("ui.settings.model.default_effort.model_default")};return t.resolvedLevel&&t.stored.trim()===""&&Ks(t.resolvedLevel,t.storable)!==null&&(s.description=n("ui.settings.model.default_effort.model_default_resolves",{level:lt(t.resolvedLevel)})),[s,...Ui(t.ladder,t.storable)]}function Ks(t,s){const a=t.trim().toLowerCase();return a===""?null:s.find(r=>r.trim().toLowerCase()===a)??null}function Ui(t,s){return t.flatMap(a=>{const r=Ks(a,s);return r===null?[]:[{id:r,name:lt(a)}]})}function Pm(t,s){const a=t.trim().toLowerCase();return a!==""&&s.some(r=>r.toLowerCase()===a)?s.find(r=>r.toLowerCase()===a)??"":""}function Um(t){if(!t.resolved||t.ladder===null)return null;const s=t.stored.trim().toLowerCase();if(s===""||t.ladder.some(i=>i.toLowerCase()===s))return null;const a=(t.resolvedLevel??"").trim(),r=a===""?"":Ks(a,t.storable)??"";return r.trim().toLowerCase()===s?null:r}const hn="\0unread";function en(t){return t.trim()===""?"":hn}function Km(t){if(!t.supported)return{kind:"unsupported",options:[],selectedId:"",disabled:!0,helper:""};if(!t.hasHome)return nt("no-home",n("ui.settings.model.default_effort.no_home"));if(!t.hasModel)return nt("no-model",n("ui.settings.model.default_effort.no_model"),hn);if(t.settings==="loading")return nt("settings-loading",n("ui.settings.model.default_effort.settings_loading"),hn);if(t.settings==="error")return nt("settings-error",n("ui.settings.model.default_effort.settings_error"),hn);if(t.preview==="loading")return nt("loading",n("ui.settings.model.default_effort.loading"),en(t.stored));if(t.preview==="error")return nt("error",n("ui.settings.model.default_effort.error"),en(t.stored));if(t.ladder===null||!t.specResolved)return nt("unresolved",n("ui.settings.model.default_effort.unresolved"),en(t.stored));const s=t.ladder;if(s.length===0)return nt("empty",n("ui.settings.model.default_effort.empty"),en(t.stored));const a=Ui(s,t.storable);if(a.length===0){const r=lt(s[0]),i=s.length===1&&s[0].trim().toLowerCase()==="auto";return{kind:"one-level",options:[{id:"",name:r}],selectedId:"",disabled:!0,helper:i?n("ui.settings.model.default_effort.one_level_sentinel"):n("ui.settings.model.default_effort.one_level",{level:r})}}if(s.length===1){const[r]=a;return{kind:"one-level",options:[r],selectedId:r.id,disabled:!0,helper:n("ui.settings.model.default_effort.one_level",{level:r.name})}}return{kind:"ready",options:Pi({ladder:s,resolvedLevel:t.resolvedLevel,stored:t.stored,storable:t.storable}),selectedId:Pm(t.stored,a.map(r=>r.id)),disabled:!1,helper:n("ui.settings.model.default_effort.helper_ready")}}function nt(t,s,a=""){return{kind:t,options:Pi({ladder:[],resolvedLevel:null,stored:"",storable:[]}),selectedId:a,disabled:!0,helper:s}}const Bm=({hosting:t,modelName:s,focus:a=!1,focusNonce:r})=>{te();const i=jt(),c=bt(i.data,"draft_preview"),d=co(),l=t!==""&&s!=="",u=De({queryKey:ut.all,queryFn:()=>je({op:"settings.list"}),enabled:c,staleTime:1e4}),m=u.data?.settings.find(le=>le.key===ht),p=typeof m?.value=="string"?m.value:"",g=(m?.choices??[]).map(le=>le.value).filter(le=>typeof le=="string"),f={cwd:d??"",model:l?{provider:t,model_id:s,reasoning_effort:null}:null},h=u.isSuccess?p:null,v=De({...Nr(f,bt(i.data,"draft_fast")),queryKey:[...wr(f),"model_effort",h],enabled:c&&!!d&&l}),_=v.isSuccess&&!v.isPlaceholderData,N=_?Sr(v.data?.snapshot,null).effort:null,C=_&&Array.isArray(N?.reasoning_efforts)?Cr(N):null,A=_?Mr(N):null,D=N!==null&&!Er(N),[I,O]=o.useState(!1),[b,z]=o.useState(!1),[P,U]=o.useState(null),[x,S]=o.useState(null),T=`${t}\0${s}`,j=kt(),H=o.useRef(null),$=o.useRef(!1),q=o.useRef(r);o.useEffect(()=>{r!==q.current&&(q.current=r,$.current=!1)},[r]);const W=o.useCallback(async(le,ue)=>{O(!0),U(le),z(!1),ue===null&&S(null);try{await je({op:"settings.edit",key:ht,value:le}),await j.invalidateQueries({queryKey:ut.all}),ue!==null&&S(ue)}catch{z(!0)}finally{O(!1),U(null)}},[j]),y=typeof N?.display_name=="string"&&N.display_name.trim()||s,L=Km({supported:c,hasHome:!!d,hasModel:l,settings:u.isError?"error":u.isSuccess?"ready":"loading",preview:v.isError?"error":_?"ready":"loading",ladder:C,specResolved:D,stored:p,resolvedLevel:A,storable:g}),M=Um({stored:p,ladder:C,resolvedLevel:A,resolved:_&&D&&u.isSuccess,storable:g}),V=o.useRef(null);o.useEffect(()=>{if(M===null||I)return;const le=`${t}\0${s}\0${p}\0${M}`;if(V.current===le)return;V.current=le;const ue=M===""?n("ui.settings.model.default_effort.clamped_unset",{level:lt(p),model:y}):n("ui.settings.model.default_effort.clamped",{level:lt(p),model:y,resolved:lt(M)});W(M,{text:ue,model:T})},[M,p,I,W,t,s,y,T]);const ae=o.useMemo(()=>L.options.map(qm),[L.options]);o.useEffect(()=>{if(!a){$.current=!1;return}L.disabled||$.current||(H.current?.querySelector("[role=combobox]")?.focus(),$.current=!0)},[a,r,L.disabled]);const Q=P??L.selectedId,ne=ae.find(le=>le.id===Q)??(P!==null?{id:P,name:lt(P)}:null),ce=e.jsxs("span",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{children:L.helper}),b&&e.jsx("span",{className:"text-danger",children:n("ui.settings.model.default_effort.save_failed")}),e.jsx("output",{"aria-live":"polite",children:x?.model===T?x.text:""})]});return L.kind==="unsupported"?null:e.jsx("div",{ref:H,"data-setting-key":ht,children:e.jsx(Si,{label:n("ui.settings.model.default_effort.label"),icon:e.jsx(Tc,{size:16,"aria-hidden":"true"}),placeholder:n("ui.settings.model.default_effort.placeholder"),options:ae,selected:ne,onSelect:le=>{W(le.id,null)},helperText:ce,busy:I,busyLabel:n("ui.settings.model.default_effort.busy"),disabled:L.disabled||I})})};function qm(t){return{id:t.id,name:t.name,description:t.description}}const Hm=t=>t.replace(/[\p{Co}\p{Cc}]/gu," ").replace(/\s+/g," ").trim(),Ki=(t,s)=>{const a=s.trim().toLocaleLowerCase();return a?t.filter(r=>`${r.title} ${r.cwd} ${r.sourceId}`.toLocaleLowerCase().includes(a)):t},Vm=(t,s)=>`${t??""}\0${[...s].sort().join("\0")}`,Bi=5e3,Gm=(t,s,a,r=Bi)=>{const i=new Set(a);let c=!1;for(const d of Ki(t,s))if(!i.has(d.sourceId)){if(i.size>=r){c=!0;break}i.add(d.sourceId)}return{selected:i,capped:c}},Wm=/cancel/i,Ym=new Set(["done","failed","cancelled"]),ka=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"}},Kn=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"}},Qm=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"}},Zm=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"}},Jm=t=>t==="failed"?"danger":t==="metadata_only"||t==="skipped_already_imported"?"neutral":t==="cancelled"?"warning":"success",xs=t=>Hm(t.title)||t.sourceId,ja=({path:t,label:s,onCopyPath:a})=>{const[r,i]=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(F,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{a(t).then(c=>{c&&(i(!0),window.setTimeout(()=>i(!1),1500))})},children:[r?e.jsx(Cn,{size:14}):e.jsx(mi,{size:14}),r?n("ui.settings.imports.copied"):n("ui.settings.imports.copy_path")]})]})},Xm=({progress:t,sessions:s,selected:a})=>{const r=new Map(t.results.map(l=>[l.sourceId,l])),i=t.sessionId,c=Math.max(0,t.total-t.completed-(i&&!r.has(i)?1:0)),d=s.filter(l=>a.has(l.sourceId));return e.jsxs("div",{className:"flex flex-col gap-2",children:[t.results.map(l=>e.jsx(qi,{row:l,jobCancelled:t.state==="cancelled"},`${l.source}:${l.sourceId}`)),d.filter(l=>!r.has(l.sourceId)&&l.sourceId!==i).map(l=>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:xs(l)}),e.jsx(vt,{variant:"neutral",children:n("ui.settings.imports.session_pending")})]},l.sourceId)),i&&!r.has(i)&&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(ln,{size:14,className:"animate-spin"}),e.jsx("span",{children:n("ui.settings.imports.session_importing")}),e.jsx("span",{className:"min-w-0 truncate",children:i})]}),c>0&&e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.progress_pending",{count:c})}),t.warnings.map(l=>e.jsx("p",{className:"text-meta text-warning",children:l.message},`${l.code}:${l.sessionId}:${l.message}`))]})},qi=({row:t,jobCancelled:s=!1})=>{const r=s&&t.outcome==="failed"&&t.warnings.some(i=>Wm.test(i))?"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(vt,{variant:Jm(r),children:n(Zm(r))}),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(i=>e.jsx("p",{className:"mt-1 text-meta text-warning",children:i},i))]})},eg=({sources:t,activeSource:s,sessions:a,query:r,selected:i,preview:c,previewStale:d,previewError:l,confirmed:u,busy:m,error:p,progress:g,result:f,cancelling:h,onSelectSource:v,onQueryChange:_,onToggleSession:N,onSelectAll:C,onClearSelection:A,onConfirmChange:D,onImport:I,onCancel:O,onRetry:b,onImportAnother:z,onRefresh:P,selectionNotice:U,onCopyPath:x})=>{te();const S=t.find(y=>y.source===s),T=g!==null&&!Ym.has(g.state),j=g?.total??i.size,H=o.useMemo(()=>Ki(a,r),[r,a]),$=H.length>0&&H.every(y=>i.has(y.sourceId)),q=i.size,W=q>0&&c!==null&&!d&&u&&!m&&!g&&!f;return e.jsx(Re,{title:n("ui.settings.imports.title"),icon:os,description:n("ui.settings.imports.description"),dataTourTag:"settings-import-section",children:e.jsxs("div",{className:"flex flex-col gap-5",children:[p&&e.jsxs(ge,{variant:"warning",children:[e.jsx(jn,{children:n("ui.settings.imports.title")}),e.jsx(Be,{children:e.jsxs("span",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("span",{children:p}),e.jsx(F,{variant:"secondary",size:"sm",onClick:b,children:n("ui.settings.imports.retry")})]})})]}),m==="sources"&&t.length===0?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Pe,{className:"h-20 w-full"}),e.jsx(Pe,{className:"h-20 w-full"}),e.jsx(Pe,{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(F,{variant:"ghost",size:"sm",onClick:P,disabled:T||m==="sources"||m==="sessions",children:[e.jsx(Lc,{size:14,className:pe(m==="sources"&&"animate-spin")}),n("ui.settings.imports.refresh")]})]}),!t.some(y=>y.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(y=>{const L=y.source===s,M=y.detected?n(ka(y.availability)):n("ui.settings.imports.source_not_found");return e.jsxs("button",{type:"button","aria-pressed":L,disabled:T,onClick:()=>v(y.source),className:pe("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",L?"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:y.label}),e.jsx(vt,{variant:y.detected&&y.availability==="full"?"success":"neutral",children:M})]}),e.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:n("ui.settings.imports.source_sessions",{count:y.sessionCount})}),e.jsx("p",{className:"mt-1 break-all text-meta text-ink-dim",children:y.detail||y.root})]},y.source)})})]}),S&&!g&&!f&&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")," · ",S.label]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{variant:"secondary",size:"sm",onClick:$?A:C,disabled:H.length===0,children:$?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})})]})]}),U&&e.jsx("output",{className:"text-meta text-warning",children:U}),e.jsxs("div",{className:"relative",children:[e.jsx(Ss,{size:15,className:"pointer-events-none absolute top-1/2 start-3 -translate-y-1/2 text-ink-dim"}),e.jsx(Le,{value:r,onChange:y=>_(y.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(Pe,{className:"h-12 w-full"}),e.jsx(Pe,{className:"h-12 w-full"}),e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.loading_sessions",{source:S.label})})]}):a.length===0?e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_sessions",{source:S.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(y=>{const L=`import-session-${y.source}-${y.sourceId}`;return e.jsxs("div",{className:pe("flex items-start gap-3 rounded-md border p-3",i.has(y.sourceId)?"border-accent bg-row-selected":"border-hairline bg-surface hover:bg-sunken"),children:[e.jsx(gs,{id:L,checked:i.has(y.sourceId),onCheckedChange:()=>N(y.sourceId),"aria-label":xs(y),className:"mt-0.5"}),e.jsxs("label",{htmlFor:L,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:xs(y)}),e.jsx(vt,{variant:y.availability==="full"?"neutral":"warning",children:n(ka(y.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:y.messageCount??0,compactions:y.compactionCount})}),e.jsx("span",{children:n("ui.settings.imports.session_updated",{date:Cs(new Date((y.updatedTs||y.createdTs)*1e3))})})]}),y.cwd&&e.jsx("span",{className:"mt-1 block break-all font-mono text-meta text-ink-dim",children:y.cwd}),y.availability==="metadata_only"&&e.jsx("span",{className:"mt-1 block text-meta text-warning",children:n("ui.settings.imports.metadata_only_explain")}),y.availability==="unsupported"&&e.jsx("span",{className:"mt-1 block text-meta text-warning",children:n("ui.settings.imports.session_index_only")})]})]},y.sourceId)})})]}),S&&q>0&&!g&&!f&&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"||d||c===null&&!l)&&e.jsxs("p",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[e.jsx(ln,{size:14,className:"animate-spin"}),n("ui.settings.imports.loading_preview")]}),c&&!d&&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((y,L)=>e.jsx("p",{className:"text-meta text-warning",children:y.message},`${y.code}:${y.sessionId}:${L}`)),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:[l&&e.jsx(ge,{variant:"warning",children:e.jsx(Be,{children:e.jsxs("span",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("span",{children:l}),e.jsx(F,{variant:"secondary",size:"sm",onClick:b,children:n("ui.settings.imports.retry")})]})})}),e.jsxs("div",{className:"flex items-start gap-2 text-body-sm text-ink",children:[e.jsx(gs,{checked:u,onCheckedChange:y=>D(y===!0),disabled:!c||d,"aria-label":n("ui.settings.imports.confirm_label"),className:"mt-0.5"}),e.jsx("span",{children:n("ui.settings.imports.confirm_label")})]}),e.jsxs(F,{variant:"primary",onClick:I,disabled:!W,className:"self-start",children:[m==="start"?e.jsx(ln,{size:14,className:"animate-spin"}):e.jsx(os,{size:14}),n("ui.settings.imports.import_button",{count:q})]})]})]}),g&&!f&&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(F,{variant:"secondary",size:"sm",onClick:O,disabled:h||g.state==="done"||g.state==="cancelled"||g.state==="failed",children:[e.jsx(lo,{size:12}),h?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(Kn(g.state))})," · ",n(Qm(g.phase))]}),e.jsx(Ci,{value:g.total?g.completed/g.total*100:0,className:"h-1.5"}),e.jsx(Xm,{progress:g,sessions:a,selected:i})]}),f&&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(F,{variant:"secondary",size:"sm",onClick:z,children:n("ui.settings.imports.import_another")})]}),e.jsx("p",{className:"text-body-sm text-ink",children:f.state==="cancelled"?n("ui.settings.imports.result_summary_cancelled",{state:n(Kn(f.state)),sessions:f.sessions.length,total:j,messages:f.messages}):n("ui.settings.imports.result_summary",{state:n(Kn(f.state)),sessions:f.sessions.length,messages:f.messages})}),f.sessions.map(y=>e.jsx(qi,{row:y,jobCancelled:f.state==="cancelled"},`${y.source}:${y.sourceId}:${y.targetSessionId}`)),(f.instructionReviewPath||f.memoryReviewPath)&&e.jsxs("div",{className:"flex flex-col gap-2",children:[f.instructionReviewPath&&e.jsx(ja,{path:f.instructionReviewPath,label:n("ui.settings.imports.review_instructions"),onCopyPath:x}),f.memoryReviewPath&&e.jsx(ja,{path:f.memoryReviewPath,label:n("ui.settings.imports.review_memory"),onCopyPath:x})]}),f.warnings.length>0&&e.jsx(ge,{variant:"warning",children:e.jsx(Be,{children:e.jsxs("span",{className:"flex flex-col gap-1",children:[e.jsx("span",{children:n("ui.settings.imports.warnings_heading",{count:f.warnings.length})}),f.warnings.slice(0,4).map((y,L)=>e.jsx("span",{children:y.message},`${y.code}:${L}`))]})})}),f.error&&e.jsx(ge,{variant:"danger",children:e.jsx(Be,{children:f.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(ln,{size:14,className:"animate-spin"}),n("ui.settings.imports.importing")]})]})})},Bs=t=>({source:t.source,sessionId:t.session_id,code:t.code,message:t.message}),Hi=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}),tg=t=>({jobId:t.job_id,state:t.state,sessions:t.sessions.map(Hi),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(Bs),error:t.error});async function ng(){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 sg(t,s=!1){return(await je({op:"imports.sessions",source:t,includeSubagents:s})).sessions.map(r=>({source:r.source,sourceId:r.source_id,title:r.title??"",cwd:r.cwd??"",createdTs:r.created_ts,updatedTs:r.updated_ts,messageCount:r.message_count,compactionCount:r.compaction_count,kind:r.kind,availability:r.availability,parentSourceId:r.parent_source_id}))}async function ag(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(Bs),instructionReviewPaths:s.instruction_review_paths}}async function ig(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 rg(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(Hi),warnings:s.warnings.map(Bs),error:s.error,startedAt:s.started_at,updatedAt:s.updated_at,result:s.result?tg(s.result):void 0}}async function og(t){await je({op:"imports.cancel",jobId:t})}const tn=new Set(["done","failed","cancelled"]),ft=t=>t instanceof Error?t.message:String(t),cg=()=>{te();const[t,s]=o.useState([]),[a,r]=o.useState(null),[i,c]=o.useState([]),[d,l]=o.useState(""),[u,m]=o.useState(new Set),[p,g]=o.useState(null),[f,h]=o.useState(null),[v,_]=o.useState(!1),[N,C]=o.useState(null),[A,D]=o.useState(null),[I,O]=o.useState(null),[b,z]=o.useState(null),[P,U]=o.useState(!1),[x,S]=o.useState(null),[T,j]=o.useState(0),H=o.useRef(0),$=o.useRef(0),[q,W]=o.useState(null),[y,L]=o.useState(null),M=o.useRef(null),V=I!==null&&!tn.has(I.state),ae=o.useCallback(async()=>{C("sources"),D(null);try{const ie=await ng();s(ie),r(de=>ie.some(oe=>oe.source===de&&oe.detected)?de:ie.find(oe=>oe.detected)?.source??null)}catch(ie){D(n("ui.settings.imports.error_sources",{reason:ft(ie)}))}finally{C(null)}},[]);o.useEffect(()=>{ae()},[ae]);const Q=o.useCallback(async ie=>{const de=++H.current;C("sessions"),D(null);try{const Z=await sg(ie);if(de!==H.current)return;c(Z)}catch(Z){if(de!==H.current)return;c([]),D(n("ui.settings.imports.error_sessions",{source:ie,reason:ft(Z)}))}finally{de===H.current&&C(null)}},[]);o.useEffect(()=>{if(!a){c([]);return}c([]),m(new Set),g(null),h(null),W(null),L(null),_(!1),z(null),O(null),Q(a)},[a,Q]);const ne=o.useCallback(ie=>{m(ie),_(!1),W(null),L(null),S(null)},[]),ce=o.useCallback(ie=>{V||(r(ie),l(""))},[V]),le=o.useCallback(ie=>{const de=new Set(u);de.has(ie)?de.delete(ie):de.add(ie),ne(de)},[ne,u]),ue=o.useCallback(()=>{const ie=Gm(i,d,u);ne(ie.selected),ie.capped&&S(n("ui.settings.imports.selection_limit",{max:Bi}))},[d,ne,u,i]),we=o.useCallback(()=>{ne(new Set)},[ne]),B=o.useMemo(()=>Vm(a,u),[a,u]),K=p!==null&&f!==B,k=o.useCallback(async()=>{if(!a||u.size===0)return;const ie=++$.current,de=B;C("preview"),D(null),L(null);try{const Z=await ag({sources:[a],sessionIds:{[a]:[...u].sort()}});if(ie!==$.current)return;g(Z),h(de)}catch(Z){if(ie!==$.current)return;g(null),h(null),W(de),L(n("ui.settings.imports.error_preview",{reason:ft(Z)}))}finally{ie===$.current&&C(null)}},[a,B,u]);o.useEffect(()=>{if(!a||u.size===0||I||b||p&&f===B||!p&&q===B)return;const ie=setTimeout(()=>{k()},250);return()=>clearTimeout(ie)},[a,u,B,p,f,q,I,b,k]);const Y=o.useCallback(async()=>{if(!(!a||u.size===0||!p||K||!v||I)){C("start"),D(null),z(null);try{const ie=await ig({sources:[a],sessionIds:{[a]:[...u].sort()}}),de=Date.now()/1e3;O({jobId:ie,state:"queued",phase:"queued",source:a,sessionId:"",completed:0,total:u.size,results:[],warnings:[],error:"",startedAt:de,updatedAt:de})}catch(ie){D(n("ui.settings.imports.error_start",{reason:ft(ie)}))}finally{C(null)}}},[a,v,p,K,I,u]),se=I?.jobId??null,ee=I?.state??null;o.useEffect(()=>{if(!se||!ee||tn.has(ee))return;let ie=!0,de;const Z=async()=>{try{const oe=await rg(se);if(!ie)return;if(M.current){const me=M.current;M.current=null,D(Ie=>Ie===me?null:Ie)}O(oe),oe.result&&z({...oe.result,jobId:oe.jobId}),tn.has(oe.state)||(de=setTimeout(Z,900))}catch(oe){if(!ie)return;const me=n("ui.settings.imports.error_job",{reason:ft(oe)});M.current=me,D(me),de=setTimeout(Z,2e3)}};return de=setTimeout(Z,T>0?0:700),()=>{ie=!1,de&&clearTimeout(de)}},[se,ee,T]);const ye=o.useCallback(async()=>{if(!(!I||tn.has(I.state))){U(!0),D(null);try{await og(I.jobId)}catch(ie){D(n("ui.settings.imports.error_cancel",{reason:ft(ie)}))}finally{U(!1)}}},[I]),Se=o.useCallback(()=>{m(new Set),g(null),h(null),W(null),L(null),_(!1),S(null),z(null),O(null),D(null),a&&Q(a)},[a,Q]),he=o.useCallback(async ie=>{try{return await navigator.clipboard.writeText(ie),!0}catch{return!1}},[]),be=o.useCallback(async()=>{V||(S(null),W(null),L(null),await ae(),a&&await Q(a))},[a,V,Q,ae]),ke=o.useCallback(()=>{if(V){D(null),j(ie=>ie+1);return}W(null),L(null),be()},[V,be]);return e.jsx(eg,{sources:t,activeSource:a,sessions:i,query:d,selected:u,preview:p,previewStale:K,previewError:y,confirmed:v,busy:N,error:A,progress:I,result:b,cancelling:P,onSelectSource:ce,onQueryChange:l,onToggleSession:le,onSelectAll:ue,onClearSelection:we,onConfirmChange:_,onImport:()=>void Y(),onCancel:()=>void ye(),onRetry:ke,onImportAnother:Se,onRefresh:be,selectionNotice:x,onCopyPath:he})},Dt="ui.settings.appearance.agent_avatar_size_setting",lg=t=>t==="small"?n(`${Dt}.small`):t==="medium"?n(`${Dt}.medium`):n(`${Dt}.large`),wa={className:"size-4",glyphClassName:"size-2"},dg=({size:t})=>{const s=Rr[t],a=Ir[t],r=Tr[t],i=(c,d)=>e.jsx(al,{className:pe("items-center justify-center text-ink-muted",c),children:e.jsx(wi,{className:d,"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:[i(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:pe("flex",r.className),children:i(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:[i(wa.className,wa.glyphClassName),e.jsx("span",{className:"h-2 w-12 rounded-full bg-sunken"})]})]})},ug=({value:t,onChange:s,searchRow:a})=>{te();const r=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:r,className:"flex min-h-6 items-center text-body text-ink",children:n(`${Dt}.agent_picture_size`)}),e.jsx("p",{className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n(`${Dt}.how_large_the_agent_s_picture_appears_in_the_chat_window_and_the_chat`)}),e.jsx(dg,{size:ss(t)})]}),e.jsx("div",{className:"flex h-6 shrink-0 items-center",children:e.jsx(Bt,{value:t,onValueChange:i=>s(ss(i)),children:e.jsx(qt,{"aria-labelledby":r,children:Ar.map(i=>e.jsx(dt,{value:i,children:lg(i)},i))})})})]})},Vi=()=>{const t=xe(r=>r.themeName),s=xe(r=>r.customThemeId),a=Ms();return o.useMemo(()=>{const r=a.themes.find(c=>c.id===s),i=yt(r?.base??t)?.palette;return{palette:i&&r?vn(i,r):i,name:r?.name??Qe[t].name}},[t,s,a])},Bn=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,r,i]=s,c=Math.cbrt(.4122214708*a+.5363325363*r+.0514459929*i),d=Math.cbrt(.2119034982*a+.6806995451*r+.1073969566*i),l=Math.cbrt(.0883024619*a+.2817188376*r+.6299787005*i),u=.2104542553*c+.793617785*d-.0040720468*l,m=1.9779984951*c-2.428592205*d+.4505937099*l,p=.0259040371*c+.7827717662*d-.808675766*l;return{l:u,c:Math.hypot(m,p),h:(Math.atan2(p,m)*180/Math.PI+360)%360}},qn=({l:t,c:s,h:a})=>{const r=s*Math.cos(a*Math.PI/180),i=s*Math.sin(a*Math.PI/180),c=(t+.3963377774*r+.2158037573*i)**3,d=(t-.1055613458*r-.0638541728*i)**3,l=(t-.0894841775*r-1.291485548*i)**3;return[4.0767416621*c-3.3077115913*d+.2309699292*l,-1.2684380046*c+2.6097574011*d-.3413193965*l,-.0041960863*c-.7034186147*d+1.707614701*l]},Na=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(d=>d>=-1e-7&&d<=1+1e-7),r=!a(qn(s));if(r){let c=0,d=s.c;for(let l=0;l<22;l++){const u=(c+d)/2;a(qn({...s,c:u}))?c=u:d=u}s.c=c}return{hex:`#${qn(s).map(c=>{const d=c<=.0031308?12.92*c:1.055*c**.4166666666666667-.055;return Math.round(Math.max(0,Math.min(1,d))*255).toString(16).padStart(2,"0")}).join("").toUpperCase()}`,clipped:r}},mg=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,Gi="lo-recent-colours-v1",Wi=()=>{try{const t=JSON.parse(localStorage.getItem(Gi)??"[]");return Array.isArray(t)?t.filter(s=>typeof s=="string"&&/^#[0-9A-Fa-f]{6}$/.test(s)).slice(0,8):[]}catch{return[]}},Yi=t=>{try{localStorage.setItem(Gi,JSON.stringify([t,...Wi().filter(s=>s!==t)].slice(0,8)))}catch{}},Qi=({value:t,onChange:s,onValidityChange:a,swatches:r=[]})=>{te();const i=o.useId(),c=o.useRef(t),[d,l]=o.useState(()=>Bn(t)),[u,m]=o.useState(t),[p,g]=o.useState("hex"),[f,h]=o.useState(!1),[v,_]=o.useState(!1),[N,C]=o.useState(!1),A=o.useCallback((x,S,T=p)=>T==="rgb"?[1,3,5].map(j=>Number.parseInt(x.slice(j,j+2),16)).join(", "):T==="oklch"?`${(S.l*100).toFixed(2)} ${S.c.toFixed(4)} ${S.h.toFixed(2)}`:x,[p]);o.useEffect(()=>{if(t===c.current)return;c.current=t;const x=Bn(t);l(x),m(A(t,x)),_(!1),h(!1),a?.(!0)},[t,A,a]);const D=x=>{const S={l:Math.max(0,Math.min(1,x.l)),c:Math.max(0,Math.min(.4,x.c)),h:(x.h%360+360)%360},T=Na(S);l(S),c.current=T.hex,_(T.clipped),m(A(T.hex,S)),h(!1),a?.(!0),s(T.hex)},I=x=>{const S=Bn(x);c.current=x,l(S),m(A(x,S)),_(!1),h(!1),a?.(!0),s(x)},O=()=>{const x=u.trim().split(/[\s,]+/).map(Number),S=p==="hex"?as(u):p==="rgb"?mg(x):null;if(p==="oklch"&&x.length===3&&x.every(Number.isFinite)&&x[0]>=0&&x[0]<=100&&x[1]>=0&&x[1]<=.4&&x[2]>=0&&x[2]<=360){D({l:x[0]/100,c:x[1],h:x[2]});return}if(!S){h(!0),a?.(!1);return}I(S)},b=x=>{const S=x.currentTarget.getBoundingClientRect();D({...d,c:(x.clientX-S.left)/S.width*.4,l:1-(x.clientY-S.top)/S.height})},z=x=>{const S=x.shiftKey?.1:.01,T={...d};switch(x.key){case"ArrowLeft":T.c-=S*.4;break;case"ArrowRight":T.c+=S*.4;break;case"ArrowUp":T.l+=S;break;case"ArrowDown":T.l-=S;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}x.preventDefault(),D(T)},P=o.useMemo(()=>Array.from({length:48},(x,S)=>{const T=1-(S+.5)/48;return`linear-gradient(to right, ${Array.from({length:17},(j,H)=>Na({l:T,c:H/16*.4,h:d.h}).hex).join(", ")})`}),[d.h]),U=globalThis.EyeDropper;return e.jsxs("div",{className:"flex min-w-0 flex-col gap-3","data-colour-picker":"",children:[e.jsx("div",{id:`${i}-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":`${i}-help`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(d.l*100),"aria-valuetext":n("ui.settings.appearance.editor.picker.area_value",{lightness:String(Math.round(d.l*100)),chroma:d.c.toFixed(3),hue:String(Math.round(d.h))}),onKeyDown:z,onPointerDown:x=>{x.currentTarget.setPointerCapture(x.pointerId),b(x)},onPointerMove:x=>{x.currentTarget.hasPointerCapture(x.pointerId)&&b(x)},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:P.map((x,S)=>e.jsx("div",{className:"min-h-0 flex-1",style:{background:x}},String(S)))}),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(${d.c/.4*100}% - 6px)`,top:`calc(${(1-d.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:d.h,onChange:x=>D({...d,h:Number(x.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:d.l*100,onChange:x=>D({...d,l:Number(x.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:d.c,onChange:x=>D({...d,c:Number(x.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:x=>{g(x.target.value),m(A(t,d,x.target.value)),h(!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":f,"aria-describedby":f?`${i}-error`:void 0,onChange:x=>{m(x.target.value),h(!0),a?.(!1)},onBlur:O,onKeyDown:x=>{x.key==="Enter"&&(x.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}})]}),f&&e.jsx("p",{id:`${i}-error`,role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.picker.invalid_channels")}),v&&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:r},{key:"recent",label:n("ui.settings.appearance.editor.picker.recent"),items:Wi()}].map(x=>e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-meta text-ink-muted",children:x.label}),e.jsx("div",{className:"flex flex-wrap gap-1",children:[...new Set(x.items)].map(S=>e.jsx("button",{type:"button","aria-label":n("ui.settings.appearance.editor.picker.swatch",{hex:S}),className:"size-7 rounded-sm border border-control focus-visible:outline-2 focus-visible:outline-accent",style:{background:S},onClick:()=>I(S)},S))}),!x.items.length&&e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.settings.appearance.editor.picker.recent_empty")})]},x.key)),U&&e.jsx(F,{type:"button",variant:"secondary",onClick:async()=>{try{const x=await new U().open(),S=as(x.sRGBHex);S&&I(S),C(!1)}catch(x){x instanceof DOMException&&x.name==="AbortError"||C(!0)}},children:n("ui.settings.appearance.picker.eyedropper")}),N&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.picker.eyedropper_error")})]})},gg=5,pg={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"},Sa=t=>n(pg[Or(t)]),Ca=(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,fg=t=>{te();const{themeName:s,themeAccent:a,themeAccentAlt:r,curated:i,all:c,paletteName:d,custom:l,customNames:u,selected:m,paintedAccent:p,adjusted:g,applied:f}=t,[h,v]=o.useState(!1),_=o.useRef(null),N=o.useRef(null),[C,A]=o.useState(null),D=h?c:i,I=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:r,label:n("ui.settings.appearance.accent.theme_second_accent",{theme:s})},...D.map(j=>({key:`palette:${j.id}`,ref:{kind:"palette",id:j.id},hex:j.hex,label:n("ui.settings.appearance.accent.from_theme",{theme:d(j.id),hue:Sa(j.hex)})}))],[s,a,r,D,d]),O=l.map(j=>({key:`custom:${j}`,ref:{kind:"custom",hex:j},hex:j,custom:j,label:n("ui.settings.appearance.accent.custom_swatch",{name:u[j]??j})})),b=[...I];if(m.kind==="palette"&&!I.some(j=>Ca(j.ref,m))){const j=c.find(H=>H.id===m.id);j&&b.push({key:`palette:${j.id}`,ref:m,hex:j.hex,label:n("ui.settings.appearance.accent.from_theme",{theme:d(j.id),hue:Sa(j.hex)})})}const z=[...b,...O],P=Math.max(0,z.findIndex(j=>Ca(j.ref,m))),U=m.kind!=="theme"&&f&&g>gg?n("ui.settings.appearance.accent.adjusted"):null,x=o.useRef(null),S=j=>{if(!["ArrowRight","ArrowDown","ArrowLeft","ArrowUp"].includes(j.key)&&j.key!=="Home"&&j.key!=="End")return;const $=[...x.current?.querySelectorAll('[role="radio"]')??[]],q=$.indexOf(j.target);if(q<0)return;j.preventDefault();const W=getComputedStyle(j.currentTarget).direction==="rtl",y=j.key==="ArrowDown"||j.key==="ArrowRight"&&!W||j.key==="ArrowLeft"&&W,L=j.key==="Home"?0:j.key==="End"?$.length-1:(q+(y?1:-1)+$.length)%$.length;$[L]?.focus(),$[L]?.click()},T=(j,H)=>{const $=H===P,q=e.jsx("button",{type:"button",role:"radio","aria-checked":$,"aria-label":j.label,tabIndex:$?0:-1,"data-accent-swatch":j.key,onClick:()=>t.onSelect(j.ref),className:pe("group relative flex size-8 shrink-0 items-center justify-center rounded-full"),children:e.jsx("span",{"aria-hidden":"true",style:{backgroundColor:j.hex},className:pe("flex size-6 items-center justify-center rounded-full border border-hairline transition-colors group-hover:border-hairline-strong",$&&"outline-2 outline-ink outline-offset-2"),children:$&&e.jsx(Cn,{size:14,strokeWidth:3,style:{color:j.hex.toUpperCase()===p.toUpperCase()?"var(--color-on-accent)":$r(j.hex).ink}})})}),W=$&&U?`${j.label}. ${U}`:j.label,y=e.jsx(Ze,{side:"bottom",content:W,children:q},j.key);if(!j.custom)return y;const L=j.custom;return e.jsxs(uo,{children:[e.jsx(mo,{asChild:!0,children:e.jsx("span",{className:"inline-flex",onContextMenuCapture:M=>{_.current=M.currentTarget.querySelector("button")},onKeyDown:M=>{if(M.key!=="ContextMenu"&&!(M.key==="F10"&&M.shiftKey))return;M.preventDefault();const V=M.currentTarget.getBoundingClientRect();M.currentTarget.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,clientX:V.left,clientY:V.bottom}))},children:y})}),e.jsxs(go,{onCloseAutoFocus:M=>{const V=N.current;V&&(M.preventDefault(),N.current=null,requestAnimationFrame(()=>A(V)))},children:[e.jsx(In,{onSelect:()=>{N.current={kind:"edit",hex:L}},children:n("ui.settings.appearance.accent.edit_colour")}),e.jsx(In,{onSelect:()=>{N.current={kind:"rename",hex:L}},children:n("ui.settings.appearance.accent.rename")}),e.jsx(In,{destructive:!0,onSelect:()=>t.onRemove(L),children:n("ui.settings.appearance.accent.remove")})]})]},j.key)};return e.jsx(Mi,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(il,{open:C!==null,onOpenChange:j=>{j||A(null)},children:[e.jsxs("div",{ref:x,role:"radiogroup","aria-label":n("ui.settings.appearance.accent.row_label"),onKeyDown:S,className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[b.map((j,H)=>T(j,H)),O.length>0&&e.jsx("span",{"aria-hidden":"true",className:"mx-1 h-6 w-px shrink-0 bg-hairline"}),O.map((j,H)=>T(j,b.length+H)),e.jsx(rl,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:e.jsx(Ze,{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:j=>{_.current=j.currentTarget,A({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(kn,{size:14})})})})})})]}),e.jsx(ol,{onCloseAutoFocus:j=>{j.preventDefault(),_.current?.focus()},align:"start",className:"w-66","aria-label":C?.kind==="rename"?n("ui.settings.appearance.picker.rename_dialog"):C?.kind==="edit"?n("ui.settings.appearance.picker.edit_dialog"):n("ui.settings.appearance.picker.dialog"),children:C?.kind==="rename"?e.jsx(xg,{initial:u[C.hex]??"",onCancel:()=>A(null),onSave:j=>{t.onRename(C.hex,j),A(null)}}):C?e.jsx(hg,{initial:C.kind==="edit"?C.hex:p,submitLabel:C.kind==="edit"?n("ui.settings.appearance.picker.save"):n("ui.settings.appearance.picker.add"),onCancel:()=>A(null),onSubmit:j=>{C.kind==="edit"?t.onReplace(C.hex,j):t.onAdd(j),A(null)}},C.kind==="edit"?C.hex:"add"):null})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-1",children:[e.jsx(F,{variant:"linkQuiet",size:"sm","aria-expanded":h,onClick:()=>v(j=>!j),children:h?n("ui.settings.appearance.accent.show_fewer"):n("ui.settings.appearance.accent.show_all")}),l.length>=Lr&&e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.settings.appearance.accent.limit")})]}),!f&&m.kind!=="theme"&&e.jsx("output",{className:"block px-1 text-meta text-warning",children:n("ui.settings.appearance.accent.not_applied")}),U&&e.jsx("p",{className:"px-1 text-meta text-ink-muted",children:U})]})})},hg=({initial:t,submitLabel:s,onSubmit:a,onCancel:r})=>{const[i,c]=o.useState(as(t)??"#3B82F6"),[d,l]=o.useState(!0);return e.jsxs("form",{onSubmit:u=>{u.preventDefault(),d&&(Yi(i),a(i))},className:"flex flex-col gap-3",children:[e.jsx(Qi,{value:i,onChange:c,onValidityChange:l}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(F,{type:"button",variant:"ghost",size:"sm",onClick:r,children:n("ui.settings.appearance.picker.cancel")}),e.jsx(F,{type:"submit",variant:"primary",size:"sm",disabled:!d,children:s})]})]})},xg=({initial:t,onSave:s,onCancel:a})=>{const[r,i]=o.useState(t),c=o.useId();return e.jsxs("form",{className:"flex flex-col gap-3",onSubmit:d=>{d.preventDefault(),s(r)},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(Le,{id:c,inputSize:"sm",autoFocus:!0,maxLength:Dr,value:r,onChange:d=>i(d.target.value)})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(F,{type:"button",variant:"ghost",size:"sm",onClick:a,children:n("ui.settings.appearance.picker.cancel")}),e.jsx(F,{type:"submit",variant:"primary",size:"sm",children:n("ui.settings.appearance.picker.save")})]})]})},_g=({previewTheme:t,className:s})=>(te(),e.jsx("section",{"aria-label":n("ui.settings.appearance.layers.preview_label"),"data-appearance-preview":"",className:pe("rounded-md border border-hairline",s),children:e.jsxs("div",{"data-theme":t,ref:yg,"aria-hidden":"true",className:pe("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(Oc,{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(ps,{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(Hn,{tone:"success"}),e.jsx(Hn,{tone:"warning"}),e.jsx(Hn,{tone:"danger"})]})]})})),yg=t=>{t?.setAttribute("inert","")},bg={success:{icon:cl,className:"border-success-border bg-success-wash text-success",key:"ui.settings.appearance.layers.preview.success"},warning:{icon:Ai,className:"border-warning-border bg-warning-wash text-warning",key:"ui.settings.appearance.layers.preview.warning"},danger:{icon:Ei,className:"border-danger-border bg-danger-wash text-danger",key:"ui.settings.appearance.layers.preview.danger"}},Hn=({tone:t})=>{const{icon:s,className:a,key:r}=bg[t];return e.jsxs("div",{className:pe("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(r)})]})},vg={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"},kg={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"},zt=t=>n(vg[t]),Ma=t=>t>0?`+${t}`:String(t),Ea=t=>{const s=si(t);if(s)return zt(s);const a=Fr(t);return a?n("ui.settings.appearance.contrast.value_between",{from:zt(a[0]),to:zt(a[1]),value:Ma(t)}):Ma(t)},jg=({committed:t,effective:s,mode:a,pending:r=!1,backgroundAtCeiling:i=!1,onDraft:c,onCommit:d})=>{te();const[l,u]=o.useState(null),m=l??t,p=o.useId(),g=o.useId(),f=o.useRef(m);f.current=m;const h=o.useRef(!1),[v,_]=o.useState({committed:t,mode:a,pending:r});(v.committed!==t||v.mode!==a||v.pending!==r)&&(_({committed:t,mode:a,pending:r}),(v.committed!==t||v.mode!==a||v.pending&&!r)&&u(null));const N=x=>{u(x),c(x)},C=x=>{x!==t?(N(x),d(x)):(u(null),c(null))},A=si(m),D=A?null:zr(m),I=s!==void 0&&!r&&l===null?s!==t:!1,O=x=>{if(x.button!==0)return;h.current=!0;const S=()=>{window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",S),h.current=!1,C(f.current)};window.addEventListener("pointerup",S),window.addEventListener("pointercancel",S)},b=x=>{let S=null;if(x.key==="PageUp")S=Qs(m,1);else if(x.key==="PageDown")S=Qs(m,-1);else if(x.key==="Home")S=-100;else if(x.key==="End")S=100;else if(x.key.startsWith("Arrow")){const T=getComputedStyle(x.currentTarget).direction==="rtl",j=x.key==="ArrowUp"||x.key==="ArrowRight"&&!T||x.key==="ArrowLeft"&&T,H=x.key==="ArrowDown"||x.key==="ArrowLeft"&&!T||x.key==="ArrowRight"&&T;j?S=Rn(m+An,{snap:!1}):H&&(S=Rn(m-An,{snap:!1}))}S!==null&&(x.preventDefault(),N(S))},z=x=>{(x.key.startsWith("Arrow")||x.key==="PageUp"||x.key==="PageDown"||x.key==="Home"||x.key==="End")&&C(f.current)},P=x=>{if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown"].includes(x.key))return;x.preventDefault();const T=Tt.findIndex(y=>y.name===(A??D)),j=getComputedStyle(x.currentTarget).direction==="rtl",H=x.key==="ArrowDown"||x.key==="ArrowRight"!==j,$=Math.max(0,Math.min(Tt.length-1,T+(H?1:-1))),q=Tt[$];C(q.value),x.currentTarget.querySelectorAll("[role=radio]")[$]?.focus()},U=(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(F,{variant:"link",size:"sm",onClick:()=>C(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:P,className:"grid grid-cols-5 gap-2",children:Tt.map(({name:x,value:S})=>{const T=A===x,j=D===x,H=T||A===null&&j;return e.jsx(Ze,{content:n(kg[x]),side:"bottom",children:e.jsxs("button",{type:"button",role:"radio","aria-checked":T,tabIndex:H?0:-1,"data-contrast-chip":x,onClick:()=>C(S),className:pe("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:pe("relative block h-6 overflow-hidden rounded-sm border",T?"border-accent":"border-hairline"),children:[e.jsxs("span",{"data-theme":bn.chip(x),"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:pe("truncate px-0.5 text-meta",T?"text-ink":"text-ink-muted"),children:j?n("ui.settings.appearance.contrast.adjusted",{preset:zt(x)}):zt(x)})]})},x)})}),e.jsx("output",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:Ea(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:An,value:m,"aria-label":n("ui.settings.appearance.contrast.slider"),"aria-valuetext":Ea(m),"aria-describedby":p,"data-contrast-slider":"",onPointerDown:O,onKeyDown:b,onKeyUp:z,onChange:x=>{const S=Rn(Number(x.target.value),{snap:h.current});h.current?N(S):C(S)},style:{"--fill":`${U}%`},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:r?n("ui.settings.appearance.contrast.applying"):I&&s!==void 0?n("ui.settings.appearance.contrast.capped_hint"):i?n("ui.settings.appearance.contrast.background_ceiling"):a==="dark"?n("ui.settings.appearance.contrast.applies_dark"):n("ui.settings.appearance.contrast.applies_light")})]})},Aa="lo-appearance-preview",Ra=t=>{let s=document.getElementById(Aa);if(!t){s?.remove();return}s||(s=document.createElement("style"),s.id=Aa,document.head.appendChild(s)),s.textContent!==t&&(s.textContent=t)},wg=t=>{if(t.identity)return null;const s=t.palette,a={};for(const r of Kr)a[r]=s[r];return a},_s=new Set;let Sn=null;const Zi=t=>{Sn=t;for(const s of _s)s(t)},Ng=()=>{const[t,s]=o.useState(Sn);return o.useEffect(()=>(_s.add(s),()=>{_s.delete(s)}),[]),t},Sg=t=>{const s=Ng(),a=Vi().palette,r=o.useMemo(()=>wg(t),[t]),i=o.useMemo(()=>a?Zs(a,Tt.map(({name:d,value:l})=>({id:bn.chip(d),contrast:l})),r):"",[a,r]),c=o.useRef(null);return o.useLayoutEffect(()=>{if(!a)return;const d=()=>{c.current=null;const l=Sn===null?"":Zs(a,[{id:bn.strip,contrast:Sn}],r);Ra(i+l)};c.current!==null&&cancelAnimationFrame(c.current),s===null?d():c.current=requestAnimationFrame(d)},[a,r,s,i]),o.useEffect(()=>()=>{c.current!==null&&cancelAnimationFrame(c.current),Ra("")},[]),s},Cg=()=>{const t=Es(),s=Sg(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(_g,{previewTheme:s===null?void 0:bn.strip})})},Mg=({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]}),Eg=()=>{const t=xe(i=>i.setContrast),[s,a]=o.useState(!1);return{commit:o.useCallback((i,c)=>{a(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>{t(i,c),Zi(null),a(!1)}))},[t]),pending:s}},Ag=()=>{te();const t=Es(),s=xe(b=>b.themeName),a=xe(b=>b.contrast),r=xe(b=>b.accent),i=xe(b=>b.customAccents),c=xe(b=>b.customAccentNames),d=xe(b=>b.setAccent),l=xe(b=>b.addCustomAccent),u=xe(b=>b.replaceCustomAccent),m=xe(b=>b.renameCustomAccent),p=xe(b=>b.removeCustomAccent),{commit:g,pending:f}=Eg(),h=Vi(),v=h.palette,_=v?.mode??"dark",N=a[_]??0,C=r[_]??{kind:"theme"},A=o.useMemo(()=>Object.keys(Qe).map(b=>{const z=yt(b)?.palette;return z?{id:b,palette:z}:null}).filter(b=>!!b),[]),D=o.useMemo(()=>Pr(A,_,s),[A,_,s]),I=o.useMemo(()=>Ur(A,_),[A,_]);if(!v)return null;const O=h.name;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("section",{"data-appearance-layer":"contrast",children:e.jsx(jg,{committed:N,effective:t.effectiveContrast,backgroundAtCeiling:_==="light"&&N>0&&t.palette.canvas.toUpperCase()===v.canvas.toUpperCase(),mode:_,pending:f,onDraft:Zi,onCommit:b=>g(_,b)})}),e.jsxs("section",{"data-appearance-layer":"accent",children:[e.jsx(Mg,{title:n("ui.settings.appearance.accent.title"),action:C.kind!=="theme"?e.jsx(F,{type:"button",variant:"link",size:"sm",className:"min-h-6 min-w-6",onClick:()=>d(_,{kind:"theme"}),children:n("ui.settings.appearance.accent.reset")}):null}),e.jsx(fg,{themeName:O,themeAccent:v.accent,themeAccentAlt:v.accentAlt,curated:D,all:I,paletteName:b=>Qe[b]?.name??b,custom:i,customNames:c,selected:C,paintedAccent:t.palette.accent,adjusted:t.accentAdjusted,applied:t.accentApplied,onSelect:b=>d(_,b),onAdd:b=>l(b,_),onReplace:u,onRename:m,onRemove:p})]})]})},Rg=()=>{te();const t=xe(l=>l.themeName),s=xe(l=>l.accent),a=xe(l=>l.customAccentNames),r=xe(l=>l.setAccent),i=yt(t)?.palette.mode??"dark",c=s[i],d=Es();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:d.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:Qe[c.id]?.name??c.id})}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx(F,{type:"button",variant:"link",size:"sm",className:"min-h-6 min-w-6",onClick:()=>r(i,{kind:"theme"}),children:n("ui.settings.appearance.accent.use_theme_accent")})]})},Ig=()=>(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(Rg,{})})]})),Tg=({gallery:t})=>e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(Cg,{}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ig,{}),t]}),e.jsx(Ag,{})]}),Lg=[[[".claude.json"],"Claude Code"],[[".claude",".mcp.json"],"Claude Code"],[[".cursor","mcp.json"],"Cursor"],[[".vscode","mcp.json"],"VS Code"],[[".codex","config.toml"],"Codex CLI"]];function Ji(t){if(!t)return null;const s=t.split("\\").join("/").split("/").filter(Boolean);for(const[a,r]of Lg)if(!(s.length<a.length)&&s.slice(-a.length).join("/")===a.join("/"))return r;return null}const xn=t=>n("ui.settings.integrations.integration_model.tool_count",{count:t}),Og=t=>n("ui.settings.integrations.integration_model.integration_count",{count:t}),$g=["connected","needs_sign_in","not_started","connecting","error"],Xi=t=>$g.includes(t),wt=(t,s)=>[...s].filter(a=>a.name===t&&a.status==="running").sort((a,r)=>r.created_at-a.created_at)[0]??null,Dg={connectedAt:null,connectedToolCount:null,settledGroup:null,pinnedGroup:null,pinnedOperationId:null,needsKey:!1,needsSignIn:!1,disconnectedAt:null,holdUntil:null,lastDecisive:null},zg=1e12,Fg=1e9,Pg=60*60*1e3,er=(t,s=Date.now())=>{if(typeof t!="number"||!Number.isFinite(t))return null;const a=t>=zg?t:t<Fg?null:t*1e3;return a===null||a>s+Pg?null:Math.min(a,s)},mt=(t,s)=>t?.[s]??Dg,Gt=(t,s,a)=>Bg(t,s)??a?.lastDecisive??null,Ug=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}:{}}),qs=(t,s)=>t.status==="not_started"&&typeof t.tool_count=="number"&&(s.connectedAt!==null||t.status_basis==="stored"&&t.tool_count_basis==="last_seen"),Kg=(t,s)=>[...s].filter(a=>a.name===t).sort((a,r)=>r.created_at-a.created_at)[0]??null,Bg=(t,s)=>Kg(t,s.filter(a=>a.status!=="cancelled")),Mn=t=>t.actions.includes("set_key")||t.actions.includes("add_key");function qg(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 r=Math.round(a/60);if(r<60)return n("ui.settings.integrations.integration_model.minutes_min_ago",{minutes:r});const i=Math.round(r/60);return i<24?n("ui.settings.integrations.integration_model.hours_h_ago",{hours:i}):n("ui.settings.integrations.integration_model.days_ago",{days:Math.round(i/24)})}function Vn(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 r=0;r<3;r+=1){const i=a.replace(/^(?:connection (?:closed|error|refused)|error|closed|failed)\s*:\s*/i,"").trim();if(i===a)break;a=i}return a=a.replace(/\s*\(\s*\d{3}\s*\)/g,"").replace(/\s+([.,;])/g,"$1").replace(/\s{2,}/g," ").trim(),a||null}function Hg(t,s=[],a,r=Date.now()){const i=mt(a,t.name),c=wt(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(!Xi(t.status))return{label:n("ui.settings.integrations.integration_model.status_unavailable"),tone:"neutral",detail:null,busy:!1};const d=Gt(t.name,s,i),l=En(d)&&t.status!=="connected",u=qs(t,i),m=Gs(d)&&t.status!=="connected",p=(d?.action==="login"||d?.action==="reauth")&&d.status==="failed";if(i.disconnectedAt!==null)return{label:n("ui.settings.integrations.integration_model.not_connected"),tone:"neutral",detail:null,busy:!1,explanation:n(Ia)};switch(t.status){case"connected":return{label:typeof t.tool_count=="number"?n("ui.settings.integrations.integration_model.connected_with_tools",{tools:String(xn(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"||Ft(t,s,i)?n("ui.settings.integrations.integration_model.needs_a_key"):n("ui.settings.integrations.integration_model.needs_sign_in"),tone:"warning",detail:Vn(t.status_reason),busy:!1};case"error":return{label:n("ui.settings.integrations.integration_model.couldn_t_start"),tone:"danger",detail:Vn(t.status_reason)??n("ui.settings.integrations.integration_model.no_reason_was_given"),busy:!1};default:if(l)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(Ft(t,s,i))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(i.needsSignIn)return{label:t.auth.kind==="api_key"||Ft(t,s,i)?n("ui.settings.integrations.integration_model.needs_a_key"):n("ui.settings.integrations.integration_model.needs_sign_in"),tone:"warning",detail:Vn(t.status_reason),busy:!1};if(t.status_basis==="stored"&&u&&i.disconnectedAt===null){const g=i.connectedAt??er(t.last_seen_at,r);return{label:g!==null?n("ui.settings.integrations.integration_model.worked_when_with_tools",{when:String(qg(r,g)),tools:String(xn(t.tool_count))}):n("ui.settings.integrations.integration_model.worked_earlier_with_tools",{tools:String(xn(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(Ia)}:{label:n("ui.settings.integrations.integration_model.ready"),tone:"neutral",detail:null,busy:!1,explanation:n(Wg)}}}const tr=t=>n("ui.settings.integrations.integration_model.replace_keys",{count:t}),Vg=/[,;]?\s*(?:or|and)?\s*add (?:its|a|the) key instead\.?\s*$/i;function Gg(t,s){const a=t?.trim()??"";if(!a)return null;if(s)return a;const r=a.replace(Vg,"").trim();return r?/\.$/.test(r)?r:`${r}.`:a}const Wg="ui.settings.integrations.integration_model.copy_ready_explanation",Ia="ui.settings.integrations.integration_model.copy_not_connected_explanation",Yg=t=>t.transport==="local_command"?n("ui.settings.integrations.integration_model.local_command"):n("ui.settings.integrations.integration_model.remote_url");function nr(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 Ji(t.source.path)}}function Qg(t,s){const a=[{text:Yg(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(xn(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 r=nr(t);return r?a.push({text:n("ui.settings.integrations.integration_model.imported_from_origin",{origin:String(r)}),importSource:!0}):t.source.editable||a.push({text:n("ui.settings.integrations.integration_model.imported_from_a_project_file"),importSource:!0}),a}const Hs=(t,s)=>s.disconnectedAt!==null?"not_started":t.status;function Vs(t,s=[],a){const r=mt(a,t.name),i=wt(t.name,s);if(i)return i.action==="login"||i.action==="reauth"?{kind:"sign_in",label:n("ui.settings.integrations.integration_model.continue_sign_in")}:null;const c=p=>t.actions.includes(p),d=Mn(t),l=Ft(t,s,r);if(!Xi(t.status))return c("test")?{kind:"test",label:n("ui.settings.integrations.integration_model.check_again")}:null;const u=Gt(t.name,s,r),m=u?.status==="failed"&&Wt(u);switch(Hs(t,r)){case"connected":case"connecting":return null;case"needs_sign_in":return l?{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")}:d?{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(En(u)&&c("sign_in"))return{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")};if(Gs(u)&&c("sign_out"))return{kind:"sign_out",label:n("ui.settings.integrations.integration_model.sign_out_again")};if(r.disconnectedAt!==null&&c("connect"))return{kind:"connect",label:n("ui.settings.integrations.integration_model.connect")};if(r.needsSignIn){if(l&&d)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 l&&d?{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")}:qs(t,r)&&!c("connect")?null:c("connect")?{kind:"connect",label:n("ui.settings.integrations.integration_model.connect"),...r.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 Wt=t=>t.action==="login"||t.action==="reauth",En=t=>!!(t&&t.action==="logout"&&t.status==="complete"),Gs=t=>!!(t&&t.action==="logout"&&t.status!=="running"&&t.status!=="complete"),sr=/no oauth authorization server/i;function Ft(t,s,a){if(!Mn(t))return!1;const r=Gt(t.name,s,a);return r&&Wt(r)&&r.status==="failed"&&sr.test(r.message??"")?!0:a.needsKey}function Zg(t,s=[],a){const r=Vs(t,s,a)?.kind,i=Hs(t,mt(a,t.name)),c=u=>t.actions.includes(u),d=[],l=wt(t.name,s);if(l&&d.push({kind:"cancel",label:n("ui.settings.integrations.integration_model.cancel")}),!l&&c("test")&&r!=="test"&&d.push({kind:"test",label:n("ui.settings.integrations.integration_model.test_connection")}),c("connect")&&r!=="connect"&&i!=="connected"&&d.push({kind:"connect",label:n("ui.settings.integrations.integration_model.reconnect")}),!l&&c("sign_in")&&r!=="sign_in"&&i!=="connected"&&d.push({kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}),c("reload")&&d.push({kind:"reload",label:n("ui.settings.integrations.integration_model.reload")}),!l&&c("reauth")&&r!=="reauth"&&d.push({kind:"reauth",label:n("ui.settings.integrations.integration_model.sign_in_again")}),Mn(t)&&r!=="set_key"&&d.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")&&d.push({kind:"sign_out",label:n("ui.settings.integrations.integration_model.sign_out")}),c("disconnect")&&i==="connected"&&d.push({kind:"disconnect",label:n("ui.settings.integrations.integration_model.disconnect")}),c("copy_setup")&&t.setup_prompt&&d.push({kind:"copy_setup",label:n("ui.settings.integrations.integration_model.copy_setup_prompt")}),r!=="fix"&&d.push({kind:"open_config",label:n("ui.settings.integrations.integration_model.open_config_file")}),c("remove"))d.push({kind:"remove",label:n("ui.settings.integrations.integration_model.remove"),destructive:!0});else if(!t.source.editable){const u=nr(t);d.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 d}const Jg={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 ar(t,s=[],a){const r=mt(a,t.name),i=wt(t.name,s),c=Hs(t,r);if(i&&r.pinnedGroup&&r.pinnedOperationId===i.id)return r.pinnedGroup;if(c==="needs_sign_in"||c==="error")return"attention";const d=Gt(t.name,s,r);return En(d)&&c!=="connected"||Gs(d)&&c!=="connected"?"attention":r.disconnectedAt!==null?"ready":Ft(t,s,r)||r.needsSignIn&&c!=="connected"||d?.status==="failed"&&Wt(d)&&c!=="connected"?"attention":c==="connected"||t.status_basis==="stored"&&qs(t,r)?"connected":i&&i.action!=="test"?"attention":"ready"}function Xg(t,s=[],a){return["attention","connected","ready"].map(i=>({id:i,title:Jg[i],rows:t.filter(c=>ar(c,s,a)===i)})).filter(i=>i.rows.length>0)}function ep(t,s,a=Date.now()){if(!s)return t??{};const r={};for(const i of s.servers){const c=mt(t,i.name),d=wt(i.name,s.operations),l=Gt(i.name,s.operations,c),u=En(l),m=i.status==="connected"&&(i.status_basis==="probe"||i.status_basis==="live"),p=c.holdUntil!==null&&a<c.holdUntil,g=!p&&!u&&c.connectedAt===null&&i.status_basis==="stored"&&i.tool_count_basis==="last_seen"?er(i.last_seen_at,a):null,f=!u,h=l?.status==="failed"&&Wt(l)&&sr.test(l.message??""),v={connectedAt:m&&!p?a:g!==null?g:f?c.connectedAt:null,connectedToolCount:m&&!p||g!==null?i.tool_count??c.connectedToolCount:f?c.connectedToolCount:null,settledGroup:c.settledGroup,pinnedGroup:d&&c.pinnedOperationId===d.id?c.pinnedGroup:d?c.settledGroup:null,pinnedOperationId:d?d.id:null,needsKey:m?!1:c.needsKey||h,needsSignIn:m||u?!1:c.needsSignIn||i.status==="needs_sign_in",disconnectedAt:m&&!p?null:c.disconnectedAt,holdUntil:p?c.holdUntil:null,lastDecisive:l?Ug(l):null};d||(v.settledGroup=ar(i,s.operations,{...r,[i.name]:v})),r[i.name]=v}return r}const tp=(t,s)=>t!==null&&s===t,ys="local-operator.settings.integrations.row-memory",ir=(t,s)=>`${t}#${s}`;function np(t,s){const a={};if(!s)return a;for(const r of s.servers){const i=t[r.name];i&&(a[ir(r.source.path,r.name)]=i)}return a}function sp(t,s,a){if(!s)return t;let r=null;for(const i of s.servers){if(Object.prototype.hasOwnProperty.call(t,i.name))continue;const c=rp(a[ir(i.source.path,i.name)]);c&&(r=r??{...t},r[i.name]=c)}return r??t}const ap=["attention","connected","ready"],rr=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Ws=t=>typeof t=="number"&&Number.isFinite(t)?t:null,Ta=t=>ap.includes(t)?t:null,Gn=t=>{const s=Ws(t);return s!==null&&s>=1e12?s:null};function ip(t){if(!rr(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:Ws(t.created_at)??0,credential_removed:t.credential_removed===!0,...typeof t.message=="string"?{message:t.message}:{}}}function rp(t){if(!rr(t))return null;const s=Gn(t.connectedAt),a=Gn(t.disconnectedAt),r=t.needsKey===!0,i=t.needsSignIn===!0,c=ip(t.lastDecisive);return s===null&&a===null&&!r&&!i&&!c?null:{connectedAt:s,connectedToolCount:Ws(t.connectedToolCount),settledGroup:Ta(t.settledGroup),pinnedGroup:Ta(t.pinnedGroup),pinnedOperationId:typeof t.pinnedOperationId=="string"?t.pinnedOperationId:null,needsKey:r,needsSignIn:i,disconnectedAt:a,holdUntil:Gn(t.holdUntil),lastDecisive:c}}const or=2e3,La=8e3;function op(t){return t&&(t.servers.some(a=>a.status==="connecting")||t.operations.some(a=>a.status==="running"))?or:!1}const cp=/^[A-Za-z0-9_.:-]{1,100}$/,lp=/:\/\//;function dp(t,s){const a=t.trim();return a?cp.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 up(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"):lp.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 mp=t=>t.split(`
|
|
297
|
+
`).map(s=>s.trim()).filter(Boolean);function bs(t,s){const a=!!t?.cold,r=(t?.servers??[]).map(i=>{const c=i.transport==="http",d=i.secret_refs??[],l=i.status==="connected"?"connected":i.status==="connecting"?"connecting":i.status==="auth-required"?"needs_sign_in":"not_started",u=[];l!=="connected"&&u.push("connect"),l==="connected"&&u.push("disconnect"),a||u.push("reload"),c&&i.transport_oauth_supported!==!1&&u.push("sign_in"),d.length>0&&u.push("set_key"),i.owned_scope&&u.push("remove"),i.setup?.text&&u.push("copy_setup");const m=Ji(i.source);return{id:i.name,name:i.name,scope:i.owned_scope??"global",project_cwd:null,source:{kind:gp(i.source,m,i.owned_scope),path:i.source??"",editable:i.owned_scope!==null,owned_scope:i.owned_scope},transport:c?"remote_url":"local_command",endpoint:{command:null,url:null,endpoint_redacted:!1},status:l,status_reason:null,status_observed_at:null,last_seen_at:null,status_basis:a?"stored":"live",auth:{kind:d.length?"api_key":c?"unknown":"none",signed_in:null,secret_refs:d.map(p=>({id:p.id,state:"missing"}))},tool_count:typeof i.tool_count=="number"?i.tool_count:null,tool_count_basis:typeof i.tool_count=="number"?"live":null,actions:u,setup_prompt:i.setup?.text??null}});return{cwd:"",project_scope_available:r.some(i=>i.source.owned_scope==="project"),global_path:"",project_path:null,status_source:a?"config":"live",session_id:s,servers:r,operations:(t?.operations??[]).map(i=>({...i}))}}const gp=(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",Oa={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")}},pp="ui.settings.integrations.integration_model.copy_catalog_refusal_fallback";function nn(t,s,a){if(s instanceof ks&&s.status===409){const r=typeof s.code=="string"&&Object.prototype.hasOwnProperty.call(Oa,s.code)?Oa[s.code]:n(pp);return`${po[t]}. ${r}`}return fo(t,s,a).message}const fp="ui.settings.integrations.add_integration_form.copy_add_integration_pickup_note",hp="ui.settings.integrations.add_integration_form.copy_transport_hint",xp=({existingNames:t,projectScopeAvailable:s,projectLabel:a,onSubmit:r,onCancel:i,initial:c})=>{te();const[d,l]=o.useState(c?.name??""),[u,m]=o.useState(c?.mode??"command"),[p,g]=o.useState(c?.command??""),[f,h]=o.useState(c?.args??""),[v,_]=o.useState(c?.url??""),[N,C]=o.useState("global"),[A,D]=o.useState(c?.touched?{name:!0,command:!0,url:!0}:{}),[I,O]=o.useState(!!c?.touched),[b,z]=o.useState(!1),[P,U]=o.useState(null),x=o.useRef(null),S=o.useRef(null),T=o.useRef(null);o.useEffect(()=>{x.current?.focus()},[]);const j=dp(d,t),H=u==="command"&&!p.trim()?n("ui.settings.integrations.add_integration_form.enter_the_command_to_run"):null,$=u==="url"?up(v):null,q=M=>I||A[M],W=async M=>{if(M.preventDefault(),O(!0),j||H||$){j?x.current?.focus():H?S.current?.focus():T.current?.focus();return}z(!0),U(null);const V=s?N:"global",ae=u==="command"?{name:d.trim(),scope:V,mode:u,command:p.trim(),args:mp(f)}:{name:d.trim(),scope:V,mode:u,url:v.trim()},Q=await r(ae);z(!1),U(Q)},y=(M,V,ae)=>V&&q(ae)?e.jsx("p",{id:M,className:"text-body-sm text-danger",children:V}):null,L=M=>M.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:M=>void W(M),onKeyDown:M=>{M.key==="Escape"&&(M.stopPropagation(),i())},children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(qe,{htmlFor:"integration-add-name",children:n("ui.settings.integrations.add_integration_form.name")}),e.jsx(Le,{ref:x,id:"integration-add-name",value:d,placeholder:n("ui.settings.integrations.add_integration_form.e_g_notion"),autoComplete:"off","aria-invalid":!!(j&&q("name")),"aria-describedby":j&&q("name")?"integration-add-name-error":void 0,onChange:M=>l(M.target.value),onBlur:()=>D(M=>({...M,name:!0}))}),y("integration-add-name-error",j,"name")]}),e.jsxs(Bt,{value:u,onValueChange:M=>m(M==="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(qt,{"aria-labelledby":"integration-add-transport-label",children:[e.jsx(dt,{value:"command","data-integration-transport":"command",children:n("ui.settings.integrations.add_integration_form.local_command")}),e.jsx(dt,{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(hp)}),e.jsxs(da,{value:"command",className:"mt-0 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(qe,{htmlFor:"integration-add-command",children:n("ui.settings.integrations.add_integration_form.command")}),e.jsx(Le,{ref:S,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:M=>g(M.target.value),onBlur:()=>D(M=>({...M,command:!0}))}),y("integration-add-command-error",H,"command")]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs(qe,{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(Ds,{id:"integration-add-args",value:f,rows:2,className:"font-mono",onChange:M=>h(M.target.value)})]})]}),e.jsx(da,{value:"url",className:"mt-0 flex flex-col gap-4",children:e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(qe,{htmlFor:"integration-add-url",children:n("ui.settings.integrations.add_integration_form.url")}),e.jsx(Le,{ref:T,id:"integration-add-url",type:"url",value:v,placeholder:n("ui.settings.integrations.add_integration_form.https_mcp_example_com_mcp"),autoComplete:"off",className:"font-mono","aria-invalid":!!($&&q("url")),"aria-describedby":$&&q("url")?"integration-add-url-error":"integration-add-url-help",onChange:M=>_(M.target.value),onBlur:()=>D(M=>({...M,url:!0}))}),y("integration-add-url-error",$,"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(Bt,{value:N,onValueChange:M=>C(M==="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(qt,{"aria-labelledby":"integration-add-scope-label",children:[e.jsx(dt,{value:"global","data-integration-scope":"global",children:n("ui.settings.integrations.add_integration_form.all_chats")}),e.jsx(dt,{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:N==="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,P?e.jsx("p",{className:"text-body-sm text-danger",role:"alert",children:P}):null,e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:pe("text-body-sm text-ink-dim"),children:n(fp)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(F,{type:"button",variant:"ghost",size:"md",onMouseDown:L,onClick:i,children:n("ui.settings.integrations.add_integration_form.cancel")}),e.jsxs(F,{type:"submit",variant:"primary",size:"md",disabled:b,onMouseDown:L,children:[b?e.jsx(Ce,{size:"xs"}):null,n("ui.settings.integrations.add_integration_form.add_integration")]})]})]})]})},_p=4;function yp(t){return t.rowMoving?t.now+t.windowMs:Math.max(t.hold.until,t.lastMovingAt+t.windowMs)}function bp(t){return t.now>t.hold.until||t.hold.reanchors>=_p?"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 vp(t){const s=yp({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,r=t.candidate;if(!r)return{hold:{until:s,reanchors:t.hold.reanchors,landedOn:a},land:null};if(!a)return{hold:{until:s,reanchors:t.hold.reanchors,landedOn:r},land:r};const i=bp({hold:{until:s,reanchors:t.hold.reanchors,landedOn:a},candidate:r,active:t.active,body:t.body,now:t.now});if(i==="settled")return{hold:{until:s,reanchors:t.hold.reanchors,landedOn:a},land:null};if(i==="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:r},land:r}}function kp(t){const{row:s,target:a}=t;return!s||!a||typeof a.nodeType!="number"?!1:!s.contains(a)}const $a=250;function Da(t){return t?!t.disabled:!1}function jp(t){return Da(t.primary)?t.primary??null:Da(t.overflow)?t.overflow??null:null}function wp(t){return t.verdict==="finished"?null:t.watchMs}const cr="key";function Np(t){const{name:s,keyless:a,freeName:r,names:i,values:c,replace:d,canReplace:l}=t;if(a){const u=vs(s,r);return{values:{[u]:(c[cr]??"").trim()},confirmedReplace:d&&l?[u]:[],header:r.trim()}}return{values:Object.fromEntries(i.map(u=>[u,(c[u]??"").trim()])),confirmedReplace:d&&l?i:[],header:void 0}}function vs(t,s){const a=za(t),r=za(s);if(!r)return"";const i=[a,r].filter(Boolean).join("_"),c=/^[A-Za-z_]/.test(i)?i:`K_${i}`;if(c.length<=Wn)return c;const d=Sp(a),l=Wn-r.length-d.length-2,u=[a.slice(0,Math.max(l,0)),d,r].filter(Boolean).join("_");return u.length<=Wn?u:u.slice(-128)}const Wn=128,za=t=>t.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,""),Sp=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)},Cp=({name:t,keyNames:s,keyless:a=!1,savedKeys:r=[],saving:i,failure:c,onSave:d,onClose:l})=>{te();const[u,m]=o.useState({}),[p,g]=o.useState(!1),[f,h]=o.useState(""),v=a?[vs(t,f)]:[...s],_=a?[cr]:v,N=(a?vs(t,f).length>0:!0)&&_.every(A=>(u[A]??"").trim()),C=v.some(A=>r.includes(A));return e.jsx(gi,{open:!0,onClose:l,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(cs,{onClick:l,children:n("ui.settings.integrations.integration_key_dialog.cancel")}),e.jsx(ls,{disabled:!N||i,onClick:()=>{const A=Np({name:t,keyless:a,freeName:f,names:v,values:u,replace:p,canReplace:C});d(A.values,A.confirmedReplace,A.header)},children:i?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(qe,{htmlFor:"integration-key-name",children:n("ui.settings.integrations.integration_key_dialog.the_header_this_server_wants_the_key_in")}),e.jsx(Le,{id:"integration-key-name",autoComplete:"off",placeholder:n("ui.settings.integrations.integration_key_dialog.e_g_authorization_or_x_api_key"),value:f,onChange:A=>h(A.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,_.filter(A=>a!==!0||A.trim().length>0).map(A=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(qe,{htmlFor:`integration-key-${A}`,className:"font-mono",children:a?"Key":A}),e.jsx(Le,{id:`integration-key-${A}`,type:"password",autoComplete:"off",value:u[A]??"",onChange:D=>m(I=>({...I,[A]:D.target.value}))})]},A)),C?e.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx(gs,{id:"integration-key-replace",checked:p,onCheckedChange:A=>g(A===!0)}),e.jsx(qe,{htmlFor:"integration-key-replace",className:"font-normal",children:tr(v.length)})]}):null,c?e.jsx("p",{className:"-mx-1.5 text-body-sm text-danger",role:"alert",children:c}):null]})})},Mp={success:"bg-success",warning:"bg-warning",danger:"bg-danger",info:"bg-info",neutral:"bg-ink-dim"},Ep={success:"text-ink-muted",warning:"text-warning",danger:"text-danger",info:"text-ink-muted",neutral:"text-ink-dim"},Ap=({row:t,operations:s,memories:a,now:r,projectScopeAvailable:i,highlighted:c=!1,rowRef:d,primaryRef:l,overflowRef:u,pending:m,failure:p,confirm:g,onPrimary:f,onOverflow:h,onConfirm:v,onCancelConfirm:_})=>{te();const N=Hg(t,s,a,r),C=c&&N.tone==="danger"?"text-ink":Ep[N.tone],A=Vs(t,s,a),D=Zg(t,s,a),I=Qg(t,i),O=D.findIndex(b=>b.kind==="remove"||b.kind==="remove_elsewhere");return e.jsxs("li",{ref:d,"data-integration":t.name,"data-search-row":`integration.${t.id}`,"data-search-control":!0,"data-status":t.status,className:pe("flex min-h-14 flex-col justify-center gap-1 px-4 py-2.5",c&&"bg-row-selected"),onKeyDown:b=>{!g||b.key!=="Escape"||(b.stopPropagation(),_())},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:N.busy?e.jsx(Ce,{size:"xs"}):e.jsx("span",{"aria-hidden":"true","data-tone":N.tone,className:pe("size-2 rounded-full",Mp[N.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:I.map((b,z)=>e.jsxs("span",{children:[z>0?" · ":null,b.importSource&&t.source.path?e.jsx(Ze,{content:Br(t.source.path),children:e.jsx("span",{className:"underline decoration-dotted underline-offset-2",children:b.text})}):b.text]},b.text))})]}),N.explanation?e.jsx(Ze,{content:N.explanation,children:e.jsx("span",{className:pe("shrink-0 text-body-sm",C),children:N.label})}):e.jsx("span",{className:pe("shrink-0 text-body-sm",C),children:N.label}),A?e.jsxs(F,{ref:l,variant:A.variant??"secondary",size:"sm","aria-label":`${A.label} ${t.name}`,disabled:m,"data-integration-action":A.kind,onClick:()=>f(A),children:[m?e.jsx(Ce,{size:"xs"}):null,A.label]}):null,e.jsxs(zs,{children:[e.jsx(Fs,{asChild:!0,children:e.jsx(F,{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(As,{"aria-hidden":"true"})})}),e.jsx(Ps,{align:"end",className:"min-w-48",children:D.map((b,z)=>e.jsx(Rp,{item:b,separated:z===O&&z>0,onSelect:()=>h(b)},b.kind))})]})]}),N.detail?e.jsx("p",{className:pe("ps-7 text-body-sm",N.tone==="danger"?"text-ink-muted":"text-ink-dim"),children:N.detail}):null,p?e.jsx("p",{className:pe("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(F,{variant:"danger",size:"sm",onClick:v,"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(F,{variant:"ghost",size:"sm",onClick:_,children:n("ui.settings.integrations.integration_row.keep")})]}):null]})},Rp=({item:t,separated:s,onSelect:a})=>(te(),e.jsxs(e.Fragment,{children:[s?e.jsx(ll,{}):null,t.kind==="remove_elsewhere"?e.jsxs(at,{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(at,{destructive:t.kind==="remove",onSelect:a,"data-integration-menu":t.kind,children:t.label})]}));function Ip(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:Gg(s.message,a)??n("ui.settings.integrations.integration_sign_in_dialog.the_server_didn_t_say_why"),nextStep:Tp(s.message??null,a)}}function Tp(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 Lp(t,s){return t.kind==="ready"?"ready":t.kind==="running"&&s&&s.tone!=="progress"?s.tone==="success"?"success":"failure":"running"}const Op=({name:t,action:s,keyRoute:a,phase:r,onStart:i,onCancel:c,onOpenLink:d,onClose:l})=>{te();const u=r.kind==="running"?r.operation:null,m=r.kind==="running"?Ip(t,u,a):null,p=r.kind==="starting"||r.kind==="running"&&m?.tone==="progress",g=m&&m.tone!=="progress",f=o.useRef(null),h=o.useRef(!1),v=Lp(r,m);o.useEffect(()=>{if(!h.current){h.current=!0;return}v&&f.current?.focus()},[v]);const _=()=>l(m?.tone==="success"?"signed-in":"dismissed");return e.jsx(gi,{open:!0,onClose:_,maxWidth:"xs",fullWidth:!0,title:n("ui.settings.integrations.integration_sign_in_dialog.sign_in_to_name",{name:String(t)}),dialogProps:{onOpenAutoFocus:N=>{N.preventDefault(),f.current?.focus()}},actions:e.jsxs(e.Fragment,{children:[p&&u?e.jsx(cs,{ref:f,onClick:()=>c(u.id),children:n("ui.settings.integrations.integration_sign_in_dialog.cancel_sign_in")}):e.jsx(cs,{ref:r.kind==="ready"?void 0:f,onClick:_,children:m?.tone==="success"?n("ui.settings.integrations.integration_sign_in_dialog.done"):n("ui.settings.integrations.integration_sign_in_dialog.close")}),r.kind==="ready"?e.jsx(ls,{ref:f,onClick:i,children:n("ui.settings.integrations.integration_sign_in_dialog.continue_in_browser")}):null,r.kind==="refused"||m?.tone==="failure"?e.jsx(ls,{ref:m?.tone==="failure"?f:void 0,onClick:i,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:[r.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,r.kind==="starting"?e.jsxs("p",{className:"-mx-1.5 flex items-center gap-2",children:[e.jsx(Ce,{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(Ce,{size:"xs",className:"mt-0.5"}):null,m.tone==="failure"?e.jsx(Ai,{"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(F,{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(()=>ds(n("ui.settings.integrations.integration_sign_in_dialog.sign_in_link_copied"))).catch(()=>{})},children:e.jsx(mi,{"aria-hidden":"true"})})]}),e.jsx(F,{variant:"link",size:"sm",onClick:()=>d(m.link??""),children:n("ui.settings.integrations.integration_sign_in_dialog.open_the_sign_in_page")})]}):null,r.kind==="refused"?e.jsx("p",{className:"text-danger",role:"alert",children:r.message}):null]})})},$p=t=>t.reduce((s,a)=>s?(a.updated_at??0)>(s.updated_at??0)?a:s:a,null),Dp=/^[A-Za-z]:[\\/]/,_n=t=>{const s=t?.trim();return s&&(s.startsWith("/")||Dp.test(s))?s:null};function zp(t){const i=t?.payload?.frontend?.snapshot?.cwd;return typeof i=="string"&&i.trim()?i:null}const Ht="local-operator.settings.integrations.last-cwd";function Fp(t,s,a=typeof localStorage>"u"?null:localStorage){const r=_n(s);if(!(!t||!r||!a))try{const i=a.getItem(Ht),c=i?JSON.parse(i):{};if(c[t]===r)return;a.setItem(Ht,JSON.stringify({...c,[t]:r}))}catch{}}const lr=()=>typeof localStorage>"u"?null:localStorage;function dr(t=lr()){if(!t)return{};try{const s=t.getItem(ys);if(!s)return{};const a=JSON.parse(s);return!a||typeof a!="object"||Array.isArray(a)?{}:a}catch{return{}}}const Fa=256;function Pp(t,s=lr()){if(s)try{const a={...dr(s),...t},r=Object.keys(a);if(r.length>Fa){const i={};for(const c of r.slice(-Fa))i[c]=a[c];s.setItem(ys,JSON.stringify(i));return}s.setItem(ys,JSON.stringify(a))}catch{}}function Pa(t,s,a){if(t==="saved")return null;if(t==="replace_confirmation_required"){const i=tr(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(i)})}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 r=s.length?s:Object.keys(a);return n("ui.settings.integrations.use_integrations.keys_not_saved",{keys:String(r.join(", "))})}function Up(t,s=typeof localStorage>"u"?null:localStorage){if(!(!t||!s))try{const a=s.getItem(Ht);if(!a)return;const r=JSON.parse(a);if(!(t in r))return;const i={...r};delete i[t],s.setItem(Ht,JSON.stringify(i))}catch{}}const Kp=t=>!!(t&&typeof t=="object"&&"code"in t&&t.code==="invalid_cwd"),Bp=(t,s)=>s!==null&&t===s?null:t;function qp(t,s=typeof localStorage>"u"?null:localStorage){if(!t||!s)return null;try{const a=s.getItem(Ht);if(!a)return null;const i=JSON.parse(a)[t];return typeof i=="string"?i:null}catch{return null}}const Hp=t=>t.action==="disconnect"?"disconnected":"connected";function Vp(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 Gp(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 Wp({sessionId:t}){const s=jt(),a=bt(s.data,"mcp_catalog"),r=bt(s.data,"mcp"),i=a?"catalog":r?"session":null,[c,d]=o.useState(null),l=kt(),u=Ot(K=>K.sessions),m=Ot(K=>K.fetchSessions),p=Ot(K=>K.loading),g=o.useMemo(()=>u.find(K=>K.session_id===t)??null,[u,t]),f=o.useMemo(()=>i==="session"&&!t?$p(u):null,[i,t,u]),h=i==="session"?t??f?.session_id??null:null;o.useEffect(()=>{i!=="session"||t||u.length>0||m(qr)},[i,t,u.length,m]);const v=i==="catalog"?_n(g?.cwd):null,_=i==="catalog"&&!!t&&v===null,N=De({queryKey:["desktop","session-cwd",t??""],queryFn:()=>je({op:"sessions.get",sessionId:t??""}),enabled:_,staleTime:Number.POSITIVE_INFINITY,retry:!1}),C=_&&!N.isFetched,A=v??_n(zp(N.data))??(N.isFetched?_n(qp(t)):null),D=Bp(A,c),I=i==="catalog"?D:null,O=i==="catalog"?t??null:null,b=ho.catalog(I,O);o.useEffect(()=>{i!=="catalog"||!t||!I||Fp(t,I)},[i,t,I]);const z=o.useRef(0),[P,U]=o.useState(0),x=o.useRef(null),S=o.useCallback((K,k)=>{const Y=Date.now()+La;z.current=Y,x.current={name:K,expect:k},U(Y)},[]),T=o.useCallback(K=>Date.now()<z.current?or:op(K),[]),j=De({queryKey:b,queryFn:()=>yo(I,O),enabled:i==="catalog"&&!C,staleTime:1e4,refetchInterval:K=>T(K.state.data)}),H=Kp(j.error);o.useEffect(()=>{!H||!A||c===A||(d(A),Up(t))},[H,A,c,t]);const $=De({queryKey:us.list(h??""),queryFn:()=>bo(h??""),enabled:i==="session"&&!!h,staleTime:1e4,refetchInterval:K=>T(K.state.data?bs(K.state.data,h??""):void 0)}),q=o.useMemo(()=>{if(i==="catalog")return j.data;if(i==="session"&&$.data&&h)return bs($.data,h)},[i,j.data,$.data,h]),W=o.useCallback(()=>Yp({queryClient:l,route:i,catalogKey:b,sessionId:h}),[i,b,l,h]);o.useEffect(()=>{if(!P)return;const K=x.current;if(!K)return;const k=q?.servers.find(se=>se.name===K.name);!k||!(K.expect==="connected"?k.status==="connected":k.status_basis==="live"&&k.status!=="connected")||(z.current=0,x.current=null,U(0))},[q,P]);const y=o.useRef({}),[L,M]=o.useState(0),V=o.useMemo(()=>(y.current=ep(sp(y.current,q,dr()),q),y.current),[q,L]),ae=o.useRef("");o.useEffect(()=>{const K=np(V,q);if(!Object.keys(K).length)return;const k=JSON.stringify(K);k!==ae.current&&(ae.current=k,Pp(K))},[V,q]);const Q=o.useCallback(K=>{const k=mt(y.current,K);k.needsKey||(y.current={...y.current,[K]:{...k,needsKey:!0}},M(Y=>Y+1))},[]),ne=o.useCallback(K=>{if(K.action!=="disconnect"&&K.action!=="connect"&&K.action!=="reload")return;const k=mt(y.current,K.name),Y=Date.now()+La,se=K.action==="disconnect"?{...k,connectedAt:null,disconnectedAt:Date.now(),holdUntil:Y}:{...k,disconnectedAt:null,holdUntil:Y};y.current={...y.current,[K.name]:se},S(K.name,Hp(K)),M(ee=>ee+1)},[S]),ce=o.useCallback(async K=>{if(i==="catalog"){const k=Vp(K);if(!k)return null;try{const Y=await xo(I,k);return l.setQueryData(b,Y),ne(K),Y.operation?.id??null}catch(Y){throw Y instanceof ks&&Y.status===409&&l.invalidateQueries({queryKey:b}),Y}}if(i==="session"&&h){const k=await je({op:"mcp.control",sessionId:h,control:Gp(K)});ne(K);const Y=us.list(h),se=k?.data;return se&&"servers"in se&&Array.isArray(se.servers)?(l.setQueryData(Y,se),null):(l.invalidateQueries({queryKey:Y}),se&&"id"in se&&typeof se.id=="string"?se.id:null)}return null},[i,I,b,l,h,ne]),le=o.useCallback(async K=>{if(i==="catalog"&&O&&(K.action==="connect"||K.action==="disconnect"||K.action==="reload")){try{await je({op:"mcp.control",sessionId:O,control:{action:K.action,name:K.name,...K.action==="disconnect"?{confirmed:!0}:{}}})}catch(k){throw l.invalidateQueries({queryKey:b}),k}return ne(K),await l.invalidateQueries({queryKey:b}),null}return ce(K)},[i,O,l,b,ce,ne]),ue=o.useCallback(async(K,k,Y,se)=>{if(i==="catalog"){const ee=await _o(I,K,k,Y,se);if(ee.catalog&&l.setQueryData(b,ee.catalog),ee.code!=="saved")return{saved:!1,message:Pa(ee.code,ee.failed_ids,k)};try{await ce({action:"test",name:K})}catch{}return{saved:!0,message:null}}if(i==="session"&&h){const ee=await je({op:"mcp.credentials.store",sessionId:h,name:K,values:k,confirmedReplace:Y});if(ee.data?.code!=="saved")return{saved:!1,message:Pa(ee.data?.code,ee.data?.failed_ids??[],k)};try{await ce({action:"connect",name:K})}catch{}return{saved:!0,message:null}}return{saved:!1,message:null}},[i,I,b,l,ce,h]),we=i==="catalog"?j:$,B=o.useCallback(()=>{we.refetch()},[we]);return{enabled:i!==null,route:i,sessionId:i==="catalog"?O:h,borrowed:f,noConversation:i==="session"&&!h&&!p,document:q,isLoading:s.isLoading||i==="catalog"&&(C||j.isLoading)||i==="session"&&(h?$.isLoading:p),isError:we.isError,folderUnavailable:tp(c,A),refetch:B,readDocument:W,control:le,storeKeys:ue,memories:V,markNeedsKey:Q}}function Yp(t){if(t.route==="catalog")return t.queryClient.getQueryData(t.catalogKey);if(t.route==="session"&&t.sessionId){const s=t.queryClient.getQueryData(us.list(t.sessionId));return s?bs(s,t.sessionId):void 0}}const Qp=(t,s)=>{const a=t?.trim();if(!a)return null;const r=ko(a,s);return r.kind==="auth"?{kind:"matched",name:r.name,unresolved:null}:{kind:"miss",asked:a}},Zp=6,Yn="ui.settings.integrations.mcp_management_section.copy_section_title",Jp="ui.settings.integrations.mcp_management_section.copy_section_description",Xp={test:"test",connect:"reconnect",disconnect:"disconnect",reload:"reload",remove:"remove",sign_out:"disconnect",cancel:"cancel",login:"grant",reauth:"grant"},ef=({sessionId:t,sectionRef:s,highlightServer:a})=>{te();const r=Wp({sessionId:t}),{document:i,control:c,readDocument:d}=r,l=ai(),u=i?.servers??[],m=i?.operations??[],p=i?.project_scope_available??!1,[g,f]=o.useState(!1),[h,v]=o.useState(""),[_,N]=o.useState(null),[C,A]=o.useState({}),[D,I]=o.useState(null),[O,b]=o.useState(null),[z,P]=o.useState({kind:"ready"}),[U,x]=o.useState(null),[S,T]=o.useState(null),[j,H]=o.useState(!1),$=o.useRef({}),q=o.useRef({}),W=o.useRef({}),y=o.useRef(0),L=o.useRef(null),M=o.useRef(null),V=o.useRef(null),[ae,Q]=o.useState(null),[ne,ce]=o.useState(null),[le,ue]=o.useState(null),we=o.useCallback(()=>{const R=V.current;V.current=null,b(null),x(null),window.setTimeout(()=>{R?.isConnected&&R.focus()},0)},[]),B=o.useCallback(R=>{const E=window.document.activeElement;V.current=E instanceof HTMLElement?E:null,b(R)},[]),K=o.useCallback((R,E)=>{ce({name:R,waitForSignIn:E==="signed-in",until:Date.now()+Rt,reanchors:0}),we()},[we]),k=o.useMemo(()=>Qp(a,u.map(R=>R.name)),[a,u]),Y=k?.kind==="matched"?k.name:null,se=o.useRef(null),ee=o.useRef(null),ye=h.trim().toLowerCase(),Se=o.useMemo(()=>ye?u.filter(R=>R.name.toLowerCase().includes(ye)):u,[u,ye]),he=Xg(Se,m,r.memories),be=O?.kind==="sign_in"?u.find(R=>R.name===O.name)??null:null;o.useEffect(()=>{!Y||ee.current===Y||!h||v("")},[Y,h]),o.useEffect(()=>{!Y||ee.current===Y||Se.some(R=>R.name===Y)&&(ee.current=Y,se.current?.scrollIntoView({block:"center",behavior:"smooth"}))},[Y,Se]),o.useEffect(()=>{if(!U)return;const R=m.find(E=>E.id===U)??null;P({kind:"running",operation:R})},[m,U]);const ke=m.some(R=>R.status==="running"),ie=R=>{const E=window.document.activeElement;E&&E!==window.document.body&&E.isConnected||ce({name:R,waitForSignIn:!1,until:Date.now()+Rt,reanchors:0})},de=async(R,E,G)=>{N(R),A(({[R]:Ee,...Ne})=>Ne);let J=null,_e=!1;try{J=await G()}catch(Ee){_e=!0,A(Ne=>({...Ne,[R]:nn(Xp[E]??"status",Ee,ke)}))}finally{N(null),E!=="sign_out"&&(E!=="remove"||_e)&&ie(R)}return{operationId:J,failed:_e}},Z=R=>u.find(E=>E.name===R),oe=R=>{R.source.path&&jo(R.source.path)},me=async(R,E)=>{P({kind:"starting"}),x(null);try{const G=await c({action:E,name:R});G?x(G):P({kind:"running",operation:null})}catch(G){G instanceof ks&&G.code==="oauth_unsupported"&&r.markNeedsKey(R),P({kind:"refused",message:nn("grant",G,ke)})}},Ie=(R,E)=>{switch(E.kind){case"sign_in":case"reauth":{const G=m.find(J=>J.name===R.name&&J.status==="running");G&&Wt(G)?(P({kind:"running",operation:G}),x(G.id)):(P({kind:"ready"}),x(null)),B({kind:"sign_in",name:R.name,action:E.kind==="reauth"?"reauth":"login"});return}case"set_key":T(null),B({kind:"key",name:R.name,keyNames:R.auth.secret_refs.map(G=>G.id)});return;case"fix":oe(R);return;case"sign_out":I({name:R.name,kind:"sign_out"});return;default:{const G=E.kind;de(R.name,G,()=>c({action:G,name:R.name}))}}},Je=(R,E)=>{switch(E.kind){case"remove":case"sign_out":I({name:R.name,kind:E.kind});return;case"sign_in":case"reauth":case"set_key":Ie(R,{kind:E.kind,label:E.label});return;case"open_config":oe(R);return;case"copy_setup":navigator.clipboard.writeText(R.setup_prompt??"").then(()=>ds(n("ui.settings.integrations.mcp_management_section.setup_steps_copied_paste_them_into_a_chat"))).catch(()=>{});return;case"cancel":{const G=m.find(J=>J.name===R.name&&J.status==="running");G&&de(R.name,"cancel",()=>c({action:"cancel",operationId:G.id}));return}case"test":case"connect":case"disconnect":case"reload":{const G=E.kind;de(R.name,G,()=>c({action:G,name:R.name}));return}default:return}},Me=(R,E)=>{if(I(null),E==="remove"){const G=R.source.owned_scope;if(!G)return;const J=Se.findIndex(_e=>_e.name===R.name);de(R.name,"remove",()=>c({action:"remove",name:R.name,scope:G})).then(({operationId:_e,failed:Ee})=>{Ee||_e!==null||(ds(n("ui.settings.integrations.mcp_management_section.removed_name",{name:String(R.name)})),J>=0&&ue({index:J}))});return}de(R.name,"sign_out",()=>c({action:"logout",name:R.name})).then(()=>{ce({name:R.name,waitForSignIn:!1,until:Date.now()+Rt,reanchors:0})})},Ue=async R=>{try{return await c({action:"add",name:R.name,scope:R.scope,...R.mode==="command"?{command:R.command,args:R.args}:{url:R.url}}),f(!1),Q(R.name),null}catch(E){return nn("add",E,!1)}},Ge=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(Yn)}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:n(Jp)})]}),r.enabled&&u.length>0&&!g?e.jsxs(F,{ref:L,variant:"secondary",size:"sm",onClick:()=>f(!0),"data-tour-tag":"mcp-add-server",children:[e.jsx(kn,{"aria-hidden":"true"}),n("ui.settings.integrations.mcp_management_section.add_integration")]}):null]});if(!r.enabled&&!r.isLoading)return e.jsx(Re,{title:n(Yn),titleComponent:Ge,sectionRef:s,searchSection:"integrations",searchSectionLabel:n("ui.settings.navigation.settings_sidebar.integrations"),children:e.jsx(ge,{variant:"warning",children:n("ui.settings.integrations.mcp_management_section.integrations_need_a_newer_local_operator_backend_update_it_and_re")})});const Xe=e.jsx(xp,{existingNames:u.map(R=>R.name),projectScopeAvailable:p,projectLabel:i?.cwd?nf(i.cwd):null,onSubmit:Ue,onCancel:()=>{f(!1),window.setTimeout(()=>L.current?.focus(),0)}}),rt=O?Z(O.name):void 0,gt=Object.entries(C).filter(([R])=>!u.some(E=>E.name===R)),Nt=R=>A(({[R]:E,...G})=>G);o.useEffect(()=>{if(!ae)return;const R=$.current[ae];if(!R){u.some(E=>E.name===ae)&&(q.current[ae]?.focus(),Q(null));return}R.focus(),Q(null)},[ae,u]),o.useEffect(()=>{if(!le)return;const E=Se[Math.min(le.index,Se.length-1)]??Se.at(-1);if(E){const G=$.current[E.name]??q.current[E.name];if(!G)return;G.focus()}else L.current?.focus();ue(null)},[le,Se]);const et=o.useCallback((R,E)=>{const G=d()??i,J=G?.servers.find(He=>He.name===R.name),_e=G?.operations??[],Ee=J?J.status==="connecting"||wt(J.name,_e)!==null:!1;Ee&&J&&(y.current=E);const Ne=J?Vs(J,_e,r.memories):null;if(J&&R.waitForSignIn&&(Ne?.kind==="sign_in"||Ne?.kind==="reauth"))return"kept";const Oe=vp({hold:R,now:E,windowMs:Rt,rowMoving:Ee,lastMovingAt:y.current,candidate:J?jp({primary:Ne?$.current[J.name]:null,overflow:q.current[J.name]}):void 0,active:window.document.activeElement,body:window.document.body});if(!Oe.hold)return ce(null),"finished";if(!Oe.land)return"kept";ce({name:R.name,waitForSignIn:!1,until:Oe.hold.until,landedOn:Oe.land,reanchors:Oe.hold.reanchors});const ze=Oe.land;return window.setTimeout(()=>{ze.isConnected&&ze.focus()},0),"landed"},[d,i,r.memories]);return o.useEffect(()=>{if(!ne)return;et(ne,Date.now());let R=0,E=!1;const G=()=>{if(E)return;const J=wp({verdict:et(ne,Date.now()),watchMs:$a});J!==null&&(R=window.setTimeout(G,J))};return R=window.setTimeout(G,$a),()=>{E=!0,window.clearTimeout(R)}},[ne,et]),o.useEffect(()=>{if(!ne)return;const R=E=>{kp({target:E.target,row:W.current[ne.name]})&&ce(null)};return window.document.addEventListener("pointerdown",R,!0),()=>{window.document.removeEventListener("pointerdown",R,!0)}},[ne]),e.jsxs(Re,{title:n(Yn),titleComponent:Ge,sectionRef:s,searchSection:"integrations",searchSectionLabel:n("ui.settings.navigation.settings_sidebar.integrations"),children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[r.route==="session"&&r.borrowed?e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.integrations.mcp_management_section.borrowed_chat_notice",{chat:r.borrowed.title?.trim()||r.borrowed.session_id.slice(0,6)})}):null,r.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(F,{variant:"primary",size:"sm",onClick:()=>l("/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,r.isLoading?e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(Ce,{size:"lg",label:n("ui.settings.integrations.mcp_management_section.loading_integrations")})}):null,r.folderUnavailable?e.jsx(ge,{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,r.isError?e.jsx(ge,{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(F,{variant:"secondary",size:"sm",onClick:r.refetch,children:n("ui.settings.integrations.mcp_management_section.retry")})]})}):null,gt.map(([R,E])=>e.jsx(ge,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:E}),e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>Nt(R),children:n("ui.settings.integrations.mcp_management_section.dismiss")})]})},R)),g&&u.length>0?Xe:null,u.length>=Zp?e.jsxs("div",{className:"relative",children:[e.jsx(Ss,{"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 start-3 size-4 -translate-y-1/2 text-ink-dim"}),e.jsx(Le,{ref:M,value:h,onChange:R=>v(R.target.value),onKeyDown:R=>{R.key!=="Escape"||!h||(R.preventDefault(),v(""))},placeholder:n("ui.settings.integrations.mcp_management_section.search_integrations_placeholder",{integrations:Og(u.length)}),"aria-label":n("ui.settings.integrations.mcp_management_section.search_integrations"),className:"ps-9"})]}):null,k?.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(k.asked)})}):null,k?.kind==="matched"&&k.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(k.name),asked:String(k.unresolved)})}):null,i&&u.length===0&&!r.isLoading?g?Xe:e.jsxs("div",{className:"flex flex-col items-start gap-3 rounded-lg bg-surface p-6",children:[e.jsx(pi,{"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(F,{variant:"primary",size:"md",onClick:()=>f(!0),"data-tour-tag":"mcp-add-server",children:[e.jsx(kn,{"aria-hidden":"true"}),n("ui.settings.integrations.mcp_management_section.add_integration")]})]}):null,u.length>0&&Se.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(F,{variant:"secondary",size:"sm",onClick:()=>{v(""),window.setTimeout(()=>{(M.current??L.current)?.focus()},0)},children:n("ui.settings.integrations.mcp_management_section.clear_search")})]}):null,he.map(R=>e.jsxs("section",{"aria-labelledby":`integrations-group-${R.id}`,className:"flex flex-col gap-1.5",children:[e.jsxs("h3",{id:`integrations-group-${R.id}`,className:"px-1 text-ink-dim text-meta",children:[R.title," · ",R.rows.length]}),e.jsx("ul",{className:"flex flex-col divide-y divide-hairline overflow-hidden rounded-lg bg-surface",children:R.rows.map(E=>e.jsx(Ap,{row:E,operations:m,memories:r.memories,projectScopeAvailable:p,highlighted:E.name===Y,rowRef:G=>{W.current[E.name]=G,E.name===Y&&(se.current=G)},primaryRef:G=>{$.current[E.name]=G},overflowRef:G=>{q.current[E.name]=G},pending:_===E.name,failure:C[E.name]??null,confirm:D?.name===E.name?{kind:D.kind}:null,onPrimary:G=>Ie(E,G),onOverflow:G=>Je(E,G),onConfirm:()=>D&&Me(E,D.kind),onCancelConfirm:()=>{I(null),window.setTimeout(()=>{q.current[E.name]?.focus()},0)}},E.id))})]},R.id))]}),O?.kind==="sign_in"?e.jsx(Op,{name:O.name,action:O.action,keyRoute:be?Mn(be):!1,phase:z,onStart:()=>void me(O.name,O.action),onCancel:R=>void c({action:"cancel",operationId:R}).catch(()=>{}),onOpenLink:R=>void vo(R),onClose:R=>K(O.name,R)}):null,O?.kind==="key"?e.jsx(Cp,{name:O.name,keyNames:O.keyNames.length?O.keyNames:rt?.auth.secret_refs.map(R=>R.id)??[],keyless:O.keyNames.length===0,savedKeys:rt?.auth.secret_refs.filter(R=>R.state==="encrypted").map(R=>R.id),saving:j,failure:S,onClose:we,onSave:(R,E,G)=>{H(!0),T(null),r.storeKeys(O.name,R,E,G).then(J=>{if(!J.saved){T(J.message);return}b(null),ce({name:O.name,waitForSignIn:!1,until:Date.now()+Rt,reanchors:0})}).catch(J=>T(nn("key",J,!1))).finally(()=>H(!1))}}):null]})},Rt=4e3,tf=/^\/(?:Users|home)\/[^/]+(?=\/|$)/,nf=t=>t.replace(tf,"~"),ur="group/row flex min-h-11 items-center gap-3 border-b border-hairline px-2",mr="group/row flex min-h-11 items-center gap-3 border-b border-hairline px-2 hover:bg-row-hover",gr="group-hover/row:not-data-[state=checked]:border-ink-muted",pr=({sound:t,state:s,onToggle:a,inTabOrder:r})=>{te();const i=s==="playing",c=i?n("ui.settings.notifications.preview.stop",{name:t.label}):n("ui.settings.notifications.preview.play",{name:t.label});return e.jsx("button",{type:"button",className:pe(No,i&&"text-accent hover:text-accent"),"aria-label":c,"aria-pressed":i,tabIndex:r?void 0:-1,"data-preview":t.id,onClick:d=>{d.preventDefault(),d.stopPropagation(),a()},children:s==="loading"?e.jsx(Ce,{size:"sm"}):i?e.jsx(Ql,{className:"size-4","aria-hidden":"true"}):e.jsx(fi,{className:"size-4","aria-hidden":"true"})})},Ua=({sound:t,isDefault:s,preview:a,onPreview:r,describedBy:i,description:c,noPreview:d=!1})=>{te();const l=`notification-sound-${t.id}`,u=c?`${l}-description`:void 0;return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("label",{htmlFor:l,className:pe(mr,"cursor-pointer"),"data-sound-row":t.id,children:[e.jsx(Ri,{id:l,value:t.id,className:gr,"aria-describedby":[u,i].filter(Boolean).join(" ")||void 0,"aria-label":s?`${t.label}, ${n("ui.settings.notifications.list.default_tag")}`:void 0}),e.jsxs("span",{className:"flex min-w-0 flex-1 flex-col py-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-body text-ink",title:t.label,children:t.label}),s&&e.jsx(vt,{variant:"neutral",className:"shrink-0",children:n("ui.settings.notifications.list.default_tag")})]}),c&&e.jsx("span",{id:u,className:"text-body-sm text-ink-muted",children:c})]}),!d&&e.jsx(pr,{sound:t,state:a,onToggle:r,inTabOrder:!1})]}),a==="failed"&&e.jsx("output",{className:"block px-2 pt-1 pb-2 text-meta text-danger",children:n("ui.settings.notifications.preview.failed")})]})},sf=({sound:t,selected:s,preview:a,onPreview:r,mode:i,maxNameChars:c,describedBy:d,moreRef:l,onStartRename:u,onRename:m,onCancelRename:p,onStartRemove:g,onConfirmRemove:f,onCancelRemove:h})=>{te();const v=`notification-sound-${t.id}`,_=o.useRef(null),N=wo(t.duration_s);if(o.useEffect(()=>{if(i.kind==="confirm-remove"&&!i.removing){const C=setTimeout(()=>_.current?.focus(),0);return()=>clearTimeout(C)}},[i]),i.kind==="confirm-remove"){const C=s?n("ui.settings.notifications.custom.remove_confirm_selected",{name:t.label}):n("ui.settings.notifications.custom.remove_confirm",{name:t.label});return e.jsxs("div",{className:"flex flex-col gap-2 border-b border-hairline px-2 py-2","data-sound-row":t.id,"data-row-mode":"confirm-remove",onKeyDown:A=>{A.key==="Escape"&&(A.stopPropagation(),h())},children:[e.jsxs("div",{className:"flex min-h-7 flex-wrap items-center gap-x-3 gap-y-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-body-sm text-ink",children:C}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsxs(F,{variant:"danger",size:"sm",onClick:f,disabled:i.removing,children:[i.removing&&e.jsx(Ce,{size:"xs"}),n("ui.settings.notifications.custom.remove_action")]}),e.jsx(F,{ref:_,variant:"secondary",size:"sm",onClick:h,disabled:i.removing,children:n("ui.settings.notifications.custom.cancel")})]})]}),i.error&&e.jsx("output",{className:"block text-meta text-danger",children:i.error})]})}return i.kind==="renaming"?e.jsx("div",{className:"flex flex-col border-b border-hairline px-2 py-1","data-sound-row":t.id,"data-row-mode":"renaming",children:e.jsxs("div",{className:"flex min-h-9 items-center gap-3",children:[e.jsx("span",{"aria-hidden":"true",className:pe("inline-flex size-4 shrink-0 items-center justify-center rounded-full border",s?"border-accent":"border-control"),children:s&&e.jsx("span",{className:"size-2 rounded-full bg-accent"})}),e.jsx(af,{initial:t.label,maxNameChars:c,saving:i.saving,onSave:m,onCancel:p,serverError:i.error})]})}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("label",{htmlFor:v,className:pe(mr,"@container cursor-pointer"),"data-sound-row":t.id,children:[e.jsx(Ri,{id:v,value:t.id,className:gr,"aria-describedby":d,"aria-keyshortcuts":"F2 Delete",onKeyDown:C=>{C.key==="F2"?(C.preventDefault(),u()):C.key==="Delete"&&(C.preventDefault(),g())}}),e.jsx("span",{className:"min-w-0 flex-1 truncate py-2 text-body text-ink",title:t.label,children:t.label}),N&&e.jsx("span",{"aria-hidden":"true",className:"hidden shrink-0 font-mono text-mono-sm text-ink-dim @[420px]:inline",children:N}),e.jsx(pr,{sound:t,state:a,onToggle:r,inTabOrder:!0}),e.jsxs(zs,{children:[e.jsx(Fs,{asChild:!0,children:e.jsx(F,{ref:l,variant:"ghost",size:"icon",className:"size-11 shrink-0 text-ink-muted hover:text-ink","aria-label":n("ui.settings.notifications.custom.more",{name:t.label}),"data-sound-more":t.id,onClick:C=>C.stopPropagation(),children:e.jsx(As,{"aria-hidden":"true"})})}),e.jsxs(Ps,{align:"end",className:"min-w-40",children:[e.jsx(at,{onSelect:u,children:n("ui.settings.notifications.custom.rename")}),e.jsx(at,{onSelect:g,children:n("ui.settings.notifications.custom.remove")})]})]})]}),a==="failed"&&e.jsx("output",{className:"block px-2 pt-1 pb-2 text-meta text-danger",children:n("ui.settings.notifications.preview.failed")})]})},af=({initial:t,maxNameChars:s,saving:a,onSave:r,onCancel:i,serverError:c})=>{te();const[d,l]=o.useState(t),[u,m]=o.useState(null),p=o.useRef(null),g=o.useId();o.useEffect(()=>{const _=setTimeout(()=>{p.current?.focus(),p.current?.select()},0);return()=>clearTimeout(_)},[]);const f=u??c,h=o.useRef(!1);o.useEffect(()=>{a||(h.current=!1)},[a]);const v=()=>{const _=So(d,s);if(_){m(_==="ui.settings.notifications.custom.rename_long"?n(_,{max:s}):n("ui.settings.notifications.custom.rename_empty"));return}h.current=!0,r(d.trim())};return e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[e.jsx(Le,{ref:p,inputSize:"sm",value:d,disabled:a,"aria-label":n("ui.settings.notifications.custom.rename_label"),"aria-invalid":f?!0:void 0,"aria-describedby":f?g:void 0,onChange:_=>{l(_.target.value),m(null)},onKeyDown:_=>{_.nativeEvent.isComposing||(_.key==="Escape"?(_.preventDefault(),_.stopPropagation(),h.current=!0,i()):_.key==="Enter"&&(_.preventDefault(),v()))},onBlur:()=>{if(!(a||h.current)){if(d.trim()===t.trim()){h.current=!0,i();return}v()}}}),f&&e.jsx("p",{id:g,className:"text-meta text-danger",children:f})]})},rf=".wav,.flac,.mp3,.ogg,audio/wav,audio/flac,audio/mpeg,audio/ogg",Qn=t=>t instanceof Error&&t.message?t.message:"";function of(t){return t.kind==="error"&&t.refusal?{code:t.refusal.code,params:t.refusal.params}:{code:null}}const fr=o.forwardRef(({listing:t,selectedId:s,volume:a,canSelect:r,onSelect:i,onChanged:c,initialPreview:d,initialPending:l,initialSaveError:u,initialFailedChoice:m,initialMode:p},g)=>{te();const f=o.useMemo(()=>Co(t.sounds),[t.sounds]),h=o.useId(),v=o.useId(),_=t.limits,[N,C]=o.useState(null),[A,D]=o.useState(u??null),[I,O]=o.useState(m??null),b=o.useRef(null),z=o.useRef(null),P=N??s,U=o.useRef(P);U.current=P,o.useEffect(()=>{N!==null&&N===s&&C(null)},[N,s]);const x=o.useCallback(async w=>{try{await i(w),D(null),O(null)}catch(re){C(null),O(w),D(Qn(re))}},[i]),S=o.useCallback(w=>{b.current&&clearTimeout(b.current),z.current=w,b.current=setTimeout(()=>{b.current=null,z.current=null,x(w)},Mo)},[x]),T=o.useCallback(()=>{if(!b.current)return;clearTimeout(b.current),b.current=null;const w=z.current;z.current=null,w&&x(w)},[x]),j=()=>{b.current&&clearTimeout(b.current),b.current=null,z.current=null},H=o.useRef(T);H.current=T;const[$,q]=o.useState(d??null),W=o.useRef(null),y=o.useRef(0),L=Ct(w=>w.ownerId),M=Ct(w=>w.status);o.useEffect(()=>{!$||$.state!=="playing"||(L!==Yt||M==="ended")&&q(null)},[L,M,$]);const V=o.useCallback(()=>{W.current&&Eo(W.current),W.current=null},[]),ae=o.useCallback(()=>{y.current+=1,Ct.getState().stop(Yt),q(null)},[]),Q=o.useCallback(async(w,re)=>{if(w===ms)return;const fe=++y.current,Ae=Date.now();q({id:w,state:"loading"});try{const Ke=await is({op:"notification_sounds.audio",soundId:w,volume:Math.max(0,Math.min(100,Math.round(re)))},null);if(fe!==y.current)return;if(Date.now()-Ae>Ao){q(null);return}if(Ke.kind!=="bytes")throw new Error("no audio");V();const Fe=Ro(Ke.data,Ke.mimeType||"audio/wav");W.current=Fe;const ve=await Ct.getState().play(Yt,Fe,{onEnded:()=>q(null),fixedOutput:{volume:1,playbackRate:1},onError:()=>q({id:w,state:"failed"})});if(fe!==y.current)return;q(ve?{id:w,state:"playing"}:{id:w,state:"failed"})}catch{if(fe!==y.current)return;q({id:w,state:"failed"})}},[V]),ne=w=>{if($?.id===w&&$.state==="playing"){ae();return}Q(w,a)};o.useImperativeHandle(g,()=>({previewSelected:w=>{Q(P,w)}}),[Q,P]),o.useEffect(()=>()=>{H.current(),Ct.getState().stop(Yt),V()},[V]);const[ce,le]=o.useState(""),[ue,we]=o.useState(null),[B,K]=o.useState(p?{[p.id]:p.mode}:{}),k=w=>B[w]??{kind:"idle"},Y=(w,re)=>K(fe=>({...fe,[w]:re})),se=o.useRef(new Map),ee=w=>{let re=se.current.get(w);return re||(re={current:null},se.current.set(w,re)),re},ye=o.useRef(null),Se=o.useRef(null),[he,be]=o.useState(null);o.useEffect(()=>{if(!he)return;const w=setTimeout(()=>{he==="add"?ye.current?.focus():se.current.get(he)?.current?.focus(),be(null)},0);return()=>clearTimeout(w)},[he]);const ke=async(w,re)=>{Y(w.id,{kind:"renaming",saving:!0,error:null});try{await je({op:"notification_sounds.rename",id:w.id,name:re}),await c(),Y(w.id,{kind:"idle"}),be(w.id)}catch(fe){Y(w.id,{kind:"renaming",saving:!1,error:n("ui.settings.notifications.custom.rename_failed",{reason:Qn(fe)}).trim()})}},ie=async w=>{Y(w.id,{kind:"confirm-remove",removing:!0,error:null});const re=f.custom.map(fe=>fe.id);try{const fe=await je({op:"notification_sounds.remove",id:w.id});$?.id===w.id&&ae();const Ae=fe?.selection_reset===!0;Ae&&(j(),C(Io)),le(Ae?n("ui.settings.notifications.custom.removed_reset",{name:w.label}):n("ui.settings.notifications.custom.removed",{name:w.label}));const Ke=To(re,w.id);K(Fe=>{const{[w.id]:ve,...tt}=Fe;return tt}),await c(),be(Ke??"add")}catch(fe){Y(w.id,{kind:"confirm-remove",removing:!1,error:n("ui.settings.notifications.custom.remove_failed",{name:w.label,reason:Qn(fe)}).trim()})}},[de,Z]=o.useState(()=>(l??[]).map(({fileName:w,percent:re,...fe})=>({...fe,file:new File([],w)}))),[oe,me]=o.useState(()=>Object.fromEntries((l??[]).map(w=>[w.key,w.percent??0]))),Ie=o.useRef(Promise.resolve()),Je=o.useRef(0),Me=o.useRef(new Set),Ue=(w,re)=>Z(fe=>fe.map(Ae=>Ae.key===w?{...Ae,...re}:Ae)),Ge=w=>Z(re=>re.filter(fe=>fe.key!==w)),Xe=async w=>{if(Me.current.has(w.key))return null;if(w.file.size>_.max_bytes)return Ue(w.key,{phase:"error",refusal:{code:"too_large"}}),null;Ue(w.key,{phase:"uploading"}),me(Fe=>({...Fe,[w.key]:0}));let re;try{re=await lf(w.file,Fe=>me(ve=>({...ve,[w.key]:Math.round(Fe*100)})))}catch{return Ue(w.key,{phase:"error",refusal:{code:null}}),null}if(Me.current.has(w.key))return null;if(re.byteLength>_.max_bytes)return Ue(w.key,{phase:"error",refusal:{code:"too_large"}}),null;Ue(w.key,{phase:"processing"});const fe=await is({op:"notification_sounds.upload",fileName:w.file.name||"sound",name:w.stem},re).catch(()=>null);if(Me.current.has(w.key))return null;if(!fe||fe.kind!=="json")return Ue(w.key,{phase:"error",refusal:fe?of(fe):{code:null}}),null;const Ae=fe.body,Ke=typeof Ae?.result?.id=="string"?Ae.result.id:null;return await c(),Ge(w.key),Ke},rt=w=>{if(w.length===0)return;we(null);const re=f.custom.length+de.filter(ve=>ve.phase!=="error").length,{accepted:fe,overLimit:Ae}=$o(w,re,_.max_sounds),Ke=[...fe.map(ve=>({key:`upload-${++Je.current}`,file:ve,stem:na(ve.name,_.max_name_chars),phase:"queued"})),...Ae.map(ve=>({key:`upload-${++Je.current}`,file:ve,stem:na(ve.name,_.max_name_chars),phase:"error",refusal:{code:"limit_reached"}}))];Z(ve=>[...ve,...Ke]);const Fe=Ke.filter(ve=>ve.phase==="queued");Ie.current=Ie.current.then(async()=>{const ve=[];for(const tt of Fe){const St=await Xe(tt);St&&ve.push({id:St,name:tt.stem})}if(ve.length!==0){if(Fe.length===1&&ve.length===1)gt(ve[0]);else{const tt=n("ui.settings.notifications.custom.added_many",{count:ve.length});le(tt),we(tt)}ye.current?.focus()}})},gt=w=>{j(),C(w.id),x(w.id),Q(w.id,a),le(n("ui.settings.notifications.custom.added_one",{name:w.name}))},Nt=w=>{Ue(w.key,{phase:"queued",refusal:void 0}),Ie.current=Ie.current.then(async()=>{const re=await Xe({...w,phase:"queued"});re&>({id:re,name:w.stem})})},et=w=>{Me.current.add(w.key),Ge(w.key)},R=f.custom.length,E=R>=_.max_sounds,G=w=>$?.id===w?$.state:"idle",J=o.useRef({active:!1,repeated:!1}),_e=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Ee=w=>{_e.includes(w.key)&&(J.current.active=!0,w.repeat&&(J.current.repeated=!0))},Ne=w=>{if(!_e.includes(w.key))return;const re=J.current.repeated;J.current={active:!1,repeated:!1},re&&Q(U.current,a)},Oe=w=>{if(!J.current.active)return;const re=w.target;re?.getAttribute("role")==="radio"&&re.getAttribute("data-state")!=="checked"&&re.click()},ze=w=>{w.key==="Escape"&&$&&ae()},He=()=>Se.current?.click();return e.jsxs("div",{className:"flex flex-col gap-3",onKeyDown:ze,children:[e.jsx("span",{id:v,className:"sr-only",children:n("ui.settings.notifications.list.label")}),e.jsxs(dl,{"aria-labelledby":v,value:P,loop:!0,disabled:!r,onValueChange:w=>{w!==U.current&&(C(w),U.current=w,D(null),J.current.repeated||Q(w,a),S(w))},onKeyDownCapture:Ee,onKeyUp:Ne,onFocusCapture:Oe,onBlur:w=>{w.currentTarget.contains(w.relatedTarget)||T()},children:[e.jsx("p",{className:"px-2 pb-1 text-meta text-ink-dim",children:n("ui.settings.notifications.list.builtin")}),e.jsxs("div",{className:"border-t border-hairline",children:[f.builtin.map(w=>e.jsx(Ua,{sound:w,isDefault:w.is_default,preview:G(w.id),onPreview:()=>ne(w.id)},w.id)),f.system&&e.jsx("div",{className:"border-t border-hairline",children:e.jsx(Ua,{sound:{...f.system,label:n("ui.settings.notifications.list.system_name")},isDefault:!1,preview:"idle",onPreview:()=>{},noPreview:!0,description:n("ui.settings.notifications.list.system_description")})})]}),e.jsxs("div",{className:"flex items-baseline justify-between px-2 pt-5 pb-1",children:[e.jsx("p",{id:h,className:"text-meta text-ink-dim",children:n("ui.settings.notifications.list.custom")}),R>0&&e.jsx("p",{className:"font-mono text-mono-sm text-ink-dim",children:n("ui.settings.notifications.list.custom_count",{count:R,max:_.max_sounds})})]}),e.jsxs("div",{className:"border-t border-hairline",children:[R===0&&de.length===0&&e.jsx("p",{className:`${ur} text-body-sm text-ink-muted`,children:n("ui.settings.notifications.custom.empty")}),f.custom.map(w=>e.jsx(sf,{sound:w,selected:P===w.id,preview:G(w.id),onPreview:()=>ne(w.id),mode:k(w.id),maxNameChars:_.max_name_chars,describedBy:h,moreRef:ee(w.id),onStartRename:()=>Y(w.id,{kind:"renaming",saving:!1,error:null}),onRename:re=>ke(w,re),onCancelRename:()=>{Y(w.id,{kind:"idle"}),be(w.id)},onStartRemove:()=>Y(w.id,{kind:"confirm-remove",removing:!1,error:null}),onConfirmRemove:()=>void ie(w),onCancelRemove:()=>{Y(w.id,{kind:"idle"}),be(w.id)}},w.id)),de.map(w=>e.jsx(df,{row:w,percent:oe[w.key]??0,limitSeconds:_.max_duration_s,limitMegabytes:Math.round(_.max_bytes/(1024*1024)),maxSounds:_.max_sounds,onCancel:()=>et(w),onDismiss:()=>Ge(w.key),onChooseAnother:()=>{Ge(w.key),He()},onRetry:()=>Nt(w)},w.key))]})]}),A!==null&&e.jsx(ge,{variant:"warning",children:e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx("span",{children:n("ui.settings.notifications.save.failed",{reason:A}).trim()}),I&&e.jsx(F,{variant:"secondary",size:"sm",onClick:()=>{C(I),x(I)},children:n("ui.settings.notifications.retry")})]})}),e.jsxs("div",{className:"flex flex-col items-start gap-2 px-2",children:[e.jsx("input",{ref:Se,type:"file",multiple:!0,accept:rf,className:"hidden",tabIndex:-1,"aria-hidden":"true",onChange:w=>{const re=Array.from(w.target.files??[]);w.target.value="",rt(re)}}),e.jsxs(F,{ref:ye,variant:"secondary",size:"sm",disabled:E,onClick:He,children:[e.jsx(kn,{"aria-hidden":"true"}),n("ui.settings.notifications.custom.add")]}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:E?n("ui.settings.notifications.custom.full",{count:_.max_sounds}):n("ui.settings.notifications.custom.hint",{seconds:_.max_duration_s,megabytes:Math.round(_.max_bytes/(1024*1024))})})]}),ue&&e.jsx("p",{className:"px-2 text-body-sm text-ink-muted","aria-hidden":"true","data-added-notice":"",children:ue}),e.jsx("output",{"aria-live":"polite",className:"sr-only",children:ce})]})});fr.displayName="NotificationSoundList";function cf(t,s){switch(t){case"ui.settings.notifications.error.too_large":return n(t,{file:s.file,megabytes:s.megabytes});case"ui.settings.notifications.error.too_long":return n(t,{file:s.file,seconds:s.seconds,limit:s.limitSeconds});case"ui.settings.notifications.custom.full":return n(t,{count:s.maxSounds});case"ui.settings.notifications.error.unsupported_codec":case"ui.settings.notifications.error.unsupported_format":case"ui.settings.notifications.error.undecodable":case"ui.settings.notifications.error.silent":case"ui.settings.notifications.error.network":return n(t,{file:s.file});default:return n("ui.settings.notifications.error.network",{file:s.file})}}async function lf(t,s){if(typeof FileReader>"u"||t.size===0){const a=await t.arrayBuffer();return s(1),new Uint8Array(a)}return new Promise((a,r)=>{const i=new FileReader;i.onprogress=c=>{c.lengthComputable&&c.total>0&&s(c.loaded/c.total)},i.onerror=()=>r(i.error),i.onload=()=>{s(1),a(new Uint8Array(i.result))},i.readAsArrayBuffer(t)})}const df=({row:t,percent:s,limitSeconds:a,limitMegabytes:r,maxSounds:i,onCancel:c,onDismiss:d,onChooseAnother:l,onRetry:u})=>{te();const m=t.file.name||t.stem;if(t.phase==="error"){const g=t.refusal??{code:null},f=Lo(g),h=cf(f.key,{file:m,seconds:Oo(g,a),limitSeconds:a,megabytes:r,maxSounds:i});return e.jsxs("div",{className:"flex min-h-11 flex-wrap items-center gap-x-3 gap-y-1 border-b border-hairline px-2","data-pending-row":t.key,"data-pending-phase":"error",children:[e.jsx(Ei,{className:"size-4 shrink-0 text-danger","aria-hidden":"true"}),e.jsx("output",{className:"block min-w-0 flex-1 text-body-sm text-ink",children:h}),f.action==="retry"?e.jsx(F,{variant:"link",size:"sm",onClick:u,children:n("ui.settings.notifications.retry")}):e.jsx(F,{variant:"link",size:"sm",onClick:l,children:n("ui.settings.notifications.error.choose_another")}),e.jsx(F,{variant:"ghost",size:"icon",className:"size-11 shrink-0 text-ink-muted hover:text-ink","aria-label":n("ui.settings.notifications.error.dismiss"),onClick:d,children:e.jsx(ua,{"aria-hidden":"true"})})]})}const p=t.phase==="processing";return e.jsxs("div",{className:ur,"data-pending-row":t.key,"data-pending-phase":t.phase,children:[e.jsx("span",{className:"inline-flex size-4 shrink-0 items-center justify-center",children:e.jsx(Ce,{size:"xs"})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-body text-ink",title:t.stem,children:t.stem}),e.jsxs("span",{className:"flex shrink-0 items-center gap-2 text-meta text-ink-muted",children:[p?n("ui.settings.notifications.custom.finishing"):n("ui.settings.notifications.custom.uploading",{percent:s}),e.jsx(uf,{value:p?null:s})]}),p?e.jsx("span",{className:"size-11 shrink-0","aria-hidden":"true"}):e.jsx(F,{variant:"ghost",size:"icon",className:"size-11 shrink-0 text-ink-muted hover:text-ink","aria-label":n("ui.settings.notifications.custom.cancel_upload",{file:m}),onClick:c,children:e.jsx(ua,{"aria-hidden":"true"})})]})},uf=({value:t})=>e.jsx(Ci,{value:t,className:"w-16","aria-hidden":"true"}),Zn={list:[...Hr.settings,"notification-sounds"]};function mf(t){return t==="enabled"?"ready":t==="below-version"?"older":"pairing"}const gf=({resetErrorBoundary:t})=>(te(),e.jsx(ge,{variant:"warning",children:e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx("span",{children:n("ui.settings.notifications.load.failed",{reason:""}).trim()}),e.jsxs(F,{variant:"secondary",size:"sm",onClick:t,children:[e.jsx(Nn,{"aria-hidden":"true"}),n("ui.settings.notifications.retry")]})]})})),Jn=(t,s)=>typeof t?.value=="boolean"?t.value:s,Ka=(t,s)=>typeof t?.value=="number"&&Number.isFinite(t.value)?t.value:s,pf=({sectionRef:t,listPresets:s})=>{te();const a=kt(),r=jt(),i=Rs(),c=ii(r.data,"notification_sounds"),d=mf(c),l=De({queryKey:ut.all,queryFn:()=>je({op:"settings.list"}),enabled:d!=="pairing",staleTime:1e4}),u=De({queryKey:Zn.list,queryFn:async()=>{const B=await je({op:"notification_sounds.list"}),K=Ko(B);if(!K)throw new Error("unreadable notification sound listing");return K},enabled:d==="ready",staleTime:1e4}),m=l.data?.settings??[],p=o.useMemo(()=>new Map(m.map(B=>[B.key,B])),[m]),g=p.get(ot),f=p.get(Mt),h=o.useMemo(()=>Do(m),[m]),v=h.byKey["notifications.sound.enabled"],_=h.byKey["notifications.sound.id"],N=h.byKey["notifications.sound.volume"],[C,A]=o.useState({}),[D,I]=o.useState({}),O=o.useCallback((B,K)=>A(k=>({...k,[B]:K})),[]),b=o.useCallback((B,K)=>I(k=>({...k,[B]:K})),[]),z=o.useCallback(async()=>{await Promise.all([a.invalidateQueries({queryKey:ut.all}),a.invalidateQueries({queryKey:Zn.list})])},[a]),P=o.useRef(new Map),U=o.useRef(new Map),x=o.useCallback((B,K)=>{const k=P.current.get(B)??Promise.resolve();U.current.set(B,(U.current.get(B)??0)+1),O(B,!0),b(B,null);const Y=k.catch(()=>{}).then(async()=>{try{await je({op:"settings.edit",key:B,value:K}),await z()}catch(se){throw b(B,se instanceof Error&&se.message?se.message:n("ui.settings.notifications.save.failed_generic")),se}finally{const se=(U.current.get(B)??1)-1;U.current.set(B,se),se===0&&O(B,!1)}});return P.current.set(B,Y),Y},[z,O,b]),S=o.useCallback(async B=>{O(B,!0),b(B,null);try{await je({op:"settings.reset",key:B}),await z()}catch(K){throw b(B,K instanceof Error&&K.message?K.message:n("ui.settings.notifications.save.failed_generic")),K}finally{O(B,!1)}},[z,O,b]),T=zo(),j=o.useRef(null);o.useEffect(()=>{const B=T.configChange;if(!B)return;const K=`${B.epoch}:${B.seq}`;j.current!==K&&(j.current=K,B.changedKeys.some(k=>k==="notifications"||k.startsWith("notifications.")||k==="display"||k===ot||k===Mt)&&z())},[T.configChange,z]),o.useEffect(()=>{const B=()=>{a.invalidateQueries({queryKey:Zn.list})};return window.addEventListener("focus",B),()=>window.removeEventListener("focus",B)},[a]);const H=o.useRef(null),$=o.useRef(null),q=o.useRef(null),W=n("ui.settings.notifications.section.title"),y=n("ui.settings.notifications.section.description"),L=B=>e.jsx(Re,{title:W,icon:Dc,description:y,sectionRef:t,searchSection:"notifications",searchSectionLabel:W,searchIgnore:"notification rows are registry keys read from the daemon's own selection",children:B});if(d==="pairing"){const{sentence:B}=Ut(i??null,n("ui.settings.notifications.load.failed",{reason:""}).trim(),r.data?null:r.error??null);return L(e.jsx(ge,{variant:"warning",children:B}))}const M=Jn(g,!0),V=e.jsxs("div",{className:"flex flex-col gap-1",ref:$,children:[g&&e.jsx($t,{label:g.label,description:g.help||void 0,value:M,isSaving:!!C[ot],savingInPlace:!0,onChange:B=>x(ot,B).catch(()=>{})}),f&&e.jsx($t,{label:f.label,description:f.help||void 0,value:Jn(f,!0),isSaving:!!C[Mt],savingInPlace:!0,onChange:B=>x(Mt,B).catch(()=>{})}),[ot,Mt].map(B=>D[B]&&e.jsx("output",{className:"block text-meta text-danger",children:D[B]},B))]});if(l.isPending)return L(e.jsxs("div",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(Ce,{size:"sm"}),n("ui.settings.notifications.load.loading")]}));if(l.error){const{sentence:B}=Ut(i??null,n("ui.settings.notifications.load.failed",{reason:""}).trim(),l.error);return L(e.jsx(ge,{variant:"warning",children:e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx("span",{children:B}),e.jsxs(F,{variant:"secondary",size:"sm",onClick:()=>{z().then(()=>{a.getQueryState(ut.all)?.status==="success"&&I({})})},children:[e.jsx(Nn,{"aria-hidden":"true"}),n("ui.settings.notifications.retry")]})]})}))}const ae=e.jsx("h3",{className:"text-body font-medium text-ink",children:n("ui.settings.notifications.sound.heading")});if(d==="older")return L(e.jsxs("div",{className:"flex flex-col gap-6",children:[V,e.jsxs("div",{className:"flex flex-col gap-2 border-t border-hairline pt-6",children:[ae,e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.notifications.backend_older")})]})]}));const Q=u.data??null,ne=Jn(v,Q?.enabled??!0),ce=typeof _?.value=="string"?_.value:Q?.selected??"",le=Ka(N?{...N,value:N.default}:void 0,sa),ue=Ka(N,Q?.volume??sa),we=B=>{const{key:K,value:k}=Bo(B,le);return n(K,{value:k})};return L(e.jsxs("div",{className:"flex flex-col gap-6",children:[V,e.jsxs("div",{className:"flex flex-col gap-4 border-t border-hairline pt-6","data-notification-sound-group":"",children:[ae,!M&&e.jsx(ge,{variant:"info",children:e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx("span",{children:n("ui.settings.notifications.sound.gated")}),e.jsx(F,{variant:"secondary",size:"sm",disabled:!!C[ot],onClick:()=>{x(ot,!0).then(()=>Ba($.current,'[role="switch"]'),()=>{})},children:n("ui.settings.notifications.sound.gated_action")})]})}),v&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx($t,{searchRow:"notifications.sound.enabled",searchTerms:n("ui.settings.notifications.search_terms"),label:n("ui.settings.notifications.sound.enabled_label"),description:n("ui.settings.notifications.sound.enabled_description"),value:ne,isSaving:!!C["notifications.sound.enabled"],savingInPlace:!0,onChange:B=>x("notifications.sound.enabled",B).catch(()=>{})}),!ne&&e.jsx("p",{className:"text-body-sm text-ink-muted","data-sound-off-note":"",children:n("ui.settings.notifications.sound.enabled_off_note")}),D["notifications.sound.enabled"]&&e.jsx("output",{className:"block text-meta text-danger",children:D["notifications.sound.enabled"]})]}),N&&e.jsxs("div",{ref:q,className:"flex flex-col gap-1","data-search-row":"notifications.sound.volume","data-search-control":"",children:[e.jsx($c,{value:ue,label:n("ui.settings.notifications.volume.label"),description:n(qo(ue,ce)),min:0,max:100,step:Uo,pageStep:Po,icon:Fo(ue),readout:we,valueText:B=>n("ui.settings.notifications.volume.valuetext",{value:Math.round(B)}),disabled:ce===ms,isSaving:!!C["notifications.sound.volume"],savingInPlace:!0,trailing:Math.round(ue)!==Math.round(le)?e.jsx(F,{variant:"link",size:"sm",disabled:ce===ms,onClick:()=>{S("notifications.sound.volume").then(()=>{Ba(q.current,'input[type="range"]'),H.current?.previewSelected(le)},()=>{})},children:n("ui.settings.notifications.volume.reset")}):null,onChange:async B=>{await x("notifications.sound.volume",B),H.current?.previewSelected(B)}}),D["notifications.sound.volume"]&&e.jsx("output",{className:"block text-meta text-danger",children:D["notifications.sound.volume"]})]}),u.error?e.jsx(ge,{variant:"warning",children:e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx("span",{children:n("ui.settings.notifications.load.failed",{reason:u.error instanceof Error?u.error.message:""}).trim()}),e.jsxs(F,{variant:"secondary",size:"sm",onClick:()=>{u.refetch()},children:[e.jsx(Nn,{"aria-hidden":"true"}),n("ui.settings.notifications.retry")]})]})}):Q?e.jsx(Ii,{fallbackRender:gf,children:e.jsx(fr,{ref:H,listing:Q,selectedId:ce,volume:ue,canSelect:!!_,onSelect:B=>x("notifications.sound.id",B),onChanged:z,...s})}):e.jsxs("div",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(Ce,{size:"sm"}),n("ui.settings.notifications.load.loading")]}),h.missing.length>0&&e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.notifications.missing_rows",{count:h.missing.length,rows:h.missing.join(", ")})}),e.jsx(ff,{})]})]}))},ff=()=>{te();const[t,s]=o.useState("idle"),a=window.api?.sendTestNotification;return typeof a!="function"?null:e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[e.jsxs(F,{variant:"secondary",size:"sm",disabled:t==="sending",onClick:async()=>{s("sending");try{const r=await a();s(r.shown?"sent":"failed")}catch{s("failed")}},children:[t==="sending"&&e.jsx(Ce,{size:"xs"}),n("ui.settings.notifications.test.action")]}),e.jsx("output",{"aria-live":"polite",className:"text-body-sm text-ink-muted",children:t==="sent"?n("ui.settings.notifications.test.sent"):t==="failed"?n("ui.settings.notifications.test.failed"):""})]})};function Ba(t,s){requestAnimationFrame(()=>{t?.querySelector(s)?.focus()})}const Pt=new WeakMap,qa=new WeakSet;function hr(t,s){if(!qa.has(t)){qa.add(t);let r=xt(t);Ho(t,()=>{const i=xt(t);r!==i&&(r=i,Pt.delete(t))})}if(!s.startsWith(`${xt(t)}:`))return;const a=Pt.get(t);if(a?.key===s)return a;Pt.delete(t)}function hf(t,s,a){if(s.startsWith(`${xt(t)}:`)){if(hr(t,s),!Object.keys(a).length){Pt.delete(t);return}Pt.set(t,{key:s,fields:a})}}const xf=$e.object({display_name:$e.string(),title:$e.string(),description:$e.string(),timezone:$e.string()}),_f=xf.extend({account_id:$e.string(),display_label:$e.string(),avatar_url:$e.string().optional(),avatar:$e.object({source:$e.string(),hash:$e.string(),updated_at:$e.string().optional()}).optional()}),yf=$e.object({scope:$e.string().regex(/^[a-f0-9]{64}$/),profile:_f});class Ha extends Error{constructor(s,a){super("Account profile request failed"),this.code=s,this.status=a}}async function sn(t,s=null){const a=await is(t,s);if(a.kind!=="json")throw new Ha(a.kind==="error"?a.code:void 0,a.kind==="error"?a.status:null);const r=yf.parse(a.body.result);if(r.profile.account_id!==t.expectedAccountId)throw new Ha("account_mismatch",409);return r}const an={read:t=>sn({op:"account.profile",expectedAccountId:t}),update:(t,s,a)=>sn({op:"account.profile.update",expectedAccountId:t,scope:s,fields:a}),upload:(t,s,a)=>sn({op:"account.avatar.put",expectedAccountId:t,scope:s},a),remove:(t,s,a)=>sn({op:"account.avatar.delete",expectedAccountId:t,scope:s,mode:a,confirmed:!0})};function Xn(t,s){return Object.fromEntries(Object.keys(t).filter(a=>t[a]!==s[a]).map(a=>[a,s[a]]))}const xr={snapshot:(t,s)=>["account-profile",t,s]};function es(t,s,a){if(xt(t)!==s||Vo(t).accountId!==a.profile.account_id)throw new Error("Account authority changed");t.setQueryData(xr.snapshot(a.profile.account_id,s),a),t.setQueryData(aa.user(),r=>{if(!r||r.account.id!==a.profile.account_id)return r;const{display_name:i,title:c,description:d,timezone:l,avatar:u,avatar_url:m}=a.profile;return{...r,account:{...r.account,profile:{...r.account.profile,display_name:i,title:c,description:d,timezone:l,avatar:u},avatar_url:m}}}),t.invalidateQueries({predicate:r=>r.queryKey[0]==="team-bridge"&&r.queryKey.some((i,c)=>i==="account"&&r.queryKey[c+1]===a.profile.account_id)}),t.invalidateQueries({queryKey:aa.user()})}function bf(t=!0,s=()=>"personal"){const a=kt(),r=hi(),i=r.accountId,c=s(),d=De({queryKey:xr.snapshot(i??"unresolved",r.token),enabled:t&&!!i,retry:!1,queryFn:()=>Go(a,i,()=>an.read(i??""))}),l=()=>{if(!i||xt(a)!==r.token||s()!==c)throw new Error("Account authority changed")};return{...d,authority:r,async update(u){if(l(),!d.data||!i)throw new Error("Account profile unresolved");const m=await an.update(i,d.data.scope,u);return l(),es(a,r.token,m),m},async upload(u){if(l(),!d.data||!i)throw new Error("Account profile unresolved");const m=await an.upload(i,d.data.scope,u);return l(),es(a,r.token,m),m},async remove(u){if(l(),!d.data||!i)throw new Error("Account profile unresolved");const m=await an.remove(i,d.data.scope,u);return l(),es(a,r.token,m),m}}}const vf=1024*1024;function kf(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 r=t[a++];if(r===217||r===218||a+2>t.length)return null;if(r===1||r>=208&&r<=215)continue;const i=s.getUint16(a);if(i<2||a+i>t.length)return null;if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(r)&&i>=8)return{width:s.getUint16(a+5),height:s.getUint16(a+3)};a+=i}}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 Va(t){return!!(t&&t.width>0&&t.height>0&&t.width<=4096&&t.height<=4096&&t.width*t.height<=16e6)}async function jf(t){if(!t.size||t.size>vf||!["image/png","image/jpeg","image/webp"].includes(t.type))throw new Error("Profile image refused");const s=new Uint8Array(await t.arrayBuffer());if(!Va(kf(s)))throw new Error("Profile image dimensions refused");const a=await createImageBitmap(t,{imageOrientation:"from-image"});if(!Va(a))throw a.close(),new Error("Profile decoded image dimensions refused");return a}const rn=t=>({display_name:t.profile.display_name,title:t.profile.title,description:t.profile.description,timezone:t.profile.timezone}),yn={display_name:64,title:80,description:500},wf=t=>yn[t]*2,Ga=8,Wa=t=>t.formatToParts(new Date).find(s=>s.type==="timeZoneName")?.value;function Nf(){return[...new Set(["UTC",...Intl.supportedValuesOf("timeZone")])].map(t=>{const s=Wa(new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"shortOffset"})),a=Wa(new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"short"})),r=[s,a].filter(i=>!!i&&i!==t);return{id:t,name:t.split("_").join(" "),description:s,keywords:r}})}function Sf({snapshot:t,initialDraft:s,onDraftChange:a,photoUrl:r,onSave:i,onUpload:c,onRemove:d}){te();const l=o.useId(),[u,m]=o.useState(()=>rn(t)),[p,g]=o.useState(()=>({...rn(t),...s})),[f,h]=o.useState(!1),[v,_]=o.useState(!1),[N,C]=o.useState(),[A,D]=o.useState(),[I,O]=o.useState(),[b,z]=o.useState(),[P,U]=o.useState(),[x,S]=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)},j=o.useMemo(Nf,[]),[H,$]=o.useState(!1),[q,W]=o.useState(!1),[y,L]=o.useState(),M=kl(y),V=o.useRef(null),ae=o.useRef(void 0),Q=o.useRef(!0),ne=o.useRef(0),ce=Object.keys(Xn(u,p)).length>0;o.useEffect(()=>{a?.(Xn(u,p))},[u,p,a]);const le=I==="photo_invalid"?n("ui.settings.personal_profile.photo_invalid"):I?n("ui.settings.personal_profile.photo_error"):void 0,ue=t.profile.avatar,we=ue?.source==="uploaded"?"uploaded":"provider",B=f||v;o.useEffect(()=>(Q.current=!0,()=>{Q.current=!1,ne.current++,ae.current?.close()}),[]),o.useEffect(()=>{x&&(T[x].current?.focus(),S(void 0))});const K=()=>{ne.current++,ae.current?.close(),ae.current=void 0,L(void 0),O(void 0)},k=()=>{K(),S("photo")},Y=()=>{$(!1),S("cancel")},se=()=>{W(!1),S("remove")},ee=(Z,oe=!1)=>me=>{me.key!=="Escape"||oe||(me.preventDefault(),me.stopPropagation(),Z())},ye=async Z=>{if(!Z||B)return;const oe=++ne.current;O(void 0),_(!0),U(void 0);try{const me=await jf(Z);if(!Q.current||oe!==ne.current){me.close();return}ae.current?.close(),ae.current=me,L(me),W(!1)}catch{Q.current&&oe===ne.current&&O("photo_invalid")}finally{Q.current&&oe===ne.current&&_(!1)}},Se=async()=>{if(!Q.current||B||!ce)return;const Z=Xn(u,p),oe=Object.keys(yn).map(me=>me in Z&&[...p[me]].length>yn[me]?{field:me,reason:"length"}:me==="description"&&p.description.split(`
|
|
298
|
+
`).length>Ga?{field:me,reason:"lines"}:void 0).find(Boolean);if(oe){D(oe),S(oe.field);return}h(!0),C(void 0),D(void 0),z(void 0);try{const me=await i(Z);if(!Q.current)return;m(rn(me)),g(rn(me)),z("saved"),S("heading")}catch{Q.current&&C("save_error")}finally{Q.current&&h(!1)}},he=async Z=>{if(!Q.current||B)return;_(!0),O(void 0),U(void 0);const oe=ne.current,me=M.capture();try{if(Z.size>1024*1024)throw new Error("Profile crop too large");if(!await wl(M,me,()=>Z.arrayBuffer(),Je=>{if(!(!Q.current||oe!==ne.current))return c(new Uint8Array(Je))})||!Q.current)return;K(),U("photo_saved"),S("photo")}catch{Q.current&&O("photo_error")}finally{Q.current&&_(!1)}},be=async()=>{if(!(!Q.current||B)){_(!0),O(void 0),U(void 0);try{await d(we),Q.current&&(W(!1),U("photo_removed"),S("photo"))}catch{Q.current&&O("photo_error")}finally{Q.current&&_(!1)}}},ke=(Z,oe)=>{f||(g(me=>({...me,[Z]:oe})),z(void 0),C(void 0),A?.field===Z&&D(void 0),$(!1))},ie=Z=>A?.field!==Z?void 0:A.reason==="lines"?n("ui.settings.personal_profile.description_lines",{count:String(Ga)}):n("ui.settings.personal_profile.field_too_long",{count:String(yn[Z])}),de=(Z,oe,me)=>{const Ie=ie(Z);return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(qe,{htmlFor:`${l}-${Z}`,children:oe}),me({id:`${l}-${Z}`,value:p[Z],maxLength:wf(Z),readOnly:f,"aria-invalid":Ie?!0:void 0,"aria-describedby":Ie?`${l}-${Z}-error`:void 0}),Ie&&e.jsx("p",{id:`${l}-${Z}-error`,className:"text-meta text-danger",children:Ie})]})};return e.jsxs("section",{"aria-labelledby":`${l}-heading`,className:"flex min-w-0 flex-col gap-4","data-account-profile-editor":"",children:[e.jsx("h3",{ref:T.heading,id:`${l}-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:r?e.jsx("img",{alt:"",src:r,className:"size-full object-cover"}):t.profile.display_label.trim()[0]||"?"}),e.jsx(F,{ref:T.photo,variant:"secondary",size:"sm",disabled:B,onClick:()=>V.current?.click(),children:ue?.hash?n("ui.settings.personal_profile.replace"):n("ui.settings.personal_profile.choose")}),ue?.hash&&e.jsx(F,{ref:T.remove,variant:"ghost",size:"sm",disabled:B,onClick:()=>{W(!0),K(),S("remove_cancel")},children:n("ui.settings.personal_profile.remove")}),e.jsx("input",{ref:V,type:"file",accept:"image/png,image/jpeg,image/webp",className:"sr-only",tabIndex:-1,"aria-hidden":"true",disabled:B,onChange:Z=>{const oe=Z.currentTarget.files?.[0];Z.currentTarget.value="",ye(oe)}})]}),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:P==="photo_saved"?n("ui.settings.personal_profile.photo_saved"):P==="photo_removed"?n("ui.settings.personal_profile.photo_removed"):null}),y&&e.jsx("div",{onKeyDown:ee(k,v),children:e.jsx(jl,{source:y,outputEdge:256,onSave:Z=>void he(Z),onCancel:k,saving:v,error:le,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:(Z,oe)=>n("ui.settings.personal_profile.crop_instructions",{width:String(Z),height:String(oe)}),zoom:n("ui.settings.personal_profile.zoom"),zoomIn:n("ui.settings.personal_profile.zoom_in"),zoomOut:n("ui.settings.personal_profile.zoom_out"),zoomValue:Z=>n("ui.settings.personal_profile.zoom_value",{value:Z}),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:ee(se,v),children:[e.jsx("p",{className:"text-body-sm text-ink",children:we==="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(F,{variant:"danger",size:"sm",disabled:B,onClick:()=>void be(),children:v?n("ui.settings.personal_profile.saving"):n("ui.settings.personal_profile.remove")}),e.jsx(F,{ref:T.remove_cancel,variant:"secondary",size:"sm",disabled:B,onClick:se,children:n("ui.common.actions.cancel")})]})]}),I&&!y&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:le}),e.jsxs("form",{className:"flex min-w-0 flex-col gap-4",onSubmit:Z=>{Z.preventDefault(),Se()},"aria-busy":f,children:[de("display_name",n("ui.settings.personal_profile.display_name"),Z=>e.jsx(Le,{ref:T.display_name,...Z,onChange:oe=>ke("display_name",oe.target.value),autoComplete:"nickname"})),de("title",n("ui.settings.personal_profile.title"),Z=>e.jsx(Le,{ref:T.title,...Z,onChange:oe=>ke("title",oe.target.value),autoComplete:"organization-title"})),de("description",n("ui.settings.personal_profile.description"),Z=>e.jsx(Ds,{ref:T.description,...Z,onChange:oe=>ke("description",oe.target.value),rows:3})),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(qe,{asChild:!0,children:e.jsx("span",{"aria-hidden":"true",children:n("ui.settings.personal_profile.timezone")})}),e.jsx(Si,{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:j,selected:p.timezone?j.find(Z=>Z.id===p.timezone)??{id:p.timezone,name:p.timezone.split("_").join(" ")}:null,onSelect:Z=>ke("timezone",Z.id),onClear:()=>ke("timezone","")})]}),N&&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:ee(Y),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(F,{type:"button",variant:"secondary",size:"sm",onClick:()=>{g(u),$(!1),C(void 0),D(void 0),S("heading")},children:n("ui.settings.personal_profile.discard_action")}),e.jsx(F,{ref:T.keep_editing,type:"button",variant:"primary",size:"sm",onClick:Y,children:n("ui.settings.personal_profile.keep_editing")})]})]}):e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(F,{type:"submit",variant:"primary",size:"sm",disabled:!ce||B,children:f?n("ui.settings.personal_profile.saving"):n("ui.settings.personal_profile.save")}),e.jsx(F,{ref:T.cancel,type:"button",variant:"secondary",size:"sm",disabled:!ce||f,onClick:()=>{$(!0),S("keep_editing")},children:n("ui.common.actions.cancel")})]})]}),e.jsx("output",{className:"text-meta text-ink-muted empty:hidden",children:b==="saved"?n("ui.settings.personal_profile.saved"):null}),e.jsxs(F,{variant:"link",size:"sm",className:"w-fit",onClick:()=>Is("https://console.radienthq.com/dashboard/account"),children:[n("ui.settings.personal_profile.manage"),e.jsx(xi,{"aria-hidden":"true"})]})]})}function Cf(){return te(),e.jsx("output",{className:"text-body-sm text-ink-muted",children:n("ui.settings.personal_profile.loading")})}function Mf({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(F,{variant:"secondary",size:"sm",onClick:t,children:n("ui.common.actions.retry")})]})}const Ef=/^[a-f0-9]{16}$/;function Af(){te();const t=jt(),s=bt(t.data,"account_profile"),a=hi(),r=o.useCallback(()=>{try{return JSON.stringify(a.accountId?_l(window.localStorage,a.accountId)??"personal":"unresolved")}catch{return"unresolved"}},[a.accountId]),i=o.useCallback(v=>{const _=N=>{(N.key===bl||N.key===null)&&v()};return window.addEventListener("storage",_),()=>window.removeEventListener("storage",_)},[]),c=o.useSyncExternalStore(i,r,r),d=bf(s,r),l=o.useRef(null),u=d.data,m=kt(),p=`${d.authority.token}:${c}:${u?.scope??""}`,g=u?hr(m,p):void 0,f=u?.profile.avatar?.hash,h=zc(u&&f&&Ef.test(f)?{accountId:u.profile.account_id,hash:f}:null,64);return o.useEffect(()=>{!u||!yl(d.authority.token)||(l.current?.scrollIntoView({block:"start"}),l.current?.focus({preventScroll:!0}))},[u,d.authority.token]),s?!d.authority.accountId||d.isPending?e.jsx(Cf,{}):u?e.jsx("div",{ref:l,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(Sf,{snapshot:u,initialDraft:g?.fields,onDraftChange:v=>hf(m,p,v),photoUrl:h,onSave:d.update,onUpload:d.upload,onRemove:d.remove},p)}):e.jsx(Mf,{onRetry:()=>void d.refetch()}):e.jsx(F,{variant:"secondary",size:"sm",onClick:()=>Is("https://console.radienthq.com/dashboard/account"),children:n("ui.settings.personal_profile.manage")})}const Rf=({verification:t})=>{te();const{prices:s}=Yo(),a=t.grant_amount??s?.default_new_credits,{sentence:r,action:i}=Qo(t.signup_grant,Zo(a)),c=Jo(t.claim_url,Xo);return e.jsxs("div",{className:"mt-8 flex items-start gap-3 rounded-sm border border-hairline bg-surface p-3",children:[e.jsx(wn,{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:r}),e.jsx(F,{variant:"secondary",size:"sm",onClick:()=>Is(c),children:i})]})]})},If=({onAfterCredentialUpdate:t})=>{te();const{isAuthenticated:s,user:a,isLoading:r,accountRead:i,signOut:c}=Wo(),d=_i(g=>g.isSigningOut),l=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:f,verification:h}=a.radientUser,v=h!=null&&!h.email_verified&&h.signup_grant!=="claimed";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-8",children:e.jsx(Af,{})}),e.jsxs(Vt,{children:[e.jsx(Te,{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(vt,{variant:"success",className:"capitalize",children:g.status})]})}),e.jsx(Te,{label:n("ui.settings.account.radient_account_section.name"),value:g.name||n("ui.settings.account.radient_account_section.not_provided")}),e.jsx(Te,{label:n("ui.settings.account.radient_account_section.email"),value:g.email}),e.jsx(Te,{label:n("ui.settings.account.radient_account_section.account_id"),value:e.jsx("span",{className:"text-mono-sm",children:g.id})}),e.jsx(Te,{label:n("ui.settings.account.radient_account_section.tenant_id"),value:e.jsx("span",{className:"text-mono-sm",children:g.tenant_id})}),e.jsx(Te,{label:n("ui.settings.account.radient_account_section.provider"),value:e.jsx("span",{className:"capitalize",children:f.provider})}),e.jsx(Te,{label:n("ui.settings.account.radient_account_section.created"),value:yi(g.created_at)})]}),v&&h?e.jsx(Rf,{verification:h}):null,e.jsx("div",{className:"mt-8",children:e.jsx(Fc,{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(F,{variant:"danger",className:"mt-3",onClick:l,children:[e.jsx(Pc,{}),n("ui.settings.account.radient_account_section.sign_out_from_radient")]})]})]})})(),m=i==="refused"?n("ui.settings.account.radient_account_section.radient_refused_the_sign_in_this_app_is_holding_so_your_account_d"):bi(i)?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(vl,{titleText:"",onAfterCredentialUpdate:t,descriptionText:"",onSignInSuccess:()=>{}})})]});return r||d?e.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center gap-3",children:[e.jsx(Ce,{size:"lg",label:n("ui.settings.account.radient_account_section.loading_account")}),!d&&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})},ts={label:1,synonym:.8,key:.75,choice:.7,section:.6,description:.4},Tf={exact:1,prefix:.92,substring:.7,subsequence:.45};function _r(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 Ya(t){let s=!1;const a=t.split(" ").map(r=>{const i=_r(r);return i!==r&&(s=!0),i}).join(" ");return s?a:t}const Qa=new WeakMap,Za={exact:3,prefix:2,substring:1};function Lf(t,s,a){const r=_r(a),i=[Zt(t,a)];r!==a&&i.push(Zt(t,r)),s!==t&&(i.push(Zt(s,a)),r!==a&&i.push(Zt(s,r)));let c=null;for(const d of i)!d||d==="subsequence"||(!c||Za[d]>Za[c])&&(c=d);return c}const Of=12,$f=2;function Df(t,s){let a=0,r=-1,i=null,c=Qa.get(t.fields);if(!c){c={};for(const d of Object.keys(ts)){const l=t.fields[d];l&&(c[d]=Ya(l))}Qa.set(t.fields,c)}for(const d of s){let l=-1,u=null;for(const m of Object.keys(ts)){const p=t.fields[m];if(!p)continue;const g=Lf(p,c[m]??Ya(p),d);if(!g)continue;const f=ts[m]*Tf[g];f>l&&(l=f,u=m)}if(u===null)return null;a+=l,l>r&&(r=l,i=u)}return i?{score:a,reason:i}:null}function zf(t,s,a=Of){const r=Uc(s);if(r.length===0)return{results:[],total:0};const i=Kt(s),c=[];for(const d of t){const l=Df(d,r);if(!l)continue;const u=d.fields.label!==""&&d.fields.label===i;c.push({entry:d,reason:l.reason,score:u?l.score+$f:l.score})}return c.sort((d,l)=>l.score-d.score||d.entry.fields.label.length-l.entry.fields.label.length||d.entry.order-l.entry.order),{results:c.slice(0,Math.max(0,a)).map(({entry:d,reason:l})=>({entry:d,reason:l})),total:c.length}}function Ff(t){return Kt(t)===""}function Pf(t){const s=new Map;for(const i of t){const c=i.entry.sectionId||"",d=s.get(c);if(d){d.results.push(i);continue}s.set(c,{sectionId:c,sectionLabel:i.entry.sectionLabel,results:[i]})}const a=[...s.values()],r=a.filter(i=>i.sectionId==="");return[...a.filter(i=>i.sectionId!==""),...r]}const Uf={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 Kf(t){const{registry:s,sections:a,build:r=Am}=t,i=te();return o.useMemo(()=>r({registry:s,sections:a}),[r,s,a,i])}function Bf(){return nc()==="mac"?"⌘F":"Ctrl+F"}const qf=o.forwardRef(function({index:s,readRendered:a,onJump:r,onDismiss:i,className:c},d){te();const l=o.useRef(null),u=o.useRef(null),[m,p]=o.useState(null),[g,f]=o.useState(""),[h,v]=o.useState(!1),[_,N]=o.useState(-1),[C,A]=o.useState(""),D=o.useId();o.useImperativeHandle(d,()=>({focus:()=>{l.current?.focus(),v(!0)}}));const I=o.useCallback(()=>a?.()??[],[a]),O=o.useCallback(()=>{p(I())},[I]),b=o.useCallback(()=>{p(M=>M??I())},[I]),z=o.useCallback(()=>{const M=m;return M&&M.length>0?[...s,...M]:s},[s,m]),P=Ff(g),{results:U,total:x}=o.useMemo(()=>zf(z(),g),[z,g]),S=o.useMemo(()=>Pf(U),[U]),T=_<0||U.length===0?-1:Math.min(_,U.length-1),j=T>=0?U[T]:void 0,H=o.useMemo(()=>new Map(U.map((M,V)=>[M.entry.id,V])),[U]),$=o.useCallback(M=>{M!==void 0&&f(M),v(!1),N(-1),i?.()},[i]),q=o.useCallback(async M=>{if(await r(M)==="missing"){A(n("ui.settings.search.jump.missing"));return}A(""),v(!1),N(-1)},[r]),W=M=>`${D}-option-${M}`,y=M=>{switch(M.key){case"ArrowDown":M.preventDefault(),v(!0),N(V=>U.length===0?-1:V<0?0:(V+1)%U.length);return;case"ArrowUp":M.preventDefault(),v(!0),N(V=>U.length===0?-1:V<0?U.length-1:(V-1+U.length)%U.length);return;case"Home":if(!h)return;M.preventDefault(),N(0);return;case"End":if(!h)return;M.preventDefault(),N(Math.max(0,U.length-1));return;case"Enter":if(M.preventDefault(),!h){v(!0);return}{const V=j??U[0];V&&q(V.entry)}return;case"Escape":if(M.preventDefault(),g!==""){f(""),A(""),N(-1);return}$();return;default:return}},L=P?"":n("ui.settings.search.results.count",{count:x});return e.jsxs("div",{ref:u,className:pe("relative @container w-full",c),onBlur:M=>{const V=M.relatedTarget;V&&u.current?.contains(V)||(v(!1),N(-1),i?.())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ss,{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(Le,{ref:l,role:"combobox","aria-expanded":h,"aria-controls":h?D:void 0,"aria-activedescendant":h&&j?W(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(),v(!0)},onChange:M=>{b(),f(M.currentTarget.value),N(-1),A(""),v(!0)},onKeyDown:y})]}),h&&e.jsxs("div",{id:D,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:[C&&e.jsx("p",{"data-search-notice":"","aria-hidden":"true",className:"px-2 pt-2 pb-1 text-body-sm text-ink",children:C}),P?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(ec,{text:n("ui.settings.search.empty.shortcut",{shortcut:tc(Bf())})})})]}):U.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:M=>M.preventDefault(),onClick:()=>{$(""),l.current?.focus()},children:n("ui.settings.search.no_results.clear")})]}):e.jsxs(e.Fragment,{children:[S.map(M=>e.jsxs("div",{role:M.sectionLabel?"group":void 0,"aria-label":M.sectionLabel||void 0,children:[M.sectionLabel&&e.jsx("p",{className:"px-2 pt-2 pb-1 font-medium text-ink-muted text-meta",children:M.sectionLabel}),M.results.map(V=>{const ae=H.get(V.entry.id)??0,Q=ae===T;return e.jsxs("div",{id:W(ae),role:"option","aria-selected":Q,"data-search-result-id":V.entry.id,className:pe("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",Q?"bg-accent-wash outline-solid outline-1 -outline-offset-1 outline-control":"hover:bg-row-hover"),onMouseDown:ne=>ne.preventDefault(),onMouseEnter:()=>N(ae),onClick:()=>q(V.entry),children:[e.jsx("span",{className:"min-w-0 text-body-sm text-ink",children:V.entry.label}),e.jsxs("span",{className:"@[40rem]:shrink-0 @[40rem]:text-right text-meta text-ink-dim",children:[V.entry.sectionLabel&&n("ui.settings.search.row.section_hint",{section:V.entry.sectionLabel}),V.entry.sectionLabel&&" · ",n(Uf[V.reason]),V.entry.detail&&V.entry.detail!==V.entry.sectionLabel&&e.jsxs(e.Fragment,{children:[" · ",V.entry.detail]})]})]},V.entry.id)})]},M.sectionId||"no-section")),x>U.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:x-U.length})})]})]}),e.jsx("output",{"aria-live":"polite",className:"sr-only",children:C||L})]})});function Hf({metric:t,data:s}){return te(),e.jsx(sc,{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)}`:ac(a),children:e.jsx(qu,{data:s,children:e.jsx(li,{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 Vf={all:["desktop","tts-path-resolution"]};function Gf(t){return De({queryKey:Vf.all,queryFn:()=>je({op:"tts.paths"}),enabled:t,staleTime:Number.POSITIVE_INFINITY,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:Vr})}const Wf=["speech.voice.gender","speech.voice.tone","speech.voice.expressiveness","speech.voice.pace","speech.voice.language","speech.voice.accent","speech.voice.instructions"];function Ja(t){const s=new Map(t.map(i=>[i.key,i])),a=[],r=[];for(const i of Wf){const c=s.get(i);c?a.push(c):r.push(i)}return{rows:a,missing:r}}const Yf=["provider_tts_radient","provider_tts_elevenlabs","provider_tts_openai","none"];function Xa(t){return typeof t=="string"&&Yf.includes(t)}function Qf(t){if(t===null||typeof t!="object")return null;const s=t;if(!Xa(s.path)||typeof s.reason!="string"||typeof s.servable!="boolean"||!Array.isArray(s.rungs))return null;const a=[];for(const r of s.rungs){if(r===null||typeof r!="object")return null;const i=r;if(!Xa(i.path)||typeof i.available!="boolean"||typeof i.reason!="string")return null;a.push({path:i.path,available:i.available,reason:i.reason})}return{path:s.path,reason:s.reason,servable:s.servable,rungs:a}}const Zf={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 yr(t){return Zf[t]}function Jf(t){return{servable:t.servable,serving:t.path==="none"?null:t.path,reason:t.reason,rungs:t.rungs.map(s=>({path:s.path,name:yr(s.path),available:s.available,reason:s.reason}))}}const Xf="ui.settings.speech.speech_section.copy_backend_older_sentence",br="ui.settings.speech.speech_section.copy_unavailable_sentence",eh=({resetErrorBoundary:t})=>(te(),e.jsx(ge,{variant:"warning",children:e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx("span",{children:n(br)}),e.jsxs(F,{variant:"secondary",onClick:t,children:[e.jsx(Nn,{"aria-hidden":"true"}),n("ui.settings.speech.speech_section.try_again")]})]})}));function th(t){return t==="enabled"?"ready":t==="below-version"?"older":"pairing"}const nh=({sectionRef:t})=>{te();const s=jt(),a=Rs(),r=ii(s.data,"tts"),i=th(r),c=De({queryKey:ut.all,queryFn:()=>je({op:"settings.list"}),enabled:i==="ready",staleTime:1e4}),d=Gf(i==="ready"),{hasRadientApiKey:l,hasRadientSession:u,speechBlock:m}=ic(),p=`${u}:${l}`,g=o.useRef(p),f=d.refetch;o.useEffect(()=>{g.current!==p&&(g.current=p,f())},[p,f]);const h=c.data,v=o.useMemo(()=>Ja(h?.settings??[]),[h]),[_,N]=o.useState({}),[C,A]=o.useState({}),[D,I]=o.useState({});o.useEffect(()=>{h&&N(y=>{let L=!1;const M={...y};for(const V of Ja(h.settings).rows){const ae=y[V.key];if(ae&&ae.value!==Et(V).value)continue;const Q=Et(V);ae&&ae.value===Q.value&&ae.cascadeBase===Q.cascadeBase||(M[V.key]=Q,L=!0)}return L?M:y})},[h]);const O=(y,L)=>A(M=>({...M,[y]:L})),b=(y,L)=>I(M=>({...M,[y]:L})),z=async y=>{const L=_[y.key];if(!L)return;const M=cc(y,L);if(!M.ok){b(y.key,M.error);return}O(y.key,!0),b(y.key,null);try{await je(M.request),O(y.key,!1);const ae=(await c.refetch()).data?.settings.find(Q=>Q.key===y.key);ae&&N(Q=>{const ne=Q[y.key];return ne&&ne.value===L.value&&ne.cascadeBase===L.cascadeBase?{...Q,[y.key]:Et(ae)}:Q})}catch(V){O(y.key,!1),b(y.key,V instanceof Error?V.message:n("ui.settings.speech.speech_section.the_setting_could_not_be_saved"))}},P=async y=>{O(y.key,!0),b(y.key,null);try{await je({op:"settings.reset",key:y.key}),N(L=>({...L,[y.key]:Et({...y,value:y.default,is_default:!0})})),O(y.key,!1),await c.refetch()}catch(L){O(y.key,!1),b(y.key,L instanceof Error?L.message:n("ui.settings.speech.speech_section.the_setting_could_not_be_reset"))}},U=o.useMemo(()=>Qf(d.data),[d.data]),x=U?Jf(U):null,S=d.isSuccess&&U===null,T=(s.data?null:s.error)??null,j=c.error,H=n("ui.settings.speech.speech_section.speech_voicing"),$=n("ui.settings.speech.speech_section.how_the_assistant_sounds_when_it_speaks_aloud");if(i==="pairing"){const{sentence:y}=Ut(a??null,n("ui.settings.speech.speech_section.speech_settings_could_not_be_loaded"),T);return e.jsx(Re,{title:H,icon:Jt,description:$,sectionRef:t,children:e.jsx(ge,{variant:"warning",children:y})})}if(i==="older")return e.jsx(Re,{title:H,icon:Jt,description:$,sectionRef:t,children:e.jsx(ge,{variant:"warning",children:n(Xf)})});if(j||!h){const{sentence:y,remedy:L}=Ut(a??null,n("ui.settings.speech.speech_section.speech_settings_could_not_be_loaded"),j);return e.jsx(Re,{title:H,icon:Jt,description:$,sectionRef:t,children:e.jsx(ge,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:y}),L&&e.jsx(F,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{c.refetch()},children:n("ui.settings.speech.speech_section.retry")})]})})})}const q=x?!x.servable:m==="offline",W=x?x.rungs.find(y=>y.path===x.serving)??null:null;return e.jsx(Re,{title:H,icon:Jt,description:$,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:[d.isPending&&e.jsxs("p",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(Ce,{}),ia("checking")]}),(d.isError||S)&&!x&&m!=="offline"&&e.jsx(ge,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{children:[n(br)," ",d.error instanceof Error?d.error.message:""]}),e.jsx(F,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{d.refetch()},children:n("ui.settings.speech.speech_section.retry")})]})}),e.jsx(Ii,{fallbackRender:eh,resetKeys:[d.dataUpdatedAt],children:x&&e.jsxs(e.Fragment,{children:[e.jsxs(Vt,{children:[e.jsx(Te,{label:n("ui.settings.speech.speech_section.speaks_through"),value:x.serving?yr(x.serving):n("ui.settings.speech.speech_section.nothing_yet")}),e.jsx(Te,{label:n("ui.settings.speech.speech_section.availability"),value:x.servable?n("ui.settings.speech.speech_section.ready"):n("ui.settings.speech.speech_section.no_provider")})]}),x.reason&&x.reason!==W?.reason&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:x.reason}),e.jsx("ul",{className:"flex flex-col gap-1",children:x.rungs.map(y=>e.jsxs("li",{className:"flex flex-col gap-0.5 text-body-sm",children:[e.jsxs("span",{className:y.path===x.serving?"text-ink":"text-ink-muted",children:[y.name,e.jsxs("span",{className:y.path===x.serving?"text-ink-muted":"text-ink-dim",children:[" ",y.available?n("ui.settings.speech.speech_section.available"):n("ui.settings.speech.speech_section.not_available")]})]}),e.jsx("span",{className:"text-meta text-ink-dim",children:y.reason})]},y.path))})]})})]}),q&&e.jsx(ge,{variant:"warning",children:ia(m)}),e.jsx("div",{className:"flex flex-col gap-1",children:v.rows.map(y=>e.jsx(rc,{setting:y,draft:_[y.key]??Et(y),tier:oc(y),saving:!!C[y.key],error:D[y.key]??null,onDraftChange:L=>N(M=>({...M,[y.key]:L})),onSave:()=>{z(y)},onReset:()=>{P(y)}},y.key))}),v.missing.length>0&&e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.speech.speech_section.missing_voice_rows",{count:v.missing.length,rows:v.missing.join(", ")})})]})})},sh=lc().use(dc).use(uc),We="data-prompt-node",ns="data-prompt-opaque",ah=/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/,ih=/^&(?:#[xX][\da-fA-F]+|#\d+|[a-zA-Z][a-zA-Z\d]+);/,rh=/^[ \t]*(`{3,}|~{3,})/,oh=/^<([\w-]+)/,ch=/^([ \t]*(?:[-+*]|\d+[.)])[ \t]+\[)([ xX])(\])/,lh=/^[ \t]*(?:>[ \t]*)*(?:(?:[-+*]|\d+[.)])[ \t]+)?/,dh=/(?:[-+*]|\d+[.)])[ \t]+$/,uh=/(\r\n|\r|\n)/,mh=/^[ \t>]*/,gh=/\r$/,ei=new Set(["text","inlineCode","emphasis","strong","delete","link","linkReference","break","image","imageReference","footnoteReference"]),Ye=t=>t.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""");let ph=0;const fh=t=>{try{const s=new URL(t);return["https:","http:","mailto:"].includes(s.protocol)?t:null}catch{return null}};class hh{constructor(s,a=""){this.editSourceLabel=s,this.emptyTaskLabel=a}prefix=`prompt${++ph}n`;next=0;spans=new Map;snapshot={source:"",children:[],start:0,end:0};snapshots=new Map;allocate(s,a,r){const i=`${this.prefix}${this.next++}`,c=s.position?.start.offset??0,d=s.position?.end.offset??c,l=a.lastIndexOf(`
|
|
299
|
+
`,c-1)+1,m=(a.slice(l,c).match(lh)?.[0]??"").replace(dh,g=>" ".repeat(g.length)),p={id:i,baseId:i,type:s.type,start:c,end:d,raw:a.slice(c,d),children:[],opaque:!1,block:r,continuationPrefix:m};return this.spans.set(i,p),p}opaqueHtml(s){const a=s.block?"div":"span";return[`<${a} ${We}="${s.id}" ${ns}="true" contenteditable="false" role="button" tabindex="0" aria-label="${Ye(this.editSourceLabel)}"`,' class="cursor-pointer whitespace-pre-wrap break-words rounded-sm bg-sunken px-1 font-mono text-mono-sm text-ink-muted">',`${Ye(s.raw)}</${a}>`].join("")}renderNode(s,a,r="root",i=!1,c,d=0){const l=s,u=r==="root"||!ei.has(l.type)&&l.type!=="html",m=this.allocate(s,a,u);l.type==="text"&&(m.text=l.value??"");const p=`${We}="${m.id}"`,g=()=>(l.children??[]).map((h,v)=>{const _=this.next,N=this.renderNode(h,a,l.type,i,c,v);return m.children.push(`${this.prefix}${_}`),N}).join("");let f;switch(l.type){case"text":f=`<span ${p}>${Ye(l.value??"")}</span>`;break;case"paragraph":f=`<p ${p}>${g()}</p>`;break;case"heading":{const h=`h${Math.max(1,Math.min(6,l.depth??1))}`;f=`<${h} ${p}>${g()}</${h}>`;break}case"strong":f=`<strong ${p}>${g()}</strong>`;break;case"emphasis":f=`<em ${p}>${g()}</em>`;break;case"delete":f=`<del ${p}>${g()}</del>`;break;case"inlineCode":f=`<code ${p}>${Ye(l.value??"")}</code>`;break;case"code":f=`<pre ${p}><code${l.lang?` class="language-${Ye(l.lang)}"`:""}>${Ye(l.value??"")}
|
|
300
|
+
</code></pre>`;break;case"blockquote":f=`<blockquote ${p}>${g()}</blockquote>`;break;case"list":{const h=l.ordered?"ol":"ul";f=`<${h} ${p}${l.ordered&&l.start!==void 0?` start="${l.start}"`:""}>${g()}</${h}>`;break}case"listItem":{const h=_=>_.value??(_.children??[]).map(h).join(""),v=(l.children??[]).map(h).join(" ").trim()||this.emptyTaskLabel;f=`<li ${p}${l.checked!==null&&l.checked!==void 0?' class="task-list-item"':""}>${l.checked!==null&&l.checked!==void 0?`<input type="checkbox"${l.checked?" checked":""} aria-label="${Ye(v)}"/> `:""}${g()}</li>`;break}case"break":f=`<br ${p}/>`;break;case"thematicBreak":f=`<hr ${p}/>`;break;case"link":{const h=fh(l.url??"");h?f=`<span ${p} data-prompt-link="true" class="text-accent underline" title="${Ye(l.title??h)}">${g()}</span>`:(m.opaque=!0,f=this.opaqueHtml(m));break}case"linkReference":f=`<span ${p} class="text-accent underline">${g()}</span>`;break;case"table":{const v=(l.children??[]).map((_,N)=>{const C=this.next,A=this.renderNode(_,a,l.type,N===0,l.align);return m.children.push(`${this.prefix}${C}`),A});f=`<table ${p}><thead>${v[0]??""}</thead><tbody>${v.slice(1).join("")}</tbody></table>`;break}case"tableRow":f=`<tr ${p}>${g()}</tr>`;break;case"tableCell":{const h=i?"th":"td",v=c?.[d],_=v&&["left","center","right"].includes(v)?` align="${v}"`:"";f=`<${h} ${p}${_}>${g()}</${h}>`;break}default:m.opaque=!0,f=this.opaqueHtml(m)}return f}findSpan(s){return this.spans.get(s.getAttribute(We)??"")}skeleton(s,a=s){if(s!==a){const i=this.findSpan(s);if(i)return`@${i.baseId}`}const r=[...s.attributes].filter(i=>![We,ns].includes(i.name)&&!(s.tagName==="INPUT"&&i.name==="checked")).map(i=>`${i.name}=${i.value}`).sort();return`<${s.tagName} ${r.join("|")}>${[...s.childNodes].map(i=>i.nodeType===1?this.skeleton(i,a):i.nodeType===3?JSON.stringify(i.textContent):"").join("")}</${s.tagName}>`}capture(s,a){const r=window.document.createElement("template");r.innerHTML=s;for(const i of r.content.querySelectorAll(`[${We}]`)){const c=this.findSpan(i);c&&(c.html=i.outerHTML,c.skeleton=this.skeleton(i))}for(const i of a.children)this.snapshots.set(i,a);return r.innerHTML}renderSnapshot=s=>{const a=sh.parse(s),r=[],i=a.children.map(c=>{const d=this.next,l=this.renderNode(c,s);return r.push(`${this.prefix}${d}`),l}).join("");return this.snapshot={source:s,children:r,start:0,end:s.length},this.capture(i,this.snapshot)};render=s=>(this.spans.clear(),this.snapshots.clear(),this.renderSnapshot(s));insertSource=s=>{const a=this.snapshot,r=this.renderSnapshot(s);this.snapshot=a;const i=window.document.createElement("template");return i.innerHTML=r,i.content.children.length===1&&i.content.firstElementChild?.tagName==="P"?i.content.firstElementChild.innerHTML:r};ownedChildren(s){return[...s.querySelectorAll(`[${We}]`)].filter(a=>a.parentElement?.closest(`[${We}]`)===s)}serializeOwner(s){const a=s.cloneNode(!0),r=new Map;for(const c of[...a.querySelectorAll(`[${We}]`)]){const d=this.findSpan(c);if(!d||!d.opaque&&(!ei.has(d.type)||c.outerHTML!==d.html))continue;let l;do l=`PROMPTISLAND${this.prefix}${this.next++}END`;while(a.textContent?.includes(l));r.set(l,d.raw),c.replaceWith(window.document.createTextNode(l))}let i=oa(a.outerHTML);return r.size&&(i=i.replace(new RegExp([...r.keys()].join("|"),"g"),c=>r.get(c)??c)),i}patchText(s,a){const r=s.text;if(r===void 0)return null;if(r===a)return s.raw;const i=[];let c="";const d=(S,T)=>{const j=[];let H="";for(let $=0;$<S.length;){const q=$;let W=String.fromCodePoint(S.codePointAt($)??0);if($+=W.length,W==="\\"&&ah.test(S[$]??""))W=S[$++];else if(W==="&"){const y=S.slice(q).match(ih);if(y){const L=window.document.createElement("textarea");L.innerHTML=y[0],W=L.value,$=q+y[0].length}}j.push({rawStart:T+q,rawEnd:T+$,text:W}),H+=W}return{text:H,pieces:j}},l=s.raw.split(uh),u=r.split(`
|
|
301
|
+
`),m=[];let p=0;for(let S=0;S<u.length;S++){const T=l[S*2]??"",j=l[S*2+1]??"",H=S===0?0:T.match(mh)?.[0].length??0;let $=null,q=0;for(;q<=H;q++){const W=d(T.slice(q),p+q);if(W.text===u[S]){$=W;break}}if(!$)return null;m.push(T.slice(0,q));for(const W of $.pieces)i.push({...W,decodedStart:c.length,decodedEnd:c.length+W.text.length}),c+=W.text;p+=T.length,j&&(i.push({rawStart:p,rawEnd:p+j.length,decodedStart:c.length,decodedEnd:c.length+1,text:`
|
|
302
|
+
`}),c+=`
|
|
303
|
+
`,p+=j.length)}if(c!==r)return null;let g=0,f=0;for(;g<r.length&&g<a.length&&r[g]===a[g];)g++;for(;f<r.length-g&&f<a.length-g&&r[r.length-f-1]===a[a.length-f-1];)f++;const h=r.length-f,v=i.find(S=>S.decodedStart<g&&g<S.decodedEnd),_=i.find(S=>S.decodedStart<h&&h<S.decodedEnd),N=v?.decodedStart??g,C=_?.decodedEnd??h,A=a.slice(N,a.length-f+C-h),D=`${this.prefix}BEGIN`,I=`${this.prefix}END`,O=S=>{const T=oa(`<p>${D}${Ye(S)}${I}</p>`),j=T.indexOf(D),H=T.lastIndexOf(I);return j>=0&&H>=j?T.slice(j+D.length,H):null},b=A.split(`
|
|
304
|
+
`).map(O);if(b.some(S=>S===null))return null;const z=s.raw.includes(`\r
|
|
305
|
+
`)?`\r
|
|
306
|
+
`:`
|
|
307
|
+
`,P=m.find(S=>S.length>0)??s.continuationPrefix,U=b.join(z+P),x=S=>i.find(T=>T.decodedStart===S)?.rawStart??s.raw.length;return s.raw.slice(0,x(N))+U+s.raw.slice(x(C))}reconcile(s,a){const r=[...a.querySelectorAll("input[type=checkbox]")].some(l=>l.checked!==l.hasAttribute("checked"));if(s.opaque||a.outerHTML===s.html&&!r)return s.raw;if(s.type==="code"&&a.tagName==="PRE"&&a.querySelector("code")){const l=s.raw.indexOf(`
|
|
308
|
+
`),u=s.raw.slice(0,l).replace(gh,""),m=u.match(rh);if(l>=0&&m){const p=m[1],g=u.slice(0,m[0].length-p.length),f=u.slice(m[0].length),h=s.raw[l-1]==="\r"?`\r
|
|
309
|
+
`:`
|
|
310
|
+
`,v=s.raw.lastIndexOf(`
|
|
311
|
+
`)+1,_=s.raw.slice(v),N=_.startsWith(s.continuationPrefix)?_.slice(s.continuationPrefix.length).match(new RegExp(`^([ ]*)(${p[0]}{${p.length},})([ ]*)$`)):null,C=v>=l+1&&N!==null,A=a.querySelector("code")?.textContent??"",D=A.endsWith(`
|
|
312
|
+
`)?A.slice(0,-1):A,O=(D.match(new RegExp(`${p[0]}+`,"g"))??[]).reduce((x,S)=>Math.max(x,S.length+1),p.length),b=p[0].repeat(O),z=s.continuationPrefix+g,P=z+D.split(`
|
|
313
|
+
`).join(h+z),U=C&&N?h+s.continuationPrefix+N[1]+p[0].repeat(Math.max(O,N[2].length))+N[3]:s.raw.endsWith(`
|
|
314
|
+
`)?h:"";return g+b+f+h+P+U}}if(s.type==="text"){if(!a.children.length){const h=this.patchText(s,a.textContent??"");if(h!==null)return h}const l=`${this.prefix}BEGIN`,u=`${this.prefix}END`,m=a.cloneNode(!0);m.prepend(window.document.createTextNode(l)),m.append(window.document.createTextNode(u));const p=this.serializeOwner(m),g=p.indexOf(l),f=p.lastIndexOf(u);return g>=0&&f>=g?p.slice(g+l.length,f):null}if(a.tagName!==s.html?.match(oh)?.[1]?.toUpperCase()||this.skeleton(a)!==s.skeleton)return null;const i=this.ownedChildren(a);if(i.length!==s.children.length)return null;const c=[];if(s.type==="listItem"){const l=a.querySelector(":scope > input[type=checkbox]"),u=s.raw.match(ch);if(l&&u){const m=l.checked?u[2].trim()?u[2]:"x":" ";m!==u[2]&&c.push({start:u[1].length,end:u[1].length+1,value:m})}}for(let l=0;l<i.length;l++){const u=this.findSpan(i[l]),m=this.spans.get(s.children[l]);if(!u||!m||u.baseId!==m.baseId)return null;const p=this.reconcile(u,i[l]);if(p===null)return null;p!==m.raw&&c.push({start:m.start-s.start,end:m.end-s.start,value:p})}let d=s.raw;for(const l of c.sort((u,m)=>m.start-u.start))d=d.slice(0,l.start)+l.value+d.slice(l.end);return d}read=s=>{const a=[...s.childNodes].flatMap(m=>{if(m.nodeType===1)return[m];if(m.nodeType!==3||!m.textContent)return[];const p=window.document.createElement("span");return p.textContent=m.textContent,[p]}),r=a.map(m=>this.findSpan(m)).find(Boolean),i=(r&&this.snapshots.get(r.baseId))??this.snapshot,c=i.children;let d="",l=-1;for(const m of a){const p=this.findSpan(m),g=p?c.indexOf(p.baseId):-1,f=g>=0?this.spans.get(c[g]):void 0,h=l>=0?this.spans.get(c[l]):void 0,v=f&&g===l+1?i.source.slice(h?.end??i.start,f.start):d?`
|
|
315
|
+
|
|
316
|
+
`:"",_=p?this.reconcile(p,m)??this.serializeOwner(m):this.serializeOwner(m);d+=v+_,l=g}const u=l>=0?this.spans.get(c[l]):void 0;if(u&&l===c.length-1)d+=i.source.slice(u.end,i.end);else if(!a.length)return i.children.length?"":i.source;return d};getOpaque=s=>{const a=s.closest(`[${ns}]`),r=a&&this.findSpan(a);return r?.opaque?{id:r.id,source:r.raw}:null};replaceOpaque=(s,a,r,i)=>{if(this.read(s)!==r)return null;const c=this.spans.get(a),d=s.querySelector(`[${We}="${a}"]`);if(!c?.opaque||!d)return null;const l={...c,id:`${this.prefix}${this.next++}`,raw:i};this.spans.set(l.id,l);const u=window.document.createElement("template");u.innerHTML=this.opaqueHtml(l);const m=u.content.firstElementChild;return m?(l.html=m.outerHTML,l.skeleton=this.skeleton(m),d.replaceWith(m),this.read(s)):null}}const xh=({value:t,onChange:s,onLocalDraftActiveChange:a,sourceVersion:r=0,disabled:i=!1})=>{const c=o.useId(),[d,l]=o.useState(!1),[u]=o.useState(()=>new hh(n("ui.settings.model.system_prompt.source_edit"),n("ui.canvas.wysiwyg_markdown_editor.checklist"))),[m,p]=o.useState(0),[g,f]=o.useState(t),h=o.useMemo(()=>({id:`system-prompt-draft-${c}-${m}`,title:"system-prompt.md",path:"",type:"markdown",content:g}),[c,m,g]),v=o.useCallback(C=>s(C),[s]),_=o.useMemo(()=>({onChange:v,onLocalDraftActiveChange:a,sourceVersion:r,disabled:i,label:n("ui.settings.model.system_prompt.instructions"),codec:u,sourceLabel:n("ui.settings.model.system_prompt.source_edit"),sourceStaleLabel:n("ui.settings.model.system_prompt.source_stale")}),[v,i,u,a,r]),N=()=>{f(t),p(C=>C+1),l(!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(F,{variant:"ghost",className:d?void 0:"bg-sunken font-semibold text-ink","aria-pressed":!d,disabled:i,onClick:N,children:n("ui.settings.model.system_prompt.rich_text")}),e.jsx(F,{variant:"ghost",className:d?"bg-sunken font-semibold text-ink":void 0,"aria-pressed":d,disabled:i,onClick:()=>l(!0),children:n("ui.settings.model.system_prompt.source")})]}),d?e.jsx(Ds,{id:"app-system-prompt",name:"systemPrompt","aria-label":n("ui.settings.model.system_prompt.instructions"),value:t,disabled:i,onChange:C=>s(C.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",...i?{inert:""}:{},children:e.jsx(Kc,{document:h,draft:_,measure:"fill"},h.id)})]})},_h=()=>{te();const{data:t,isLoading:s,error:a}=Uu(),r=Ku(),[i,c]=o.useState(""),[d,l]=o.useState(!1),u=o.useRef(!1),m=o.useRef(""),[p,g]=o.useState(0),[f,h]=o.useState(!1),[v,_]=o.useState(0),N=o.useRef(null),[C,A]=o.useState(null);o.useLayoutEffect(()=>{const P=t?JSON.stringify([t.content,t.last_modified]):null;if(P!==N.current&&(N.current=P,_(x=>x+1)),u.current||f)return;const U=t?.content??"";U!==m.current&&(m.current=U,c(U),g(x=>x+1)),l(!1)},[t,f]);const D=o.useCallback(P=>{c(P),u.current=P!==m.current,l(u.current),A(null)},[]),I=async()=>{if(!(!d||r.isPending)){A(null);try{const P={content:i};await r.mutateAsync(P),m.current=i,u.current=!1,l(!1)}catch(P){A(P instanceof Error?P.message:n("ui.common.errors.system_prompt_update_unknown"))}}},O=()=>{u.current=!1,m.current=t?.content??"",c(m.current),g(P=>P+1),A(null),l(!1)},b=r.isPending,z=()=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(qe,{htmlFor:"app-system-prompt",children:n("ui.settings.model.system_prompt.instructions")}),e.jsx(xh,{value:i,onChange:D,onLocalDraftActiveChange:h,sourceVersion:v,disabled:b},p)]}),C&&e.jsx(ge,{variant:"danger",children:C}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(F,{variant:"primary",onClick:I,disabled:!d||b,children:[b?e.jsx(Ce,{size:"sm"}):e.jsx(ji,{}),b?n("ui.settings.model.system_prompt.saving"):n("ui.settings.model.system_prompt.save_changes")]}),e.jsx(F,{onClick:O,disabled:!d||b,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:Cs(t.last_modified)})]})]});return e.jsx(Re,{title:n("ui.settings.model.system_prompt.system_prompt"),icon:Nl,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(Ce,{size:"lg",label:n("ui.settings.model.system_prompt.loading_system_prompt")})}):a&&!t&&!d?e.jsx(ge,{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")})}):z()})},yh=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],bh=t=>yh.includes(t),vh=t=>{const s=[];let a=0;for(const r of t){const i=Math.max(0,Math.floor(r.count)),c=Math.max(1,Math.floor(r.columns));for(let d=0;d<i;d+=c)s.push({start:a+d,count:Math.min(c,i-d)});a+=i}return s},kh=({index:t,key:s,groups:a})=>{const r=vh(a),i=r.reduce((c,d)=>c+d.count,0);if(!Number.isInteger(t)||t<0||t>=i)return t;switch(s){case"Home":return 0;case"End":return i-1;case"ArrowLeft":return Math.max(0,t-1);case"ArrowRight":return Math.min(i-1,t+1);case"ArrowUp":case"ArrowDown":{const c=r.findIndex(u=>t>=u.start&&t<u.start+u.count),d=r[c+(s==="ArrowDown"?1:-1)];if(!d)return t;const l=t-r[c].start;return d.start+Math.min(l,d.count-1)}default:return t}},jh=`const x = {
|
|
317
|
+
ready: true
|
|
318
|
+
};`,wh=({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:[Lt.map(s=>e.jsx("div",{"data-accent-preview":s.id,className:"flex min-w-0 flex-wrap items-center gap-2 text-meta",children:s.preview==="interaction"?e.jsx("span",{className:"rounded-sm border border-control px-2 py-1",style:{color:`var(--lo-${pt(s.ink)})`,outline:`2px solid var(--lo-${pt(s.role)})`,outlineOffset:-2},children:n(s.usageKey)}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"rounded-sm px-2 py-1",style:{color:`var(--lo-${pt(s.ink)})`,background:`var(--lo-${pt(s.wash)})`},children:n("ui.settings.appearance.editor.preview.identity")}),e.jsxs("span",{style:{color:`var(--lo-${pt(s.ink)})`},children:[e.jsx("span",{"aria-hidden":"true",children:"● "}),n("ui.settings.appearance.editor.preview.category")]}),e.jsx("span",{style:{color:`var(--lo-${pt(s.ink)})`},children:n("ui.settings.appearance.editor.preview.meta")})]})},s.id)),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(ps,{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(F,{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(F,{variant:"primary",size:"sm",tabIndex:-1,children:n("ui.settings.appearance.editor.preview.primary")}),e.jsx(F,{size:"sm",variant:"secondary",tabIndex:-1,children:n("ui.settings.appearance.editor.preview.secondary")}),e.jsx(F,{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:jh})}),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(Le,{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(ps,{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")})]})})),Nh=()=>({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")}),on=t=>Nh()[t]??t,It=/^#[0-9A-Fa-f]{6}$/,Sh=({initial:t,onClose:s})=>{te();const a=o.useId().replace(/[^a-z0-9]/gi,""),r=`custom-draft-${a}`,[i,c]=o.useState(t),[d,l]=o.useState(t);o.useEffect(()=>{const k=setTimeout(()=>l(i),180);return()=>clearTimeout(k)},[i]);const[u,m]=o.useState({}),[p,g]=o.useState(null),[f,h]=o.useState(!0),[v,_]=o.useState(!1),[N,C]=o.useState(!1),[A,D]=o.useState(!1),I=o.useRef(null),O=o.useRef(!1),[b,z]=o.useState(""),[P,U]=o.useState(()=>{try{return localStorage.getItem("lo-theme-editor-advanced")==="true"}catch{return!1}}),[x,S]=o.useState([]),T=Ms(),j=xe(k=>k.contrast),H=xe(k=>k.accent),$=yt(i.base)?.palette;if(!$)throw new Error("unknown custom theme base");const q=o.useMemo(()=>vn($,i),[$,i]),W=o.useMemo(()=>Tn(q,i.base),[q,i.base]),y=o.useMemo(()=>vn($,d),[$,d]),L=o.useMemo(()=>Tn(y,i.base).findings.length===0,[y,i.base]),M=o.useMemo(()=>L?Gr(y,{contrast:j[$.mode],accent:H[$.mode],id:i.base,preserveSecondary:!0,paletteAccent:k=>yt(k)?.palette.accent}):{palette:y},[y,L,j,H,$.mode,i.base]),V=o.useMemo(()=>Tn(M.palette,i.base),[M.palette,i.base]),ae=$.mode==="dark"?Js(q.canvas).l>50:Js(q.canvas).l<50,Q=JSON.stringify(i)!==JSON.stringify(t)||Object.keys(u).length>0,ne=Object.values(u).some(k=>!It.test(k)),ce=!T.themes.some(k=>k.id===i.id)&&T.themes.length>=50,le=k=>{S(Y=>[...Y.slice(-19),i]),c(k),_(!1),C(!1)},ue=(k,Y)=>{const se=Object.prototype.hasOwnProperty.call(i.overrides,k)?"overrides":Lt.find(ee=>ee.role===k)?.storage??(Qt.includes(k)?"seeds":"overrides");le({...i,[se]:{...i[se],[k]:Y}}),m(ee=>{const ye={...ee};return delete ye[k],ye})},we=()=>{A||(Q?(I.current=document.activeElement instanceof HTMLElement?document.activeElement:null,D(!0)):s())},B=()=>{const k=pc($,i);k?(le(k),z(n("ui.settings.appearance.editor.validation_pass"))):C(!0)},K=(k,Y=on(k))=>{const se=V.readings.filter(he=>he.foreground===k||he.background===k).sort((he,be)=>he.value/he.floor-be.value/be.floor)[0],ee=u[k]??i.overrides[k]??i.seeds[k]??q[k],ye=Object.prototype.hasOwnProperty.call(i.overrides,k),Se=`${a}-${k}`;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:Y}),"aria-expanded":p===k,onClick:()=>{g(p===k?null:k),h(!0)},className:"size-8 shrink-0 rounded-sm border border-control focus-visible:outline-2 focus-visible:outline-accent",style:{background:q[k]}}),e.jsxs("label",{htmlFor:Se,className:"min-w-0 flex-1 text-body-sm",children:[Y,ye&&e.jsx("span",{className:"ms-1 text-meta text-ink-muted",children:n("ui.settings.appearance.editor.edited")})]}),e.jsx(Le,{id:Se,inputSize:"sm",value:ee,maxLength:7,"aria-invalid":!It.test(ee),className:"w-24 shrink-0 font-mono",onChange:he=>m(be=>({...be,[k]:he.target.value})),onBlur:()=>{It.test(ee)&&ue(k,ee.toUpperCase())},onKeyDown:he=>{he.key==="Enter"&&It.test(ee)&&(he.preventDefault(),ue(k,ee.toUpperCase()))}}),se&&e.jsx("span",{className:pe("text-meta",se.value<se.floor?"text-danger":"text-ink-muted"),title:`${n("ui.settings.appearance.editor.pair",{foreground:on(se.foreground),background:on(se.background)})} · ${n("ui.settings.appearance.editor.floor",{value:String(se.floor)})}`,children:n("ui.settings.appearance.editor.ratio",{value:se.value.toFixed(2)})}),(ye||Object.prototype.hasOwnProperty.call(i.seeds,k))&&e.jsx(F,{type:"button",size:"sm",variant:"ghost","aria-label":n("ui.settings.appearance.editor.reset_role",{role:Y}),onClick:()=>{const he={...i.seeds},be={...i.overrides};ye?delete be[k]:delete he[k],le({...i,seeds:he,overrides:be}),m(ke=>{const ie={...ke};return delete ie[k],ie})},children:n("ui.settings.appearance.editor.reset_role",{role:Y})})]}),!It.test(ee)&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.invalid_hex")}),p===k&&e.jsx("div",{className:"rounded-md border border-hairline bg-surface p-3",children:e.jsx(Qi,{value:q[k],onChange:he=>ue(k,he),onValidityChange:h,swatches:[...new Set([...Qt,...Lt.map(he=>he.role)])].map(he=>q[he])},k)})]},k)};return e.jsxs(e.Fragment,{children:[e.jsx(ul,{open:!0,onOpenChange:k=>{k||we()},children:e.jsxs(ml,{className:"flex w-full max-w-full flex-col gap-0 overflow-hidden sm:w-140 sm:max-w-140 text-ink",onKeyDown:k=>{if((k.metaKey||k.ctrlKey)&&k.key==="z"&&!(k.target instanceof HTMLInputElement||k.target instanceof HTMLTextAreaElement||k.target instanceof HTMLElement&&k.target.isContentEditable)){k.preventDefault();const Y=x.at(-1);Y&&(c(Y),S(se=>se.slice(0,-1)))}},children:[e.jsxs("div",{className:"shrink-0 border-hairline border-b pb-3 pe-8",children:[e.jsx(gl,{children:n("ui.settings.appearance.editor.edit")}),e.jsx(pl,{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(Le,{value:i.name,id:`${a}-name`,maxLength:60,onChange:k=>le({...i,name:k.target.value}),"aria-invalid":!i.name.trim()})]}),!i.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:it(i.base)?Qe[i.base].name:i.base})," ","·"," ",n($.mode==="dark"?"ui.settings.appearance.editor.mode_dark":"ui.settings.appearance.editor.mode_light")]}),ae&&e.jsx("p",{className:"text-meta text-warning",children:n("ui.settings.appearance.editor.mode_warning")}),e.jsx("style",{children:Ti(r,M.palette)}),e.jsx(wh,{id:r}),e.jsxs("p",{className:"text-meta text-ink-muted",children:[L&&n("ui.settings.appearance.editor.contrast_note",{value:String(j[$.mode])})," ",L&&H[$.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:ne||!f||W.findings.length?"text-danger":"text-success",children:ne?n("ui.settings.appearance.editor.invalid_hex"):f?W.findings.length?n("ui.settings.appearance.editor.validation_summary",{count:W.findings.length}):n("ui.settings.appearance.editor.validation_pass"):n("ui.settings.appearance.editor.picker.invalid_channels")}),!ne&&f&&W.findings.length>0&&e.jsx(F,{type:"button",variant:"secondary",size:"sm",onClick:B,children:n("ui.settings.appearance.editor.adjust")})]}),N&&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.accents")}),Lt.map(k=>e.jsxs("div",{"data-accent-family":k.id,children:[e.jsx("p",{className:"mt-2 text-meta text-ink-muted",children:n(k.usageKey)}),K(k.role,n(k.labelKey))]},k.id)),e.jsx("p",{className:"mt-2 text-meta text-ink-muted",children:n("ui.settings.appearance.editor.accent.effective")})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-body-sm font-medium",children:n("ui.settings.appearance.editor.essentials")}),Qt.filter(k=>!Xs(k)).map(k=>K(k))]}),e.jsxs("section",{children:[e.jsxs("button",{type:"button","aria-expanded":P,className:"flex w-full items-center justify-between text-start text-body-sm font-medium",onClick:()=>{U(!P);try{localStorage.setItem("lo-theme-editor-advanced",String(!P))}catch{}},children:[n("ui.settings.appearance.editor.advanced"),e.jsx("span",{"aria-hidden":"true",children:P?"−":"+"})]}),e.jsx("p",{className:"mt-2 text-meta text-ink-muted",children:n("ui.settings.appearance.editor.pinned_note")}),P&&e.jsxs(e.Fragment,{children:[Lt.map(k=>e.jsxs("section",{className:"mt-3","data-accent-variants":k.id,children:[e.jsxs("h4",{className:"text-body-sm font-medium",children:[n(k.labelKey)," ·"," ",n("ui.settings.appearance.editor.accent.variants")]}),k.preview==="identity"&&e.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:n("ui.settings.appearance.editor.accent.secondary_help")}),k.variants.map(Y=>K(Y))]},k.id)),mc.filter(k=>!Qt.includes(k)&&!Xs(k)).map(k=>K(k)),["overlayShadow","scrim"].map(k=>e.jsxs("label",{className:"flex flex-col gap-1 py-2 text-body-sm",children:[on(k),e.jsx("input",{type:"range",min:0,max:1,step:.01,value:i.overrides[k]??Number(/\/\s*([\d.]+)/.exec($[k])?.[1]??.5),onChange:Y=>le({...i,overrides:{...i.overrides,[k]:Y.target.value}}),className:"h-7 accent-accent"})]},k))]})]})]})}),e.jsxs("div",{className:"shrink-0 border-hairline border-t pt-3",children:[e.jsx("output",{className:"text-meta text-ink-muted",children:b}),v&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.save_error")}),ce&&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(F,{variant:"ghost",onClick:we,children:n("ui.settings.appearance.editor.cancel")}),e.jsx(F,{variant:"primary",disabled:!i.name.trim()||i.name.length>60||ne||!f||W.findings.length>0||ce,onClick:()=>{try{const k={...i,name:i.name.trim(),updatedAt:Date.now()};gc(k),xe.setState({themeName:it(k.base)?k.base:"localOperatorDark",customThemeId:k.id});for(const Y of Object.values(k.seeds))Yi(Y);ws(n("ui.settings.appearance.editor.saved")),s()}catch{_(!0)}},children:n("ui.settings.appearance.editor.save")})]})]})]})}),e.jsx(dn,{open:A,onOpenChange:D,children:e.jsxs(un,{onCloseAutoFocus:k=>{!O.current&&I.current?.isConnected&&(k.preventDefault(),I.current.focus({preventScroll:!0}))},children:[e.jsx(mn,{children:n("ui.settings.appearance.editor.discard_title")}),e.jsx(gn,{children:n("ui.settings.appearance.editor.discard_description")}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(F,{variant:"secondary",onClick:()=>D(!1),children:n("ui.settings.appearance.editor.keep_editing")}),e.jsx(F,{variant:"danger",onClick:()=>{O.current=!0,s()},children:n("ui.settings.appearance.editor.discard")})]})]})})]})},Ch=({loading:t,error:s,count:a,onRetry:r})=>(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(F,{variant:"ghost",size:"sm",onClick:r,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),ti=()=>`custom-${crypto.randomUUID().replace(/-/g,"").slice(0,20)}`,Mh=()=>{const t=Ms(),s=xe(b=>b.customThemeId),a=xe(b=>b.themeName),[r,i]=o.useState(null),[c,d]=o.useState(null),[l,u]=o.useState(null),[m,p]=o.useState(!1),[g,f]=o.useState(""),[h,v]=o.useState(""),[_,N]=o.useState(""),C=b=>{const z=t.themes.find(x=>x.id===b),P=z?.base??b;if(!it(P))return;const U=ra(n("ui.settings.appearance.editor.new_name",{name:z?.name??Qe[P].name}),t.themes);i({format:"local-operator-theme",version:1,id:ti(),name:U,base:P,seeds:{...z?.seeds},overrides:{...z?.overrides},updatedAt:Date.now()})},A=b=>{try{const z=_c(b,it,{id:ti()});z.name=ra(z.name,t.themes),p(!1),N(""),i(z)}catch(z){const P=z instanceof Error?z.message:"import_error",U={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")};N(U[P]??n("ui.settings.appearance.editor.import_error"))}},D=(b,z=!0)=>{const P=t.themes.find(x=>x.id===b),U=P?.name??(it(b)?Qe[b].name:b);return e.jsxs(zs,{children:[e.jsx(Fs,{asChild:!0,children:e.jsx(F,{type:"button",variant:"ghost",size:"icon-sm",tabIndex:z?0:-1,"aria-label":n("ui.settings.appearance.editor.more",{name:U}),className:"absolute end-1 top-1 z-10 bg-canvas",children:e.jsx(As,{size:14})})}),e.jsxs(Ps,{align:"end",children:[P&&e.jsx(at,{onSelect:()=>i(P),children:n("ui.settings.appearance.editor.edit")}),e.jsx(at,{onSelect:()=>C(b),children:n("ui.settings.appearance.editor.duplicate")}),P&&e.jsxs(e.Fragment,{children:[e.jsx(at,{onSelect:()=>{u(P),N(""),v("")},children:n("ui.settings.appearance.editor.export")}),e.jsx(at,{onSelect:()=>{d(P),N("")},children:n("ui.settings.appearance.editor.delete")})]})]})]})},I=e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(F,{variant:"secondary",size:"sm",onClick:()=>{const b=t.themes.find(z=>z.id===s);b?i(b):C(a)},children:n("ui.settings.appearance.editor.customize")}),e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>{p(!0),N(""),f("")},children:n("ui.settings.appearance.editor.import")})]}),e.jsx(Ch,{loading:t.loading,error:t.error,count:t.themes.length,onRetry:fc})]}),O=e.jsxs(e.Fragment,{children:[r&&e.jsx(Sh,{initial:r,onClose:()=>i(null)},r.id),e.jsx(dn,{open:!!c,onOpenChange:b=>{b||d(null)},children:e.jsxs(un,{children:[e.jsx(mn,{children:n("ui.settings.appearance.editor.delete_title",{name:c?.name??""})}),e.jsx(gn,{children:n("ui.settings.appearance.editor.delete_description")}),_&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:_}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(F,{variant:"secondary",onClick:()=>d(null),children:n("ui.settings.appearance.editor.cancel")}),e.jsx(F,{variant:"danger",onClick:()=>{if(c)try{hc(c.id),s===c.id&&xe.setState({customThemeId:null}),d(null),ws(n("ui.settings.appearance.editor.deleted"))}catch{N(n("ui.settings.appearance.editor.save_error"))}},children:n("ui.settings.appearance.editor.delete")})]})]})}),e.jsx(dn,{open:m,onOpenChange:p,children:e.jsxs(un,{children:[e.jsx(mn,{children:n("ui.settings.appearance.editor.import_title")}),e.jsx(gn,{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":!!_,value:g,onChange:b=>f(b.target.value),className:"min-h-48 w-full rounded-sm border border-control bg-sunken p-2 font-mono text-meta"})]}),_&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:_}),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 b=>{const z=b.target.files?.[0];if(z){if(z.size>xc){N(n("ui.settings.appearance.editor.import_size"));return}try{A(await z.text())}catch{N(n("ui.settings.appearance.editor.import_read"))}b.target.value=""}}})]}),e.jsx(F,{disabled:!g.trim(),onClick:()=>A(g),children:n("ui.settings.appearance.editor.import_submit")})]})]})}),e.jsx(dn,{open:!!l,onOpenChange:b=>{b||u(null)},children:e.jsxs(un,{children:[e.jsx(mn,{children:n("ui.settings.appearance.editor.export_title",{name:l?.name??""})}),e.jsx(gn,{children:n("ui.settings.appearance.editor.export_title",{name:l?.name??""})}),_&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:_}),e.jsx("textarea",{dir:"ltr","aria-label":n("ui.settings.appearance.editor.import_text"),readOnly:!0,value:l?Ln(l):"",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:h}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(F,{variant:"secondary",onClick:()=>{if(l)try{const b=URL.createObjectURL(new Blob([Ln(l)],{type:"application/json"})),z=document.createElement("a");z.href=b,z.download=`${l.name.replace(/[^a-z0-9_-]/gi,"-").slice(0,60)||"theme"}.json`,z.click(),setTimeout(()=>URL.revokeObjectURL(b),1e3)}catch{N(n("ui.settings.appearance.editor.export_error"))}},children:n("ui.settings.appearance.editor.export_file")}),e.jsx(F,{onClick:async()=>{if(l)try{await navigator.clipboard.writeText(Ln(l)),v(n("ui.settings.appearance.editor.export_copied"))}catch{N(n("ui.settings.appearance.editor.clipboard_error"))}},children:n("ui.settings.appearance.editor.export_copy")})]})]})})]});return{library:t,active:s,header:I,menu:D,dialogs:O}},Eh={localOperatorDark:Yd,localOperatorLight:xu,dracula:lu,dune:jd,sage:Ud,monokai:qc,tokyoNight:Xd,iceberg:uu,radient:Od,neon:bc,obsidian:Li,synth:$l,catppuccinMocha:cd,catppuccinLatte:Hd,tokyoNightStorm:ed,gruvbox:ql,nord:Fu,oneDark:Ll,solarizedDark:fu,rosePine:Cd,rosePineMoon:Gd,rosePineDawn:rd,alucard:Ed,gruvboxLight:fd,tokyoNightDay:Zd,oneLight:Bd,catppuccinFrappe:gd,catppuccinMacchiato:Dd,palenight:yc,everforest:Ru,everforestLight:Eu,kanagawaWave:Ou,kanagawaLotus:Nd,ayuDark:xd,ayuMirage:yd,ayuLight:iu,nightfox:nd,duskfox:vu,synthwave:su,matrix:zl,tron:Jl,cyberpunk:Bc,vaporwave:Cu,outrun:Kl,neonNoir:Tu,arcade:Fd,forest:Nu,ocean:vd,desert:ju,autumn:Du,lavender:gu,arctic:ad,rosewood:Td,solarizedLight:yu,githubLight:Rd,paper:Sl,linen:ou,highContrastLight:Il,mintLight:Pl},ni="bg-[color-mix(in_srgb,var(--color-accent)_8%,var(--color-accent-wash))]",Ah=({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"})]})]})]}),Rh=({id:t,name:s,description:a,isSelected:r,isTabStop:i,onSelect:c,onFocusTile:d})=>{const l=Eh[t]??tu;return e.jsx(Ze,{side:"bottom",align:"start",content:a,children:e.jsxs("button",{type:"button","data-theme-tile":t,"aria-pressed":r,tabIndex:i?0:-1,onFocus:d,onClick:c,className:pe("relative flex flex-col gap-1.5 rounded-md p-1 text-start transition-colors duration-fast ease-out-quart",r?ni:"hover:bg-surface"),children:[e.jsxs("span",{className:pe("relative block h-10 overflow-hidden rounded-sm border transition-colors duration-fast ease-out-quart",r?"border-accent":"border-hairline"),children:[e.jsx(Ah,{id:t}),r&&e.jsx("span",{className:pe("pointer-events-none absolute top-0.5 end-0.5 flex h-4 w-4 items-center justify-center rounded-full",ni),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(l,{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})]})]})})},Ih=t=>[...t.querySelectorAll("[data-theme-grid]")].map(s=>{const a=[...s.querySelectorAll("[data-theme-tile]")],r=a[0]?.getBoundingClientRect().top??0;return{count:a.length,columns:Math.max(1,a.filter(i=>Math.abs(i.getBoundingClientRect().top-r)<1).length)}}),Th=()=>{te();const{themeName:t,setTheme:s}=xe(),a=Mh(),r=a.library.themes.find(g=>g.id===a.active)?.id??t,i=a.library.themes.flatMap(g=>{const f=yt(g.base)?.palette;if(!f)return[];const h=vn(f,g);return[{id:g.id,name:g.name,description:n("ui.settings.appearance.editor.base",{name:it(g.base)?Qe[g.base].name:g.base}),css:Ti(g.id,h)}]}),c=Object.values(Qe),d=[{label:n("ui.settings.appearance.editor.custom_group"),items:i},{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),[l,u]=o.useState(null),m=o.useMemo(()=>{const g=d.flatMap(f=>f.items.map(h=>h.id));return l&&g.includes(l)?l:g.includes(r)?r:g[0]},[d,l,r]),p=g=>{if(!bh(g.key))return;const f=[...g.currentTarget.querySelectorAll("[data-theme-tile]")],h=f.indexOf(g.target);if(h<0)return;g.preventDefault();const v=kh({index:h,key:g.key,groups:Ih(g.currentTarget)});v!==h&&f[v]?.focus()};return e.jsx(Mi,{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:i.map(g=>g.css).join(`
|
|
319
|
+
`)}),a.dialogs,d.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:f,name:h,description:v})=>e.jsxs("div",{className:"group relative min-w-0",children:[e.jsx(Rh,{id:f,name:h,description:v,isSelected:f===r,isTabStop:f===m,onSelect:()=>{const _=a.library.themes.find(N=>N.id===f);_&&it(_.base)?xe.setState({themeName:_.base,customThemeId:f}):it(f)&&s(f)},onFocusTile:()=>u(f)}),e.jsx("div",{className:"absolute end-1 top-1 opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",children:a.menu(f,f===m)})]},f))})]},g.label))]})})},Lh=({value:t,onChange:s,searchRow:a})=>{te();const r=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:r,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(Bt,{value:t,onValueChange:i=>s(ri(i)),children:e.jsx(qt,{"aria-labelledby":r,children:Wr.map(i=>e.jsx(dt,{value:i.value,children:i.value==="by-turn"?n("ui.settings.appearance.transcript_display_mode_setting.by_turn"):n("ui.settings.appearance.transcript_display_mode_setting.by_response")},i.value))})})})]})},Oh=()=>{te();const{data:t,isLoading:s,error:a}=Vu({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(ud,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.radient_pass")]}),s&&e.jsx(Pe,{className:"h-6 w-36"}),a&&e.jsx(ge,{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(F,{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(Wl,{}),n("ui.settings.account.settings_page.add_credits")]})})]})]})},$h=[{id:"credits",get label(){return n("ui.settings.account.settings_page.credits")}},{id:"tokens",get label(){return n("ui.settings.account.settings_page.tokens")}}],Dh=()=>{te();const[t,s]=o.useState("credits"),a=o.useMemo(()=>{const l=new Date,u=Bu(l);return{start_date:ma(u),end_date:ma(l),rollup:"daily"}},[]),{data:r,isLoading:i,error:c}=Wu(a,{enabled:!0}),d=o.useMemo(()=>r?.data_points?[...r.data_points].sort((u,m)=>zn(u.timestamp).getTime()-zn(m.timestamp).getTime()).map(u=>({bucket:Cc(El(zn(u.timestamp),"yyyy-MM-dd")),value:t==="credits"?Number.parseFloat(u.total_cost.toFixed(2)):u.total_tokens})):[],[r,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(Vl,{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:$h.map(({id:l,label:u})=>e.jsx(F,{variant:"ghost",size:"sm","aria-pressed":t===l,onClick:()=>s(l),className:pe(t===l&&"bg-surface text-ink hover:bg-surface"),children:u},l))})]})]}),i&&e.jsx(Pe,{className:"h-62 w-full"}),c&&e.jsx(ge,{variant:"warning",children:n("ui.settings.account.settings_page.usage_load_failed",{reason:c.message})}),!i&&!c&&r&&d.length>0&&e.jsx(Hf,{metric:t,data:d}),!i&&!c&&(!r||d.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")})]})},zh=()=>(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(nl,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.radient_account")]}),e.jsx(F,{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(xi,{})]})})]})),tx=()=>{te();const t=vc(),s=xe(E=>E.showAgentReasoning),a=xe(E=>E.setShowAgentReasoning),r=xe(E=>E.transcriptDisplayMode),i=xe(E=>E.setTranscriptDisplayMode),c=xe(E=>E.agentAvatarSize),d=xe(E=>E.setAgentAvatarSize),{data:l,isLoading:u,isFetching:m,error:p,refetch:g}=kc(),{needsProvider:f}=jc(),h=Rs(),{sentence:v,remedy:_}=Ut(h??null,n("ui.settings.navigation.settings_page.your_settings_could_not_be_loaded"),p),N=Hc(),[C,A]=o.useState(null),D=_i(),{isAuthenticated:I,accountRead:O,isFetching:b,isRefreshing:z,refreshUser:P}=Ns(),U=Ot(E=>E.activeSessionId),x=Ot(E=>E.sessions),S=vm(),{accountId:T,snapshot:j,model:H}=ki(),$=o.useRef(null);j.status?$.current={accountId:T,status:j.status}:j.checking||($.current=null);const q=j.status??($.current?.accountId===T?$.current.status:null),W=tm(S),y=o.useMemo(()=>Vc.filter(E=>E.id!=="agent-messages"||S!=="absent"),[S]),L=o.useCallback(()=>H.check("surface_open",!0),[H]),[M,V]=o.useState("general"),[ae,Q]=o.useState(!1),ne=o.useRef(null),ce=o.useRef(null),{startTour:le}=Gc(),ue=Yr(),we=ai(),{data:B,refetch:K}=wc(),{refreshModels:k}=Nc(),Y=o.useMemo(()=>B?.keys?[...B.keys].sort():[],[B?.keys]),se=o.useRef({keys:"",hosting:void 0});o.useEffect(()=>{const E=Y.join(","),G=l?.values?.hosting;(se.current.keys!==E||se.current.hosting!==G)&&(se.current={keys:E,hosting:G},k().catch(J=>{console.error("Failed to refresh models after credentials or hosting change:",J)}))},[Y,l?.values?.hosting,k]);const ee=o.useRef({general:o.useRef(null),radient:o.useRef(null),integrations:o.useRef(null),appearance:o.useRef(null),notifications: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,ye=o.useMemo(()=>new URLSearchParams(ue.search).get("setting"),[ue.search]),Se=o.useMemo(()=>new URLSearchParams(ue.search).get("filter")??"",[ue.search]),he=o.useMemo(()=>new URLSearchParams(ue.search).get("mcp")??void 0,[ue.search]),be=o.useMemo(()=>new URLSearchParams(ue.search).get("provider"),[ue.search]),ke=o.useCallback(E=>{V(E),Q(!0);const G=ee[E],J=ce.current;if(G?.current&&J){const Ee=G.current.getBoundingClientRect().top-J.getBoundingClientRect().top;J.scrollHeight>J.clientHeight?J.scrollTo({top:Math.max(0,J.scrollTop+Ee-80),behavior:"smooth"}):window.scrollTo({top:Math.max(0,G.current.getBoundingClientRect().top+window.scrollY-80),behavior:"smooth"}),clearTimeout(ne.current??void 0),ne.current=setTimeout(()=>{Q(!1),ne.current=null},800)}else Q(!1)},[ee]),ie=o.useRef(null),de=o.useRef(null),Z=jt(),oe=bt(Z.data,"settings"),me=De({queryKey:ut.all,queryFn:()=>je({op:"settings.list"}),enabled:oe,staleTime:1e4}),Ie=Kf({registry:me.data,sections:y}),Je=o.useCallback(()=>ce.current?Em(ce.current):[],[]),[Me,Ue]=o.useState(null),Ge=o.useCallback(async E=>{de.current=null;const G=ce.current??document;if(E.source==="page")return Lm(G,E.id.slice(5));if(E.source==="section")return Om(G,E.sectionId);const J=E.settingKey;if(!J)return"missing";const _e=cn(J,"backend");return me.data&&!me.data.settings.some(Ee=>Ee.key===J)?"missing":(ke(_e),Ue({key:J,nonce:Date.now()}),G.querySelector(`[data-search-section="${_e}"]`)?"landed":"missing")},[ke,me.data]);o.useEffect(()=>{Ue(null)},[ue.search]),o.useEffect(()=>{const E=G=>{!(G.metaKey||G.ctrlKey)||G.altKey||G.key.toLowerCase()==="f"&&(Qr(G.target)||(G.preventDefault(),de.current=ce.current?.scrollTop??null,ie.current?.focus()))};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[]),o.useEffect(()=>{const E=setTimeout(()=>{const G=ce.current;if(!G)return;const J=()=>{if(ae)return;const _e=G.getBoundingClientRect(),Ee=_e.height;let Ne="",Oe=0;for(const[ze,He]of Object.entries(ee))if(He.current){const w=He.current.getBoundingClientRect(),re=_e.top,fe=w.top-re,Ae=w.bottom-re,Ke=w.height,Fe=Math.max(0,fe),ve=Math.min(Ee,Ae),St=Math.max(0,ve-Fe)/Ke,Ys=St+(fe<Ee*.3?.1:0);Ys>Oe&&St>.1&&(Oe=Ys,Ne=ze)}Ne&&Ne!==M&&V(Ne)};return J(),G.addEventListener("scroll",J,{passive:!0}),()=>{G.removeEventListener("scroll",J),clearTimeout(ne.current??void 0)}},100);return()=>clearTimeout(E)},[ee,M,ae]),o.useEffect(()=>{const E=new URLSearchParams(ue.search),G=E.get("section"),J=E.get("setting"),_e=J?cn(J,"backend"):G;if(_e==="agent-messages"&&!W)return;const Ee=_e?ee[_e]:void 0;if(!_e||!Ee)return;let Ne=!1,Oe=Number.NaN,ze=0;const He=window.setTimeout(()=>{Ne||(Ne=!0,re.disconnect(),ke(_e))},2e3),w=()=>{if(Ne)return;const fe=Ee.current;if(!fe){ze=requestAnimationFrame(w);return}const Ae=Math.round(fe.getBoundingClientRect().top+window.scrollY);if(Ae===Oe&&Ae>0){Ne=!0,re.disconnect(),window.clearTimeout(He),ke(_e);return}Oe=Ae,ze=requestAnimationFrame(w)},re=new ResizeObserver(()=>{Ne||(cancelAnimationFrame(ze),ze=requestAnimationFrame(w))});return ce.current&&re.observe(ce.current),ze=requestAnimationFrame(w),()=>{Ne=!0,cancelAnimationFrame(ze),re.disconnect(),window.clearTimeout(He)}},[ue.search,ee,ke,W]);const Xe=async(E,G)=>{A(E);try{await N.mutateAsync({[E]:G}),await g()}catch(J){console.error(`Error updating ${E}:`,J)}finally{A(null)}},rt=u,gt=O==="checking",Nt=bi(O),et=O==="ready"||O==="checking"||b,R=vi(rt,4e3);return p?e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(ge,{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:v}),_&&e.jsx(F,{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")})]})})}):rt?e.jsxs("div",{role:"status",className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-canvas",children:[e.jsx(Ce,{size:"lg",label:R?void 0:n("ui.settings.navigation.settings_page.loading_settings")}),R&&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")})]}):l?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(Wc,{activeSection:M,onSelectSection:ke,sections:y})}),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:ce,"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(sl,{title:n("ui.settings.page.title"),icon:ca}),e.jsx(qf,{onDismiss:()=>{const E=de.current;de.current=null,E!==null&&ce.current?.scrollTo({top:E})},ref:ie,index:Ie,readRendered:Je,onJump:Ge})]}),e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsxs("div",{ref:ee.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(Yc,{focus:ye===Dn||Me?.key===Dn,focusNonce:Me?.key===Dn?Me.nonce:void 0}),e.jsxs(Re,{title:n("ui.settings.profile.title"),icon:wi,description:n(I?"ui.settings.profile.description_authenticated":"ui.settings.profile.description_anonymous"),children:[gt&&e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.profile.account_checking")}),Nt&&e.jsx(ge,{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(F,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>P(),disabled:z,children:z?n("ui.settings.profile.retrying"):n("ui.settings.profile.retry")})]})}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(la,{searchRow:"general.profile.name",value:D.profile.name,label:n("ui.settings.profile.display_name.label"),placeholder:n("ui.settings.profile.display_name.placeholder"),isSaving:C==="user_name",onSave:async E=>{A("user_name");try{D.updateName(E)}finally{A(null)}},readOnly:et}),e.jsx(la,{searchRow:"general.profile.email",value:D.profile.email,label:n("ui.settings.profile.email.label"),placeholder:n("ui.settings.profile.email.placeholder"),isSaving:C==="user_email",onSave:async E=>{A("user_email");try{D.updateEmail(E)}finally{A(null)}},readOnly:et})]})]}),e.jsx(Re,{title:n("ui.settings.tour.title"),description:n("ui.settings.tour.description"),children:e.jsxs(F,{variant:"secondary","data-search-row":"general.tour","data-search-control":!0,onClick:()=>{le({forceModalCompleted:!0})},children:[e.jsx(fi,{}),n("ui.settings.tour.action")]})}),e.jsx(Re,{id:"model-settings",title:n("ui.settings.model.settings_page.model_settings"),icon:Qc,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(Zc,{value:l.values.hosting,isSaving:C==="hosting",onSave:E=>Xe("hosting",E),filterByCredentials:!0,allowCustom:!0,allowDefault:!1,emptyHelperText:n("ui.settings.model.settings_page.no_hosting_options")}),e.jsx(Jc,{value:l.values.model_name,hostingId:l.values.hosting,isSaving:C==="model_name",onSave:E=>Xe("model_name",E),allowCustom:!0,allowDefault:!1}),e.jsx(Bm,{hosting:l.values.hosting,modelName:l.values.model_name,focus:ye===ht||Me?.key===ht,focusNonce:Me?.key===ht?Me.nonce:void 0}),f&&e.jsx(ge,{variant:"neutral",icon:e.jsx(wn,{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:()=>{ke("providers"),ee.providers.current?.focus({preventScroll:!0})},children:n("ui.settings.model.provider_callout.providers_link")}),"."]})})]})}),e.jsx(_h,{}),e.jsx(Re,{title:n("ui.settings.configuration.settings_page.configuration_information"),icon:wn,description:n("ui.settings.configuration.settings_page.system_information_about_the_current_configuration"),children:e.jsxs(Vt,{children:[e.jsx(Te,{label:n("ui.settings.configuration.settings_page.version"),value:e.jsx("span",{className:"text-mono-sm",children:l.version})}),e.jsx(Te,{label:n("ui.settings.configuration.settings_page.created"),value:yi(l.metadata.created_at)}),e.jsx(Te,{label:n("ui.settings.configuration.settings_page.last_modified"),value:Cs(l.metadata.last_modified)}),e.jsx(Te,{label:n("ui.settings.configuration.settings_page.description"),value:l.metadata.description||n("ui.settings.configuration.settings_page.no_description_available")})]})})]}),e.jsx(Re,{title:n("ui.settings.appearance.settings_page.appearance"),icon:Li,description:n("ui.settings.appearance.settings_page.customize_the_look_and_feel_of_local_operator"),sectionRef:ee.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(Tg,{gallery:e.jsx(Th,{})}),e.jsx($t,{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 E=>a(E)}),e.jsx(Lh,{searchRow:"appearance.transcript",value:ri(r),onChange:E=>i(E)}),e.jsx(ug,{searchRow:"appearance.agent-picture-size",value:ss(c),onChange:E=>d(E)}),e.jsx(Ju,{searchRow:"appearance.glass",state:t.state,onChange:t.set})]})}),e.jsx(pf,{sectionRef:ee.notifications}),e.jsx(nh,{sectionRef:ee.speech}),e.jsx(Xc,{sectionRef:ee.keyboard,focusKey:ye}),e.jsx(Re,{title:n("ui.settings.model.settings_page.model_providers"),icon:pi,description:n("ui.settings.navigation.settings_page.sign_in_to_the_services_your_agents_think_with_new_chats_use_your"),sectionRef:ee.providers,searchSection:"providers",searchSectionLabel:n("ui.settings.navigation.settings_sidebar.model_providers"),id:"model-providers",className:"focus-visible:outline-none!",children:e.jsx(el,{initialProviderId:be,onChangeModel:()=>ke("general")})}),e.jsx(ef,{sessionId:U??void 0,sectionRef:ee.integrations,highlightServer:he}),e.jsx(Re,{title:n("ui.settings.account.settings_page.radient_account"),titleComponent:e.jsx(zh,{}),description:n("ui.settings.account.settings_page.your_radient_account_radient_pass_details_and_credits_to_use_radi"),sectionRef:ee.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(If,{onAfterCredentialUpdate:()=>{k(),K()}}),I&&e.jsxs(e.Fragment,{children:[e.jsx(Oh,{}),e.jsx(Dh,{})]})]})}),W&&e.jsx(Re,{title:n("ui.agentMessages.settings.section"),icon:tl,description:n("ui.agentMessages.settings.description"),sectionRef:ee["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(lm,{availability:S,status:q,accountId:T,refusal:j.refusal,onRefreshStatus:L,sessions:x,focus:ye===On||Me?.key===On,focusNonce:Me?.key===On?Me.nonce:void 0,onOpenSession:E=>{H.invalidateStatus(),Zr(we,E)}}):j.refusal?e.jsxs(ge,{variant:"warning",children:[e.jsx(jn,{children:n("ui.agentMessages.settings.error.title")}),e.jsxs(Be,{children:[j.refusal.code!=="client_unavailable"&&e.jsx("span",{className:"block",children:fn(j.refusal)}),e.jsx("span",{className:"block",children:n("ui.agentMessages.settings.error.no_changes")}),e.jsx(F,{className:"mt-3",variant:"secondary",onClick:()=>void L(),children:n("ui.agentMessages.settings.error.retry")})]})]}):e.jsxs("div",{"aria-busy":"true",className:"flex flex-col gap-3",children:[e.jsx(Pe,{className:"h-5 w-40"}),e.jsx(Pe,{className:"h-4 w-full max-w-xl"})]})}),e.jsx(Re,{title:n("ui.settings.navigation.settings_page.backend_settings"),icon:ca,description:n("ui.settings.navigation.settings_page.every_setting_the_backend_registry_owns_searchable_with_typed_edi"),sectionRef:ee.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(Sc,{hideInterfaceLanguage:!0,hideModelEffort:!0,hideAgentMessages:!0,hideSpeechShortcuts:!0,hideNotifications:!0,focusKey:Me?Me.key:ye&&cn(ye,"backend")==="backend"?ye:null,focusNonce:Me?.nonce,initialFilter:Se})}),e.jsx("div",{ref:ee.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(cg,{})}),e.jsx("div",{ref:ee.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(Fm,{})})]})]})})})]}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(ge,{variant:"warning",className:"w-full max-w-xl",children:n("ui.settings.navigation.settings_page.your_settings_could_not_be_loaded")})})};export{tx as SettingsPage};
|