local-operator-ui 0.57.3 → 0.57.5
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 +1044 -63
- package/out/preload/index.js +102 -21
- package/out/renderer/assets/{_basePickBy-BeAzmqgq.js → _basePickBy-D2upKftS.js} +1 -1
- package/out/renderer/assets/{_baseUniq-Clx9gdFs.js → _baseUniq-BGD19KIN.js} +1 -1
- package/out/renderer/assets/{agent-details-page-BMztNR89.js → agent-details-page-OPyFw_dI.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-quUNNwcr.js → agent-hub-page-B3V1y16n.js} +1 -1
- package/out/renderer/assets/{agents-page-BTYHgMAf.js → agents-page-CowgZsSO.js} +3 -3
- package/out/renderer/assets/appearance-DO4VPBSi.js +65 -0
- package/out/renderer/assets/{approvalsOverlay-BxwEca1y.js → approvalsOverlay-CBPXn0ct.js} +1 -1
- package/out/renderer/assets/{arc-BOZHzyJm.js → arc-Cv6N9gTJ.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-CpE8Siol.js → architectureDiagram-IEHRJDOE-DHtB5fE0.js} +1 -1
- package/out/renderer/assets/{avatar-cropper-BWJE7j7A.js → avatar-cropper-Bjo9zUPg.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-D4LTtQ_H.js → blockDiagram-JOT3LUYC-4WEK73Je.js} +1 -1
- package/out/renderer/assets/{book-open-fa_DaJBq.js → book-open-CmfjhXrg.js} +1 -1
- package/out/renderer/assets/browser-page-2S7sbehs.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-VC7pNm9O.js → browser-webauthn-prompt-D8Tgtg83.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-DRtUDXOF.js → c4Diagram-VJAJSXHY-kaGHtOK6.js} +1 -1
- package/out/renderer/assets/channel-DRHru1K8.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-Cw4VudrA.js → chunk-4BMEZGHF-CpC8J2AT.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-0JOiKMb-.js → chunk-A2AXSNBT-DKmX4atq.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-CAKCg9DA.js → chunk-AEK57VVT-Dtej3BD4.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-CFZ2DTGX.js → chunk-D6G4REZN-DUXxF-pw.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-CupwUHva.js → chunk-RZ5BOZE2-DeeJjU3w.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-B1vcbFku.js → chunk-XZIHB7SX-D4R6kzHb.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-Cs0VSRpc.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-Cs0VSRpc.js +1 -0
- package/out/renderer/assets/clone-_NlCUljT.js +1 -0
- package/out/renderer/assets/{console-mirror-IB35kNI8.js → console-mirror-Bp3thuUi.js} +1 -1
- package/out/renderer/assets/{consoleCapture-D4G96kDb.js → consoleCapture-BJR8BDEY.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-DlorrZ6B.js → conversation-input-sync-FnnZiNnd.js} +4 -4
- package/out/renderer/assets/{dagre-OKDRZEBW-CunvCCGM.js → dagre-OKDRZEBW-DDY_IkmM.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-DlpXMePq.js → diagram-SSKATNLV-D7AGoSSj.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-CtgMK6MT.js → diagram-VNBRO52H-CcgAGaBN.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-C-QNezLB.js → erDiagram-Q7BY3M3F-LEYxek3-.js} +1 -1
- package/out/renderer/assets/{error-boundary-C1x5W-AX.js → error-boundary-BsWceBKP.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-DjwRYw0E.js → flowDiagram-4HSFHLVR-CQLUaH8T.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-Tb5F1KXD.js → ganttDiagram-APWFNJXF-Ole27PT-.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-BokP9Y1T.js → gitGraphDiagram-7IBYFJ6S-BNYa___9.js} +1 -1
- package/out/renderer/assets/{graph-DEHYXN6b.js → graph-Bibb0aeq.js} +1 -1
- package/out/renderer/assets/{heart-DqMMtrJ1.js → heart-Cix0tXFr.js} +1 -1
- package/out/renderer/assets/index-BKLUTBo0.css +1 -0
- package/out/renderer/assets/index-BKh47kLl.js +857 -0
- package/out/renderer/assets/{index-D7fnBkIK.js → index-C9UzsV82.js} +1 -1
- package/out/renderer/assets/{index-CJ8BPUHQ.js → index-CMJfInon.js} +1 -1
- package/out/renderer/assets/{index-BWQzFq0n.js → index-D0qlrLIs.js} +10 -10
- package/out/renderer/assets/infoDiagram-PH2N3AL5-BXhry1Gr.js +2 -0
- package/out/renderer/assets/{inline-error-boundary-ChbTvdIh.js → inline-error-boundary-Ba_FWBMT.js} +1 -1
- package/out/renderer/assets/{installer-Bplg-bpo.js → installer-bmE_RNOZ.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-BfXoBW-2.js → journeyDiagram-U35MCT3I-DI32aDKT.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BeT3LOJG.js → kanban-definition-NDS4AKOZ-CZ-ELIdr.js} +1 -1
- package/out/renderer/assets/{layout-B71SsWep.js → layout-Dza9PMRJ.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-BaSX_kru.js → legacy-agents-page-CPFGYWOZ.js} +1 -1
- package/out/renderer/assets/{library-page-BwmVBhNJ.js → library-page-DiaLon0b.js} +3 -3
- package/out/renderer/assets/{log-in-C4tjIXzF.js → log-in-Bd6fDqyJ.js} +1 -1
- package/out/renderer/assets/{mermaid.core-D7wfsRjY.js → mermaid.core-BcJdc-X6.js} +5 -5
- package/out/renderer/assets/{mesh-page-DbC0RmVo.js → mesh-page-7T5BtRTh.js} +1 -1
- package/out/renderer/assets/{messages-B7aIuFuF.js → messages-BYDbMAVA.js} +10 -10
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-BPTOzHuL.js → mindmap-definition-ALO5MXBD-D2CXGzTD.js} +1 -1
- package/out/renderer/assets/{mini-DXMqE-0u.js → mini-CJlFVLUZ.js} +1 -1
- package/out/renderer/assets/{notebook-pen-CQdB2BC5.js → notebook-pen-D05OGtSm.js} +1 -1
- package/out/renderer/assets/{notifications-page-C9PU2typ.js → notifications-page-BjrfZb8l.js} +1 -1
- package/out/renderer/assets/{org-access-Fw38H9fZ.js → org-access-B9_h9w7n.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-CKBjFWJL.js → org-surface-gate-sm4xQvjq.js} +1 -1
- package/out/renderer/assets/{page-header-CAW9G_fb.js → page-header-DXwYxMB-.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-C0JN0KMq.js → pieDiagram-IB7DONF6-DUG4cv-v.js} +1 -1
- package/out/renderer/assets/{projects-page-D9F4QotN.js → projects-page-DlCYJUiP.js} +1 -1
- package/out/renderer/assets/{publication-validation-DygSOQkj.js → publication-validation-Bn7rmCS6.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-BRgjFQlM.js → quadrantDiagram-7GDLP6J5-DaYms9_B.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-VE0niGVF.js → radar-MK3ICKWK-B97TgRmB.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-CXMLVkUO.js → radient-auth-buttons-CEfTJcvg.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-DkwJBmMi.js → requirementDiagram-KVF5MWMF-DgyICZXf.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DFv3zh8B.js → sankeyDiagram-QLVOVGJD-DHgZL_Zc.js} +1 -1
- package/out/renderer/assets/{schedules-page-aTbxrD_M.js → schedules-page-CNdkudlY.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-BXcr3er8.js → sequenceDiagram-X6HHIX6F-pU2H-s2W.js} +1 -1
- package/out/renderer/assets/settings-page-B9GORgXK.js +319 -0
- package/out/renderer/assets/{smartart-CWBh1X_F.js → smartart-gFtvTNRW.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-Cw08neDd.js → stateDiagram-DGXRK772-HwW2OpHh.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BwCPC1S5.js +1 -0
- package/out/renderer/assets/{team-bridge-page-BHAdGSZS.js → team-bridge-page-ChcIcnje.js} +17 -17
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-B-ZFBehC.js → timeline-definition-BDJGKUSR-CPNzpTN8.js} +1 -1
- package/out/renderer/assets/{use-default-on-banner-C8DUslhy.js → use-default-on-banner-CuXTqN3l.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-DMGaSxDK.js → use-download-agent-mutation-BCbr9wLe.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BGB8PPzY.js → xychartDiagram-VJFVF3MP-TZFrKw4j.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 +7 -7
- package/package.json +1 -1
- package/out/renderer/assets/appearance-DCqlsN7S.js +0 -65
- package/out/renderer/assets/browser-page-AgwdXhLM.js +0 -1
- package/out/renderer/assets/channel-DMQl-cpj.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DJsxDWD8.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DJsxDWD8.js +0 -1
- package/out/renderer/assets/clone-B9GxWhWi.js +0 -1
- package/out/renderer/assets/index-BnqyWEPM.css +0 -1
- package/out/renderer/assets/index-Buuz619t.js +0 -852
- package/out/renderer/assets/infoDiagram-PH2N3AL5-bdAhVGkO.js +0 -2
- package/out/renderer/assets/settings-page-DWZ3Mguh.js +0 -319
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BtazAv7-.js +0 -1
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import{r as o,j as e,c as xe,n as jt,t as Xe,l as it}from"./index-BWQzFq0n.js";import{ar as Ar,aM as Er,m as ze,u as Nt,aN as Rr,aC as Ir,aO as Tr,aP as dt,a as gt,d as Qe,aQ as Lr,ao as Or,aR as Dr,aS as $r,aT as Pr,aU as Fr,j as Ne,i as zr,aV as os,aW as Ur,aX as Kr,aY as Br,aZ as qr,I as be,a_ as cs,a$ as Hr,b0 as Vr,b1 as Wr,b2 as Gr,b3 as Yr,ae as Qr,b4 as li,b5 as Zr,b6 as Lt,b7 as Ht,b8 as Tn,b9 as Ln,ba as Jr,bb as Xs,bc as Xr,bd as eo,be as ea,bf as to,Q as St,bg as no,A as yt,bh as so,f as di,ay as ls,g as ui,O as ao,bi as Vt,ai as io,N as Fe,r as ro,bj as Ot,bk as oo,bl as ta,bm as na,bn as co,bo as mi,bp as lo,aa as uo,o as mo,ab as po}from"./appearance-DCqlsN7S.js";import{eS as ds,eT as go,eU as sa,eV as st,cy as ho,aQ as pi,aR as Ss,aj as gi,bf as fo,ac as Cs,eW as xo,eX as _o,eY as yo,eZ as bo,e_ as hi,e$ as Ms,aO as fi,f0 as vo,f1 as ko,f2 as gn,f3 as xi,f4 as jo,bi as us,f5 as aa,f6 as wo,f7 as bt,f8 as mt,bU as As,f9 as Es,cQ as hn,cc as No,fa as _i,fb as Rs,fc as kn,fd as So,fe as Co,ff as Mo,fg as On,fh as Ao,fi as Mn,fj as Eo,fk as Ro,aD as yi,bk as ms,bl as ps,bt as Is,ad as gs,fl as Io,fm as To,fn as hs,fo as Lo,fp as Oo,fq as Do,fr as bi,fs as $o,ft as Po,fu as Fo,fv as zo,fw as vi,fx as Uo,fy as Ko,fz as Bo,fA as qo,fB as Mt,fC as tn,dW as Ho,fD as fs,fE as Vo,dV as Wo,fF as Go,fG as Yo,fH as Qo,fI as Zo,fJ as Jo,fK as ia,bZ as Ts,fL as ct,fM as At,fN as Xo,fO as ec,fP as ra,fQ as tc,fR as nc,fS as sc,fT as ac,fU as ic,fV as rc,bn as oc,dd as vt,el as cc,d3 as ki,de as lc,r as oa,d4 as dc,bX as An,cX as ji,be as uc,fW as wi,bj as Ni,fX as Si,fY as mc,fZ as pc,f_ as gc,f$ as hc,g0 as fc,g1 as xc,dC as _c,aN as yc,g2 as bc,g3 as vc,c8 as kc,g4 as Et,g5 as ca,g6 as jc,g7 as wc,g8 as Nc,e1 as Sc,e3 as Cc,d0 as Mc,g9 as Dn,ga as nn,gb as Ac,gc as Ec,gd as Rc,ge as Ic,gf as Tc,gg as Lc,gh as $n,gi as la,gj as Oc,ct as Dc,gk as $c,gl as Pc,cA as Fc,gm as zc,gn as Uc,go as Kc,cw as Bc,ep as Pn,gp as qc,gq as Hc}from"./conversation-input-sync-DlorrZ6B.js";import{ew as Ci,ex as Vc,ey as Wc,ez as Mi,eA as Gc,d8 as Yc,eB as He,N as Qc,S as Ai,cB as Zt,cC as Oe,eC as Wt,eD as Re,eE as Fn,eF as Zc,R as Jc,bX as Ei,b as jn,bH as Xc,cw as el,a as tl,eG as nl,eH as sl,eI as al,eJ as il,eK as rl,eL as Ri,dS as ol,eM as cl,eN as ll,eO as dl,d6 as ul,eP as ml,eQ as sn,eR as an,eS as da,cP as pl,cA as gl,cL as hl,eT as fl,eU as xl,eV as _l,eW as yl,cr as ua,eX as bl,cx as ma,cW as vl,cy as kl,cz as jl,eY as wl,eZ as Nl,e_ as Sl}from"./index-Buuz619t.js";import{P as Cl}from"./page-header-CAW9G_fb.js";import{c as X,u as ne,B as O,S as Ee,a5 as Ls,w as et,N as Gt,O as Yt,P as ut,A as _e,p as wn,x as Ve,l as Ue,U as Os,V as Ds,W as $s,Y as Ps,Z as kt,L as We,K as $e,ad as Nn,a6 as Ii,e as wt,a as xs,ah as Ti,b as En,a4 as Ml,af as Li,a1 as Al,ae as El,a3 as Rl,as as _s,q as Oi,T as Di,au as Il,av as pa,r as Fs,D as zs,g as Us,i as Ks,H as Tl,I as at,aw as $i,ax as Ll,X as ga,R as Sn,E as Pi,m as Dt,n as $t,y as Ol,o as Pt,z as Ft,F as Dl,ai as $l,aj as Pl,ay as Fl,az as zl}from"./error-boundary-C1x5W-AX.js";import{t as n,i as Ul,L as zn}from"./messages-B7aIuFuF.js";import{u as ha,d as Kl,e as Bl,D as ql,l as Hl}from"./use-default-on-banner-C8DUslhy.js";import{s as Vl}from"./team-bridge-trial-model-DLdMGEm0.js";import{R as Wl}from"./radient-auth-buttons-CXMLVkUO.js";import{u as Gl,A as Yl,d as Ql}from"./avatar-cropper-BWJE7j7A.js";import{N as Zl}from"./notebook-pen-CQdB2BC5.js";import{k as xt,p as Fi}from"./roles-D1pcbxAx.js";import{B as Jl}from"./book-open-fa_DaJBq.js";import{i as Xl,a as lt,b as ed,p as Un,f as td}from"./parseISO-CxPiCKvF.js";import{t as nd}from"./en-US-CW_dDnkH.js";import"./console-mirror-IB35kNI8.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 sd=[["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"}]],ad=X("aperture",sd);/**
|
|
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 id=[["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"}]],rd=X("atom",id);/**
|
|
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 od=[["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"}]],cd=X("audio-waveform",od);/**
|
|
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 ld=[["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"}]],dd=X("binary",ld);/**
|
|
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 ud=[["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"}]],md=X("candy",ud);/**
|
|
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 pd=[["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"}]],gd=X("car-front",pd);/**
|
|
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 hd=[["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"}]],fd=X("cassette-tape",hd);/**
|
|
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 xd=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],_d=X("chart-line",xd);/**
|
|
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 yd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],bd=X("circle-plus",yd);/**
|
|
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 vd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],kd=X("circle-stop",vd);/**
|
|
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 jd=[["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"}]],wd=X("circuit-board",jd);/**
|
|
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 Nd=[["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"}]],Sd=X("cloud-lightning",Nd);/**
|
|
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 Cd=[["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"}]],Md=X("cloud-moon",Cd);/**
|
|
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 Ad=[["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"}]],Ed=X("cloud-snow",Ad);/**
|
|
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 Rd=[["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"}]],Id=X("cloud-sun",Rd);/**
|
|
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 Td=[["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"}]],Ld=X("coffee",Td);/**
|
|
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 Od=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]],zi=X("contrast",Od);/**
|
|
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"}]],$d=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 Pd=[["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"}]],Fd=X("cup-soda",Pd);/**
|
|
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 zd=[["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"}]],Ud=X("disc-3",zd);/**
|
|
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 Kd=[["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"}]],Bd=X("droplet",Kd);/**
|
|
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 qd=[["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"}]],Hd=X("droplets",qd);/**
|
|
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 Vd=[["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"}]],Wd=X("fish",Vd);/**
|
|
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 Gd=[["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"}]],Yd=X("flame",Gd);/**
|
|
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 Qd=[["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"}]],Zd=X("flower-2",Qd);/**
|
|
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 Jd=[["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"}]],Xd=X("flower",Jd);/**
|
|
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 eu=[["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"}]],tu=X("ghost",eu);/**
|
|
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 nu=[["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"}]],su=X("github",nu);/**
|
|
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 au=[["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"}]],iu=X("guitar",au);/**
|
|
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 ru=[["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"}]],ou=X("hexagon",ru);/**
|
|
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 cu=[["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"}]],lu=X("ice-cream-bowl",cu);/**
|
|
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 du=[["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"}]],uu=X("joystick",du);/**
|
|
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 mu=[["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"}]],pu=X("leaf",mu);/**
|
|
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 gu=[["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"}]],hu=X("lightbulb",gu);/**
|
|
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 fu=[["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"}]],xu=X("milk",fu);/**
|
|
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 _u=[["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"}]],yu=X("moon-star",_u);/**
|
|
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 bu=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],vu=X("moon",bu);/**
|
|
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 ku=[["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"}]],ju=X("mountain-snow",ku);/**
|
|
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 wu=[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]],Nu=X("mountain",wu);/**
|
|
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 Su=[["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"}]],Cu=X("palette",Su);/**
|
|
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 Mu=[["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"}]],Au=X("radio",Mu);/**
|
|
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 Eu=[["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"}]],Ru=X("sailboat",Eu);/**
|
|
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 Iu=[["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"}]],Tu=X("shirt",Iu);/**
|
|
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 Lu=[["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"}]],Ou=X("skull",Lu);/**
|
|
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"}]],$u=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 Pu=[["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"}]],Fu=X("sparkle",Pu);/**
|
|
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 zu=[["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"}]],Uu=X("sun-dim",zu);/**
|
|
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 Ku=[["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"}]],Bu=X("sun",Ku);/**
|
|
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 qu=[["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"}]],Hu=X("sunrise",qu);/**
|
|
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 Vu=[["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"}]],Wu=X("sunset",Vu);/**
|
|
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 Gu=[["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"}]],Yu=X("tent",Gu);/**
|
|
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 Qu=[["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"}]],Zu=X("tree-deciduous",Qu);/**
|
|
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 Ju=[["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"}]],Xu=X("tree-palm",Ju);/**
|
|
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 em=[["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"}]],tm=X("tree-pine",em);/**
|
|
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 nm=[["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"}]],sm=X("trees",nm);/**
|
|
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 am=[["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"}]],im=X("umbrella",am);/**
|
|
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 rm=[["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"}]],om=X("waves",rm);/**
|
|
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 cm=[["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"}]],lm=X("wheat",cm);/**
|
|
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 dm=[["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"}]],um=X("wind",dm),mm=({appVersion:t=null,slowWaitHintMs:s})=>{ne();const a="https://local-operator.com/download",[r,i]=o.useState(!1),c=Ci(r,s??Vc),[l,d]=o.useState(!1),[u,m]=o.useState(null),[h,p]=o.useState("info"),[g,f]=o.useState(null),[j,_]=o.useState(null),b=t?.trim()?t.trim():null,A=o.useRef(!1),y=ds(L=>L.openDetail),I=o.useRef(!1),M=o.useRef(0),P=o.useRef(!1),N=o.useCallback((L,w)=>{I.current=!1,m(L),p(w),d(!0)},[]),E=o.useCallback(L=>{I.current=!0,m(L),p("success"),d(!0)},[]),z=o.useCallback(()=>{I.current&&(I.current=!1,d(!1),m(null))},[]),{clearDeferredUpdate:K}=go();o.useEffect(()=>{const L=window.api.updater.onUpdateError(v=>{A.current&&v.includes("manually")&&(f({message:n("ui.common.updates.check_for_updates_button.the_server_is_installed_outside_the_app_so_use_the_tool_you_insta"),command:""}),I.current=!1,m(null),p("warning"),d(!0))}),w=window.api.updater.onBackendUpdateDevMode(v=>{A.current&&N(v,"info")}),V=()=>{P.current=!0,z()},$=window.api.updater.onUpdateAvailable(V),q=window.api.updater.onUpdateNpxAvailable(V),G=window.api.updater.onBackendUpdateAvailable(V);return()=>{L(),w(),$(),q(),G()}},[z,N]),o.useEffect(()=>{let L=!1;const w=()=>{window.api.updater.getLastInstallAttempt().then($=>{L||_($)}).catch(()=>{})};w();const V=window.api.updater.onUpdateInstallFailed(()=>w());return()=>{L=!0,V()}},[]);const x=async()=>{const L=++M.current;z(),P.current=!1;try{i(!0),A.current=!0,K(st.UI),K(st.BACKEND);const w=await window.api.updater.checkForAllUpdates({manual:!0});if(L!==M.current)return;w.app==="available"&&y(st.UI),w.server==="available"&&y(st.BACKEND),w?.affirmation&&!P.current?E(w.affirmation):z()}catch(w){if(L!==M.current)return;console.warn(`Update check failed; the app-level alert owns the report: ${Wc(w)}`)}finally{L===M.current&&i(!1),setTimeout(()=>{A.current=!1},2e3)}},R=()=>{I.current=!1,d(!1),m(null)};return e.jsxs(e.Fragment,{children:[j&&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"),j.targetVersion," ",n("ui.common.updates.check_for_updates_button.didn_t_finish"),j.attempts>1?n("ui.common.updates.check_for_updates_button.detail",{attempts:j.attempts,attemptsText:String(j.attempts)}):"",".",b?n("ui.common.updates.check_for_updates_button.version",{liveversion:String(b)}):null]}),e.jsxs("p",{className:"mt-1 text-meta text-ink-dim",children:[n("ui.common.updates.check_for_updates_button.detected")," ",j.detectedAt?Ul(Ar(new Date(j.detectedAt),Er)):n("ui.common.updates.check_for_updates_button.at_an_unknown_time"),". ",j.detail]}),e.jsx(O,{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(O,{variant:"outline",onClick:()=>void x(),disabled:r,children:[r?e.jsx(Ee,{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")}),g&&e.jsxs(sa,{open:l,autoHideDuration:1e4,onClose:R,variant:"warning",children:[e.jsx("p",{className:"text-body-sm",children:g.message}),g.command&&e.jsx("code",{className:"mt-2 block rounded-sm bg-sunken p-2 text-mono-sm text-ink",children:g.command})]}),u&&h!=="danger"&&e.jsx(sa,{open:l,autoHideDuration:6e3,onClose:R,variant:h,children:u})]})},fn=["system-prompt"],pm=()=>{const{shouldEnableQuery:t}=ho();return ze({enabled:t({bypassInternetCheck:!0}),queryKey:fn,queryFn:async()=>{try{const a=await pi(Ss.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 gi(a),s}},refetchOnWindowFocus:!1,staleTime:5e3})},gm=()=>{const t=Nt(),s=pi(Ss.baseUrl);return fo({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 gi(i),r}},onSuccess:async a=>{await t.invalidateQueries({queryKey:fn,refetchType:"none"}),t.setQueryData(fn,r=>r&&{...r,...a}),await t.refetchQueries({queryKey:fn,type:"all"}),Cs(n("ui.notices.settings.system_prompt_updated"))},onError:a=>{console.error("Error updating system prompt:",a)}})},zt=({searchRow:t,searchTerms:s,value:a,label:r,description:i,onChange:c,icon:l,isSaving:d=!1,disabled:u=!1,savingInPlace:m=!1})=>{ne();const[h,p]=o.useState(a),g=o.useRef(0),[f,j]=o.useState(0);o.useEffect(()=>{m&&g.current>0||p(a)},[a,m,f]);const _=o.useId(),b=`${_}-label`,A=`${_}-description`,y=async I=>{if(!(d&&!m||u)){if(p(I),m){g.current+=1;try{await c(I)}catch(M){console.error("Error toggling setting:",M)}finally{g.current-=1,g.current===0&&j(M=>M+1)}return}try{await c(I)}catch(M){p(!I),console.error("Error toggling setting:",M)}}};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&&d?!0:void 0,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("span",{id:b,"data-search-label":"",className:"flex min-h-6 items-center gap-2 text-body text-ink",children:[l&&e.jsx(l,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),r]}),i&&e.jsx("p",{id:A,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&&d&&e.jsx(Ee,{size:"xs",label:n("ui.common.forms.toggle_setting.saving",{label:r})}),d&&!m?e.jsx(Ee,{size:"md",label:n("ui.common.forms.toggle_setting.saving",{label:r})}):e.jsx(Ls,{checked:h,onCheckedChange:y,disabled:u,"aria-labelledby":b,"aria-describedby":i?A:void 0})]})]})};function fa(t,s){const a=nd(t,s?.in);if(!Xl(a))throw new RangeError("Invalid time value");const r=lt(a.getDate(),2),i=lt(a.getMonth()+1,2),c=a.getFullYear(),l=lt(a.getHours(),2),d=lt(a.getMinutes(),2),u=lt(a.getSeconds(),2);let m="",h="";const p=a.getTimezoneOffset();if(p!==0){const g=Math.abs(p),f=lt(Math.trunc(g/60),2),j=lt(g%60,2);h=`${p<0?"+":"-"}${f}:${j}`}else h="Z";return`${c}-${i}-${r}T${l}:${d}:${u}${m}${h}`}function hm(t,s,a){return ed(t,-30,a)}var fm=xo({chartName:"LineChart",GraphicalChild:hi,axisComponents:[{axisType:"xAxis",AxisComp:_o},{axisType:"yAxis",AxisComp:yo}],formatAxisMap:bo});const xm=["radient","creditBalance"],_m=t=>{const{user:s,isAuthenticated:a}=Ms(),r=s?.account?.tenant_id,i=a&&!!r&&t?.enabled;return ze({queryKey:[xm,r],queryFn:async()=>{if(!r)throw new Error(n("ui.common.errors.tenant_missing"));const c=await fi({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})},ym=["radient","usageRollup"],bm=(t,s)=>{const{user:a,isAuthenticated:r}=Ms(),i=a?.account?.tenant_id,c=r&&!!i&&s?.enabled;return ze({queryKey:[...ym,i,t],queryFn:async()=>{if(!i)throw new Error(n("ui.common.errors.tenant_missing"));const l={};for(const[u,m]of Object.entries(t))m!=null&&(l[u]=String(m));const d=await fi({operation:"usage",tenantId:i,query:l});if(!d)throw new Error(n("ui.common.errors.usage_rollup_invalid"));return d},enabled:c,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},vm=t=>t==="sidebars"?n("ui.settings.appearance.window_glass.coverage_sidebars"):n("ui.settings.appearance.window_glass.coverage_full"),km=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")}},jm=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")}},xa=({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(Gt,{value:a,onValueChange:r,children:e.jsx(Yt,{"aria-labelledby":c,children:i.map(l=>e.jsx(ut,{value:l.value,children:l.label},l.value))})})})]})},wm=({state:t,onChange:s,searchRow:a})=>{ne();const r=o.useId(),i=`${r}-description`,[c,l]=o.useState(null),d=o.useRef(!1),u=o.useRef(null),m=t?.settings.intensity??0;if(!t)return null;const h=!t.capability.supported,p=h?jm(t.capability.reason):null,g=async _=>{if(d.current){u.current=_;return}d.current=!0;try{await s({intensity:_})}finally{d.current=!1;const b=u.current;u.current=null,b!==null&&b!==_?g(b):l(null)}},f=t.settings.enabled,j=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(et,{content:p,disabled:!h,children:e.jsx("div",{className:h?"opacity-60":void 0,children:e.jsx(zt,{value:h?!1:f,disabled:h,label:n("ui.settings.appearance.window_glass.label"),description:n("ui.settings.appearance.window_glass.description"),onChange:async _=>s({enabled:_})},h?"unavailable":"available")})}),p&&e.jsx("p",{"data-glass-unsupported":t.capability.reason,className:"max-w-2xl text-body-sm text-ink-muted",children:p}),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")}),f&&!h&&e.jsxs(e.Fragment,{children:[e.jsx(xa,{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:vo.map(_=>({value:_,label:vm(_)}))}),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(j)})})]}),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:j,"aria-describedby":i,"aria-valuetext":n("ui.settings.appearance.window_glass.intensity_value",{value:String(j)}),onChange:_=>{const b=Number(_.target.value);l(b),g(b)},style:{"--fill":`${j}%`},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(xa,{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:km(_)}))})]})]})},Nm=new Set(["B","C","D","E","F"]);function Sm(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&&Nm.has(s.surface_state)?"visible":"absent":i&&r?"visible":a&&r?"error":"absent"}function Cm(t,s){return t!=="absent"}function Rt(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 Mm="open_chief_of_staff";function Am(t){const s=t?.delivery_hold;if(!s||s.code!==Mm||s.count<=0)return null;const a=s.session||t?.local.session||null;return{count:s.count,sessionId:a}}function Ui(t){return Rr(t)}function Em(t){return t.target.endpoint_id?{kind:"endpoint",id:t.target.endpoint_id}:{kind:"account",id:t.target.account_id??""}}function ys(t){return t.map((s,a)=>{const r=Em(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 bs(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 Ki(t){return JSON.stringify(t)}function Rm(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"}:Ki(bs(t.entries,t.modes))===t.savedSignature?{disabled:!0,reason:"unchanged"}:{disabled:!1}}const Im=/^[^\s\p{Cc}]{1,128}$/u;function Tm(t){return t===""?n("ui.agentMessages.settings.allowlist.identifier_empty"):t.length>128?n("ui.agentMessages.settings.allowlist.identifier_long"):Im.test(t)?null:n("ui.agentMessages.settings.allowlist.identifier_invalid")}function xn(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 Lm=['[data-agent-messages-action="turn_on_again"]','[role="switch"]','[data-agent-messages-action="enable"]'],Kn="__none__";function Om({availability:t,status:s,accountId:a,refusal:r=null,api:i=Yc,onRefreshStatus:c,sessions:l=[],onOpenSession:d,focus:u=!1,focusNonce:m,typingAvailable:h=!1}){ne();const[p,g]=o.useState({kind:"loading"}),[f,j]=o.useState(0),[_,b]=o.useState(null),[A,y]=o.useState(null),[I,M]=o.useState(s?.local.enabled??!1),[P,N]=o.useState(s?.local.session??""),E=s?.tenant_id??void 0,z=t==="visible",K=s?.account_id??null,x=K!==null&&K===a,R=p.kind==="ready"?p.settings.share_typing:void 0;o.useEffect(()=>{typeof R=="boolean"&&ha.getState().setShareTyping(R)},[R]),o.useEffect(()=>{if(!z)return;let C=!1;return g({kind:"loading"}),y(null),(async()=>{try{const D=await i.settings(E);if(C)return;if(!D){g({kind:"error",refusal:{code:"invalid_response",message:n("ui.agentMessages.settings.error.unreadable")}});return}let J=null;if(D.endpoint){if(J=await i.allowlist(D.settings.tenant_id),C)return;if(!J){g({kind:"error",refusal:{code:"invalid_response",message:n("ui.agentMessages.settings.error.unreadable")}});return}}g({kind:"ready",settings:D,allowlist:J})}catch(D){if(C)return;g({kind:"error",refusal:He(D)})}})(),()=>{C=!0}},[z,a,K,E,f,i]),o.useEffect(()=>{if(!z||p.kind!=="ready"||!p.settings.endpoint||p.allowlist)return;let C=!1;return(async()=>{try{const D=await i.allowlist(p.settings.settings.tenant_id);if(C||!D)return;g(J=>J.kind==="ready"&&!J.allowlist?{...J,allowlist:D}:J)}catch(D){C||y(He(D))}})(),()=>{C=!0}},[z,p,i]),o.useEffect(()=>{s&&(M(s.local.enabled),N(s.local.session))},[s]);const L=()=>j(C=>C+1),w=p.kind==="ready"?p.settings:null,V=Kl(s,w,K),$=Bl({api:i,accountId:x?K:null,tenantId:w?.settings.tenant_id??null,markerTenantId:s?.tenant_id??null,onSettings:C=>g(D=>D.kind==="ready"?{...D,settings:C}:D),onChanged:()=>c(!0)}),q=o.useRef(null),G=o.useRef(!1),v=o.useRef(m);if(o.useEffect(()=>{m!==v.current&&(v.current=m,G.current=!1)},[m]),o.useEffect(()=>{if(!u){G.current=!1;return}if(G.current||p.kind!=="ready"||_!==null)return;const C=q.current,D=Lm.map(J=>C?.querySelector(`${J}:not(:disabled)`)).find(J=>J!=null);D&&(D.focus(),G.current=!0)},[u,m,p,_,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(_e,{variant:"warning",children:[e.jsx(wn,{children:n("ui.agentMessages.settings.error.title")}),e.jsxs(Ve,{children:[r?xn(r):n("ui.agentMessages.settings.refusal.generic"),e.jsx(O,{className:"mt-3",variant:"secondary",onClick:()=>{L(),c(!0)},children:n("ui.agentMessages.settings.error.retry")})]})]})});if(!s||!a)return null;const B=Am(s);return e.jsxs("div",{ref:q,"data-agent-messages-section":"",className:"flex flex-col gap-6",children:[B&&e.jsx($m,{count:B.count,onMessage:B.sessionId&&d?()=>d(B.sessionId):void 0}),V&&e.jsx(ql,{consentText:Ir(s,w),pending:$.pending,failure:$.failure,onTurnOff:()=>void $.turnOff(),onDismiss:()=>void $.dismiss()}),A&&e.jsx(_e,{variant:"warning",children:e.jsx(Ve,{children:xn(A)})}),p.kind==="loading"&&e.jsx(Dm,{}),p.kind==="error"&&e.jsxs(_e,{variant:"warning",children:[e.jsx(wn,{children:n("ui.agentMessages.settings.error.title")}),e.jsxs(Ve,{children:[p.refusal.code!=="client_unavailable"&&e.jsx("span",{className:"block",children:xn(p.refusal)}),e.jsx("span",{className:"block",children:n("ui.agentMessages.settings.error.no_changes")}),e.jsx(O,{className:"mt-3",variant:"secondary",onClick:L,children:n("ui.agentMessages.settings.error.retry")})]})]}),p.kind==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx(zm,{state:Rt(s,p.settings),status:s,settings:p.settings,accountId:K??a,accountMatches:x,api:i,pending:_,localEnabled:I,onActionRefusal:y,onSettings:C=>g(D=>D.kind==="ready"?{...D,settings:C}:D),onLocalEnabled:M,onRefreshStatus:c,setPending:b}),h&&i.setShareTyping&&typeof p.settings.share_typing=="boolean"&&e.jsx(Km,{value:p.settings.share_typing,pending:_==="share_typing",disabled:_!==null||!x,onChange:async C=>{const D=K??a,J=i.setShareTyping;if(!(!D||!J)){b("share_typing"),y(null);try{const ee=await J(D,C);g(Z=>Z.kind==="ready"?{...Z,settings:{...Z.settings,share_typing:ee}}:Z),ha.getState().setShareTyping(ee)}catch(ee){y(He(ee))}finally{b(null)}}}}),e.jsx(Bm,{value:P,sessions:l,pending:_==="session",disabled:_!==null,onSave:async C=>{b("session"),y(null);try{await i.localSetting("team_bridge.session",C),N(C),await c(!0)}catch(D){y(He(D))}finally{b(null)}}}),p.allowlist&&(Rt(s,p.settings)==="C"||Rt(s,p.settings)==="D"||Rt(s,p.settings)==="F")&&e.jsx(qm,{allowlist:p.allowlist,accountId:K??a,accountMatches:x,readOnly:s.read_only===!0&&Rt(s,p.settings)==="F",pending:_!==null,onSaving:C=>b(C?"allowlist":null),onRefusal:y,onSaved:C=>g(D=>D.kind==="ready"?{...D,allowlist:C}:D),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(Ue,{className:"h-5 w-40"}),e.jsx(Ue,{className:"h-4 w-full max-w-xl"}),e.jsx(Ue,{className:"h-9 w-36"}),e.jsx(Ue,{className:"h-4 w-64"})]})}const $m=({count:t,onMessage:s})=>e.jsx("output",{className:"block","data-agent-messages-hold":"open_chief_of_staff",children:e.jsx(_e,{variant:"info",className:xe(Qc,"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(O,{variant:"ghost",size:"sm",className:"shrink-0 text-ink",onClick:s,children:n("ui.agentMessages.settings.hold.open")})]})})}),_a=({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})}),Bi={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"},qi={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 Pm(t){return t==="B"?"ui.agentMessages.settings.default_on.b_title":Bi[t]}function Fm(t){return t==="B"?"ui.agentMessages.settings.default_on.b_body":t==="E"?"ui.agentMessages.settings.default_on.e_body":qi[t]}const zm=({state:t,status:s,settings:a,accountId:r,accountMatches:i,api:c,pending:l,localEnabled:d,onActionRefusal:u,onSettings:m,onLocalEnabled:h,onRefreshStatus:p,setPending:g})=>{const f=Ui(s),j=a.settings.tenant_id,_=l!==null||!i,b=Tr(s);async function A(N,E={}){if(!i)return null;g(N),u(null);try{const z=await c.updateSettings({expected_account_id:r,tenant_id:j,state:N,...E});if(m(z),N==="disabled"&&!b)try{await c.localSetting("team_bridge.enabled",!1),h(!1)}catch(K){u(He(K))}return z}catch(z){const K=He(z);return u(K),K.code==="consent_version_unknown"&&await p(!0),null}finally{g(null)}}async function y(){if(!(!f||!i||!await A("active",{consent_version:f.version,consented_via:"settings"}))){g("local");try{await c.localSetting("team_bridge.enabled",!0),h(!0),await p(!0)}catch(E){u(He(E))}finally{g(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(Bn,{settings:a,status:s,readOnly:!0}),e.jsx(qn,{searchRow:"agent-messages.enabled",searchTerms:"team bridge team_bridge enabled devices",value:d,disabled:_,description:n("ui.agentMessages.settings.local.stays_enrolled"),onChange:async N=>{g("local"),u(null);try{await c.localSetting("team_bridge.enabled",N),h(N),await p(!0)}catch(E){u(He(E))}finally{g(null)}}})]});const I=a.endpoint?.label?.trim(),M=a.endpoint?.consent??null,P=M!==null&&!M.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(b?Pm(t):Bi[t])}),I&&e.jsx("span",{className:"text-body-sm text-ink-muted",children:I})]}),e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted",children:n(b?Fm(t):qi[t])}),b&&t==="E"&&e.jsxs("div",{className:"flex flex-col gap-3",children:[f?e.jsx(_a,{text:f.text}):e.jsx(_e,{variant:"warning",children:e.jsx(Ve,{children:n("ui.agentMessages.settings.consent.unavailable")})}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx(O,{"data-agent-messages-action":"turn_on_again","data-search-row":"agent-messages.enabled","data-search-control":!0,onClick:()=>void y(),disabled:_||!f,children:n("ui.agentMessages.settings.action.turn_on_again")})})]}),!b&&(t==="B"||t==="E")&&e.jsxs("div",{className:"flex flex-col gap-3",children:[f?e.jsx(_a,{text:f.text}):e.jsx(_e,{variant:"warning",children:e.jsx(Ve,{children:n("ui.agentMessages.settings.consent.unavailable")})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(O,{"data-agent-messages-action":"enable","data-search-row":"agent-messages.enabled","data-search-control":!0,onClick:()=>void y(),disabled:_||!f,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(O,{"data-agent-messages-action":"pause",variant:"secondary",disabled:_,onClick:()=>void A("paused"),children:n("ui.agentMessages.settings.action.pause")}),e.jsx(O,{"data-agent-messages-action":"turn_off",variant:"secondary",disabled:_,onClick:()=>void A("disabled"),children:n("ui.agentMessages.settings.action.turn_off")})]}),e.jsx(Bn,{settings:a,status:s}),P&&!b&&e.jsx(ya,{onRenew:()=>void y(),disabled:_||!f}),e.jsx(qn,{searchRow:"agent-messages.enabled",searchTerms:"team bridge team_bridge enabled devices",value:d,disabled:_,description:n("ui.agentMessages.settings.local.stays_enrolled"),onChange:async N=>{g("local"),u(null);try{await c.localSetting("team_bridge.enabled",N),h(N),await p(!0)}catch(E){u(He(E))}finally{g(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(O,{"data-agent-messages-action":"resume",disabled:_||a.settings.consent_required&&f===null,onClick:()=>void A("active",a.settings.consent_required&&f?{consent_version:f.version,consented_via:"settings"}:{}),children:n("ui.agentMessages.settings.action.resume")}),e.jsx(O,{"data-agent-messages-action":"turn_off",variant:"secondary",disabled:_,onClick:()=>void A("disabled"),children:n("ui.agentMessages.settings.action.turn_off")})]}),a.settings.consent_required&&!f&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.consent.unavailable")}),e.jsx(Bn,{settings:a,status:s}),P&&!b&&e.jsx(ya,{onRenew:()=>void y(),disabled:_||!f}),e.jsx(qn,{searchRow:"agent-messages.enabled",searchTerms:"team bridge team_bridge enabled devices",value:d,disabled:_,description:n("ui.agentMessages.settings.local.stays_enrolled"),onChange:async N=>{g("local"),u(null);try{await c.localSetting("team_bridge.enabled",N),h(N),await p(!0)}catch(E){u(He(E))}finally{g(null)}}})]})]})},ya=({onRenew:t,disabled:s})=>e.jsx(_e,{variant:"warning",children:e.jsxs(Ve,{children:[n("ui.agentMessages.settings.consent.renew"),e.jsx(O,{"data-agent-messages-action":"enable",className:"mt-3",variant:"secondary",disabled:s,onClick:t,children:n("ui.agentMessages.settings.action.enable_again")})]})});function Um(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 Bn=({settings:t,status:s,readOnly:a=!1})=>{const r=t.endpoint?.consent??null,i=Ui(s);return r?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs(Zt,{children:[e.jsx(Oe,{label:n("ui.agentMessages.settings.consent.version"),value:r.version}),e.jsx(Oe,{label:n("ui.agentMessages.settings.consent.via"),value:Um(r.consented_via)}),e.jsx(Oe,{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")})},qn=({value:t,disabled:s,description:a,onChange:r,searchRow:i,searchTerms:c})=>{const l=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:l,className:"text-body-sm text-ink",children:n("ui.agentMessages.settings.local.label")}),e.jsx("p",{className:"mt-0.5 text-meta text-ink-dim",children:a})]}),e.jsx(Ls,{"aria-labelledby":l,checked:t,disabled:s,onCheckedChange:d=>void r(d)})]})},Km=({value:t,pending:s,disabled:a,onChange:r})=>{const i=o.useId(),c=o.useId();return e.jsxs("div",{"data-agent-messages-share-typing":"","data-search-row":"agent-messages.share-typing","data-search-control":!0,"data-search-terms":"team bridge team_bridge typing share_typing indicator",className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{id:i,className:"text-body-sm text-ink",children:n("ui.agentMessages.settings.share_typing.label")}),e.jsx("p",{id:c,className:"mt-0.5 text-meta text-ink-dim",children:n("ui.agentMessages.settings.share_typing.description")})]}),e.jsx(Ls,{"aria-labelledby":i,"aria-describedby":c,"aria-busy":s||void 0,checked:t,disabled:a,onCheckedChange:l=>void r(l)})]})},Bm=({value:t,sessions:s,pending:a,disabled:r,onSave:i})=>{const c=s.some(l=>l.session_id===t);return e.jsxs("div",{"data-search-row":"agent-messages.session","data-search-control":!0,"data-search-terms":"team bridge team_bridge session",className:"flex flex-col gap-2",children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.agentMessages.settings.session.title")}),e.jsx("p",{className:"max-w-2xl text-meta text-ink-dim",children:n("ui.agentMessages.settings.session.help")}),e.jsxs(Os,{value:t===""?Kn:t,disabled:r,onValueChange:l=>void i(l===Kn?"":l),children:[e.jsx(Ds,{className:"w-full max-w-md","aria-label":n("ui.agentMessages.settings.session.title"),children:e.jsx($s,{})}),e.jsxs(Ps,{children:[e.jsx(kt,{value:Kn,children:n("ui.agentMessages.settings.session.none")}),s.map(l=>e.jsx(kt,{value:l.session_id,children:l.title?.trim()||l.session_id},l.session_id)),t!==""&&!c&&e.jsx(kt,{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")})]})},qm=({allowlist:t,accountId:s,accountMatches:a,readOnly:r,pending:i,api:c,onSaving:l,onRefusal:d,onSaved:u})=>{const[m,h]=o.useState(()=>ys(t.allowlist.entries)),[p,g]=o.useState(()=>({send:t.view.directions.send.mode,receive:t.view.directions.receive.mode})),f=i||r||!a,j=Ki(bs(Hm(t),Vm(t))),_=Rm({entries:m,modes:p,savedSignature:j,saving:i}),b=o.useRef(0),A=M=>h(P=>[...P,{...M,key:`${M.direction}:${M.effect}:${b.current++}`}]),y=M=>h(P=>P.filter(N=>N.key!==M)),I=async()=>{if(!f){l(!0),d(null);try{const M=await c.updateAllowlist({expected_account_id:s,tenant_id:t.allowlist.tenant_id,entries:bs(m,p)}),P=ys(M.allowlist.entries);h(P),g({send:M.view.directions.send.mode,receive:M.view.directions.receive.mode}),u(M)}catch(M){d(He(M))}finally{l(!1)}}};return e.jsxs("div",{"data-agent-messages-allowlist":"",className:"flex flex-col gap-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.agentMessages.settings.allowlist.title")}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.allowlist.description")})]}),e.jsx(ba,{direction:"receive",title:n("ui.agentMessages.settings.allowlist.receive"),mode:p.receive,cues:t.view.cues,entries:m.filter(M=>M.direction==="receive"),disabled:f,onMode:M=>g(P=>({...P,receive:M})),onAdd:M=>A({...M,direction:"receive"}),onRemove:y}),e.jsx(ba,{direction:"send",title:n("ui.agentMessages.settings.allowlist.send"),mode:p.send,cues:t.view.cues,entries:m.filter(M=>M.direction==="send"),disabled:f,onMode:M=>g(P=>({...P,send:M})),onAdd:M=>A({...M,direction:"send"}),onRemove:y}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(O,{onClick:()=>void I(),disabled:_.disabled||f,children:[e.jsx(Ai,{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 Hm(t){return ys(t.allowlist.entries)}function Vm(t){return{send:t.view.directions.send.mode,receive:t.view.directions.receive.mode}}const ba=({direction:t,title:s,mode:a,cues:r,entries:i,disabled:c,onMode:l,onAdd:d,onRemove:u})=>{const m=i.filter(p=>p.effect==="allow"),h=i.filter(p=>p.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(Wm,{mode:a,disabled:c,onMode:l}),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(p=>e.jsx(va,{entry:p,disabled:c,onRemove:()=>u(p.key)},p.key)),e.jsx(ka,{label:n("ui.agentMessages.settings.allowlist.add_allowed"),disabled:c,onAdd:p=>d({...p,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")}),h.length===0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.agentMessages.settings.allowlist.blocked_empty")}),h.map(p=>e.jsx(va,{entry:p,disabled:c,onRemove:()=>u(p.key)},p.key)),e.jsx(ka,{label:n("ui.agentMessages.settings.allowlist.add_blocked"),disabled:c,onAdd:p=>d({...p,effect:"deny"})})]})]})},Wm=({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(O,{variant:"ghost",size:"sm","aria-pressed":t===i.value,disabled:s,onClick:()=>a(i.value),className:xe(t===i.value&&"bg-surface text-ink hover:bg-surface"),children:i.label},i.value))})]})},va=({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(O,{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")})]}),ka=({label:t,disabled:s,onAdd:a})=>{const[r,i]=o.useState("endpoint"),[c,l]=o.useState(""),[d,u]=o.useState(null),m=o.useId(),h=`${m}-help`,p=()=>{const g=Tm(c.trim());u(g),!g&&(a({kind:r,id:c.trim()}),l(""))};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(We,{htmlFor:m,children:t}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Os,{value:r,disabled:s,onValueChange:g=>i(g),children:[e.jsx(Ds,{className:"w-32","aria-label":n("ui.agentMessages.settings.allowlist.kind"),children:e.jsx($s,{})}),e.jsxs(Ps,{children:[e.jsx(kt,{value:"endpoint",children:n("ui.agentMessages.settings.allowlist.kind_agent")}),e.jsx(kt,{value:"account",children:n("ui.agentMessages.settings.allowlist.kind_person")})]})]}),e.jsx($e,{id:m,"aria-describedby":h,className:"max-w-xs",value:c,disabled:s,placeholder:n("ui.agentMessages.settings.allowlist.identifier"),onChange:g=>l(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),p())}}),e.jsx(O,{variant:"secondary",size:"sm",disabled:s,onClick:p,children:n("ui.agentMessages.settings.allowlist.add")})]}),e.jsx("p",{id:h,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")}),d&&e.jsx("p",{className:"text-meta text-danger",children:d})]})};function Gm(){const{snapshot:t}=Mi(),[s,a]=o.useState(!1),r=Sm({status:t.status,refused:t.refusal!==null,everVisible:s,checking:t.checking});return o.useEffect(()=>{r!=="absent"&&a(!0)},[r]),o.useEffect(()=>{Gc()},[]),r}function Bs(t){const s=a=>typeof a=="string"?Wt(a):Wt((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 Ym(t){const s=new Map;for(const a of t??[])s.set(a.name,{label:a.title||a.name,folded:Wt([a.title,a.name].join(" "))});return s}function Qm(t,s={}){if(!t)return[];const{startOrder:a=0,sections:r=[]}=s,i=Ym(t.sections),c=new Map(r.map(l=>[l.id,l.label]));return t.settings.map((l,d)=>{const u=i.get(l.section),m=gn(l.key,"backend");return{id:`setting:${l.key}`,source:"registry",label:l.label||l.key,description:l.help??"",sectionId:m,sectionLabel:c.get(m)??"",detail:u?.label??l.section,order:a+d,settingKey:l.key,fields:Bs({label:l.label,synonym:l.synonyms??[],key:l.key,choice:(l.choices??[]).flatMap(h=>[h.label,h.description??""]),section:u?.folded??l.section,description:l.help})}})}function Zm(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:Bs({label:a.label})}))}function Jm(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 Xm(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 ep(t){return t.closest("[data-search-section]")}function tp(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 np(t,s=0){return Array.from(t.querySelectorAll("[data-search-row]")).map((r,i)=>{const c=ep(r),l=c?.getAttribute("data-search-section")??"",u=(c?.getAttribute("data-search-section-label")?.trim()??"")||c?.querySelector("[data-search-section-label], h2")?.textContent?.trim()||"",m=Jm(r),h=r.getAttribute("data-search-terms")??"",p=tp(r,m);return{id:`page:${r.getAttribute("data-search-row")??i}`,source:"page",label:Xm(m),sectionId:l,sectionLabel:u,order:s+i,fields:Bs({label:m,synonym:h,section:[u,l],description:p})}})}function sp(t){const s=Qm(t.registry,{startOrder:0,sections:t.sections}).filter(r=>!(r.settingKey&&r.settingKey in ko)),a=[...t.rendered??[]].map((r,i)=>({...r,order:s.length+i}));return[...s,...a,...Zm(t.sections??[],s.length+a.length)]}const ap=12,ja="input, textarea, select, button, [role='switch'], [role='tab'], [role='combobox'], [tabindex]";function ip(t,s){return t.querySelector(`[data-search-row="${CSS.escape(s)}"]`)}function rp(t){const a=(t.matches("[data-search-control]")?t:null)??t.querySelector("[data-search-control]");return a?a.matches(ja)?a:a.querySelector(ja)??a:t}function Hi(t){return t.isConnected&&t.closest("[hidden]")===null}function op(t,s,a={}){const r=a.frames??ap,i=a.paint??xi;return new Promise(c=>{let l=0;const d=()=>{const u=ip(t,s);if(u&&Hi(u)){const m=rp(u);m===u&&(u.tabIndex=-1),m.scrollIntoView({block:"center"}),m.focus(),i(u),c("landed");return}if(l+=1,l>=r){c("missing");return}requestAnimationFrame(d)};requestAnimationFrame(d)})}function cp(t,s,a={}){const r=t.querySelector(`[data-search-section="${CSS.escape(s)}"]`);return!r||!Hi(r)?"missing":(r.scrollIntoView({block:"start"}),r.tabIndex<0&&(r.tabIndex=-1),r.focus(),(a.paint??xi)(r),"landed")}const wa={get[st.UI](){return n("ui.settings.updates.update_following.application_updates")},get[st.BACKEND](){return n("ui.settings.updates.update_following.server_updates")}},rn={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")}}},Na=({type:t})=>{ne();const s=ds(r=>r.followed[t]),a=ds(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:wa[t]}),e.jsx("div",{className:"mt-0.5 text-meta text-ink-muted",children:rn[s].description})]}),e.jsxs(Os,{value:s,onValueChange:r=>a(t,r),children:[e.jsx(Ds,{"aria-label":n("ui.settings.updates.update_following.surface_choice",{surface:wa[t],choice:rn[s].label}),className:"w-full sm:w-56","data-followed-segment":t,children:e.jsx($s,{})}),e.jsx(Ps,{children:jo.map(r=>e.jsx(kt,{value:r,title:rn[r].description,children:rn[r].label},r))})]})]})},lp=()=>(ne(),e.jsxs("div",{className:xe("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(Na,{type:st.UI}),e.jsx(Na,{type:st.BACKEND})]})]})),dp=({appVersion:t})=>e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(lp,{}),e.jsx(mm,{appVersion:t})]}),up=t=>{if(!t)return null;try{return new URL(t).host}catch{return null}},mp=()=>{ne();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 d=!0;const u=f=>{if(!d)return;const j=up(f.url);if(f.state==="connecting"){r({value:"Loading...",detail:null,degraded:!1});return}if(f.state==="detached"){r({value:"Not connected",detail:f.detail||null,degraded:!1});return}if(f.state==="wedged"){r({value:"Not attached",detail:f.detail||null,degraded:!1});return}const _=f.version||"Version unknown";r({value:j?`${_} · ${j}`:_,detail:f.detail||null,degraded:f.state==="degraded"})};let m=!1;const h=window.api?.backend?.onStatusChange(f=>{m=!0,u(f)}),p=async()=>{try{const[f,j]=await Promise.all([window.api.systemInfo.getAppVersion(),window.api.systemInfo.getPlatformInfo()]);d&&(s(f),c(j))}catch(f){console.error("Error fetching app information:",f)}},g=async()=>{try{const f=window.api?.backend;if(f){const b=await f.getStatus();m||u(b);return}const j=await aa.healthCheck(Ss.baseUrl),_=aa.getServerVersion(j);d&&r({value:_,detail:null,degraded:!1})}catch(f){console.error("Error fetching server version:",f),d&&r({value:"Unavailable",detail:null,degraded:!1})}};return p(),g(),()=>{d=!1,h?.()}},[]);const l=(d,u,m,h={})=>e.jsx(Oe,{label:e.jsx(et,{content:m,children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Nn,{size:12,className:"shrink-0"}),d]})}),valueClassName:h.valueClassName,value:e.jsxs(e.Fragment,{children:[h.valueTooltip?e.jsx(et,{content:h.valueTooltip,children:e.jsx("span",{"data-backend-version":h.valueHoverTarget?"":void 0,children:u})}):u,h.statusNote?e.jsx("span",{className:"mt-0.5 block text-meta text-ink-dim",children:h.statusNote}):null]})});return e.jsx(Re,{title:n("ui.settings.updates.app_updates_section.application_updates_and_info"),icon:us,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(Zt,{children:[l(n("ui.settings.updates.app_updates_section.application_version"),t??n("ui.settings.updates.app_updates_section.state_loading"),n("ui.settings.updates.app_updates_section.the_version_of_the_local_operator_user_interface_application")),l(n("ui.settings.updates.app_updates_section.server_version"),Fn(a.value),n("ui.settings.updates.app_updates_section.the_version_of_the_local_operator_api_server_backend_and_the_addr"),{valueTooltip:a.detail,valueHoverTarget:!0,statusNote:a.degraded?n("ui.settings.updates.app_updates_section.not_answering"):void 0,valueClassName:a.degraded?"text-ink-muted":void 0}),l(n("ui.settings.updates.app_updates_section.platform"),`${i.platform} (${i.arch})`,n("ui.settings.updates.app_updates_section.the_operating_system_and_architecture_your_application_is_running")),l(n("ui.settings.updates.app_updates_section.node_js_version"),Fn(i.nodeVersion),n("ui.settings.updates.app_updates_section.the_javascript_runtime_environment_version")),l(n("ui.settings.updates.app_updates_section.electron_version"),Fn(i.electronVersion),n("ui.settings.updates.app_updates_section.the_framework_version_enabling_this_desktop_application"))]}),e.jsx(dp,{appVersion:t})]})})};function Vi(t){const s={id:"",name:n("ui.settings.model.default_effort.model_default")};return t.resolvedLevel&&t.stored.trim()===""&&qs(t.resolvedLevel,t.storable)!==null&&(s.description=n("ui.settings.model.default_effort.model_default_resolves",{level:dt(t.resolvedLevel)})),[s,...Wi(t.ladder,t.storable)]}function qs(t,s){const a=t.trim().toLowerCase();return a===""?null:s.find(r=>r.trim().toLowerCase()===a)??null}function Wi(t,s){return t.flatMap(a=>{const r=qs(a,s);return r===null?[]:[{id:r,name:dt(a)}]})}function pp(t,s){const a=t.trim().toLowerCase();return a!==""&&s.some(r=>r.toLowerCase()===a)?s.find(r=>r.toLowerCase()===a)??"":""}function gp(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===""?"":qs(a,t.storable)??"";return r.trim().toLowerCase()===s?null:r}const _n="\0unread";function on(t){return t.trim()===""?"":_n}function hp(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"),_n);if(t.settings==="loading")return nt("settings-loading",n("ui.settings.model.default_effort.settings_loading"),_n);if(t.settings==="error")return nt("settings-error",n("ui.settings.model.default_effort.settings_error"),_n);if(t.preview==="loading")return nt("loading",n("ui.settings.model.default_effort.loading"),on(t.stored));if(t.preview==="error")return nt("error",n("ui.settings.model.default_effort.error"),on(t.stored));if(t.ladder===null||!t.specResolved)return nt("unresolved",n("ui.settings.model.default_effort.unresolved"),on(t.stored));const s=t.ladder;if(s.length===0)return nt("empty",n("ui.settings.model.default_effort.empty"),on(t.stored));const a=Wi(s,t.storable);if(a.length===0){const r=dt(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:Vi({ladder:s,resolvedLevel:t.resolvedLevel,stored:t.stored,storable:t.storable}),selectedId:pp(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:Vi({ladder:[],resolvedLevel:null,stored:"",storable:[]}),selectedId:a,disabled:!0,helper:s}}const fp=({hosting:t,modelName:s,focus:a=!1,focusNonce:r})=>{ne();const i=gt(),c=Qe(i.data,"draft_preview"),l=wo(),d=t!==""&&s!=="",u=ze({queryKey:mt.all,queryFn:()=>Ne({op:"settings.list"}),enabled:c,staleTime:1e4}),m=u.data?.settings.find(ie=>ie.key===bt),h=typeof m?.value=="string"?m.value:"",p=(m?.choices??[]).map(ie=>ie.value).filter(ie=>typeof ie=="string"),g={cwd:l??"",model:d?{provider:t,model_id:s,reasoning_effort:null}:null},f=u.isSuccess?h:null,j=ze({...Or(g,Qe(i.data,"draft_fast")),queryKey:[...Lr(g),"model_effort",f],enabled:c&&!!l&&d}),_=j.isSuccess&&!j.isPlaceholderData,b=_?Dr(j.data?.snapshot,null).effort:null,A=_&&Array.isArray(b?.reasoning_efforts)?$r(b):null,y=_?Pr(b):null,I=b!==null&&!Fr(b),[M,P]=o.useState(!1),[N,E]=o.useState(!1),[z,K]=o.useState(null),[x,R]=o.useState(null),L=`${t}\0${s}`,w=Nt(),V=o.useRef(null),$=o.useRef(!1),q=o.useRef(r);o.useEffect(()=>{r!==q.current&&(q.current=r,$.current=!1)},[r]);const G=o.useCallback(async(ie,de)=>{P(!0),K(ie),E(!1),de===null&&R(null);try{await Ne({op:"settings.edit",key:bt,value:ie}),await w.invalidateQueries({queryKey:mt.all}),de!==null&&R(de)}catch{E(!0)}finally{P(!1),K(null)}},[w]),v=typeof b?.display_name=="string"&&b.display_name.trim()||s,B=hp({supported:c,hasHome:!!l,hasModel:d,settings:u.isError?"error":u.isSuccess?"ready":"loading",preview:j.isError?"error":_?"ready":"loading",ladder:A,specResolved:I,stored:h,resolvedLevel:y,storable:p}),C=gp({stored:h,ladder:A,resolvedLevel:y,resolved:_&&I&&u.isSuccess,storable:p}),D=o.useRef(null);o.useEffect(()=>{if(C===null||M)return;const ie=`${t}\0${s}\0${h}\0${C}`;if(D.current===ie)return;D.current=ie;const de=C===""?n("ui.settings.model.default_effort.clamped_unset",{level:dt(h),model:v}):n("ui.settings.model.default_effort.clamped",{level:dt(h),model:v,resolved:dt(C)});G(C,{text:de,model:L})},[C,h,M,G,t,s,v,L]);const J=o.useMemo(()=>B.options.map(xp),[B.options]);o.useEffect(()=>{if(!a){$.current=!1;return}B.disabled||$.current||(V.current?.querySelector("[role=combobox]")?.focus(),$.current=!0)},[a,r,B.disabled]);const ee=z??B.selectedId,Z=J.find(ie=>ie.id===ee)??(z!==null?{id:z,name:dt(z)}:null),ce=e.jsxs("span",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{children:B.helper}),N&&e.jsx("span",{className:"text-danger",children:n("ui.settings.model.default_effort.save_failed")}),e.jsx("output",{"aria-live":"polite",children:x?.model===L?x.text:""})]});return B.kind==="unsupported"?null:e.jsx("div",{ref:V,"data-setting-key":bt,children:e.jsx(Ii,{label:n("ui.settings.model.default_effort.label"),icon:e.jsx(Zc,{size:16,"aria-hidden":"true"}),placeholder:n("ui.settings.model.default_effort.placeholder"),options:J,selected:Z,onSelect:ie=>{G(ie.id,null)},helperText:ce,busy:M,busyLabel:n("ui.settings.model.default_effort.busy"),disabled:B.disabled||M})})};function xp(t){return{id:t.id,name:t.name,description:t.description}}const _p=t=>t.replace(/[\p{Co}\p{Cc}]/gu," ").replace(/\s+/g," ").trim(),Gi=(t,s)=>{const a=s.trim().toLocaleLowerCase();return a?t.filter(r=>`${r.title} ${r.cwd} ${r.sourceId}`.toLocaleLowerCase().includes(a)):t},yp=(t,s)=>`${t??""}\0${[...s].sort().join("\0")}`,Yi=5e3,bp=(t,s,a,r=Yi)=>{const i=new Set(a);let c=!1;for(const l of Gi(t,s))if(!i.has(l.sourceId)){if(i.size>=r){c=!0;break}i.add(l.sourceId)}return{selected:i,capped:c}},vp=/cancel/i,kp=new Set(["done","failed","cancelled"]),Sa=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"}},Hn=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"}},jp=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"}},wp=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"}},Np=t=>t==="failed"?"danger":t==="metadata_only"||t==="skipped_already_imported"?"neutral":t==="cancelled"?"warning":"success",vs=t=>_p(t.title)||t.sourceId,Ca=({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(O,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{a(t).then(c=>{c&&(i(!0),window.setTimeout(()=>i(!1),1500))})},children:[r?e.jsx(En,{size:14}):e.jsx(_i,{size:14}),r?n("ui.settings.imports.copied"):n("ui.settings.imports.copy_path")]})]})},Sp=({progress:t,sessions:s,selected:a})=>{const r=new Map(t.results.map(d=>[d.sourceId,d])),i=t.sessionId,c=Math.max(0,t.total-t.completed-(i&&!r.has(i)?1:0)),l=s.filter(d=>a.has(d.sourceId));return e.jsxs("div",{className:"flex flex-col gap-2",children:[t.results.map(d=>e.jsx(Qi,{row:d,jobCancelled:t.state==="cancelled"},`${d.source}:${d.sourceId}`)),l.filter(d=>!r.has(d.sourceId)&&d.sourceId!==i).map(d=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-hairline bg-surface p-2 text-body-sm text-ink-muted",children:[e.jsx("span",{className:"min-w-0 truncate",children:vs(d)}),e.jsx(wt,{variant:"neutral",children:n("ui.settings.imports.session_pending")})]},d.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(hn,{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(d=>e.jsx("p",{className:"text-meta text-warning",children:d.message},`${d.code}:${d.sessionId}:${d.message}`))]})},Qi=({row:t,jobCancelled:s=!1})=>{const r=s&&t.outcome==="failed"&&t.warnings.some(i=>vp.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(wt,{variant:Np(r),children:n(wp(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))]})},Cp=({sources:t,activeSource:s,sessions:a,query:r,selected:i,preview:c,previewStale:l,previewError:d,confirmed:u,busy:m,error:h,progress:p,result:g,cancelling:f,onSelectSource:j,onQueryChange:_,onToggleSession:b,onSelectAll:A,onClearSelection:y,onConfirmChange:I,onImport:M,onCancel:P,onRetry:N,onImportAnother:E,onRefresh:z,selectionNotice:K,onCopyPath:x})=>{ne();const R=t.find(v=>v.source===s),L=p!==null&&!kp.has(p.state),w=p?.total??i.size,V=o.useMemo(()=>Gi(a,r),[r,a]),$=V.length>0&&V.every(v=>i.has(v.sourceId)),q=i.size,G=q>0&&c!==null&&!l&&u&&!m&&!p&&!g;return e.jsx(Re,{title:n("ui.settings.imports.title"),icon:us,description:n("ui.settings.imports.description"),dataTourTag:"settings-import-section",children:e.jsxs("div",{className:"flex flex-col gap-5",children:[h&&e.jsxs(_e,{variant:"warning",children:[e.jsx(wn,{children:n("ui.settings.imports.title")}),e.jsx(Ve,{children:e.jsxs("span",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("span",{children:h}),e.jsx(O,{variant:"secondary",size:"sm",onClick:N,children:n("ui.settings.imports.retry")})]})})]}),m==="sources"&&t.length===0?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ue,{className:"h-20 w-full"}),e.jsx(Ue,{className:"h-20 w-full"}),e.jsx(Ue,{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(O,{variant:"ghost",size:"sm",onClick:z,disabled:L||m==="sources"||m==="sessions",children:[e.jsx(Jc,{size:14,className:xe(m==="sources"&&"animate-spin")}),n("ui.settings.imports.refresh")]})]}),!t.some(v=>v.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(v=>{const B=v.source===s,C=v.detected?n(Sa(v.availability)):n("ui.settings.imports.source_not_found");return e.jsxs("button",{type:"button","aria-pressed":B,disabled:L,onClick:()=>j(v.source),className:xe("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",B?"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:v.label}),e.jsx(wt,{variant:v.detected&&v.availability==="full"?"success":"neutral",children:C})]}),e.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:n("ui.settings.imports.source_sessions",{count:v.sessionCount})}),e.jsx("p",{className:"mt-1 break-all text-meta text-ink-dim",children:v.detail||v.root})]},v.source)})})]}),R&&!p&&!g&&e.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("h3",{className:"text-heading text-ink",children:[n("ui.settings.imports.source_heading")," · ",R.label]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{variant:"secondary",size:"sm",onClick:$?y:A,disabled:V.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})})]})]}),K&&e.jsx("output",{className:"text-meta text-warning",children:K}),e.jsxs("div",{className:"relative",children:[e.jsx(As,{size:15,className:"pointer-events-none absolute top-1/2 start-3 -translate-y-1/2 text-ink-dim"}),e.jsx($e,{value:r,onChange:v=>_(v.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(Ue,{className:"h-12 w-full"}),e.jsx(Ue,{className:"h-12 w-full"}),e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.loading_sessions",{source:R.label})})]}):a.length===0?e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.imports.empty_sessions",{source:R.label})}):V.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:V.map(v=>{const B=`import-session-${v.source}-${v.sourceId}`;return e.jsxs("div",{className:xe("flex items-start gap-3 rounded-md border p-3",i.has(v.sourceId)?"border-accent bg-row-selected":"border-hairline bg-surface hover:bg-sunken"),children:[e.jsx(xs,{id:B,checked:i.has(v.sourceId),onCheckedChange:()=>b(v.sourceId),"aria-label":vs(v),className:"mt-0.5"}),e.jsxs("label",{htmlFor:B,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:vs(v)}),e.jsx(wt,{variant:v.availability==="full"?"neutral":"warning",children:n(Sa(v.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:v.messageCount??0,compactions:v.compactionCount})}),e.jsx("span",{children:n("ui.settings.imports.session_updated",{date:Es(new Date((v.updatedTs||v.createdTs)*1e3))})})]}),v.cwd&&e.jsx("span",{className:"mt-1 block break-all font-mono text-meta text-ink-dim",children:v.cwd}),v.availability==="metadata_only"&&e.jsx("span",{className:"mt-1 block text-meta text-warning",children:n("ui.settings.imports.metadata_only_explain")}),v.availability==="unsupported"&&e.jsx("span",{className:"mt-1 block text-meta text-warning",children:n("ui.settings.imports.session_index_only")})]})]},v.sourceId)})})]}),R&&q>0&&!p&&!g&&e.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.preview_heading")}),(m==="preview"||l||c===null&&!d)&&e.jsxs("p",{className:"flex items-center gap-2 text-meta text-ink-muted",children:[e.jsx(hn,{size:14,className:"animate-spin"}),n("ui.settings.imports.loading_preview")]}),c&&!l&&e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border border-hairline bg-surface p-4",children:[e.jsx("p",{className:"text-body-sm text-ink",children:n("ui.settings.imports.preview_summary",{sessions:c.totalSessions,messages:c.totalMessages,compactions:c.totalCompactions})}),e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.preview_memory",{records:c.totalMemoryRecords,tokens:zr(c.projectedMemoryTokens)})}),c.warnings.slice(0,4).map((v,B)=>e.jsx("p",{className:"text-meta text-warning",children:v.message},`${v.code}:${v.sessionId}:${B}`)),c.warnings.length>4&&e.jsx("p",{className:"text-meta text-warning",children:n("ui.settings.imports.warnings_heading",{count:c.warnings.length})}),e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.preview_confirm")})]}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-hairline bg-surface p-4",children:[d&&e.jsx(_e,{variant:"warning",children:e.jsx(Ve,{children:e.jsxs("span",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("span",{children:d}),e.jsx(O,{variant:"secondary",size:"sm",onClick:N,children:n("ui.settings.imports.retry")})]})})}),e.jsxs("div",{className:"flex items-start gap-2 text-body-sm text-ink",children:[e.jsx(xs,{checked:u,onCheckedChange:v=>I(v===!0),disabled:!c||l,"aria-label":n("ui.settings.imports.confirm_label"),className:"mt-0.5"}),e.jsx("span",{children:n("ui.settings.imports.confirm_label")})]}),e.jsxs(O,{variant:"primary",onClick:M,disabled:!G,className:"self-start",children:[m==="start"?e.jsx(hn,{size:14,className:"animate-spin"}):e.jsx(us,{size:14}),n("ui.settings.imports.import_button",{count:q})]})]})]}),p&&!g&&e.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.progress_heading")}),e.jsxs(O,{variant:"secondary",size:"sm",onClick:P,disabled:f||p.state==="done"||p.state==="cancelled"||p.state==="failed",children:[e.jsx(No,{size:12}),f?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:p.jobId,state:n(Hn(p.state))})," · ",n(jp(p.phase))]}),e.jsx(Ti,{value:p.total?p.completed/p.total*100:0,className:"h-1.5"}),e.jsx(Sp,{progress:p,sessions:a,selected:i})]}),g&&e.jsxs("div",{className:"flex flex-col gap-3 border-t border-hairline pt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h3",{className:"text-heading text-ink",children:n("ui.settings.imports.result_heading")}),e.jsx(O,{variant:"secondary",size:"sm",onClick:E,children:n("ui.settings.imports.import_another")})]}),e.jsx("p",{className:"text-body-sm text-ink",children:g.state==="cancelled"?n("ui.settings.imports.result_summary_cancelled",{state:n(Hn(g.state)),sessions:g.sessions.length,total:w,messages:g.messages}):n("ui.settings.imports.result_summary",{state:n(Hn(g.state)),sessions:g.sessions.length,messages:g.messages})}),g.sessions.map(v=>e.jsx(Qi,{row:v,jobCancelled:g.state==="cancelled"},`${v.source}:${v.sourceId}:${v.targetSessionId}`)),(g.instructionReviewPath||g.memoryReviewPath)&&e.jsxs("div",{className:"flex flex-col gap-2",children:[g.instructionReviewPath&&e.jsx(Ca,{path:g.instructionReviewPath,label:n("ui.settings.imports.review_instructions"),onCopyPath:x}),g.memoryReviewPath&&e.jsx(Ca,{path:g.memoryReviewPath,label:n("ui.settings.imports.review_memory"),onCopyPath:x})]}),g.warnings.length>0&&e.jsx(_e,{variant:"warning",children:e.jsx(Ve,{children:e.jsxs("span",{className:"flex flex-col gap-1",children:[e.jsx("span",{children:n("ui.settings.imports.warnings_heading",{count:g.warnings.length})}),g.warnings.slice(0,4).map((v,B)=>e.jsx("span",{children:v.message},`${v.code}:${B}`))]})})}),g.error&&e.jsx(_e,{variant:"danger",children:e.jsx(Ve,{children:g.error})}),e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.settings.imports.rerun_safe")})]}),m==="start"&&!p&&e.jsxs("p",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(hn,{size:14,className:"animate-spin"}),n("ui.settings.imports.importing")]})]})})},Hs=t=>({source:t.source,sessionId:t.session_id,code:t.code,message:t.message}),Zi=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}),Mp=t=>({jobId:t.job_id,state:t.state,sessions:t.sessions.map(Zi),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(Hs),error:t.error});async function Ap(){return(await Ne({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 Ep(t,s=!1){return(await Ne({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 Rp(t){const s=await Ne({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(Hs),instructionReviewPaths:s.instruction_review_paths}}async function Ip(t){return(await Ne({op:"imports.start",sources:t.sources,sessionIds:t.sessionIds,includeMemory:t.includeMemory??!0,includeInstructions:t.includeInstructions??!0})).job_id}async function Tp(t){const s=await Ne({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(Zi),warnings:s.warnings.map(Hs),error:s.error,startedAt:s.started_at,updatedAt:s.updated_at,result:s.result?Mp(s.result):void 0}}async function Lp(t){await Ne({op:"imports.cancel",jobId:t})}const cn=new Set(["done","failed","cancelled"]),_t=t=>t instanceof Error?t.message:String(t),Op=()=>{ne();const[t,s]=o.useState([]),[a,r]=o.useState(null),[i,c]=o.useState([]),[l,d]=o.useState(""),[u,m]=o.useState(new Set),[h,p]=o.useState(null),[g,f]=o.useState(null),[j,_]=o.useState(!1),[b,A]=o.useState(null),[y,I]=o.useState(null),[M,P]=o.useState(null),[N,E]=o.useState(null),[z,K]=o.useState(!1),[x,R]=o.useState(null),[L,w]=o.useState(0),V=o.useRef(0),$=o.useRef(0),[q,G]=o.useState(null),[v,B]=o.useState(null),C=o.useRef(null),D=M!==null&&!cn.has(M.state),J=o.useCallback(async()=>{A("sources"),I(null);try{const se=await Ap();s(se),r(re=>se.some(Q=>Q.source===re&&Q.detected)?re:se.find(Q=>Q.detected)?.source??null)}catch(se){I(n("ui.settings.imports.error_sources",{reason:_t(se)}))}finally{A(null)}},[]);o.useEffect(()=>{J()},[J]);const ee=o.useCallback(async se=>{const re=++V.current;A("sessions"),I(null);try{const ve=await Ep(se);if(re!==V.current)return;c(ve)}catch(ve){if(re!==V.current)return;c([]),I(n("ui.settings.imports.error_sessions",{source:se,reason:_t(ve)}))}finally{re===V.current&&A(null)}},[]);o.useEffect(()=>{if(!a){c([]);return}c([]),m(new Set),p(null),f(null),G(null),B(null),_(!1),E(null),P(null),ee(a)},[a,ee]);const Z=o.useCallback(se=>{m(se),_(!1),G(null),B(null),R(null)},[]),ce=o.useCallback(se=>{D||(r(se),d(""))},[D]),ie=o.useCallback(se=>{const re=new Set(u);re.has(se)?re.delete(se):re.add(se),Z(re)},[Z,u]),de=o.useCallback(()=>{const se=bp(i,l,u);Z(se.selected),se.capped&&R(n("ui.settings.imports.selection_limit",{max:Yi}))},[l,Z,u,i]),Se=o.useCallback(()=>{Z(new Set)},[Z]),H=o.useMemo(()=>yp(a,u),[a,u]),U=h!==null&&g!==H,k=o.useCallback(async()=>{if(!a||u.size===0)return;const se=++$.current,re=H;A("preview"),I(null),B(null);try{const ve=await Rp({sources:[a],sessionIds:{[a]:[...u].sort()}});if(se!==$.current)return;p(ve),f(re)}catch(ve){if(se!==$.current)return;p(null),f(null),G(re),B(n("ui.settings.imports.error_preview",{reason:_t(ve)}))}finally{se===$.current&&A(null)}},[a,H,u]);o.useEffect(()=>{if(!a||u.size===0||M||N||h&&g===H||!h&&q===H)return;const se=setTimeout(()=>{k()},250);return()=>clearTimeout(se)},[a,u,H,h,g,q,M,N,k]);const Y=o.useCallback(async()=>{if(!(!a||u.size===0||!h||U||!j||M)){A("start"),I(null),E(null);try{const se=await Ip({sources:[a],sessionIds:{[a]:[...u].sort()}}),re=Date.now()/1e3;P({jobId:se,state:"queued",phase:"queued",source:a,sessionId:"",completed:0,total:u.size,results:[],warnings:[],error:"",startedAt:re,updatedAt:re})}catch(se){I(n("ui.settings.imports.error_start",{reason:_t(se)}))}finally{A(null)}}},[a,j,h,U,M,u]),ae=M?.jobId??null,ue=M?.state??null;o.useEffect(()=>{if(!ae||!ue||cn.has(ue))return;let se=!0,re;const ve=async()=>{try{const Q=await Tp(ae);if(!se)return;if(C.current){const ge=C.current;C.current=null,I(he=>he===ge?null:he)}P(Q),Q.result&&E({...Q.result,jobId:Q.jobId}),cn.has(Q.state)||(re=setTimeout(ve,900))}catch(Q){if(!se)return;const ge=n("ui.settings.imports.error_job",{reason:_t(Q)});C.current=ge,I(ge),re=setTimeout(ve,2e3)}};return re=setTimeout(ve,L>0?0:700),()=>{se=!1,re&&clearTimeout(re)}},[ae,ue,L]);const ke=o.useCallback(async()=>{if(!(!M||cn.has(M.state))){K(!0),I(null);try{await Lp(M.jobId)}catch(se){I(n("ui.settings.imports.error_cancel",{reason:_t(se)}))}finally{K(!1)}}},[M]),me=o.useCallback(()=>{m(new Set),p(null),f(null),G(null),B(null),_(!1),R(null),E(null),P(null),I(null),a&&ee(a)},[a,ee]),pe=o.useCallback(async se=>{try{return await navigator.clipboard.writeText(se),!0}catch{return!1}},[]),je=o.useCallback(async()=>{D||(R(null),G(null),B(null),await J(),a&&await ee(a))},[a,D,ee,J]),Ke=o.useCallback(()=>{if(D){I(null),w(se=>se+1);return}G(null),B(null),je()},[D,je]);return e.jsx(Cp,{sources:t,activeSource:a,sessions:i,query:l,selected:u,preview:h,previewStale:U,previewError:v,confirmed:j,busy:b,error:y,progress:M,result:N,cancelling:z,onSelectSource:ce,onQueryChange:d,onToggleSession:ie,onSelectAll:de,onClearSelection:Se,onConfirmChange:_,onImport:()=>void Y(),onCancel:()=>void ke(),onRetry:Ke,onImportAnother:me,onRefresh:je,selectionNotice:x,onCopyPath:pe})},Ut="ui.settings.appearance.agent_avatar_size_setting",Dp=t=>t==="small"?n(`${Ut}.small`):t==="medium"?n(`${Ut}.medium`):n(`${Ut}.large`),Ma={className:"size-4",glyphClassName:"size-2"},$p=({size:t})=>{const s=Kr[t],a=Br[t],r=qr[t],i=(c,l)=>e.jsx(Ml,{className:xe("items-center justify-center text-ink-muted",c),children:e.jsx(Ei,{className:l,"aria-hidden":"true"})});return e.jsxs("div",{"aria-hidden":"true","data-agent-size-sample":t,className:"mt-3 flex items-start gap-6 rounded-md border border-hairline bg-surface p-3",children:[e.jsxs("div",{className:"flex h-10 items-center gap-2",children:[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:xe("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(Ma.className,Ma.glyphClassName),e.jsx("span",{className:"h-2 w-12 rounded-full bg-sunken"})]})]})},Pp=({value:t,onChange:s,searchRow:a})=>{ne();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(`${Ut}.agent_picture_size`)}),e.jsx("p",{className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n(`${Ut}.how_large_the_agent_s_picture_appears_in_the_chat_window_and_the_chat`)}),e.jsx($p,{size:os(t)})]}),e.jsx("div",{className:"flex h-6 shrink-0 items-center",children:e.jsx(Gt,{value:t,onValueChange:i=>s(os(i)),children:e.jsx(Yt,{"aria-labelledby":r,children:Ur.map(i=>e.jsx(ut,{value:i,children:Dp(i)},i))})})})]})},Ji=()=>{const t=be(r=>r.themeName),s=be(r=>r.customThemeId),a=Rs();return o.useMemo(()=>{const r=a.themes.find(c=>c.id===s),i=jt(r?.base??t)?.palette;return{palette:i&&r?kn(i,r):i,name:r?.name??Xe[t].name}},[t,s,a])},Vn=t=>{const s=[1,3,5].map(p=>Number.parseInt(t.slice(p,p+2),16)/255).map(p=>p<=.04045?p/12.92:((p+.055)/1.055)**2.4),[a,r,i]=s,c=Math.cbrt(.4122214708*a+.5363325363*r+.0514459929*i),l=Math.cbrt(.2119034982*a+.6806995451*r+.1073969566*i),d=Math.cbrt(.0883024619*a+.2817188376*r+.6299787005*i),u=.2104542553*c+.793617785*l-.0040720468*d,m=1.9779984951*c-2.428592205*l+.4505937099*d,h=.0259040371*c+.7827717662*l-.808675766*d;return{l:u,c:Math.hypot(m,h),h:(Math.atan2(h,m)*180/Math.PI+360)%360}},Wn=({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,l=(t-.1055613458*r-.0638541728*i)**3,d=(t-.0894841775*r-1.291485548*i)**3;return[4.0767416621*c-3.3077115913*l+.2309699292*d,-1.2684380046*c+2.6097574011*l-.3413193965*d,-.0041960863*c-.7034186147*l+1.707614701*d]},Aa=t=>{const s={l:Math.max(0,Math.min(1,t.l)),c:Math.max(0,Math.min(.4,t.c)),h:(t.h%360+360)%360},a=c=>c.every(l=>l>=-1e-7&&l<=1+1e-7),r=!a(Wn(s));if(r){let c=0,l=s.c;for(let d=0;d<22;d++){const u=(c+l)/2;a(Wn({...s,c:u}))?c=u:l=u}s.c=c}return{hex:`#${Wn(s).map(c=>{const l=c<=.0031308?12.92*c:1.055*c**.4166666666666667-.055;return Math.round(Math.max(0,Math.min(1,l))*255).toString(16).padStart(2,"0")}).join("").toUpperCase()}`,clipped:r}},Fp=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,Xi="lo-recent-colours-v1",er=()=>{try{const t=JSON.parse(localStorage.getItem(Xi)??"[]");return Array.isArray(t)?t.filter(s=>typeof s=="string"&&/^#[0-9A-Fa-f]{6}$/.test(s)).slice(0,8):[]}catch{return[]}},tr=t=>{try{localStorage.setItem(Xi,JSON.stringify([t,...er().filter(s=>s!==t)].slice(0,8)))}catch{}},nr=({value:t,onChange:s,onValidityChange:a,swatches:r=[]})=>{ne();const i=o.useId(),c=o.useRef(t),[l,d]=o.useState(()=>Vn(t)),[u,m]=o.useState(t),[h,p]=o.useState("hex"),[g,f]=o.useState(!1),[j,_]=o.useState(!1),[b,A]=o.useState(!1),y=o.useCallback((x,R,L=h)=>L==="rgb"?[1,3,5].map(w=>Number.parseInt(x.slice(w,w+2),16)).join(", "):L==="oklch"?`${(R.l*100).toFixed(2)} ${R.c.toFixed(4)} ${R.h.toFixed(2)}`:x,[h]);o.useEffect(()=>{if(t===c.current)return;c.current=t;const x=Vn(t);d(x),m(y(t,x)),_(!1),f(!1),a?.(!0)},[t,y,a]);const I=x=>{const R={l:Math.max(0,Math.min(1,x.l)),c:Math.max(0,Math.min(.4,x.c)),h:(x.h%360+360)%360},L=Aa(R);d(R),c.current=L.hex,_(L.clipped),m(y(L.hex,R)),f(!1),a?.(!0),s(L.hex)},M=x=>{const R=Vn(x);c.current=x,d(R),m(y(x,R)),_(!1),f(!1),a?.(!0),s(x)},P=()=>{const x=u.trim().split(/[\s,]+/).map(Number),R=h==="hex"?cs(u):h==="rgb"?Fp(x):null;if(h==="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){I({l:x[0]/100,c:x[1],h:x[2]});return}if(!R){f(!0),a?.(!1);return}M(R)},N=x=>{const R=x.currentTarget.getBoundingClientRect();I({...l,c:(x.clientX-R.left)/R.width*.4,l:1-(x.clientY-R.top)/R.height})},E=x=>{const R=x.shiftKey?.1:.01,L={...l};switch(x.key){case"ArrowLeft":L.c-=R*.4;break;case"ArrowRight":L.c+=R*.4;break;case"ArrowUp":L.l+=R;break;case"ArrowDown":L.l-=R;break;case"Home":L.c=0;break;case"End":L.c=.4;break;case"PageUp":L.l+=.1;break;case"PageDown":L.l-=.1;break;default:return}x.preventDefault(),I(L)},z=o.useMemo(()=>Array.from({length:48},(x,R)=>{const L=1-(R+.5)/48;return`linear-gradient(to right, ${Array.from({length:17},(w,V)=>Aa({l:L,c:V/16*.4,h:l.h}).hex).join(", ")})`}),[l.h]),K=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(l.l*100),"aria-valuetext":n("ui.settings.appearance.editor.picker.area_value",{lightness:String(Math.round(l.l*100)),chroma:l.c.toFixed(3),hue:String(Math.round(l.h))}),onKeyDown:E,onPointerDown:x=>{x.currentTarget.setPointerCapture(x.pointerId),N(x)},onPointerMove:x=>{x.currentTarget.hasPointerCapture(x.pointerId)&&N(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:z.map((x,R)=>e.jsx("div",{className:"min-h-0 flex-1",style:{background:x}},String(R)))}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute size-3 rounded-full border-2 border-white outline-1 outline-black",style:{left:`calc(${l.c/.4*100}% - 6px)`,top:`calc(${(1-l.l)*100}% - 6px)`,background:t}})]}),e.jsxs("label",{className:"flex flex-col gap-1 text-meta",children:[n("ui.settings.appearance.picker.hue"),e.jsx("input",{type:"range",dir:"ltr",min:0,max:360,step:1,value:l.h,onChange:x=>I({...l,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:l.l*100,onChange:x=>I({...l,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:l.c,onChange:x=>I({...l,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:h,onChange:x=>{p(x.target.value),m(y(t,l,x.target.value)),f(!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":h==="hex"?n("ui.settings.appearance.picker.hex"):h==="rgb"?n("ui.settings.appearance.editor.picker.rgb"):n("ui.settings.appearance.editor.picker.oklch"),value:u,"aria-invalid":g,"aria-describedby":g?`${i}-error`:void 0,onChange:x=>{m(x.target.value),f(!0),a?.(!1)},onBlur:P,onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),P())},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}})]}),g&&e.jsx("p",{id:`${i}-error`,role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.picker.invalid_channels")}),j&&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:er()}].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(R=>e.jsx("button",{type:"button","aria-label":n("ui.settings.appearance.editor.picker.swatch",{hex:R}),className:"size-7 rounded-sm border border-control focus-visible:outline-2 focus-visible:outline-accent",style:{background:R},onClick:()=>M(R)},R))}),!x.items.length&&e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.settings.appearance.editor.picker.recent_empty")})]},x.key)),K&&e.jsx(O,{type:"button",variant:"secondary",onClick:async()=>{try{const x=await new K().open(),R=cs(x.sRGBHex);R&&M(R),A(!1)}catch(x){x instanceof DOMException&&x.name==="AbortError"||A(!0)}},children:n("ui.settings.appearance.picker.eyedropper")}),b&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.picker.eyedropper_error")})]})},zp=5,Up={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"},Ea=t=>n(Up[Vr(t)]),Ra=(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,Kp=t=>{ne();const{themeName:s,themeAccent:a,themeAccentAlt:r,curated:i,all:c,paletteName:l,custom:d,customNames:u,selected:m,paintedAccent:h,adjusted:p,applied:g}=t,[f,j]=o.useState(!1),_=o.useRef(null),b=o.useRef(null),[A,y]=o.useState(null),I=f?c:i,M=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})},...I.map(w=>({key:`palette:${w.id}`,ref:{kind:"palette",id:w.id},hex:w.hex,label:n("ui.settings.appearance.accent.from_theme",{theme:l(w.id),hue:Ea(w.hex)})}))],[s,a,r,I,l]),P=d.map(w=>({key:`custom:${w}`,ref:{kind:"custom",hex:w},hex:w,custom:w,label:n("ui.settings.appearance.accent.custom_swatch",{name:u[w]??w})})),N=[...M];if(m.kind==="palette"&&!M.some(w=>Ra(w.ref,m))){const w=c.find(V=>V.id===m.id);w&&N.push({key:`palette:${w.id}`,ref:m,hex:w.hex,label:n("ui.settings.appearance.accent.from_theme",{theme:l(w.id),hue:Ea(w.hex)})})}const E=[...N,...P],z=Math.max(0,E.findIndex(w=>Ra(w.ref,m))),K=m.kind!=="theme"&&g&&p>zp?n("ui.settings.appearance.accent.adjusted"):null,x=o.useRef(null),R=w=>{if(!["ArrowRight","ArrowDown","ArrowLeft","ArrowUp"].includes(w.key)&&w.key!=="Home"&&w.key!=="End")return;const $=[...x.current?.querySelectorAll('[role="radio"]')??[]],q=$.indexOf(w.target);if(q<0)return;w.preventDefault();const G=getComputedStyle(w.currentTarget).direction==="rtl",v=w.key==="ArrowDown"||w.key==="ArrowRight"&&!G||w.key==="ArrowLeft"&&G,B=w.key==="Home"?0:w.key==="End"?$.length-1:(q+(v?1:-1)+$.length)%$.length;$[B]?.focus(),$[B]?.click()},L=(w,V)=>{const $=V===z,q=e.jsx("button",{type:"button",role:"radio","aria-checked":$,"aria-label":w.label,tabIndex:$?0:-1,"data-accent-swatch":w.key,onClick:()=>t.onSelect(w.ref),className:xe("group relative flex size-8 shrink-0 items-center justify-center rounded-full"),children:e.jsx("span",{"aria-hidden":"true",style:{backgroundColor:w.hex},className:xe("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(En,{size:14,strokeWidth:3,style:{color:w.hex.toUpperCase()===h.toUpperCase()?"var(--color-on-accent)":Wr(w.hex).ink}})})}),G=$&&K?`${w.label}. ${K}`:w.label,v=e.jsx(et,{side:"bottom",content:G,children:q},w.key);if(!w.custom)return v;const B=w.custom;return e.jsxs(So,{children:[e.jsx(Co,{asChild:!0,children:e.jsx("span",{className:"inline-flex",onContextMenuCapture:C=>{_.current=C.currentTarget.querySelector("button")},onKeyDown:C=>{if(C.key!=="ContextMenu"&&!(C.key==="F10"&&C.shiftKey))return;C.preventDefault();const D=C.currentTarget.getBoundingClientRect();C.currentTarget.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,clientX:D.left,clientY:D.bottom}))},children:v})}),e.jsxs(Mo,{onCloseAutoFocus:C=>{const D=b.current;D&&(C.preventDefault(),b.current=null,requestAnimationFrame(()=>y(D)))},children:[e.jsx(On,{onSelect:()=>{b.current={kind:"edit",hex:B}},children:n("ui.settings.appearance.accent.edit_colour")}),e.jsx(On,{onSelect:()=>{b.current={kind:"rename",hex:B}},children:n("ui.settings.appearance.accent.rename")}),e.jsx(On,{destructive:!0,onSelect:()=>t.onRemove(B),children:n("ui.settings.appearance.accent.remove")})]})]},w.key)};return e.jsx(Li,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(Al,{open:A!==null,onOpenChange:w=>{w||y(null)},children:[e.jsxs("div",{ref:x,role:"radiogroup","aria-label":n("ui.settings.appearance.accent.row_label"),onKeyDown:R,className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[N.map((w,V)=>L(w,V)),P.length>0&&e.jsx("span",{"aria-hidden":"true",className:"mx-1 h-6 w-px shrink-0 bg-hairline"}),P.map((w,V)=>L(w,N.length+V)),e.jsx(El,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:e.jsx(et,{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:w=>{_.current=w.currentTarget,y({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(jn,{size:14})})})})})})]}),e.jsx(Rl,{onCloseAutoFocus:w=>{w.preventDefault(),_.current?.focus()},align:"start",className:"w-66","aria-label":A?.kind==="rename"?n("ui.settings.appearance.picker.rename_dialog"):A?.kind==="edit"?n("ui.settings.appearance.picker.edit_dialog"):n("ui.settings.appearance.picker.dialog"),children:A?.kind==="rename"?e.jsx(qp,{initial:u[A.hex]??"",onCancel:()=>y(null),onSave:w=>{t.onRename(A.hex,w),y(null)}}):A?e.jsx(Bp,{initial:A.kind==="edit"?A.hex:h,submitLabel:A.kind==="edit"?n("ui.settings.appearance.picker.save"):n("ui.settings.appearance.picker.add"),onCancel:()=>y(null),onSubmit:w=>{A.kind==="edit"?t.onReplace(A.hex,w):t.onAdd(w),y(null)}},A.kind==="edit"?A.hex:"add"):null})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-1",children:[e.jsx(O,{variant:"linkQuiet",size:"sm","aria-expanded":f,onClick:()=>j(w=>!w),children:f?n("ui.settings.appearance.accent.show_fewer"):n("ui.settings.appearance.accent.show_all")}),d.length>=Hr&&e.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.settings.appearance.accent.limit")})]}),!g&&m.kind!=="theme"&&e.jsx("output",{className:"block px-1 text-meta text-warning",children:n("ui.settings.appearance.accent.not_applied")}),K&&e.jsx("p",{className:"px-1 text-meta text-ink-muted",children:K})]})})},Bp=({initial:t,submitLabel:s,onSubmit:a,onCancel:r})=>{const[i,c]=o.useState(cs(t)??"#3B82F6"),[l,d]=o.useState(!0);return e.jsxs("form",{onSubmit:u=>{u.preventDefault(),l&&(tr(i),a(i))},className:"flex flex-col gap-3",children:[e.jsx(nr,{value:i,onChange:c,onValidityChange:d}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(O,{type:"button",variant:"ghost",size:"sm",onClick:r,children:n("ui.settings.appearance.picker.cancel")}),e.jsx(O,{type:"submit",variant:"primary",size:"sm",disabled:!l,children:s})]})]})},qp=({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:l=>{l.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($e,{id:c,inputSize:"sm",autoFocus:!0,maxLength:Gr,value:r,onChange:l=>i(l.target.value)})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(O,{type:"button",variant:"ghost",size:"sm",onClick:a,children:n("ui.settings.appearance.picker.cancel")}),e.jsx(O,{type:"submit",variant:"primary",size:"sm",children:n("ui.settings.appearance.picker.save")})]})]})},Hp=[["canvas","canvas"],["surface","surface"],["elevated","elevated"],["sunken","sunken"],["ink","ink"],["inkMuted","ink-muted"],["inkDim","ink-dim"],["borderControl","border-control"],["hairline","hairline"],["danger","danger"],["success","success"],["warning","warning"],["info","info"]],Vp=t=>{if(!t)return null;const s=getComputedStyle(t),a={};for(const[i,c]of Hp){const l=s.getPropertyValue(`--lo-${c}`).trim();if(l==="")return null;a[i]=l}const r=s.getPropertyValue("color-scheme").trim();return{roles:a,scheme:r==="dark"||r==="light"?r:null}},Wp=(t,s,a)=>{if(!t)return{kind:"solid"};if(t.restartRequired)return{kind:"solid"};if(!t.capability.supported||t.capability.mechanism==="none")return{kind:"solid"};if(!t.active)return{kind:"solid"};if(!s)return{kind:"solid"};const r=s.scheme??a;return{kind:"glass",scheme:r,paint:Ao({...t.settings,mechanism:t.capability.mechanism,scheme:r,floors:Yr(s.roles)})}},Gp=32,Gn=t=>`#${Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0").repeat(3)}`,Yp=t=>{const s=Qr["under-window"][t],a=t==="dark"?-32:Gp;return{"--lo-preview-backdrop-a":Gn(s),"--lo-preview-backdrop-b":Gn(s+a/2),"--lo-preview-backdrop-c":Gn(s+a)}},Qp="ui.settings.appearance.layers.preview.sample_backdrop",sr=({previewTheme:t,className:s,glass:a,variant:r="full"})=>{ne();const i=o.useRef(null),[c,l]=o.useState({kind:"solid"}),d=Mn();o.useLayoutEffect(()=>{const m=()=>l(Wp(a,Vp(i.current),d.palette.mode));m();const h=requestAnimationFrame(m);return()=>cancelAnimationFrame(h)},[a,t,d]);const u=c.kind==="glass"?c.paint:null;return e.jsxs("section",{ref:i,"aria-label":n("ui.settings.appearance.layers.preview_label"),"data-appearance-preview":"","data-preview-variant":r,"data-theme":t,"data-preview-glass":u?.kinds??"",style:{...u?.vars,...c.kind==="glass"?Yp(c.scheme):null},className:xe("appearance-preview rounded-md border border-hairline",s),children:[e.jsx("div",{"data-preview-chrome":"",className:"rounded-t-md px-2 pt-1.5 pb-1 text-ink-dim text-meta",children:n("ui.settings.appearance.layers.preview_label")}),e.jsxs("div",{"data-preview-samples":"",ref:Zp,"aria-hidden":"true",className:xe("gap-2 rounded-md p-2 text-ink",r==="compact"?"flex flex-col":"grid grid-cols-[repeat(auto-fit,minmax(min(100%,200px),1fr))] items-start"),children:[e.jsxs("div",{"data-preview-region":"canvas",className:"flex min-w-0 flex-col gap-2 rounded-md bg-canvas p-1",children:[e.jsx("div",{"data-preview-block":"",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",{"data-preview-field":"",className:"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(Xc,{size:14})})]})]}),e.jsxs("div",{"data-preview-region":"sidebar",className:"flex min-w-0 flex-col gap-0.5 rounded-md bg-surface p-1",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(_s,{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")})})]}),r==="full"?e.jsxs("div",{"data-preview-region":"canvas",className:"hidden min-w-0 flex-col gap-1.5 rounded-md bg-canvas p-1 sm:flex",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",{"data-preview-field":"",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(Yn,{tone:"success"}),e.jsx(Yn,{tone:"warning"}),e.jsx(Yn,{tone:"danger"})]}):null]}),c.kind==="glass"?e.jsx("div",{"data-preview-caption":"","data-preview-chrome":"",className:"rounded-b-md px-2 pt-1 pb-1.5 text-ink-dim text-meta",children:n(Qp)}):null]})},Zp=t=>{t?.setAttribute("inert","")},Jp={success:{icon:Il,className:"border-success-border bg-success-wash text-success",key:"ui.settings.appearance.layers.preview.success"},warning:{icon:Di,className:"border-warning-border bg-warning-wash text-warning",key:"ui.settings.appearance.layers.preview.warning"},danger:{icon:Oi,className:"border-danger-border bg-danger-wash text-danger",key:"ui.settings.appearance.layers.preview.danger"}},Yn=({tone:t})=>{const{icon:s,className:a,key:r}=Jp[t];return e.jsxs("div",{className:xe("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)})]})},Xp={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"},eg={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"},Kt=t=>n(Xp[t]),Ia=t=>t>0?`+${t}`:String(t),Ta=t=>{const s=li(t);if(s)return Kt(s);const a=Jr(t);return a?n("ui.settings.appearance.contrast.value_between",{from:Kt(a[0]),to:Kt(a[1]),value:Ia(t)}):Ia(t)},tg=({committed:t,effective:s,mode:a,pending:r=!1,backgroundAtCeiling:i=!1,onDraft:c,onCommit:l})=>{ne();const[d,u]=o.useState(null),m=d??t,h=o.useId(),p=o.useId(),g=o.useRef(m);g.current=m;const f=o.useRef(!1),[j,_]=o.useState({committed:t,mode:a,pending:r});(j.committed!==t||j.mode!==a||j.pending!==r)&&(_({committed:t,mode:a,pending:r}),(j.committed!==t||j.mode!==a||j.pending&&!r)&&u(null));const b=x=>{u(x),c(x)},A=x=>{x!==t?(b(x),l(x)):(u(null),c(null))},y=li(m),I=y?null:Zr(m),M=s!==void 0&&!r&&d===null?s!==t:!1,P=x=>{if(x.button!==0)return;f.current=!0;const R=()=>{window.removeEventListener("pointerup",R),window.removeEventListener("pointercancel",R),f.current=!1,A(g.current)};window.addEventListener("pointerup",R),window.addEventListener("pointercancel",R)},N=x=>{let R=null;if(x.key==="PageUp")R=Xs(m,1);else if(x.key==="PageDown")R=Xs(m,-1);else if(x.key==="Home")R=-100;else if(x.key==="End")R=100;else if(x.key.startsWith("Arrow")){const L=getComputedStyle(x.currentTarget).direction==="rtl",w=x.key==="ArrowUp"||x.key==="ArrowRight"&&!L||x.key==="ArrowLeft"&&L,V=x.key==="ArrowDown"||x.key==="ArrowLeft"&&!L||x.key==="ArrowRight"&&L;w?R=Ln(m+Tn,{snap:!1}):V&&(R=Ln(m-Tn,{snap:!1}))}R!==null&&(x.preventDefault(),b(R))},E=x=>{(x.key.startsWith("Arrow")||x.key==="PageUp"||x.key==="PageDown"||x.key==="Home"||x.key==="End")&&A(g.current)},z=x=>{if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown"].includes(x.key))return;x.preventDefault();const L=Lt.findIndex(v=>v.name===(y??I)),w=getComputedStyle(x.currentTarget).direction==="rtl",V=x.key==="ArrowDown"||x.key==="ArrowRight"!==w,$=Math.max(0,Math.min(Lt.length-1,L+(V?1:-1))),q=Lt[$];A(q.value),x.currentTarget.querySelectorAll("[role=radio]")[$]?.focus()},K=(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:p,className:"px-1 text-meta text-ink-dim",children:n("ui.settings.appearance.contrast.title")}),t!==0&&e.jsx(O,{variant:"link",size:"sm",onClick:()=>A(0),className:"min-h-6 min-w-6 text-meta",children:n("ui.settings.appearance.contrast.reset")})]}),e.jsx("div",{role:"radiogroup","aria-labelledby":p,onKeyDown:z,className:"grid grid-cols-5 gap-2 lg:flex",children:Lt.map(({name:x,value:R})=>{const L=y===x,w=I===x,V=L||y===null&&w;return e.jsx(et,{content:n(eg[x]),side:"bottom",children:e.jsxs("button",{type:"button",role:"radio","aria-checked":L,tabIndex:V?0:-1,"data-contrast-chip":x,onClick:()=>A(R),className:xe("relative flex h-13 min-w-0 flex-1 flex-col gap-1 rounded-md p-1 text-start transition-colors duration-fast ease-out-quart max-[900px]:h-12",w&&"lg:flex-none",L?"bg-[color-mix(in_srgb,var(--color-accent)_8%,var(--color-accent-wash))]":"hover:bg-surface"),children:[e.jsxs("span",{className:xe("relative block h-6 overflow-hidden rounded-sm border",L?"border-accent":"border-hairline"),children:[e.jsxs("span",{"data-theme":Ht.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"})]}),L&&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(En,{size:10,strokeWidth:3})})]}),e.jsx("span",{className:xe("truncate px-0.5 text-meta",L?"text-ink":"text-ink-muted"),children:w?n("ui.settings.appearance.contrast.adjusted",{preset:Kt(x)}):Kt(x)})]})},x)})}),e.jsx("output",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:Ta(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:Tn,value:m,"aria-label":n("ui.settings.appearance.contrast.slider"),"aria-valuetext":Ta(m),"aria-describedby":h,"data-contrast-slider":"",onPointerDown:P,onKeyDown:N,onKeyUp:E,onChange:x=>{const R=Ln(Number(x.target.value),{snap:f.current});f.current?b(R):A(R)},style:{"--fill":`${K}%`},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:h,"aria-live":"polite",className:"px-1 text-meta text-ink-muted",children:r?n("ui.settings.appearance.contrast.applying"):M&&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")})]})},La="lo-appearance-preview",Oa=t=>{let s=document.getElementById(La);if(!t){s?.remove();return}s||(s=document.createElement("style"),s.id=La,document.head.appendChild(s)),s.textContent!==t&&(s.textContent=t)},ng=t=>{if(t.identity)return null;const s=t.palette,a={};for(const r of to)a[r]=s[r];return a},ks=new Set;let Cn=null;const ar=t=>{Cn=t;for(const s of ks)s(t)},ir=()=>{const[t,s]=o.useState(Cn);return o.useEffect(()=>(ks.add(s),()=>{ks.delete(s)}),[]),t},sg=t=>{const s=ir(),a=Ji().palette,r=o.useMemo(()=>ng(t),[t]),i=o.useMemo(()=>a?ea(a,Lt.map(({name:l,value:d})=>({id:Ht.chip(l),contrast:d})),r):"",[a,r]),c=o.useRef(null);return o.useLayoutEffect(()=>{if(!a)return;const l=()=>{c.current=null;const d=Cn===null?"":ea(a,[{id:Ht.strip,contrast:Cn}],r);Oa(i+d)};c.current!==null&&cancelAnimationFrame(c.current),s===null?l():c.current=requestAnimationFrame(l)},[a,r,s,i]),o.useEffect(()=>()=>{c.current!==null&&cancelAnimationFrame(c.current),Oa("")},[]),s},ag=({glass:t})=>{const s=Mn(),a=sg(s);return e.jsx("div",{className:"border-hairline border-b pb-3",children:e.jsx(sr,{glass:t,previewTheme:a===null?void 0:Ht.strip})})},ig=({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]}),rg=()=>{const t=be(i=>i.setContrast),[s,a]=o.useState(!1);return{commit:o.useCallback((i,c)=>{a(!0),requestAnimationFrame(()=>requestAnimationFrame(()=>{t(i,c),ar(null),a(!1)}))},[t]),pending:s}},og=({glass:t})=>{const s=ir();return e.jsx(sr,{glass:t,variant:"compact",previewTheme:s===null?void 0:Ht.strip,className:"lg:order-2"})},cg=({glass:t})=>{ne();const s=Mn(),a=be(E=>E.themeName),r=be(E=>E.contrast),i=be(E=>E.accent),c=be(E=>E.customAccents),l=be(E=>E.customAccentNames),d=be(E=>E.setAccent),u=be(E=>E.addCustomAccent),m=be(E=>E.replaceCustomAccent),h=be(E=>E.renameCustomAccent),p=be(E=>E.removeCustomAccent),{commit:g,pending:f}=rg(),j=Ji(),_=j.palette,b=_?.mode??"dark",A=r[b]??0,y=i[b]??{kind:"theme"},I=o.useMemo(()=>Object.keys(Xe).map(E=>{const z=jt(E)?.palette;return z?{id:E,palette:z}:null}).filter(E=>!!E),[]),M=o.useMemo(()=>Xr(I,b,a),[I,b,a]),P=o.useMemo(()=>eo(I,b),[I,b]);if(!_)return null;const N=j.name;return e.jsxs("div",{className:"grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_15rem]",children:[e.jsx(og,{glass:t}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-6 lg:order-1",children:[e.jsx("section",{"data-appearance-layer":"contrast",children:e.jsx(tg,{committed:A,effective:s.effectiveContrast,backgroundAtCeiling:b==="light"&&A>0&&s.palette.canvas.toUpperCase()===_.canvas.toUpperCase(),mode:b,pending:f,onDraft:ar,onCommit:E=>g(b,E)})}),e.jsxs("section",{"data-appearance-layer":"accent",children:[e.jsx(ig,{title:n("ui.settings.appearance.accent.title"),action:y.kind!=="theme"?e.jsx(O,{type:"button",variant:"link",size:"sm",className:"min-h-6 min-w-6",onClick:()=>d(b,{kind:"theme"}),children:n("ui.settings.appearance.accent.reset")}):null}),e.jsx(Kp,{themeName:N,themeAccent:_.accent,themeAccentAlt:_.accentAlt,curated:M,all:P,paletteName:E=>Xe[E]?.name??E,custom:c,customNames:l,selected:y,paintedAccent:s.palette.accent,adjusted:s.accentAdjusted,applied:s.accentApplied,onSelect:E=>d(b,E),onAdd:E=>u(E,b),onReplace:m,onRename:h,onRemove:p})]})]})]})},lg=()=>{ne();const t=be(d=>d.themeName),s=be(d=>d.accent),a=be(d=>d.customAccentNames),r=be(d=>d.setAccent),i=jt(t)?.palette.mode??"dark",c=s[i],l=Mn();return!c||c.kind==="theme"||c.kind==="theme-alt"?null:e.jsxs("p",{className:"flex flex-wrap items-center gap-1.5 text-meta text-ink-muted",children:[e.jsx("span",{"aria-hidden":"true",className:"inline-block size-3 rounded-full border border-hairline",style:{backgroundColor:l.palette.accent}}),e.jsx("span",{children:c.kind==="custom"?n("ui.settings.appearance.accent.override_notice",{colour:a[c.hex]??c.hex}):n("ui.settings.appearance.accent.palette_override_notice",{theme:Xe[c.id]?.name??c.id})}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx(O,{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")})]})},dg=()=>(ne(),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(lg,{})})]})),ug=({gallery:t,glass:s})=>e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(ag,{glass:s}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(dg,{}),t]}),e.jsx(cg,{glass:s})]}),mg=[[[".claude.json"],"Claude Code"],[[".claude",".mcp.json"],"Claude Code"],[[".cursor","mcp.json"],"Cursor"],[[".vscode","mcp.json"],"VS Code"],[[".codex","config.toml"],"Codex CLI"]];function rr(t){if(!t)return null;const s=t.split("\\").join("/").split("/").filter(Boolean);for(const[a,r]of mg)if(!(s.length<a.length)&&s.slice(-a.length).join("/")===a.join("/"))return r;return null}const yn=t=>n("ui.settings.integrations.integration_model.tool_count",{count:t}),pg=t=>n("ui.settings.integrations.integration_model.integration_count",{count:t}),gg=["connected","needs_sign_in","not_started","connecting","error"],or=t=>gg.includes(t),Ct=(t,s)=>[...s].filter(a=>a.name===t&&a.status==="running").sort((a,r)=>r.created_at-a.created_at)[0]??null,hg={connectedAt:null,connectedToolCount:null,settledGroup:null,pinnedGroup:null,pinnedOperationId:null,needsKey:!1,needsSignIn:!1,disconnectedAt:null,holdUntil:null,lastDecisive:null},fg=1e12,xg=1e9,_g=60*60*1e3,cr=(t,s=Date.now())=>{if(typeof t!="number"||!Number.isFinite(t))return null;const a=t>=fg?t:t<xg?null:t*1e3;return a===null||a>s+_g?null:Math.min(a,s)},pt=(t,s)=>t?.[s]??hg,Jt=(t,s,a)=>vg(t,s)??a?.lastDecisive??null,yg=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}:{}}),Vs=(t,s)=>t.status==="not_started"&&typeof t.tool_count=="number"&&(s.connectedAt!==null||t.status_basis==="stored"&&t.tool_count_basis==="last_seen"),bg=(t,s)=>[...s].filter(a=>a.name===t).sort((a,r)=>r.created_at-a.created_at)[0]??null,vg=(t,s)=>bg(t,s.filter(a=>a.status!=="cancelled")),Rn=t=>t.actions.includes("set_key")||t.actions.includes("add_key");function kg(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 Qn(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 jg(t,s=[],a,r=Date.now()){const i=pt(a,t.name),c=Ct(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(!or(t.status))return{label:n("ui.settings.integrations.integration_model.status_unavailable"),tone:"neutral",detail:null,busy:!1};const l=Jt(t.name,s,i),d=In(l)&&t.status!=="connected",u=Vs(t,i),m=Ys(l)&&t.status!=="connected",h=(l?.action==="login"||l?.action==="reauth")&&l.status==="failed";if(i.disconnectedAt!==null)return{label:n("ui.settings.integrations.integration_model.not_connected"),tone:"neutral",detail:null,busy:!1,explanation:n(Da)};switch(t.status){case"connected":return{label:typeof t.tool_count=="number"?n("ui.settings.integrations.integration_model.connected_with_tools",{tools:String(yn(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"||Bt(t,s,i)?n("ui.settings.integrations.integration_model.needs_a_key"):n("ui.settings.integrations.integration_model.needs_sign_in"),tone:"warning",detail:Qn(t.status_reason),busy:!1};case"error":return{label:n("ui.settings.integrations.integration_model.couldn_t_start"),tone:"danger",detail:Qn(t.status_reason)??n("ui.settings.integrations.integration_model.no_reason_was_given"),busy:!1};default:if(d)return{label:n("ui.settings.integrations.integration_model.signed_out"),tone:"warning",detail:null,busy:!1};if(m)return{label:n("ui.settings.integrations.integration_model.sign_out_didn_t_finish"),tone:"warning",detail:n("ui.settings.integrations.integration_model.the_sign_in_is_still_saved"),busy:!1};if(Bt(t,s,i))return{label:n("ui.settings.integrations.integration_model.needs_a_key"),tone:"warning",detail:null,busy:!1};if(h)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"||Bt(t,s,i)?n("ui.settings.integrations.integration_model.needs_a_key"):n("ui.settings.integrations.integration_model.needs_sign_in"),tone:"warning",detail:Qn(t.status_reason),busy:!1};if(t.status_basis==="stored"&&u&&i.disconnectedAt===null){const p=i.connectedAt??cr(t.last_seen_at,r);return{label:p!==null?n("ui.settings.integrations.integration_model.worked_when_with_tools",{when:String(kg(r,p)),tools:String(yn(t.tool_count))}):n("ui.settings.integrations.integration_model.worked_earlier_with_tools",{tools:String(yn(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(Da)}:{label:n("ui.settings.integrations.integration_model.ready"),tone:"neutral",detail:null,busy:!1,explanation:n(Sg)}}}const lr=t=>n("ui.settings.integrations.integration_model.replace_keys",{count:t}),wg=/[,;]?\s*(?:or|and)?\s*add (?:its|a|the) key instead\.?\s*$/i;function Ng(t,s){const a=t?.trim()??"";if(!a)return null;if(s)return a;const r=a.replace(wg,"").trim();return r?/\.$/.test(r)?r:`${r}.`:a}const Sg="ui.settings.integrations.integration_model.copy_ready_explanation",Da="ui.settings.integrations.integration_model.copy_not_connected_explanation",Cg=t=>t.transport==="local_command"?n("ui.settings.integrations.integration_model.local_command"):n("ui.settings.integrations.integration_model.remote_url");function dr(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 rr(t.source.path)}}function Mg(t,s){const a=[{text:Cg(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(yn(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=dr(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 Ws=(t,s)=>s.disconnectedAt!==null?"not_started":t.status;function Gs(t,s=[],a){const r=pt(a,t.name),i=Ct(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=h=>t.actions.includes(h),l=Rn(t),d=Bt(t,s,r);if(!or(t.status))return c("test")?{kind:"test",label:n("ui.settings.integrations.integration_model.check_again")}:null;const u=Jt(t.name,s,r),m=u?.status==="failed"&&Xt(u);switch(Ws(t,r)){case"connected":case"connecting":return null;case"needs_sign_in":return d?{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")}:c("sign_in")?{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}:l?{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")}:c("reauth")?{kind:"reauth",label:n("ui.settings.integrations.integration_model.sign_in_again")}:{kind:"fix",label:n("ui.settings.integrations.integration_model.fix")};case"error":return c("connect")?{kind:"connect",label:n("ui.settings.integrations.integration_model.reconnect")}:c("test")?{kind:"test",label:n("ui.settings.integrations.integration_model.retry")}:{kind:"fix",label:n("ui.settings.integrations.integration_model.fix")};default:{if(In(u)&&c("sign_in"))return{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")};if(Ys(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(d&&l)return{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")};if(c("sign_in"))return{kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}}return d&&l?{kind:"set_key",label:n("ui.settings.integrations.integration_model.add_key")}:m&&c("sign_in")?{kind:"sign_in",label:n("ui.settings.integrations.integration_model.try_again")}:Vs(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 Xt=t=>t.action==="login"||t.action==="reauth",In=t=>!!(t&&t.action==="logout"&&t.status==="complete"),Ys=t=>!!(t&&t.action==="logout"&&t.status!=="running"&&t.status!=="complete"),ur=/no oauth authorization server/i;function Bt(t,s,a){if(!Rn(t))return!1;const r=Jt(t.name,s,a);return r&&Xt(r)&&r.status==="failed"&&ur.test(r.message??"")?!0:a.needsKey}function Ag(t,s=[],a){const r=Gs(t,s,a)?.kind,i=Ws(t,pt(a,t.name)),c=u=>t.actions.includes(u),l=[],d=Ct(t.name,s);if(d&&l.push({kind:"cancel",label:n("ui.settings.integrations.integration_model.cancel")}),!d&&c("test")&&r!=="test"&&l.push({kind:"test",label:n("ui.settings.integrations.integration_model.test_connection")}),c("connect")&&r!=="connect"&&i!=="connected"&&l.push({kind:"connect",label:n("ui.settings.integrations.integration_model.reconnect")}),!d&&c("sign_in")&&r!=="sign_in"&&i!=="connected"&&l.push({kind:"sign_in",label:n("ui.settings.integrations.integration_model.sign_in")}),c("reload")&&l.push({kind:"reload",label:n("ui.settings.integrations.integration_model.reload")}),!d&&c("reauth")&&r!=="reauth"&&l.push({kind:"reauth",label:n("ui.settings.integrations.integration_model.sign_in_again")}),Rn(t)&&r!=="set_key"&&l.push({kind:"set_key",label:t.auth.secret_refs.length>0?n("ui.settings.integrations.integration_model.update_key"):n("ui.settings.integrations.integration_model.add_key")}),c("sign_out")&&l.push({kind:"sign_out",label:n("ui.settings.integrations.integration_model.sign_out")}),c("disconnect")&&i==="connected"&&l.push({kind:"disconnect",label:n("ui.settings.integrations.integration_model.disconnect")}),c("copy_setup")&&t.setup_prompt&&l.push({kind:"copy_setup",label:n("ui.settings.integrations.integration_model.copy_setup_prompt")}),r!=="fix"&&l.push({kind:"open_config",label:n("ui.settings.integrations.integration_model.open_config_file")}),c("remove"))l.push({kind:"remove",label:n("ui.settings.integrations.integration_model.remove"),destructive:!0});else if(!t.source.editable){const u=dr(t);l.push({kind:"remove_elsewhere",label:u?n("ui.settings.integrations.integration_model.remove_in_origin",{origin:String(u)}):n("ui.settings.integrations.integration_model.remove_in_its_own_file"),hint:u?n("ui.settings.integrations.integration_model.defined_in_origin_s_config_remove_it_there",{origin:String(u)}):n("ui.settings.integrations.integration_model.defined_in_a_file_this_app_doesn_t_write_remove_it_there")})}return l}const Eg={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 mr(t,s=[],a){const r=pt(a,t.name),i=Ct(t.name,s),c=Ws(t,r);if(i&&r.pinnedGroup&&r.pinnedOperationId===i.id)return r.pinnedGroup;if(c==="needs_sign_in"||c==="error")return"attention";const l=Jt(t.name,s,r);return In(l)&&c!=="connected"||Ys(l)&&c!=="connected"?"attention":r.disconnectedAt!==null?"ready":Bt(t,s,r)||r.needsSignIn&&c!=="connected"||l?.status==="failed"&&Xt(l)&&c!=="connected"?"attention":c==="connected"||t.status_basis==="stored"&&Vs(t,r)?"connected":i&&i.action!=="test"?"attention":"ready"}function Rg(t,s=[],a){return["attention","connected","ready"].map(i=>({id:i,title:Eg[i],rows:t.filter(c=>mr(c,s,a)===i)})).filter(i=>i.rows.length>0)}function Ig(t,s,a=Date.now()){if(!s)return t??{};const r={};for(const i of s.servers){const c=pt(t,i.name),l=Ct(i.name,s.operations),d=Jt(i.name,s.operations,c),u=In(d),m=i.status==="connected"&&(i.status_basis==="probe"||i.status_basis==="live"),h=c.holdUntil!==null&&a<c.holdUntil,p=!h&&!u&&c.connectedAt===null&&i.status_basis==="stored"&&i.tool_count_basis==="last_seen"?cr(i.last_seen_at,a):null,g=!u,f=d?.status==="failed"&&Xt(d)&&ur.test(d.message??""),j={connectedAt:m&&!h?a:p!==null?p:g?c.connectedAt:null,connectedToolCount:m&&!h||p!==null?i.tool_count??c.connectedToolCount:g?c.connectedToolCount:null,settledGroup:c.settledGroup,pinnedGroup:l&&c.pinnedOperationId===l.id?c.pinnedGroup:l?c.settledGroup:null,pinnedOperationId:l?l.id:null,needsKey:m?!1:c.needsKey||f,needsSignIn:m||u?!1:c.needsSignIn||i.status==="needs_sign_in",disconnectedAt:m&&!h?null:c.disconnectedAt,holdUntil:h?c.holdUntil:null,lastDecisive:d?yg(d):null};l||(j.settledGroup=mr(i,s.operations,{...r,[i.name]:j})),r[i.name]=j}return r}const Tg=(t,s)=>t!==null&&s===t,js="local-operator.settings.integrations.row-memory",pr=(t,s)=>`${t}#${s}`;function Lg(t,s){const a={};if(!s)return a;for(const r of s.servers){const i=t[r.name];i&&(a[pr(r.source.path,r.name)]=i)}return a}function Og(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=Pg(a[pr(i.source.path,i.name)]);c&&(r=r??{...t},r[i.name]=c)}return r??t}const Dg=["attention","connected","ready"],gr=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Qs=t=>typeof t=="number"&&Number.isFinite(t)?t:null,$a=t=>Dg.includes(t)?t:null,Zn=t=>{const s=Qs(t);return s!==null&&s>=1e12?s:null};function $g(t){if(!gr(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:Qs(t.created_at)??0,credential_removed:t.credential_removed===!0,...typeof t.message=="string"?{message:t.message}:{}}}function Pg(t){if(!gr(t))return null;const s=Zn(t.connectedAt),a=Zn(t.disconnectedAt),r=t.needsKey===!0,i=t.needsSignIn===!0,c=$g(t.lastDecisive);return s===null&&a===null&&!r&&!i&&!c?null:{connectedAt:s,connectedToolCount:Qs(t.connectedToolCount),settledGroup:$a(t.settledGroup),pinnedGroup:$a(t.pinnedGroup),pinnedOperationId:typeof t.pinnedOperationId=="string"?t.pinnedOperationId:null,needsKey:r,needsSignIn:i,disconnectedAt:a,holdUntil:Zn(t.holdUntil),lastDecisive:c}}const hr=2e3,Pa=8e3;function Fg(t){return t&&(t.servers.some(a=>a.status==="connecting")||t.operations.some(a=>a.status==="running"))?hr:!1}const zg=/^[A-Za-z0-9_.:-]{1,100}$/,Ug=/:\/\//;function Kg(t,s){const a=t.trim();return a?zg.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 Bg(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"):Ug.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 qg=t=>t.split(`
|
|
297
|
-
`).map(s=>s.trim()).filter(Boolean);function ws(t,s){const a=!!t?.cold,r=(t?.servers??[]).map(i=>{const c=i.transport==="http",l=i.secret_refs??[],d=i.status==="connected"?"connected":i.status==="connecting"?"connecting":i.status==="auth-required"?"needs_sign_in":"not_started",u=[];d!=="connected"&&u.push("connect"),d==="connected"&&u.push("disconnect"),a||u.push("reload"),c&&i.transport_oauth_supported!==!1&&u.push("sign_in"),l.length>0&&u.push("set_key"),i.owned_scope&&u.push("remove"),i.setup?.text&&u.push("copy_setup");const m=rr(i.source);return{id:i.name,name:i.name,scope:i.owned_scope??"global",project_cwd:null,source:{kind:Hg(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:d,status_reason:null,status_observed_at:null,last_seen_at:null,status_basis:a?"stored":"live",auth:{kind:l.length?"api_key":c?"unknown":"none",signed_in:null,secret_refs:l.map(h=>({id:h.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 Hg=(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",Fa={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")}},Vg="ui.settings.integrations.integration_model.copy_catalog_refusal_fallback";function ln(t,s,a){if(s instanceof St&&s.status===409){const r=typeof s.code=="string"&&Object.prototype.hasOwnProperty.call(Fa,s.code)?Fa[s.code]:n(Vg);return`${Eo[t]}. ${r}`}return Ro(t,s,a).message}const Wg="ui.settings.integrations.add_integration_form.copy_add_integration_pickup_note",Gg="ui.settings.integrations.add_integration_form.copy_transport_hint",Yg=({existingNames:t,projectScopeAvailable:s,projectLabel:a,onSubmit:r,onCancel:i,initial:c})=>{ne();const[l,d]=o.useState(c?.name??""),[u,m]=o.useState(c?.mode??"command"),[h,p]=o.useState(c?.command??""),[g,f]=o.useState(c?.args??""),[j,_]=o.useState(c?.url??""),[b,A]=o.useState("global"),[y,I]=o.useState(c?.touched?{name:!0,command:!0,url:!0}:{}),[M,P]=o.useState(!!c?.touched),[N,E]=o.useState(!1),[z,K]=o.useState(null),x=o.useRef(null),R=o.useRef(null),L=o.useRef(null);o.useEffect(()=>{x.current?.focus()},[]);const w=Kg(l,t),V=u==="command"&&!h.trim()?n("ui.settings.integrations.add_integration_form.enter_the_command_to_run"):null,$=u==="url"?Bg(j):null,q=C=>M||y[C],G=async C=>{if(C.preventDefault(),P(!0),w||V||$){w?x.current?.focus():V?R.current?.focus():L.current?.focus();return}E(!0),K(null);const D=s?b:"global",J=u==="command"?{name:l.trim(),scope:D,mode:u,command:h.trim(),args:qg(g)}:{name:l.trim(),scope:D,mode:u,url:j.trim()},ee=await r(J);E(!1),K(ee)},v=(C,D,J)=>D&&q(J)?e.jsx("p",{id:C,className:"text-body-sm text-danger",children:D}):null,B=C=>C.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:C=>void G(C),onKeyDown:C=>{C.key==="Escape"&&(C.stopPropagation(),i())},children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(We,{htmlFor:"integration-add-name",children:n("ui.settings.integrations.add_integration_form.name")}),e.jsx($e,{ref:x,id:"integration-add-name",value:l,placeholder:n("ui.settings.integrations.add_integration_form.e_g_notion"),autoComplete:"off","aria-invalid":!!(w&&q("name")),"aria-describedby":w&&q("name")?"integration-add-name-error":void 0,onChange:C=>d(C.target.value),onBlur:()=>I(C=>({...C,name:!0}))}),v("integration-add-name-error",w,"name")]}),e.jsxs(Gt,{value:u,onValueChange:C=>m(C==="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(Yt,{"aria-labelledby":"integration-add-transport-label",children:[e.jsx(ut,{value:"command","data-integration-transport":"command",children:n("ui.settings.integrations.add_integration_form.local_command")}),e.jsx(ut,{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(Gg)}),e.jsxs(pa,{value:"command",className:"mt-0 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(We,{htmlFor:"integration-add-command",children:n("ui.settings.integrations.add_integration_form.command")}),e.jsx($e,{ref:R,id:"integration-add-command",value:h,placeholder:n("ui.settings.integrations.add_integration_form.e_g_npx"),autoComplete:"off",className:"font-mono","aria-invalid":!!(V&&q("command")),"aria-describedby":V&&q("command")?"integration-add-command-error":void 0,onChange:C=>p(C.target.value),onBlur:()=>I(C=>({...C,command:!0}))}),v("integration-add-command-error",V,"command")]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs(We,{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(Fs,{id:"integration-add-args",value:g,rows:2,className:"font-mono",onChange:C=>f(C.target.value)})]})]}),e.jsx(pa,{value:"url",className:"mt-0 flex flex-col gap-4",children:e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(We,{htmlFor:"integration-add-url",children:n("ui.settings.integrations.add_integration_form.url")}),e.jsx($e,{ref:L,id:"integration-add-url",type:"url",value:j,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:C=>_(C.target.value),onBlur:()=>I(C=>({...C,url:!0}))}),v("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(Gt,{value:b,onValueChange:C=>A(C==="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(Yt,{"aria-labelledby":"integration-add-scope-label",children:[e.jsx(ut,{value:"global","data-integration-scope":"global",children:n("ui.settings.integrations.add_integration_form.all_chats")}),e.jsx(ut,{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:b==="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,z?e.jsx("p",{className:"text-body-sm text-danger",role:"alert",children:z}):null,e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:xe("text-body-sm text-ink-dim"),children:n(Wg)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(O,{type:"button",variant:"ghost",size:"md",onMouseDown:B,onClick:i,children:n("ui.settings.integrations.add_integration_form.cancel")}),e.jsxs(O,{type:"submit",variant:"primary",size:"md",disabled:N,onMouseDown:B,children:[N?e.jsx(Ee,{size:"xs"}):null,n("ui.settings.integrations.add_integration_form.add_integration")]})]})]})]})},Qg=4;function Zg(t){return t.rowMoving?t.now+t.windowMs:Math.max(t.hold.until,t.lastMovingAt+t.windowMs)}function Jg(t){return t.now>t.hold.until||t.hold.reanchors>=Qg?"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 Xg(t){const s=Zg({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=Jg({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 eh(t){const{row:s,target:a}=t;return!s||!a||typeof a.nodeType!="number"?!1:!s.contains(a)}const za=250;function Ua(t){return t?!t.disabled:!1}function th(t){return Ua(t.primary)?t.primary??null:Ua(t.overflow)?t.overflow??null:null}function nh(t){return t.verdict==="finished"?null:t.watchMs}const fr="key";function sh(t){const{name:s,keyless:a,freeName:r,names:i,values:c,replace:l,canReplace:d}=t;if(a){const u=Ns(s,r);return{values:{[u]:(c[fr]??"").trim()},confirmedReplace:l&&d?[u]:[],header:r.trim()}}return{values:Object.fromEntries(i.map(u=>[u,(c[u]??"").trim()])),confirmedReplace:l&&d?i:[],header:void 0}}function Ns(t,s){const a=Ka(t),r=Ka(s);if(!r)return"";const i=[a,r].filter(Boolean).join("_"),c=/^[A-Za-z_]/.test(i)?i:`K_${i}`;if(c.length<=Jn)return c;const l=ah(a),d=Jn-r.length-l.length-2,u=[a.slice(0,Math.max(d,0)),l,r].filter(Boolean).join("_");return u.length<=Jn?u:u.slice(-128)}const Jn=128,Ka=t=>t.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,""),ah=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)},ih=({name:t,keyNames:s,keyless:a=!1,savedKeys:r=[],saving:i,failure:c,onSave:l,onClose:d})=>{ne();const[u,m]=o.useState({}),[h,p]=o.useState(!1),[g,f]=o.useState(""),j=a?[Ns(t,g)]:[...s],_=a?[fr]:j,b=(a?Ns(t,g).length>0:!0)&&_.every(y=>(u[y]??"").trim()),A=j.some(y=>r.includes(y));return e.jsx(yi,{open:!0,onClose:d,maxWidth:"xs",title:n("ui.settings.integrations.integration_key_dialog.add_keys_heading",{count:a?1:s.length,name:t}),actions:e.jsxs(e.Fragment,{children:[e.jsx(ms,{onClick:d,children:n("ui.settings.integrations.integration_key_dialog.cancel")}),e.jsx(ps,{disabled:!b||i,onClick:()=>{const y=sh({name:t,keyless:a,freeName:g,names:j,values:u,replace:h,canReplace:A});l(y.values,y.confirmedReplace,y.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(We,{htmlFor:"integration-key-name",children:n("ui.settings.integrations.integration_key_dialog.the_header_this_server_wants_the_key_in")}),e.jsx($e,{id:"integration-key-name",autoComplete:"off",placeholder:n("ui.settings.integrations.integration_key_dialog.e_g_authorization_or_x_api_key"),value:g,onChange:y=>f(y.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(y=>a!==!0||y.trim().length>0).map(y=>e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(We,{htmlFor:`integration-key-${y}`,className:"font-mono",children:a?"Key":y}),e.jsx($e,{id:`integration-key-${y}`,type:"password",autoComplete:"off",value:u[y]??"",onChange:I=>m(M=>({...M,[y]:I.target.value}))})]},y)),A?e.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx(xs,{id:"integration-key-replace",checked:h,onCheckedChange:y=>p(y===!0)}),e.jsx(We,{htmlFor:"integration-key-replace",className:"font-normal",children:lr(j.length)})]}):null,c?e.jsx("p",{className:"-mx-1.5 text-body-sm text-danger",role:"alert",children:c}):null]})})},rh={success:"bg-success",warning:"bg-warning",danger:"bg-danger",info:"bg-info",neutral:"bg-ink-dim"},oh={success:"text-ink-muted",warning:"text-warning",danger:"text-danger",info:"text-ink-muted",neutral:"text-ink-dim"},ch=({row:t,operations:s,memories:a,now:r,projectScopeAvailable:i,highlighted:c=!1,rowRef:l,primaryRef:d,overflowRef:u,pending:m,failure:h,confirm:p,onPrimary:g,onOverflow:f,onConfirm:j,onCancelConfirm:_})=>{ne();const b=jg(t,s,a,r),A=c&&b.tone==="danger"?"text-ink":oh[b.tone],y=Gs(t,s,a),I=Ag(t,s,a),M=Mg(t,i),P=I.findIndex(N=>N.kind==="remove"||N.kind==="remove_elsewhere");return e.jsxs("li",{ref:l,"data-integration":t.name,"data-search-row":`integration.${t.id}`,"data-search-control":!0,"data-status":t.status,className:xe("flex min-h-14 flex-col justify-center gap-1 px-4 py-2.5",c&&"bg-row-selected"),onKeyDown:N=>{!p||N.key!=="Escape"||(N.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:b.busy?e.jsx(Ee,{size:"xs"}):e.jsx("span",{"aria-hidden":"true","data-tone":b.tone,className:xe("size-2 rounded-full",rh[b.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:M.map((N,E)=>e.jsxs("span",{children:[E>0?" · ":null,N.importSource&&t.source.path?e.jsx(et,{content:no(t.source.path),children:e.jsx("span",{className:"underline decoration-dotted underline-offset-2",children:N.text})}):N.text]},N.text))})]}),b.explanation?e.jsx(et,{content:b.explanation,children:e.jsx("span",{className:xe("shrink-0 text-body-sm",A),children:b.label})}):e.jsx("span",{className:xe("shrink-0 text-body-sm",A),children:b.label}),y?e.jsxs(O,{ref:d,variant:y.variant??"secondary",size:"sm","aria-label":`${y.label} ${t.name}`,disabled:m,"data-integration-action":y.kind,onClick:()=>g(y),children:[m?e.jsx(Ee,{size:"xs"}):null,y.label]}):null,e.jsxs(zs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(O,{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(Is,{"aria-hidden":"true"})})}),e.jsx(Ks,{align:"end",className:"min-w-48",children:I.map((N,E)=>e.jsx(lh,{item:N,separated:E===P&&E>0,onSelect:()=>f(N)},N.kind))})]})]}),b.detail?e.jsx("p",{className:xe("ps-7 text-body-sm",b.tone==="danger"?"text-ink-muted":"text-ink-dim"),children:b.detail}):null,h?e.jsx("p",{className:xe("ps-7 text-body-sm",c?"text-ink":"text-danger"),role:"alert",children:h}):null,p?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 ps-7",children:[e.jsx("span",{className:"text-body-sm text-ink",children:p.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:p.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(O,{variant:"danger",size:"sm",onClick:j,"data-integration-confirm":p.kind,children:p.kind==="remove"?n("ui.settings.integrations.integration_row.remove"):n("ui.settings.integrations.integration_row.sign_out")}),e.jsx(O,{variant:"ghost",size:"sm",onClick:_,children:n("ui.settings.integrations.integration_row.keep")})]}):null]})},lh=({item:t,separated:s,onSelect:a})=>(ne(),e.jsxs(e.Fragment,{children:[s?e.jsx(Tl,{}):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 dh(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:Ng(s.message,a)??n("ui.settings.integrations.integration_sign_in_dialog.the_server_didn_t_say_why"),nextStep:uh(s.message??null,a)}}function uh(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 mh(t,s){return t.kind==="ready"?"ready":t.kind==="running"&&s&&s.tone!=="progress"?s.tone==="success"?"success":"failure":"running"}const ph=({name:t,action:s,keyRoute:a,phase:r,onStart:i,onCancel:c,onOpenLink:l,onClose:d})=>{ne();const u=r.kind==="running"?r.operation:null,m=r.kind==="running"?dh(t,u,a):null,h=r.kind==="starting"||r.kind==="running"&&m?.tone==="progress",p=m&&m.tone!=="progress",g=o.useRef(null),f=o.useRef(!1),j=mh(r,m);o.useEffect(()=>{if(!f.current){f.current=!0;return}j&&g.current?.focus()},[j]);const _=()=>d(m?.tone==="success"?"signed-in":"dismissed");return e.jsx(yi,{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:b=>{b.preventDefault(),g.current?.focus()}},actions:e.jsxs(e.Fragment,{children:[h&&u?e.jsx(ms,{ref:g,onClick:()=>c(u.id),children:n("ui.settings.integrations.integration_sign_in_dialog.cancel_sign_in")}):e.jsx(ms,{ref:r.kind==="ready"?void 0:g,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(ps,{ref:g,onClick:i,children:n("ui.settings.integrations.integration_sign_in_dialog.continue_in_browser")}):null,r.kind==="refused"||m?.tone==="failure"?e.jsx(ps,{ref:m?.tone==="failure"?g: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(Ee,{size:"xs"}),n("ui.settings.integrations.integration_sign_in_dialog.starting_sign_in")]}):null,m?e.jsxs("div",{className:"flex flex-col gap-1",role:p?"status":void 0,children:[e.jsxs("p",{className:(m.tone==="success","-mx-1.5 flex items-start gap-2 text-ink"),children:[m.tone==="progress"?e.jsx(Ee,{size:"xs",className:"mt-0.5"}):null,m.tone==="failure"?e.jsx(Di,{"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(O,{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(()=>gs(n("ui.settings.integrations.integration_sign_in_dialog.sign_in_link_copied"))).catch(()=>{})},children:e.jsx(_i,{"aria-hidden":"true"})})]}),e.jsx(O,{variant:"link",size:"sm",onClick:()=>l(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]})})},gh=t=>t.reduce((s,a)=>s?(a.updated_at??0)>(s.updated_at??0)?a:s:a,null),hh=/^[A-Za-z]:[\\/]/,bn=t=>{const s=t?.trim();return s&&(s.startsWith("/")||hh.test(s))?s:null};function fh(t){const i=t?.payload?.frontend?.snapshot?.cwd;return typeof i=="string"&&i.trim()?i:null}const Qt="local-operator.settings.integrations.last-cwd";function xh(t,s,a=typeof localStorage>"u"?null:localStorage){const r=bn(s);if(!(!t||!r||!a))try{const i=a.getItem(Qt),c=i?JSON.parse(i):{};if(c[t]===r)return;a.setItem(Qt,JSON.stringify({...c,[t]:r}))}catch{}}const xr=()=>typeof localStorage>"u"?null:localStorage;function _r(t=xr()){if(!t)return{};try{const s=t.getItem(js);if(!s)return{};const a=JSON.parse(s);return!a||typeof a!="object"||Array.isArray(a)?{}:a}catch{return{}}}const Ba=256;function _h(t,s=xr()){if(s)try{const a={..._r(s),...t},r=Object.keys(a);if(r.length>Ba){const i={};for(const c of r.slice(-Ba))i[c]=a[c];s.setItem(js,JSON.stringify(i));return}s.setItem(js,JSON.stringify(a))}catch{}}function qa(t,s,a){if(t==="saved")return null;if(t==="replace_confirmation_required"){const i=lr(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 yh(t,s=typeof localStorage>"u"?null:localStorage){if(!(!t||!s))try{const a=s.getItem(Qt);if(!a)return;const r=JSON.parse(a);if(!(t in r))return;const i={...r};delete i[t],s.setItem(Qt,JSON.stringify(i))}catch{}}const bh=t=>!!(t&&typeof t=="object"&&"code"in t&&t.code==="invalid_cwd"),vh=(t,s)=>s!==null&&t===s?null:t;function kh(t,s=typeof localStorage>"u"?null:localStorage){if(!t||!s)return null;try{const a=s.getItem(Qt);if(!a)return null;const i=JSON.parse(a)[t];return typeof i=="string"?i:null}catch{return null}}const jh=t=>t.action==="disconnect"?"disconnected":"connected";function wh(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 Nh(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 Sh({sessionId:t}){const s=gt(),a=Qe(s.data,"mcp_catalog"),r=Qe(s.data,"mcp"),i=a?"catalog":r?"session":null,[c,l]=o.useState(null),d=Nt(),u=yt(U=>U.sessions),m=yt(U=>U.fetchSessions),h=yt(U=>U.loading),p=o.useMemo(()=>u.find(U=>U.session_id===t)??null,[u,t]),g=o.useMemo(()=>i==="session"&&!t?gh(u):null,[i,t,u]),f=i==="session"?t??g?.session_id??null:null;o.useEffect(()=>{i!=="session"||t||u.length>0||m(so)},[i,t,u.length,m]);const j=i==="catalog"?bn(p?.cwd):null,_=i==="catalog"&&!!t&&j===null,b=ze({queryKey:["desktop","session-cwd",t??""],queryFn:()=>Ne({op:"sessions.get",sessionId:t??""}),enabled:_,staleTime:Number.POSITIVE_INFINITY,retry:!1}),A=_&&!b.isFetched,y=j??bn(fh(b.data))??(b.isFetched?bn(kh(t)):null),I=vh(y,c),M=i==="catalog"?I:null,P=i==="catalog"?t??null:null,N=Io.catalog(M,P);o.useEffect(()=>{i!=="catalog"||!t||!M||xh(t,M)},[i,t,M]);const E=o.useRef(0),[z,K]=o.useState(0),x=o.useRef(null),R=o.useCallback((U,k)=>{const Y=Date.now()+Pa;E.current=Y,x.current={name:U,expect:k},K(Y)},[]),L=o.useCallback(U=>Date.now()<E.current?hr:Fg(U),[]),w=ze({queryKey:N,queryFn:()=>Oo(M,P),enabled:i==="catalog"&&!A,staleTime:1e4,refetchInterval:U=>L(U.state.data)}),V=bh(w.error);o.useEffect(()=>{!V||!y||c===y||(l(y),yh(t))},[V,y,c,t]);const $=ze({queryKey:hs.list(f??""),queryFn:()=>Do(f??""),enabled:i==="session"&&!!f,staleTime:1e4,refetchInterval:U=>L(U.state.data?ws(U.state.data,f??""):void 0)}),q=o.useMemo(()=>{if(i==="catalog")return w.data;if(i==="session"&&$.data&&f)return ws($.data,f)},[i,w.data,$.data,f]),G=o.useCallback(()=>Ch({queryClient:d,route:i,catalogKey:N,sessionId:f}),[i,N,d,f]);o.useEffect(()=>{if(!z)return;const U=x.current;if(!U)return;const k=q?.servers.find(ae=>ae.name===U.name);!k||!(U.expect==="connected"?k.status==="connected":k.status_basis==="live"&&k.status!=="connected")||(E.current=0,x.current=null,K(0))},[q,z]);const v=o.useRef({}),[B,C]=o.useState(0),D=o.useMemo(()=>(v.current=Ig(Og(v.current,q,_r()),q),v.current),[q,B]),J=o.useRef("");o.useEffect(()=>{const U=Lg(D,q);if(!Object.keys(U).length)return;const k=JSON.stringify(U);k!==J.current&&(J.current=k,_h(U))},[D,q]);const ee=o.useCallback(U=>{const k=pt(v.current,U);k.needsKey||(v.current={...v.current,[U]:{...k,needsKey:!0}},C(Y=>Y+1))},[]),Z=o.useCallback(U=>{if(U.action!=="disconnect"&&U.action!=="connect"&&U.action!=="reload")return;const k=pt(v.current,U.name),Y=Date.now()+Pa,ae=U.action==="disconnect"?{...k,connectedAt:null,disconnectedAt:Date.now(),holdUntil:Y}:{...k,disconnectedAt:null,holdUntil:Y};v.current={...v.current,[U.name]:ae},R(U.name,jh(U)),C(ue=>ue+1)},[R]),ce=o.useCallback(async U=>{if(i==="catalog"){const k=wh(U);if(!k)return null;try{const Y=await To(M,k);return d.setQueryData(N,Y),Z(U),Y.operation?.id??null}catch(Y){throw Y instanceof St&&Y.status===409&&d.invalidateQueries({queryKey:N}),Y}}if(i==="session"&&f){const k=await Ne({op:"mcp.control",sessionId:f,control:Nh(U)});Z(U);const Y=hs.list(f),ae=k?.data;return ae&&"servers"in ae&&Array.isArray(ae.servers)?(d.setQueryData(Y,ae),null):(d.invalidateQueries({queryKey:Y}),ae&&"id"in ae&&typeof ae.id=="string"?ae.id:null)}return null},[i,M,N,d,f,Z]),ie=o.useCallback(async U=>{if(i==="catalog"&&P&&(U.action==="connect"||U.action==="disconnect"||U.action==="reload")){try{await Ne({op:"mcp.control",sessionId:P,control:{action:U.action,name:U.name,...U.action==="disconnect"?{confirmed:!0}:{}}})}catch(k){throw d.invalidateQueries({queryKey:N}),k}return Z(U),await d.invalidateQueries({queryKey:N}),null}return ce(U)},[i,P,d,N,ce,Z]),de=o.useCallback(async(U,k,Y,ae)=>{if(i==="catalog"){const ue=await Lo(M,U,k,Y,ae);if(ue.catalog&&d.setQueryData(N,ue.catalog),ue.code!=="saved")return{saved:!1,message:qa(ue.code,ue.failed_ids,k)};try{await ce({action:"test",name:U})}catch{}return{saved:!0,message:null}}if(i==="session"&&f){const ue=await Ne({op:"mcp.credentials.store",sessionId:f,name:U,values:k,confirmedReplace:Y});if(ue.data?.code!=="saved")return{saved:!1,message:qa(ue.data?.code,ue.data?.failed_ids??[],k)};try{await ce({action:"connect",name:U})}catch{}return{saved:!0,message:null}}return{saved:!1,message:null}},[i,M,N,d,ce,f]),Se=i==="catalog"?w:$,H=o.useCallback(()=>{Se.refetch()},[Se]);return{enabled:i!==null,route:i,sessionId:i==="catalog"?P:f,borrowed:g,noConversation:i==="session"&&!f&&!h,document:q,isLoading:s.isLoading||i==="catalog"&&(A||w.isLoading)||i==="session"&&(f?$.isLoading:h),isError:Se.isError,folderUnavailable:Tg(c,y),refetch:H,readDocument:G,control:ie,storeKeys:de,memories:D,markNeedsKey:ee}}function Ch(t){if(t.route==="catalog")return t.queryClient.getQueryData(t.catalogKey);if(t.route==="session"&&t.sessionId){const s=t.queryClient.getQueryData(hs.list(t.sessionId));return s?ws(s,t.sessionId):void 0}}const Mh=(t,s)=>{const a=t?.trim();if(!a)return null;const r=Po(a,s);return r.kind==="auth"?{kind:"matched",name:r.name,unresolved:null}:{kind:"miss",asked:a}},Ah=6,Xn="ui.settings.integrations.mcp_management_section.copy_section_title",Eh="ui.settings.integrations.mcp_management_section.copy_section_description",Rh={test:"test",connect:"reconnect",disconnect:"disconnect",reload:"reload",remove:"remove",sign_out:"disconnect",cancel:"cancel",login:"grant",reauth:"grant"},Ih=({sessionId:t,sectionRef:s,highlightServer:a})=>{ne();const r=Sh({sessionId:t}),{document:i,control:c,readDocument:l}=r,d=di(),u=i?.servers??[],m=i?.operations??[],h=i?.project_scope_available??!1,[p,g]=o.useState(!1),[f,j]=o.useState(""),[_,b]=o.useState(null),[A,y]=o.useState({}),[I,M]=o.useState(null),[P,N]=o.useState(null),[E,z]=o.useState({kind:"ready"}),[K,x]=o.useState(null),[R,L]=o.useState(null),[w,V]=o.useState(!1),$=o.useRef({}),q=o.useRef({}),G=o.useRef({}),v=o.useRef(0),B=o.useRef(null),C=o.useRef(null),D=o.useRef(null),[J,ee]=o.useState(null),[Z,ce]=o.useState(null),[ie,de]=o.useState(null),Se=o.useCallback(()=>{const T=D.current;D.current=null,N(null),x(null),window.setTimeout(()=>{T?.isConnected&&T.focus()},0)},[]),H=o.useCallback(T=>{const W=window.document.activeElement;D.current=W instanceof HTMLElement?W:null,N(T)},[]),U=o.useCallback((T,W)=>{ce({name:T,waitForSignIn:W==="signed-in",until:Date.now()+It,reanchors:0}),Se()},[Se]),k=o.useMemo(()=>Mh(a,u.map(T=>T.name)),[a,u]),Y=k?.kind==="matched"?k.name:null,ae=o.useRef(null),ue=o.useRef(null),ke=f.trim().toLowerCase(),me=o.useMemo(()=>ke?u.filter(T=>T.name.toLowerCase().includes(ke)):u,[u,ke]),pe=Rg(me,m,r.memories),je=P?.kind==="sign_in"?u.find(T=>T.name===P.name)??null:null;o.useEffect(()=>{!Y||ue.current===Y||!f||j("")},[Y,f]),o.useEffect(()=>{!Y||ue.current===Y||me.some(T=>T.name===Y)&&(ue.current=Y,ae.current?.scrollIntoView({block:"center",behavior:"smooth"}))},[Y,me]),o.useEffect(()=>{if(!K)return;const T=m.find(W=>W.id===K)??null;z({kind:"running",operation:T})},[m,K]);const Ke=m.some(T=>T.status==="running"),se=T=>{const W=window.document.activeElement;W&&W!==window.document.body&&W.isConnected||ce({name:T,waitForSignIn:!1,until:Date.now()+It,reanchors:0})},re=async(T,W,te)=>{b(T),y(({[T]:ye,...Ce})=>Ce);let F=null,le=!1;try{F=await te()}catch(ye){le=!0,y(Ce=>({...Ce,[T]:ln(Rh[W]??"status",ye,Ke)}))}finally{b(null),W!=="sign_out"&&(W!=="remove"||le)&&se(T)}return{operationId:F,failed:le}},ve=T=>u.find(W=>W.name===T),Q=T=>{T.source.path&&Fo(T.source.path)},ge=async(T,W)=>{z({kind:"starting"}),x(null);try{const te=await c({action:W,name:T});te?x(te):z({kind:"running",operation:null})}catch(te){te instanceof St&&te.code==="oauth_unsupported"&&r.markNeedsKey(T),z({kind:"refused",message:ln("grant",te,Ke)})}},he=(T,W)=>{switch(W.kind){case"sign_in":case"reauth":{const te=m.find(F=>F.name===T.name&&F.status==="running");te&&Xt(te)?(z({kind:"running",operation:te}),x(te.id)):(z({kind:"ready"}),x(null)),H({kind:"sign_in",name:T.name,action:W.kind==="reauth"?"reauth":"login"});return}case"set_key":L(null),H({kind:"key",name:T.name,keyNames:T.auth.secret_refs.map(te=>te.id)});return;case"fix":Q(T);return;case"sign_out":M({name:T.name,kind:"sign_out"});return;default:{const te=W.kind;re(T.name,te,()=>c({action:te,name:T.name}))}}},Pe=(T,W)=>{switch(W.kind){case"remove":case"sign_out":M({name:T.name,kind:W.kind});return;case"sign_in":case"reauth":case"set_key":he(T,{kind:W.kind,label:W.label});return;case"open_config":Q(T);return;case"copy_setup":navigator.clipboard.writeText(T.setup_prompt??"").then(()=>gs(n("ui.settings.integrations.mcp_management_section.setup_steps_copied_paste_them_into_a_chat"))).catch(()=>{});return;case"cancel":{const te=m.find(F=>F.name===T.name&&F.status==="running");te&&re(T.name,"cancel",()=>c({action:"cancel",operationId:te.id}));return}case"test":case"connect":case"disconnect":case"reload":{const te=W.kind;re(T.name,te,()=>c({action:te,name:T.name}));return}default:return}},Ge=(T,W)=>{if(M(null),W==="remove"){const te=T.source.owned_scope;if(!te)return;const F=me.findIndex(le=>le.name===T.name);re(T.name,"remove",()=>c({action:"remove",name:T.name,scope:te})).then(({operationId:le,failed:ye})=>{ye||le!==null||(gs(n("ui.settings.integrations.mcp_management_section.removed_name",{name:String(T.name)})),F>=0&&de({index:F}))});return}re(T.name,"sign_out",()=>c({action:"logout",name:T.name})).then(()=>{ce({name:T.name,waitForSignIn:!1,until:Date.now()+It,reanchors:0})})},Be=async T=>{try{return await c({action:"add",name:T.name,scope:T.scope,...T.mode==="command"?{command:T.command,args:T.args}:{url:T.url}}),g(!1),ee(T.name),null}catch(W){return ln("add",W,!1)}},Ae=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(Xn)}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:n(Eh)})]}),r.enabled&&u.length>0&&!p?e.jsxs(O,{ref:B,variant:"secondary",size:"sm",onClick:()=>g(!0),"data-tour-tag":"mcp-add-server",children:[e.jsx(jn,{"aria-hidden":"true"}),n("ui.settings.integrations.mcp_management_section.add_integration")]}):null]});if(!r.enabled&&!r.isLoading)return e.jsx(Re,{title:n(Xn),titleComponent:Ae,sectionRef:s,searchSection:"integrations",searchSectionLabel:n("ui.settings.navigation.settings_sidebar.integrations"),children:e.jsx(_e,{variant:"warning",children:n("ui.settings.integrations.mcp_management_section.integrations_need_a_newer_local_operator_backend_update_it_and_re")})});const tt=e.jsx(Yg,{existingNames:u.map(T=>T.name),projectScopeAvailable:h,projectLabel:i?.cwd?Lh(i.cwd):null,onSubmit:Be,onCancel:()=>{g(!1),window.setTimeout(()=>B.current?.focus(),0)}}),ht=P?ve(P.name):void 0,rt=Object.entries(A).filter(([T])=>!u.some(W=>W.name===T)),ft=T=>y(({[T]:W,...te})=>te);o.useEffect(()=>{if(!J)return;const T=$.current[J];if(!T){u.some(W=>W.name===J)&&(q.current[J]?.focus(),ee(null));return}T.focus(),ee(null)},[J,u]),o.useEffect(()=>{if(!ie)return;const W=me[Math.min(ie.index,me.length-1)]??me.at(-1);if(W){const te=$.current[W.name]??q.current[W.name];if(!te)return;te.focus()}else B.current?.focus();de(null)},[ie,me]);const ot=o.useCallback((T,W)=>{const te=l()??i,F=te?.servers.find(Ye=>Ye.name===T.name),le=te?.operations??[],ye=F?F.status==="connecting"||Ct(F.name,le)!==null:!1;ye&&F&&(v.current=W);const Ce=F?Gs(F,le,r.memories):null;if(F&&T.waitForSignIn&&(Ce?.kind==="sign_in"||Ce?.kind==="reauth"))return"kept";const Ie=Xg({hold:T,now:W,windowMs:It,rowMoving:ye,lastMovingAt:v.current,candidate:F?th({primary:Ce?$.current[F.name]:null,overflow:q.current[F.name]}):void 0,active:window.document.activeElement,body:window.document.body});if(!Ie.hold)return ce(null),"finished";if(!Ie.land)return"kept";ce({name:T.name,waitForSignIn:!1,until:Ie.hold.until,landedOn:Ie.land,reanchors:Ie.hold.reanchors});const Te=Ie.land;return window.setTimeout(()=>{Te.isConnected&&Te.focus()},0),"landed"},[l,i,r.memories]);return o.useEffect(()=>{if(!Z)return;ot(Z,Date.now());let T=0,W=!1;const te=()=>{if(W)return;const F=nh({verdict:ot(Z,Date.now()),watchMs:za});F!==null&&(T=window.setTimeout(te,F))};return T=window.setTimeout(te,za),()=>{W=!0,window.clearTimeout(T)}},[Z,ot]),o.useEffect(()=>{if(!Z)return;const T=W=>{eh({target:W.target,row:G.current[Z.name]})&&ce(null)};return window.document.addEventListener("pointerdown",T,!0),()=>{window.document.removeEventListener("pointerdown",T,!0)}},[Z]),e.jsxs(Re,{title:n(Xn),titleComponent:Ae,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(O,{variant:"primary",size:"sm",onClick:()=>d("/chat"),children:n("ui.settings.integrations.mcp_management_section.start_a_chat")}),e.jsx("p",{className:"text-ink-dim text-meta",children:n("ui.settings.integrations.mcp_management_section.updating_local_operator_removes_this_step")})]}):null,r.isLoading?e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(Ee,{size:"lg",label:n("ui.settings.integrations.mcp_management_section.loading_integrations")})}):null,r.folderUnavailable?e.jsx(_e,{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(_e,{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(O,{variant:"secondary",size:"sm",onClick:r.refetch,children:n("ui.settings.integrations.mcp_management_section.retry")})]})}):null,rt.map(([T,W])=>e.jsx(_e,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:W}),e.jsx(O,{variant:"ghost",size:"sm",onClick:()=>ft(T),children:n("ui.settings.integrations.mcp_management_section.dismiss")})]})},T)),p&&u.length>0?tt:null,u.length>=Ah?e.jsxs("div",{className:"relative",children:[e.jsx(As,{"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 start-3 size-4 -translate-y-1/2 text-ink-dim"}),e.jsx($e,{ref:C,value:f,onChange:T=>j(T.target.value),onKeyDown:T=>{T.key!=="Escape"||!f||(T.preventDefault(),j(""))},placeholder:n("ui.settings.integrations.mcp_management_section.search_integrations_placeholder",{integrations:pg(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?p?tt:e.jsxs("div",{className:"flex flex-col items-start gap-3 rounded-lg bg-surface p-6",children:[e.jsx(bi,{"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(O,{variant:"primary",size:"md",onClick:()=>g(!0),"data-tour-tag":"mcp-add-server",children:[e.jsx(jn,{"aria-hidden":"true"}),n("ui.settings.integrations.mcp_management_section.add_integration")]})]}):null,u.length>0&&me.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(O,{variant:"secondary",size:"sm",onClick:()=>{j(""),window.setTimeout(()=>{(C.current??B.current)?.focus()},0)},children:n("ui.settings.integrations.mcp_management_section.clear_search")})]}):null,pe.map(T=>e.jsxs("section",{"aria-labelledby":`integrations-group-${T.id}`,className:"flex flex-col gap-1.5",children:[e.jsxs("h3",{id:`integrations-group-${T.id}`,className:"px-1 text-ink-dim text-meta",children:[T.title," · ",T.rows.length]}),e.jsx("ul",{className:"flex flex-col divide-y divide-hairline overflow-hidden rounded-lg bg-surface",children:T.rows.map(W=>e.jsx(ch,{row:W,operations:m,memories:r.memories,projectScopeAvailable:h,highlighted:W.name===Y,rowRef:te=>{G.current[W.name]=te,W.name===Y&&(ae.current=te)},primaryRef:te=>{$.current[W.name]=te},overflowRef:te=>{q.current[W.name]=te},pending:_===W.name,failure:A[W.name]??null,confirm:I?.name===W.name?{kind:I.kind}:null,onPrimary:te=>he(W,te),onOverflow:te=>Pe(W,te),onConfirm:()=>I&&Ge(W,I.kind),onCancelConfirm:()=>{M(null),window.setTimeout(()=>{q.current[W.name]?.focus()},0)}},W.id))})]},T.id))]}),P?.kind==="sign_in"?e.jsx(ph,{name:P.name,action:P.action,keyRoute:je?Rn(je):!1,phase:E,onStart:()=>void ge(P.name,P.action),onCancel:T=>void c({action:"cancel",operationId:T}).catch(()=>{}),onOpenLink:T=>void $o(T),onClose:T=>U(P.name,T)}):null,P?.kind==="key"?e.jsx(ih,{name:P.name,keyNames:P.keyNames.length?P.keyNames:ht?.auth.secret_refs.map(T=>T.id)??[],keyless:P.keyNames.length===0,savedKeys:ht?.auth.secret_refs.filter(T=>T.state==="encrypted").map(T=>T.id),saving:w,failure:R,onClose:Se,onSave:(T,W,te)=>{V(!0),L(null),r.storeKeys(P.name,T,W,te).then(F=>{if(!F.saved){L(F.message);return}N(null),ce({name:P.name,waitForSignIn:!1,until:Date.now()+It,reanchors:0})}).catch(F=>L(ln("key",F,!1))).finally(()=>V(!1))}}):null]})},It=4e3,Th=/^\/(?:Users|home)\/[^/]+(?=\/|$)/,Lh=t=>t.replace(Th,"~"),yr="group/row flex min-h-11 items-center gap-3 border-b border-hairline px-2",br="group/row flex min-h-11 items-center gap-3 border-b border-hairline px-2 hover:bg-row-hover",vr="group-hover/row:not-data-[state=checked]:border-ink-muted",kr=({sound:t,state:s,onToggle:a,inTabOrder:r})=>{ne();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:xe(Uo,i&&"text-accent hover:text-accent"),"aria-label":c,"aria-pressed":i,tabIndex:r?void 0:-1,"data-preview":t.id,onClick:l=>{l.preventDefault(),l.stopPropagation(),a()},children:s==="loading"?e.jsx(Ee,{size:"sm"}):i?e.jsx(kd,{className:"size-4","aria-hidden":"true"}):e.jsx(vi,{className:"size-4","aria-hidden":"true"})})},Ha=({sound:t,isDefault:s,preview:a,onPreview:r,describedBy:i,description:c,noPreview:l=!1})=>{ne();const d=`notification-sound-${t.id}`,u=c?`${d}-description`:void 0;return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("label",{htmlFor:d,className:xe(br,"cursor-pointer"),"data-sound-row":t.id,children:[e.jsx($i,{id:d,value:t.id,className:vr,"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(wt,{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})]}),!l&&e.jsx(kr,{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")})]})},Oh=({sound:t,selected:s,preview:a,onPreview:r,mode:i,maxNameChars:c,describedBy:l,moreRef:d,onStartRename:u,onRename:m,onCancelRename:h,onStartRemove:p,onConfirmRemove:g,onCancelRemove:f})=>{ne();const j=`notification-sound-${t.id}`,_=o.useRef(null),b=zo(t.duration_s);if(o.useEffect(()=>{if(i.kind==="confirm-remove"&&!i.removing){const A=setTimeout(()=>_.current?.focus(),0);return()=>clearTimeout(A)}},[i]),i.kind==="confirm-remove"){const A=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:y=>{y.key==="Escape"&&(y.stopPropagation(),f())},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:A}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsxs(O,{variant:"danger",size:"sm",onClick:g,disabled:i.removing,children:[i.removing&&e.jsx(Ee,{size:"xs"}),n("ui.settings.notifications.custom.remove_action")]}),e.jsx(O,{ref:_,variant:"secondary",size:"sm",onClick:f,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:xe("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(Dh,{initial:t.label,maxNameChars:c,saving:i.saving,onSave:m,onCancel:h,serverError:i.error})]})}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("label",{htmlFor:j,className:xe(br,"@container cursor-pointer"),"data-sound-row":t.id,children:[e.jsx($i,{id:j,value:t.id,className:vr,"aria-describedby":l,"aria-keyshortcuts":"F2 Delete",onKeyDown:A=>{A.key==="F2"?(A.preventDefault(),u()):A.key==="Delete"&&(A.preventDefault(),p())}}),e.jsx("span",{className:"min-w-0 flex-1 truncate py-2 text-body text-ink",title:t.label,children:t.label}),b&&e.jsx("span",{"aria-hidden":"true",className:"hidden shrink-0 font-mono text-mono-sm text-ink-dim @[420px]:inline",children:b}),e.jsx(kr,{sound:t,state:a,onToggle:r,inTabOrder:!0}),e.jsxs(zs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(O,{ref:d,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:A=>A.stopPropagation(),children:e.jsx(Is,{"aria-hidden":"true"})})}),e.jsxs(Ks,{align:"end",className:"min-w-40",children:[e.jsx(at,{onSelect:u,children:n("ui.settings.notifications.custom.rename")}),e.jsx(at,{onSelect:p,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")})]})},Dh=({initial:t,maxNameChars:s,saving:a,onSave:r,onCancel:i,serverError:c})=>{ne();const[l,d]=o.useState(t),[u,m]=o.useState(null),h=o.useRef(null),p=o.useId();o.useEffect(()=>{const _=setTimeout(()=>{h.current?.focus(),h.current?.select()},0);return()=>clearTimeout(_)},[]);const g=u??c,f=o.useRef(!1);o.useEffect(()=>{a||(f.current=!1)},[a]);const j=()=>{const _=Ko(l,s);if(_){m(_==="ui.settings.notifications.custom.rename_long"?n(_,{max:s}):n("ui.settings.notifications.custom.rename_empty"));return}f.current=!0,r(l.trim())};return e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[e.jsx($e,{ref:h,inputSize:"sm",value:l,disabled:a,"aria-label":n("ui.settings.notifications.custom.rename_label"),"aria-invalid":g?!0:void 0,"aria-describedby":g?p:void 0,onChange:_=>{d(_.target.value),m(null)},onKeyDown:_=>{_.nativeEvent.isComposing||(_.key==="Escape"?(_.preventDefault(),_.stopPropagation(),f.current=!0,i()):_.key==="Enter"&&(_.preventDefault(),j()))},onBlur:()=>{if(!(a||f.current)){if(l.trim()===t.trim()){f.current=!0,i();return}j()}}}),g&&e.jsx("p",{id:p,className:"text-meta text-danger",children:g})]})},$h=".wav,.flac,.mp3,.ogg,audio/wav,audio/flac,audio/mpeg,audio/ogg",es=t=>t instanceof Error&&t.message?t.message:"";function Ph(t){return t.kind==="error"&&t.refusal?{code:t.refusal.code,params:t.refusal.params}:{code:null}}const jr=o.forwardRef(({listing:t,selectedId:s,volume:a,canSelect:r,onSelect:i,onChanged:c,initialPreview:l,initialPending:d,initialSaveError:u,initialFailedChoice:m,initialMode:h},p)=>{ne();const g=o.useMemo(()=>Bo(t.sounds),[t.sounds]),f=o.useId(),j=o.useId(),_=t.limits,[b,A]=o.useState(null),[y,I]=o.useState(u??null),[M,P]=o.useState(m??null),N=o.useRef(null),E=o.useRef(null),z=b??s,K=o.useRef(z);K.current=z,o.useEffect(()=>{b!==null&&b===s&&A(null)},[b,s]);const x=o.useCallback(async S=>{try{await i(S),I(null),P(null)}catch(oe){A(null),P(S),I(es(oe))}},[i]),R=o.useCallback(S=>{N.current&&clearTimeout(N.current),E.current=S,N.current=setTimeout(()=>{N.current=null,E.current=null,x(S)},qo)},[x]),L=o.useCallback(()=>{if(!N.current)return;clearTimeout(N.current),N.current=null;const S=E.current;E.current=null,S&&x(S)},[x]),w=()=>{N.current&&clearTimeout(N.current),N.current=null,E.current=null},V=o.useRef(L);V.current=L;const[$,q]=o.useState(l??null),G=o.useRef(null),v=o.useRef(0),B=Mt(S=>S.ownerId),C=Mt(S=>S.status);o.useEffect(()=>{!$||$.state!=="playing"||(B!==tn||C==="ended")&&q(null)},[B,C,$]);const D=o.useCallback(()=>{G.current&&Ho(G.current),G.current=null},[]),J=o.useCallback(()=>{v.current+=1,Mt.getState().stop(tn),q(null)},[]),ee=o.useCallback(async(S,oe)=>{if(S===fs)return;const fe=++v.current,Me=Date.now();q({id:S,state:"loading"});try{const De=await ls({op:"notification_sounds.audio",soundId:S,volume:Math.max(0,Math.min(100,Math.round(oe)))},null);if(fe!==v.current)return;if(Date.now()-Me>Vo){q(null);return}if(De.kind!=="bytes")throw new Error("no audio");D();const Le=Wo(De.data,De.mimeType||"audio/wav");G.current=Le;const we=await Mt.getState().play(tn,Le,{onEnded:()=>q(null),fixedOutput:{volume:1,playbackRate:1},onError:()=>q({id:S,state:"failed"})});if(fe!==v.current)return;q(we?{id:S,state:"playing"}:{id:S,state:"failed"})}catch{if(fe!==v.current)return;q({id:S,state:"failed"})}},[D]),Z=S=>{if($?.id===S&&$.state==="playing"){J();return}ee(S,a)};o.useImperativeHandle(p,()=>({previewSelected:S=>{ee(z,S)}}),[ee,z]),o.useEffect(()=>()=>{V.current(),Mt.getState().stop(tn),D()},[D]);const[ce,ie]=o.useState(""),[de,Se]=o.useState(null),[H,U]=o.useState(h?{[h.id]:h.mode}:{}),k=S=>H[S]??{kind:"idle"},Y=(S,oe)=>U(fe=>({...fe,[S]:oe})),ae=o.useRef(new Map),ue=S=>{let oe=ae.current.get(S);return oe||(oe={current:null},ae.current.set(S,oe)),oe},ke=o.useRef(null),me=o.useRef(null),[pe,je]=o.useState(null);o.useEffect(()=>{if(!pe)return;const S=setTimeout(()=>{pe==="add"?ke.current?.focus():ae.current.get(pe)?.current?.focus(),je(null)},0);return()=>clearTimeout(S)},[pe]);const Ke=async(S,oe)=>{Y(S.id,{kind:"renaming",saving:!0,error:null});try{await Ne({op:"notification_sounds.rename",id:S.id,name:oe}),await c(),Y(S.id,{kind:"idle"}),je(S.id)}catch(fe){Y(S.id,{kind:"renaming",saving:!1,error:n("ui.settings.notifications.custom.rename_failed",{reason:es(fe)}).trim()})}},se=async S=>{Y(S.id,{kind:"confirm-remove",removing:!0,error:null});const oe=g.custom.map(fe=>fe.id);try{const fe=await Ne({op:"notification_sounds.remove",id:S.id});$?.id===S.id&&J();const Me=fe?.selection_reset===!0;Me&&(w(),A(Go)),ie(Me?n("ui.settings.notifications.custom.removed_reset",{name:S.label}):n("ui.settings.notifications.custom.removed",{name:S.label}));const De=Yo(oe,S.id);U(Le=>{const{[S.id]:we,...Ze}=Le;return Ze}),await c(),je(De??"add")}catch(fe){Y(S.id,{kind:"confirm-remove",removing:!1,error:n("ui.settings.notifications.custom.remove_failed",{name:S.label,reason:es(fe)}).trim()})}},[re,ve]=o.useState(()=>(d??[]).map(({fileName:S,percent:oe,...fe})=>({...fe,file:new File([],S)}))),[Q,ge]=o.useState(()=>Object.fromEntries((d??[]).map(S=>[S.key,S.percent??0]))),he=o.useRef(Promise.resolve()),Pe=o.useRef(0),Ge=o.useRef(new Set),Be=(S,oe)=>ve(fe=>fe.map(Me=>Me.key===S?{...Me,...oe}:Me)),Ae=S=>ve(oe=>oe.filter(fe=>fe.key!==S)),tt=async S=>{if(Ge.current.has(S.key))return null;if(S.file.size>_.max_bytes)return Be(S.key,{phase:"error",refusal:{code:"too_large"}}),null;Be(S.key,{phase:"uploading"}),ge(Le=>({...Le,[S.key]:0}));let oe;try{oe=await zh(S.file,Le=>ge(we=>({...we,[S.key]:Math.round(Le*100)})))}catch{return Be(S.key,{phase:"error",refusal:{code:null}}),null}if(Ge.current.has(S.key))return null;if(oe.byteLength>_.max_bytes)return Be(S.key,{phase:"error",refusal:{code:"too_large"}}),null;Be(S.key,{phase:"processing"});const fe=await ls({op:"notification_sounds.upload",fileName:S.file.name||"sound",name:S.stem},oe).catch(()=>null);if(Ge.current.has(S.key))return null;if(!fe||fe.kind!=="json")return Be(S.key,{phase:"error",refusal:fe?Ph(fe):{code:null}}),null;const Me=fe.body,De=typeof Me?.result?.id=="string"?Me.result.id:null;return await c(),Ae(S.key),De},ht=S=>{if(S.length===0)return;Se(null);const oe=g.custom.length+re.filter(we=>we.phase!=="error").length,{accepted:fe,overLimit:Me}=Jo(S,oe,_.max_sounds),De=[...fe.map(we=>({key:`upload-${++Pe.current}`,file:we,stem:ia(we.name,_.max_name_chars),phase:"queued"})),...Me.map(we=>({key:`upload-${++Pe.current}`,file:we,stem:ia(we.name,_.max_name_chars),phase:"error",refusal:{code:"limit_reached"}}))];ve(we=>[...we,...De]);const Le=De.filter(we=>we.phase==="queued");he.current=he.current.then(async()=>{const we=[];for(const Ze of Le){const en=await tt(Ze);en&&we.push({id:en,name:Ze.stem})}if(we.length!==0){if(Le.length===1&&we.length===1)rt(we[0]);else{const Ze=n("ui.settings.notifications.custom.added_many",{count:we.length});ie(Ze),Se(Ze)}ke.current?.focus()}})},rt=S=>{w(),A(S.id),x(S.id),ee(S.id,a),ie(n("ui.settings.notifications.custom.added_one",{name:S.name}))},ft=S=>{Be(S.key,{phase:"queued",refusal:void 0}),he.current=he.current.then(async()=>{const oe=await tt({...S,phase:"queued"});oe&&rt({id:oe,name:S.stem})})},ot=S=>{Ge.current.add(S.key),Ae(S.key)},T=g.custom.length,W=T>=_.max_sounds,te=S=>$?.id===S?$.state:"idle",F=o.useRef({active:!1,repeated:!1}),le=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],ye=S=>{le.includes(S.key)&&(F.current.active=!0,S.repeat&&(F.current.repeated=!0))},Ce=S=>{if(!le.includes(S.key))return;const oe=F.current.repeated;F.current={active:!1,repeated:!1},oe&&ee(K.current,a)},Ie=S=>{if(!F.current.active)return;const oe=S.target;oe?.getAttribute("role")==="radio"&&oe.getAttribute("data-state")!=="checked"&&oe.click()},Te=S=>{S.key==="Escape"&&$&&J()},Ye=()=>me.current?.click();return e.jsxs("div",{className:"flex flex-col gap-3",onKeyDown:Te,children:[e.jsx("span",{id:j,className:"sr-only",children:n("ui.settings.notifications.list.label")}),e.jsxs(Ll,{"aria-labelledby":j,value:z,loop:!0,disabled:!r,onValueChange:S=>{S!==K.current&&(A(S),K.current=S,I(null),F.current.repeated||ee(S,a),R(S))},onKeyDownCapture:ye,onKeyUp:Ce,onFocusCapture:Ie,onBlur:S=>{S.currentTarget.contains(S.relatedTarget)||L()},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:[g.builtin.map(S=>e.jsx(Ha,{sound:S,isDefault:S.is_default,preview:te(S.id),onPreview:()=>Z(S.id)},S.id)),g.system&&e.jsx("div",{className:"border-t border-hairline",children:e.jsx(Ha,{sound:{...g.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:f,className:"text-meta text-ink-dim",children:n("ui.settings.notifications.list.custom")}),T>0&&e.jsx("p",{className:"font-mono text-mono-sm text-ink-dim",children:n("ui.settings.notifications.list.custom_count",{count:T,max:_.max_sounds})})]}),e.jsxs("div",{className:"border-t border-hairline",children:[T===0&&re.length===0&&e.jsx("p",{className:`${yr} text-body-sm text-ink-muted`,children:n("ui.settings.notifications.custom.empty")}),g.custom.map(S=>e.jsx(Oh,{sound:S,selected:z===S.id,preview:te(S.id),onPreview:()=>Z(S.id),mode:k(S.id),maxNameChars:_.max_name_chars,describedBy:f,moreRef:ue(S.id),onStartRename:()=>Y(S.id,{kind:"renaming",saving:!1,error:null}),onRename:oe=>Ke(S,oe),onCancelRename:()=>{Y(S.id,{kind:"idle"}),je(S.id)},onStartRemove:()=>Y(S.id,{kind:"confirm-remove",removing:!1,error:null}),onConfirmRemove:()=>void se(S),onCancelRemove:()=>{Y(S.id,{kind:"idle"}),je(S.id)}},S.id)),re.map(S=>e.jsx(Uh,{row:S,percent:Q[S.key]??0,limitSeconds:_.max_duration_s,limitMegabytes:Math.round(_.max_bytes/(1024*1024)),maxSounds:_.max_sounds,onCancel:()=>ot(S),onDismiss:()=>Ae(S.key),onChooseAnother:()=>{Ae(S.key),Ye()},onRetry:()=>ft(S)},S.key))]})]}),y!==null&&e.jsx(_e,{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:y}).trim()}),M&&e.jsx(O,{variant:"secondary",size:"sm",onClick:()=>{A(M),x(M)},children:n("ui.settings.notifications.retry")})]})}),e.jsxs("div",{className:"flex flex-col items-start gap-2 px-2",children:[e.jsx("input",{ref:me,type:"file",multiple:!0,accept:$h,className:"hidden",tabIndex:-1,"aria-hidden":"true",onChange:S=>{const oe=Array.from(S.target.files??[]);S.target.value="",ht(oe)}}),e.jsxs(O,{ref:ke,variant:"secondary",size:"sm",disabled:W,onClick:Ye,children:[e.jsx(jn,{"aria-hidden":"true"}),n("ui.settings.notifications.custom.add")]}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:W?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))})})]}),de&&e.jsx("p",{className:"px-2 text-body-sm text-ink-muted","aria-hidden":"true","data-added-notice":"",children:de}),e.jsx("output",{"aria-live":"polite",className:"sr-only",children:ce})]})});jr.displayName="NotificationSoundList";function Fh(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 zh(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 Uh=({row:t,percent:s,limitSeconds:a,limitMegabytes:r,maxSounds:i,onCancel:c,onDismiss:l,onChooseAnother:d,onRetry:u})=>{ne();const m=t.file.name||t.stem;if(t.phase==="error"){const p=t.refusal??{code:null},g=Qo(p),f=Fh(g.key,{file:m,seconds:Zo(p,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(Oi,{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:f}),g.action==="retry"?e.jsx(O,{variant:"link",size:"sm",onClick:u,children:n("ui.settings.notifications.retry")}):e.jsx(O,{variant:"link",size:"sm",onClick:d,children:n("ui.settings.notifications.error.choose_another")}),e.jsx(O,{variant:"ghost",size:"icon",className:"size-11 shrink-0 text-ink-muted hover:text-ink","aria-label":n("ui.settings.notifications.error.dismiss"),onClick:l,children:e.jsx(ga,{"aria-hidden":"true"})})]})}const h=t.phase==="processing";return e.jsxs("div",{className:yr,"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(Ee,{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:[h?n("ui.settings.notifications.custom.finishing"):n("ui.settings.notifications.custom.uploading",{percent:s}),e.jsx(Kh,{value:h?null:s})]}),h?e.jsx("span",{className:"size-11 shrink-0","aria-hidden":"true"}):e.jsx(O,{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(ga,{"aria-hidden":"true"})})]})},Kh=({value:t})=>e.jsx(Ti,{value:t,className:"w-16","aria-hidden":"true"}),ts={list:[...ao.settings,"notification-sounds"]};function Bh(t){return t==="enabled"?"ready":t==="below-version"?"older":"pairing"}const qh=({resetErrorBoundary:t})=>(ne(),e.jsx(_e,{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(O,{variant:"secondary",size:"sm",onClick:t,children:[e.jsx(Sn,{"aria-hidden":"true"}),n("ui.settings.notifications.retry")]})]})})),ns=(t,s)=>typeof t?.value=="boolean"?t.value:s,Va=(t,s)=>typeof t?.value=="number"&&Number.isFinite(t.value)?t.value:s,Hh=({sectionRef:t,listPresets:s})=>{ne();const a=Nt(),r=gt(),i=Ts(),c=ui(r.data,"notification_sounds"),l=Bh(c),d=ze({queryKey:mt.all,queryFn:()=>Ne({op:"settings.list"}),enabled:l!=="pairing",staleTime:1e4}),u=ze({queryKey:ts.list,queryFn:async()=>{const H=await Ne({op:"notification_sounds.list"}),U=ac(H);if(!U)throw new Error("unreadable notification sound listing");return U},enabled:l==="ready",staleTime:1e4}),m=d.data?.settings??[],h=o.useMemo(()=>new Map(m.map(H=>[H.key,H])),[m]),p=h.get(ct),g=h.get(At),f=o.useMemo(()=>Xo(m),[m]),j=f.byKey["notifications.sound.enabled"],_=f.byKey["notifications.sound.id"],b=f.byKey["notifications.sound.volume"],[A,y]=o.useState({}),[I,M]=o.useState({}),P=o.useCallback((H,U)=>y(k=>({...k,[H]:U})),[]),N=o.useCallback((H,U)=>M(k=>({...k,[H]:U})),[]),E=o.useCallback(async()=>{await Promise.all([a.invalidateQueries({queryKey:mt.all}),a.invalidateQueries({queryKey:ts.list})])},[a]),z=o.useRef(new Map),K=o.useRef(new Map),x=o.useCallback((H,U)=>{const k=z.current.get(H)??Promise.resolve();K.current.set(H,(K.current.get(H)??0)+1),P(H,!0),N(H,null);const Y=k.catch(()=>{}).then(async()=>{try{await Ne({op:"settings.edit",key:H,value:U}),await E()}catch(ae){throw N(H,ae instanceof Error&&ae.message?ae.message:n("ui.settings.notifications.save.failed_generic")),ae}finally{const ae=(K.current.get(H)??1)-1;K.current.set(H,ae),ae===0&&P(H,!1)}});return z.current.set(H,Y),Y},[E,P,N]),R=o.useCallback(async H=>{P(H,!0),N(H,null);try{await Ne({op:"settings.reset",key:H}),await E()}catch(U){throw N(H,U instanceof Error&&U.message?U.message:n("ui.settings.notifications.save.failed_generic")),U}finally{P(H,!1)}},[E,P,N]),L=ec(),w=o.useRef(null);o.useEffect(()=>{const H=L.configChange;if(!H)return;const U=`${H.epoch}:${H.seq}`;w.current!==U&&(w.current=U,H.changedKeys.some(k=>k==="notifications"||k.startsWith("notifications.")||k==="display"||k===ct||k===At)&&E())},[L.configChange,E]),o.useEffect(()=>{const H=()=>{a.invalidateQueries({queryKey:ts.list})};return window.addEventListener("focus",H),()=>window.removeEventListener("focus",H)},[a]);const V=o.useRef(null),$=o.useRef(null),q=o.useRef(null),G=n("ui.settings.notifications.section.title"),v=n("ui.settings.notifications.section.description"),B=H=>e.jsx(Re,{title:G,icon:tl,description:v,sectionRef:t,searchSection:"notifications",searchSectionLabel:G,searchIgnore:"notification rows are registry keys read from the daemon's own selection",children:H});if(l==="pairing"){const{sentence:H}=Vt(i??null,n("ui.settings.notifications.load.failed",{reason:""}).trim(),r.data?null:r.error??null);return B(e.jsx(_e,{variant:"warning",children:H}))}const C=ns(p,!0),D=e.jsxs("div",{className:"flex flex-col gap-1",ref:$,children:[p&&e.jsx(zt,{label:p.label,description:p.help||void 0,value:C,isSaving:!!A[ct],savingInPlace:!0,onChange:H=>x(ct,H).catch(()=>{})}),g&&e.jsx(zt,{label:g.label,description:g.help||void 0,value:ns(g,!0),isSaving:!!A[At],savingInPlace:!0,onChange:H=>x(At,H).catch(()=>{})}),[ct,At].map(H=>I[H]&&e.jsx("output",{className:"block text-meta text-danger",children:I[H]},H))]});if(d.isPending)return B(e.jsxs("div",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(Ee,{size:"sm"}),n("ui.settings.notifications.load.loading")]}));if(d.error){const{sentence:H}=Vt(i??null,n("ui.settings.notifications.load.failed",{reason:""}).trim(),d.error);return B(e.jsx(_e,{variant:"warning",children:e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx("span",{children:H}),e.jsxs(O,{variant:"secondary",size:"sm",onClick:()=>{E().then(()=>{a.getQueryState(mt.all)?.status==="success"&&M({})})},children:[e.jsx(Sn,{"aria-hidden":"true"}),n("ui.settings.notifications.retry")]})]})}))}const J=e.jsx("h3",{className:"text-body font-medium text-ink",children:n("ui.settings.notifications.sound.heading")});if(l==="older")return B(e.jsxs("div",{className:"flex flex-col gap-6",children:[D,e.jsxs("div",{className:"flex flex-col gap-2 border-t border-hairline pt-6",children:[J,e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.notifications.backend_older")})]})]}));const ee=u.data??null,Z=ns(j,ee?.enabled??!0),ce=typeof _?.value=="string"?_.value:ee?.selected??"",ie=Va(b?{...b,value:b.default}:void 0,ra),de=Va(b,ee?.volume??ra),Se=H=>{const{key:U,value:k}=ic(H,ie);return n(U,{value:k})};return B(e.jsxs("div",{className:"flex flex-col gap-6",children:[D,e.jsxs("div",{className:"flex flex-col gap-4 border-t border-hairline pt-6","data-notification-sound-group":"",children:[J,!C&&e.jsx(_e,{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(O,{variant:"secondary",size:"sm",disabled:!!A[ct],onClick:()=>{x(ct,!0).then(()=>Wa($.current,'[role="switch"]'),()=>{})},children:n("ui.settings.notifications.sound.gated_action")})]})}),j&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(zt,{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:Z,isSaving:!!A["notifications.sound.enabled"],savingInPlace:!0,onChange:H=>x("notifications.sound.enabled",H).catch(()=>{})}),!Z&&e.jsx("p",{className:"text-body-sm text-ink-muted","data-sound-off-note":"",children:n("ui.settings.notifications.sound.enabled_off_note")}),I["notifications.sound.enabled"]&&e.jsx("output",{className:"block text-meta text-danger",children:I["notifications.sound.enabled"]})]}),b&&e.jsxs("div",{ref:q,className:"flex flex-col gap-1","data-search-row":"notifications.sound.volume","data-search-control":"",children:[e.jsx(el,{value:de,label:n("ui.settings.notifications.volume.label"),description:n(rc(de,ce)),min:0,max:100,step:sc,pageStep:nc,icon:tc(de),readout:Se,valueText:H=>n("ui.settings.notifications.volume.valuetext",{value:Math.round(H)}),disabled:ce===fs,isSaving:!!A["notifications.sound.volume"],savingInPlace:!0,trailing:Math.round(de)!==Math.round(ie)?e.jsx(O,{variant:"link",size:"sm",disabled:ce===fs,onClick:()=>{R("notifications.sound.volume").then(()=>{Wa(q.current,'input[type="range"]'),V.current?.previewSelected(ie)},()=>{})},children:n("ui.settings.notifications.volume.reset")}):null,onChange:async H=>{await x("notifications.sound.volume",H),V.current?.previewSelected(H)}}),I["notifications.sound.volume"]&&e.jsx("output",{className:"block text-meta text-danger",children:I["notifications.sound.volume"]})]}),u.error?e.jsx(_e,{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(O,{variant:"secondary",size:"sm",onClick:()=>{u.refetch()},children:[e.jsx(Sn,{"aria-hidden":"true"}),n("ui.settings.notifications.retry")]})]})}):ee?e.jsx(Pi,{fallbackRender:qh,children:e.jsx(jr,{ref:V,listing:ee,selectedId:ce,volume:de,canSelect:!!_,onSelect:H=>x("notifications.sound.id",H),onChanged:E,...s})}):e.jsxs("div",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(Ee,{size:"sm"}),n("ui.settings.notifications.load.loading")]}),f.missing.length>0&&e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.notifications.missing_rows",{count:f.missing.length,rows:f.missing.join(", ")})}),e.jsx(Vh,{})]})]}))},Vh=()=>{ne();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(O,{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(Ee,{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 Wa(t,s){requestAnimationFrame(()=>{t?.querySelector(s)?.focus()})}const Wh="mobile_password_unset",Gh="••••••••••••",Yh=2e3,Qh=async()=>{try{const s=(await Ne({op:"mobile.password"}))?.password;return typeof s!="string"||!s?null:s}catch(t){if(t instanceof St&&t.code===Wh)return null;throw t}};function Zh(t){return t?.password?{kind:"read",password:t.password}:t?.state?{kind:t.state}:{kind:"idle"}}const Jh=({read:t,initial:s})=>{const[a,r]=o.useState(()=>Zh(s)),[i,c]=o.useState(!!s?.revealed),[l,d]=o.useState("idle"),u=o.useRef(!0);o.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]),o.useEffect(()=>{if(l!=="copied")return;const _=setTimeout(()=>d("idle"),Yh);return()=>clearTimeout(_)},[l]);const m=o.useRef(null),h=o.useRef(null),p=o.useRef(null),g=o.useRef(!1);o.useEffect(()=>{if(!g.current||a.kind==="reading")return;g.current=!1;const _=document.activeElement;_&&_!==document.body&&!m.current?.contains(_)||(a.kind==="read"?h:p).current?.focus()},[a.kind]);const f=()=>{g.current=!0,r({kind:"reading"}),c(!1),d("idle"),t().then(_=>{u.current&&r(_?{kind:"read",password:_}:{kind:"unset"})},()=>{u.current&&r({kind:"error"})})},j=_=>{d("idle"),Promise.resolve().then(()=>navigator.clipboard.writeText(_)).then(()=>u.current&&d("copied"),()=>u.current&&d("failed"))};return e.jsxs("div",{ref:m,className:"flex flex-col gap-2","data-testid":"phone-password-panel",children:[e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.phone_pairing.password.body")}),a.kind==="read"?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-meta text-ink",children:n("ui.phone_pairing.password.label")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i?e.jsx("code",{dir:"ltr",style:{unicodeBidi:"isolate"},className:"break-all rounded-sm bg-sunken px-2 py-1 font-mono text-body-sm text-ink","data-testid":"phone-password-value",children:a.password}):e.jsx("span",{role:"img","aria-label":n("ui.phone_pairing.password.masked_aria"),className:"rounded-sm bg-sunken px-2 py-1 font-mono text-body-sm text-ink","data-testid":"phone-password-masked",children:Gh}),e.jsx(O,{type:"button",variant:"secondary",size:"sm",ref:h,onClick:()=>c(_=>!_),"data-testid":"phone-password-toggle",children:i?n("ui.phone_pairing.password.hide"):n("ui.phone_pairing.password.show")}),e.jsx(O,{type:"button",variant:"secondary",size:"sm",onClick:()=>j(a.password),"data-testid":"phone-password-copy",children:l==="copied"?n("ui.phone_pairing.password.copied"):n("ui.phone_pairing.password.copy")})]}),l==="failed"?e.jsx("p",{className:"text-meta text-danger",role:"alert",children:n("ui.phone_pairing.password.copy_failed")}):null]}):e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[e.jsx(O,{type:"button",variant:"secondary",size:"sm",ref:p,disabled:a.kind==="reading",onClick:f,"data-testid":"phone-password-read",children:n("ui.phone_pairing.password.read")}),a.kind==="unset"?e.jsx("output",{className:"block text-meta text-ink-muted","data-testid":"phone-password-unset",children:n("ui.phone_pairing.password.unset")}):a.kind==="error"?e.jsx("p",{className:"text-meta text-danger",role:"alert","data-testid":"phone-password-error",children:n("ui.phone_pairing.password.error")}):null]})]})},Xh=({read:t=Qh,defaultOpen:s=!1,initial:a})=>e.jsx("div",{"data-testid":"phone-password-disclosure",children:e.jsx(oc,{summary:n("ui.phone_pairing.password.disclosure"),defaultOpen:s,children:e.jsx(Jh,{read:t,initial:a})})}),ef={ios:"ui.phone_pairing.platform.ios",android:"ui.phone_pairing.platform.android",web:"ui.phone_pairing.platform.web"};function tf(t){return n(ef[t]??"ui.phone_pairing.platform.unknown")}function Ga(t){return io(t*1e3,{dateStyle:"medium"})}const Ya={still_removing:"ui.phone_pairing.phones.still_removing",not_found:"ui.phone_pairing.phones.not_found",error:"ui.phone_pairing.phones.error"},nf=({phones:t,loading:s=!1,loadFailed:a=!1,removing:r=null,notices:i={},onRemove:c,onRetryLoad:l,initialConfirm:d=null})=>{const[u,m]=o.useState(d),h=t?.find(y=>y.deviceId===u)??null,p=Ri(),g=o.useRef(null),f=o.useRef(null),j=o.useRef(d),_=()=>{const y=j.current,I=y?Array.from(g.current?.querySelectorAll("button[data-device-id]")??[]).find(M=>M.dataset.deviceId===y):void 0;I&&!I.disabled?I.focus():f.current?.focus()},b=new Set(t?.map(y=>y.deviceId)??[]),A=Object.entries(i).filter(([y,I])=>I==="not_found"||!b.has(y));return e.jsxs("section",{ref:g,className:"flex flex-col gap-3","data-testid":"paired-phones",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h3",{ref:f,tabIndex:-1,className:"font-medium text-body text-ink outline-none","data-testid":"paired-phones-heading",children:n("ui.phone_pairing.phones.title")}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.phone_pairing.phones.subtitle")})]}),a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-body-sm text-danger",role:"alert",children:n("ui.phone_pairing.phones.load_error")}),l?e.jsx(O,{type:"button",variant:"secondary",size:"sm",onClick:l,children:n("ui.phone_pairing.phones.retry")}):null]}):null,A.map(([y,I])=>e.jsx("p",{className:xe("text-meta",I==="error"?"text-danger":"text-ink-muted"),role:I==="error"?"alert":"status","data-testid":"paired-phones-list-notice",children:n(Ya[I])},y)),a||s||!t?null:t.length===0?e.jsx("p",{className:"text-body-sm text-ink-muted","data-testid":"paired-phones-empty",children:n("ui.phone_pairing.phones.empty")}):e.jsx("ul",{className:"flex flex-col divide-y divide-hairline rounded-md border border-hairline",children:t.map(y=>{const I=i[y.deviceId],M=r===y.deviceId,P=y.state==="removing"||I==="still_removing";return e.jsxs("li",{className:"flex items-start gap-3 p-3","data-testid":"paired-phone-row","data-state":y.state,children:[e.jsx(rl,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),e.jsxs("div",{className:"flex min-w-0 grow flex-col gap-0.5",children:[e.jsx("q",{className:"truncate font-medium text-body-sm text-ink",children:e.jsx("bdi",{title:y.name,"data-testid":"paired-phone-name",children:y.name})}),e.jsx("span",{className:"text-meta text-ink-muted",children:[tf(y.platform),y.pairedAt?n("ui.phone_pairing.phones.paired_at",{date:Ga(y.pairedAt)}):null,y.lastSeen?n("ui.phone_pairing.phones.last_seen",{date:Ga(y.lastSeen)}):null].filter(Boolean).join(" · ")}),y.state==="unconfirmed"?e.jsx("span",{className:"text-meta text-ink-muted",children:n("ui.phone_pairing.phones.unconfirmed")}):null,M?e.jsx("span",{className:"text-meta text-ink","data-testid":"paired-phone-working",children:n("ui.phone_pairing.setup.working",{os:p})}):P?e.jsx("span",{className:"text-meta text-warning",role:I==="still_removing"?"status":void 0,"data-testid":"paired-phone-unfinished",children:I==="still_removing"?n("ui.phone_pairing.phones.still_removing"):n("ui.phone_pairing.phones.removing",{os:p})}):null,I==="error"?e.jsx("span",{className:"text-meta text-danger",role:"alert","data-testid":"paired-phone-notice",children:n(Ya[I])}):null]}),P?e.jsx(O,{type:"button",variant:"secondary",size:"sm",disabled:M,onClick:()=>{j.current=y.deviceId,c(y.deviceId)},"data-testid":"paired-phone-finish","data-device-id":y.deviceId,children:n("ui.phone_pairing.phones.finish_removing")}):e.jsx(O,{type:"button",variant:"danger",size:"sm",disabled:M,"aria-label":n("ui.phone_pairing.phones.remove_aria",{name:y.name}),onClick:()=>{j.current=y.deviceId,m(y.deviceId)},"data-testid":"paired-phone-remove","data-device-id":y.deviceId,children:n("ui.phone_pairing.phones.remove")})]},y.deviceId)})}),e.jsx(Dt,{open:h!==null,onOpenChange:y=>{y||m(null)},children:e.jsxs($t,{"data-testid":"paired-phone-dialog",onCloseAutoFocus:y=>{y.preventDefault(),_()},children:[e.jsxs(Ol,{children:[e.jsx(Pt,{children:n("ui.phone_pairing.phones.dialog_title")}),e.jsx(Ft,{children:e.jsx("q",{className:"font-medium text-ink",children:e.jsx("bdi",{"data-testid":"paired-phone-dialog-name",children:h?.name})})})]}),e.jsxs("div",{className:"flex flex-col gap-2 text-body-sm text-ink",children:[e.jsx("p",{children:n("ui.phone_pairing.phones.dialog_body")}),e.jsx("p",{children:n("ui.phone_pairing.phones.dialog_again")}),e.jsx("p",{className:"text-ink-muted",children:n("ui.phone_pairing.phones.dialog_gesture",{os:p})})]}),e.jsxs(Dl,{children:[e.jsx(O,{type:"button",variant:"secondary",size:"md",onClick:()=>m(null),children:n("ui.phone_pairing.phones.cancel")}),e.jsx(O,{type:"button",variant:"danger",size:"md","data-testid":"paired-phone-confirm-remove",onClick:()=>{h&&c(h.deviceId),m(null)},children:n("ui.phone_pairing.phones.remove")})]})]})})]})},sf=({state:t,running:s=!1,message:a=null,failed:r=!1,onTurnOn:i})=>{const c=Ri();if(t.state==="on")return a?e.jsx("output",{className:"block text-body-sm text-ink",children:n("ui.phone_pairing.setup.on",{os:c})}):null;const l=s||t.inProgress;return e.jsxs("section",{className:"flex flex-col gap-2 rounded-md border border-hairline p-3","data-testid":"phone-approvals-setup",children:[e.jsx("h3",{className:"font-medium text-body-sm text-ink",children:n("ui.phone_pairing.setup.title")}),t.canPrompt?e.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.phone_pairing.setup.body",{os:c})}):t.message?e.jsx("p",{className:"text-meta text-ink-muted",children:t.message}):null,t.fileOnlyNotice?e.jsx("p",{className:"text-meta text-ink-muted",children:t.fileOnlyNotice}):null,t.state==="finish_setup"&&!l?e.jsx("p",{className:"text-meta text-ink","data-testid":"phone-approvals-finish-reason",children:n("ui.phone_pairing.setup.finish_reason")}):null,l?e.jsx("output",{className:"block text-meta text-ink",children:n("ui.phone_pairing.setup.working",{os:c})}):null,a?e.jsx("output",{className:"block text-meta text-ink",children:a}):r?e.jsx("p",{className:"text-meta text-danger",role:"alert",children:n("ui.phone_pairing.setup.error")}):null,t.canPrompt?e.jsx("div",{children:e.jsx(O,{type:"button",variant:"primary",size:"sm",disabled:l,onClick:i,"data-testid":"phone-approvals-turn-on",children:t.state==="finish_setup"?n("ui.phone_pairing.setup.finish"):n("ui.phone_pairing.setup.turn_on")})}):null]})},af=()=>{const t=nl(!0),s=sl(),[a,r]=o.useState(null);return t.data?e.jsx(sf,{state:t.data,running:s.isPending,message:a,failed:s.isError&&!a,onTurnOn:()=>s.mutate(void 0,{onSuccess:i=>r(i),onError:i=>r(i instanceof St&&i.status===409?i.message:null)})}):null},rf=()=>{const t=al(!0),s=il(),[a,r]=o.useState({}),i=(c,l)=>r(d=>{const u={...d};return l?u[c]=l:delete u[c],u});return e.jsx(nf,{phones:t.data,loading:t.isLoading,loadFailed:t.isError,onRetryLoad:()=>void t.refetch(),removing:s.isPending?s.variables??null:null,notices:a,onRemove:c=>{i(c,null),s.mutate(c,{onSuccess:l=>i(c,l.state==="removing"?"still_removing":null),onError:l=>i(c,l instanceof St&&l.status===404?"not_found":"error")})}})},of=({className:t})=>{const s=gt(),a=Qe(s.data,"phone_pairing"),r=Qe(s.data,"operator_setup"),i=Qe(s.data,"mobile_password_read");return!a&&!r&&!i?null:e.jsxs("div",{className:xe("flex flex-col gap-4",t),"data-testid":"phone-pairing-settings",children:[r?e.jsx(af,{}):null,a?e.jsx(rf,{}):null,i?e.jsx(Xh,{}):null]})},qt=new WeakMap,Qa=new WeakSet;function wr(t,s){if(!Qa.has(t)){Qa.add(t);let r=vt(t);cc(t,()=>{const i=vt(t);r!==i&&(r=i,qt.delete(t))})}if(!s.startsWith(`${vt(t)}:`))return;const a=qt.get(t);if(a?.key===s)return a;qt.delete(t)}function cf(t,s,a){if(s.startsWith(`${vt(t)}:`)){if(wr(t,s),!Object.keys(a).length){qt.delete(t);return}qt.set(t,{key:s,fields:a})}}const lf=Fe.object({display_name:Fe.string(),title:Fe.string(),description:Fe.string(),timezone:Fe.string()}),df=lf.extend({account_id:Fe.string(),display_label:Fe.string(),avatar_url:Fe.string().optional(),avatar:Fe.object({source:Fe.string(),hash:Fe.string(),updated_at:Fe.string().optional()}).optional()}),uf=Fe.object({scope:Fe.string().regex(/^[a-f0-9]{64}$/),profile:df});class Za extends Error{constructor(s,a){super("Account profile request failed"),this.code=s,this.status=a}}async function dn(t,s=null){const a=await ls(t,s);if(a.kind!=="json")throw new Za(a.kind==="error"?a.code:void 0,a.kind==="error"?a.status:null);const r=uf.parse(a.body.result);if(r.profile.account_id!==t.expectedAccountId)throw new Za("account_mismatch",409);return r}const un={read:t=>dn({op:"account.profile",expectedAccountId:t}),update:(t,s,a)=>dn({op:"account.profile.update",expectedAccountId:t,scope:s,fields:a}),upload:(t,s,a)=>dn({op:"account.avatar.put",expectedAccountId:t,scope:s},a),remove:(t,s,a)=>dn({op:"account.avatar.delete",expectedAccountId:t,scope:s,mode:a,confirmed:!0})};function ss(t,s){return Object.fromEntries(Object.keys(t).filter(a=>t[a]!==s[a]).map(a=>[a,s[a]]))}const Nr={snapshot:(t,s)=>["account-profile",t,s]};function as(t,s,a){if(vt(t)!==s||lc(t).accountId!==a.profile.account_id)throw new Error("Account authority changed");t.setQueryData(Nr.snapshot(a.profile.account_id,s),a),t.setQueryData(oa.user(),r=>{if(!r||r.account.id!==a.profile.account_id)return r;const{display_name:i,title:c,description:l,timezone:d,avatar:u,avatar_url:m}=a.profile;return{...r,account:{...r.account,profile:{...r.account.profile,display_name:i,title:c,description:l,timezone:d,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:oa.user()})}function mf(t=!0,s=()=>"personal"){const a=Nt(),r=ki(),i=r.accountId,c=s(),l=ze({queryKey:Nr.snapshot(i??"unresolved",r.token),enabled:t&&!!i,retry:!1,queryFn:()=>dc(a,i,()=>un.read(i??""))}),d=()=>{if(!i||vt(a)!==r.token||s()!==c)throw new Error("Account authority changed")};return{...l,authority:r,async update(u){if(d(),!l.data||!i)throw new Error("Account profile unresolved");const m=await un.update(i,l.data.scope,u);return d(),as(a,r.token,m),m},async upload(u){if(d(),!l.data||!i)throw new Error("Account profile unresolved");const m=await un.upload(i,l.data.scope,u);return d(),as(a,r.token,m),m},async remove(u){if(d(),!l.data||!i)throw new Error("Account profile unresolved");const m=await un.remove(i,l.data.scope,u);return d(),as(a,r.token,m),m}}}const pf=1024*1024;function gf(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 Ja(t){return!!(t&&t.width>0&&t.height>0&&t.width<=4096&&t.height<=4096&&t.width*t.height<=16e6)}async function hf(t){if(!t.size||t.size>pf||!["image/png","image/jpeg","image/webp"].includes(t.type))throw new Error("Profile image refused");const s=new Uint8Array(await t.arrayBuffer());if(!Ja(gf(s)))throw new Error("Profile image dimensions refused");const a=await createImageBitmap(t,{imageOrientation:"from-image"});if(!Ja(a))throw a.close(),new Error("Profile decoded image dimensions refused");return a}const ff=t=>t.replace(/\u2212/g,"-"),xf=(t,s)=>t.formatToParts(s).find(a=>a.type==="timeZoneName")?.value,Xa="en-US";function _f(t,s=new Date){return[...new Set(["UTC",...Intl.supportedValuesOf("timeZone")])].map(a=>{const r=(d,u)=>xf(new Intl.DateTimeFormat(d,{timeZone:a,timeZoneName:u}),s),i=r(t,"shortOffset"),c=[i,r(t,"short"),r(Xa,"shortOffset"),r(Xa,"short")],l=[...new Set(c.flatMap(d=>d===void 0?[]:[d,ff(d)]).filter(d=>!!d&&d!==a))];return{id:a,name:a.split("_").join(" "),description:i,keywords:l}})}const mn=t=>({display_name:t.profile.display_name,title:t.profile.title,description:t.profile.description,timezone:t.profile.timezone}),vn={display_name:64,title:80,description:500},yf=t=>vn[t]*2,ei=8;function bf({snapshot:t,initialDraft:s,onDraftChange:a,photoUrl:r,onSave:i,onUpload:c,onRemove:l}){const d=ne(),u=o.useId(),[m,h]=o.useState(()=>mn(t)),[p,g]=o.useState(()=>({...mn(t),...s})),[f,j]=o.useState(!1),[_,b]=o.useState(!1),[A,y]=o.useState(),[I,M]=o.useState(),[P,N]=o.useState(),[E,z]=o.useState(),[K,x]=o.useState(),[R,L]=o.useState(),w={heading:o.useRef(null),photo:o.useRef(null),remove:o.useRef(null),remove_cancel:o.useRef(null),cancel:o.useRef(null),keep_editing:o.useRef(null),display_name:o.useRef(null),title:o.useRef(null),description:o.useRef(null)},V=o.useMemo(()=>_f(d),[d]),[$,q]=o.useState(!1),[G,v]=o.useState(!1),[B,C]=o.useState(),D=Gl(B),J=o.useRef(null),ee=o.useRef(void 0),Z=o.useRef(!0),ce=o.useRef(0),ie=Object.keys(ss(m,p)).length>0;o.useEffect(()=>{a?.(ss(m,p))},[m,p,a]);const de=P==="photo_invalid"?n("ui.settings.personal_profile.photo_invalid"):P?n("ui.settings.personal_profile.photo_error"):void 0,Se=t.profile.avatar,H=Se?.source==="uploaded"?"uploaded":"provider",U=f||_;o.useEffect(()=>(Z.current=!0,()=>{Z.current=!1,ce.current++,ee.current?.close()}),[]),o.useEffect(()=>{R&&(w[R].current?.focus(),L(void 0))});const k=()=>{ce.current++,ee.current?.close(),ee.current=void 0,C(void 0),N(void 0)},Y=()=>{k(),L("photo")},ae=()=>{q(!1),L("cancel")},ue=()=>{v(!1),L("remove")},ke=(Q,ge=!1)=>he=>{he.key!=="Escape"||ge||(he.preventDefault(),he.stopPropagation(),Q())},me=async Q=>{if(!Q||U)return;const ge=++ce.current;N(void 0),b(!0),x(void 0);try{const he=await hf(Q);if(!Z.current||ge!==ce.current){he.close();return}ee.current?.close(),ee.current=he,C(he),v(!1)}catch{Z.current&&ge===ce.current&&N("photo_invalid")}finally{Z.current&&ge===ce.current&&b(!1)}},pe=async()=>{if(!Z.current||U||!ie)return;const Q=ss(m,p),ge=Object.keys(vn).map(he=>he in Q&&[...p[he]].length>vn[he]?{field:he,reason:"length"}:he==="description"&&p.description.split(`
|
|
298
|
-
`).length>ei?{field:he,reason:"lines"}:void 0).find(Boolean);if(ge){M(ge),L(ge.field);return}j(!0),y(void 0),M(void 0),z(void 0);try{const he=await i(Q);if(!Z.current)return;h(mn(he)),g(mn(he)),z("saved"),L("heading")}catch{Z.current&&y("save_error")}finally{Z.current&&j(!1)}},je=async Q=>{if(!Z.current||U)return;b(!0),N(void 0),x(void 0);const ge=ce.current,he=D.capture();try{if(Q.size>1024*1024)throw new Error("Profile crop too large");if(!await Ql(D,he,()=>Q.arrayBuffer(),Ge=>{if(!(!Z.current||ge!==ce.current))return c(new Uint8Array(Ge))})||!Z.current)return;k(),x("photo_saved"),L("photo")}catch{Z.current&&N("photo_error")}finally{Z.current&&b(!1)}},Ke=async()=>{if(!(!Z.current||U)){b(!0),N(void 0),x(void 0);try{await l(H),Z.current&&(v(!1),x("photo_removed"),L("photo"))}catch{Z.current&&N("photo_error")}finally{Z.current&&b(!1)}}},se=(Q,ge)=>{f||(g(he=>({...he,[Q]:ge})),z(void 0),y(void 0),I?.field===Q&&M(void 0),q(!1))},re=Q=>I?.field!==Q?void 0:I.reason==="lines"?n("ui.settings.personal_profile.description_lines",{count:String(ei)}):n("ui.settings.personal_profile.field_too_long",{count:String(vn[Q])}),ve=(Q,ge,he)=>{const Pe=re(Q);return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(We,{htmlFor:`${u}-${Q}`,children:ge}),he({id:`${u}-${Q}`,value:p[Q],maxLength:yf(Q),readOnly:f,"aria-invalid":Pe?!0:void 0,"aria-describedby":Pe?`${u}-${Q}-error`:void 0}),Pe&&e.jsx("p",{id:`${u}-${Q}-error`,className:"text-meta text-danger",children:Pe})]})};return e.jsxs("section",{"aria-labelledby":`${u}-heading`,className:"flex min-w-0 flex-col gap-4","data-account-profile-editor":"",children:[e.jsx("h3",{ref:w.heading,id:`${u}-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(O,{ref:w.photo,variant:"secondary",size:"sm",disabled:U,onClick:()=>J.current?.click(),children:Se?.hash?n("ui.settings.personal_profile.replace"):n("ui.settings.personal_profile.choose")}),Se?.hash&&e.jsx(O,{ref:w.remove,variant:"ghost",size:"sm",disabled:U,onClick:()=>{v(!0),k(),L("remove_cancel")},children:n("ui.settings.personal_profile.remove")}),e.jsx("input",{ref:J,type:"file",accept:"image/png,image/jpeg,image/webp",className:"sr-only",tabIndex:-1,"aria-hidden":"true",disabled:U,onChange:Q=>{const ge=Q.currentTarget.files?.[0];Q.currentTarget.value="",me(ge)}})]}),e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.personal_profile.photo_help")}),e.jsx("output",{className:"text-meta text-ink-muted empty:hidden",children:K==="photo_saved"?n("ui.settings.personal_profile.photo_saved"):K==="photo_removed"?n("ui.settings.personal_profile.photo_removed"):null}),B&&e.jsx("div",{onKeyDown:ke(Y,_),children:e.jsx(Yl,{source:B,outputEdge:256,onSave:Q=>void je(Q),onCancel:Y,saving:_,error:de,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:(Q,ge)=>n("ui.settings.personal_profile.crop_instructions",{width:String(Q),height:String(ge)}),zoom:n("ui.settings.personal_profile.zoom"),zoomIn:n("ui.settings.personal_profile.zoom_in"),zoomOut:n("ui.settings.personal_profile.zoom_out"),zoomValue:Q=>n("ui.settings.personal_profile.zoom_value",{value:Q}),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")}})}),G&&e.jsxs("fieldset",{className:"flex flex-col gap-2","aria-label":n("ui.settings.personal_profile.remove"),onKeyDown:ke(ue,_),children:[e.jsx("p",{className:"text-body-sm text-ink",children:H==="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(O,{variant:"danger",size:"sm",disabled:U,onClick:()=>void Ke(),children:_?n("ui.settings.personal_profile.saving"):n("ui.settings.personal_profile.remove")}),e.jsx(O,{ref:w.remove_cancel,variant:"secondary",size:"sm",disabled:U,onClick:ue,children:n("ui.common.actions.cancel")})]})]}),P&&!B&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:de}),e.jsxs("form",{className:"flex min-w-0 flex-col gap-4",onSubmit:Q=>{Q.preventDefault(),pe()},"aria-busy":f,children:[ve("display_name",n("ui.settings.personal_profile.display_name"),Q=>e.jsx($e,{ref:w.display_name,...Q,onChange:ge=>se("display_name",ge.target.value),autoComplete:"nickname"})),ve("title",n("ui.settings.personal_profile.title"),Q=>e.jsx($e,{ref:w.title,...Q,onChange:ge=>se("title",ge.target.value),autoComplete:"organization-title"})),ve("description",n("ui.settings.personal_profile.description"),Q=>e.jsx(Fs,{ref:w.description,...Q,onChange:ge=>se("description",ge.target.value),rows:3})),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(We,{asChild:!0,children:e.jsx("span",{"aria-hidden":"true",children:n("ui.settings.personal_profile.timezone")})}),e.jsx(Ii,{showLabel:!1,ariaLabel:n("ui.settings.personal_profile.timezone"),placeholder:n("ui.settings.personal_profile.timezone_placeholder"),busyLabel:n("ui.settings.personal_profile.loading"),options:V,selected:p.timezone?V.find(Q=>Q.id===p.timezone)??{id:p.timezone,name:p.timezone.split("_").join(" ")}:null,onSelect:Q=>se("timezone",Q.id),onClear:()=>se("timezone","")})]}),A&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.personal_profile.save_error")}),$?e.jsxs("div",{className:"flex flex-col gap-2",onKeyDown:ke(ae),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(O,{type:"button",variant:"secondary",size:"sm",onClick:()=>{g(m),q(!1),y(void 0),M(void 0),L("heading")},children:n("ui.settings.personal_profile.discard_action")}),e.jsx(O,{ref:w.keep_editing,type:"button",variant:"primary",size:"sm",onClick:ae,children:n("ui.settings.personal_profile.keep_editing")})]})]}):e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(O,{type:"submit",variant:"primary",size:"sm",disabled:!ie||U,children:f?n("ui.settings.personal_profile.saving"):n("ui.settings.personal_profile.save")}),e.jsx(O,{ref:w.cancel,type:"button",variant:"secondary",size:"sm",disabled:!ie||f,onClick:()=>{q(!0),L("keep_editing")},children:n("ui.common.actions.cancel")})]})]}),e.jsx("output",{className:"text-meta text-ink-muted empty:hidden",children:E==="saved"?n("ui.settings.personal_profile.saved"):null}),e.jsxs(O,{variant:"link",size:"sm",className:"w-fit",onClick:()=>An("https://console.radienthq.com/dashboard/account"),children:[n("ui.settings.personal_profile.manage"),e.jsx(ji,{"aria-hidden":"true"})]})]})}function vf(){return ne(),e.jsx("output",{className:"text-body-sm text-ink-muted",children:n("ui.settings.personal_profile.loading")})}function kf({onRetry:t}){return ne(),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(O,{variant:"secondary",size:"sm",onClick:t,children:n("ui.common.actions.retry")})]})}const jf=/^[a-f0-9]{16}$/;function wf(){ne();const t=gt(),s=Qe(t.data,"account_profile"),a=ki(),r=o.useCallback(()=>{try{return JSON.stringify(a.accountId?ol(window.localStorage,a.accountId)??"personal":"unresolved")}catch{return"unresolved"}},[a.accountId]),i=o.useCallback(j=>{const _=b=>{(b.key===ll||b.key===null)&&j()};return window.addEventListener("storage",_),()=>window.removeEventListener("storage",_)},[]),c=o.useSyncExternalStore(i,r,r),l=mf(s,r),d=o.useRef(null),u=l.data,m=Nt(),h=`${l.authority.token}:${c}:${u?.scope??""}`,p=u?wr(m,h):void 0,g=u?.profile.avatar?.hash,f=cl(u&&g&&jf.test(g)?{accountId:u.profile.account_id,hash:g}:null,64);return o.useEffect(()=>{!u||!Hl(l.authority.token)||(d.current?.scrollIntoView({block:"start"}),d.current?.focus({preventScroll:!0}))},[u,l.authority.token]),s?!l.authority.accountId||l.isPending?e.jsx(vf,{}):u?e.jsx("div",{ref:d,tabIndex:-1,"aria-label":n("ui.settings.personal_profile.heading"),className:"focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",children:e.jsx(bf,{snapshot:u,initialDraft:p?.fields,onDraftChange:j=>cf(m,h,j),photoUrl:f,onSave:l.update,onUpload:l.upload,onRemove:l.remove},h)}):e.jsx(kf,{onRetry:()=>void l.refetch()}):e.jsx(O,{variant:"secondary",size:"sm",onClick:()=>An("https://console.radienthq.com/dashboard/account"),children:n("ui.settings.personal_profile.manage")})}const Nf=({verification:t})=>{ne();const{prices:s}=mc(),a=t.grant_amount??s?.default_new_credits,{sentence:r,action:i}=pc(t.signup_grant,gc(a)),c=hc(t.claim_url,fc);return e.jsxs("div",{className:"mt-8 flex items-start gap-3 rounded-sm border border-hairline bg-surface p-3",children:[e.jsx(Nn,{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(O,{variant:"secondary",size:"sm",onClick:()=>An(c),children:i})]})]})},Sf=({onAfterCredentialUpdate:t})=>{ne();const{isAuthenticated:s,user:a,isLoading:r,accountRead:i,signOut:c}=uc(),l=wi(p=>p.isSigningOut),d=o.useCallback(async()=>{try{await c()}catch(p){console.error("Error signing out:",p)}},[c]),u=(()=>{if(!s||!a?.radientUser)return null;const{account:p,identity:g,verification:f}=a.radientUser,j=f!=null&&!f.email_verified&&f.signup_grant!=="claimed";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-8",children:e.jsx(wf,{})}),e.jsxs(Zt,{children:[e.jsx(Oe,{label:n("ui.settings.account.radient_account_section.status"),value:e.jsxs("span",{className:"inline-flex items-center gap-2",children:[n("ui.settings.account.radient_account_section.connected"),e.jsx(wt,{variant:"success",className:"capitalize",children:p.status})]})}),e.jsx(Oe,{label:n("ui.settings.account.radient_account_section.name"),value:p.name||n("ui.settings.account.radient_account_section.not_provided")}),e.jsx(Oe,{label:n("ui.settings.account.radient_account_section.email"),value:p.email}),e.jsx(Oe,{label:n("ui.settings.account.radient_account_section.account_id"),value:e.jsx("span",{className:"text-mono-sm",children:p.id})}),e.jsx(Oe,{label:n("ui.settings.account.radient_account_section.tenant_id"),value:e.jsx("span",{className:"text-mono-sm",children:p.tenant_id})}),e.jsx(Oe,{label:n("ui.settings.account.radient_account_section.provider"),value:e.jsx("span",{className:"capitalize",children:g.provider})}),e.jsx(Oe,{label:n("ui.settings.account.radient_account_section.created"),value:Ni(p.created_at)})]}),j&&f?e.jsx(Nf,{verification:f}):null,e.jsx("div",{className:"mt-8",children:e.jsx(dl,{offerSignIn:!0,diagnostics:!0,searchRow:"radient.phone-access"})}),e.jsx(of,{className:"mt-6"}),e.jsxs("p",{className:"mt-8 text-body-sm text-ink-muted","data-testid":"radient-team-plan-line",children:[n("ui.settings.account.radient_account_section.team_plan_line")," ",e.jsx(O,{variant:"link",size:"sm",onClick:()=>An(Vl(p.tenant_id)),children:n("ui.teamBridge.plan.see_plan")})]}),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(O,{variant:"danger",className:"mt-3",onClick:d,children:[e.jsx(ul,{}),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"):Si(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"),h=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(Wl,{titleText:"",onAfterCredentialUpdate:t,descriptionText:"",onSignInSuccess:()=>{}})})]});return r||l?e.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center gap-3",children:[e.jsx(Ee,{size:"lg",label:n("ui.settings.account.radient_account_section.loading_account")}),!l&&e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.account.radient_account_section.loading_your_radient_account_details")})]}):s&&a?.radientUser?u:e.jsx("div",{className:"flex flex-col gap-4",children:h})},is={label:1,synonym:.8,key:.75,choice:.7,section:.6,description:.4},Cf={exact:1,prefix:.92,substring:.7,subsequence:.45};function Sr(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 ti(t){let s=!1;const a=t.split(" ").map(r=>{const i=Sr(r);return i!==r&&(s=!0),i}).join(" ");return s?a:t}const ni=new WeakMap,si={exact:3,prefix:2,substring:1};function Mf(t,s,a){const r=Sr(a),i=[sn(t,a)];r!==a&&i.push(sn(t,r)),s!==t&&(i.push(sn(s,a)),r!==a&&i.push(sn(s,r)));let c=null;for(const l of i)!l||l==="subsequence"||(!c||si[l]>si[c])&&(c=l);return c}const Af=12,Ef=2;function Rf(t,s){let a=0,r=-1,i=null,c=ni.get(t.fields);if(!c){c={};for(const l of Object.keys(is)){const d=t.fields[l];d&&(c[l]=ti(d))}ni.set(t.fields,c)}for(const l of s){let d=-1,u=null;for(const m of Object.keys(is)){const h=t.fields[m];if(!h)continue;const p=Mf(h,c[m]??ti(h),l);if(!p)continue;const g=is[m]*Cf[p];g>d&&(d=g,u=m)}if(u===null)return null;a+=d,d>r&&(r=d,i=u)}return i?{score:a,reason:i}:null}function If(t,s,a=Af){const r=ml(s);if(r.length===0)return{results:[],total:0};const i=Wt(s),c=[];for(const l of t){const d=Rf(l,r);if(!d)continue;const u=l.fields.label!==""&&l.fields.label===i;c.push({entry:l,reason:d.reason,score:u?d.score+Ef:d.score})}return c.sort((l,d)=>d.score-l.score||l.entry.fields.label.length-d.entry.fields.label.length||l.entry.order-d.entry.order),{results:c.slice(0,Math.max(0,a)).map(({entry:l,reason:d})=>({entry:l,reason:d})),total:c.length}}function Tf(t){return Wt(t)===""}function Lf(t){const s=new Map;for(const i of t){const c=i.entry.sectionId||"",l=s.get(c);if(l){l.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 Of={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 Df(t){const{registry:s,sections:a,build:r=sp}=t,i=ne();return o.useMemo(()=>r({registry:s,sections:a}),[r,s,a,i])}function $f(){return yc()==="mac"?"⌘F":"Ctrl+F"}const Pf=o.forwardRef(function({index:s,readRendered:a,onJump:r,onDismiss:i,className:c},l){ne();const d=o.useRef(null),u=o.useRef(null),[m,h]=o.useState(null),[p,g]=o.useState(""),[f,j]=o.useState(!1),[_,b]=o.useState(-1),[A,y]=o.useState(""),I=o.useId();o.useImperativeHandle(l,()=>({focus:()=>{d.current?.focus(),j(!0)}}));const M=o.useCallback(()=>a?.()??[],[a]),P=o.useCallback(()=>{h(M())},[M]),N=o.useCallback(()=>{h(C=>C??M())},[M]),E=o.useCallback(()=>{const C=m;return C&&C.length>0?[...s,...C]:s},[s,m]),z=Tf(p),{results:K,total:x}=o.useMemo(()=>If(E(),p),[E,p]),R=o.useMemo(()=>Lf(K),[K]),L=_<0||K.length===0?-1:Math.min(_,K.length-1),w=L>=0?K[L]:void 0,V=o.useMemo(()=>new Map(K.map((C,D)=>[C.entry.id,D])),[K]),$=o.useCallback(C=>{C!==void 0&&g(C),j(!1),b(-1),i?.()},[i]),q=o.useCallback(async C=>{if(await r(C)==="missing"){y(n("ui.settings.search.jump.missing"));return}y(""),j(!1),b(-1)},[r]),G=C=>`${I}-option-${C}`,v=C=>{switch(C.key){case"ArrowDown":C.preventDefault(),j(!0),b(D=>K.length===0?-1:D<0?0:(D+1)%K.length);return;case"ArrowUp":C.preventDefault(),j(!0),b(D=>K.length===0?-1:D<0?K.length-1:(D-1+K.length)%K.length);return;case"Home":if(!f)return;C.preventDefault(),b(0);return;case"End":if(!f)return;C.preventDefault(),b(Math.max(0,K.length-1));return;case"Enter":if(C.preventDefault(),!f){j(!0);return}{const D=w??K[0];D&&q(D.entry)}return;case"Escape":if(C.preventDefault(),p!==""){g(""),y(""),b(-1);return}$();return;default:return}},B=z?"":n("ui.settings.search.results.count",{count:x});return e.jsxs("div",{ref:u,className:xe("relative @container w-full",c),onBlur:C=>{const D=C.relatedTarget;D&&u.current?.contains(D)||(j(!1),b(-1),i?.())},children:[e.jsxs("div",{className:"relative",children:[e.jsx(As,{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($e,{ref:d,role:"combobox","aria-expanded":f,"aria-controls":f?I:void 0,"aria-activedescendant":f&&w?G(L):void 0,"aria-autocomplete":"list","aria-label":n("ui.settings.search.field.label"),placeholder:n("ui.settings.search.field.placeholder"),value:p,type:"text",className:"pl-8",onFocus:()=>{P(),j(!0)},onChange:C=>{N(),g(C.currentTarget.value),b(-1),y(""),j(!0)},onKeyDown:v})]}),f&&e.jsxs("div",{id:I,role:"listbox",tabIndex:-1,"aria-label":n("ui.settings.search.panel.label"),"data-glass-overlay":"","data-lo-floating":"",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 bg-elevated p-1 shadow-overlay",children:[A&&e.jsx("p",{"data-search-notice":"","aria-hidden":"true",className:"px-2 pt-2 pb-1 text-body-sm text-ink",children:A}),z?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(xc,{text:n("ui.settings.search.empty.shortcut",{shortcut:_c($f())})})})]}):K.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:p})}),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:C=>C.preventDefault(),onClick:()=>{$(""),d.current?.focus()},children:n("ui.settings.search.no_results.clear")})]}):e.jsxs(e.Fragment,{children:[R.map(C=>e.jsxs("div",{role:C.sectionLabel?"group":void 0,"aria-label":C.sectionLabel||void 0,children:[C.sectionLabel&&e.jsx("p",{className:"px-2 pt-2 pb-1 font-medium text-ink-muted text-meta",children:C.sectionLabel}),C.results.map(D=>{const J=V.get(D.entry.id)??0,ee=J===L;return e.jsxs("div",{id:G(J),role:"option","aria-selected":ee,"data-search-result-id":D.entry.id,className:xe("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",ee?"bg-accent-wash outline-solid outline-1 -outline-offset-1 outline-control":"hover:bg-row-hover"),onMouseDown:Z=>Z.preventDefault(),onMouseEnter:()=>b(J),onClick:()=>q(D.entry),children:[e.jsx("span",{className:"min-w-0 text-body-sm text-ink",children:D.entry.label}),e.jsxs("span",{className:"@[40rem]:shrink-0 @[40rem]:text-right text-meta text-ink-dim",children:[D.entry.sectionLabel&&n("ui.settings.search.row.section_hint",{section:D.entry.sectionLabel}),D.entry.sectionLabel&&" · ",n(Of[D.reason]),D.entry.detail&&D.entry.detail!==D.entry.sectionLabel&&e.jsxs(e.Fragment,{children:[" · ",D.entry.detail]})]})]},D.entry.id)})]},C.sectionId||"no-section")),x>K.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-K.length})})]})]}),e.jsx("output",{"aria-live":"polite",className:"sr-only",children:A||B})]})});function Ff({metric:t,data:s}){return ne(),e.jsx(bc,{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)}`:vc(a),children:e.jsx(fm,{data:s,children:e.jsx(hi,{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 zf={all:["desktop","tts-path-resolution"]};function Uf(t){return ze({queryKey:zf.all,queryFn:()=>Ne({op:"tts.paths"}),enabled:t,staleTime:Number.POSITIVE_INFINITY,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:ro})}const Kf=["speech.voice.gender","speech.voice.tone","speech.voice.expressiveness","speech.voice.pace","speech.voice.language","speech.voice.accent","speech.voice.instructions"];function ai(t){const s=new Map(t.map(i=>[i.key,i])),a=[],r=[];for(const i of Kf){const c=s.get(i);c?a.push(c):r.push(i)}return{rows:a,missing:r}}const Bf=["provider_tts_radient","provider_tts_elevenlabs","provider_tts_openai","none"];function ii(t){return typeof t=="string"&&Bf.includes(t)}function qf(t){if(t===null||typeof t!="object")return null;const s=t;if(!ii(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(!ii(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 Hf={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 Cr(t){return Hf[t]}function Vf(t){return{servable:t.servable,serving:t.path==="none"?null:t.path,reason:t.reason,rungs:t.rungs.map(s=>({path:s.path,name:Cr(s.path),available:s.available,reason:s.reason}))}}const Wf="ui.settings.speech.speech_section.copy_backend_older_sentence",Mr="ui.settings.speech.speech_section.copy_unavailable_sentence",Gf=({resetErrorBoundary:t})=>(ne(),e.jsx(_e,{variant:"warning",children:e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx("span",{children:n(Mr)}),e.jsxs(O,{variant:"secondary",onClick:t,children:[e.jsx(Sn,{"aria-hidden":"true"}),n("ui.settings.speech.speech_section.try_again")]})]})}));function Yf(t){return t==="enabled"?"ready":t==="below-version"?"older":"pairing"}const Qf=({sectionRef:t})=>{ne();const s=gt(),a=Ts(),r=ui(s.data,"tts"),i=Yf(r),c=ze({queryKey:mt.all,queryFn:()=>Ne({op:"settings.list"}),enabled:i==="ready",staleTime:1e4}),l=Uf(i==="ready"),{hasRadientApiKey:d,hasRadientSession:u,speechBlock:m}=kc(),h=`${u}:${d}`,p=o.useRef(h),g=l.refetch;o.useEffect(()=>{p.current!==h&&(p.current=h,g())},[h,g]);const f=c.data,j=o.useMemo(()=>ai(f?.settings??[]),[f]),[_,b]=o.useState({}),[A,y]=o.useState({}),[I,M]=o.useState({});o.useEffect(()=>{f&&b(v=>{let B=!1;const C={...v};for(const D of ai(f.settings).rows){const J=v[D.key];if(J&&J.value!==Et(D).value)continue;const ee=Et(D);J&&J.value===ee.value&&J.cascadeBase===ee.cascadeBase||(C[D.key]=ee,B=!0)}return B?C:v})},[f]);const P=(v,B)=>y(C=>({...C,[v]:B})),N=(v,B)=>M(C=>({...C,[v]:B})),E=async v=>{const B=_[v.key];if(!B)return;const C=Nc(v,B);if(!C.ok){N(v.key,C.error);return}P(v.key,!0),N(v.key,null);try{await Ne(C.request),P(v.key,!1);const J=(await c.refetch()).data?.settings.find(ee=>ee.key===v.key);J&&b(ee=>{const Z=ee[v.key];return Z&&Z.value===B.value&&Z.cascadeBase===B.cascadeBase?{...ee,[v.key]:Et(J)}:ee})}catch(D){P(v.key,!1),N(v.key,D instanceof Error?D.message:n("ui.settings.speech.speech_section.the_setting_could_not_be_saved"))}},z=async v=>{P(v.key,!0),N(v.key,null);try{await Ne({op:"settings.reset",key:v.key}),b(B=>({...B,[v.key]:Et({...v,value:v.default,is_default:!0})})),P(v.key,!1),await c.refetch()}catch(B){P(v.key,!1),N(v.key,B instanceof Error?B.message:n("ui.settings.speech.speech_section.the_setting_could_not_be_reset"))}},K=o.useMemo(()=>qf(l.data),[l.data]),x=K?Vf(K):null,R=l.isSuccess&&K===null,L=(s.data?null:s.error)??null,w=c.error,V=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:v}=Vt(a??null,n("ui.settings.speech.speech_section.speech_settings_could_not_be_loaded"),L);return e.jsx(Re,{title:V,icon:an,description:$,sectionRef:t,children:e.jsx(_e,{variant:"warning",children:v})})}if(i==="older")return e.jsx(Re,{title:V,icon:an,description:$,sectionRef:t,children:e.jsx(_e,{variant:"warning",children:n(Wf)})});if(w||!f){const{sentence:v,remedy:B}=Vt(a??null,n("ui.settings.speech.speech_section.speech_settings_could_not_be_loaded"),w);return e.jsx(Re,{title:V,icon:an,description:$,sectionRef:t,children:e.jsx(_e,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:v}),B&&e.jsx(O,{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",G=x?x.rungs.find(v=>v.path===x.serving)??null:null;return e.jsx(Re,{title:V,icon:an,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:[l.isPending&&e.jsxs("p",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(Ee,{}),ca("checking")]}),(l.isError||R)&&!x&&m!=="offline"&&e.jsx(_e,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{children:[n(Mr)," ",l.error instanceof Error?l.error.message:""]}),e.jsx(O,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{l.refetch()},children:n("ui.settings.speech.speech_section.retry")})]})}),e.jsx(Pi,{fallbackRender:Gf,resetKeys:[l.dataUpdatedAt],children:x&&e.jsxs(e.Fragment,{children:[e.jsxs(Zt,{children:[e.jsx(Oe,{label:n("ui.settings.speech.speech_section.speaks_through"),value:x.serving?Cr(x.serving):n("ui.settings.speech.speech_section.nothing_yet")}),e.jsx(Oe,{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!==G?.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(v=>e.jsxs("li",{className:"flex flex-col gap-0.5 text-body-sm",children:[e.jsxs("span",{className:v.path===x.serving?"text-ink":"text-ink-muted",children:[v.name,e.jsxs("span",{className:v.path===x.serving?"text-ink-muted":"text-ink-dim",children:[" ",v.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:v.reason})]},v.path))})]})})]}),q&&e.jsx(_e,{variant:"warning",children:ca(m)}),e.jsx("div",{className:"flex flex-col gap-1",children:j.rows.map(v=>e.jsx(jc,{setting:v,draft:_[v.key]??Et(v),tier:wc(v),saving:!!A[v.key],error:I[v.key]??null,onDraftChange:B=>b(C=>({...C,[v.key]:B})),onSave:()=>{E(v)},onReset:()=>{z(v)}},v.key))}),j.missing.length>0&&e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.speech.speech_section.missing_voice_rows",{count:j.missing.length,rows:j.missing.join(", ")})})]})})},Zf=Sc().use(Cc).use(Mc),Je="data-prompt-node",rs="data-prompt-opaque",Jf=/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/,Xf=/^&(?:#[xX][\da-fA-F]+|#\d+|[a-zA-Z][a-zA-Z\d]+);/,ex=/^[ \t]*(`{3,}|~{3,})/,tx=/^<([\w-]+)/,nx=/^([ \t]*(?:[-+*]|\d+[.)])[ \t]+\[)([ xX])(\])/,sx=/^[ \t]*(?:>[ \t]*)*(?:(?:[-+*]|\d+[.)])[ \t]+)?/,ax=/(?:[-+*]|\d+[.)])[ \t]+$/,ix=/(\r\n|\r|\n)/,rx=/^[ \t>]*/,ox=/\r$/,ri=new Set(["text","inlineCode","emphasis","strong","delete","link","linkReference","break","image","imageReference","footnoteReference"]),qe=t=>t.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""");let cx=0;const lx=t=>{try{const s=new URL(t);return["https:","http:","mailto:"].includes(s.protocol)?t:null}catch{return null}};class dx{constructor(s,a="",r){this.editSourceLabel=s,this.emptyTaskLabel=a,this.labelIds=r}prefix=`prompt${++cx}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,l=s.position?.end.offset??c,d=a.lastIndexOf(`
|
|
299
|
-
`,c-1)+1,m=(a.slice(d,c).match(sx)?.[0]??"").replace(ax,p=>" ".repeat(p.length)),h={id:i,baseId:i,type:s.type,start:c,end:l,raw:a.slice(c,l),children:[],opaque:!1,block:r,continuationPrefix:m};return this.spans.set(i,h),h}opaqueHtml(s){const a=s.block?"div":"span";return[`<${a} ${Je}="${s.id}" ${rs}="true" contenteditable="false" role="button" tabindex="0" ${this.labelIds?`aria-labelledby="${qe(this.labelIds.source)}"`:`aria-label="${qe(this.editSourceLabel)}"`}`,' class="cursor-pointer whitespace-pre-wrap break-words rounded-sm bg-sunken px-1 font-mono text-mono-sm text-ink-muted">',`${qe(s.raw)}</${a}>`].join("")}renderNode(s,a,r="root",i=!1,c,l=0){const d=s,u=r==="root"||!ri.has(d.type)&&d.type!=="html",m=this.allocate(s,a,u);d.type==="text"&&(m.text=d.value??"");const h=`${Je}="${m.id}"`,p=()=>(d.children??[]).map((f,j)=>{const _=this.next,b=this.renderNode(f,a,d.type,i,c,j);return m.children.push(`${this.prefix}${_}`),b}).join("");let g;switch(d.type){case"text":g=`<span ${h}>${qe(d.value??"")}</span>`;break;case"paragraph":g=`<p ${h}>${p()}</p>`;break;case"heading":{const f=`h${Math.max(1,Math.min(6,d.depth??1))}`;g=`<${f} ${h}>${p()}</${f}>`;break}case"strong":g=`<strong ${h}>${p()}</strong>`;break;case"emphasis":g=`<em ${h}>${p()}</em>`;break;case"delete":g=`<del ${h}>${p()}</del>`;break;case"inlineCode":g=`<code ${h}>${qe(d.value??"")}</code>`;break;case"code":g=`<pre ${h}><code${d.lang?` class="language-${qe(d.lang)}"`:""}>${qe(d.value??"")}
|
|
300
|
-
</code></pre>`;break;case"blockquote":g=`<blockquote ${h}>${p()}</blockquote>`;break;case"list":{const f=d.ordered?"ol":"ul";g=`<${f} ${h}${d.ordered&&d.start!==void 0?` start="${d.start}"`:""}>${p()}</${f}>`;break}case"listItem":{const f=A=>A.value??(A.children??[]).map(f).join(""),j=(d.children??[]).map(f).join(" ").trim(),_=j||this.emptyTaskLabel,b=!j&&this.labelIds?`aria-labelledby="${qe(this.labelIds.emptyTask)}"`:`aria-label="${qe(_)}"`;g=`<li ${h}${d.checked!==null&&d.checked!==void 0?' class="task-list-item"':""}>${d.checked!==null&&d.checked!==void 0?`<input type="checkbox"${d.checked?" checked":""} ${b}/> `:""}${p()}</li>`;break}case"break":g=`<br ${h}/>`;break;case"thematicBreak":g=`<hr ${h}/>`;break;case"link":{const f=lx(d.url??"");f?g=`<span ${h} data-prompt-link="true" class="text-accent underline" title="${qe(d.title??f)}">${p()}</span>`:(m.opaque=!0,g=this.opaqueHtml(m));break}case"linkReference":g=`<span ${h} class="text-accent underline">${p()}</span>`;break;case"table":{const j=(d.children??[]).map((_,b)=>{const A=this.next,y=this.renderNode(_,a,d.type,b===0,d.align);return m.children.push(`${this.prefix}${A}`),y});g=`<table ${h}><thead>${j[0]??""}</thead><tbody>${j.slice(1).join("")}</tbody></table>`;break}case"tableRow":g=`<tr ${h}>${p()}</tr>`;break;case"tableCell":{const f=i?"th":"td",j=c?.[l],_=j&&["left","center","right"].includes(j)?` align="${j}"`:"";g=`<${f} ${h}${_}>${p()}</${f}>`;break}default:m.opaque=!0,g=this.opaqueHtml(m)}return g}findSpan(s){return this.spans.get(s.getAttribute(Je)??"")}skeleton(s,a=s){if(s!==a){const i=this.findSpan(s);if(i)return`@${i.baseId}`}const r=[...s.attributes].filter(i=>![Je,rs].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(`[${Je}]`)){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=Zf.parse(s),r=[],i=a.children.map(c=>{const l=this.next,d=this.renderNode(c,s);return r.push(`${this.prefix}${l}`),d}).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(`[${Je}]`)].filter(a=>a.parentElement?.closest(`[${Je}]`)===s)}serializeOwner(s){const a=s.cloneNode(!0),r=new Map;for(const c of[...a.querySelectorAll(`[${Je}]`)]){const l=this.findSpan(c);if(!l||!l.opaque&&(!ri.has(l.type)||c.outerHTML!==l.html))continue;let d;do d=`PROMPTISLAND${this.prefix}${this.next++}END`;while(a.textContent?.includes(d));r.set(d,l.raw),c.replaceWith(window.document.createTextNode(d))}let i=da(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 l=(R,L)=>{const w=[];let V="";for(let $=0;$<R.length;){const q=$;let G=String.fromCodePoint(R.codePointAt($)??0);if($+=G.length,G==="\\"&&Jf.test(R[$]??""))G=R[$++];else if(G==="&"){const v=R.slice(q).match(Xf);if(v){const B=window.document.createElement("textarea");B.innerHTML=v[0],G=B.value,$=q+v[0].length}}w.push({rawStart:L+q,rawEnd:L+$,text:G}),V+=G}return{text:V,pieces:w}},d=s.raw.split(ix),u=r.split(`
|
|
301
|
-
`),m=[];let h=0;for(let R=0;R<u.length;R++){const L=d[R*2]??"",w=d[R*2+1]??"",V=R===0?0:L.match(rx)?.[0].length??0;let $=null,q=0;for(;q<=V;q++){const G=l(L.slice(q),h+q);if(G.text===u[R]){$=G;break}}if(!$)return null;m.push(L.slice(0,q));for(const G of $.pieces)i.push({...G,decodedStart:c.length,decodedEnd:c.length+G.text.length}),c+=G.text;h+=L.length,w&&(i.push({rawStart:h,rawEnd:h+w.length,decodedStart:c.length,decodedEnd:c.length+1,text:`
|
|
302
|
-
`}),c+=`
|
|
303
|
-
`,h+=w.length)}if(c!==r)return null;let p=0,g=0;for(;p<r.length&&p<a.length&&r[p]===a[p];)p++;for(;g<r.length-p&&g<a.length-p&&r[r.length-g-1]===a[a.length-g-1];)g++;const f=r.length-g,j=i.find(R=>R.decodedStart<p&&p<R.decodedEnd),_=i.find(R=>R.decodedStart<f&&f<R.decodedEnd),b=j?.decodedStart??p,A=_?.decodedEnd??f,y=a.slice(b,a.length-g+A-f),I=`${this.prefix}BEGIN`,M=`${this.prefix}END`,P=R=>{const L=da(`<p>${I}${qe(R)}${M}</p>`),w=L.indexOf(I),V=L.lastIndexOf(M);return w>=0&&V>=w?L.slice(w+I.length,V):null},N=y.split(`
|
|
304
|
-
`).map(P);if(N.some(R=>R===null))return null;const E=s.raw.includes(`\r
|
|
305
|
-
`)?`\r
|
|
306
|
-
`:`
|
|
307
|
-
`,z=m.find(R=>R.length>0)??s.continuationPrefix,K=N.join(E+z),x=R=>i.find(L=>L.decodedStart===R)?.rawStart??s.raw.length;return s.raw.slice(0,x(b))+K+s.raw.slice(x(A))}reconcile(s,a){const r=[...a.querySelectorAll("input[type=checkbox]")].some(d=>d.checked!==d.hasAttribute("checked"));if(s.opaque||a.outerHTML===s.html&&!r)return s.raw;if(s.type==="code"&&a.tagName==="PRE"&&a.querySelector("code")){const d=s.raw.indexOf(`
|
|
308
|
-
`),u=s.raw.slice(0,d).replace(ox,""),m=u.match(ex);if(d>=0&&m){const h=m[1],p=u.slice(0,m[0].length-h.length),g=u.slice(m[0].length),f=s.raw[d-1]==="\r"?`\r
|
|
309
|
-
`:`
|
|
310
|
-
`,j=s.raw.lastIndexOf(`
|
|
311
|
-
`)+1,_=s.raw.slice(j),b=_.startsWith(s.continuationPrefix)?_.slice(s.continuationPrefix.length).match(new RegExp(`^([ ]*)(${h[0]}{${h.length},})([ ]*)$`)):null,A=j>=d+1&&b!==null,y=a.querySelector("code")?.textContent??"",I=y.endsWith(`
|
|
312
|
-
`)?y.slice(0,-1):y,P=(I.match(new RegExp(`${h[0]}+`,"g"))??[]).reduce((x,R)=>Math.max(x,R.length+1),h.length),N=h[0].repeat(P),E=s.continuationPrefix+p,z=E+I.split(`
|
|
313
|
-
`).join(f+E),K=A&&b?f+s.continuationPrefix+b[1]+h[0].repeat(Math.max(P,b[2].length))+b[3]:s.raw.endsWith(`
|
|
314
|
-
`)?f:"";return p+N+g+f+z+K}}if(s.type==="text"){if(!a.children.length){const f=this.patchText(s,a.textContent??"");if(f!==null)return f}const d=`${this.prefix}BEGIN`,u=`${this.prefix}END`,m=a.cloneNode(!0);m.prepend(window.document.createTextNode(d)),m.append(window.document.createTextNode(u));const h=this.serializeOwner(m),p=h.indexOf(d),g=h.lastIndexOf(u);return p>=0&&g>=p?h.slice(p+d.length,g):null}if(a.tagName!==s.html?.match(tx)?.[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 d=a.querySelector(":scope > input[type=checkbox]"),u=s.raw.match(nx);if(d&&u){const m=d.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 d=0;d<i.length;d++){const u=this.findSpan(i[d]),m=this.spans.get(s.children[d]);if(!u||!m||u.baseId!==m.baseId)return null;const h=this.reconcile(u,i[d]);if(h===null)return null;h!==m.raw&&c.push({start:m.start-s.start,end:m.end-s.start,value:h})}let l=s.raw;for(const d of c.sort((u,m)=>m.start-u.start))l=l.slice(0,d.start)+d.value+l.slice(d.end);return l}read=s=>{const a=[...s.childNodes].flatMap(m=>{if(m.nodeType===1)return[m];if(m.nodeType!==3||!m.textContent)return[];const h=window.document.createElement("span");return h.textContent=m.textContent,[h]}),r=a.map(m=>this.findSpan(m)).find(Boolean),i=(r&&this.snapshots.get(r.baseId))??this.snapshot,c=i.children;let l="",d=-1;for(const m of a){const h=this.findSpan(m),p=h?c.indexOf(h.baseId):-1,g=p>=0?this.spans.get(c[p]):void 0,f=d>=0?this.spans.get(c[d]):void 0,j=g&&p===d+1?i.source.slice(f?.end??i.start,g.start):l?`
|
|
315
|
-
|
|
316
|
-
`:"",_=h?this.reconcile(h,m)??this.serializeOwner(m):this.serializeOwner(m);l+=j+_,d=p}const u=d>=0?this.spans.get(c[d]):void 0;if(u&&d===c.length-1)l+=i.source.slice(u.end,i.end);else if(!a.length)return i.children.length?"":i.source;return l};getOpaque=s=>{const a=s.closest(`[${rs}]`),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),l=s.querySelector(`[${Je}="${a}"]`);if(!c?.opaque||!l)return null;const d={...c,id:`${this.prefix}${this.next++}`,raw:i};this.spans.set(d.id,d);const u=window.document.createElement("template");u.innerHTML=this.opaqueHtml(d);const m=u.content.firstElementChild;return m?(d.html=m.outerHTML,d.skeleton=this.skeleton(m),l.replaceWith(m),this.read(s)):null}}const ux=({value:t,onChange:s,onLocalDraftActiveChange:a,sourceVersion:r=0,disabled:i=!1})=>{const c=ne(),l=o.useId(),d=`${l}-source-label`,u=`${l}-empty-task-label`,[m,h]=o.useState(!1),[p]=o.useState(()=>new dx(n("ui.settings.model.system_prompt.source_edit"),n("ui.canvas.wysiwyg_markdown_editor.checklist"),{source:d,emptyTask:u})),[g,f]=o.useState(0),[j,_]=o.useState(t),b=o.useMemo(()=>({id:`system-prompt-draft-${l}-${g}`,title:"system-prompt.md",path:"",type:"markdown",content:j}),[l,g,j]),A=o.useCallback(M=>s(M),[s]),y=o.useMemo(()=>({onChange:A,onLocalDraftActiveChange:a,sourceVersion:r,disabled:i,label:n("ui.settings.model.system_prompt.instructions"),codec:p,sourceLabel:n("ui.settings.model.system_prompt.source_edit"),sourceStaleLabel:n("ui.settings.model.system_prompt.source_stale")}),[A,i,p,a,r,c]),I=()=>{_(t),f(M=>M+1),h(!1)};return e.jsxs("div",{className:"flex min-w-0 flex-col gap-2",children:[e.jsx("span",{id:d,className:"sr-only",children:n("ui.settings.model.system_prompt.source_edit")}),e.jsx("span",{id:u,className:"sr-only",children:n("ui.canvas.wysiwyg_markdown_editor.checklist")}),e.jsxs("fieldset",{className:"flex flex-wrap gap-2","aria-label":n("ui.settings.model.system_prompt.instructions"),children:[e.jsx(O,{variant:"ghost",className:m?void 0:"bg-sunken font-semibold text-ink","aria-pressed":!m,disabled:i,onClick:I,children:n("ui.settings.model.system_prompt.rich_text")}),e.jsx(O,{variant:"ghost",className:m?"bg-sunken font-semibold text-ink":void 0,"aria-pressed":m,disabled:i,onClick:()=>h(!0),children:n("ui.settings.model.system_prompt.source")})]}),m?e.jsx(Fs,{id:"app-system-prompt",name:"systemPrompt","aria-label":n("ui.settings.model.system_prompt.instructions"),value:t,disabled:i,onChange:M=>s(M.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(pl,{document:b,draft:y,measure:"fill"},b.id)})]})},mx=()=>{ne();const{data:t,isLoading:s,error:a}=pm(),r=gm(),[i,c]=o.useState(""),[l,d]=o.useState(!1),u=o.useRef(!1),m=o.useRef(""),[h,p]=o.useState(0),[g,f]=o.useState(!1),[j,_]=o.useState(0),b=o.useRef(null),[A,y]=o.useState(null);o.useLayoutEffect(()=>{const z=t?JSON.stringify([t.content,t.last_modified]):null;if(z!==b.current&&(b.current=z,_(x=>x+1)),u.current||g)return;const K=t?.content??"";K!==m.current&&(m.current=K,c(K),p(x=>x+1)),d(!1)},[t,g]);const I=o.useCallback(z=>{c(z),u.current=z!==m.current,d(u.current),y(null)},[]),M=async()=>{if(!(!l||r.isPending)){y(null);try{const z={content:i};await r.mutateAsync(z),m.current=i,u.current=!1,d(!1)}catch(z){y(z instanceof Error?z.message:n("ui.common.errors.system_prompt_update_unknown"))}}},P=()=>{u.current=!1,m.current=t?.content??"",c(m.current),p(z=>z+1),y(null),d(!1)},N=r.isPending,E=()=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(We,{htmlFor:"app-system-prompt",children:n("ui.settings.model.system_prompt.instructions")}),e.jsx(ux,{value:i,onChange:I,onLocalDraftActiveChange:f,sourceVersion:j,disabled:N},h)]}),A&&e.jsx(_e,{variant:"danger",children:A}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(O,{variant:"primary",onClick:M,disabled:!l||N,children:[N?e.jsx(Ee,{size:"sm"}):e.jsx(Ai,{}),N?n("ui.settings.model.system_prompt.saving"):n("ui.settings.model.system_prompt.save_changes")]}),e.jsx(O,{onClick:P,disabled:!l||N,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:Es(t.last_modified)})]})]});return e.jsx(Re,{title:n("ui.settings.model.system_prompt.system_prompt"),icon:Zl,description:n("ui.settings.model.system_prompt.every_local_operator_agent_receives_this_prompt_in_addition_to_it"),children:s?e.jsx("div",{className:"flex min-h-50 items-center justify-center",children:e.jsx(Ee,{size:"lg",label:n("ui.settings.model.system_prompt.loading_system_prompt")})}):a&&!t&&!l?e.jsx(_e,{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")})}):E()})},px=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],gx=t=>px.includes(t),hx=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 l=0;l<i;l+=c)s.push({start:a+l,count:Math.min(c,i-l)});a+=i}return s},fx=({index:t,key:s,groups:a})=>{const r=hx(a),i=r.reduce((c,l)=>c+l.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),l=r[c+(s==="ArrowDown"?1:-1)];if(!l)return t;const d=t-r[c].start;return l.start+Math.min(d,l.count-1)}default:return t}},xx=`const x = {
|
|
317
|
-
ready: true
|
|
318
|
-
};`,_x=({id:t})=>(ne(),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:[Ot.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-${xt(s.ink)})`,outline:`2px solid var(--lo-${xt(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-${xt(s.ink)})`,background:`var(--lo-${xt(s.wash)})`},children:n("ui.settings.appearance.editor.preview.identity")}),e.jsxs("span",{style:{color:`var(--lo-${xt(s.ink)})`},children:[e.jsx("span",{"aria-hidden":"true",children:"● "}),n("ui.settings.appearance.editor.preview.category")]}),e.jsx("span",{style:{color:`var(--lo-${xt(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(_s,{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(O,{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(O,{variant:"primary",size:"sm",tabIndex:-1,children:n("ui.settings.appearance.editor.preview.primary")}),e.jsx(O,{size:"sm",variant:"secondary",tabIndex:-1,children:n("ui.settings.appearance.editor.preview.secondary")}),e.jsx(O,{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:xx})}),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($e,{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(_s,{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")})]})})),yx=()=>({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")}),pn=t=>yx()[t]??t,Tt=/^#[0-9A-Fa-f]{6}$/,bx=({initial:t,onClose:s})=>{ne();const a=o.useId().replace(/[^a-z0-9]/gi,""),r=`custom-draft-${a}`,[i,c]=o.useState(t),[l,d]=o.useState(t);o.useEffect(()=>{const k=setTimeout(()=>d(i),180);return()=>clearTimeout(k)},[i]);const[u,m]=o.useState({}),[h,p]=o.useState(null),[g,f]=o.useState(!0),[j,_]=o.useState(!1),[b,A]=o.useState(!1),[y,I]=o.useState(!1),M=o.useRef(null),P=o.useRef(!1),[N,E]=o.useState(""),[z,K]=o.useState(()=>{try{return localStorage.getItem("lo-theme-editor-advanced")==="true"}catch{return!1}}),[x,R]=o.useState([]),L=Rs(),w=be(k=>k.contrast),V=be(k=>k.accent),$=jt(i.base)?.palette;if(!$)throw new Error("unknown custom theme base");const q=o.useMemo(()=>kn($,i),[$,i]),G=o.useMemo(()=>Dn(q,i.base),[q,i.base]),v=o.useMemo(()=>kn($,l),[$,l]),B=o.useMemo(()=>Dn(v,i.base).findings.length===0,[v,i.base]),C=o.useMemo(()=>B?oo(v,{contrast:w[$.mode],accent:V[$.mode],id:i.base,preserveSecondary:!0,paletteAccent:k=>jt(k)?.palette.accent}):{palette:v},[v,B,w,V,$.mode,i.base]),D=o.useMemo(()=>Dn(C.palette,i.base),[C.palette,i.base]),J=$.mode==="dark"?ta(q.canvas).l>50:ta(q.canvas).l<50,ee=JSON.stringify(i)!==JSON.stringify(t)||Object.keys(u).length>0,Z=Object.values(u).some(k=>!Tt.test(k)),ce=!L.themes.some(k=>k.id===i.id)&&L.themes.length>=50,ie=k=>{R(Y=>[...Y.slice(-19),i]),c(k),_(!1),A(!1)},de=(k,Y)=>{const ae=Object.prototype.hasOwnProperty.call(i.overrides,k)?"overrides":Ot.find(ue=>ue.role===k)?.storage??(nn.includes(k)?"seeds":"overrides");ie({...i,[ae]:{...i[ae],[k]:Y}}),m(ue=>{const ke={...ue};return delete ke[k],ke})},Se=()=>{y||(ee?(M.current=document.activeElement instanceof HTMLElement?document.activeElement:null,I(!0)):s())},H=()=>{const k=Rc($,i);k?(ie(k),E(n("ui.settings.appearance.editor.validation_pass"))):A(!0)},U=(k,Y=pn(k))=>{const ae=D.readings.filter(pe=>pe.foreground===k||pe.background===k).sort((pe,je)=>pe.value/pe.floor-je.value/je.floor)[0],ue=u[k]??i.overrides[k]??i.seeds[k]??q[k],ke=Object.prototype.hasOwnProperty.call(i.overrides,k),me=`${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":h===k,onClick:()=>{p(h===k?null:k),f(!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:me,className:"min-w-0 flex-1 text-body-sm",children:[Y,ke&&e.jsx("span",{className:"ms-1 text-meta text-ink-muted",children:n("ui.settings.appearance.editor.edited")})]}),e.jsx($e,{id:me,inputSize:"sm",value:ue,maxLength:7,"aria-invalid":!Tt.test(ue),className:"w-24 shrink-0 font-mono",onChange:pe=>m(je=>({...je,[k]:pe.target.value})),onBlur:()=>{Tt.test(ue)&&de(k,ue.toUpperCase())},onKeyDown:pe=>{pe.key==="Enter"&&Tt.test(ue)&&(pe.preventDefault(),de(k,ue.toUpperCase()))}}),ae&&e.jsx("span",{className:xe("text-meta",ae.value<ae.floor?"text-danger":"text-ink-muted"),title:`${n("ui.settings.appearance.editor.pair",{foreground:pn(ae.foreground),background:pn(ae.background)})} · ${n("ui.settings.appearance.editor.floor",{value:String(ae.floor)})}`,children:n("ui.settings.appearance.editor.ratio",{value:ae.value.toFixed(2)})}),(ke||Object.prototype.hasOwnProperty.call(i.seeds,k))&&e.jsx(O,{type:"button",size:"sm",variant:"ghost","aria-label":n("ui.settings.appearance.editor.reset_role",{role:Y}),onClick:()=>{const pe={...i.seeds},je={...i.overrides};ke?delete je[k]:delete pe[k],ie({...i,seeds:pe,overrides:je}),m(Ke=>{const se={...Ke};return delete se[k],se})},children:n("ui.settings.appearance.editor.reset_role",{role:Y})})]}),!Tt.test(ue)&&e.jsx("p",{role:"alert",className:"text-meta text-danger",children:n("ui.settings.appearance.editor.invalid_hex")}),h===k&&e.jsx("div",{className:"rounded-md border border-hairline bg-surface p-3",children:e.jsx(nr,{value:q[k],onChange:pe=>de(k,pe),onValidityChange:f,swatches:[...new Set([...nn,...Ot.map(pe=>pe.role)])].map(pe=>q[pe])},k)})]},k)};return e.jsxs(e.Fragment,{children:[e.jsx($l,{open:!0,onOpenChange:k=>{k||Se()},children:e.jsxs(Pl,{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),R(ae=>ae.slice(0,-1)))}},children:[e.jsxs("div",{className:"shrink-0 border-hairline border-b pb-3 pe-8",children:[e.jsx(Fl,{children:n("ui.settings.appearance.editor.edit")}),e.jsx(zl,{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($e,{value:i.name,id:`${a}-name`,maxLength:60,onChange:k=>ie({...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)?Xe[i.base].name:i.base})," ","·"," ",n($.mode==="dark"?"ui.settings.appearance.editor.mode_dark":"ui.settings.appearance.editor.mode_light")]}),J&&e.jsx("p",{className:"text-meta text-warning",children:n("ui.settings.appearance.editor.mode_warning")}),e.jsx("style",{children:Fi(r,C.palette)}),e.jsx(_x,{id:r}),e.jsxs("p",{className:"text-meta text-ink-muted",children:[B&&n("ui.settings.appearance.editor.contrast_note",{value:String(w[$.mode])})," ",B&&V[$.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:Z||!g||G.findings.length?"text-danger":"text-success",children:Z?n("ui.settings.appearance.editor.invalid_hex"):g?G.findings.length?n("ui.settings.appearance.editor.validation_summary",{count:G.findings.length}):n("ui.settings.appearance.editor.validation_pass"):n("ui.settings.appearance.editor.picker.invalid_channels")}),!Z&&g&&G.findings.length>0&&e.jsx(O,{type:"button",variant:"tonal",size:"sm",onClick:H,children:n("ui.settings.appearance.editor.adjust")})]}),b&&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")}),Ot.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)}),U(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")}),nn.filter(k=>!na(k)).map(k=>U(k))]}),e.jsxs("section",{children:[e.jsxs("button",{type:"button","aria-expanded":z,className:"flex w-full items-center justify-between text-start text-body-sm font-medium",onClick:()=>{K(!z);try{localStorage.setItem("lo-theme-editor-advanced",String(!z))}catch{}},children:[n("ui.settings.appearance.editor.advanced"),e.jsx("span",{"aria-hidden":"true",children:z?"−":"+"})]}),e.jsx("p",{className:"mt-2 text-meta text-ink-muted",children:n("ui.settings.appearance.editor.pinned_note")}),z&&e.jsxs(e.Fragment,{children:[Ot.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=>U(Y))]},k.id)),Ac.filter(k=>!nn.includes(k)&&!na(k)).map(k=>U(k)),["overlayShadow","scrim"].map(k=>e.jsxs("label",{className:"flex flex-col gap-1 py-2 text-body-sm",children:[pn(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=>ie({...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:N}),j&&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(O,{variant:"ghost",onClick:Se,children:n("ui.settings.appearance.editor.cancel")}),e.jsx(O,{variant:"primary",disabled:!i.name.trim()||i.name.length>60||Z||!g||G.findings.length>0||ce,onClick:()=>{try{const k={...i,name:i.name.trim(),updatedAt:Date.now()};Ec(k),be.setState({themeName:it(k.base)?k.base:"localOperatorDark",customThemeId:k.id});for(const Y of Object.values(k.seeds))tr(Y);Cs(n("ui.settings.appearance.editor.saved")),s()}catch{_(!0)}},children:n("ui.settings.appearance.editor.save")})]})]})]})}),e.jsx(Dt,{open:y,onOpenChange:I,children:e.jsxs($t,{onCloseAutoFocus:k=>{!P.current&&M.current?.isConnected&&(k.preventDefault(),M.current.focus({preventScroll:!0}))},children:[e.jsx(Pt,{children:n("ui.settings.appearance.editor.discard_title")}),e.jsx(Ft,{children:n("ui.settings.appearance.editor.discard_description")}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(O,{variant:"tonal",onClick:()=>I(!1),children:n("ui.settings.appearance.editor.keep_editing")}),e.jsx(O,{variant:"danger",onClick:()=>{P.current=!0,s()},children:n("ui.settings.appearance.editor.discard")})]})]})})]})},vx=({loading:t,error:s,count:a,onRetry:r})=>(ne(),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(O,{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),oi=()=>`custom-${crypto.randomUUID().replace(/-/g,"").slice(0,20)}`,kx=()=>{const t=Rs(),s=be(N=>N.customThemeId),a=be(N=>N.themeName),[r,i]=o.useState(null),[c,l]=o.useState(null),[d,u]=o.useState(null),[m,h]=o.useState(!1),[p,g]=o.useState(""),[f,j]=o.useState(""),[_,b]=o.useState(""),A=N=>{const E=t.themes.find(x=>x.id===N),z=E?.base??N;if(!it(z))return;const K=la(n("ui.settings.appearance.editor.new_name",{name:E?.name??Xe[z].name}),t.themes);i({format:"local-operator-theme",version:1,id:oi(),name:K,base:z,seeds:{...E?.seeds},overrides:{...E?.overrides},updatedAt:Date.now()})},y=N=>{try{const E=Oc(N,it,{id:oi()});E.name=la(E.name,t.themes),h(!1),b(""),i(E)}catch(E){const z=E instanceof Error?E.message:"import_error",K={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")};b(K[z]??n("ui.settings.appearance.editor.import_error"))}},I=(N,E=!0)=>{const z=t.themes.find(x=>x.id===N),K=z?.name??(it(N)?Xe[N].name:N);return e.jsxs(zs,{children:[e.jsx(Us,{asChild:!0,children:e.jsx(O,{type:"button",variant:"ghost",size:"icon-sm",tabIndex:E?0:-1,"aria-label":n("ui.settings.appearance.editor.more",{name:K}),className:"absolute end-1 top-1 z-10 bg-canvas",children:e.jsx(Is,{size:14})})}),e.jsxs(Ks,{align:"end",children:[z&&e.jsx(at,{onSelect:()=>i(z),children:n("ui.settings.appearance.editor.edit")}),e.jsx(at,{onSelect:()=>A(N),children:n("ui.settings.appearance.editor.duplicate")}),z&&e.jsxs(e.Fragment,{children:[e.jsx(at,{onSelect:()=>{u(z),b(""),j("")},children:n("ui.settings.appearance.editor.export")}),e.jsx(at,{onSelect:()=>{l(z),b("")},children:n("ui.settings.appearance.editor.delete")})]})]})]})},M=e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(O,{variant:"secondary",size:"sm",onClick:()=>{const N=t.themes.find(E=>E.id===s);N?i(N):A(a)},children:n("ui.settings.appearance.editor.customize")}),e.jsx(O,{variant:"ghost",size:"sm",onClick:()=>{h(!0),b(""),g("")},children:n("ui.settings.appearance.editor.import")})]}),e.jsx(vx,{loading:t.loading,error:t.error,count:t.themes.length,onRetry:Ic})]}),P=e.jsxs(e.Fragment,{children:[r&&e.jsx(bx,{initial:r,onClose:()=>i(null)},r.id),e.jsx(Dt,{open:!!c,onOpenChange:N=>{N||l(null)},children:e.jsxs($t,{children:[e.jsx(Pt,{children:n("ui.settings.appearance.editor.delete_title",{name:c?.name??""})}),e.jsx(Ft,{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(O,{variant:"tonal",onClick:()=>l(null),children:n("ui.settings.appearance.editor.cancel")}),e.jsx(O,{variant:"danger",onClick:()=>{if(c)try{Tc(c.id),s===c.id&&be.setState({customThemeId:null}),l(null),Cs(n("ui.settings.appearance.editor.deleted"))}catch{b(n("ui.settings.appearance.editor.save_error"))}},children:n("ui.settings.appearance.editor.delete")})]})]})}),e.jsx(Dt,{open:m,onOpenChange:h,children:e.jsxs($t,{children:[e.jsx(Pt,{children:n("ui.settings.appearance.editor.import_title")}),e.jsx(Ft,{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:p,onChange:N=>g(N.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 N=>{const E=N.target.files?.[0];if(E){if(E.size>Lc){b(n("ui.settings.appearance.editor.import_size"));return}try{y(await E.text())}catch{b(n("ui.settings.appearance.editor.import_read"))}N.target.value=""}}})]}),e.jsx(O,{disabled:!p.trim(),onClick:()=>y(p),children:n("ui.settings.appearance.editor.import_submit")})]})]})}),e.jsx(Dt,{open:!!d,onOpenChange:N=>{N||u(null)},children:e.jsxs($t,{children:[e.jsx(Pt,{children:n("ui.settings.appearance.editor.export_title",{name:d?.name??""})}),e.jsx(Ft,{children:n("ui.settings.appearance.editor.export_title",{name:d?.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:d?$n(d):"",className:"min-h-48 w-full rounded-sm border border-control bg-sunken p-2 font-mono text-meta"}),e.jsx("p",{"aria-live":"polite",className:"text-meta text-success",children:f}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(O,{variant:"tonal",onClick:()=>{if(d)try{const N=URL.createObjectURL(new Blob([$n(d)],{type:"application/json"})),E=document.createElement("a");E.href=N,E.download=`${d.name.replace(/[^a-z0-9_-]/gi,"-").slice(0,60)||"theme"}.json`,E.click(),setTimeout(()=>URL.revokeObjectURL(N),1e3)}catch{b(n("ui.settings.appearance.editor.export_error"))}},children:n("ui.settings.appearance.editor.export_file")}),e.jsx(O,{onClick:async()=>{if(d)try{await navigator.clipboard.writeText($n(d)),j(n("ui.settings.appearance.editor.export_copied"))}catch{b(n("ui.settings.appearance.editor.clipboard_error"))}},children:n("ui.settings.appearance.editor.export_copy")})]})]})})]});return{library:t,active:s,header:M,menu:I,dialogs:P}},jx={localOperatorDark:vu,localOperatorLight:Bu,dracula:Ou,dune:Yd,sage:pu,monokai:hl,tokyoNight:Nu,iceberg:$u,radient:ou,neon:$c,obsidian:zi,synth:cd,catppuccinMocha:Ld,catppuccinLatte:xu,tokyoNightStorm:Sd,gruvbox:fd,nord:um,oneDark:rd,solarizedDark:Uu,rosePine:Xd,rosePineMoon:yu,rosePineDawn:Id,alucard:tu,gruvboxLight:Ud,tokyoNightDay:ju,oneLight:hu,catppuccinFrappe:Fd,catppuccinMacchiato:lu,palenight:Dc,everforest:sm,everforestLight:tm,kanagawaWave:om,kanagawaLotus:Zd,ayuDark:Bd,ayuMirage:Hd,ayuLight:Ru,nightfox:Md,duskfox:Wu,synthwave:Au,matrix:dd,tron:wd,cyberpunk:gl,vaporwave:Xu,outrun:gd,neonNoir:im,arcade:uu,forest:Zu,ocean:Wd,desert:Yu,autumn:lm,lavender:Fu,arctic:Ed,rosewood:iu,solarizedLight:Hu,githubLight:su,paper:Jl,linen:Tu,highContrastLight:ad,mintLight:md},ci="bg-[color-mix(in_srgb,var(--color-accent)_8%,var(--color-accent-wash))]",wx=({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"})]})]})]}),Nx=({id:t,name:s,description:a,isSelected:r,isTabStop:i,onSelect:c,onFocusTile:l})=>{const d=jx[t]??Cu;return e.jsx(et,{side:"bottom",align:"start",content:a,children:e.jsxs("button",{type:"button","data-theme-tile":t,"aria-pressed":r,tabIndex:i?0:-1,onFocus:l,onClick:c,className:xe("relative flex flex-col gap-1.5 rounded-md p-1 text-start transition-colors duration-fast ease-out-quart",r?ci:"hover:bg-surface"),children:[e.jsxs("span",{className:xe("relative block h-10 overflow-hidden rounded-sm border transition-colors duration-fast ease-out-quart",r?"border-accent":"border-hairline"),children:[e.jsx(wx,{id:t}),r&&e.jsx("span",{className:xe("pointer-events-none absolute top-0.5 end-0.5 flex h-4 w-4 items-center justify-center rounded-full",ci),children:e.jsx(En,{size:12,className:"text-accent","aria-hidden":"true"})})]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(d,{size:12,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink",children:s})]})]})})},Sx=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)}}),Cx=()=>{ne();const{themeName:t,setTheme:s}=be(),a=kx(),r=a.library.themes.find(p=>p.id===a.active)?.id??t,i=a.library.themes.flatMap(p=>{const g=jt(p.base)?.palette;if(!g)return[];const f=kn(g,p);return[{id:p.id,name:p.name,description:n("ui.settings.appearance.editor.base",{name:it(p.base)?Xe[p.base].name:p.base}),css:Fi(p.id,f)}]}),c=Object.values(Xe),l=[{label:n("ui.settings.appearance.editor.custom_group"),items:i},{label:n("ui.settings.appearance.theme_selector.dark"),items:c.filter(p=>p.theme.palette.mode==="dark")},{label:n("ui.settings.appearance.theme_selector.light"),items:c.filter(p=>p.theme.palette.mode==="light")}].filter(p=>p.items.length>0),[d,u]=o.useState(null),m=o.useMemo(()=>{const p=l.flatMap(g=>g.items.map(f=>f.id));return d&&p.includes(d)?d:p.includes(r)?r:p[0]},[l,d,r]),h=p=>{if(!gx(p.key))return;const g=[...p.currentTarget.querySelectorAll("[data-theme-tile]")],f=g.indexOf(p.target);if(f<0)return;p.preventDefault();const j=fx({index:f,key:p.key,groups:Sx(p.currentTarget)});j!==f&&g[j]?.focus()};return e.jsx(Li,{children:e.jsxs("div",{onKeyDown:h,"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(p=>p.css).join(`
|
|
319
|
-
`)}),a.dialogs,l.map(p=>e.jsxs("div",{children:[e.jsx("h3",{className:"px-1 pb-2 text-meta text-ink-dim",children:p.label}),e.jsx("div",{"data-theme-grid":p.label,className:"grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2",children:p.items.map(({id:g,name:f,description:j})=>e.jsxs("div",{className:"group relative min-w-0",children:[e.jsx(Nx,{id:g,name:f,description:j,isSelected:g===r,isTabStop:g===m,onSelect:()=>{const _=a.library.themes.find(b=>b.id===g);_&&it(_.base)?be.setState({themeName:_.base,customThemeId:g}):it(g)&&s(g)},onFocusTile:()=>u(g)}),e.jsx("div",{className:"absolute end-1 top-1 opacity-0 group-focus-within:opacity-100 group-hover:opacity-100",children:a.menu(g,g===m)})]},g))})]},p.label))]})})},Mx=({value:t,onChange:s,searchRow:a})=>{ne();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(Gt,{value:t,onValueChange:i=>s(mi(i)),children:e.jsx(Yt,{"aria-labelledby":r,children:co.map(i=>e.jsx(ut,{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))})})})]})},Ax=()=>{ne();const{data:t,isLoading:s,error:a}=_m({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($d,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.radient_pass")]}),s&&e.jsx(Ue,{className:"h-6 w-36"}),a&&e.jsx(_e,{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(O,{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(bd,{}),n("ui.settings.account.settings_page.add_credits")]})})]})]})},Ex=[{id:"credits",get label(){return n("ui.settings.account.settings_page.credits")}},{id:"tokens",get label(){return n("ui.settings.account.settings_page.tokens")}}],Rx=()=>{ne();const[t,s]=o.useState("credits"),a=o.useMemo(()=>{const d=new Date,u=hm(d);return{start_date:fa(u),end_date:fa(d),rollup:"daily"}},[]),{data:r,isLoading:i,error:c}=bm(a,{enabled:!0}),l=o.useMemo(()=>r?.data_points?[...r.data_points].sort((u,m)=>Un(u.timestamp).getTime()-Un(m.timestamp).getTime()).map(u=>({bucket:Hc(td(Un(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(_d,{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:Ex.map(({id:d,label:u})=>e.jsx(O,{variant:"ghost",size:"sm","aria-pressed":t===d,onClick:()=>s(d),className:xe(t===d&&"bg-surface text-ink hover:bg-surface"),children:u},d))})]})]}),i&&e.jsx(Ue,{className:"h-62 w-full"}),c&&e.jsx(_e,{variant:"warning",children:n("ui.settings.account.settings_page.usage_load_failed",{reason:c.message})}),!i&&!c&&r&&l.length>0&&e.jsx(Ff,{metric:t,data:l}),!i&&!c&&(!r||l.length===0)&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:n("ui.settings.account.settings_page.no_usage_recorded_in_the_last_30_days")})]})},Ix=()=>(ne(),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(Sl,{size:16,className:"shrink-0 text-ink-dim"}),n("ui.settings.account.settings_page.radient_account")]}),e.jsx(O,{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(ji,{})]})})]})),Zx=()=>{ne();const t=Pc(),s=be(F=>F.showAgentReasoning),a=be(F=>F.setShowAgentReasoning),r=be(F=>F.transcriptDisplayMode),i=be(F=>F.setTranscriptDisplayMode),c=be(F=>F.agentAvatarSize),l=be(F=>F.setAgentAvatarSize),{data:d,isLoading:u,isFetching:m,error:h,refetch:p}=Fc(),{needsProvider:g}=zc(),f=Ts(),{sentence:j,remedy:_}=Vt(f??null,n("ui.settings.navigation.settings_page.your_settings_could_not_be_loaded"),h),b=fl(),[A,y]=o.useState(null),I=wi(),{isAuthenticated:M,accountRead:P,isFetching:N,isRefreshing:E,refreshUser:z}=Ms(),K=yt(F=>F.activeSessionId),x=yt(F=>F.sessions),R=yt(F=>F.temporaryChats),L=o.useMemo(()=>lo(x,R),[x,R]),w=Gm(),{accountId:V,snapshot:$,model:q}=Mi(),G=o.useRef(null);$.status?G.current={accountId:V,status:$.status}:$.checking||(G.current=null);const v=$.status??(G.current?.accountId===V?G.current.status:null),B=Cm(w),C=o.useMemo(()=>xl.filter(F=>F.id!=="agent-messages"||w!=="absent"),[w]),D=o.useCallback(()=>q.check("surface_open",!0),[q]),[J,ee]=o.useState("general"),[Z,ce]=o.useState(!1),ie=o.useRef(null),de=o.useRef(null),{startTour:Se}=_l(),H=uo(),U=di(),{data:k,refetch:Y}=Uc(),{refreshModels:ae}=Kc(),ue=o.useMemo(()=>k?.keys?[...k.keys].sort():[],[k?.keys]),ke=o.useRef({keys:"",hosting:void 0});o.useEffect(()=>{const F=ue.join(","),le=d?.values?.hosting;(ke.current.keys!==F||ke.current.hosting!==le)&&(ke.current={keys:F,hosting:le},ae().catch(ye=>{console.error("Failed to refresh models after credentials or hosting change:",ye)}))},[ue,d?.values?.hosting,ae]);const me=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,pe=o.useMemo(()=>new URLSearchParams(H.search).get("setting"),[H.search]),je=o.useMemo(()=>new URLSearchParams(H.search).get("filter")??"",[H.search]),Ke=o.useMemo(()=>new URLSearchParams(H.search).get("mcp")??void 0,[H.search]),se=o.useMemo(()=>new URLSearchParams(H.search).get("provider"),[H.search]),re=o.useCallback(F=>{ee(F),ce(!0);const le=me[F],ye=de.current;if(le?.current&&ye){const Ie=le.current.getBoundingClientRect().top-ye.getBoundingClientRect().top;ye.scrollHeight>ye.clientHeight?ye.scrollTo({top:Math.max(0,ye.scrollTop+Ie-80),behavior:"smooth"}):window.scrollTo({top:Math.max(0,le.current.getBoundingClientRect().top+window.scrollY-80),behavior:"smooth"}),clearTimeout(ie.current??void 0),ie.current=setTimeout(()=>{ce(!1),ie.current=null},800)}else ce(!1)},[me]),ve=o.useRef(null),Q=o.useRef(null),ge=gt(),he=Qe(ge.data,"settings"),Pe=ze({queryKey:mt.all,queryFn:()=>Ne({op:"settings.list"}),enabled:he,staleTime:1e4}),Ge=Df({registry:Pe.data,sections:C}),Be=o.useCallback(()=>de.current?np(de.current):[],[]),[Ae,tt]=o.useState(null),ht=o.useCallback(async F=>{Q.current=null;const le=de.current??document;if(F.source==="page")return op(le,F.id.slice(5));if(F.source==="section")return cp(le,F.sectionId);const ye=F.settingKey;if(!ye)return"missing";const Ce=gn(ye,"backend");return Pe.data&&!Pe.data.settings.some(Ie=>Ie.key===ye)?"missing":(re(Ce),tt({key:ye,nonce:Date.now()}),le.querySelector(`[data-search-section="${Ce}"]`)?"landed":"missing")},[re,Pe.data]);o.useEffect(()=>{tt(null)},[H.search]),o.useEffect(()=>{const F=le=>{!(le.metaKey||le.ctrlKey)||le.altKey||le.key.toLowerCase()==="f"&&(po(le.target)||(le.preventDefault(),Q.current=de.current?.scrollTop??null,ve.current?.focus()))};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[]),o.useEffect(()=>{const F=setTimeout(()=>{const le=de.current;if(!le)return;const ye=()=>{if(Z)return;const Ce=le.getBoundingClientRect(),Ie=Ce.height;let Te="",Ye=0;for(const[S,oe]of Object.entries(me))if(oe.current){const fe=oe.current.getBoundingClientRect(),Me=Ce.top,De=fe.top-Me,Le=fe.bottom-Me,we=fe.height,Ze=Math.max(0,De),en=Math.min(Ie,Le),Zs=Math.max(0,en-Ze)/we,Js=Zs+(De<Ie*.3?.1:0);Js>Ye&&Zs>.1&&(Ye=Js,Te=S)}Te&&Te!==J&&ee(Te)};return ye(),le.addEventListener("scroll",ye,{passive:!0}),()=>{le.removeEventListener("scroll",ye),clearTimeout(ie.current??void 0)}},100);return()=>clearTimeout(F)},[me,J,Z]),o.useEffect(()=>{const F=new URLSearchParams(H.search),le=F.get("section"),ye=F.get("setting"),Ce=ye?gn(ye,"backend"):le;if(Ce==="agent-messages"&&!B)return;const Ie=Ce?me[Ce]:void 0;if(!Ce||!Ie)return;let Te=!1,Ye=Number.NaN,S=0;const oe=window.setTimeout(()=>{Te||(Te=!0,Me.disconnect(),re(Ce))},2e3),fe=()=>{if(Te)return;const De=Ie.current;if(!De){S=requestAnimationFrame(fe);return}const Le=Math.round(De.getBoundingClientRect().top+window.scrollY);if(Le===Ye&&Le>0){Te=!0,Me.disconnect(),window.clearTimeout(oe),re(Ce);return}Ye=Le,S=requestAnimationFrame(fe)},Me=new ResizeObserver(()=>{Te||(cancelAnimationFrame(S),S=requestAnimationFrame(fe))});return de.current&&Me.observe(de.current),S=requestAnimationFrame(fe),()=>{Te=!0,cancelAnimationFrame(S),Me.disconnect(),window.clearTimeout(oe)}},[H.search,me,re,B]);const rt=async(F,le)=>{y(F);try{await b.mutateAsync({[F]:le}),await p()}catch(ye){console.error(`Error updating ${F}:`,ye)}finally{y(null)}},ft=u,ot=P==="checking",T=Si(P),W=P==="ready"||P==="checking"||N,te=Ci(ft,4e3);return h?e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(_e,{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:j}),_&&e.jsx(O,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void p(),disabled:m,children:m?n("ui.settings.navigation.settings_page.retrying"):n("ui.settings.navigation.settings_page.retry")})]})})}):ft?e.jsxs("div",{role:"status",className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-canvas",children:[e.jsx(Ee,{size:"lg",label:te?void 0:n("ui.settings.navigation.settings_page.loading_settings")}),te&&e.jsx("p",{className:"max-w-sm text-center text-body-sm text-ink-muted",children:n("ui.settings.navigation.settings_page.the_local_operator_server_is_taking_longer_than_usual_to_answer_i")})]}):d?e.jsxs("div",{"data-glass-region":"canvas","data-glass-split":"",className:"panel-flush flex min-h-0 flex-1 overflow-hidden bg-canvas",children:[e.jsx("div",{className:"w-12 shrink-0 overflow-y-auto min-[1040px]:w-55",children:e.jsx(yl,{activeSection:J,onSelectSection:re,sections:C})}),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:de,"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(Cl,{title:n("ui.settings.page.title"),icon:ua}),e.jsx(Pf,{onDismiss:()=>{const F=Q.current;Q.current=null,F!==null&&de.current?.scrollTo({top:F})},ref:ve,index:Ge,readRendered:Be,onJump:ht})]}),e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsxs("div",{ref:me.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(bl,{focus:pe===zn||Ae?.key===zn,focusNonce:Ae?.key===zn?Ae.nonce:void 0}),e.jsxs(Re,{title:n("ui.settings.profile.title"),icon:Ei,description:n(M?"ui.settings.profile.description_authenticated":"ui.settings.profile.description_anonymous"),children:[ot&&e.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.settings.profile.account_checking")}),T&&e.jsx(_e,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:n(P==="refused"?"ui.settings.profile.account_read_failed_refused":"ui.settings.profile.account_read_failed_retry")}),e.jsx(O,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>z(),disabled:E,children:E?n("ui.settings.profile.retrying"):n("ui.settings.profile.retry")})]})}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ma,{searchRow:"general.profile.name",value:I.profile.name,label:n("ui.settings.profile.display_name.label"),placeholder:n("ui.settings.profile.display_name.placeholder"),isSaving:A==="user_name",onSave:async F=>{y("user_name");try{I.updateName(F)}finally{y(null)}},readOnly:W}),e.jsx(ma,{searchRow:"general.profile.email",value:I.profile.email,label:n("ui.settings.profile.email.label"),placeholder:n("ui.settings.profile.email.placeholder"),isSaving:A==="user_email",onSave:async F=>{y("user_email");try{I.updateEmail(F)}finally{y(null)}},readOnly:W})]})]}),e.jsx(Re,{title:n("ui.settings.tour.title"),description:n("ui.settings.tour.description"),children:e.jsxs(O,{variant:"secondary","data-search-row":"general.tour","data-search-control":!0,onClick:()=>{Se({forceModalCompleted:!0})},children:[e.jsx(vi,{}),n("ui.settings.tour.action")]})}),e.jsx(Re,{id:"model-settings",title:n("ui.settings.model.settings_page.model_settings"),icon:vl,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(kl,{value:d.values.hosting,isSaving:A==="hosting",onSave:F=>rt("hosting",F),filterByCredentials:!0,allowCustom:!0,allowDefault:!1,emptyHelperText:n("ui.settings.model.settings_page.no_hosting_options")}),e.jsx(jl,{value:d.values.model_name,hostingId:d.values.hosting,isSaving:A==="model_name",onSave:F=>rt("model_name",F),allowCustom:!0,allowDefault:!1}),e.jsx(fp,{hosting:d.values.hosting,modelName:d.values.model_name,focus:pe===bt||Ae?.key===bt,focusNonce:Ae?.key===bt?Ae.nonce:void 0}),g&&e.jsx(_e,{variant:"neutral",icon:e.jsx(Nn,{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:()=>{re("providers"),me.providers.current?.focus({preventScroll:!0})},children:n("ui.settings.model.provider_callout.providers_link")}),"."]})})]})}),e.jsx(mx,{}),e.jsx(Re,{title:n("ui.settings.configuration.settings_page.configuration_information"),icon:Nn,description:n("ui.settings.configuration.settings_page.system_information_about_the_current_configuration"),children:e.jsxs(Zt,{children:[e.jsx(Oe,{label:n("ui.settings.configuration.settings_page.version"),value:e.jsx("span",{className:"text-mono-sm",children:d.version})}),e.jsx(Oe,{label:n("ui.settings.configuration.settings_page.created"),value:Ni(d.metadata.created_at)}),e.jsx(Oe,{label:n("ui.settings.configuration.settings_page.last_modified"),value:Es(d.metadata.last_modified)}),e.jsx(Oe,{label:n("ui.settings.configuration.settings_page.description"),value:d.metadata.description||n("ui.settings.configuration.settings_page.no_description_available")})]})})]}),e.jsx(Re,{title:n("ui.settings.appearance.settings_page.appearance"),icon:zi,description:n("ui.settings.appearance.settings_page.customize_the_look_and_feel_of_local_operator"),sectionRef:me.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(ug,{gallery:e.jsx(Cx,{}),glass:t.state}),e.jsx(zt,{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 F=>a(F)}),e.jsx(Mx,{searchRow:"appearance.transcript",value:mi(r),onChange:F=>i(F)}),e.jsx(Pp,{searchRow:"appearance.agent-picture-size",value:os(c),onChange:F=>l(F)}),e.jsx(wm,{searchRow:"appearance.glass",state:t.state,onChange:t.set})]})}),e.jsx(Hh,{sectionRef:me.notifications}),e.jsx(Qf,{sectionRef:me.speech}),e.jsx(wl,{sectionRef:me.keyboard,focusKey:pe}),e.jsx(Re,{title:n("ui.settings.model.settings_page.model_providers"),icon:bi,description:n("ui.settings.navigation.settings_page.sign_in_to_the_services_your_agents_think_with_new_chats_use_your"),sectionRef:me.providers,searchSection:"providers",searchSectionLabel:n("ui.settings.navigation.settings_sidebar.model_providers"),id:"model-providers",className:"focus-visible:outline-none!",children:e.jsx(Nl,{initialProviderId:se,onChangeModel:()=>re("general")})}),e.jsx(Ih,{sessionId:K??void 0,sectionRef:me.integrations,highlightServer:Ke}),e.jsx(Re,{title:n("ui.settings.account.settings_page.radient_account"),titleComponent:e.jsx(Ix,{}),description:n("ui.settings.account.settings_page.your_radient_account_radient_pass_details_and_credits_to_use_radi"),sectionRef:me.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(Sf,{onAfterCredentialUpdate:()=>{ae(),Y()}}),M&&e.jsxs(e.Fragment,{children:[e.jsx(Ax,{}),e.jsx(Rx,{})]})]})}),B&&e.jsx(Re,{title:n("ui.agentMessages.settings.section"),icon:Bc,description:n("ui.agentMessages.settings.description"),sectionRef:me["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:v?e.jsx(Om,{availability:w,status:v,accountId:V,refusal:$.refusal,onRefreshStatus:D,sessions:L,typingAvailable:Qe(ge.data,"team_bridge_typing"),focus:pe===Pn||Ae?.key===Pn,focusNonce:Ae?.key===Pn?Ae.nonce:void 0,onOpenSession:F=>{q.invalidateStatus(),mo(U,F)}}):$.refusal?e.jsxs(_e,{variant:"warning",children:[e.jsx(wn,{children:n("ui.agentMessages.settings.error.title")}),e.jsxs(Ve,{children:[$.refusal.code!=="client_unavailable"&&e.jsx("span",{className:"block",children:xn($.refusal)}),e.jsx("span",{className:"block",children:n("ui.agentMessages.settings.error.no_changes")}),e.jsx(O,{className:"mt-3",variant:"secondary",onClick:()=>void D(),children:n("ui.agentMessages.settings.error.retry")})]})]}):e.jsxs("div",{"aria-busy":"true",className:"flex flex-col gap-3",children:[e.jsx(Ue,{className:"h-5 w-40"}),e.jsx(Ue,{className:"h-4 w-full max-w-xl"})]})}),e.jsx(Re,{title:n("ui.settings.navigation.settings_page.backend_settings"),icon:ua,description:n("ui.settings.navigation.settings_page.every_setting_the_backend_registry_owns_searchable_with_typed_edi"),sectionRef:me.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(qc,{hideInterfaceLanguage:!0,hideModelEffort:!0,hideAgentMessages:!0,hideSpeechShortcuts:!0,hideNotifications:!0,focusKey:Ae?Ae.key:pe&&gn(pe,"backend")==="backend"?pe:null,focusNonce:Ae?.nonce,initialFilter:je})}),e.jsx("div",{ref:me.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(Op,{})}),e.jsx("div",{ref:me.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(mp,{})})]})]})})})]}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(_e,{variant:"warning",className:"w-full max-w-xl",children:n("ui.settings.navigation.settings_page.your_settings_could_not_be_loaded")})})};export{Zx as SettingsPage};
|