@openchamber/web 2.7.2 → 2.7.3-canary.20261115.21

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.
Files changed (103) hide show
  1. package/dist/assets/{AboutDialog-l-zrh7nU.js → AboutDialog-gL1x0YFW.js} +1 -1
  2. package/dist/assets/{AboutLogo-K3wdJM69.js → AboutLogo-cbKkZDLU.js} +1 -1
  3. package/dist/assets/{ArchiveView-DjRZQdOo.js → ArchiveView-0QjF07oK.js} +1 -1
  4. package/dist/assets/{ChangeRequestDiffUnavailable-BtH6Ad8g.js → ChangeRequestDiffUnavailable-kfarKKvU.js} +1 -1
  5. package/dist/assets/{CommandPalette-C7Uc4nDE.js → CommandPalette-D4bXVkJf.js} +1 -1
  6. package/dist/assets/{DataFileArtifact-DtnZXuug.js → DataFileArtifact-DWC11mPC.js} +1 -1
  7. package/dist/assets/{DiffView-CS0gR_am.js → DiffView-CSSPNDYJ.js} +1 -1
  8. package/dist/assets/{FilesView-tcU8_bnh.js → FilesView-D0FOaLpo.js} +3 -3
  9. package/dist/assets/{GitView-Ccs7O5Rf.js → GitView-CJl97ZjN.js} +1 -1
  10. package/dist/assets/{GuestPanelContent-CJ_wlnNr.js → GuestPanelContent-BCxvKv4H.js} +1 -1
  11. package/dist/assets/{HelpDialog-iH44R9qu.js → HelpDialog-DjficTGt.js} +1 -1
  12. package/dist/assets/{IntegrationsCatalogView-D9icTaJt.js → IntegrationsCatalogView-BvS1pCRR.js} +1 -1
  13. package/dist/assets/{JsonTreeView-BjPbJlHc.js → JsonTreeView-DQ6XLAW4.js} +1 -1
  14. package/dist/assets/{MarkdownDiffPreview-gCh_8R1F.js → MarkdownDiffPreview-C8KpNQaC.js} +1 -1
  15. package/dist/assets/{MarkdownRendererImpl-fohUB8r2.js → MarkdownRendererImpl-B1SjhV-G.js} +4 -4
  16. package/dist/assets/{MemoryDebugPanel-fX9cD8th.js → MemoryDebugPanel-BWT5owg7.js} +1 -1
  17. package/dist/assets/{NoteEditor-CTPSChrc.js → NoteEditor-DfHpXxIN.js} +1 -1
  18. package/dist/assets/{OfficeArtifact-BRviGdkx.js → OfficeArtifact-BAYHzDft.js} +2 -2
  19. package/dist/assets/{OfficeDocumentDiff-Hp2baXgN.js → OfficeDocumentDiff-Csvxzve7.js} +1 -1
  20. package/dist/assets/{OnboardingScreen-CDhZHMEt.js → OnboardingScreen-NWWMu7OG.js} +1 -1
  21. package/dist/assets/{OpenCodeStatusDialog-CBiLhgh9.js → OpenCodeStatusDialog-DtnVfNI4.js} +1 -1
  22. package/dist/assets/{OverviewView-DmNAg498.js → OverviewView-BXMN0Z8_.js} +1 -1
  23. package/dist/assets/{PatchDiff-rhuT-3au.js → PatchDiff-DxGkHtIk.js} +1 -1
  24. package/dist/assets/{PlanView-VhIl4wzm.js → PlanView-DE4sxgkq.js} +1 -1
  25. package/dist/assets/{ProjectActionsDialog-B_jMMuJ0.js → ProjectActionsDialog-C5q25ipO.js} +1 -1
  26. package/dist/assets/{ReceivedPagePanel-CCDFxXT4.js → ReceivedPagePanel-CfXyzCii.js} +5 -5
  27. package/dist/assets/{ReplyCommand-CUHB1iPz.js → ReplyCommand-OczgxN8d.js} +1 -1
  28. package/dist/assets/{ReplyUiBlock-TNOJJ_HH.js → ReplyUiBlock-D1HJeVU_.js} +1 -1
  29. package/dist/assets/{ReviewCards-UN_E9jl0.js → ReviewCards-D7jBPhS_.js} +1 -1
  30. package/dist/assets/{RunOverview-C7FUT8DD.js → RunOverview-BDblAbDp.js} +1 -1
  31. package/dist/assets/{ScheduledTasksDialog-DdXypryy.js → ScheduledTasksDialog-NDtZLq5t.js} +1 -1
  32. package/dist/assets/{SettingsView-uSZDjIcc.js → SettingsView-UjifxDq7.js} +1 -1
  33. package/dist/assets/{SettingsWindow-CoijA05f.js → SettingsWindow-D2K9vSYk.js} +1 -1
  34. package/dist/assets/{SidebarSectionsManager-d6IaYpHW.js → SidebarSectionsManager-QqwIUOdu.js} +1 -1
  35. package/dist/assets/{SourceBoardView-BrQkCEgn.js → SourceBoardView-CKJDJ2f4.js} +1 -1
  36. package/dist/assets/{SpaceAccessDialog-CymnxxLO.js → SpaceAccessDialog-G331hiT_.js} +1 -1
  37. package/dist/assets/{SpaceApplyDialog-DVJkF4lG.js → SpaceApplyDialog-x0rDuJEc.js} +1 -1
  38. package/dist/assets/{SpaceRow-CJFX1Zsr.js → SpaceRow-CsS43yrt.js} +1 -1
  39. package/dist/assets/{SpaceSetupOutput-Btttdq6K.js → SpaceSetupOutput-BEXQGXPw.js} +1 -1
  40. package/dist/assets/{SpacesView-GxzOEIeI.js → SpacesView-DFcnInBv.js} +1 -1
  41. package/dist/assets/{SubmoduleDiffSummary-D0Nj5PJN.js → SubmoduleDiffSummary-CTqIH0Cp.js} +1 -1
  42. package/dist/assets/{TableArtifact-DiRnrtL5.js → TableArtifact-Beve8fiv.js} +1 -1
  43. package/dist/assets/{ToolOutputDialog-DnvhhdiH.js → ToolOutputDialog-Bn2g6tIX.js} +1 -1
  44. package/dist/assets/{ToolPartDiffPreview-CHdkL7BJ.js → ToolPartDiffPreview-mgtjJMMz.js} +1 -1
  45. package/dist/assets/{UiBlock-CvZ92eyw.js → UiBlock-DkgJyZVl.js} +2 -2
  46. package/dist/assets/{UsageStatsView-Dbo3dCgC.js → UsageStatsView-CLJFagDC.js} +1 -1
  47. package/dist/assets/{WalkthroughView-l9TMdlPB.js → WalkthroughView-Dm4-RaV3.js} +1 -1
  48. package/dist/assets/{WorktreesView-DNa5Soxq.js → WorktreesView-DyZy4OjB.js} +1 -1
  49. package/dist/assets/{appThemeRegistry-C3TUDJ7r.js → appThemeRegistry-C4Av1s90.js} +1 -1
  50. package/dist/assets/{codeHighlight-DyrRLTkb.js → codeHighlight-Bmb7zcc2.js} +1 -1
  51. package/dist/assets/{columnWidthMemory-D0i9Kdhi.js → columnWidthMemory-D8H-O0YE.js} +1 -1
  52. package/dist/assets/{computeVirtualFileMetrics-YMtW3BEg.js → computeVirtualFileMetrics-Bc_YiqAD.js} +2 -2
  53. package/dist/assets/{contextFileOpenGuard-USev-3h1.js → contextFileOpenGuard-D-HtBtn6.js} +1 -1
  54. package/dist/assets/{date-time-DSQbTMhf.js → date-time-DfmOsLQo.js} +1 -1
  55. package/dist/assets/{diffsHighlighter-DZ_8ZCaS.js → diffsHighlighter-CFc933Ip.js} +1 -1
  56. package/dist/assets/{documentClient-5O0az-Ma.js → documentClient-D-gfZAFK.js} +2 -2
  57. package/dist/assets/{documentHost-BqOqnqk5.js → documentHost-fBeQzdlp.js} +1 -1
  58. package/dist/assets/{editorCodeMetrics-a0NLS65y.js → editorCodeMetrics-CNBjOGNA.js} +1 -1
  59. package/dist/assets/{fileContentPoller-B8a010z5.js → fileContentPoller-DRoVO_sh.js} +1 -1
  60. package/dist/assets/{flexokiTheme-DJaL_u7G.js → flexokiTheme-CcqiI7j-.js} +1 -1
  61. package/dist/assets/{highlights-CSy_17b-.js → highlights-_5vZZ38i.js} +1 -1
  62. package/dist/assets/{index-CvHejcGo.js → index-BbbQXJ_t.js} +1 -1
  63. package/dist/assets/{initializeSharedPreferences-MLG8op-A.js → initializeSharedPreferences-B1ISDxLb.js} +1 -1
  64. package/dist/assets/{install-NTaAzPnj.js → install-DY6TBn2e.js} +1 -1
  65. package/dist/assets/{install-request-D5VhmtWC.js → install-request-CzRei4tp.js} +1 -1
  66. package/dist/assets/{isDiffPlainText-B6ZzF_T5.js → isDiffPlainText-Cx5SgKlQ.js} +1 -1
  67. package/dist/assets/{isFilePlainText-Bitg2337.js → isFilePlainText-Bcn3vV6J.js} +1 -1
  68. package/dist/assets/{katex.min-B3YMLLh4.js → katex.min-DklPh68d.js} +3 -3
  69. package/dist/assets/{main-Bqwtrv5m.js → main-D0ACoTpS.js} +2 -2
  70. package/dist/assets/{main-B61P9v4A.js → main-QZk4AKac.js} +4 -4
  71. package/dist/assets/{miniChat-CZx_2XHj.js → miniChat-DeYRMPYt.js} +2 -2
  72. package/dist/assets/{mobile-DiLdHL_W.js → mobile-DjT3KVMo.js} +2 -2
  73. package/dist/assets/{moveWorkspacePath-CpN2DOGn.js → moveWorkspacePath-DibtVw_Q.js} +1 -1
  74. package/dist/assets/{officeDocument-Ca0s-jYd.js → officeDocument-CBwDUdTr.js} +1 -1
  75. package/dist/assets/{parseDiffFromFile-CL7WjMrZ.js → parseDiffFromFile-D28_u-uC.js} +1 -1
  76. package/dist/assets/{pierreDiffTint-C4cPKKnP.js → pierreDiffTint-CLCzflgS.js} +1 -1
  77. package/dist/assets/{relocateRestoredSession-Bw3yb1_0.js → relocateRestoredSession-BPqdEuzx.js} +2 -2
  78. package/dist/assets/{renderElectronMiniChatApp-DB0hWKLa.js → renderElectronMiniChatApp-C0v7P53f.js} +2 -2
  79. package/dist/assets/{renderMarkdownForExport-CICPn_1e.js → renderMarkdownForExport-DvKl_kjS.js} +1 -1
  80. package/dist/assets/{renderMobileApp-CYhEWO14.js → renderMobileApp-EVllBWS5.js} +3 -3
  81. package/dist/assets/{resolveLanguages-gKOTFspE.js → resolveLanguages-DqxtADuz.js} +1 -1
  82. package/dist/assets/{scheduledTasksApi-C1TDMoZd.js → scheduledTasksApi-v463mt0u.js} +1 -1
  83. package/dist/assets/{shiki-B0-fz3dN.js → shiki-3oNYFbTw.js} +1 -1
  84. package/dist/assets/{space-apply-DnoCDzwj.js → space-apply-j71ap5Rs.js} +1 -1
  85. package/dist/assets/{space-close-Bqfdl7kv.js → space-close-Bj32J79L.js} +1 -1
  86. package/dist/assets/{spaceNetwork-D5Fcyb33.js → spaceNetwork-BV5W32NY.js} +1 -1
  87. package/dist/assets/{stream-tokenizer-FniCZxxb.js → stream-tokenizer-wGP5G2_C.js} +1 -1
  88. package/dist/assets/{useAppFontEffects-CpxtKEGw.js → useAppFontEffects-BDLOJuy5.js} +15 -15
  89. package/dist/assets/{useBranchPullRequestRequest-DVy6rEsu.js → useBranchPullRequestRequest-DMiPjfPQ.js} +1 -1
  90. package/dist/assets/{useCallableModelProviders-DngJbZnV.js → useCallableModelProviders-aGFpVUZL.js} +1 -1
  91. package/dist/assets/{useDiffFindSurface-DY6lBBpH.js → useDiffFindSurface-mA0rc6AR.js} +1 -1
  92. package/dist/assets/{useGitCleanLine-CxdK3EQ3.js → useGitCleanLine-BwAypcLn.js} +1 -1
  93. package/dist/assets/{useInlineCommentController-Z8ADSR8f.js → useInlineCommentController-Wnopn0Ar.js} +1 -1
  94. package/dist/assets/{useMarkdownLocalAssets-CZIMWgjn.js → useMarkdownLocalAssets-BjT607tF.js} +1 -1
  95. package/dist/assets/{useRootScrollLock-C9UIEqnb.js → useRootScrollLock-DPhGk2Eu.js} +1 -1
  96. package/dist/assets/{useWalkthroughReview-BWxwaV05.js → useWalkthroughReview-BrULG_dy.js} +1 -1
  97. package/dist/assets/{useWholeFileComment-zterYCFS.js → useWholeFileComment-CQj6q_QX.js} +1 -1
  98. package/dist/assets/{useWorktreeArchiveActions-CKnDdsvh.js → useWorktreeArchiveActions-CpegLYyZ.js} +1 -1
  99. package/dist/assets/{vendor-codemirror-language-data-BI6j-q9C.js → vendor-codemirror-language-data-CFvXza4M.js} +2 -2
  100. package/dist/index.html +3 -3
  101. package/dist/mini-chat.html +2 -2
  102. package/dist/mobile.html +2 -2
  103. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-capacitor-core-B4EWRrHz.js"])))=>i.map(i=>d[i]);
2
- import{R as g,j as s,f as Fe,r as Ye}from"./vendor-react--VO_rL_p.js";import{u as $s,c as Go}from"./vendor-zustand-C9tWdk0j.js";import{u as Oe,I as ae,b0 as Ps,oo as at,aO as Qe,op as yn,x as ua,P as Us,aq as Wp,B as G,ah as Wt,z as Cn,A as Y,oq as sc,n as ys,or as vu,bb as Va,Z as nn,bl as ma,a3 as Jo,a2 as He,bv as Gp,dS as So,dY as Jp,aY as _t,aX as Dt,a_ as ht,aZ as Ft,aW as Ot,y as Ze,os as In,ot as yu,ou as Qp,fh as To,ov as nc,ow as Yp,ox as Si,t as Ut,q as Kt,D as qt,l as Bt,F as Vt,o as as,oy as hr,a7 as pa,a8 as ra,bg as Ta,bh as ca,a6 as ga,a5 as fa,bf as Ra,be as Ma,lU as Pn,lV as gn,oz as ls,dJ as cs,oA as xr,hN as zt,V as pt,fE as It,aT as Os,fG as $n,oB as xn,oC as Ss,oD as ss,aj as hs,oE as xs,oF as ju,oG as Zp,oH as ut,oI as ku,oJ as Xp,oK as eg,oL as Ei,oM as tg,f4 as Dn,oN as zs,eX as Qa,lX as _s,oO as Ha,oP as wu,oQ as br,fH as vr,ac as oa,oR as Kl,oS as sg,oT as ac,oU as ng,oV as ag,l_ as ig,oW as og,eu as Qo,oX as ic,hV as Ea,lW as $t,R as yr,oY as jr,oZ as ia,o_ as Su,o$ as bn,p0 as Nu,p1 as kr,lY as Nn,hH as wa,p2 as lg,mt as Li,C as da,ce as oc,dv as rg,co as cg,dC as dg,bd as ug,fL as mg,cU as pg,fM as gg,K as Yo,p3 as Jt,bS as ti,h0 as Ti,mT as Cu,p4 as fg,p5 as hg,dO as xg,p6 as bg,ay as Da,dQ as An,p7 as Iu,p8 as vg,hX as Bs,p9 as wr,pa as wn,pb as Ro,pc as yg,pd as jg,pe as kg,pf as wg,pg as Sg,ph as Ng,pi as Cg,pj as Pu,pk as Ig,pl as Pg,pm as Au,pn as Ag,po as Eu,pp as Tu,pq as Zo,kr as bs,pr as Ru,ks as Mu,ko as Du,gg as Eg,kp as Tg,kq as Fu,lA as Rg,ps as Ou,pt as Mg,pu as Dg,pv as Fg,pw as lc,dN as Lu,px as Og,py as Lg,pz as _g,pA as $g,pB as Ug,pC as _u,pD as Kg,pE as zg,pF as Bg,pG as Vg,pH as Hg,pI as qg,pJ as Ya,pK as Wg,pL as Gg,pM as $u,pN as Jg,pO as Ns,hW as En,cs as Fs,ct as Xo,pP as Qg,mu as Uu,hI as Yg,hS as Zg,iD as Xg,pQ as ef,pR as tf,f2 as el,d9 as _i,f3 as $i,dW as sf,dX as rl,dV as nf,lE as Ku,pS as cl,pT as af,pU as of,pV as lf,pW as rf,pX as cf,pY as df,pZ as uf,p_ as mf,bo as Ts,p$ as Sr,lZ as Js,dk as Nr,q0 as cn,ms as pf,q1 as Ia,fb as gf,q2 as Mo,q3 as ka,je as ff,q4 as hf,q5 as xf,hO as bf,q6 as vf,q7 as yf,q8 as Qs,q9 as Ks,qa as ja,qb as Un,qc as rc,qd as No,qe as jf,ao as kf,qf as zu,qg as Sa,qh as wf,qi as Sf,qj as Nf,qk as Cf,k as Bu,d_ as If,lv as Pf,ql as ba,qm as Sn,qn as _n,qo as Af,qp as Ef,qq as Tf,qr as Rf,qs as dl,qt as cc,qu as Mf,qv as Df,qw as Ff,qx as Of,qy as Lf,qz as dc,qA as ci,qB as uc,qC as Cr,qD as _f,a0 as $f,ck as mc,qE as Uf,fD as Vu,qF as Za,qG as Kf,qH as zf,qI as ul,qJ as pc,qK as Bf,qL as Ir,f as Kn,h as Pa,qM as gc,qN as Vf,qO as Hf,qP as qf,qQ as Ui,qR as Wf,qS as Gf,az as vn,qT as Jf,hq as Qf,qU as Yf,qV as Zf,qW as Pr,m1 as fn,qX as Xf,f9 as eh,lo as th,aC as sh,qY as nh,qZ as ml,q_ as ah,eU as ih,q$ as oh,l7 as zl,f5 as lh,f6 as rh,r0 as ch,r1 as dh,r2 as di,r3 as uh,aD as mh,r4 as ph,eC as fc,r5 as pl,l8 as gh,eB as fh,cn as va,f7 as hh,ae as xh,af as bh,f8 as vh}from"./useAppFontEffects-CpxtKEGw.js";import{j as Gt,cL as Na,cM as Hu,bv as qu,cN as yh,bt as Wu,aX as Zs,cO as jh,M as kt,u as oe,m as os,cP as Ri,cQ as Ni,cR as Tn,cS as Gu,cT as kh,v as Ys,cU as hc,cV as wh,ar as Fa,W as Qt,bY as Ar,b7 as Sh,aA as rs,_ as Oa,aR as gl,aU as xc,aS as bc,a_ as ui,bF as Nh,cW as Ch,bB as Ih,a$ as na,cX as Ph,cw as vc,aT as Ah,cY as Eh,cZ as Th,bx as yc,bj as Ki,cA as Rh,c_ as Mh,c$ as Ju,d0 as Mt,d1 as Dh,d2 as Fh,d3 as Bl,d4 as Oh,d5 as Lh,a6 as zi,bf as _h,bg as $h,b9 as Er,ap as Tr,bd as Uh,b6 as Kh,ae as tl,bM as Aa,d6 as Qu,as as Yu,d7 as zh,d8 as Bh,be as Do,d9 as Zu,da as za,db as Vh,dc as Hh,aZ as Rr,k as qh,dd as Wh,w as Fo,aD as Gh,aB as Ci,de as Jh,df as ea,dg as jc,dh as kc,di as wc,dj as Sc,dk as Qh,dl as Nc,dm as Cc,Q as Xu,dn as Bi,dp as Yh,X as Ic,dq as Zh,dr as Xh,r as Vl,ds as e1,dt as Pc,du as t1,b as s1,dv as n1,dw as a1,dx as i1,dy as o1,dz as l1,aV as em,dA as tm,dB as r1,dC as Hl,dD as c1,dE as d1,dF as u1,dG as m1,dH as p1,dI as g1,dJ as f1,dK as sm,dL as ql,dM as Ac,dN as h1,dO as Ec,dP as lo,dQ as x1,dR as b1,dS as v1,dT as y1,bQ as j1,bL as k1,bI as w1,af as Tc,bk as S1,dU as N1,dV as C1,dW as I1,dX as P1}from"./katex.min-B3YMLLh4.js";import{cP as Rc,cQ as A1,cR as E1,aV as T1,cS as R1,cI as fl,cJ as M1,cT as D1,cU as F1,cV as O1,cW as ns,cX as L1,cY as si,cZ as Rs,c_ as Mi,c$ as Rn,d0 as Xa,d1 as Vi,d2 as Mr,d3 as ei,a6 as zn,a4 as Bn,a5 as Vn,d4 as Wl,d5 as _1,cq as Ls,d6 as $1,d7 as nm,d8 as U1,d9 as Gl,cA as Mc,cG as K1,cB as am,da as z1,db as B1,dc as V1,cp as H1,dd as q1,de as W1}from"./ReceivedPagePanel-CCDFxXT4.js";import{o as es,s as At,e as Hi,l as im,c as Xs,n as Di,a as la,h as Fi,_ as Dr,u as Oo}from"./vendor-zod-DV_WH382.js";import{n as G1,M as om,r as J1,a as Q1,u as lm,i as rm,s as cm,b as Y1,c as Z1}from"./install-NTaAzPnj.js";import{s as X1,c as ex}from"./vendor-yaml-CE-D_49-.js";import{c as Dc,C as Fc,p as tx}from"./flexokiTheme-DJaL_u7G.js";import{u as sx}from"./vendor-tanstack-react-virtual-Bw3q1rnq.js";import{m as nx}from"./vendor-tanstack-virtual-core-B4TJYmIq.js";import{c as ax}from"./codeHighlight-DyrRLTkb.js";import{getCodeTokenTheme as ix}from"./appThemeRegistry-C3TUDJ7r.js";import{E as Oc}from"./vendor-codemirror-view-Ciie9ey-.js";import{Q as dm}from"./vendor-qrcode-Cl8OheHW.js";import{u as Lc}from"./install-request-D5VhmtWC.js";import{toast as qa}from"./vendor-sonner-Dw26OnzC.js";import{s as ox}from"./vendor-strip-json-comments-5dJlOkP1.js";import{u as lx}from"./useCallableModelProviders-DngJbZnV.js";import{S as Fr,f as Lo}from"./SpaceRow-CJFX1Zsr.js";import{_ as rx}from"./vendor-vite-runtime-DD1OZmLC.js";import{A as _c}from"./AboutLogo-K3wdJM69.js";import{s as cx}from"./pageTitle-BT3-HFbv.js";const $c=({label:t})=>{const{t:e}=Oe(),[n,a]=g.useState(null);g.useEffect(()=>{let l=false;const r=typeof AbortController<"u"?new AbortController:void 0;return(async()=>{try{const u=await Gt("/api/system/info",{signal:r?.signal,headers:{Accept:"application/json"}});if(!u.ok)return;const d=await u.json().catch(()=>null);if(!d||l)return;const p=typeof d.port=="number"&&Number.isFinite(d.port)&&d.port>0?d.port:null,m=typeof d.tunnelUrl=="string"&&d.tunnelUrl.trim().length>0?d.tunnelUrl.trim():null;a({port:p,tunnelUrl:m})}catch{}})(),()=>{l=true,r?.abort()}},[]);const i=[];if(n?.port!==null&&n?.port!==void 0&&i.push({key:"application",label:e("settings.openchamber.about.field.applicationUrl"),url:`http://localhost:${n.port}/`}),n?.tunnelUrl&&i.push({key:"tunnel",label:e("settings.openchamber.about.field.tunnelUrl"),url:n.tunnelUrl}),i.length===0)return null;const o=s.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1",children:i.map(l=>s.jsxs("button",{type:"button",title:l.label,className:"inline-flex max-w-full items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground",onClick:()=>{Ps(l.url)},children:[s.jsx("span",{className:"max-w-64 truncate font-mono",children:l.url}),s.jsx(ae,{name:"external-link",className:"size-3.5 shrink-0"})]},l.key))});return t?s.jsx(at,{label:t,controlClassName:"min-h-8",children:o}):o},dx="https://github.com/openchamber/openchamber/releases",ux=t=>{const e=Fe.c(8),{release:n,label:a}=t;let i;e[0]!==a?(i=a&&s.jsxs("div",{className:"mb-3 flex items-center gap-3",children:[s.jsx("span",{className:"typography-ui-label rounded bg-[var(--primary-base)]/10 px-1.5 py-0.5 font-mono text-[var(--primary-base)]",children:a.version}),a.date&&s.jsx("span",{className:"typography-meta text-muted-foreground",children:a.date})]}),e[0]=a,e[1]=i):i=e[1];const o=a!==null;let l;e[2]!==n||e[3]!==o?(l=s.jsx(A1,{notes:n,folded:o}),e[2]=n,e[3]=o,e[4]=l):l=e[4];let r;return e[5]!==i||e[6]!==l?(r=s.jsxs("div",{className:"oc-tile rounded-lg p-4",children:[i,l]}),e[5]=i,e[6]=l,e[7]=r):r=e[7],r},mx=t=>{const e=Fe.c(23),{version:n,since:a,describeVersion:i}=t,{t:o}=Oe(),[l,r]=g.useState(null),c=`${a??""}>${n}`;let u,d;e[0]!==c||e[1]!==a||e[2]!==n?(u=()=>{const f=new AbortController;return E1(n,a,f.signal).then(h=>{f.signal.aborted||r(h?{key:c,releases:h}:null)}),()=>f.abort()},d=[n,a,c],e[0]=c,e[1]=a,e[2]=n,e[3]=u,e[4]=d):(u=e[3],d=e[4]),g.useEffect(u,d);let p,m;if(e[5]!==i||e[6]!==l||e[7]!==c||e[8]!==a||e[9]!==o||e[10]!==n){m=Symbol.for("react.early_return_sentinel");e:{const f=l?.key===c?l.releases:[];if(f.length===0){m=null;break e}const h=f.length===1?f[0]:null,v=h&&!a&&!Na(h.version),x=f.map(px),b=(S,P)=>{const w=x[P];if(!w)return{version:`v${S.version}`,date:Rc(S.date)};const I=x.find((C,A)=>A!==P&&C?.builtOn.getTime()===w.builtOn.getTime());return{version:o("updateDialog.canary.night",{date:Hu(w,ua(),I)}),date:null}};let k;e[13]!==i||e[14]!==a||e[15]!==o||e[16]!==n?(k=a?o("settings.openchamber.about.releaseNotes.since",{version:i(a,n)}):o("settings.openchamber.about.releaseNotes.current",{version:i(n)}),e[13]=i,e[14]=a,e[15]=o,e[16]=n,e[17]=k):k=e[17];let j;e[18]!==o?(j=o("settings.openchamber.about.releaseNotes.allReleases"),e[18]=o,e[19]=j):j=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(ae,{name:"external-link",className:"size-3.5"}),e[20]=y):y=e[20];let N;e[21]!==j?(N=s.jsxs("a",{href:dx,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground",children:[j,y]}),e[21]=j,e[22]=N):N=e[22],p=s.jsx(Qe,{title:s.jsxs("h2",{className:yn,children:[k,v&&s.jsxs("span",{className:"typography-meta whitespace-nowrap text-muted-foreground",children:[" \xB7 ",Rc(h.date)]})]}),headerAction:N,contentClassName:"space-y-2",children:f.map((S,P)=>s.jsx(ux,{release:S,label:a?b(S,P):null},S.version))})}e[5]=i,e[6]=l,e[7]=c,e[8]=a,e[9]=o,e[10]=n,e[11]=p,e[12]=m}else p=e[11],m=e[12];return m!==Symbol.for("react.early_return_sentinel")?m:p};function px(t){return Na(t.version)}const Uc="https://github.com/openchamber/openchamber",Kc="https://discord.gg/ZYRSdnwwKA",zc="https://x.com/openchamber_dev",gx=800,fx=async t=>{const e=await Zs();return e?e.serverUpdateChannel??(Na(t)?"canary":"stable"):null},hx={info:null,checking:false,available:false,error:null};function xx(t){const e=Fe.c(5),[n,a]=g.useState(hx);let i;e[0]!==t?(i=async()=>{if(t){a(bx);try{const r=await M1();a({info:r,checking:false,available:r.available,error:null})}catch(r){const c=r;a({info:null,checking:false,available:false,error:c instanceof Error?D1(c):String(c)})}}},e[0]=t,e[1]=i):i=e[1];const o=i;let l;return e[2]!==o||e[3]!==n?(l={...n,check:o},e[2]=o,e[3]=n,e[4]=l):l=e[4],l}function bx(t){return{...t,checking:true,error:null}}function vx(t){const e=Fe.c(11),[n,a]=g.useState(null);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={kind:"idle"},e[0]=i):i=e[0];const[o,l]=g.useState(i);let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=async()=>{try{const x=await F1();return a(x),x}catch{return null}},e[1]=r):r=e[1];const c=r;let u,d;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{c()},d=[c],e[2]=u,e[3]=d):(u=e[2],d=e[3]),g.useEffect(u,d);let p;e[4]!==t?(p=async()=>{l({kind:"upgrading"});try{const x=await O1(t);l({kind:"installed",version:x})}catch(x){const b=x;l({kind:"failed",error:b instanceof Error?b.message:t})}},e[4]=t,e[5]=p):p=e[5];const m=p;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=async x=>{await x().catch(yx);const b=await c();b?.currentVersion&&l(k=>k.kind!=="installed"||k.version&&k.version.replace(/^v/,"")!==b.currentVersion?k:{kind:"idle"})},e[6]=f):f=e[6];const h=f;let v;return e[7]!==o||e[8]!==n||e[9]!==m?(v={status:n,phase:o,refresh:c,upgrade:m,reloadAfterUpgrade:h},e[7]=o,e[8]=n,e[9]=m,e[10]=v):v=e[10],v}function yx(){}function jx(t){const[e,n]=g.useState(null);return g.useEffect(()=>{if(!t)return;let a=false;return rx(async()=>{const{App:i}=await import("./vendor-capacitor-app-BrDJj9I_.js");return{App:i}},__vite__mapDeps([0,1,2])).then(({App:i})=>i.getInfo()).then(i=>{a||n(i.version.trim()||null)}).catch(()=>{}),()=>{a=true}},[t]),e}const kx=({initialUpdateDialogOpen:t=false})=>{const{t:e}=Oe(),[n,a]=g.useState(t),[i,o]=g.useState(false),[l,r]=g.useState(null),c=T1($s(se=>({info:se.info,checking:se.checking,available:se.available,error:se.error,downloading:se.downloading,downloaded:se.downloaded,installing:se.installing,progress:se.progress,runtimeType:se.runtimeType,checkForUpdates:se.checkForUpdates,downloadUpdate:se.downloadUpdate,restartToUpdate:se.restartToUpdate}))),{isMobile:u}=Us(),d=g.useMemo(()=>qu(),[]),p=R1(),m=xx(d||p),f=p?m:null,h=m.check;g.useEffect(()=>{p&&h()},[p,h]);const[v,x]=g.useState(false),[b,k]=g.useState(null);g.useEffect(()=>{if(!p)return;let se=false;return Wp().then(de=>{se||k(de)}),()=>{se=true}},[p]);const j=jx(d),y=d?{info:m.info,checking:m.checking,available:m.available,error:m.error,checkForUpdates:m.check,runtimeType:"web"}:{info:c.info,checking:c.checking,available:c.available,error:c.error,checkForUpdates:c.checkForUpdates,runtimeType:c.runtimeType},N=(se,de)=>{const je=Na(se);return je?e("settings.openchamber.about.canaryVersion",{version:je.release,date:Hu(je,ua(),Na(de))}):se},S=y.available?y.info?.version:null,P=N(l||y.info?.currentVersion||"unknown",S),w=N(b||c.info?.currentVersion||"unknown",S),I=l||f?.info?.currentVersion||"unknown",C=p?b||c.info?.currentVersion:l||y.info?.currentVersion,A=!!(S&&Na(C)&&!Na(S)),E=C?s.jsx(mx,{version:S||C,since:S&&!A?C:null,describeVersion:N}):null,D=c.runtimeType==="desktop",[M,O]=g.useState(false),R=c.runtimeType==="web"&&M&&l!==null,[F,T]=g.useState(null);g.useEffect(()=>{if(!D&&!R)return;let se=false;return(D?yh():fx(l??"")).then(je=>{se||T(je)}),()=>{se=true}},[D,R,l]);const _=vx(e("opencodeUpdate.toast.failed.description")),$=_.status?.currentVersion??null,z=_.phase.kind==="installed"?null:_.status?.availableVersion??null,[H,q]=g.useState(false),J=se=>{const de=N(se?.version||"",se?.currentVersion);return se?.packageManager==="electron"?e("settings.openchamber.about.actions.updateDesktopToVersion",{version:de}):e("settings.openchamber.about.actions.updateServerToVersion",{version:de})},U=(()=>{const se=N(y.info?.version||"",y.info?.currentVersion);return d?J(y.info):p?e("settings.openchamber.about.actions.updateAppToVersion",{version:se}):e("settings.openchamber.about.actions.updateOpenChamberToVersion",{version:se})})(),B=se=>se?.installBlocked==="opencode-version",W=se=>!!se?.installBlocked&&!B(se),Q=y.available&&W(y.info),ee=d&&Wu()==="android",X=ee&&c.runtimeType==="mobile"&&c.available?c.info?.downloadUrl??null:null,ne=X?s.jsxs(G,{type:"button",size:"sm",variant:"outline",onClick:()=>{Ps(X)},children:[s.jsx(ae,{name:"download",className:"size-4"}),e("settings.openchamber.about.actions.downloadAppVersion",{version:N(c.info?.version||"",j)})]}):null,K=async se=>{if(se===F)return;const de=F;if(T(se),!(D?await jh(se)===se:(await kt({serverUpdateChannel:se})).ok)){T(de),Y.error(e("settings.openchamber.about.toast.updateChannelNotSaved"));return}y.checkForUpdates()},le=F&&s.jsx(Wt,{value:F,onChange:se=>{K(se)},"aria-label":e("settings.openchamber.about.field.updateChannel"),className:"flex-nowrap",options:[{value:"stable",label:e("settings.openchamber.about.option.updateChannel.stable")},{value:"canary",label:e("settings.openchamber.about.option.updateChannel.canary"),selectedClassName:"bg-[var(--brand-canary)] text-[var(--brand-canary-foreground)] hover:bg-[var(--brand-canary)] hover:text-[var(--brand-canary-foreground)]"}]}),be=()=>{y.checkForUpdates(),f&&f.check(),ee&&c.checkForUpdates(),_.refresh()},ue=async se=>{(await Va(se)).ok&&(q(true),setTimeout(()=>q(false),2e3))},Pe=()=>{_.reloadAfterUpgrade(async()=>{await vu({message:e("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]})}).then(()=>{y.checkForUpdates(),f&&f.check()})},Ae=se=>{if(se?.installBlocked==="opencode-version")return s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:e("updateDialog.openCodeTooOld",{version:N(se.version||""),required:se.requiredOpenCodeVersion||"",current:se.openCodeVersion||""})});if(se?.installBlocked==="desktop-host")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:se.version||""})});if(se?.installBlocked==="manual-install")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.manualInstallUpdate",{version:N(se.version||"")})});const de=se?.updateCommand||"openchamber update";return s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.serviceManagerUpdate",{version:N(se?.version||"")})}),s.jsxs("div",{className:"flex items-center gap-2 oc-tile-inset rounded-md p-1 ps-3",children:[s.jsx(ys,{as:"code",outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-w-0",fillContainer:false,className:"whitespace-nowrap font-mono text-sm text-foreground",children:de}),s.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{ue(de)},"aria-label":e(H?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:s.jsx(ae,{name:H?"check":"clipboard",className:"size-4"})})]})]})},re=y.available&&y.info?.installBlocked?Ae(y.info):null,te=!!(f?.available&&!f.checking),he=te&&f?.info?.installBlocked?Ae(f.info):null,xe=te&&!W(f?.info??null)?s.jsxs(G,{type:"button",size:"sm",variant:"outline",onClick:()=>x(true),disabled:B(f?.info??null),children:[s.jsx(ae,{name:"download",className:"size-4"}),J(f?.info??null)]}):null,ke=f?s.jsx(fl,{open:v,onOpenChange:x,info:f.info,downloading:false,downloaded:false,progress:null,error:f.error,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"}):null,we=(()=>{const{phase:se}=_;if(se.kind==="installed")return{action:s.jsx(G,{type:"button",size:"sm",variant:"outline",onClick:Pe,children:e("opencodeUpdate.toast.actions.reload")}),note:s.jsx("p",{className:"typography-meta text-muted-foreground",children:se.version?e("settings.openchamber.about.openCode.installedVersion",{version:se.version}):e("settings.openchamber.about.openCode.installed")})};if(!z)return null;if(!_.status?.supported)return{action:null,note:s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.openCode.manualUpdate",{version:z})})};const de=se.kind==="upgrading";return{action:s.jsxs(G,{type:"button",size:"sm",variant:"outline",onClick:()=>{_.upgrade()},disabled:de,children:[de?s.jsx(Cn,{className:"size-4"}):s.jsx(ae,{name:"download",className:"size-4"}),de?e("opencodeUpdate.toast.upgrading.title"):e("settings.openchamber.about.actions.updateOpenCodeToVersion",{version:z})]}),note:se.kind==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:se.error}):null}})(),Te=we?s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[we.note,we.action]}):null;g.useEffect(()=>{let se=false;return(async()=>{try{const je=await Gt("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!je.ok)return;const De=await je.json().catch(()=>null),We=typeof De?.openchamberVersion=="string"&&De.openchamberVersion.trim().length>0?De.openchamberVersion.trim():null;se||(r(We),O(De?.runtime==="web"))}catch{se||r(null)}})(),()=>{se=true}},[]);const ge=f?.checking??false,Ee=f?.available??false,Ce=g.useRef(false),ce=ee&&c.checking,ye=!!X;g.useEffect(()=>{if(y.checking)o(true),Ce.current=true;else if(i&&!ce){const se=setTimeout(()=>{o(false);const de=ge||Ee;Ce.current&&!y.available&&!y.error&&!de&&(Y.success(e(ye?"settings.openchamber.about.toast.serverLatestAppUpdate":d?"settings.openchamber.about.toast.serverLatestVersion":"settings.openchamber.about.toast.latestVersion")),Ce.current=false)},gx);return()=>clearTimeout(se)}},[e,d,y.checking,i,y.available,y.error,ge,Ee,ce,ye]);const Z=y.checking||i;if(u)return s.jsxs("div",{className:"w-full space-y-6 pb-2",children:[s.jsxs("div",{className:"flex flex-col items-center text-center",children:[s.jsx(_c,{size:72}),s.jsx("h2",{className:`mt-4 ${sc}`,children:"OpenChamber"}),s.jsx("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:d?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:P})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:$||e("settings.openchamber.about.state.unknown")})}),j&&s.jsx("p",{children:e("settings.openchamber.about.native.appVersion",{version:j})})]}):p?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.appVersionLabel",{version:w})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:I})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:$||e("settings.openchamber.about.state.unknown")})})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:P})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:$||e("settings.openchamber.about.state.unknown")})})]})}),s.jsx($c,{})]}),le&&s.jsx("div",{className:"flex justify-center",children:le}),s.jsxs("div",{className:"flex justify-center",children:[!y.available&&!y.error&&s.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:be,disabled:Z,className:"w-auto justify-center gap-2",children:[Z?s.jsx(Cn,{className:"size-4"}):s.jsx(ae,{name:"refresh",className:"size-4"}),e(Z?"settings.openchamber.about.state.checking":d&&!ee?"settings.openchamber.about.actions.checkServerForUpdates":"settings.openchamber.about.actions.checkForUpdates")]}),!Z&&y.available&&!Q&&s.jsxs(G,{type:"button",variant:"default",size:"sm",onClick:()=>a(true),disabled:B(y.info),className:"w-auto justify-center gap-2",children:[s.jsx(ae,{name:"download",className:"size-4"}),U]})]}),ne&&s.jsx("div",{className:"flex justify-center",children:ne}),re,(xe||he)&&s.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[xe,he]}),Te&&s.jsx("div",{className:"flex justify-center text-center",children:Te}),[y.error,f?.error].filter(Boolean).map(se=>s.jsx("p",{className:"rounded-xl bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:se},se)),s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsxs("div",{className:"flex items-center justify-center gap-5",children:[s.jsxs("a",{href:Uc,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(ae,{name:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:Kc,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(ae,{name:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:zc,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(ae,{name:"twitter-xfill",className:"size-5"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"text-center typography-ui text-muted-foreground",children:e("aboutDialog.footerNote")}),E,s.jsx(fl,{open:n,onOpenChange:a,info:y.info,downloading:c.downloading,downloaded:c.downloaded,installing:c.installing,progress:c.progress,error:y.error,onDownload:c.downloadUpdate,onRestart:c.restartToUpdate,runtimeType:y.runtimeType}),ke]});const fe=s.jsx("span",{"aria-hidden":"true",className:"typography-meta text-muted-foreground/60",children:"\xB7"}),Ne=Z?s.jsxs(s.Fragment,{children:[fe,s.jsxs("span",{className:"flex items-center gap-1.5 typography-meta text-muted-foreground",children:[s.jsx(Cn,{className:"size-4"}),e("settings.openchamber.about.state.checking")]})]}):y.available&&!Q?s.jsxs(G,{size:"sm",variant:"default",onClick:()=>a(true),disabled:B(y.info),children:[s.jsx(ae,{name:"download",className:"size-4"}),U]}):!y.available&&!y.error?s.jsxs(s.Fragment,{children:[fe,s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")})]}):null,Ie=se=>s.jsx("span",{className:"typography-meta font-mono text-muted-foreground",children:se}),$e="min-h-8 flex-wrap @xl:flex-initial",L=[re,he,we?.note??null,...[y.error,f?.error].filter(Boolean).map(se=>s.jsx("p",{className:"rounded-lg bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:se},se))].filter(Boolean);return s.jsxs(s.Fragment,{children:[s.jsx(Qe,{children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(_c,{size:48}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("h2",{className:sc,children:"OpenChamber"}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[{href:Uc,icon:"github-fill",label:"GitHub"},{href:Kc,icon:"discord-fill",label:"Discord"},{href:zc,icon:"twitter-xfill",label:"@openchamber_dev"}].map(se=>s.jsxs("a",{href:se.href,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(ae,{name:se.icon,className:"size-4"}),s.jsx("span",{children:se.label})]},se.href))})]})]})}),s.jsxs(Qe,{contentClassName:"space-y-4",children:[s.jsxs("div",{children:[p?s.jsxs(s.Fragment,{children:[s.jsxs(at,{label:e("settings.openchamber.about.field.appVersion"),controlClassName:$e,children:[Ie(w),Ne]}),s.jsxs(at,{label:e("settings.openchamber.about.field.serverVersion"),controlClassName:$e,children:[Ie(I),xe]})]}):d?s.jsxs(s.Fragment,{children:[j&&s.jsxs(at,{label:e("settings.openchamber.about.field.appVersion"),controlClassName:$e,children:[Ie(N(j,c.info?.version)),ne]}),s.jsxs(at,{label:e("settings.openchamber.about.field.serverVersion"),controlClassName:$e,children:[Ie(P),Ne]})]}):s.jsxs(at,{label:e("settings.openchamber.about.field.version"),controlClassName:$e,children:[Ie(P),Ne]}),s.jsxs(at,{label:e("settings.openchamber.about.field.updateChannel"),info:le?e("settings.openchamber.about.field.updateChannelHint"):void 0,controlClassName:$e,children:[le,s.jsx(G,{size:"sm",variant:"outline",onClick:be,disabled:Z,children:e("settings.openchamber.about.actions.checkForUpdates")})]}),s.jsxs(at,{label:e("settings.openchamber.about.field.openCodeVersion"),controlClassName:$e,children:[Ie($||e("settings.openchamber.about.state.unknown")),we?.action]}),s.jsx($c,{label:e("settings.openchamber.about.field.instanceUrls")})]}),L.length>0&&s.jsx("div",{className:"space-y-3",children:L})]}),E,s.jsx(fl,{open:n,onOpenChange:a,info:y.info,downloading:c.downloading,downloaded:c.downloaded,installing:c.installing,progress:c.progress,error:y.error,onDownload:c.downloadUpdate,onRestart:c.restartToUpdate,runtimeType:y.runtimeType}),ke]})},wx=(t,e,n)=>t&&e.some(i=>i.path===t)?t:(e.find(i=>i.id===n)??e[0])?.path??null,en=()=>{const t=Fe.c(4),e=oe(Sx),n=nn(Nx),a=nn(Cx);let i;return t[0]!==a||t[1]!==n||t[2]!==e?(i=wx(e,n,a),t[0]=a,t[1]=n,t[2]=e,t[3]=i):i=t[3],i};function Sx(t){return t.settingsProjectPath}function Nx(t){return t.projects}function Cx(t){return t.activeProjectId}const Jl=Go(t=>({tab:"messages",setTab:e=>t({tab:e})})),um=new Map([["chat.activity-default","messages"],["chat.reasoning","messages"],["chat.reasoning-traces","messages"],["chat.tool-file-icons","messages"],["chat.changed-files","messages"],["chat.streaming-auto-follow","messages"],["chat.message-appearance","messages"],["chat.width","messages"],["chat.prompt-navigator","messages"],["chat.collapsible-user-messages","messages"],["chat.sticky-user-header","messages"],["chat.inline-assistant-actions","messages"],["chat.selection-approval-text","messages"],["chat.user-message-rendering","messages"],["chat.mermaid-rendering","messages"],["chat.diff-layout","messages"],["chat.code-block-line-wrap","messages"],["chat.table-cell-wrap","messages"],["chat.copy-plain-text","messages"],["chat.message-search","messages"],["chat.message-search-enabled","messages"],["chat.message-search-reasoning","messages"],["chat.composer","composer"],["chat.enter-to-send","composer"],["chat.mobile-return-key-sends","composer"],["chat.follow-up-behavior","composer"],["chat.questions-placement","composer"],["chat.large-text-paste","composer"],["chat.subagent-read-only-banner","composer"],["chat.save-pasted-images","composer"],["chat.spellcheck","composer"],["chat.input-history-scope","composer"],["chat.input-history-limit","composer"],["chat.session-assistance","assistance"],["chat.draft-starters-visible","assistance"],["chat.session-recap","assistance"],["chat.session-suggestion","assistance"],["chat.session-review-offer","assistance"],["chat.session-goal","assistance"],["chat.session-goal-checker","assistance"],["chat.session-goal-max-turns","assistance"],["chat.session-goal-budget","assistance"]]),Ix=t=>um.get(t)??null,Px=t=>[...um].filter(([,e])=>e===t).map(([e])=>e),Ql=Go(t=>({variant:null,setVariant:e=>t({variant:e})})),Ax=t=>t==="appearance.light-theme"?"light":t==="appearance.dark-theme"?"dark":null,ni=t=>{const e=Fe.c(73),{className:n}=t,{t:a}=Oe(),{currentTheme:i}=ma(),o=oe(Ex),[l,r]=g.useState(false),c=Jo(nn(Tx)),u=en(),d=oe(Rx),p=os();let m;e[0]!==u||e[1]!==c?(m=c.find(A=>A.path===u)??c[0]??null,e[0]=u,e[1]=c,e[2]=m):m=e[2];const f=m;if(p||!f)return null;let h;e[3]!==d||e[4]!==c?(h=A=>{const E=c.find(D=>D.id===A);E&&d(E.path)},e[3]=d,e[4]=c,e[5]=h):h=e[5];const v=h;if(o){let A;e[6]!==n?(A=He(n),e[6]=n,e[7]=A):A=e[7];let E;e[8]!==a?(E=a("settings.shared.projectSelector.switchProjectAria"),e[8]=a,e[9]=E):E=e[9];let D;e[10]!==a?(D=a("settings.shared.projectSelector.switchProjectTitle"),e[10]=a,e[11]=D):D=e[11];let M,O;e[12]===Symbol.for("react.memo_cache_sentinel")?(M=()=>r(true),O=He(Gp({size:"touch"}),"w-full min-w-0"),e[12]=M,e[13]=O):(M=e[12],O=e[13]);let R;e[14]!==f||e[15]!==i?(R=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:s.jsx(So,{project:f,theme:i})}),e[14]=f,e[15]=i,e[16]=R):R=e[16];let F;e[17]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(ae,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[17]=F):F=e[17];let T;e[18]!==l||e[19]!==E||e[20]!==D||e[21]!==O||e[22]!==R?(T=s.jsxs("button",{type:"button","aria-label":E,title:D,"aria-haspopup":"dialog","aria-expanded":l,onClick:M,className:O,children:[R,F]}),e[18]=l,e[19]=E,e[20]=D,e[21]=O,e[22]=R,e[23]=T):T=e[23];let _;e[24]!==T||e[25]!==A?(_=s.jsx("div",{className:A,children:T}),e[24]=T,e[25]=A,e[26]=_):_=e[26];let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($=()=>r(false),e[27]=$):$=e[27];const z=f.id;let H;e[28]!==a?(H=a("settings.shared.projectSelector.sheetTitle"),e[28]=a,e[29]=H):H=e[29];let q;e[30]!==a?(q=a("settings.shared.projectSelector.searchPlaceholder"),e[30]=a,e[31]=q):q=e[31];let J;e[32]!==f.id||e[33]!==i||e[34]!==v||e[35]!==l||e[36]!==c||e[37]!==H||e[38]!==q?(J=s.jsx(Jp,{open:l,onClose:$,projects:c,selectedProjectId:z,onSelectProject:v,theme:i,title:H,searchPlaceholder:q}),e[32]=f.id,e[33]=i,e[34]=v,e[35]=l,e[36]=c,e[37]=H,e[38]=q,e[39]=J):J=e[39];let U;return e[40]!==_||e[41]!==J?(U=s.jsxs(s.Fragment,{children:[_,J]}),e[40]=_,e[41]=J,e[42]=U):U=e[42],U}let x;e[43]!==n?(x=He(n),e[43]=n,e[44]=x):x=e[44];const b=f.id;let k;e[45]!==v?(k=A=>{A&&v(A)},e[45]=v,e[46]=k):k=e[46];let j;e[47]!==a?(j=a("settings.shared.projectSelector.switchProjectAria"),e[47]=a,e[48]=j):j=e[48];let y;e[49]!==a?(y=a("settings.shared.projectSelector.switchProjectTitle"),e[49]=a,e[50]=y):y=e[50];let N;e[51]!==f||e[52]!==i?(N=s.jsx(_t,{children:s.jsx(So,{project:f,theme:i})}),e[51]=f,e[52]=i,e[53]=N):N=e[53];let S;e[54]!==j||e[55]!==y||e[56]!==N?(S=s.jsx(Dt,{className:"w-full","aria-label":j,title:y,children:N}),e[54]=j,e[55]=y,e[56]=N,e[57]=S):S=e[57];let P;if(e[58]!==i||e[59]!==c){let A;e[61]!==i?(A=E=>s.jsx(ht,{value:E.id,className:"max-w-[24rem] truncate",children:s.jsx(So,{project:E,theme:i})},E.id),e[61]=i,e[62]=A):A=e[62],P=c.map(A),e[58]=i,e[59]=c,e[60]=P}else P=e[60];let w;e[63]!==P?(w=s.jsx(Ft,{fitContent:true,children:P}),e[63]=P,e[64]=w):w=e[64];let I;e[65]!==f.id||e[66]!==w||e[67]!==k||e[68]!==S?(I=s.jsxs(Ot,{value:b,onValueChange:k,children:[S,w]}),e[65]=f.id,e[66]=w,e[67]=k,e[68]=S,e[69]=I):I=e[69];let C;return e[70]!==I||e[71]!==x?(C=s.jsx("div",{className:x,children:I}),e[70]=I,e[71]=x,e[72]=C):C=e[72],C};function Ex(t){return t.isMobile}function Tx(t){return t.projects}function Rx(t){return t.setSettingsProjectPath}const Or=t=>{const e=Fe.c(16),{value:n,onChange:a}=t,{t:i}=Oe();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(ae,{name:"search",className:"pointer-events-none absolute inset-s-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":true}),e[0]=o):o=e[0];let l;e[1]!==a?(l=p=>a(p.target.value),e[1]=a,e[2]=l):l=e[2];let r;e[3]!==a||e[4]!==n?(r=p=>{p.key==="Escape"&&n&&(p.preventDefault(),p.stopPropagation(),a(""))},e[3]=a,e[4]=n,e[5]=r):r=e[5];let c;e[6]!==i?(c=i("settings.common.sidebar.searchPlaceholder"),e[6]=i,e[7]=c):c=e[7];let u;e[8]!==i?(u=i("settings.common.sidebar.searchPlaceholder"),e[8]=i,e[9]=u):u=e[9];let d;return e[10]!==l||e[11]!==r||e[12]!==c||e[13]!==u||e[14]!==n?(d=s.jsxs("div",{className:"relative mt-3",children:[o,s.jsx(Ze,{value:n,onChange:l,onKeyDown:r,placeholder:c,"aria-label":u,className:"h-8 ps-7 typography-meta"})]}),e[10]=l,e[11]=r,e[12]=c,e[13]=u,e[14]=n,e[15]=d):d=e[15],d},Lr=t=>{const e=Fe.c(5),{query:n}=t,{t:a}=Oe();let i;e[0]!==n||e[1]!==a?(i=a("settings.common.sidebar.noMatches",{query:n.trim()}),e[0]=n,e[1]=a,e[2]=i):i=e[2];let o;return e[3]!==i?(o=s.jsx("p",{className:"px-2 py-6 text-center typography-meta text-muted-foreground",children:i}),e[3]=i,e[4]=o):o=e[4],o};function Mx(t,e){return`opencode:sidebar-group:${t}:${e}`}const Yl=t=>{const e=Fe.c(33),{label:n,count:a,storageKey:i,defaultExpanded:o,children:l}=t,r=o===void 0?true:o;let c;e[0]!==n||e[1]!==i?(c=Mx(i,n),e[0]=n,e[1]=i,e[2]=c):c=e[2];const u=c,d=g.useId();let p;e[3]!==r||e[4]!==u?(p=()=>{try{const A=localStorage.getItem(u);if(A!==null)return A==="true"}catch{}return r},e[3]=r,e[4]=u,e[5]=p):p=e[5];const[m,f]=Ye.useState(p);let h,v;e[6]!==m||e[7]!==u?(h=()=>{try{localStorage.setItem(u,String(m))}catch{}},v=[u,m],e[6]=m,e[7]=u,e[8]=h,e[9]=v):(h=e[8],v=e[9]),Ye.useEffect(h,v);let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=()=>f(Dx),e[10]=x):x=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=He("flex w-full items-center gap-1 rounded-md px-2 py-1 text-start","text-xs font-semibold uppercase tracking-wide text-muted-foreground","hover:bg-[var(--interactive-hover)] transition-colors duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),e[11]=b):b=e[11];const k=!m&&"-rotate-90 rtl:rotate-90";let j;e[12]!==k?(j=He("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",k),e[12]=k,e[13]=j):j=e[13];let y;e[14]!==j?(y=s.jsx(ae,{name:"arrow-down-s",className:j}),e[14]=j,e[15]=y):y=e[15];let N;e[16]!==n?(N=s.jsx("span",{className:"flex-1 truncate",children:n}),e[16]=n,e[17]=N):N=e[17];let S;e[18]!==a?(S=s.jsx("span",{className:"ms-1 tabular-nums opacity-60",children:a}),e[18]=a,e[19]=S):S=e[19];let P;e[20]!==d||e[21]!==m||e[22]!==y||e[23]!==N||e[24]!==S?(P=s.jsxs("button",{type:"button",onClick:x,"aria-expanded":m,"aria-controls":d,className:b,children:[y,N,S]}),e[20]=d,e[21]=m,e[22]=y,e[23]=N,e[24]=S,e[25]=P):P=e[25];const w=!m;let I;e[26]!==l||e[27]!==d||e[28]!==w?(I=s.jsx("div",{id:d,hidden:w,className:"mt-0.5 space-y-0.5 ms-2 ps-3 border-s-2 border-[var(--interactive-border)]",children:l}),e[26]=l,e[27]=d,e[28]=w,e[29]=I):I=e[29];let C;return e[30]!==P||e[31]!==I?(C=s.jsxs("div",{children:[P,I]}),e[30]=P,e[31]=I,e[32]=C):C=e[32],C};function Dx(t){return!t}const Fx=({onItemSelect:t})=>{const{t:e}=Oe(),[n,a]=g.useState(""),[i,o]=g.useState(null),[l,r]=g.useState(""),[c,u]=g.useState(null),[d,p]=g.useState(false),[m,f]=g.useState(null),{selectedAgentName:h,setSelectedAgent:v,setAgentDraft:x,createAgent:b,deleteAgent:k,loadAgents:j,loadDisabledAgents:y,updateAgent:N,fetchAgentEntity:S}=In($s(K=>({selectedAgentName:K.selectedAgentName,setSelectedAgent:K.setSelectedAgent,setAgentDraft:K.setAgentDraft,createAgent:K.createAgent,deleteAgent:K.deleteAgent,loadAgents:K.loadAgents,loadDisabledAgents:K.loadDisabledAgents,updateAgent:K.updateAgent,fetchAgentEntity:K.fetchAgentEntity}))),P=en(),w=In(K=>yu(K,P)),I=In(K=>Qp(K,P)),[C,A]=g.useState(null);g.useEffect(()=>{j(P),y(P)},[j,y,P]);const E=w.filter(K=>To(K.mode)&&!nc(K)).length,D=K=>!(To(K.mode)&&!nc(K)&&E<=1),M=async(K,ie)=>{A(K);try{await N(K,{disabled:ie},P),ie&&h===K&&v(null),Y.success(ie?e("settings.agents.sidebar.toast.agentDisabled",{name:K}):e("settings.agents.sidebar.toast.agentEnabled",{name:K}))}catch{Y.error(e(ie?"settings.agents.sidebar.toast.disableFailed":"settings.agents.sidebar.toast.enableFailed"))}finally{A(null)}},O=I.filter(K=>Ri([K.name,K.description],n)),R="bg-background",F=()=>{const K="new-agent";let ie=K,le=1;for(;w.some(be=>be.name===ie);)ie=`${K}-${le}`,le++;x({name:ie,scope:"user"}),v(ie),t?.()},T=async K=>{if(Si(K)){Y.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}u(K)},_=()=>{u(null)},$=async()=>{if(c){p(true);try{(await k(c.name,c.scope,P)).ok?(Y.success(e("settings.agents.sidebar.toast.agentDeleted",{name:c.name})),_()):Y.error(e("settings.agents.sidebar.toast.deleteFailed"))}catch(K){const ie=K instanceof Error?K.message:"",le=/built-in|not deletable|not found/i.test(ie);Y.error(e(le?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed"))}p(false)}},z=async K=>{const ie=K.name;let le=1,be=`${ie}-copy`;for(;w.some(re=>re.name===be);)le++,be=`${ie}-copy-${le}`;const ue=K,Pe=await S(K.name,P);if(!Pe){Y.error(e("settings.agents.sidebar.toast.renameFailed"));return}const Ae=Pe.config.request?.body;x({name:be,scope:Pe.scope??ue.scope??"user",description:Pe.config.description??void 0,model:Pe.config.model??null,system:Pe.config.system??void 0,steps:Pe.config.steps??void 0,temperature:Ae?.temperature,top_p:Ae?.top_p,mode:Pe.config.mode??ue.mode,permissions:Pe.config.permissions??void 0,hidden:Pe.config.hidden}),v(be),t?.()},H=K=>{r(K.name),o(K)},q=async()=>{if(!i)return;const K=l.trim().replace(/\s+/g,"-");if(!K){Y.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(K===i.name){o(null);return}if(w.some(ue=>ue.name===K)){Y.error(e("settings.agents.sidebar.toast.agentExists"));return}const ie=i,le=await S(i.name,P);if(!le){Y.error(e("settings.agents.sidebar.toast.renameFailed"));return}(await b({...le.config,name:K,scope:le.scope??ie.scope},P)).ok?(await k(i.name,ie.scope,P)).ok?(Y.success(e("settings.agents.sidebar.toast.agentRenamed",{name:K})),v(K)):Y.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed")):Y.error(e("settings.agents.sidebar.toast.renameFailed")),o(null)},J=K=>{switch(K){case"primary":return s.jsx(ae,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return s.jsx(ae,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return s.jsx(ae,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},U=new Set(I.map(K=>K.name)),B=w.filter(K=>Yp(K)&&!U.has(K.name)),W=B.filter(K=>Ri([K.name,K.description],n)),Q=W.filter(Si),ee=W.filter(K=>!Si(K)),{groupedCustomAgents:X,ungroupedCustomAgents:ne}=Ye.useMemo(()=>{const K={},ie=[];for(const be of ee){const ue=be;ue.group?(K[ue.group]||(K[ue.group]=[]),K[ue.group].push(be)):ie.push(be)}return{groupedCustomAgents:Object.keys(K).sort((be,ue)=>be.localeCompare(ue)).map(be=>({name:be,agents:K[be]})),ungroupedCustomAgents:ie}},[ee]);return s.jsxs("div",{className:He("flex h-full flex-col",R),children:[s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[s.jsx("h2",{className:`${yn} mb-3`,children:e("settings.agents.sidebar.title")}),s.jsx(ni,{className:"mb-3"}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.agents.sidebar.total",{count:B.length})}),s.jsx(G,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:F,children:s.jsx(ae,{name:"add",className:"h-3.5 w-3.5"})})]}),B.length>0?s.jsx(Or,{value:n,onChange:a}):null]}),s.jsxs(ys,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:[B.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(ae,{name:"robot-2",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:e("settings.agents.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.agents.sidebar.empty.description")})]}):W.length===0?s.jsx(Lr,{query:n}):s.jsxs(s.Fragment,{children:[Q.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.builtIn")}),Q.map(K=>s.jsx(hl,{agent:K,isSelected:h===K.name,onSelect:()=>{v(K.name),t?.()},onDuplicate:()=>{z(K)},onDisable:D(K)?()=>{M(K.name,true)}:void 0,getAgentModeIcon:J,isMenuOpen:m===K.name,onMenuOpenChange:ie=>f(ie?K.name:null)},K.name))]}),ee.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.custom")}),X.map(({name:K,agents:ie})=>s.jsx(Yl,{label:K,count:ie.length,storageKey:"agents",children:ie.map(le=>s.jsx(hl,{agent:le,isSelected:h===le.name,onSelect:()=>{v(le.name),t?.()},onRename:()=>H(le),onDelete:()=>T(le),onDuplicate:()=>{z(le)},onDisable:D(le)?()=>{M(le.name,true)}:void 0,getAgentModeIcon:J,isMenuOpen:m===le.name,onMenuOpenChange:be=>f(be?le.name:null)},le.name))},K)),ne.map(K=>s.jsx(hl,{agent:K,isSelected:h===K.name,onSelect:()=>{v(K.name),t?.()},onRename:()=>H(K),onDelete:()=>T(K),onDuplicate:()=>{z(K)},onDisable:D(K)?()=>{M(K.name,true)}:void 0,getAgentModeIcon:J,isMenuOpen:m===K.name,onMenuOpenChange:ie=>f(ie?K.name:null)},K.name))]})]}),O.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.disabled")}),O.map(K=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-1.5 py-1",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"typography-ui-label truncate text-muted-foreground",children:K.name}),K.description?s.jsx("div",{className:"typography-micro truncate leading-tight text-muted-foreground",children:K.description}):null]}),s.jsx(G,{size:"xs",variant:"outline",disabled:C===K.name,onClick:()=>{M(K.name,false)},"aria-label":e("settings.agents.sidebar.actions.enableAria",{name:K.name}),children:e("settings.agents.sidebar.actions.enable")})]},K.name))]})]}),s.jsx(Ut,{open:c!==null,onOpenChange:K=>{!K&&!d&&_()},children:s.jsxs(Kt,{className:"max-w-md",children:[s.jsxs(qt,{children:[s.jsx(Bt,{children:e("settings.agents.sidebar.dialog.deleteTitle")}),s.jsx(Vt,{children:e("settings.agents.sidebar.dialog.deleteDescription",{name:c?.name??""})})]}),s.jsxs(as,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:_,disabled:d,children:e("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",onClick:$,disabled:d,children:e("settings.common.actions.delete")})]})]})}),s.jsx(Ut,{open:i!==null,onOpenChange:K=>!K&&o(null),children:s.jsxs(Kt,{children:[s.jsxs(qt,{children:[s.jsx(Bt,{children:e("settings.agents.sidebar.renameDialog.title")}),s.jsx(Vt,{children:e("settings.agents.sidebar.renameDialog.description",{name:i?.name??""})})]}),s.jsx(Ze,{value:l,onChange:K=>r(K.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:K=>{K.key==="Enter"&&q()}}),s.jsxs(as,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:()=>o(null),children:e("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",onClick:q,children:e("settings.common.actions.rename")})]})]})})]})},hl=t=>{const e=Fe.c(52),{agent:n,isSelected:a,onSelect:i,onDelete:o,onRename:l,onDuplicate:r,onDisable:c,getAgentModeIcon:u,isMenuOpen:d,onMenuOpenChange:p}=t,{t:m}=Oe(),f=n;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=hr(),e[0]=h):h=e[0];const v=h,[x,b]=g.useState(false);let k;e[1]!==o||e[2]!==c||e[3]!==r||e[4]!==l||e[5]!==m?(k=H=>s.jsxs(s.Fragment,{children:[l&&s.jsxs(H,{onClick:q=>{q.stopPropagation(),l()},children:[s.jsx(ae,{name:"edit",className:"h-4 w-4 me-px"}),m("settings.common.actions.rename")]}),s.jsxs(H,{onClick:q=>{q.stopPropagation(),r()},children:[s.jsx(ae,{name:"file-copy",className:"h-4 w-4 me-px"}),m("settings.common.actions.duplicate")]}),c&&s.jsxs(H,{onClick:q=>{q.stopPropagation(),c()},children:[s.jsx(ae,{name:"eye-off",className:"h-4 w-4 me-px"}),m("settings.agents.sidebar.actions.disable")]}),o&&s.jsxs(H,{onClick:q=>{q.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[s.jsx(ae,{name:"delete-bin",className:"h-4 w-4 me-px"}),m("settings.common.actions.delete")]})]}),e[1]=o,e[2]=c,e[3]=r,e[4]=l,e[5]=m,e[6]=k):k=e[6];const j=k,y=a?"bg-interactive-selection":"hover:bg-interactive-hover";let N;e[7]!==y?(N=He("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",y),e[7]=y,e[8]=N):N=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=v?void 0:H=>{H.preventDefault(),b(true)},e[9]=S):S=e[9];let P;e[10]!==N?(P=s.jsx("div",{className:N,onContextMenu:S}),e[10]=N,e[11]=P):P=e[11];let w;e[12]!==n.name?(w=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n.name}),e[12]=n.name,e[13]=w):w=e[13];let I;e[14]!==n.mode||e[15]!==u?(I=u(n.mode),e[14]=n.mode,e[15]=u,e[16]=I):I=e[16];let C;e[17]!==n||e[18]!==f.scope||e[19]!==m?(C=(f.scope||Si(n))&&s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-edge",children:Si(n)?m("settings.agents.sidebar.badge.system"):f.scope}),e[17]=n,e[18]=f.scope,e[19]=m,e[20]=C):C=e[20];let A;e[21]!==w||e[22]!==I||e[23]!==C?(A=s.jsxs("div",{className:"flex items-center gap-1.5",children:[w,I,C]}),e[21]=w,e[22]=I,e[23]=C,e[24]=A):A=e[24];let E;e[25]!==n.description?(E=n.description&&s.jsx("div",{className:"typography-micro text-muted-foreground truncate leading-tight",children:n.description}),e[25]=n.description,e[26]=E):E=e[26];let D;e[27]!==i||e[28]!==A||e[29]!==E?(D=s.jsxs("button",{onClick:i,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,children:[A,E]}),e[27]=i,e[28]=A,e[29]=E,e[30]=D):D=e[30];let M;e[31]!==p?(M=H=>{H&&b(false),p(H)},e[31]=p,e[32]=M):M=e[32];let O;e[33]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(ga,{asChild:true,children:s.jsx(G,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -me-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 pointer-fine:hidden",children:s.jsx(ae,{name:"more",className:"h-3.5 w-3.5"})})}),e[33]=O):O=e[33];let R;e[34]!==j?(R=s.jsx(pa,{align:"end",className:"w-fit min-w-20",children:j(ra)}),e[34]=j,e[35]=R):R=e[35];let F;e[36]!==d||e[37]!==M||e[38]!==R?(F=s.jsxs(fa,{open:d,onOpenChange:M,children:[O,R]}),e[36]=d,e[37]=M,e[38]=R,e[39]=F):F=e[39];let T;e[40]!==D||e[41]!==F?(T=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[D,F]}),e[40]=D,e[41]=F,e[42]=T):T=e[42];let _;e[43]!==T||e[44]!==P?(_=s.jsx(Ra,{render:P,children:T}),e[43]=T,e[44]=P,e[45]=_):_=e[45];let $;e[46]!==j?($=s.jsx(Ta,{className:"w-fit min-w-20",children:j(ca)}),e[46]=j,e[47]=$):$=e[47];let z;return e[48]!==x||e[49]!==_||e[50]!==$?(z=s.jsxs(Ma,{open:x,onOpenChange:b,children:[_,$]}),e[48]=x,e[49]=_,e[50]=$,e[51]=z):z=e[51],z},Vs={ok:true,changed:false},Mn={ok:true,changed:true},vs=t=>({ok:false,reason:t}),Ox=t=>t instanceof HTMLElement?t.matches('input, textarea, [contenteditable="true"]'):false,ai=t=>{const{t:e}=Oe(),[n,a]=g.useState(0),i=g.useRef(t);i.current=t;const o=g.useRef(e);o.current=e;const l=g.useRef(false),r=g.useRef(false),c=g.useRef(false),u=g.useCallback(()=>{a(m=>m+1)},[]),d=g.useCallback(m=>{Ox(m.target)&&u()},[u]),p=g.useCallback(async()=>{l.current=true;try{for(;;){r.current=false;let m;try{m=await i.current()}catch(f){m={ok:false,reason:f instanceof Error?f.message:String(f)}}if(!c.current)return;if(!r.current){m.ok||Y.error(o.current("settings.common.status.saveFailedReason",{reason:m.reason}));return}}}finally{l.current=false}},[]);return g.useEffect(()=>(c.current=true,()=>{c.current=false}),[]),g.useEffect(()=>{if(n!==0){if(l.current){r.current=true;return}p()}},[n,p]),{requestSave:u,onBlurCapture:d}},Lx=["allow","ask","deny"],_x=["shell","edit","read","glob","grep","patch","webfetch","websearch","skill","subagent","question","external_directory"],$x=["openchamber","openchamber_schedule","openchamber_web","openchamber_memory","openchamber_knowledge","openchamber_notify","openchamber_usage","openchamber_render","openchamber_image","openchamber_secret"],Ux=new Set(["bash","task","write","list","lsp","todowrite","todoread","multiedit","doom_loop","plan_enter","plan_exit"]),mm=t=>Ux.has(t),Kx=[{action:"*",resource:"*",effect:"allow"},{action:"read",resource:"*.env",effect:"ask"},{action:"read",resource:"*.env.*",effect:"ask"},{action:"read",resource:"*.env.example",effect:"allow"}],Bc=()=>({global:null,keys:{},source:[]}),ya=t=>({global:t.global,source:t.source,keys:Object.fromEntries(Object.entries(t.keys).map(([e,n])=>[e,{effect:n.effect,patterns:n.patterns.map(a=>({...a}))}]))}),zx=t=>{const e={global:null,keys:{},source:t.map(n=>({...n}))};for(const n of t){if(mm(n.action))continue;if(n.action==="*"){n.resource==="*"&&(e.global=n.effect);continue}const a=e.keys[n.action]??{effect:null,patterns:[]};if(n.resource==="*")a.effect=n.effect;else{const i=a.patterns.findIndex(o=>o.pattern===n.resource);i>=0?a.patterns[i]={pattern:n.resource,effect:n.effect}:a.patterns.push({pattern:n.resource,effect:n.effect})}e.keys[n.action]=a}return e},Bx=t=>t.action!=="*"||t.resource==="*",Ca=(t,e)=>`${t}\0${e}`,Vx=t=>{const e=new Map;t.global!==null&&e.set(Ca("*","*"),t.global);for(const[n,a]of Object.entries(t.keys)){a.effect!==null&&e.set(Ca(n,"*"),a.effect);for(const i of a.patterns){const o=i.pattern.trim();o.length!==0&&e.set(Ca(n,o),i.effect)}}return e},Zl=t=>{const e=Vx(t),n=new Set,a=[];for(const o of t.source){if(mm(o.action))continue;if(!Bx(o)){a.push({...o});continue}const l=Ca(o.action,o.resource),r=e.get(l);r!==void 0&&(a.push({action:o.action,resource:o.resource,effect:r}),n.add(l))}const i=Ca("*","*");t.global!==null&&!n.has(i)&&a.unshift({action:"*",resource:"*",effect:t.global});for(const[o,l]of Object.entries(t.keys)){const r=Ca(o,"*");if(l.effect!==null&&!n.has(r)){const c=a.findIndex(d=>d.action===o),u={action:o,resource:"*",effect:l.effect};c>=0?a.splice(c,0,u):a.push(u)}for(const c of l.patterns){const u=c.pattern.trim();if(u.length===0)continue;const d=Ca(o,u),p=e.get(d);p===void 0||n.has(d)||(n.add(d),a.push({action:o,resource:u,effect:p}))}}return a},Hx=(t,e)=>JSON.stringify(Zl(t))===JSON.stringify(Zl(e)),qx=(t,e)=>{const n=[...Kx,...e.global,...e.agentGlobal?[{action:"*",resource:"*",effect:e.agentGlobal}]:[]];let a="ask";for(const i of n)i.resource==="*"&&(i.action==="*"||i.action===t)&&(a=i.effect);return a},Wx=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),Gx=new Set(["shell","edit","read","glob","grep","patch","webfetch","skill","subagent","external_directory"]),Jx={effect:null,patterns:[]},Qx=t=>{const e=Fe.c(163),{agent:n,registerSave:a,requestSave:i}=t,{t:o}=Oe(),l=In(Yx),r=In(Zx);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[u,d]=g.useState(c),[p,m]=g.useState(Bc),[f,h]=g.useState(Bc),[v,x]=g.useState(true),[b,k]=g.useState(false);let j;e[1]===Symbol.for("react.memo_cache_sentinel")?(j={},e[1]=j):j=e[1];const[y,N]=g.useState(j),[S,P]=g.useState(""),[w,I]=g.useState(0),C=n.name,A=en(),E=Pn(Xx);let D;e[2]!==A?(D=_e=>xr(_e,A),e[2]=A,e[3]=D):D=e[3];const M=Pn(D);let O;e[4]!==A?(O=_e=>_e.getStatusForDirectory(A),e[4]=A,e[5]=O):O=e[5];const R=gn(O);let F,T;e[6]!==E||e[7]!==A?(F=()=>{E({directory:A})},T=[E,A],e[6]=E,e[7]=A,e[8]=F,e[9]=T):(F=e[8],T=e[9]),g.useEffect(F,T);let _;e[10]!==C||e[11]!==r||e[12]!==A?(_=()=>{let _e=false;return x(true),k(false),(async()=>{const nt=await r(C,A);if(_e)return;if(!nt){k(true),x(false);return}const Ue=zx(nt.agent);d(nt.global),m(ya(Ue)),h(Ue),N({}),x(false)})(),()=>{_e=true}},e[10]=C,e[11]=r,e[12]=A,e[13]=_):_=e[13];let $;e[14]!==C||e[15]!==r||e[16]!==w||e[17]!==A?($=[C,r,w,A],e[14]=C,e[15]=r,e[16]=w,e[17]=A,e[18]=$):$=e[18],g.useEffect(_,$);let z;e[19]!==C||e[20]!==p||e[21]!==f||e[22]!==A||e[23]!==o||e[24]!==l?(z=async()=>Hx(f,p)?Vs:(await l(C,{permissions:Zl(f)},A)).ok?(m(ya(f)),Mn):vs(o("settings.agents.page.permissionsEditor.toast.saveFailed")),e[19]=C,e[20]=p,e[21]=f,e[22]=A,e[23]=o,e[24]=l,e[25]=z):z=e[25];const H=z;let q,J;e[26]!==a||e[27]!==H?(q=()=>(a(H),()=>a(null)),J=[a,H],e[26]=a,e[27]=H,e[28]=q,e[29]=J):(q=e[28],J=e[29]),g.useEffect(q,J);let U;e[30]!==M?(U=M.map(eb),e[30]=M,e[31]=U):U=e[31];const B=U;let W;if(e[32]!==B||e[33]!==f.keys){W=[..._x,...$x];const _e=new Set(B.map(tb));let nt;e[35]!==f.keys?(nt=Object.keys(f.keys),e[35]=f.keys,e[36]=nt):nt=e[36];for(const Ue of nt)!W.includes(Ue)&&!_e.has(Ue)&&W.push(Ue);e[32]=B,e[33]=f.keys,e[34]=W}else W=e[34];const Q=W;let ee;e[37]!==R||e[38]!==o?(ee=_e=>{switch(R?.[_e]?.status.status){case"connected":return o("settings.mcp.page.status.label.connected");case"failed":return o("settings.mcp.page.status.label.failed");case"needs_auth":return o("settings.mcp.page.status.label.needsAuth");case"disabled":return o("settings.agents.page.permissionsEditor.mcpStatus.disabled");case"pending":return o("settings.agents.page.permissionsEditor.mcpStatus.pending");default:return null}},e[37]=R,e[38]=o,e[39]=ee):ee=e[39];const X=ee;let ne;e[40]!==u||e[41]!==f.global?(ne=_e=>qx(_e,{global:u,agentGlobal:f.global}),e[40]=u,e[41]=f.global,e[42]=ne):ne=e[42];const K=ne;let ie;e[43]!==i?(ie=_e=>{h(nt=>({...nt,global:_e})),i()},e[43]=i,e[44]=ie):ie=e[44];const le=ie;let be;e[45]!==i?(be=(_e,nt)=>{h(Ue=>{const Se=ya(Ue),Ve=Se.keys[_e]??{effect:null,patterns:[]};return Ve.effect=nt,Ve.effect===null&&Ve.patterns.length===0?delete Se.keys[_e]:Se.keys[_e]=Ve,Se}),i()},e[45]=i,e[46]=be):be=e[46];const ue=be;let Pe;e[47]!==i?(Pe=(_e,nt,Ue,Se,Ve)=>{h(Re=>{const Je=ya(Re),ot=Je.keys[_e]??{effect:null,patterns:[]};return ot.patterns[nt]={pattern:Ue,effect:Se},Je.keys[_e]=ot,Je}),Ve&&i()},e[47]=i,e[48]=Pe):Pe=e[48];const Ae=Pe;let re;e[49]===Symbol.for("react.memo_cache_sentinel")?(re=_e=>{h(nt=>{const Ue=ya(nt),Se=Ue.keys[_e]??{effect:null,patterns:[]};return Se.patterns.push({pattern:"",effect:"allow"}),Ue.keys[_e]=Se,Ue}),N(nt=>({...nt,[_e]:true}))},e[49]=re):re=e[49];const te=re;let he;e[50]!==i?(he=(_e,nt)=>{h(Ue=>{const Se=ya(Ue),Ve=Se.keys[_e];return Ve?(Ve.patterns.splice(nt,1),Ve.effect===null&&Ve.patterns.length===0&&delete Se.keys[_e],Se):Ue}),i()},e[50]=i,e[51]=he):he=e[51];const xe=he;let ke;e[52]!==S||e[53]!==i?(ke=()=>{const _e=S.trim();!_e||_e==="*"||(h(nt=>{if(nt.keys[_e])return nt;const Ue=ya(nt);return Ue.keys[_e]={effect:"ask",patterns:[]},Ue}),P(""),i())},e[52]=S,e[53]=i,e[54]=ke):ke=e[54];const we=ke;let Te;e[55]!==o?(Te=_e=>o(_e==="allow"?"settings.agents.page.permissionsEditor.action.allow":_e==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),e[55]=o,e[56]=Te):Te=e[56];const ge=Te;let Ee,Ce,ce,ye,Z,fe,Ne,Ie,$e;if(e[57]!==ge||e[58]!==K||e[59]!==y||e[60]!==v||e[61]!==b||e[62]!==B||e[63]!==X||e[64]!==f.global||e[65]!==f.keys||e[66]!==xe||e[67]!==le||e[68]!==ue||e[69]!==Ae||e[70]!==o||e[71]!==Q){$e=Symbol.for("react.early_return_sentinel");e:{const _e=o("settings.agents.page.permissionsEditor.action.inherit"),nt=o("settings.agents.page.permissionsEditor.action.default");let Ue;e[81]!==ge?(Ue=st=>[...st?[{value:"inherit",label:st}]:[],...Lx.map(rt=>({value:rt,label:ge(rt)}))],e[81]=ge,e[82]=Ue):Ue=e[82];const Se=Ue,Ve=(st,rt,St,mt)=>{const Et=mt===void 0?_e:mt;return s.jsx(Wt,{value:st??"inherit",options:Se(Et),onChange:Pt=>rt(Pt==="inherit"?null:Pt),"aria-label":St})};if(v){let st;e[83]!==o?(st=o("settings.agents.page.section.toolPermissions"),e[83]=o,e[84]=st):st=e[84];let rt;e[85]!==o?(rt=o("common.loading"),e[85]=o,e[86]=rt):rt=e[86];let St;e[87]!==rt?(St=s.jsx("p",{className:zt,children:rt}),e[87]=rt,e[88]=St):St=e[88];let mt;e[89]!==st||e[90]!==St?(mt=s.jsx(Qe,{title:st,children:St}),e[89]=st,e[90]=St,e[91]=mt):mt=e[91],$e=mt;break e}if(b){let st;e[92]!==o?(st=o("settings.agents.page.section.toolPermissions"),e[92]=o,e[93]=st):st=e[93];let rt;e[94]!==o?(rt=o("settings.agents.page.permissionsEditor.state.loadFailed"),e[94]=o,e[95]=rt):rt=e[95];let St;e[96]!==rt?(St=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:rt}),e[96]=rt,e[97]=St):St=e[97];let mt;e[98]===Symbol.for("react.memo_cache_sentinel")?(mt=()=>I(sb),e[98]=mt):mt=e[98];let Et;e[99]!==o?(Et=o("settings.agents.page.permissionsEditor.actions.retry"),e[99]=o,e[100]=Et):Et=e[100];let Pt;e[101]!==Et?(Pt=s.jsx(G,{variant:"outline",size:"xs",onClick:mt,children:Et}),e[101]=Et,e[102]=Pt):Pt=e[102];let et;e[103]!==St||e[104]!==Pt?(et=s.jsxs("div",{className:"flex items-center gap-3",children:[St,Pt]}),e[103]=St,e[104]=Pt,e[105]=et):et=e[105];let yt;e[106]!==st||e[107]!==et?(yt=s.jsx(Qe,{title:st,children:et}),e[106]=st,e[107]=et,e[108]=yt):yt=e[108],$e=yt;break e}const Re=(st,rt,St)=>{const mt=f.keys[st]??Jx,Et=Gx.has(st)||mt.patterns.length>0,Pt=y[st]===true;return s.jsxs("div",{className:"border-t border-edge-muted py-2",children:[s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsxs("button",{type:"button",onClick:Et?()=>N(et=>({...et,[st]:!Pt})):void 0,className:He("flex min-w-0 items-center gap-1.5 text-start",!Et&&"cursor-default"),"aria-expanded":Et?Pt:void 0,children:[s.jsx(ae,{name:Pt&&Et?"arrow-down-s":"arrow-right-s",className:He("h-3.5 w-3.5 shrink-0 text-muted-foreground",!Et&&"opacity-0")}),s.jsx("span",{className:ls,children:rt}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground",children:st}),St&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:St}),mt.effect===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:ge(K(st))})}),mt.patterns.length>0&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:o("settings.agents.page.permissionsEditor.ruleCount",{count:String(mt.patterns.length)})})]}),Ve(mt.effect,et=>ue(st,et),o("settings.agents.page.permissionsEditor.keyAria",{key:st}))]}),Pt&&Et&&s.jsxs("div",{className:"mt-2 space-y-2 ps-5",children:[mt.patterns.map((et,yt)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Ze,{value:et.pattern,onChange:Tt=>Ae(st,yt,Tt.target.value,et.effect,false),placeholder:o("settings.agents.page.permissionsEditor.patternPlaceholder"),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:st}),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(Wt,{value:et.effect,options:Se(),onChange:Tt=>Ae(st,yt,et.pattern,Tt,true),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:st})}),s.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>xe(st,yt),"aria-label":o("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx(ae,{name:"close",className:"h-3.5 w-3.5"})})]},yt)),s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>te(st),children:[s.jsx(ae,{name:"add",className:"me-1 h-3.5 w-3.5"}),o("settings.agents.page.permissionsEditor.actions.addRule")]})]})]},st)};Ee=Qe,e[109]!==o?(Ce=o("settings.agents.page.section.toolPermissions"),e[109]=o,e[110]=Ce):Ce=e[110],ce="agents.permissions",e[111]!==o?(ye=o("settings.agents.page.permissionsEditor.sectionInfo"),e[111]=o,e[112]=ye):ye=e[112],Z="space-y-4";let Je;e[113]!==o?(Je=o("settings.agents.page.permissionsEditor.defaultLabel"),e[113]=o,e[114]=Je):Je=e[114];let ot;e[115]!==Je?(ot=s.jsx("span",{className:ls,children:Je}),e[115]=Je,e[116]=ot):ot=e[116];let wt;e[117]!==o?(wt=o("settings.agents.page.permissionsEditor.defaultInfo"),e[117]=o,e[118]=wt):wt=e[118];let bt;e[119]!==wt?(bt=s.jsx(cs,{children:wt}),e[119]=wt,e[120]=bt):bt=e[120];let me;e[121]!==ge||e[122]!==K||e[123]!==f.global||e[124]!==o?(me=f.global===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:ge(K("*"))})}),e[121]=ge,e[122]=K,e[123]=f.global,e[124]=o,e[125]=me):me=e[125];let dt;e[126]!==ot||e[127]!==bt||e[128]!==me?(dt=s.jsxs("div",{className:"flex items-center gap-1.5",children:[ot,bt,me]}),e[126]=ot,e[127]=bt,e[128]=me,e[129]=dt):dt=e[129];const vt=f.global;let Ke;e[130]!==o?(Ke=o("settings.agents.page.permissionsEditor.defaultAria"),e[130]=o,e[131]=Ke):Ke=e[131],fe=s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[dt,Ve(vt,le,Ke,nt)]}),Ne=s.jsx("div",{children:Q.map(st=>Re(st,Wx(st),null))}),Ie=B.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-edge-muted pt-3 pb-1",children:[s.jsx("span",{className:ls,children:o("settings.agents.page.permissionsEditor.mcpTitle")}),s.jsx(cs,{children:o("settings.agents.page.permissionsEditor.mcpInfo")})]}),B.map(st=>Re(st.key,st.server,X(st.server)))]})}e[57]=ge,e[58]=K,e[59]=y,e[60]=v,e[61]=b,e[62]=B,e[63]=X,e[64]=f.global,e[65]=f.keys,e[66]=xe,e[67]=le,e[68]=ue,e[69]=Ae,e[70]=o,e[71]=Q,e[72]=Ee,e[73]=Ce,e[74]=ce,e[75]=ye,e[76]=Z,e[77]=fe,e[78]=Ne,e[79]=Ie,e[80]=$e}else Ee=e[72],Ce=e[73],ce=e[74],ye=e[75],Z=e[76],fe=e[77],Ne=e[78],Ie=e[79],$e=e[80];if($e!==Symbol.for("react.early_return_sentinel"))return $e;let L;e[132]===Symbol.for("react.memo_cache_sentinel")?(L=_e=>P(_e.target.value),e[132]=L):L=e[132];let se;e[133]!==we?(se=_e=>{_e.key==="Enter"&&(_e.preventDefault(),we())},e[133]=we,e[134]=se):se=e[134];let de;e[135]!==o?(de=o("settings.agents.page.permissionsEditor.customKeyPlaceholder"),e[135]=o,e[136]=de):de=e[136];let je;e[137]!==S||e[138]!==se||e[139]!==de?(je=s.jsx(Ze,{value:S,onChange:L,onKeyDown:se,placeholder:de,className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),e[137]=S,e[138]=se,e[139]=de,e[140]=je):je=e[140];let De;e[141]!==S?(De=S.trim(),e[141]=S,e[142]=De):De=e[142];const We=!De;let Be;e[143]===Symbol.for("react.memo_cache_sentinel")?(Be=s.jsx(ae,{name:"add",className:"me-1 h-3.5 w-3.5"}),e[143]=Be):Be=e[143];let Ge;e[144]!==o?(Ge=o("settings.agents.page.permissionsEditor.actions.addKey"),e[144]=o,e[145]=Ge):Ge=e[145];let Xe;e[146]!==we||e[147]!==We||e[148]!==Ge?(Xe=s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:we,disabled:We,children:[Be,Ge]}),e[146]=we,e[147]=We,e[148]=Ge,e[149]=Xe):Xe=e[149];let tt;e[150]!==je||e[151]!==Xe?(tt=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-edge-muted pt-3",children:[je,Xe]}),e[150]=je,e[151]=Xe,e[152]=tt):tt=e[152];let it;return e[153]!==Ee||e[154]!==Ce||e[155]!==ce||e[156]!==ye||e[157]!==Z||e[158]!==fe||e[159]!==Ne||e[160]!==Ie||e[161]!==tt?(it=s.jsxs(Ee,{title:Ce,settingsItem:ce,info:ye,contentClassName:Z,children:[fe,Ne,Ie,tt]}),e[153]=Ee,e[154]=Ce,e[155]=ce,e[156]=ye,e[157]=Z,e[158]=fe,e[159]=Ne,e[160]=Ie,e[161]=tt,e[162]=it):it=e[162],it};function Yx(t){return t.updateAgent}function Zx(t){return t.fetchAgentPermissions}function Xx(t){return t.loadMcpConfigs}function eb(t){return{key:`${t.name}_*`,server:t.name}}function tb(t){return t.key}function sb(t){return t+1}const _r=t=>{const e=Fe.c(11),{legacy:n,path:a,className:i}=t,{t:o}=Oe();if(!n)return null;let l;e[0]!==i?(l=He("mb-4 flex items-start gap-1.5",zt,i),e[0]=i,e[1]=l):l=e[1];const r=a??void 0;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(ae,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 opacity-70"}),e[2]=c):c=e[2];let u;e[3]!==o?(u=o("settings.common.legacyFormat.note"),e[3]=o,e[4]=u):u=e[4];let d;e[5]!==u?(d=s.jsx("span",{children:u}),e[5]=u,e[6]=d):d=e[6];let p;return e[7]!==l||e[8]!==r||e[9]!==d?(p=s.jsxs("p",{className:l,title:r,children:[c,d]}),e[7]=l,e[8]=r,e[9]=d,e[10]=p):p=e[10],p},nb=(t,e)=>{const n=Tn(e);if(!n)return[];const a=t.find(o=>o.id===n.providerId),i=kh(a?.models,n.modelId);return ju(i)},ab=t=>Zp(t)?.toLowerCase()??"",ib=()=>{const{t}=Oe(),e=pt(ge=>ge.providers),{selectedAgentName:n,getAgentByName:a,createAgent:i,updateAgent:o,fetchAgentEntity:l,agentDraft:r,setAgentDraft:c,setSelectedAgent:u}=In($s(ge=>({selectedAgentName:ge.selectedAgentName,getAgentByName:ge.getAgentByName,createAgent:ge.createAgent,updateAgent:ge.updateAgent,fetchAgentEntity:ge.fetchAgentEntity,agentDraft:ge.agentDraft,setAgentDraft:ge.setAgentDraft,setSelectedAgent:ge.setSelectedAgent}))),d=en(),p=In(ge=>yu(ge,d)),m=n?a(n,d):null,f=!!(r&&r.name===n&&!m),h=f?"":m?.description?.trim()??"",v=f?"":m?.system?.trim()??"",[x,b]=g.useState(""),[k,j]=g.useState("user"),[y,N]=g.useState(""),[S,P]=g.useState("subagent"),[w,I]=g.useState(""),[C,A]=g.useState(""),[E,D]=g.useState(void 0),[M,O]=g.useState(void 0),[R,F]=g.useState(void 0),[T,_]=g.useState(""),[$,z]=g.useState(""),[H,q]=g.useState(false),[J,U]=g.useState(null),B=g.useRef({}),W=g.useRef(null),Q=g.useCallback(ge=>{W.current=ge},[]),ee=g.useRef(null),X=JSON.stringify([n,d,f]),ne=g.useRef(X);ne.current=X;const K=g.useRef(null),ie={description:y,mode:S,model:w,variant:C,steps:E,temperature:M,topP:R,system:T,color:$},le=g.useRef(ie);le.current=ie;const be=g.useMemo(()=>nb(e,w),[w,e]),ue=be.length>0,Pe=C||"__default",Ae=ue,re=g.useMemo(()=>C&&!be.includes(C)?[C,...be]:be,[C,be]);g.useEffect(()=>{if(!f||!r)return;K.current=null;const ge=Ni(r.model),Ee=r.name||"",Ce=r.scope||"user",ce=r.description||"",ye=r.mode||"subagent",Z=ge?`${ge.providerID}/${ge.modelID}`:"",fe=ge?.variant||"",Ne=r.steps??void 0,Ie=r.temperature??void 0,$e=r.top_p??void 0,L=r.system||"",se="";B.current={},U(null),b(Ee),j(Ce),N(ce),P(ye),I(Z),A(fe),D(Ne),O(Ie),F($e),_(L),z(se),ee.current={draftName:Ee,draftScope:Ce,description:ce,mode:ye,model:Z,variant:fe,steps:Ne,temperature:Ie,topP:$e,system:L,color:se}},[r,f]),g.useEffect(()=>{if(f||!n)return;let ge=false;return(async()=>{const Ee=await l(n,d);if(ge||ne.current!==X||!Ee)return;const Ce=Ee.config;B.current=Ce;const ce=Ni(Ce.model),ye=Ce.request?.body,Z={draftName:"",draftScope:"user",description:Ce.description||"",mode:Ce.mode||m?.mode||"subagent",model:ce?`${ce.providerID}/${ce.modelID}`:"",variant:ce?.variant||"",steps:Ce.steps??void 0,temperature:ye?.temperature,topP:ye?.top_p,system:Ce.system||"",color:ab(Ce.color)},fe=ee.current,Ne=le.current,Ie=fe!==null&&(Ne.description!==fe.description||Ne.mode!==fe.mode||Ne.model!==fe.model||Ne.variant!==fe.variant||Ne.steps!==fe.steps||Ne.temperature!==fe.temperature||Ne.topP!==fe.topP||Ne.system!==fe.system||Ne.color!==fe.color);U({legacy:Ee.legacy===true,path:Ee.path,source:Ee.source}),!(K.current===X&&Ie)&&(K.current=X,N(Z.description),P(Z.mode),I(Z.model),A(Z.variant),D(Z.steps),O(Z.temperature),F(Z.topP),_(Z.system),z(Z.color),ee.current=Z)})(),()=>{ge=true}},[l,f,m,n,d,X]);const te=g.useCallback(ge=>{const Ee=Tn(w.trim()),Ce=Ee?Gu({providerID:Ee.providerId,modelID:Ee.modelId,variant:C.trim()||void 0}):null,ce=B.current.request,ye={...ce?.body};M===void 0?delete ye.temperature:ye.temperature=M,R===void 0?delete ye.top_p:ye.top_p=R;const Z=ce?.headers,fe={};Z&&Object.keys(Z).length>0&&(fe.headers=Z),Object.keys(ye).length>0&&(fe.body=ye);const Ne=y.trim(),Ie=T.trim(),$e={name:ge,mode:S,model:Ce,steps:E??null,system:Ie||(f?void 0:null),request:Object.keys(fe).length>0?fe:null};return Ne&&($e.description=Ne),$!==(ee.current?.color??"")&&($e.color=$||null),f&&k&&($e.scope=k),f&&r?.hidden!==void 0&&($e.hidden=r.hidden),f&&r?.permissions?.length&&($e.permissions=r.permissions),$e},[r,$,y,k,f,S,w,E,T,M,R,C]),he=g.useCallback(async()=>{const ge=ee.current,Ee=n?.trim();if(f||!ge||!Ee)return Vs;const Ce=W.current?await W.current():Vs;if(y===ge.description&&S===ge.mode&&w===ge.model&&C===ge.variant&&E===ge.steps&&M===ge.temperature&&R===ge.topP&&T===ge.system&&$===ge.color||!Ce.ok)return Ce;const ye=te(Ee);return(await o(Ee,ye,d)).ok?(ne.current!==X||(B.current={...B.current,model:ye.model,system:ye.system??void 0,steps:ye.steps,request:ye.request??void 0},ee.current={...ge,description:y,mode:S,model:w,variant:C,steps:E,temperature:M,topP:R,system:T,color:$}),Mn):vs(t("settings.agents.page.toast.updateFailed"))},[te,$,y,f,S,w,n,X,d,E,T,t,M,R,o,C]),xe=ai(he),{requestSave:ke}=xe,we=async()=>{const ge=x.trim().replace(/\s+/g,"-");if(!ge){Y.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(p.some(Ee=>Ee.name===ge)){Y.error(t("settings.agents.sidebar.toast.agentExists"));return}q(true);try{(await i(te(ge),d)).ok?(c(null),Y.success(t("settings.agents.page.toast.created"))):Y.error(t("settings.agents.page.toast.createFailed"))}catch(Ee){console.error("Error creating agent:",Ee);const Ce=Ee instanceof Error&&Ee.message?Ee.message:t("settings.agents.page.toast.saveUnexpectedError");Y.error(Ce)}finally{q(false)}},Te=()=>{c(null),u(null)};return n?s.jsxs(ns,{title:f?t("settings.agents.page.title.new"):n,description:t(f?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit"),onBlurCapture:xe.onBlurCapture,children:[!f&&J&&s.jsx(_r,{legacy:J.legacy,path:J.path}),!f&&J?.source==="none"&&s.jsxs("p",{className:`mb-4 flex items-start gap-1.5 ${zt}`,children:[s.jsx(ae,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 opacity-70"}),s.jsx("span",{children:t("settings.agents.page.runtimeProvided.note")})]}),s.jsxs(Qe,{title:t("settings.agents.page.section.identityRole"),contentClassName:"space-y-3",children:[f&&s.jsxs(at,{settingsItem:"agents.name",label:t("settings.agents.page.field.agentName"),children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground me-1",children:"@"}),s.jsx(Ze,{value:x,onChange:ge=>b(ge.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Ot,{value:k,onValueChange:ge=>j(ge),children:[s.jsx(Dt,{className:"w-fit min-w-[100px]",children:s.jsx(_t,{children:t(k==="project"?"settings.common.scope.project":"settings.common.scope.global")})}),s.jsxs(Ft,{align:"end",children:[s.jsx(ht,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ae,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(ht,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ae,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsx(It,{label:t("settings.common.field.description"),controlClassName:"w-full max-w-none",children:s.jsx(Os,{value:y,onChange:ge=>N(ge.target.value),placeholder:h||t("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})}),s.jsx(It,{settingsItem:"agents.mode",label:t("settings.agents.page.field.mode"),info:t("settings.agents.page.field.modeTooltip"),children:s.jsx(Wt,{"aria-label":t("settings.agents.page.field.mode"),value:S,onChange:ge=>{P(ge),ke()},options:[{value:"primary",label:t("settings.agents.page.mode.primary")},{value:"subagent",label:t("settings.agents.page.mode.subagent")},{value:"all",label:t("settings.agents.page.mode.all")}]})}),s.jsx(It,{settingsItem:"agents.color",label:t("settings.agents.page.field.color"),info:t("settings.agents.page.field.colorTooltip"),children:s.jsx(L1,{value:$,labels:{empty:t("settings.agents.page.field.colorAutomatic"),swatch:ge=>t("settings.agents.page.field.colorSwatchAria",{color:ge}),custom:t("settings.agents.page.field.colorCustomAria"),hex:t("settings.agents.page.field.colorHexAria")},onChange:ge=>{z(ge),ke()}})})]}),s.jsxs(Qe,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx(at,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx($n,{providerId:Tn(w)?.providerId??"",modelId:Tn(w)?.modelId??"",onChange:(ge,Ee)=>{I(ge&&Ee?`${ge}/${Ee}`:""),A(""),ke()},className:xn})}),s.jsx(at,{settingsItem:"agents.variant",label:t("settings.agents.page.field.variant"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.variantTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.variantHint")})]}),children:Ae?s.jsxs(Ot,{value:Pe,onValueChange:ge=>{A(ge==="__default"?"":ge),ke()},children:[s.jsx(Dt,{className:Ss,children:s.jsx(_t,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:ge=>ge==="__default"?t("chat.modelControls.default"):ge})}),s.jsxs(Ft,{children:[s.jsx(ht,{value:"__default",children:t("chat.modelControls.default")}),re.map(ge=>s.jsx(ht,{value:ge,children:ge},ge))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ze,{value:C,onChange:ge=>A(ge.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!w&&!C,className:"h-8 w-40 rounded-md px-3"}),C&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{A(""),ke()},className:ss,"aria-label":t("settings.common.actions.clear"),title:t("settings.common.actions.clear"),children:s.jsx(ae,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsxs(at,{settingsItem:"agents.temperature",label:t("settings.agents.page.field.temperature"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.temperatureTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.temperatureRange")})]}),children:[s.jsx(hs,{value:M,fallbackValue:.7,onValueChange:O,onClear:()=>{O(void 0),ke()},min:0,max:2,step:.1,inputMode:"decimal",placeholder:"\u2014",emptyLabel:"\u2014",className:xs}),M!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{O(void 0),ke()},className:ss,"aria-label":t("settings.agents.page.field.clearTemperatureAria"),title:t("settings.common.actions.clear"),children:s.jsx(ae,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(at,{settingsItem:"agents.top-p",label:t("settings.agents.page.field.topP"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.topPTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.topPRange")})]}),children:[s.jsx(hs,{value:R,fallbackValue:.9,onValueChange:F,onClear:()=>{F(void 0),ke()},min:0,max:1,step:.1,inputMode:"decimal",placeholder:"\u2014",emptyLabel:"\u2014",className:xs}),R!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{F(void 0),ke()},className:ss,"aria-label":t("settings.agents.page.field.clearTopPAria"),title:t("settings.common.actions.clear"),children:s.jsx(ae,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(at,{settingsItem:"agents.steps",label:t("settings.agents.page.field.steps"),info:t("settings.agents.page.field.stepsTooltip"),children:[s.jsx(hs,{value:E,fallbackValue:20,onValueChange:D,onClear:()=>{D(void 0),ke()},min:1,max:1e3,step:1,inputMode:"numeric",placeholder:"\u2014",emptyLabel:"\u2014",className:xs}),E!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{D(void 0),ke()},className:ss,"aria-label":t("settings.agents.page.field.clearStepsAria"),title:t("settings.common.actions.clear"),children:s.jsx(ae,{name:"close",className:"h-3.5 w-3.5"})})]})]}),s.jsx(Qe,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx(Os,{value:T,onChange:ge=>_(ge.target.value),placeholder:v||t("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent"})}),!f&&m&&s.jsx(Qx,{agent:m,registerSave:Q,requestSave:ke}),f&&s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[s.jsx(G,{onClick:()=>{we()},disabled:H||!x.trim(),size:"xs",className:"!font-normal",children:t(H?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(G,{variant:"ghost",onClick:Te,disabled:H,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(ae,{name:"robot-2",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-ui-label",children:t("settings.agents.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.agents.page.empty.description")})]})})};function ob(t,e){return t.kind==="file"?t.content:e??""}const Vc=es({content:At(),exists:Hi(),path:At().min(1).optional()}),lb=async(t,e)=>{const n=await t.json().catch(()=>null);return typeof n?.error=="string"&&n.error.trim()?n.error:e},rb=t=>t.length>0&&!t.endsWith(`
2
+ import{R as g,j as s,f as Fe,r as Ye}from"./vendor-react--VO_rL_p.js";import{u as $s,c as Go}from"./vendor-zustand-C9tWdk0j.js";import{u as Oe,I as ae,b0 as Ps,oo as at,aO as Qe,op as yn,x as ua,P as Us,aq as Wp,B as G,ah as Wt,z as Cn,A as Y,oq as sc,n as ys,or as vu,bb as Va,Z as nn,bl as ma,a3 as Jo,a2 as He,bv as Gp,dS as So,dY as Jp,aY as _t,aX as Dt,a_ as ht,aZ as Ft,aW as Ot,y as Ze,os as In,ot as yu,ou as Qp,fh as To,ov as nc,ow as Yp,ox as Si,t as Ut,q as Kt,D as qt,l as Bt,F as Vt,o as as,oy as hr,a7 as pa,a8 as ra,bg as Ta,bh as ca,a6 as ga,a5 as fa,bf as Ra,be as Ma,lU as Pn,lV as gn,oz as ls,dJ as cs,oA as xr,hN as zt,V as pt,fE as It,aT as Os,fG as $n,oB as xn,oC as Ss,oD as ss,aj as hs,oE as xs,oF as ju,oG as Zp,oH as ut,oI as ku,oJ as Xp,oK as eg,oL as Ei,oM as tg,f4 as Dn,oN as zs,eX as Qa,lX as _s,oO as Ha,oP as wu,oQ as br,fH as vr,ac as oa,oR as Kl,oS as sg,oT as ac,oU as ng,oV as ag,l_ as ig,oW as og,eu as Qo,oX as ic,hV as Ea,lW as $t,R as yr,oY as jr,oZ as ia,o_ as Su,o$ as bn,p0 as Nu,p1 as kr,lY as Nn,hH as wa,p2 as lg,mt as Li,C as da,ce as oc,dv as rg,co as cg,dC as dg,bd as ug,fL as mg,cU as pg,fM as gg,K as Yo,p3 as Jt,bS as ti,h0 as Ti,mT as Cu,p4 as fg,p5 as hg,dO as xg,p6 as bg,ay as Da,dQ as An,p7 as Iu,p8 as vg,hX as Bs,p9 as wr,pa as wn,pb as Ro,pc as yg,pd as jg,pe as kg,pf as wg,pg as Sg,ph as Ng,pi as Cg,pj as Pu,pk as Ig,pl as Pg,pm as Au,pn as Ag,po as Eu,pp as Tu,pq as Zo,kr as bs,pr as Ru,ks as Mu,ko as Du,gg as Eg,kp as Tg,kq as Fu,lA as Rg,ps as Ou,pt as Mg,pu as Dg,pv as Fg,pw as lc,dN as Lu,px as Og,py as Lg,pz as _g,pA as $g,pB as Ug,pC as _u,pD as Kg,pE as zg,pF as Bg,pG as Vg,pH as Hg,pI as qg,pJ as Ya,pK as Wg,pL as Gg,pM as $u,pN as Jg,pO as Ns,hW as En,cs as Fs,ct as Xo,pP as Qg,mu as Uu,hI as Yg,hS as Zg,iD as Xg,pQ as ef,pR as tf,f2 as el,d9 as _i,f3 as $i,dW as sf,dX as rl,dV as nf,lE as Ku,pS as cl,pT as af,pU as of,pV as lf,pW as rf,pX as cf,pY as df,pZ as uf,p_ as mf,bo as Ts,p$ as Sr,lZ as Js,dk as Nr,q0 as cn,ms as pf,q1 as Ia,fb as gf,q2 as Mo,q3 as ka,je as ff,q4 as hf,q5 as xf,hO as bf,q6 as vf,q7 as yf,q8 as Qs,q9 as Ks,qa as ja,qb as Un,qc as rc,qd as No,qe as jf,ao as kf,qf as zu,qg as Sa,qh as wf,qi as Sf,qj as Nf,qk as Cf,k as Bu,d_ as If,lv as Pf,ql as ba,qm as Sn,qn as _n,qo as Af,qp as Ef,qq as Tf,qr as Rf,qs as dl,qt as cc,qu as Mf,qv as Df,qw as Ff,qx as Of,qy as Lf,qz as dc,qA as ci,qB as uc,qC as Cr,qD as _f,a0 as $f,ck as mc,qE as Uf,fD as Vu,qF as Za,qG as Kf,qH as zf,qI as ul,qJ as pc,qK as Bf,qL as Ir,f as Kn,h as Pa,qM as gc,qN as Vf,qO as Hf,qP as qf,qQ as Ui,qR as Wf,qS as Gf,az as vn,qT as Jf,hq as Qf,qU as Yf,qV as Zf,qW as Pr,m1 as fn,qX as Xf,f9 as eh,lo as th,aC as sh,qY as nh,qZ as ml,q_ as ah,eU as ih,q$ as oh,l7 as zl,f5 as lh,f6 as rh,r0 as ch,r1 as dh,r2 as di,r3 as uh,aD as mh,r4 as ph,eC as fc,r5 as pl,l8 as gh,eB as fh,cn as va,f7 as hh,ae as xh,af as bh,f8 as vh}from"./useAppFontEffects-BDLOJuy5.js";import{j as Gt,cL as Na,cM as Hu,bv as qu,cN as yh,bt as Wu,aX as Zs,cO as jh,M as kt,u as oe,m as os,cP as Ri,cQ as Ni,cR as Tn,cS as Gu,cT as kh,v as Ys,cU as hc,cV as wh,ar as Fa,W as Qt,bY as Ar,b7 as Sh,aA as rs,_ as Oa,aR as gl,aU as xc,aS as bc,a_ as ui,bF as Nh,cW as Ch,bB as Ih,a$ as na,cX as Ph,cw as vc,aT as Ah,cY as Eh,cZ as Th,bx as yc,bj as Ki,cA as Rh,c_ as Mh,c$ as Ju,d0 as Mt,d1 as Dh,d2 as Fh,d3 as Bl,d4 as Oh,d5 as Lh,a6 as zi,bf as _h,bg as $h,b9 as Er,ap as Tr,bd as Uh,b6 as Kh,ae as tl,bM as Aa,d6 as Qu,as as Yu,d7 as zh,d8 as Bh,be as Do,d9 as Zu,da as za,db as Vh,dc as Hh,aZ as Rr,k as qh,dd as Wh,w as Fo,aD as Gh,aB as Ci,de as Jh,df as ea,dg as jc,dh as kc,di as wc,dj as Sc,dk as Qh,dl as Nc,dm as Cc,Q as Xu,dn as Bi,dp as Yh,X as Ic,dq as Zh,dr as Xh,r as Vl,ds as e1,dt as Pc,du as t1,b as s1,dv as n1,dw as a1,dx as i1,dy as o1,dz as l1,aV as em,dA as tm,dB as r1,dC as Hl,dD as c1,dE as d1,dF as u1,dG as m1,dH as p1,dI as g1,dJ as f1,dK as sm,dL as ql,dM as Ac,dN as h1,dO as Ec,dP as lo,dQ as x1,dR as b1,dS as v1,dT as y1,bQ as j1,bL as k1,bI as w1,af as Tc,bk as S1,dU as N1,dV as C1,dW as I1,dX as P1}from"./katex.min-DklPh68d.js";import{cP as Rc,cQ as A1,cR as E1,aV as T1,cS as R1,cI as fl,cJ as M1,cT as D1,cU as F1,cV as O1,cW as ns,cX as L1,cY as si,cZ as Rs,c_ as Mi,c$ as Rn,d0 as Xa,d1 as Vi,d2 as Mr,d3 as ei,a6 as zn,a4 as Bn,a5 as Vn,d4 as Wl,d5 as _1,cq as Ls,d6 as $1,d7 as nm,d8 as U1,d9 as Gl,cA as Mc,cG as K1,cB as am,da as z1,db as B1,dc as V1,cp as H1,dd as q1,de as W1}from"./ReceivedPagePanel-CfXyzCii.js";import{o as es,s as At,e as Hi,l as im,c as Xs,n as Di,a as la,h as Fi,_ as Dr,u as Oo}from"./vendor-zod-DV_WH382.js";import{n as G1,M as om,r as J1,a as Q1,u as lm,i as rm,s as cm,b as Y1,c as Z1}from"./install-DY6TBn2e.js";import{s as X1,c as ex}from"./vendor-yaml-CE-D_49-.js";import{c as Dc,C as Fc,p as tx}from"./flexokiTheme-CcqiI7j-.js";import{u as sx}from"./vendor-tanstack-react-virtual-Bw3q1rnq.js";import{m as nx}from"./vendor-tanstack-virtual-core-B4TJYmIq.js";import{c as ax}from"./codeHighlight-Bmb7zcc2.js";import{getCodeTokenTheme as ix}from"./appThemeRegistry-C4Av1s90.js";import{E as Oc}from"./vendor-codemirror-view-Ciie9ey-.js";import{Q as dm}from"./vendor-qrcode-Cl8OheHW.js";import{u as Lc}from"./install-request-CzRei4tp.js";import{toast as qa}from"./vendor-sonner-Dw26OnzC.js";import{s as ox}from"./vendor-strip-json-comments-5dJlOkP1.js";import{u as lx}from"./useCallableModelProviders-aGFpVUZL.js";import{S as Fr,f as Lo}from"./SpaceRow-CsS43yrt.js";import{_ as rx}from"./vendor-vite-runtime-DD1OZmLC.js";import{A as _c}from"./AboutLogo-cbKkZDLU.js";import{s as cx}from"./pageTitle-BT3-HFbv.js";const $c=({label:t})=>{const{t:e}=Oe(),[n,a]=g.useState(null);g.useEffect(()=>{let l=false;const r=typeof AbortController<"u"?new AbortController:void 0;return(async()=>{try{const u=await Gt("/api/system/info",{signal:r?.signal,headers:{Accept:"application/json"}});if(!u.ok)return;const d=await u.json().catch(()=>null);if(!d||l)return;const p=typeof d.port=="number"&&Number.isFinite(d.port)&&d.port>0?d.port:null,m=typeof d.tunnelUrl=="string"&&d.tunnelUrl.trim().length>0?d.tunnelUrl.trim():null;a({port:p,tunnelUrl:m})}catch{}})(),()=>{l=true,r?.abort()}},[]);const i=[];if(n?.port!==null&&n?.port!==void 0&&i.push({key:"application",label:e("settings.openchamber.about.field.applicationUrl"),url:`http://localhost:${n.port}/`}),n?.tunnelUrl&&i.push({key:"tunnel",label:e("settings.openchamber.about.field.tunnelUrl"),url:n.tunnelUrl}),i.length===0)return null;const o=s.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1",children:i.map(l=>s.jsxs("button",{type:"button",title:l.label,className:"inline-flex max-w-full items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground",onClick:()=>{Ps(l.url)},children:[s.jsx("span",{className:"max-w-64 truncate font-mono",children:l.url}),s.jsx(ae,{name:"external-link",className:"size-3.5 shrink-0"})]},l.key))});return t?s.jsx(at,{label:t,controlClassName:"min-h-8",children:o}):o},dx="https://github.com/openchamber/openchamber/releases",ux=t=>{const e=Fe.c(8),{release:n,label:a}=t;let i;e[0]!==a?(i=a&&s.jsxs("div",{className:"mb-3 flex items-center gap-3",children:[s.jsx("span",{className:"typography-ui-label rounded bg-[var(--primary-base)]/10 px-1.5 py-0.5 font-mono text-[var(--primary-base)]",children:a.version}),a.date&&s.jsx("span",{className:"typography-meta text-muted-foreground",children:a.date})]}),e[0]=a,e[1]=i):i=e[1];const o=a!==null;let l;e[2]!==n||e[3]!==o?(l=s.jsx(A1,{notes:n,folded:o}),e[2]=n,e[3]=o,e[4]=l):l=e[4];let r;return e[5]!==i||e[6]!==l?(r=s.jsxs("div",{className:"oc-tile rounded-lg p-4",children:[i,l]}),e[5]=i,e[6]=l,e[7]=r):r=e[7],r},mx=t=>{const e=Fe.c(23),{version:n,since:a,describeVersion:i}=t,{t:o}=Oe(),[l,r]=g.useState(null),c=`${a??""}>${n}`;let u,d;e[0]!==c||e[1]!==a||e[2]!==n?(u=()=>{const f=new AbortController;return E1(n,a,f.signal).then(h=>{f.signal.aborted||r(h?{key:c,releases:h}:null)}),()=>f.abort()},d=[n,a,c],e[0]=c,e[1]=a,e[2]=n,e[3]=u,e[4]=d):(u=e[3],d=e[4]),g.useEffect(u,d);let p,m;if(e[5]!==i||e[6]!==l||e[7]!==c||e[8]!==a||e[9]!==o||e[10]!==n){m=Symbol.for("react.early_return_sentinel");e:{const f=l?.key===c?l.releases:[];if(f.length===0){m=null;break e}const h=f.length===1?f[0]:null,v=h&&!a&&!Na(h.version),x=f.map(px),b=(S,P)=>{const w=x[P];if(!w)return{version:`v${S.version}`,date:Rc(S.date)};const I=x.find((C,A)=>A!==P&&C?.builtOn.getTime()===w.builtOn.getTime());return{version:o("updateDialog.canary.night",{date:Hu(w,ua(),I)}),date:null}};let k;e[13]!==i||e[14]!==a||e[15]!==o||e[16]!==n?(k=a?o("settings.openchamber.about.releaseNotes.since",{version:i(a,n)}):o("settings.openchamber.about.releaseNotes.current",{version:i(n)}),e[13]=i,e[14]=a,e[15]=o,e[16]=n,e[17]=k):k=e[17];let j;e[18]!==o?(j=o("settings.openchamber.about.releaseNotes.allReleases"),e[18]=o,e[19]=j):j=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(ae,{name:"external-link",className:"size-3.5"}),e[20]=y):y=e[20];let N;e[21]!==j?(N=s.jsxs("a",{href:dx,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground",children:[j,y]}),e[21]=j,e[22]=N):N=e[22],p=s.jsx(Qe,{title:s.jsxs("h2",{className:yn,children:[k,v&&s.jsxs("span",{className:"typography-meta whitespace-nowrap text-muted-foreground",children:[" \xB7 ",Rc(h.date)]})]}),headerAction:N,contentClassName:"space-y-2",children:f.map((S,P)=>s.jsx(ux,{release:S,label:a?b(S,P):null},S.version))})}e[5]=i,e[6]=l,e[7]=c,e[8]=a,e[9]=o,e[10]=n,e[11]=p,e[12]=m}else p=e[11],m=e[12];return m!==Symbol.for("react.early_return_sentinel")?m:p};function px(t){return Na(t.version)}const Uc="https://github.com/openchamber/openchamber",Kc="https://discord.gg/ZYRSdnwwKA",zc="https://x.com/openchamber_dev",gx=800,fx=async t=>{const e=await Zs();return e?e.serverUpdateChannel??(Na(t)?"canary":"stable"):null},hx={info:null,checking:false,available:false,error:null};function xx(t){const e=Fe.c(5),[n,a]=g.useState(hx);let i;e[0]!==t?(i=async()=>{if(t){a(bx);try{const r=await M1();a({info:r,checking:false,available:r.available,error:null})}catch(r){const c=r;a({info:null,checking:false,available:false,error:c instanceof Error?D1(c):String(c)})}}},e[0]=t,e[1]=i):i=e[1];const o=i;let l;return e[2]!==o||e[3]!==n?(l={...n,check:o},e[2]=o,e[3]=n,e[4]=l):l=e[4],l}function bx(t){return{...t,checking:true,error:null}}function vx(t){const e=Fe.c(11),[n,a]=g.useState(null);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={kind:"idle"},e[0]=i):i=e[0];const[o,l]=g.useState(i);let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=async()=>{try{const x=await F1();return a(x),x}catch{return null}},e[1]=r):r=e[1];const c=r;let u,d;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{c()},d=[c],e[2]=u,e[3]=d):(u=e[2],d=e[3]),g.useEffect(u,d);let p;e[4]!==t?(p=async()=>{l({kind:"upgrading"});try{const x=await O1(t);l({kind:"installed",version:x})}catch(x){const b=x;l({kind:"failed",error:b instanceof Error?b.message:t})}},e[4]=t,e[5]=p):p=e[5];const m=p;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=async x=>{await x().catch(yx);const b=await c();b?.currentVersion&&l(k=>k.kind!=="installed"||k.version&&k.version.replace(/^v/,"")!==b.currentVersion?k:{kind:"idle"})},e[6]=f):f=e[6];const h=f;let v;return e[7]!==o||e[8]!==n||e[9]!==m?(v={status:n,phase:o,refresh:c,upgrade:m,reloadAfterUpgrade:h},e[7]=o,e[8]=n,e[9]=m,e[10]=v):v=e[10],v}function yx(){}function jx(t){const[e,n]=g.useState(null);return g.useEffect(()=>{if(!t)return;let a=false;return rx(async()=>{const{App:i}=await import("./vendor-capacitor-app-BrDJj9I_.js");return{App:i}},__vite__mapDeps([0,1,2])).then(({App:i})=>i.getInfo()).then(i=>{a||n(i.version.trim()||null)}).catch(()=>{}),()=>{a=true}},[t]),e}const kx=({initialUpdateDialogOpen:t=false})=>{const{t:e}=Oe(),[n,a]=g.useState(t),[i,o]=g.useState(false),[l,r]=g.useState(null),c=T1($s(se=>({info:se.info,checking:se.checking,available:se.available,error:se.error,downloading:se.downloading,downloaded:se.downloaded,installing:se.installing,progress:se.progress,runtimeType:se.runtimeType,checkForUpdates:se.checkForUpdates,downloadUpdate:se.downloadUpdate,restartToUpdate:se.restartToUpdate}))),{isMobile:u}=Us(),d=g.useMemo(()=>qu(),[]),p=R1(),m=xx(d||p),f=p?m:null,h=m.check;g.useEffect(()=>{p&&h()},[p,h]);const[v,x]=g.useState(false),[b,k]=g.useState(null);g.useEffect(()=>{if(!p)return;let se=false;return Wp().then(de=>{se||k(de)}),()=>{se=true}},[p]);const j=jx(d),y=d?{info:m.info,checking:m.checking,available:m.available,error:m.error,checkForUpdates:m.check,runtimeType:"web"}:{info:c.info,checking:c.checking,available:c.available,error:c.error,checkForUpdates:c.checkForUpdates,runtimeType:c.runtimeType},N=(se,de)=>{const je=Na(se);return je?e("settings.openchamber.about.canaryVersion",{version:je.release,date:Hu(je,ua(),Na(de))}):se},S=y.available?y.info?.version:null,P=N(l||y.info?.currentVersion||"unknown",S),w=N(b||c.info?.currentVersion||"unknown",S),I=l||f?.info?.currentVersion||"unknown",C=p?b||c.info?.currentVersion:l||y.info?.currentVersion,A=!!(S&&Na(C)&&!Na(S)),E=C?s.jsx(mx,{version:S||C,since:S&&!A?C:null,describeVersion:N}):null,D=c.runtimeType==="desktop",[M,O]=g.useState(false),R=c.runtimeType==="web"&&M&&l!==null,[F,T]=g.useState(null);g.useEffect(()=>{if(!D&&!R)return;let se=false;return(D?yh():fx(l??"")).then(je=>{se||T(je)}),()=>{se=true}},[D,R,l]);const _=vx(e("opencodeUpdate.toast.failed.description")),$=_.status?.currentVersion??null,z=_.phase.kind==="installed"?null:_.status?.availableVersion??null,[H,q]=g.useState(false),J=se=>{const de=N(se?.version||"",se?.currentVersion);return se?.packageManager==="electron"?e("settings.openchamber.about.actions.updateDesktopToVersion",{version:de}):e("settings.openchamber.about.actions.updateServerToVersion",{version:de})},U=(()=>{const se=N(y.info?.version||"",y.info?.currentVersion);return d?J(y.info):p?e("settings.openchamber.about.actions.updateAppToVersion",{version:se}):e("settings.openchamber.about.actions.updateOpenChamberToVersion",{version:se})})(),B=se=>se?.installBlocked==="opencode-version",W=se=>!!se?.installBlocked&&!B(se),Q=y.available&&W(y.info),ee=d&&Wu()==="android",X=ee&&c.runtimeType==="mobile"&&c.available?c.info?.downloadUrl??null:null,ne=X?s.jsxs(G,{type:"button",size:"sm",variant:"outline",onClick:()=>{Ps(X)},children:[s.jsx(ae,{name:"download",className:"size-4"}),e("settings.openchamber.about.actions.downloadAppVersion",{version:N(c.info?.version||"",j)})]}):null,K=async se=>{if(se===F)return;const de=F;if(T(se),!(D?await jh(se)===se:(await kt({serverUpdateChannel:se})).ok)){T(de),Y.error(e("settings.openchamber.about.toast.updateChannelNotSaved"));return}y.checkForUpdates()},le=F&&s.jsx(Wt,{value:F,onChange:se=>{K(se)},"aria-label":e("settings.openchamber.about.field.updateChannel"),className:"flex-nowrap",options:[{value:"stable",label:e("settings.openchamber.about.option.updateChannel.stable")},{value:"canary",label:e("settings.openchamber.about.option.updateChannel.canary"),selectedClassName:"bg-[var(--brand-canary)] text-[var(--brand-canary-foreground)] hover:bg-[var(--brand-canary)] hover:text-[var(--brand-canary-foreground)]"}]}),be=()=>{y.checkForUpdates(),f&&f.check(),ee&&c.checkForUpdates(),_.refresh()},ue=async se=>{(await Va(se)).ok&&(q(true),setTimeout(()=>q(false),2e3))},Pe=()=>{_.reloadAfterUpgrade(async()=>{await vu({message:e("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]})}).then(()=>{y.checkForUpdates(),f&&f.check()})},Ae=se=>{if(se?.installBlocked==="opencode-version")return s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:e("updateDialog.openCodeTooOld",{version:N(se.version||""),required:se.requiredOpenCodeVersion||"",current:se.openCodeVersion||""})});if(se?.installBlocked==="desktop-host")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:se.version||""})});if(se?.installBlocked==="manual-install")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.manualInstallUpdate",{version:N(se.version||"")})});const de=se?.updateCommand||"openchamber update";return s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.serviceManagerUpdate",{version:N(se?.version||"")})}),s.jsxs("div",{className:"flex items-center gap-2 oc-tile-inset rounded-md p-1 ps-3",children:[s.jsx(ys,{as:"code",outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-w-0",fillContainer:false,className:"whitespace-nowrap font-mono text-sm text-foreground",children:de}),s.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{ue(de)},"aria-label":e(H?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:s.jsx(ae,{name:H?"check":"clipboard",className:"size-4"})})]})]})},re=y.available&&y.info?.installBlocked?Ae(y.info):null,te=!!(f?.available&&!f.checking),he=te&&f?.info?.installBlocked?Ae(f.info):null,xe=te&&!W(f?.info??null)?s.jsxs(G,{type:"button",size:"sm",variant:"outline",onClick:()=>x(true),disabled:B(f?.info??null),children:[s.jsx(ae,{name:"download",className:"size-4"}),J(f?.info??null)]}):null,ke=f?s.jsx(fl,{open:v,onOpenChange:x,info:f.info,downloading:false,downloaded:false,progress:null,error:f.error,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"}):null,we=(()=>{const{phase:se}=_;if(se.kind==="installed")return{action:s.jsx(G,{type:"button",size:"sm",variant:"outline",onClick:Pe,children:e("opencodeUpdate.toast.actions.reload")}),note:s.jsx("p",{className:"typography-meta text-muted-foreground",children:se.version?e("settings.openchamber.about.openCode.installedVersion",{version:se.version}):e("settings.openchamber.about.openCode.installed")})};if(!z)return null;if(!_.status?.supported)return{action:null,note:s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.openCode.manualUpdate",{version:z})})};const de=se.kind==="upgrading";return{action:s.jsxs(G,{type:"button",size:"sm",variant:"outline",onClick:()=>{_.upgrade()},disabled:de,children:[de?s.jsx(Cn,{className:"size-4"}):s.jsx(ae,{name:"download",className:"size-4"}),de?e("opencodeUpdate.toast.upgrading.title"):e("settings.openchamber.about.actions.updateOpenCodeToVersion",{version:z})]}),note:se.kind==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:se.error}):null}})(),Te=we?s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[we.note,we.action]}):null;g.useEffect(()=>{let se=false;return(async()=>{try{const je=await Gt("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!je.ok)return;const De=await je.json().catch(()=>null),We=typeof De?.openchamberVersion=="string"&&De.openchamberVersion.trim().length>0?De.openchamberVersion.trim():null;se||(r(We),O(De?.runtime==="web"))}catch{se||r(null)}})(),()=>{se=true}},[]);const ge=f?.checking??false,Ee=f?.available??false,Ce=g.useRef(false),ce=ee&&c.checking,ye=!!X;g.useEffect(()=>{if(y.checking)o(true),Ce.current=true;else if(i&&!ce){const se=setTimeout(()=>{o(false);const de=ge||Ee;Ce.current&&!y.available&&!y.error&&!de&&(Y.success(e(ye?"settings.openchamber.about.toast.serverLatestAppUpdate":d?"settings.openchamber.about.toast.serverLatestVersion":"settings.openchamber.about.toast.latestVersion")),Ce.current=false)},gx);return()=>clearTimeout(se)}},[e,d,y.checking,i,y.available,y.error,ge,Ee,ce,ye]);const Z=y.checking||i;if(u)return s.jsxs("div",{className:"w-full space-y-6 pb-2",children:[s.jsxs("div",{className:"flex flex-col items-center text-center",children:[s.jsx(_c,{size:72}),s.jsx("h2",{className:`mt-4 ${sc}`,children:"OpenChamber"}),s.jsx("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:d?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:P})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:$||e("settings.openchamber.about.state.unknown")})}),j&&s.jsx("p",{children:e("settings.openchamber.about.native.appVersion",{version:j})})]}):p?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.appVersionLabel",{version:w})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:I})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:$||e("settings.openchamber.about.state.unknown")})})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:P})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:$||e("settings.openchamber.about.state.unknown")})})]})}),s.jsx($c,{})]}),le&&s.jsx("div",{className:"flex justify-center",children:le}),s.jsxs("div",{className:"flex justify-center",children:[!y.available&&!y.error&&s.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:be,disabled:Z,className:"w-auto justify-center gap-2",children:[Z?s.jsx(Cn,{className:"size-4"}):s.jsx(ae,{name:"refresh",className:"size-4"}),e(Z?"settings.openchamber.about.state.checking":d&&!ee?"settings.openchamber.about.actions.checkServerForUpdates":"settings.openchamber.about.actions.checkForUpdates")]}),!Z&&y.available&&!Q&&s.jsxs(G,{type:"button",variant:"default",size:"sm",onClick:()=>a(true),disabled:B(y.info),className:"w-auto justify-center gap-2",children:[s.jsx(ae,{name:"download",className:"size-4"}),U]})]}),ne&&s.jsx("div",{className:"flex justify-center",children:ne}),re,(xe||he)&&s.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[xe,he]}),Te&&s.jsx("div",{className:"flex justify-center text-center",children:Te}),[y.error,f?.error].filter(Boolean).map(se=>s.jsx("p",{className:"rounded-xl bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:se},se)),s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsxs("div",{className:"flex items-center justify-center gap-5",children:[s.jsxs("a",{href:Uc,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(ae,{name:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:Kc,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(ae,{name:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:zc,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(ae,{name:"twitter-xfill",className:"size-5"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"text-center typography-ui text-muted-foreground",children:e("aboutDialog.footerNote")}),E,s.jsx(fl,{open:n,onOpenChange:a,info:y.info,downloading:c.downloading,downloaded:c.downloaded,installing:c.installing,progress:c.progress,error:y.error,onDownload:c.downloadUpdate,onRestart:c.restartToUpdate,runtimeType:y.runtimeType}),ke]});const fe=s.jsx("span",{"aria-hidden":"true",className:"typography-meta text-muted-foreground/60",children:"\xB7"}),Ne=Z?s.jsxs(s.Fragment,{children:[fe,s.jsxs("span",{className:"flex items-center gap-1.5 typography-meta text-muted-foreground",children:[s.jsx(Cn,{className:"size-4"}),e("settings.openchamber.about.state.checking")]})]}):y.available&&!Q?s.jsxs(G,{size:"sm",variant:"default",onClick:()=>a(true),disabled:B(y.info),children:[s.jsx(ae,{name:"download",className:"size-4"}),U]}):!y.available&&!y.error?s.jsxs(s.Fragment,{children:[fe,s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")})]}):null,Ie=se=>s.jsx("span",{className:"typography-meta font-mono text-muted-foreground",children:se}),$e="min-h-8 flex-wrap @xl:flex-initial",L=[re,he,we?.note??null,...[y.error,f?.error].filter(Boolean).map(se=>s.jsx("p",{className:"rounded-lg bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:se},se))].filter(Boolean);return s.jsxs(s.Fragment,{children:[s.jsx(Qe,{children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(_c,{size:48}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("h2",{className:sc,children:"OpenChamber"}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[{href:Uc,icon:"github-fill",label:"GitHub"},{href:Kc,icon:"discord-fill",label:"Discord"},{href:zc,icon:"twitter-xfill",label:"@openchamber_dev"}].map(se=>s.jsxs("a",{href:se.href,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(ae,{name:se.icon,className:"size-4"}),s.jsx("span",{children:se.label})]},se.href))})]})]})}),s.jsxs(Qe,{contentClassName:"space-y-4",children:[s.jsxs("div",{children:[p?s.jsxs(s.Fragment,{children:[s.jsxs(at,{label:e("settings.openchamber.about.field.appVersion"),controlClassName:$e,children:[Ie(w),Ne]}),s.jsxs(at,{label:e("settings.openchamber.about.field.serverVersion"),controlClassName:$e,children:[Ie(I),xe]})]}):d?s.jsxs(s.Fragment,{children:[j&&s.jsxs(at,{label:e("settings.openchamber.about.field.appVersion"),controlClassName:$e,children:[Ie(N(j,c.info?.version)),ne]}),s.jsxs(at,{label:e("settings.openchamber.about.field.serverVersion"),controlClassName:$e,children:[Ie(P),Ne]})]}):s.jsxs(at,{label:e("settings.openchamber.about.field.version"),controlClassName:$e,children:[Ie(P),Ne]}),s.jsxs(at,{label:e("settings.openchamber.about.field.updateChannel"),info:le?e("settings.openchamber.about.field.updateChannelHint"):void 0,controlClassName:$e,children:[le,s.jsx(G,{size:"sm",variant:"outline",onClick:be,disabled:Z,children:e("settings.openchamber.about.actions.checkForUpdates")})]}),s.jsxs(at,{label:e("settings.openchamber.about.field.openCodeVersion"),controlClassName:$e,children:[Ie($||e("settings.openchamber.about.state.unknown")),we?.action]}),s.jsx($c,{label:e("settings.openchamber.about.field.instanceUrls")})]}),L.length>0&&s.jsx("div",{className:"space-y-3",children:L})]}),E,s.jsx(fl,{open:n,onOpenChange:a,info:y.info,downloading:c.downloading,downloaded:c.downloaded,installing:c.installing,progress:c.progress,error:y.error,onDownload:c.downloadUpdate,onRestart:c.restartToUpdate,runtimeType:y.runtimeType}),ke]})},wx=(t,e,n)=>t&&e.some(i=>i.path===t)?t:(e.find(i=>i.id===n)??e[0])?.path??null,en=()=>{const t=Fe.c(4),e=oe(Sx),n=nn(Nx),a=nn(Cx);let i;return t[0]!==a||t[1]!==n||t[2]!==e?(i=wx(e,n,a),t[0]=a,t[1]=n,t[2]=e,t[3]=i):i=t[3],i};function Sx(t){return t.settingsProjectPath}function Nx(t){return t.projects}function Cx(t){return t.activeProjectId}const Jl=Go(t=>({tab:"messages",setTab:e=>t({tab:e})})),um=new Map([["chat.activity-default","messages"],["chat.reasoning","messages"],["chat.reasoning-traces","messages"],["chat.tool-file-icons","messages"],["chat.changed-files","messages"],["chat.streaming-auto-follow","messages"],["chat.message-appearance","messages"],["chat.width","messages"],["chat.prompt-navigator","messages"],["chat.collapsible-user-messages","messages"],["chat.sticky-user-header","messages"],["chat.inline-assistant-actions","messages"],["chat.selection-approval-text","messages"],["chat.user-message-rendering","messages"],["chat.mermaid-rendering","messages"],["chat.diff-layout","messages"],["chat.code-block-line-wrap","messages"],["chat.table-cell-wrap","messages"],["chat.copy-plain-text","messages"],["chat.message-search","messages"],["chat.message-search-enabled","messages"],["chat.message-search-reasoning","messages"],["chat.composer","composer"],["chat.enter-to-send","composer"],["chat.mobile-return-key-sends","composer"],["chat.follow-up-behavior","composer"],["chat.questions-placement","composer"],["chat.large-text-paste","composer"],["chat.subagent-read-only-banner","composer"],["chat.save-pasted-images","composer"],["chat.spellcheck","composer"],["chat.input-history-scope","composer"],["chat.input-history-limit","composer"],["chat.session-assistance","assistance"],["chat.draft-starters-visible","assistance"],["chat.session-recap","assistance"],["chat.session-suggestion","assistance"],["chat.session-review-offer","assistance"],["chat.session-goal","assistance"],["chat.session-goal-checker","assistance"],["chat.session-goal-max-turns","assistance"],["chat.session-goal-budget","assistance"]]),Ix=t=>um.get(t)??null,Px=t=>[...um].filter(([,e])=>e===t).map(([e])=>e),Ql=Go(t=>({variant:null,setVariant:e=>t({variant:e})})),Ax=t=>t==="appearance.light-theme"?"light":t==="appearance.dark-theme"?"dark":null,ni=t=>{const e=Fe.c(73),{className:n}=t,{t:a}=Oe(),{currentTheme:i}=ma(),o=oe(Ex),[l,r]=g.useState(false),c=Jo(nn(Tx)),u=en(),d=oe(Rx),p=os();let m;e[0]!==u||e[1]!==c?(m=c.find(A=>A.path===u)??c[0]??null,e[0]=u,e[1]=c,e[2]=m):m=e[2];const f=m;if(p||!f)return null;let h;e[3]!==d||e[4]!==c?(h=A=>{const E=c.find(D=>D.id===A);E&&d(E.path)},e[3]=d,e[4]=c,e[5]=h):h=e[5];const v=h;if(o){let A;e[6]!==n?(A=He(n),e[6]=n,e[7]=A):A=e[7];let E;e[8]!==a?(E=a("settings.shared.projectSelector.switchProjectAria"),e[8]=a,e[9]=E):E=e[9];let D;e[10]!==a?(D=a("settings.shared.projectSelector.switchProjectTitle"),e[10]=a,e[11]=D):D=e[11];let M,O;e[12]===Symbol.for("react.memo_cache_sentinel")?(M=()=>r(true),O=He(Gp({size:"touch"}),"w-full min-w-0"),e[12]=M,e[13]=O):(M=e[12],O=e[13]);let R;e[14]!==f||e[15]!==i?(R=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:s.jsx(So,{project:f,theme:i})}),e[14]=f,e[15]=i,e[16]=R):R=e[16];let F;e[17]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(ae,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[17]=F):F=e[17];let T;e[18]!==l||e[19]!==E||e[20]!==D||e[21]!==O||e[22]!==R?(T=s.jsxs("button",{type:"button","aria-label":E,title:D,"aria-haspopup":"dialog","aria-expanded":l,onClick:M,className:O,children:[R,F]}),e[18]=l,e[19]=E,e[20]=D,e[21]=O,e[22]=R,e[23]=T):T=e[23];let _;e[24]!==T||e[25]!==A?(_=s.jsx("div",{className:A,children:T}),e[24]=T,e[25]=A,e[26]=_):_=e[26];let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($=()=>r(false),e[27]=$):$=e[27];const z=f.id;let H;e[28]!==a?(H=a("settings.shared.projectSelector.sheetTitle"),e[28]=a,e[29]=H):H=e[29];let q;e[30]!==a?(q=a("settings.shared.projectSelector.searchPlaceholder"),e[30]=a,e[31]=q):q=e[31];let J;e[32]!==f.id||e[33]!==i||e[34]!==v||e[35]!==l||e[36]!==c||e[37]!==H||e[38]!==q?(J=s.jsx(Jp,{open:l,onClose:$,projects:c,selectedProjectId:z,onSelectProject:v,theme:i,title:H,searchPlaceholder:q}),e[32]=f.id,e[33]=i,e[34]=v,e[35]=l,e[36]=c,e[37]=H,e[38]=q,e[39]=J):J=e[39];let U;return e[40]!==_||e[41]!==J?(U=s.jsxs(s.Fragment,{children:[_,J]}),e[40]=_,e[41]=J,e[42]=U):U=e[42],U}let x;e[43]!==n?(x=He(n),e[43]=n,e[44]=x):x=e[44];const b=f.id;let k;e[45]!==v?(k=A=>{A&&v(A)},e[45]=v,e[46]=k):k=e[46];let j;e[47]!==a?(j=a("settings.shared.projectSelector.switchProjectAria"),e[47]=a,e[48]=j):j=e[48];let y;e[49]!==a?(y=a("settings.shared.projectSelector.switchProjectTitle"),e[49]=a,e[50]=y):y=e[50];let N;e[51]!==f||e[52]!==i?(N=s.jsx(_t,{children:s.jsx(So,{project:f,theme:i})}),e[51]=f,e[52]=i,e[53]=N):N=e[53];let S;e[54]!==j||e[55]!==y||e[56]!==N?(S=s.jsx(Dt,{className:"w-full","aria-label":j,title:y,children:N}),e[54]=j,e[55]=y,e[56]=N,e[57]=S):S=e[57];let P;if(e[58]!==i||e[59]!==c){let A;e[61]!==i?(A=E=>s.jsx(ht,{value:E.id,className:"max-w-[24rem] truncate",children:s.jsx(So,{project:E,theme:i})},E.id),e[61]=i,e[62]=A):A=e[62],P=c.map(A),e[58]=i,e[59]=c,e[60]=P}else P=e[60];let w;e[63]!==P?(w=s.jsx(Ft,{fitContent:true,children:P}),e[63]=P,e[64]=w):w=e[64];let I;e[65]!==f.id||e[66]!==w||e[67]!==k||e[68]!==S?(I=s.jsxs(Ot,{value:b,onValueChange:k,children:[S,w]}),e[65]=f.id,e[66]=w,e[67]=k,e[68]=S,e[69]=I):I=e[69];let C;return e[70]!==I||e[71]!==x?(C=s.jsx("div",{className:x,children:I}),e[70]=I,e[71]=x,e[72]=C):C=e[72],C};function Ex(t){return t.isMobile}function Tx(t){return t.projects}function Rx(t){return t.setSettingsProjectPath}const Or=t=>{const e=Fe.c(16),{value:n,onChange:a}=t,{t:i}=Oe();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(ae,{name:"search",className:"pointer-events-none absolute inset-s-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":true}),e[0]=o):o=e[0];let l;e[1]!==a?(l=p=>a(p.target.value),e[1]=a,e[2]=l):l=e[2];let r;e[3]!==a||e[4]!==n?(r=p=>{p.key==="Escape"&&n&&(p.preventDefault(),p.stopPropagation(),a(""))},e[3]=a,e[4]=n,e[5]=r):r=e[5];let c;e[6]!==i?(c=i("settings.common.sidebar.searchPlaceholder"),e[6]=i,e[7]=c):c=e[7];let u;e[8]!==i?(u=i("settings.common.sidebar.searchPlaceholder"),e[8]=i,e[9]=u):u=e[9];let d;return e[10]!==l||e[11]!==r||e[12]!==c||e[13]!==u||e[14]!==n?(d=s.jsxs("div",{className:"relative mt-3",children:[o,s.jsx(Ze,{value:n,onChange:l,onKeyDown:r,placeholder:c,"aria-label":u,className:"h-8 ps-7 typography-meta"})]}),e[10]=l,e[11]=r,e[12]=c,e[13]=u,e[14]=n,e[15]=d):d=e[15],d},Lr=t=>{const e=Fe.c(5),{query:n}=t,{t:a}=Oe();let i;e[0]!==n||e[1]!==a?(i=a("settings.common.sidebar.noMatches",{query:n.trim()}),e[0]=n,e[1]=a,e[2]=i):i=e[2];let o;return e[3]!==i?(o=s.jsx("p",{className:"px-2 py-6 text-center typography-meta text-muted-foreground",children:i}),e[3]=i,e[4]=o):o=e[4],o};function Mx(t,e){return`opencode:sidebar-group:${t}:${e}`}const Yl=t=>{const e=Fe.c(33),{label:n,count:a,storageKey:i,defaultExpanded:o,children:l}=t,r=o===void 0?true:o;let c;e[0]!==n||e[1]!==i?(c=Mx(i,n),e[0]=n,e[1]=i,e[2]=c):c=e[2];const u=c,d=g.useId();let p;e[3]!==r||e[4]!==u?(p=()=>{try{const A=localStorage.getItem(u);if(A!==null)return A==="true"}catch{}return r},e[3]=r,e[4]=u,e[5]=p):p=e[5];const[m,f]=Ye.useState(p);let h,v;e[6]!==m||e[7]!==u?(h=()=>{try{localStorage.setItem(u,String(m))}catch{}},v=[u,m],e[6]=m,e[7]=u,e[8]=h,e[9]=v):(h=e[8],v=e[9]),Ye.useEffect(h,v);let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=()=>f(Dx),e[10]=x):x=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=He("flex w-full items-center gap-1 rounded-md px-2 py-1 text-start","text-xs font-semibold uppercase tracking-wide text-muted-foreground","hover:bg-[var(--interactive-hover)] transition-colors duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),e[11]=b):b=e[11];const k=!m&&"-rotate-90 rtl:rotate-90";let j;e[12]!==k?(j=He("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",k),e[12]=k,e[13]=j):j=e[13];let y;e[14]!==j?(y=s.jsx(ae,{name:"arrow-down-s",className:j}),e[14]=j,e[15]=y):y=e[15];let N;e[16]!==n?(N=s.jsx("span",{className:"flex-1 truncate",children:n}),e[16]=n,e[17]=N):N=e[17];let S;e[18]!==a?(S=s.jsx("span",{className:"ms-1 tabular-nums opacity-60",children:a}),e[18]=a,e[19]=S):S=e[19];let P;e[20]!==d||e[21]!==m||e[22]!==y||e[23]!==N||e[24]!==S?(P=s.jsxs("button",{type:"button",onClick:x,"aria-expanded":m,"aria-controls":d,className:b,children:[y,N,S]}),e[20]=d,e[21]=m,e[22]=y,e[23]=N,e[24]=S,e[25]=P):P=e[25];const w=!m;let I;e[26]!==l||e[27]!==d||e[28]!==w?(I=s.jsx("div",{id:d,hidden:w,className:"mt-0.5 space-y-0.5 ms-2 ps-3 border-s-2 border-[var(--interactive-border)]",children:l}),e[26]=l,e[27]=d,e[28]=w,e[29]=I):I=e[29];let C;return e[30]!==P||e[31]!==I?(C=s.jsxs("div",{children:[P,I]}),e[30]=P,e[31]=I,e[32]=C):C=e[32],C};function Dx(t){return!t}const Fx=({onItemSelect:t})=>{const{t:e}=Oe(),[n,a]=g.useState(""),[i,o]=g.useState(null),[l,r]=g.useState(""),[c,u]=g.useState(null),[d,p]=g.useState(false),[m,f]=g.useState(null),{selectedAgentName:h,setSelectedAgent:v,setAgentDraft:x,createAgent:b,deleteAgent:k,loadAgents:j,loadDisabledAgents:y,updateAgent:N,fetchAgentEntity:S}=In($s(K=>({selectedAgentName:K.selectedAgentName,setSelectedAgent:K.setSelectedAgent,setAgentDraft:K.setAgentDraft,createAgent:K.createAgent,deleteAgent:K.deleteAgent,loadAgents:K.loadAgents,loadDisabledAgents:K.loadDisabledAgents,updateAgent:K.updateAgent,fetchAgentEntity:K.fetchAgentEntity}))),P=en(),w=In(K=>yu(K,P)),I=In(K=>Qp(K,P)),[C,A]=g.useState(null);g.useEffect(()=>{j(P),y(P)},[j,y,P]);const E=w.filter(K=>To(K.mode)&&!nc(K)).length,D=K=>!(To(K.mode)&&!nc(K)&&E<=1),M=async(K,ie)=>{A(K);try{await N(K,{disabled:ie},P),ie&&h===K&&v(null),Y.success(ie?e("settings.agents.sidebar.toast.agentDisabled",{name:K}):e("settings.agents.sidebar.toast.agentEnabled",{name:K}))}catch{Y.error(e(ie?"settings.agents.sidebar.toast.disableFailed":"settings.agents.sidebar.toast.enableFailed"))}finally{A(null)}},O=I.filter(K=>Ri([K.name,K.description],n)),R="bg-background",F=()=>{const K="new-agent";let ie=K,le=1;for(;w.some(be=>be.name===ie);)ie=`${K}-${le}`,le++;x({name:ie,scope:"user"}),v(ie),t?.()},T=async K=>{if(Si(K)){Y.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}u(K)},_=()=>{u(null)},$=async()=>{if(c){p(true);try{(await k(c.name,c.scope,P)).ok?(Y.success(e("settings.agents.sidebar.toast.agentDeleted",{name:c.name})),_()):Y.error(e("settings.agents.sidebar.toast.deleteFailed"))}catch(K){const ie=K instanceof Error?K.message:"",le=/built-in|not deletable|not found/i.test(ie);Y.error(e(le?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed"))}p(false)}},z=async K=>{const ie=K.name;let le=1,be=`${ie}-copy`;for(;w.some(re=>re.name===be);)le++,be=`${ie}-copy-${le}`;const ue=K,Pe=await S(K.name,P);if(!Pe){Y.error(e("settings.agents.sidebar.toast.renameFailed"));return}const Ae=Pe.config.request?.body;x({name:be,scope:Pe.scope??ue.scope??"user",description:Pe.config.description??void 0,model:Pe.config.model??null,system:Pe.config.system??void 0,steps:Pe.config.steps??void 0,temperature:Ae?.temperature,top_p:Ae?.top_p,mode:Pe.config.mode??ue.mode,permissions:Pe.config.permissions??void 0,hidden:Pe.config.hidden}),v(be),t?.()},H=K=>{r(K.name),o(K)},q=async()=>{if(!i)return;const K=l.trim().replace(/\s+/g,"-");if(!K){Y.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(K===i.name){o(null);return}if(w.some(ue=>ue.name===K)){Y.error(e("settings.agents.sidebar.toast.agentExists"));return}const ie=i,le=await S(i.name,P);if(!le){Y.error(e("settings.agents.sidebar.toast.renameFailed"));return}(await b({...le.config,name:K,scope:le.scope??ie.scope},P)).ok?(await k(i.name,ie.scope,P)).ok?(Y.success(e("settings.agents.sidebar.toast.agentRenamed",{name:K})),v(K)):Y.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed")):Y.error(e("settings.agents.sidebar.toast.renameFailed")),o(null)},J=K=>{switch(K){case"primary":return s.jsx(ae,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return s.jsx(ae,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return s.jsx(ae,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},U=new Set(I.map(K=>K.name)),B=w.filter(K=>Yp(K)&&!U.has(K.name)),W=B.filter(K=>Ri([K.name,K.description],n)),Q=W.filter(Si),ee=W.filter(K=>!Si(K)),{groupedCustomAgents:X,ungroupedCustomAgents:ne}=Ye.useMemo(()=>{const K={},ie=[];for(const be of ee){const ue=be;ue.group?(K[ue.group]||(K[ue.group]=[]),K[ue.group].push(be)):ie.push(be)}return{groupedCustomAgents:Object.keys(K).sort((be,ue)=>be.localeCompare(ue)).map(be=>({name:be,agents:K[be]})),ungroupedCustomAgents:ie}},[ee]);return s.jsxs("div",{className:He("flex h-full flex-col",R),children:[s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[s.jsx("h2",{className:`${yn} mb-3`,children:e("settings.agents.sidebar.title")}),s.jsx(ni,{className:"mb-3"}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.agents.sidebar.total",{count:B.length})}),s.jsx(G,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:F,children:s.jsx(ae,{name:"add",className:"h-3.5 w-3.5"})})]}),B.length>0?s.jsx(Or,{value:n,onChange:a}):null]}),s.jsxs(ys,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:[B.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(ae,{name:"robot-2",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:e("settings.agents.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.agents.sidebar.empty.description")})]}):W.length===0?s.jsx(Lr,{query:n}):s.jsxs(s.Fragment,{children:[Q.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.builtIn")}),Q.map(K=>s.jsx(hl,{agent:K,isSelected:h===K.name,onSelect:()=>{v(K.name),t?.()},onDuplicate:()=>{z(K)},onDisable:D(K)?()=>{M(K.name,true)}:void 0,getAgentModeIcon:J,isMenuOpen:m===K.name,onMenuOpenChange:ie=>f(ie?K.name:null)},K.name))]}),ee.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.custom")}),X.map(({name:K,agents:ie})=>s.jsx(Yl,{label:K,count:ie.length,storageKey:"agents",children:ie.map(le=>s.jsx(hl,{agent:le,isSelected:h===le.name,onSelect:()=>{v(le.name),t?.()},onRename:()=>H(le),onDelete:()=>T(le),onDuplicate:()=>{z(le)},onDisable:D(le)?()=>{M(le.name,true)}:void 0,getAgentModeIcon:J,isMenuOpen:m===le.name,onMenuOpenChange:be=>f(be?le.name:null)},le.name))},K)),ne.map(K=>s.jsx(hl,{agent:K,isSelected:h===K.name,onSelect:()=>{v(K.name),t?.()},onRename:()=>H(K),onDelete:()=>T(K),onDuplicate:()=>{z(K)},onDisable:D(K)?()=>{M(K.name,true)}:void 0,getAgentModeIcon:J,isMenuOpen:m===K.name,onMenuOpenChange:ie=>f(ie?K.name:null)},K.name))]})]}),O.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.disabled")}),O.map(K=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-1.5 py-1",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"typography-ui-label truncate text-muted-foreground",children:K.name}),K.description?s.jsx("div",{className:"typography-micro truncate leading-tight text-muted-foreground",children:K.description}):null]}),s.jsx(G,{size:"xs",variant:"outline",disabled:C===K.name,onClick:()=>{M(K.name,false)},"aria-label":e("settings.agents.sidebar.actions.enableAria",{name:K.name}),children:e("settings.agents.sidebar.actions.enable")})]},K.name))]})]}),s.jsx(Ut,{open:c!==null,onOpenChange:K=>{!K&&!d&&_()},children:s.jsxs(Kt,{className:"max-w-md",children:[s.jsxs(qt,{children:[s.jsx(Bt,{children:e("settings.agents.sidebar.dialog.deleteTitle")}),s.jsx(Vt,{children:e("settings.agents.sidebar.dialog.deleteDescription",{name:c?.name??""})})]}),s.jsxs(as,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:_,disabled:d,children:e("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",onClick:$,disabled:d,children:e("settings.common.actions.delete")})]})]})}),s.jsx(Ut,{open:i!==null,onOpenChange:K=>!K&&o(null),children:s.jsxs(Kt,{children:[s.jsxs(qt,{children:[s.jsx(Bt,{children:e("settings.agents.sidebar.renameDialog.title")}),s.jsx(Vt,{children:e("settings.agents.sidebar.renameDialog.description",{name:i?.name??""})})]}),s.jsx(Ze,{value:l,onChange:K=>r(K.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:K=>{K.key==="Enter"&&q()}}),s.jsxs(as,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:()=>o(null),children:e("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",onClick:q,children:e("settings.common.actions.rename")})]})]})})]})},hl=t=>{const e=Fe.c(52),{agent:n,isSelected:a,onSelect:i,onDelete:o,onRename:l,onDuplicate:r,onDisable:c,getAgentModeIcon:u,isMenuOpen:d,onMenuOpenChange:p}=t,{t:m}=Oe(),f=n;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=hr(),e[0]=h):h=e[0];const v=h,[x,b]=g.useState(false);let k;e[1]!==o||e[2]!==c||e[3]!==r||e[4]!==l||e[5]!==m?(k=H=>s.jsxs(s.Fragment,{children:[l&&s.jsxs(H,{onClick:q=>{q.stopPropagation(),l()},children:[s.jsx(ae,{name:"edit",className:"h-4 w-4 me-px"}),m("settings.common.actions.rename")]}),s.jsxs(H,{onClick:q=>{q.stopPropagation(),r()},children:[s.jsx(ae,{name:"file-copy",className:"h-4 w-4 me-px"}),m("settings.common.actions.duplicate")]}),c&&s.jsxs(H,{onClick:q=>{q.stopPropagation(),c()},children:[s.jsx(ae,{name:"eye-off",className:"h-4 w-4 me-px"}),m("settings.agents.sidebar.actions.disable")]}),o&&s.jsxs(H,{onClick:q=>{q.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[s.jsx(ae,{name:"delete-bin",className:"h-4 w-4 me-px"}),m("settings.common.actions.delete")]})]}),e[1]=o,e[2]=c,e[3]=r,e[4]=l,e[5]=m,e[6]=k):k=e[6];const j=k,y=a?"bg-interactive-selection":"hover:bg-interactive-hover";let N;e[7]!==y?(N=He("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",y),e[7]=y,e[8]=N):N=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=v?void 0:H=>{H.preventDefault(),b(true)},e[9]=S):S=e[9];let P;e[10]!==N?(P=s.jsx("div",{className:N,onContextMenu:S}),e[10]=N,e[11]=P):P=e[11];let w;e[12]!==n.name?(w=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n.name}),e[12]=n.name,e[13]=w):w=e[13];let I;e[14]!==n.mode||e[15]!==u?(I=u(n.mode),e[14]=n.mode,e[15]=u,e[16]=I):I=e[16];let C;e[17]!==n||e[18]!==f.scope||e[19]!==m?(C=(f.scope||Si(n))&&s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-edge",children:Si(n)?m("settings.agents.sidebar.badge.system"):f.scope}),e[17]=n,e[18]=f.scope,e[19]=m,e[20]=C):C=e[20];let A;e[21]!==w||e[22]!==I||e[23]!==C?(A=s.jsxs("div",{className:"flex items-center gap-1.5",children:[w,I,C]}),e[21]=w,e[22]=I,e[23]=C,e[24]=A):A=e[24];let E;e[25]!==n.description?(E=n.description&&s.jsx("div",{className:"typography-micro text-muted-foreground truncate leading-tight",children:n.description}),e[25]=n.description,e[26]=E):E=e[26];let D;e[27]!==i||e[28]!==A||e[29]!==E?(D=s.jsxs("button",{onClick:i,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,children:[A,E]}),e[27]=i,e[28]=A,e[29]=E,e[30]=D):D=e[30];let M;e[31]!==p?(M=H=>{H&&b(false),p(H)},e[31]=p,e[32]=M):M=e[32];let O;e[33]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(ga,{asChild:true,children:s.jsx(G,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -me-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 pointer-fine:hidden",children:s.jsx(ae,{name:"more",className:"h-3.5 w-3.5"})})}),e[33]=O):O=e[33];let R;e[34]!==j?(R=s.jsx(pa,{align:"end",className:"w-fit min-w-20",children:j(ra)}),e[34]=j,e[35]=R):R=e[35];let F;e[36]!==d||e[37]!==M||e[38]!==R?(F=s.jsxs(fa,{open:d,onOpenChange:M,children:[O,R]}),e[36]=d,e[37]=M,e[38]=R,e[39]=F):F=e[39];let T;e[40]!==D||e[41]!==F?(T=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[D,F]}),e[40]=D,e[41]=F,e[42]=T):T=e[42];let _;e[43]!==T||e[44]!==P?(_=s.jsx(Ra,{render:P,children:T}),e[43]=T,e[44]=P,e[45]=_):_=e[45];let $;e[46]!==j?($=s.jsx(Ta,{className:"w-fit min-w-20",children:j(ca)}),e[46]=j,e[47]=$):$=e[47];let z;return e[48]!==x||e[49]!==_||e[50]!==$?(z=s.jsxs(Ma,{open:x,onOpenChange:b,children:[_,$]}),e[48]=x,e[49]=_,e[50]=$,e[51]=z):z=e[51],z},Vs={ok:true,changed:false},Mn={ok:true,changed:true},vs=t=>({ok:false,reason:t}),Ox=t=>t instanceof HTMLElement?t.matches('input, textarea, [contenteditable="true"]'):false,ai=t=>{const{t:e}=Oe(),[n,a]=g.useState(0),i=g.useRef(t);i.current=t;const o=g.useRef(e);o.current=e;const l=g.useRef(false),r=g.useRef(false),c=g.useRef(false),u=g.useCallback(()=>{a(m=>m+1)},[]),d=g.useCallback(m=>{Ox(m.target)&&u()},[u]),p=g.useCallback(async()=>{l.current=true;try{for(;;){r.current=false;let m;try{m=await i.current()}catch(f){m={ok:false,reason:f instanceof Error?f.message:String(f)}}if(!c.current)return;if(!r.current){m.ok||Y.error(o.current("settings.common.status.saveFailedReason",{reason:m.reason}));return}}}finally{l.current=false}},[]);return g.useEffect(()=>(c.current=true,()=>{c.current=false}),[]),g.useEffect(()=>{if(n!==0){if(l.current){r.current=true;return}p()}},[n,p]),{requestSave:u,onBlurCapture:d}},Lx=["allow","ask","deny"],_x=["shell","edit","read","glob","grep","patch","webfetch","websearch","skill","subagent","question","external_directory"],$x=["openchamber","openchamber_schedule","openchamber_web","openchamber_memory","openchamber_knowledge","openchamber_notify","openchamber_usage","openchamber_render","openchamber_image","openchamber_secret"],Ux=new Set(["bash","task","write","list","lsp","todowrite","todoread","multiedit","doom_loop","plan_enter","plan_exit"]),mm=t=>Ux.has(t),Kx=[{action:"*",resource:"*",effect:"allow"},{action:"read",resource:"*.env",effect:"ask"},{action:"read",resource:"*.env.*",effect:"ask"},{action:"read",resource:"*.env.example",effect:"allow"}],Bc=()=>({global:null,keys:{},source:[]}),ya=t=>({global:t.global,source:t.source,keys:Object.fromEntries(Object.entries(t.keys).map(([e,n])=>[e,{effect:n.effect,patterns:n.patterns.map(a=>({...a}))}]))}),zx=t=>{const e={global:null,keys:{},source:t.map(n=>({...n}))};for(const n of t){if(mm(n.action))continue;if(n.action==="*"){n.resource==="*"&&(e.global=n.effect);continue}const a=e.keys[n.action]??{effect:null,patterns:[]};if(n.resource==="*")a.effect=n.effect;else{const i=a.patterns.findIndex(o=>o.pattern===n.resource);i>=0?a.patterns[i]={pattern:n.resource,effect:n.effect}:a.patterns.push({pattern:n.resource,effect:n.effect})}e.keys[n.action]=a}return e},Bx=t=>t.action!=="*"||t.resource==="*",Ca=(t,e)=>`${t}\0${e}`,Vx=t=>{const e=new Map;t.global!==null&&e.set(Ca("*","*"),t.global);for(const[n,a]of Object.entries(t.keys)){a.effect!==null&&e.set(Ca(n,"*"),a.effect);for(const i of a.patterns){const o=i.pattern.trim();o.length!==0&&e.set(Ca(n,o),i.effect)}}return e},Zl=t=>{const e=Vx(t),n=new Set,a=[];for(const o of t.source){if(mm(o.action))continue;if(!Bx(o)){a.push({...o});continue}const l=Ca(o.action,o.resource),r=e.get(l);r!==void 0&&(a.push({action:o.action,resource:o.resource,effect:r}),n.add(l))}const i=Ca("*","*");t.global!==null&&!n.has(i)&&a.unshift({action:"*",resource:"*",effect:t.global});for(const[o,l]of Object.entries(t.keys)){const r=Ca(o,"*");if(l.effect!==null&&!n.has(r)){const c=a.findIndex(d=>d.action===o),u={action:o,resource:"*",effect:l.effect};c>=0?a.splice(c,0,u):a.push(u)}for(const c of l.patterns){const u=c.pattern.trim();if(u.length===0)continue;const d=Ca(o,u),p=e.get(d);p===void 0||n.has(d)||(n.add(d),a.push({action:o,resource:u,effect:p}))}}return a},Hx=(t,e)=>JSON.stringify(Zl(t))===JSON.stringify(Zl(e)),qx=(t,e)=>{const n=[...Kx,...e.global,...e.agentGlobal?[{action:"*",resource:"*",effect:e.agentGlobal}]:[]];let a="ask";for(const i of n)i.resource==="*"&&(i.action==="*"||i.action===t)&&(a=i.effect);return a},Wx=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),Gx=new Set(["shell","edit","read","glob","grep","patch","webfetch","skill","subagent","external_directory"]),Jx={effect:null,patterns:[]},Qx=t=>{const e=Fe.c(163),{agent:n,registerSave:a,requestSave:i}=t,{t:o}=Oe(),l=In(Yx),r=In(Zx);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[u,d]=g.useState(c),[p,m]=g.useState(Bc),[f,h]=g.useState(Bc),[v,x]=g.useState(true),[b,k]=g.useState(false);let j;e[1]===Symbol.for("react.memo_cache_sentinel")?(j={},e[1]=j):j=e[1];const[y,N]=g.useState(j),[S,P]=g.useState(""),[w,I]=g.useState(0),C=n.name,A=en(),E=Pn(Xx);let D;e[2]!==A?(D=_e=>xr(_e,A),e[2]=A,e[3]=D):D=e[3];const M=Pn(D);let O;e[4]!==A?(O=_e=>_e.getStatusForDirectory(A),e[4]=A,e[5]=O):O=e[5];const R=gn(O);let F,T;e[6]!==E||e[7]!==A?(F=()=>{E({directory:A})},T=[E,A],e[6]=E,e[7]=A,e[8]=F,e[9]=T):(F=e[8],T=e[9]),g.useEffect(F,T);let _;e[10]!==C||e[11]!==r||e[12]!==A?(_=()=>{let _e=false;return x(true),k(false),(async()=>{const nt=await r(C,A);if(_e)return;if(!nt){k(true),x(false);return}const Ue=zx(nt.agent);d(nt.global),m(ya(Ue)),h(Ue),N({}),x(false)})(),()=>{_e=true}},e[10]=C,e[11]=r,e[12]=A,e[13]=_):_=e[13];let $;e[14]!==C||e[15]!==r||e[16]!==w||e[17]!==A?($=[C,r,w,A],e[14]=C,e[15]=r,e[16]=w,e[17]=A,e[18]=$):$=e[18],g.useEffect(_,$);let z;e[19]!==C||e[20]!==p||e[21]!==f||e[22]!==A||e[23]!==o||e[24]!==l?(z=async()=>Hx(f,p)?Vs:(await l(C,{permissions:Zl(f)},A)).ok?(m(ya(f)),Mn):vs(o("settings.agents.page.permissionsEditor.toast.saveFailed")),e[19]=C,e[20]=p,e[21]=f,e[22]=A,e[23]=o,e[24]=l,e[25]=z):z=e[25];const H=z;let q,J;e[26]!==a||e[27]!==H?(q=()=>(a(H),()=>a(null)),J=[a,H],e[26]=a,e[27]=H,e[28]=q,e[29]=J):(q=e[28],J=e[29]),g.useEffect(q,J);let U;e[30]!==M?(U=M.map(eb),e[30]=M,e[31]=U):U=e[31];const B=U;let W;if(e[32]!==B||e[33]!==f.keys){W=[..._x,...$x];const _e=new Set(B.map(tb));let nt;e[35]!==f.keys?(nt=Object.keys(f.keys),e[35]=f.keys,e[36]=nt):nt=e[36];for(const Ue of nt)!W.includes(Ue)&&!_e.has(Ue)&&W.push(Ue);e[32]=B,e[33]=f.keys,e[34]=W}else W=e[34];const Q=W;let ee;e[37]!==R||e[38]!==o?(ee=_e=>{switch(R?.[_e]?.status.status){case"connected":return o("settings.mcp.page.status.label.connected");case"failed":return o("settings.mcp.page.status.label.failed");case"needs_auth":return o("settings.mcp.page.status.label.needsAuth");case"disabled":return o("settings.agents.page.permissionsEditor.mcpStatus.disabled");case"pending":return o("settings.agents.page.permissionsEditor.mcpStatus.pending");default:return null}},e[37]=R,e[38]=o,e[39]=ee):ee=e[39];const X=ee;let ne;e[40]!==u||e[41]!==f.global?(ne=_e=>qx(_e,{global:u,agentGlobal:f.global}),e[40]=u,e[41]=f.global,e[42]=ne):ne=e[42];const K=ne;let ie;e[43]!==i?(ie=_e=>{h(nt=>({...nt,global:_e})),i()},e[43]=i,e[44]=ie):ie=e[44];const le=ie;let be;e[45]!==i?(be=(_e,nt)=>{h(Ue=>{const Se=ya(Ue),Ve=Se.keys[_e]??{effect:null,patterns:[]};return Ve.effect=nt,Ve.effect===null&&Ve.patterns.length===0?delete Se.keys[_e]:Se.keys[_e]=Ve,Se}),i()},e[45]=i,e[46]=be):be=e[46];const ue=be;let Pe;e[47]!==i?(Pe=(_e,nt,Ue,Se,Ve)=>{h(Re=>{const Je=ya(Re),ot=Je.keys[_e]??{effect:null,patterns:[]};return ot.patterns[nt]={pattern:Ue,effect:Se},Je.keys[_e]=ot,Je}),Ve&&i()},e[47]=i,e[48]=Pe):Pe=e[48];const Ae=Pe;let re;e[49]===Symbol.for("react.memo_cache_sentinel")?(re=_e=>{h(nt=>{const Ue=ya(nt),Se=Ue.keys[_e]??{effect:null,patterns:[]};return Se.patterns.push({pattern:"",effect:"allow"}),Ue.keys[_e]=Se,Ue}),N(nt=>({...nt,[_e]:true}))},e[49]=re):re=e[49];const te=re;let he;e[50]!==i?(he=(_e,nt)=>{h(Ue=>{const Se=ya(Ue),Ve=Se.keys[_e];return Ve?(Ve.patterns.splice(nt,1),Ve.effect===null&&Ve.patterns.length===0&&delete Se.keys[_e],Se):Ue}),i()},e[50]=i,e[51]=he):he=e[51];const xe=he;let ke;e[52]!==S||e[53]!==i?(ke=()=>{const _e=S.trim();!_e||_e==="*"||(h(nt=>{if(nt.keys[_e])return nt;const Ue=ya(nt);return Ue.keys[_e]={effect:"ask",patterns:[]},Ue}),P(""),i())},e[52]=S,e[53]=i,e[54]=ke):ke=e[54];const we=ke;let Te;e[55]!==o?(Te=_e=>o(_e==="allow"?"settings.agents.page.permissionsEditor.action.allow":_e==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),e[55]=o,e[56]=Te):Te=e[56];const ge=Te;let Ee,Ce,ce,ye,Z,fe,Ne,Ie,$e;if(e[57]!==ge||e[58]!==K||e[59]!==y||e[60]!==v||e[61]!==b||e[62]!==B||e[63]!==X||e[64]!==f.global||e[65]!==f.keys||e[66]!==xe||e[67]!==le||e[68]!==ue||e[69]!==Ae||e[70]!==o||e[71]!==Q){$e=Symbol.for("react.early_return_sentinel");e:{const _e=o("settings.agents.page.permissionsEditor.action.inherit"),nt=o("settings.agents.page.permissionsEditor.action.default");let Ue;e[81]!==ge?(Ue=st=>[...st?[{value:"inherit",label:st}]:[],...Lx.map(rt=>({value:rt,label:ge(rt)}))],e[81]=ge,e[82]=Ue):Ue=e[82];const Se=Ue,Ve=(st,rt,St,mt)=>{const Et=mt===void 0?_e:mt;return s.jsx(Wt,{value:st??"inherit",options:Se(Et),onChange:Pt=>rt(Pt==="inherit"?null:Pt),"aria-label":St})};if(v){let st;e[83]!==o?(st=o("settings.agents.page.section.toolPermissions"),e[83]=o,e[84]=st):st=e[84];let rt;e[85]!==o?(rt=o("common.loading"),e[85]=o,e[86]=rt):rt=e[86];let St;e[87]!==rt?(St=s.jsx("p",{className:zt,children:rt}),e[87]=rt,e[88]=St):St=e[88];let mt;e[89]!==st||e[90]!==St?(mt=s.jsx(Qe,{title:st,children:St}),e[89]=st,e[90]=St,e[91]=mt):mt=e[91],$e=mt;break e}if(b){let st;e[92]!==o?(st=o("settings.agents.page.section.toolPermissions"),e[92]=o,e[93]=st):st=e[93];let rt;e[94]!==o?(rt=o("settings.agents.page.permissionsEditor.state.loadFailed"),e[94]=o,e[95]=rt):rt=e[95];let St;e[96]!==rt?(St=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:rt}),e[96]=rt,e[97]=St):St=e[97];let mt;e[98]===Symbol.for("react.memo_cache_sentinel")?(mt=()=>I(sb),e[98]=mt):mt=e[98];let Et;e[99]!==o?(Et=o("settings.agents.page.permissionsEditor.actions.retry"),e[99]=o,e[100]=Et):Et=e[100];let Pt;e[101]!==Et?(Pt=s.jsx(G,{variant:"outline",size:"xs",onClick:mt,children:Et}),e[101]=Et,e[102]=Pt):Pt=e[102];let et;e[103]!==St||e[104]!==Pt?(et=s.jsxs("div",{className:"flex items-center gap-3",children:[St,Pt]}),e[103]=St,e[104]=Pt,e[105]=et):et=e[105];let yt;e[106]!==st||e[107]!==et?(yt=s.jsx(Qe,{title:st,children:et}),e[106]=st,e[107]=et,e[108]=yt):yt=e[108],$e=yt;break e}const Re=(st,rt,St)=>{const mt=f.keys[st]??Jx,Et=Gx.has(st)||mt.patterns.length>0,Pt=y[st]===true;return s.jsxs("div",{className:"border-t border-edge-muted py-2",children:[s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsxs("button",{type:"button",onClick:Et?()=>N(et=>({...et,[st]:!Pt})):void 0,className:He("flex min-w-0 items-center gap-1.5 text-start",!Et&&"cursor-default"),"aria-expanded":Et?Pt:void 0,children:[s.jsx(ae,{name:Pt&&Et?"arrow-down-s":"arrow-right-s",className:He("h-3.5 w-3.5 shrink-0 text-muted-foreground",!Et&&"opacity-0")}),s.jsx("span",{className:ls,children:rt}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground",children:st}),St&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:St}),mt.effect===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:ge(K(st))})}),mt.patterns.length>0&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:o("settings.agents.page.permissionsEditor.ruleCount",{count:String(mt.patterns.length)})})]}),Ve(mt.effect,et=>ue(st,et),o("settings.agents.page.permissionsEditor.keyAria",{key:st}))]}),Pt&&Et&&s.jsxs("div",{className:"mt-2 space-y-2 ps-5",children:[mt.patterns.map((et,yt)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Ze,{value:et.pattern,onChange:Tt=>Ae(st,yt,Tt.target.value,et.effect,false),placeholder:o("settings.agents.page.permissionsEditor.patternPlaceholder"),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:st}),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(Wt,{value:et.effect,options:Se(),onChange:Tt=>Ae(st,yt,et.pattern,Tt,true),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:st})}),s.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>xe(st,yt),"aria-label":o("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx(ae,{name:"close",className:"h-3.5 w-3.5"})})]},yt)),s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>te(st),children:[s.jsx(ae,{name:"add",className:"me-1 h-3.5 w-3.5"}),o("settings.agents.page.permissionsEditor.actions.addRule")]})]})]},st)};Ee=Qe,e[109]!==o?(Ce=o("settings.agents.page.section.toolPermissions"),e[109]=o,e[110]=Ce):Ce=e[110],ce="agents.permissions",e[111]!==o?(ye=o("settings.agents.page.permissionsEditor.sectionInfo"),e[111]=o,e[112]=ye):ye=e[112],Z="space-y-4";let Je;e[113]!==o?(Je=o("settings.agents.page.permissionsEditor.defaultLabel"),e[113]=o,e[114]=Je):Je=e[114];let ot;e[115]!==Je?(ot=s.jsx("span",{className:ls,children:Je}),e[115]=Je,e[116]=ot):ot=e[116];let wt;e[117]!==o?(wt=o("settings.agents.page.permissionsEditor.defaultInfo"),e[117]=o,e[118]=wt):wt=e[118];let bt;e[119]!==wt?(bt=s.jsx(cs,{children:wt}),e[119]=wt,e[120]=bt):bt=e[120];let me;e[121]!==ge||e[122]!==K||e[123]!==f.global||e[124]!==o?(me=f.global===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:ge(K("*"))})}),e[121]=ge,e[122]=K,e[123]=f.global,e[124]=o,e[125]=me):me=e[125];let dt;e[126]!==ot||e[127]!==bt||e[128]!==me?(dt=s.jsxs("div",{className:"flex items-center gap-1.5",children:[ot,bt,me]}),e[126]=ot,e[127]=bt,e[128]=me,e[129]=dt):dt=e[129];const vt=f.global;let Ke;e[130]!==o?(Ke=o("settings.agents.page.permissionsEditor.defaultAria"),e[130]=o,e[131]=Ke):Ke=e[131],fe=s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[dt,Ve(vt,le,Ke,nt)]}),Ne=s.jsx("div",{children:Q.map(st=>Re(st,Wx(st),null))}),Ie=B.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-edge-muted pt-3 pb-1",children:[s.jsx("span",{className:ls,children:o("settings.agents.page.permissionsEditor.mcpTitle")}),s.jsx(cs,{children:o("settings.agents.page.permissionsEditor.mcpInfo")})]}),B.map(st=>Re(st.key,st.server,X(st.server)))]})}e[57]=ge,e[58]=K,e[59]=y,e[60]=v,e[61]=b,e[62]=B,e[63]=X,e[64]=f.global,e[65]=f.keys,e[66]=xe,e[67]=le,e[68]=ue,e[69]=Ae,e[70]=o,e[71]=Q,e[72]=Ee,e[73]=Ce,e[74]=ce,e[75]=ye,e[76]=Z,e[77]=fe,e[78]=Ne,e[79]=Ie,e[80]=$e}else Ee=e[72],Ce=e[73],ce=e[74],ye=e[75],Z=e[76],fe=e[77],Ne=e[78],Ie=e[79],$e=e[80];if($e!==Symbol.for("react.early_return_sentinel"))return $e;let L;e[132]===Symbol.for("react.memo_cache_sentinel")?(L=_e=>P(_e.target.value),e[132]=L):L=e[132];let se;e[133]!==we?(se=_e=>{_e.key==="Enter"&&(_e.preventDefault(),we())},e[133]=we,e[134]=se):se=e[134];let de;e[135]!==o?(de=o("settings.agents.page.permissionsEditor.customKeyPlaceholder"),e[135]=o,e[136]=de):de=e[136];let je;e[137]!==S||e[138]!==se||e[139]!==de?(je=s.jsx(Ze,{value:S,onChange:L,onKeyDown:se,placeholder:de,className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),e[137]=S,e[138]=se,e[139]=de,e[140]=je):je=e[140];let De;e[141]!==S?(De=S.trim(),e[141]=S,e[142]=De):De=e[142];const We=!De;let Be;e[143]===Symbol.for("react.memo_cache_sentinel")?(Be=s.jsx(ae,{name:"add",className:"me-1 h-3.5 w-3.5"}),e[143]=Be):Be=e[143];let Ge;e[144]!==o?(Ge=o("settings.agents.page.permissionsEditor.actions.addKey"),e[144]=o,e[145]=Ge):Ge=e[145];let Xe;e[146]!==we||e[147]!==We||e[148]!==Ge?(Xe=s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:we,disabled:We,children:[Be,Ge]}),e[146]=we,e[147]=We,e[148]=Ge,e[149]=Xe):Xe=e[149];let tt;e[150]!==je||e[151]!==Xe?(tt=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-edge-muted pt-3",children:[je,Xe]}),e[150]=je,e[151]=Xe,e[152]=tt):tt=e[152];let it;return e[153]!==Ee||e[154]!==Ce||e[155]!==ce||e[156]!==ye||e[157]!==Z||e[158]!==fe||e[159]!==Ne||e[160]!==Ie||e[161]!==tt?(it=s.jsxs(Ee,{title:Ce,settingsItem:ce,info:ye,contentClassName:Z,children:[fe,Ne,Ie,tt]}),e[153]=Ee,e[154]=Ce,e[155]=ce,e[156]=ye,e[157]=Z,e[158]=fe,e[159]=Ne,e[160]=Ie,e[161]=tt,e[162]=it):it=e[162],it};function Yx(t){return t.updateAgent}function Zx(t){return t.fetchAgentPermissions}function Xx(t){return t.loadMcpConfigs}function eb(t){return{key:`${t.name}_*`,server:t.name}}function tb(t){return t.key}function sb(t){return t+1}const _r=t=>{const e=Fe.c(11),{legacy:n,path:a,className:i}=t,{t:o}=Oe();if(!n)return null;let l;e[0]!==i?(l=He("mb-4 flex items-start gap-1.5",zt,i),e[0]=i,e[1]=l):l=e[1];const r=a??void 0;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(ae,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 opacity-70"}),e[2]=c):c=e[2];let u;e[3]!==o?(u=o("settings.common.legacyFormat.note"),e[3]=o,e[4]=u):u=e[4];let d;e[5]!==u?(d=s.jsx("span",{children:u}),e[5]=u,e[6]=d):d=e[6];let p;return e[7]!==l||e[8]!==r||e[9]!==d?(p=s.jsxs("p",{className:l,title:r,children:[c,d]}),e[7]=l,e[8]=r,e[9]=d,e[10]=p):p=e[10],p},nb=(t,e)=>{const n=Tn(e);if(!n)return[];const a=t.find(o=>o.id===n.providerId),i=kh(a?.models,n.modelId);return ju(i)},ab=t=>Zp(t)?.toLowerCase()??"",ib=()=>{const{t}=Oe(),e=pt(ge=>ge.providers),{selectedAgentName:n,getAgentByName:a,createAgent:i,updateAgent:o,fetchAgentEntity:l,agentDraft:r,setAgentDraft:c,setSelectedAgent:u}=In($s(ge=>({selectedAgentName:ge.selectedAgentName,getAgentByName:ge.getAgentByName,createAgent:ge.createAgent,updateAgent:ge.updateAgent,fetchAgentEntity:ge.fetchAgentEntity,agentDraft:ge.agentDraft,setAgentDraft:ge.setAgentDraft,setSelectedAgent:ge.setSelectedAgent}))),d=en(),p=In(ge=>yu(ge,d)),m=n?a(n,d):null,f=!!(r&&r.name===n&&!m),h=f?"":m?.description?.trim()??"",v=f?"":m?.system?.trim()??"",[x,b]=g.useState(""),[k,j]=g.useState("user"),[y,N]=g.useState(""),[S,P]=g.useState("subagent"),[w,I]=g.useState(""),[C,A]=g.useState(""),[E,D]=g.useState(void 0),[M,O]=g.useState(void 0),[R,F]=g.useState(void 0),[T,_]=g.useState(""),[$,z]=g.useState(""),[H,q]=g.useState(false),[J,U]=g.useState(null),B=g.useRef({}),W=g.useRef(null),Q=g.useCallback(ge=>{W.current=ge},[]),ee=g.useRef(null),X=JSON.stringify([n,d,f]),ne=g.useRef(X);ne.current=X;const K=g.useRef(null),ie={description:y,mode:S,model:w,variant:C,steps:E,temperature:M,topP:R,system:T,color:$},le=g.useRef(ie);le.current=ie;const be=g.useMemo(()=>nb(e,w),[w,e]),ue=be.length>0,Pe=C||"__default",Ae=ue,re=g.useMemo(()=>C&&!be.includes(C)?[C,...be]:be,[C,be]);g.useEffect(()=>{if(!f||!r)return;K.current=null;const ge=Ni(r.model),Ee=r.name||"",Ce=r.scope||"user",ce=r.description||"",ye=r.mode||"subagent",Z=ge?`${ge.providerID}/${ge.modelID}`:"",fe=ge?.variant||"",Ne=r.steps??void 0,Ie=r.temperature??void 0,$e=r.top_p??void 0,L=r.system||"",se="";B.current={},U(null),b(Ee),j(Ce),N(ce),P(ye),I(Z),A(fe),D(Ne),O(Ie),F($e),_(L),z(se),ee.current={draftName:Ee,draftScope:Ce,description:ce,mode:ye,model:Z,variant:fe,steps:Ne,temperature:Ie,topP:$e,system:L,color:se}},[r,f]),g.useEffect(()=>{if(f||!n)return;let ge=false;return(async()=>{const Ee=await l(n,d);if(ge||ne.current!==X||!Ee)return;const Ce=Ee.config;B.current=Ce;const ce=Ni(Ce.model),ye=Ce.request?.body,Z={draftName:"",draftScope:"user",description:Ce.description||"",mode:Ce.mode||m?.mode||"subagent",model:ce?`${ce.providerID}/${ce.modelID}`:"",variant:ce?.variant||"",steps:Ce.steps??void 0,temperature:ye?.temperature,topP:ye?.top_p,system:Ce.system||"",color:ab(Ce.color)},fe=ee.current,Ne=le.current,Ie=fe!==null&&(Ne.description!==fe.description||Ne.mode!==fe.mode||Ne.model!==fe.model||Ne.variant!==fe.variant||Ne.steps!==fe.steps||Ne.temperature!==fe.temperature||Ne.topP!==fe.topP||Ne.system!==fe.system||Ne.color!==fe.color);U({legacy:Ee.legacy===true,path:Ee.path,source:Ee.source}),!(K.current===X&&Ie)&&(K.current=X,N(Z.description),P(Z.mode),I(Z.model),A(Z.variant),D(Z.steps),O(Z.temperature),F(Z.topP),_(Z.system),z(Z.color),ee.current=Z)})(),()=>{ge=true}},[l,f,m,n,d,X]);const te=g.useCallback(ge=>{const Ee=Tn(w.trim()),Ce=Ee?Gu({providerID:Ee.providerId,modelID:Ee.modelId,variant:C.trim()||void 0}):null,ce=B.current.request,ye={...ce?.body};M===void 0?delete ye.temperature:ye.temperature=M,R===void 0?delete ye.top_p:ye.top_p=R;const Z=ce?.headers,fe={};Z&&Object.keys(Z).length>0&&(fe.headers=Z),Object.keys(ye).length>0&&(fe.body=ye);const Ne=y.trim(),Ie=T.trim(),$e={name:ge,mode:S,model:Ce,steps:E??null,system:Ie||(f?void 0:null),request:Object.keys(fe).length>0?fe:null};return Ne&&($e.description=Ne),$!==(ee.current?.color??"")&&($e.color=$||null),f&&k&&($e.scope=k),f&&r?.hidden!==void 0&&($e.hidden=r.hidden),f&&r?.permissions?.length&&($e.permissions=r.permissions),$e},[r,$,y,k,f,S,w,E,T,M,R,C]),he=g.useCallback(async()=>{const ge=ee.current,Ee=n?.trim();if(f||!ge||!Ee)return Vs;const Ce=W.current?await W.current():Vs;if(y===ge.description&&S===ge.mode&&w===ge.model&&C===ge.variant&&E===ge.steps&&M===ge.temperature&&R===ge.topP&&T===ge.system&&$===ge.color||!Ce.ok)return Ce;const ye=te(Ee);return(await o(Ee,ye,d)).ok?(ne.current!==X||(B.current={...B.current,model:ye.model,system:ye.system??void 0,steps:ye.steps,request:ye.request??void 0},ee.current={...ge,description:y,mode:S,model:w,variant:C,steps:E,temperature:M,topP:R,system:T,color:$}),Mn):vs(t("settings.agents.page.toast.updateFailed"))},[te,$,y,f,S,w,n,X,d,E,T,t,M,R,o,C]),xe=ai(he),{requestSave:ke}=xe,we=async()=>{const ge=x.trim().replace(/\s+/g,"-");if(!ge){Y.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(p.some(Ee=>Ee.name===ge)){Y.error(t("settings.agents.sidebar.toast.agentExists"));return}q(true);try{(await i(te(ge),d)).ok?(c(null),Y.success(t("settings.agents.page.toast.created"))):Y.error(t("settings.agents.page.toast.createFailed"))}catch(Ee){console.error("Error creating agent:",Ee);const Ce=Ee instanceof Error&&Ee.message?Ee.message:t("settings.agents.page.toast.saveUnexpectedError");Y.error(Ce)}finally{q(false)}},Te=()=>{c(null),u(null)};return n?s.jsxs(ns,{title:f?t("settings.agents.page.title.new"):n,description:t(f?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit"),onBlurCapture:xe.onBlurCapture,children:[!f&&J&&s.jsx(_r,{legacy:J.legacy,path:J.path}),!f&&J?.source==="none"&&s.jsxs("p",{className:`mb-4 flex items-start gap-1.5 ${zt}`,children:[s.jsx(ae,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 opacity-70"}),s.jsx("span",{children:t("settings.agents.page.runtimeProvided.note")})]}),s.jsxs(Qe,{title:t("settings.agents.page.section.identityRole"),contentClassName:"space-y-3",children:[f&&s.jsxs(at,{settingsItem:"agents.name",label:t("settings.agents.page.field.agentName"),children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground me-1",children:"@"}),s.jsx(Ze,{value:x,onChange:ge=>b(ge.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Ot,{value:k,onValueChange:ge=>j(ge),children:[s.jsx(Dt,{className:"w-fit min-w-[100px]",children:s.jsx(_t,{children:t(k==="project"?"settings.common.scope.project":"settings.common.scope.global")})}),s.jsxs(Ft,{align:"end",children:[s.jsx(ht,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ae,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(ht,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ae,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsx(It,{label:t("settings.common.field.description"),controlClassName:"w-full max-w-none",children:s.jsx(Os,{value:y,onChange:ge=>N(ge.target.value),placeholder:h||t("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})}),s.jsx(It,{settingsItem:"agents.mode",label:t("settings.agents.page.field.mode"),info:t("settings.agents.page.field.modeTooltip"),children:s.jsx(Wt,{"aria-label":t("settings.agents.page.field.mode"),value:S,onChange:ge=>{P(ge),ke()},options:[{value:"primary",label:t("settings.agents.page.mode.primary")},{value:"subagent",label:t("settings.agents.page.mode.subagent")},{value:"all",label:t("settings.agents.page.mode.all")}]})}),s.jsx(It,{settingsItem:"agents.color",label:t("settings.agents.page.field.color"),info:t("settings.agents.page.field.colorTooltip"),children:s.jsx(L1,{value:$,labels:{empty:t("settings.agents.page.field.colorAutomatic"),swatch:ge=>t("settings.agents.page.field.colorSwatchAria",{color:ge}),custom:t("settings.agents.page.field.colorCustomAria"),hex:t("settings.agents.page.field.colorHexAria")},onChange:ge=>{z(ge),ke()}})})]}),s.jsxs(Qe,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx(at,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx($n,{providerId:Tn(w)?.providerId??"",modelId:Tn(w)?.modelId??"",onChange:(ge,Ee)=>{I(ge&&Ee?`${ge}/${Ee}`:""),A(""),ke()},className:xn})}),s.jsx(at,{settingsItem:"agents.variant",label:t("settings.agents.page.field.variant"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.variantTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.variantHint")})]}),children:Ae?s.jsxs(Ot,{value:Pe,onValueChange:ge=>{A(ge==="__default"?"":ge),ke()},children:[s.jsx(Dt,{className:Ss,children:s.jsx(_t,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:ge=>ge==="__default"?t("chat.modelControls.default"):ge})}),s.jsxs(Ft,{children:[s.jsx(ht,{value:"__default",children:t("chat.modelControls.default")}),re.map(ge=>s.jsx(ht,{value:ge,children:ge},ge))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ze,{value:C,onChange:ge=>A(ge.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!w&&!C,className:"h-8 w-40 rounded-md px-3"}),C&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{A(""),ke()},className:ss,"aria-label":t("settings.common.actions.clear"),title:t("settings.common.actions.clear"),children:s.jsx(ae,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsxs(at,{settingsItem:"agents.temperature",label:t("settings.agents.page.field.temperature"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.temperatureTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.temperatureRange")})]}),children:[s.jsx(hs,{value:M,fallbackValue:.7,onValueChange:O,onClear:()=>{O(void 0),ke()},min:0,max:2,step:.1,inputMode:"decimal",placeholder:"\u2014",emptyLabel:"\u2014",className:xs}),M!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{O(void 0),ke()},className:ss,"aria-label":t("settings.agents.page.field.clearTemperatureAria"),title:t("settings.common.actions.clear"),children:s.jsx(ae,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(at,{settingsItem:"agents.top-p",label:t("settings.agents.page.field.topP"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.topPTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.topPRange")})]}),children:[s.jsx(hs,{value:R,fallbackValue:.9,onValueChange:F,onClear:()=>{F(void 0),ke()},min:0,max:1,step:.1,inputMode:"decimal",placeholder:"\u2014",emptyLabel:"\u2014",className:xs}),R!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{F(void 0),ke()},className:ss,"aria-label":t("settings.agents.page.field.clearTopPAria"),title:t("settings.common.actions.clear"),children:s.jsx(ae,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(at,{settingsItem:"agents.steps",label:t("settings.agents.page.field.steps"),info:t("settings.agents.page.field.stepsTooltip"),children:[s.jsx(hs,{value:E,fallbackValue:20,onValueChange:D,onClear:()=>{D(void 0),ke()},min:1,max:1e3,step:1,inputMode:"numeric",placeholder:"\u2014",emptyLabel:"\u2014",className:xs}),E!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{D(void 0),ke()},className:ss,"aria-label":t("settings.agents.page.field.clearStepsAria"),title:t("settings.common.actions.clear"),children:s.jsx(ae,{name:"close",className:"h-3.5 w-3.5"})})]})]}),s.jsx(Qe,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx(Os,{value:T,onChange:ge=>_(ge.target.value),placeholder:v||t("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent"})}),!f&&m&&s.jsx(Qx,{agent:m,registerSave:Q,requestSave:ke}),f&&s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[s.jsx(G,{onClick:()=>{we()},disabled:H||!x.trim(),size:"xs",className:"!font-normal",children:t(H?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(G,{variant:"ghost",onClick:Te,disabled:H,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(ae,{name:"robot-2",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-ui-label",children:t("settings.agents.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.agents.page.empty.description")})]})})};function ob(t,e){return t.kind==="file"?t.content:e??""}const Vc=es({content:At(),exists:Hi(),path:At().min(1).optional()}),lb=async(t,e)=>{const n=await t.json().catch(()=>null);return typeof n?.error=="string"&&n.error.trim()?n.error:e},rb=t=>t.length>0&&!t.endsWith(`
3
3
  `)?`${t}
4
4
  `:t,ro={prompt:"",responseStyleEnabled:false,responseStylePreset:"concise",responseStyleCustomInstructions:""},cb=(t,e)=>t==="custom"?e:eg(t),db=t=>t==="custom"?"custom":ku(t)?t:"concise",Hc={concise:"settings.behavior.page.responseStyle.option.concise",detailed:"settings.behavior.page.responseStyle.option.detailed",mentor:"settings.behavior.page.responseStyle.option.mentor",pushback:"settings.behavior.page.responseStyle.option.pushback",noFiller:"settings.behavior.page.responseStyle.option.noFiller",matchEnergy:"settings.behavior.page.responseStyle.option.matchEnergy",warmPeer:"settings.behavior.page.responseStyle.option.warmPeer"},ub=()=>{const{t}=Oe(),[e,n]=g.useState(""),[a,i]=g.useState("AGENTS.md"),[o,l]=g.useState(ro.responseStyleEnabled),[r,c]=g.useState(ro.responseStylePreset),[u,d]=g.useState(ro.responseStyleCustomInstructions),[p,m]=g.useState(true),f=g.useRef(null),h=g.useRef(null);g.useEffect(()=>{const y=new AbortController;return(async()=>{try{const[S,P]=await Promise.all([Zs(),Gt("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:y.signal})]);let w=ro,I;S&&(w={...w,responseStyleEnabled:S.responseStyleEnabled===true,responseStylePreset:db(S.responseStylePreset),responseStyleCustomInstructions:S.responseStyleCustomInstructions??""},S.globalBehaviorPrompt!==void 0&&(I=S.globalBehaviorPrompt));let C={kind:"missing"};if(P.ok){const A=Vc.parse(await P.json());if(y.signal.aborted)return;i(A.path??"AGENTS.md"),h.current=A.exists?A.content:null,A.exists&&(C={kind:"file",content:A.content})}w={...w,prompt:ob(C,I)},n(w.prompt),l(w.responseStyleEnabled),c(w.responseStylePreset),d(w.responseStyleCustomInstructions),f.current=w}catch(S){S.name!=="AbortError"&&console.warn("Failed to load behavior settings:",S)}finally{m(false)}})(),()=>y.abort()},[]);const v=g.useRef(e);v.current=e,g.useEffect(()=>{let y=null;const N=async()=>{if(document.visibilityState!=="visible"||!f.current)return;y?.abort();const P=new AbortController;y=P;try{const w=await Gt("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:P.signal});if(!w.ok)return;const I=Vc.parse(await w.json()),C=f.current;if(P.signal.aborted||!C||!I.exists||I.content===h.current||v.current!==C.prompt)return;h.current=I.content,f.current={...C,prompt:I.content},n(I.content)}catch(w){w instanceof DOMException&&w.name==="AbortError"||console.warn("Failed to refresh AGENTS.md:",w)}},S=()=>{N()};return window.addEventListener("focus",S),document.addEventListener("visibilitychange",S),()=>{y?.abort(),window.removeEventListener("focus",S),document.removeEventListener("visibilitychange",S)}},[]);const x=g.useCallback(async()=>{const y=f.current;if(!y||p)return Vs;const N=e!==y.prompt,S=o!==y.responseStyleEnabled||r!==y.responseStylePreset||u!==y.responseStyleCustomInstructions;if(!N&&!S)return Vs;const P=N?rb(e):y.prompt;if(N){const I=await Gt("/api/behavior/agents-md",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:P,expectedContent:h.current})});if(I.status===409)return vs(t("settings.behavior.page.toast.agentsMdChangedOnDisk"));if(!I.ok)return vs(await lb(I,t("settings.behavior.page.toast.saveFailed")));h.current=P,n(C=>C===e?P:C)}return(await kt({...N?{globalBehaviorPrompt:P}:{},responseStyleEnabled:o,responseStylePreset:r,responseStyleCustomInstructions:u})).ok?(f.current={prompt:P,responseStyleEnabled:o,responseStylePreset:r,responseStyleCustomInstructions:u},Mn):vs(t("settings.behavior.page.toast.saveFailed"))},[p,e,u,o,r,t]),b=ai(x),{requestSave:k}=b,j=cb(r,u);return s.jsxs(ns,{title:t("settings.behavior.page.title"),namedBySidebar:true,onBlurCapture:b.onBlurCapture,children:[s.jsx(Qe,{title:t("settings.behavior.page.section.systemPrompt"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"font-medium text-foreground",children:t("settings.behavior.page.warning.title")}),s.jsx("p",{children:t("settings.behavior.page.warning.description",{path:a})})]}),settingsItem:"behavior.system-prompt",contentClassName:"space-y-3",children:s.jsx(Os,{value:e,onChange:y=>n(y.target.value),placeholder:t("settings.behavior.page.field.systemPromptPlaceholder"),rows:12,disabled:p,outerClassName:"min-h-[160px] max-h-[70vh]",className:"w-full font-mono typography-meta bg-transparent"})}),s.jsxs(Qe,{title:t("settings.behavior.page.section.responseStyle"),info:t("settings.behavior.page.responseStyle.tooltip"),settingsItem:"behavior.response-style",contentClassName:"space-y-3",children:[s.jsx(ut,{checked:o,onChange:y=>{l(y),k()},disabled:p,label:t("settings.behavior.page.responseStyle.enable"),ariaLabel:t("settings.behavior.page.responseStyle.enableAria")}),s.jsx(at,{label:t("settings.behavior.page.responseStyle.preset"),alignEnd:false,children:s.jsxs(Ot,{value:r,onValueChange:y=>{c(y),k()},disabled:p||!o,children:[s.jsx(Dt,{className:Ss,children:s.jsx(_t,{children:y=>y==="custom"?t("settings.behavior.page.responseStyle.option.custom"):ku(y)?t(Hc[y]):null})}),s.jsxs(Ft,{children:[Xp.map(y=>s.jsx(ht,{value:y,children:t(Hc[y])},y)),s.jsx(ht,{value:"custom",children:t("settings.behavior.page.responseStyle.option.custom")})]})]})}),s.jsx(Os,{value:j,onChange:y=>d(y.target.value),placeholder:t("settings.behavior.page.responseStyle.customPlaceholder"),rows:5,disabled:p||!o||r!=="custom",outerClassName:"min-h-[120px]",className:"w-full font-mono typography-meta bg-transparent"})]})]})},mb=(t,e)=>t.kind===e.kind&&(t.kind!=="provider"||e.kind==="provider"&&t.id===e.id),pb=t=>[...t.providers.map(e=>({provider:e,access:t.access?.[e.id]??null,usable:true})),...t.connectable.map(e=>({provider:e,access:t.access?.[e.id]??null,usable:false}))].sort((e,n)=>e.provider.name.localeCompare(n.provider.name,void 0,{sensitivity:"base"})),$r=t=>{const e=Fe.c(8),{t:n}=Oe(),a=Ei(vb),i=t.projectOverride!==null;let o;e[0]!==i||e[1]!==a||e[2]!==t.selection||e[3]!==n?(o=c=>{i||mb(c,t.selection)||a(c).then(u=>{u||Y.error(n("settings.webSearch.toast.saveFailed"))})},e[0]=i,e[1]=a,e[2]=t.selection,e[3]=n,e[4]=o):o=e[4];const l=o;let r;return e[5]!==l||e[6]!==i?(r={choose:l,locked:i},e[5]=l,e[6]=i,e[7]=r):r=e[7],r},gb=t=>{const e=Fe.c(51),{snapshot:n}=t,{t:a}=Oe(),{choose:i,locked:o}=$r(n),l=n.selection;let r,c;if(e[0]!==o||e[1]!==l.id||e[2]!==l.kind||e[3]!==n.providers||e[4]!==a){const j=l.kind==="provider"?n.providers.find(C=>C.id===l.id)?.name??null:null;let y;e[7]!==a?(y=a("settings.webSearch.option.default"),e[7]=a,e[8]=y):y=e[8];let N;e[9]!==o||e[10]!==y?(N={value:"default",label:y,disabled:o},e[9]=o,e[10]=y,e[11]=N):N=e[11];let S;e[12]!==o||e[13]!==n.providers.length||e[14]!==a?(S=n.providers.length>0?[{value:"random",label:a("settings.webSearch.option.random"),disabled:o}]:[],e[12]=o,e[13]=n.providers.length,e[14]=a,e[15]=S):S=e[15];let P;e[16]!==a?(P=a("settings.webSearch.option.off"),e[16]=a,e[17]=P):P=e[17];let w;e[18]!==o||e[19]!==P?(w={value:"off",label:P,disabled:o},e[18]=o,e[19]=P,e[20]=w):w=e[20];let I;e[21]!==N||e[22]!==S||e[23]!==w?(I=[N,...S,w],e[21]=N,e[22]=S,e[23]=w,e[24]=I):I=e[24],r=I,c=l.kind==="default"?a("settings.webSearch.option.defaultDescription"):l.kind==="random"?a("settings.webSearch.option.randomDescription"):l.kind==="off"?a("settings.webSearch.mode.offDescription"):j?a("settings.webSearch.mode.providerDescription",{provider:j}):a("settings.webSearch.mode.missingDescription",{provider:l.id}),e[0]=o,e[1]=l.id,e[2]=l.kind,e[3]=n.providers,e[4]=a,e[5]=r,e[6]=c}else r=e[5],c=e[6];const u=c;let d;e[25]!==a?(d=a("settings.webSearch.section.provider"),e[25]=a,e[26]=d):d=e[26];let p;e[27]!==a?(p=a("settings.webSearch.section.providerInfo"),e[27]=a,e[28]=p):p=e[28];let m;e[29]!==a?(m=a("settings.webSearch.section.provider"),e[29]=a,e[30]=m):m=e[30];let f;e[31]!==i?(f=j=>{j!=="provider"&&i({kind:j})},e[31]=i,e[32]=f):f=e[32];let h;e[33]!==r||e[34]!==l.kind||e[35]!==m||e[36]!==f?(h=s.jsx(Wt,{"aria-label":m,value:l.kind,options:r,onChange:f}),e[33]=r,e[34]=l.kind,e[35]=m,e[36]=f,e[37]=h):h=e[37];let v;e[38]!==u?(v=s.jsx("p",{className:zt,children:u}),e[38]=u,e[39]=v):v=e[39];let x;e[40]!==n.projectOverride||e[41]!==a?(x=n.projectOverride?s.jsx("p",{className:`${zt} break-all`,children:a("settings.webSearch.state.projectOverride",{path:n.projectOverride})}):null,e[40]=n.projectOverride,e[41]=a,e[42]=x):x=e[42];let b;e[43]!==h||e[44]!==v||e[45]!==x?(b=s.jsxs("div",{className:"space-y-2",children:[h,v,x]}),e[43]=h,e[44]=v,e[45]=x,e[46]=b):b=e[46];let k;return e[47]!==d||e[48]!==p||e[49]!==b?(k=s.jsx(Qe,{title:d,info:p,settingsItem:"web-search.provider",children:b}),e[47]=d,e[48]=p,e[49]=b,e[50]=k):k=e[50],k},fb=t=>{const e=Fe.c(32),{entry:n,snapshot:a,onOpen:i}=t,{t:o}=Oe(),{choose:l,locked:r}=$r(a),{provider:c,access:u,usable:d}=n,p=a.selection.kind==="provider"&&a.selection.id===c.id,m=u?.key,f=u?.connect?.kind==="key";let h;e[0]!==p||e[1]!==m?.kind||e[2]!==o||e[3]!==f||e[4]!==d?(h=p?s.jsx(Rs,{tone:"success",children:o("settings.webSearch.card.inUse")}):!d&&m?.kind==="none"?s.jsx(Rs,{tone:"warning",children:o(f?"settings.webSearch.card.needsKey":"settings.webSearch.card.needsSetup")}):null,e[0]=p,e[1]=m?.kind,e[2]=o,e[3]=f,e[4]=d,e[5]=h):h=e[5];const v=h;let x;e[6]!==m||e[7]!==o||e[8]!==f||e[9]!==d?(x=m?.kind==="stored"?o(f?"settings.webSearch.keys.saved":"settings.webSearch.keys.connected"):m?.kind==="env"?o("settings.webSearch.keys.fromEnv",{name:m.name}):d&&m?.kind==="none"?o("settings.webSearch.card.keyOptional"):null,e[6]=m,e[7]=o,e[8]=f,e[9]=d,e[10]=x):x=e[10];const b=x;let k;e[11]!==l||e[12]!==p||e[13]!==r||e[14]!==c.id||e[15]!==o||e[16]!==d?(k=d&&!p&&!r?[{label:o("settings.webSearch.actions.use"),icon:"check",onSelect:()=>l({kind:"provider",id:c.id})}]:[],e[11]=l,e[12]=p,e[13]=r,e[14]=c.id,e[15]=o,e[16]=d,e[17]=k):k=e[17];const j=k;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(Mi,{name:"global"}),e[18]=y):y=e[18];const N=c.name;let S;e[19]!==b?(S=b?s.jsx("span",{className:"min-w-0 truncate",children:b}):null,e[19]=b,e[20]=S):S=e[20];const P=!d&&m?.kind==="none";let w;e[21]!==c.name||e[22]!==o?(w=o("settings.webSearch.card.actions",{provider:c.name}),e[21]=c.name,e[22]=o,e[23]=w):w=e[23];let I;return e[24]!==j||e[25]!==i||e[26]!==v||e[27]!==c.name||e[28]!==S||e[29]!==P||e[30]!==w?(I=s.jsx(Rn,{icon:y,title:N,badges:v,footer:S,muted:P,onOpen:i,actions:j,actionsLabel:w}),e[24]=j,e[25]=i,e[26]=v,e[27]=c.name,e[28]=S,e[29]=P,e[30]=w,e[31]=I):I=e[31],I},hb=t=>{const e=Fe.c(82),{provider:n,access:a,connect:i,locked:o}=t,{t:l}=Oe(),r=Ei(yb),c=Ei(jb),[u,d]=g.useState("");let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];const[m,f]=g.useState(p),[h,v]=g.useState(false),x=i.kind==="key";let b;if(e[1]!==a.envNames||e[2]!==i.fields||e[3]!==l||e[4]!==x){const T=a.envNames.join(", ");let _;e[6]!==l?(_=z=>[z.description,z.placeholder?l("settings.webSearch.keys.fieldExample",{example:z.placeholder}):null],e[6]=l,e[7]=_):_=e[7];const $=[...i.fields.flatMap(_),a.envNames.length===0?null:x?l("settings.webSearch.keys.envHint",{names:T}):l("settings.webSearch.keys.envHintForm",{names:T})].filter(kb);b=$.length>0?$.map(wb):void 0,e[1]=a.envNames,e[2]=i.fields,e[3]=l,e[4]=x,e[5]=b}else b=e[5];const k=b;let j;e[8]!==m?(j=Object.fromEntries(Object.entries(m).map(Sb).filter(Nb)),e[8]=m,e[9]=j):j=e[9];const y=j;let N;e[10]!==i.fields||e[11]!==u||e[12]!==y||e[13]!==x?(N=(!x||u.trim()!=="")&&i.fields.every(T=>!T.required||y[T.key]!==void 0),e[10]=i.fields,e[11]=u,e[12]=y,e[13]=x,e[14]=N):N=e[14];const S=N;let P;e[15]!==S||e[16]!==u||e[17]!==y||e[18]!==n.id||e[19]!==n.name||e[20]!==r||e[21]!==l||e[22]!==x?(P=async()=>{if(!S)return;v(true);const T=await r(n.id,{key:u.trim(),answer:y});v(false),T?(d(""),f({}),Y.success(x?l("settings.webSearch.toast.keySaved",{provider:n.name}):l("settings.webSearch.toast.connected",{provider:n.name}))):Y.error(x?l("settings.webSearch.toast.keySaveFailed"):l("settings.webSearch.toast.connectFailed",{provider:n.name}))},e[15]=S,e[16]=u,e[17]=y,e[18]=n.id,e[19]=n.name,e[20]=r,e[21]=l,e[22]=x,e[23]=P):P=e[23];const w=P;let I;e[24]!==n.id||e[25]!==c||e[26]!==l?(I=async()=>{v(true);const T=await c(n.id);v(false),T||Y.error(l("settings.webSearch.toast.keyRemoveFailed"))},e[24]=n.id,e[25]=c,e[26]=l,e[27]=I):I=e[27];const C=I;let A;e[28]!==w?(A=T=>{T.key==="Enter"&&w()},e[28]=w,e[29]=A):A=e[29];const E=A;let D,M,O,R;if(e[30]!==a.key||e[31]!==m||e[32]!==h||e[33]!==S||e[34]!==i.fields||e[35]!==u||e[36]!==C||e[37]!==w||e[38]!==k||e[39]!==o||e[40]!==n.name||e[41]!==E||e[42]!==l||e[43]!==x){let T;e[48]!==m||e[49]!==n.name||e[50]!==E||e[51]!==l?(T=Q=>s.jsx(Ze,{type:Q.url?"url":"text",value:m[Q.key]??"",onChange:ee=>f(X=>({...X,[Q.key]:ee.target.value})),onKeyDown:E,placeholder:Q.label,"aria-label":l("settings.webSearch.keys.fieldAria",{provider:n.name,field:Q.label}),className:"h-8 min-w-0 flex-1 rounded-md px-3 font-mono text-xs"},Q.key),e[48]=m,e[49]=n.name,e[50]=E,e[51]=l,e[52]=T):T=e[52];const _=i.fields.map(T);if(x){let Q;e[53]===Symbol.for("react.memo_cache_sentinel")?(Q=K=>d(K.target.value),e[53]=Q):Q=e[53];let ee;e[54]!==l?(ee=l("settings.webSearch.keys.placeholder"),e[54]=l,e[55]=ee):ee=e[55];let X;e[56]!==n.name||e[57]!==l?(X=l("settings.webSearch.keys.inputAria",{provider:n.name}),e[56]=n.name,e[57]=l,e[58]=X):X=e[58];let ne;e[59]!==u||e[60]!==E||e[61]!==ee||e[62]!==X?(ne=s.jsx(Ze,{type:"password",value:u,onChange:Q,onKeyDown:E,placeholder:ee,"aria-label":X,className:"h-8 min-w-0 flex-1 rounded-md px-3 font-mono text-xs"},"key"),e[59]=u,e[60]=E,e[61]=ee,e[62]=X,e[63]=ne):ne=e[63],_.push(ne)}const $=h||!S;let z;e[64]!==w?(z=()=>{w()},e[64]=w,e[65]=z):z=e[65];let H;e[66]!==l?(H=l("settings.webSearch.keys.save"),e[66]=l,e[67]=H):H=e[67];let q;e[68]!==$||e[69]!==z||e[70]!==H?(q=s.jsx(G,{size:"xs",disabled:$,onClick:z,children:H}),e[68]=$,e[69]=z,e[70]=H,e[71]=q):q=e[71];const J=q,U=a.key;let B;e[72]!==i.fields[0]||e[73]!==i.fields.length||e[74]!==l||e[75]!==x?(B=x?l("settings.webSearch.keys.label"):i.fields.length===1&&i.fields[0]?i.fields[0].label:l("settings.webSearch.keys.connectionLabel"),e[72]=i.fields[0],e[73]=i.fields.length,e[74]=l,e[75]=x,e[76]=B):B=e[76];const W=B;D=at,O=W,R=k,M=U.kind==="stored"?s.jsxs("div",{className:`${zs} flex items-center justify-end gap-2`,children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:l(x?"settings.webSearch.keys.saved":"settings.webSearch.keys.connected")}),s.jsx(G,{variant:"outline",size:"xs",disabled:h,onClick:()=>{C()},children:l("settings.webSearch.keys.remove")})]}):U.kind==="env"?s.jsx("span",{className:"typography-meta text-muted-foreground",children:l("settings.webSearch.keys.fromEnv",{name:U.name})}):o?null:_.length===1?s.jsxs("div",{className:`${zs} flex items-center gap-2`,children:[_,J]}):s.jsxs("div",{className:`${zs} flex flex-col gap-2`,children:[_.slice(0,-1).map(Cb),s.jsxs("div",{className:"flex items-center gap-2",children:[_.at(-1),J]})]}),e[30]=a.key,e[31]=m,e[32]=h,e[33]=S,e[34]=i.fields,e[35]=u,e[36]=C,e[37]=w,e[38]=k,e[39]=o,e[40]=n.name,e[41]=E,e[42]=l,e[43]=x,e[44]=D,e[45]=M,e[46]=O,e[47]=R}else D=e[44],M=e[45],O=e[46],R=e[47];let F;return e[77]!==D||e[78]!==M||e[79]!==O||e[80]!==R?(F=s.jsx(D,{label:O,info:R,children:M}),e[77]=D,e[78]=M,e[79]=O,e[80]=R,e[81]=F):F=e[81],F},xb=t=>{const e=Fe.c(44),{entry:n,snapshot:a,onBack:i}=t,{t:o}=Oe(),{choose:l,locked:r}=$r(a),c=Dn(),{provider:u,access:d,usable:p}=n,m=a.selection.kind==="provider"&&a.selection.id===u.id,f=d?.connect??null;let h;e[0]!==f?.kind||e[1]!==m||e[2]!==u.name||e[3]!==o||e[4]!==p?(h=m?o("settings.webSearch.mode.providerDescription",{provider:u.name}):p?null:f?.kind==="form"?o("settings.webSearch.detail.needsSetup",{provider:u.name}):o("settings.webSearch.detail.needsKey",{provider:u.name}),e[0]=f?.kind,e[1]=m,e[2]=u.name,e[3]=o,e[4]=p,e[5]=h):h=e[5];const v=h,x=u.name;let b;e[6]!==o?(b=o("settings.webSearch.detail.back"),e[6]=o,e[7]=b):b=e[7];let k;e[8]!==i||e[9]!==b?(k=s.jsx(Xa,{label:b,onClick:i}),e[8]=i,e[9]=b,e[10]=k):k=e[10];let j;e[11]!==v?(j=v?s.jsx("p",{className:"typography-meta text-foreground",children:v}):null,e[11]=v,e[12]=j):j=e[12];let y;e[13]!==l||e[14]!==m||e[15]!==r||e[16]!==u.id||e[17]!==o||e[18]!==p?(y=p&&!m?s.jsx(G,{size:"sm",disabled:r,onClick:()=>l({kind:"provider",id:u.id}),children:o("settings.webSearch.actions.use")}):null,e[13]=l,e[14]=m,e[15]=r,e[16]=u.id,e[17]=o,e[18]=p,e[19]=y):y=e[19];let N;e[20]!==a.projectOverride||e[21]!==o?(N=a.projectOverride?s.jsx("p",{className:`${zt} break-all`,children:o("settings.webSearch.state.projectOverride",{path:a.projectOverride})}):null,e[20]=a.projectOverride,e[21]=o,e[22]=N):N=e[22];let S;e[23]!==j||e[24]!==y||e[25]!==N?(S=s.jsx(Qe,{children:s.jsxs("div",{className:"space-y-2",children:[j,y,N]})}),e[23]=j,e[24]=y,e[25]=N,e[26]=S):S=e[26];let P;e[27]!==c||e[28]!==o?(P=c?s.jsx("p",{className:zt,children:o("settings.webSearch.keys.enterpriseMode")}):null,e[27]=c,e[28]=o,e[29]=P):P=e[29];let w;e[30]!==d||e[31]!==f||e[32]!==c||e[33]!==u||e[34]!==o?(w=d===null?s.jsx("p",{className:zt,children:o("settings.webSearch.state.keysUnavailable")}):f?s.jsx(hb,{provider:u,access:d,connect:f,locked:c}):s.jsx("p",{className:zt,children:o("settings.webSearch.detail.noKey")}),e[30]=d,e[31]=f,e[32]=c,e[33]=u,e[34]=o,e[35]=w):w=e[35];let I;e[36]!==w||e[37]!==P?(I=s.jsx(Qe,{children:s.jsxs("div",{className:"space-y-4",children:[P,w]})}),e[36]=w,e[37]=P,e[38]=I):I=e[38];let C;return e[39]!==u.name||e[40]!==I||e[41]!==k||e[42]!==S?(C=s.jsxs(ns,{title:x,titleLeading:k,showSaveStatus:true,children:[S,I]}),e[39]=u.name,e[40]=I,e[41]=k,e[42]=S,e[43]=C):C=e[43],C},bb=()=>{const t=Fe.c(14),{t:e}=Oe(),n=Ei(Ib),a=Ei(Pb),[i,o]=g.useState(null);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=tg(),t[0]=l):l=t[0];const r=l;let c,u;t[1]!==a?(c=()=>{a()},u=[a,r],t[1]=a,t[2]=c,t[3]=u):(c=t[2],u=t[3]),g.useEffect(c,u);const d=n.kind==="ready"&&n.snapshot.scope===r?n.snapshot:null;let p,m;if(t[4]!==a||t[5]!==i||t[6]!==d||t[7]!==n.kind||t[8]!==e){m=Symbol.for("react.early_return_sentinel");e:{const f=d?pb(d):[],h=i?f.find(x=>x.provider.id===i)??null:null;if(d&&h){let x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=()=>o(null),t[11]=x):x=t[11],m=s.jsx(xb,{entry:h,snapshot:d,onBack:x});break e}let v;t[12]!==e?(v=e("settings.page.webSearch.title"),t[12]=e,t[13]=v):v=t[13],p=s.jsx(ns,{title:v,namedBySidebar:true,showSaveStatus:true,children:d?s.jsxs(s.Fragment,{children:[s.jsx(gb,{snapshot:d}),s.jsxs(Qe,{title:e("settings.webSearch.section.providers"),info:e("settings.webSearch.section.providersInfo"),settingsItem:"web-search.providers",children:[f.length===0?s.jsx("p",{className:zt,children:e("settings.webSearch.state.noProviders")}):s.jsx("div",{className:si,children:f.map(x=>s.jsx(fb,{entry:x,snapshot:d,onOpen:()=>o(x.provider.id)},x.provider.id))}),d.access===null?s.jsx("p",{className:`${zt} mt-3`,children:e("settings.webSearch.state.keysUnavailable")}):null]})]}):n.kind==="failed"?s.jsx(Qe,{children:s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("settings.webSearch.state.loadFailed")}),s.jsx(G,{variant:"outline",size:"xs",onClick:()=>{a()},children:e("settings.webSearch.actions.retry")})]})}):s.jsx(Qe,{children:s.jsx("p",{className:zt,children:e("settings.webSearch.state.loading")})})})}t[4]=a,t[5]=i,t[6]=d,t[7]=n.kind,t[8]=e,t[9]=p,t[10]=m}else p=t[9],m=t[10];return m!==Symbol.for("react.early_return_sentinel")?m:p};function vb(t){return t.setSelection}function yb(t){return t.saveKey}function jb(t){return t.removeKey}function kb(t){return!!t}function wb(t){return s.jsx("span",{className:"block",children:t},t)}function Sb(t){const[e,n]=t;return[e,n.trim()]}function Nb(t){const[,e]=t;return e!==""}function Cb(t,e){return s.jsx("div",{className:"flex",children:t},e)}function Ib(t){return t.state}function Pb(t){return t.load}const Ab=t=>{const e=Fe.c(183),{onItemSelect:n}=t,{t:a}=Oe(),[i,o]=g.useState(""),[l,r]=g.useState(null),[c,u]=g.useState(""),[d,p]=g.useState(null),[m,f]=g.useState(null),[h,v]=g.useState(false),[x,b]=g.useState(null),{selectedCommandName:k,setSelectedCommand:j,setCommandDraft:y,createCommand:N,deleteCommand:S,loadCommands:P}=Qa($s(Eb)),w=en();let I;e[0]!==w?(I=Ke=>wu(Ke,w),e[0]=w,e[1]=I):I=e[1];const C=Qa(I);let A;e[2]!==w?(A=Ke=>br(Ke,w),e[2]=w,e[3]=A):A=e[3];const E=_s(A),D=_s(Tb);let M,O;e[4]!==P||e[5]!==D||e[6]!==w?(M=()=>{P(w),D(w)},O=[P,D,w],e[4]=P,e[5]=D,e[6]=w,e[7]=M,e[8]=O):(M=e[7],O=e[8]),g.useEffect(M,O);let R;e[9]!==E?(R=new Set(E.map(Rb)),e[9]=E,e[10]=R):R=e[10];const F=R;let T;if(e[11]!==C||e[12]!==F){let Ke;e[14]!==F?(Ke=st=>!F.has(st.name),e[14]=F,e[15]=Ke):Ke=e[15],T=C.filter(Ke),e[11]=C,e[12]=F,e[13]=T}else T=e[13];const _=T;let $,z;e[16]!==k||e[17]!==j||e[18]!==F?($=()=>{k&&F.has(k)&&j(null)},z=[k,j,F],e[16]=k,e[17]=j,e[18]=F,e[19]=$,e[20]=z):($=e[19],z=e[20]),g.useEffect($,z);let H;e[21]!==C||e[22]!==n||e[23]!==y||e[24]!==j?(H=()=>{let Ke="new-command",st=1;for(;C.some(rt=>rt.name===Ke);)Ke=`new-command-${st}`,st++;y({name:Ke,scope:"user"}),j(Ke),n?.()},e[21]=C,e[22]=n,e[23]=y,e[24]=j,e[25]=H):H=e[25];const q=H;let J;e[26]!==a?(J=async Ke=>{if(Ha(Ke)){Y.error(a("settings.commands.sidebar.toast.builtInCannotDelete"));return}p(Ke),f("delete")},e[26]=a,e[27]=J):J=e[27];const U=J;let B;e[28]===Symbol.for("react.memo_cache_sentinel")?(B=async Ke=>{Ha(Ke)&&(p(Ke),f("reset"))},e[28]=B):B=e[28];const W=B;let Q;e[29]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>{p(null),f(null)},e[29]=Q):Q=e[29];const ee=Q;let X;e[30]!==d||e[31]!==m||e[32]!==S||e[33]!==w||e[34]!==a?(X=async()=>{if(!d||!m)return;v(true),await S(d.name,w)?(m==="delete"?Y.success(a("settings.commands.sidebar.toast.commandDeleted",{name:d.name})):Y.success(a("settings.commands.sidebar.toast.commandReset",{name:d.name})),ee()):m==="delete"?Y.error(a("settings.commands.sidebar.toast.deleteFailed")):Y.error(a("settings.commands.sidebar.toast.resetFailed")),v(false)},e[30]=d,e[31]=m,e[32]=S,e[33]=w,e[34]=a,e[35]=X):X=e[35];const ne=X;let K;e[36]!==C||e[37]!==y||e[38]!==j?(K=Ke=>{const st=Ke.name;let rt=1,St=`${st}-copy`;for(;C.some(mt=>mt.name===St);)rt++,St=`${st}-copy-${rt}`;y({name:St,scope:Ke.scope||"user",description:Ke.description,template:Ke.template,agent:Ke.agent,model:Ke.model,subagent:Ke.subagent}),j(St)},e[36]=C,e[37]=y,e[38]=j,e[39]=K):K=e[39];const ie=K;let le;e[40]===Symbol.for("react.memo_cache_sentinel")?(le=Ke=>{u(Ke.name),r(Ke)},e[40]=le):le=e[40];const be=le;let ue;e[41]!==C||e[42]!==N||e[43]!==S||e[44]!==l||e[45]!==c||e[46]!==j||e[47]!==w||e[48]!==a?(ue=async()=>{if(!l)return;const Ke=c.trim().replace(/\s+/g,"-");if(!Ke){Y.error(a("settings.commands.sidebar.toast.commandNameRequired"));return}if(Ke===l.name){r(null);return}if(C.some(rt=>rt.name===Ke)){Y.error(a("settings.commands.sidebar.toast.commandExists"));return}await N({name:Ke,description:l.description,template:l.template,agent:l.agent,model:l.model,subagent:l.subagent,scope:l.scope},w)?await S(l.name,w)?(Y.success(`Command renamed to "${Ke}"`),j(Ke)):Y.error(a("settings.commands.sidebar.toast.removeOldAfterRenameFailed")):Y.error(a("settings.commands.sidebar.toast.renameFailed")),r(null)},e[41]=C,e[42]=N,e[43]=S,e[44]=l,e[45]=c,e[46]=j,e[47]=w,e[48]=a,e[49]=ue):ue=e[49];const Pe=ue;let Ae,re,te,he,xe,ke;if(e[50]!==_||e[51]!==q||e[52]!==U||e[53]!==ie||e[54]!==n||e[55]!==x||e[56]!==i||e[57]!==k||e[58]!==j||e[59]!==a){let Ke;e[66]!==i?(Ke=pe=>Ri([pe.name,pe.description],i),e[66]=i,e[67]=Ke):Ke=e[67];const st=_.filter(Ke),rt=st.filter(Ha),St=st.filter(Mb);e[68]===Symbol.for("react.memo_cache_sentinel")?(xe=He("flex h-full flex-col","bg-background"),e[68]=xe):xe=e[68];let mt;e[69]!==a?(mt=a("settings.commands.sidebar.title"),e[69]=a,e[70]=mt):mt=e[70];let Et;e[71]!==mt?(Et=s.jsx("h2",{className:`${yn} mb-3`,children:mt}),e[71]=mt,e[72]=Et):Et=e[72];let Pt;e[73]===Symbol.for("react.memo_cache_sentinel")?(Pt=s.jsx(ni,{className:"mb-3"}),e[73]=Pt):Pt=e[73];let et;e[74]!==_.length||e[75]!==a?(et=a("settings.commands.sidebar.total",{count:_.length}),e[74]=_.length,e[75]=a,e[76]=et):et=e[76];let yt;e[77]!==et?(yt=s.jsx("span",{className:"typography-meta text-muted-foreground",children:et}),e[77]=et,e[78]=yt):yt=e[78];let Tt;e[79]===Symbol.for("react.memo_cache_sentinel")?(Tt=s.jsx(ae,{name:"add",className:"h-3.5 w-3.5"}),e[79]=Tt):Tt=e[79];let Nt;e[80]!==q?(Nt=s.jsx(G,{size:"sm","data-settings-item":"commands.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:q,children:Tt}),e[80]=q,e[81]=Nt):Nt=e[81];let ve;e[82]!==yt||e[83]!==Nt?(ve=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[yt,Nt]}),e[82]=yt,e[83]=Nt,e[84]=ve):ve=e[84];let qe;e[85]!==_.length||e[86]!==i?(qe=_.length>0?s.jsx(Or,{value:i,onChange:o}):null,e[85]=_.length,e[86]=i,e[87]=qe):qe=e[87],e[88]!==Et||e[89]!==ve||e[90]!==qe?(ke=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[Et,Pt,ve,qe]}),e[88]=Et,e[89]=ve,e[90]=qe,e[91]=ke):ke=e[91],Ae=ys,re="flex-1 min-h-0",te="space-y-1 px-3 py-2",he=_.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(ae,{name:"terminal-box",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:a("settings.commands.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:a("settings.commands.sidebar.empty.description")})]}):st.length===0?s.jsx(Lr,{query:i}):s.jsxs(s.Fragment,{children:[rt.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.commands.sidebar.section.builtIn")}),[...rt].sort(Db).map(pe=>s.jsx(qc,{command:pe,isSelected:k===pe.name,onSelect:()=>{j(pe.name),n?.()},onReset:()=>W(pe),onDuplicate:()=>ie(pe),isMenuOpen:x===pe.name,onMenuOpenChange:ze=>b(ze?pe.name:null)},pe.name))]}),St.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("settings.commands.sidebar.section.custom")}),[...St].sort(Fb).map(pe=>s.jsx(qc,{command:pe,isSelected:k===pe.name,onSelect:()=>{j(pe.name),n?.()},onRename:()=>be(pe),onDelete:()=>U(pe),onDuplicate:()=>ie(pe),isMenuOpen:x===pe.name,onMenuOpenChange:ze=>b(ze?pe.name:null)},pe.name))]})]}),e[50]=_,e[51]=q,e[52]=U,e[53]=ie,e[54]=n,e[55]=x,e[56]=i,e[57]=k,e[58]=j,e[59]=a,e[60]=Ae,e[61]=re,e[62]=te,e[63]=he,e[64]=xe,e[65]=ke}else Ae=e[60],re=e[61],te=e[62],he=e[63],xe=e[64],ke=e[65];let we;e[92]!==Ae||e[93]!==re||e[94]!==te||e[95]!==he?(we=s.jsx(Ae,{outerClassName:re,className:te,children:he}),e[92]=Ae,e[93]=re,e[94]=te,e[95]=he,e[96]=we):we=e[96];const Te=d!==null&&m!==null;let ge;e[97]!==h?(ge=Ke=>{!Ke&&!h&&ee()},e[97]=h,e[98]=ge):ge=e[98];let Ee;e[99]!==m||e[100]!==a?(Ee=a(m==="delete"?"settings.commands.sidebar.dialog.deleteTitle":"settings.commands.sidebar.dialog.resetTitle"),e[99]=m,e[100]=a,e[101]=Ee):Ee=e[101];let Ce;e[102]!==Ee?(Ce=s.jsx(Bt,{children:Ee}),e[102]=Ee,e[103]=Ce):Ce=e[103];let ce;e[104]!==d?.name||e[105]!==m||e[106]!==a?(ce=m==="delete"?a("settings.commands.sidebar.dialog.deleteDescription",{name:d?.name??""}):a("settings.commands.sidebar.dialog.resetDescription",{name:d?.name??""}),e[104]=d?.name,e[105]=m,e[106]=a,e[107]=ce):ce=e[107];let ye;e[108]!==ce?(ye=s.jsx(Vt,{children:ce}),e[108]=ce,e[109]=ye):ye=e[109];let Z;e[110]!==Ce||e[111]!==ye?(Z=s.jsxs(qt,{children:[Ce,ye]}),e[110]=Ce,e[111]=ye,e[112]=Z):Z=e[112];let fe;e[113]!==a?(fe=a("settings.common.actions.cancel"),e[113]=a,e[114]=fe):fe=e[114];let Ne;e[115]!==h||e[116]!==fe?(Ne=s.jsx(G,{size:"sm",variant:"ghost",onClick:ee,disabled:h,children:fe}),e[115]=h,e[116]=fe,e[117]=Ne):Ne=e[117];let Ie;e[118]!==m||e[119]!==a?(Ie=a(m==="delete"?"settings.common.actions.delete":"settings.common.actions.reset"),e[118]=m,e[119]=a,e[120]=Ie):Ie=e[120];let $e;e[121]!==ne||e[122]!==h||e[123]!==Ie?($e=s.jsx(G,{size:"sm",onClick:ne,disabled:h,children:Ie}),e[121]=ne,e[122]=h,e[123]=Ie,e[124]=$e):$e=e[124];let L;e[125]!==Ne||e[126]!==$e?(L=s.jsxs(as,{children:[Ne,$e]}),e[125]=Ne,e[126]=$e,e[127]=L):L=e[127];let se;e[128]!==Z||e[129]!==L?(se=s.jsxs(Kt,{className:"max-w-md",children:[Z,L]}),e[128]=Z,e[129]=L,e[130]=se):se=e[130];let de;e[131]!==Te||e[132]!==ge||e[133]!==se?(de=s.jsx(Ut,{open:Te,onOpenChange:ge,children:se}),e[131]=Te,e[132]=ge,e[133]=se,e[134]=de):de=e[134];const je=l!==null;let De;e[135]===Symbol.for("react.memo_cache_sentinel")?(De=Ke=>!Ke&&r(null),e[135]=De):De=e[135];let We;e[136]!==a?(We=a("settings.commands.sidebar.renameDialog.title"),e[136]=a,e[137]=We):We=e[137];let Be;e[138]!==We?(Be=s.jsx(Bt,{children:We}),e[138]=We,e[139]=Be):Be=e[139];const Ge=l?.name??"";let Xe;e[140]!==a||e[141]!==Ge?(Xe=a("settings.commands.sidebar.renameDialog.description",{name:Ge}),e[140]=a,e[141]=Ge,e[142]=Xe):Xe=e[142];let tt;e[143]!==Xe?(tt=s.jsx(Vt,{children:Xe}),e[143]=Xe,e[144]=tt):tt=e[144];let it;e[145]!==Be||e[146]!==tt?(it=s.jsxs(qt,{children:[Be,tt]}),e[145]=Be,e[146]=tt,e[147]=it):it=e[147];let _e;e[148]===Symbol.for("react.memo_cache_sentinel")?(_e=Ke=>u(Ke.target.value),e[148]=_e):_e=e[148];let nt;e[149]!==a?(nt=a("settings.commands.sidebar.renameDialog.placeholder"),e[149]=a,e[150]=nt):nt=e[150];let Ue;e[151]!==Pe?(Ue=Ke=>{Ke.key==="Enter"&&Pe()},e[151]=Pe,e[152]=Ue):Ue=e[152];let Se;e[153]!==c||e[154]!==nt||e[155]!==Ue?(Se=s.jsx(Ze,{value:c,onChange:_e,placeholder:nt,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:Ue}),e[153]=c,e[154]=nt,e[155]=Ue,e[156]=Se):Se=e[156];let Ve;e[157]===Symbol.for("react.memo_cache_sentinel")?(Ve=()=>r(null),e[157]=Ve):Ve=e[157];let Re;e[158]!==a?(Re=a("settings.common.actions.cancel"),e[158]=a,e[159]=Re):Re=e[159];let Je;e[160]!==Re?(Je=s.jsx(G,{size:"sm",variant:"ghost",onClick:Ve,children:Re}),e[160]=Re,e[161]=Je):Je=e[161];let ot;e[162]!==a?(ot=a("settings.common.actions.rename"),e[162]=a,e[163]=ot):ot=e[163];let wt;e[164]!==Pe||e[165]!==ot?(wt=s.jsx(G,{size:"sm",onClick:Pe,children:ot}),e[164]=Pe,e[165]=ot,e[166]=wt):wt=e[166];let bt;e[167]!==Je||e[168]!==wt?(bt=s.jsxs(as,{children:[Je,wt]}),e[167]=Je,e[168]=wt,e[169]=bt):bt=e[169];let me;e[170]!==it||e[171]!==Se||e[172]!==bt?(me=s.jsxs(Kt,{children:[it,Se,bt]}),e[170]=it,e[171]=Se,e[172]=bt,e[173]=me):me=e[173];let dt;e[174]!==je||e[175]!==me?(dt=s.jsx(Ut,{open:je,onOpenChange:De,children:me}),e[174]=je,e[175]=me,e[176]=dt):dt=e[176];let vt;return e[177]!==xe||e[178]!==ke||e[179]!==we||e[180]!==de||e[181]!==dt?(vt=s.jsxs("div",{className:xe,children:[ke,we,de,dt]}),e[177]=xe,e[178]=ke,e[179]=we,e[180]=de,e[181]=dt,e[182]=vt):vt=e[182],vt},qc=t=>{const e=Fe.c(47),{command:n,isSelected:a,onSelect:i,onDelete:o,onReset:l,onRename:r,onDuplicate:c,isMenuOpen:u,onMenuOpenChange:d}=t,{t:p}=Oe();let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=hr(),e[0]=m):m=e[0];const f=m,[h,v]=g.useState(false);let x;e[1]!==o||e[2]!==c||e[3]!==r||e[4]!==l||e[5]!==p?(x=_=>s.jsxs(s.Fragment,{children:[r&&s.jsxs(_,{onClick:$=>{$.stopPropagation(),r()},children:[s.jsx(ae,{name:"edit",className:"h-4 w-4 me-px"}),p("settings.common.actions.rename")]}),s.jsxs(_,{onClick:$=>{$.stopPropagation(),c()},children:[s.jsx(ae,{name:"file-copy",className:"h-4 w-4 me-px"}),p("settings.common.actions.duplicate")]}),l&&s.jsxs(_,{onClick:$=>{$.stopPropagation(),l()},children:[s.jsx(ae,{name:"restart",className:"h-4 w-4 me-px"}),p("settings.common.actions.reset")]}),o&&s.jsxs(_,{onClick:$=>{$.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[s.jsx(ae,{name:"delete-bin",className:"h-4 w-4 me-px"}),p("settings.common.actions.delete")]})]}),e[1]=o,e[2]=c,e[3]=r,e[4]=l,e[5]=p,e[6]=x):x=e[6];const b=x,k=a?"bg-interactive-selection":"hover:bg-interactive-hover";let j;e[7]!==k?(j=He("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",k),e[7]=k,e[8]=j):j=e[8];let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=f?void 0:_=>{_.preventDefault(),v(true)},e[9]=y):y=e[9];let N;e[10]!==j?(N=s.jsx("div",{className:j,onContextMenu:y}),e[10]=j,e[11]=N):N=e[11];let S;e[12]!==n.name?(S=s.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["/",n.name]}),e[12]=n.name,e[13]=S):S=e[13];let P;e[14]!==n||e[15]!==p?(P=(n.scope||Ha(n))&&s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-edge",children:Ha(n)?p("settings.agents.sidebar.badge.system"):n.scope}),e[14]=n,e[15]=p,e[16]=P):P=e[16];let w;e[17]!==S||e[18]!==P?(w=s.jsxs("div",{className:"flex items-center gap-2",children:[S,P]}),e[17]=S,e[18]=P,e[19]=w):w=e[19];let I;e[20]!==n.description?(I=n.description&&s.jsx("div",{className:"typography-micro text-muted-foreground truncate leading-tight",children:n.description}),e[20]=n.description,e[21]=I):I=e[21];let C;e[22]!==i||e[23]!==I||e[24]!==w?(C=s.jsxs("button",{onClick:i,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,children:[w,I]}),e[22]=i,e[23]=I,e[24]=w,e[25]=C):C=e[25];let A;e[26]!==d?(A=_=>{_&&v(false),d(_)},e[26]=d,e[27]=A):A=e[27];let E;e[28]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(ga,{asChild:true,children:s.jsx(G,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -me-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 pointer-fine:hidden",children:s.jsx(ae,{name:"more",className:"h-3.5 w-3.5"})})}),e[28]=E):E=e[28];let D;e[29]!==b?(D=s.jsx(pa,{align:"end",className:"w-fit min-w-20",children:b(ra)}),e[29]=b,e[30]=D):D=e[30];let M;e[31]!==u||e[32]!==A||e[33]!==D?(M=s.jsxs(fa,{open:u,onOpenChange:A,children:[E,D]}),e[31]=u,e[32]=A,e[33]=D,e[34]=M):M=e[34];let O;e[35]!==C||e[36]!==M?(O=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[C,M]}),e[35]=C,e[36]=M,e[37]=O):O=e[37];let R;e[38]!==O||e[39]!==N?(R=s.jsx(Ra,{render:N,children:O}),e[38]=O,e[39]=N,e[40]=R):R=e[40];let F;e[41]!==b?(F=s.jsx(Ta,{className:"w-fit min-w-20",children:b(ca)}),e[41]=b,e[42]=F):F=e[42];let T;return e[43]!==h||e[44]!==R||e[45]!==F?(T=s.jsxs(Ma,{open:h,onOpenChange:v,children:[R,F]}),e[43]=h,e[44]=R,e[45]=F,e[46]=T):T=e[46],T};function Eb(t){return{selectedCommandName:t.selectedCommandName,setSelectedCommand:t.setSelectedCommand,setCommandDraft:t.setCommandDraft,createCommand:t.createCommand,deleteCommand:t.deleteCommand,loadCommands:t.loadCommands}}function Tb(t){return t.loadSkills}function Rb(t){return t.name}function Mb(t){return!Ha(t)}function Db(t,e){return t.name.localeCompare(e.name)}function Fb(t,e){return t.name.localeCompare(e.name)}const Ob=()=>{const{t}=Oe(),{selectedCommandName:e,getCommandByName:n,createCommand:a,updateCommand:i,commandDraft:o,setCommandDraft:l,setSelectedCommand:r}=Qa($s(J=>({selectedCommandName:J.selectedCommandName,getCommandByName:J.getCommandByName,createCommand:J.createCommand,updateCommand:J.updateCommand,commandDraft:J.commandDraft,setCommandDraft:J.setCommandDraft,setSelectedCommand:J.setSelectedCommand}))),c=en(),u=Qa(J=>wu(J,c)),d=e?n(e,c):null,p=!!(o&&o.name===e&&!d),[m,f]=g.useState(""),[h,v]=g.useState("user"),[x,b]=g.useState(""),[k,j]=g.useState(""),[y,N]=g.useState(""),[S,P]=g.useState(""),[w,I]=g.useState(false),[C,A]=g.useState(""),[E,D]=g.useState(false),M=g.useRef(null),O=JSON.stringify([c,e]),R=g.useRef(null),F=g.useRef(null);g.useEffect(()=>{const J=R.current===O;if(R.current=O,p&&o){const U=o.name||"",B=o.scope||"user",W=o.description||"",Q=o.agent||"",ee=Ni(o.model),X=ee?`${ee.providerID}/${ee.modelID}`:"",ne=ee?.variant||"",K=o.subagent===true,ie=o.template||"";f(U),v(B),b(W),j(Q),N(X),P(ne),I(K),A(ie),M.current={draftName:U,draftScope:B,description:W,agent:Q,model:X,variant:ne,subagent:K,template:ie}}else if(d){const U=d.description||"",B=d.agent||"",W=Ni(d.model),Q=W?`${W.providerID}/${W.modelID}`:"",ee=W?.variant||"",X=d.subagent===true,ne=d.template||"",K=F.current,ie=[M.current,K?.identity===O?K.form:null];if(J&&ie.some(le=>le&&le.description===U&&le.agent===B&&le.model===Q&&le.variant===ee&&le.subagent===X&&le.template===ne))return;b(U),j(B),N(Q),P(ee),I(X),A(ne),M.current={draftName:"",draftScope:"user",description:U,agent:B,model:Q,variant:ee,subagent:X,template:ne}}},[d,p,e,u,o,O]);const T=g.useCallback(J=>{const U=k.trim(),B=Tn(y.trim()),W=B?Gu({providerID:B.providerId,modelID:B.modelId,variant:S.trim()||void 0}):null;return{name:J,description:x.trim()||void 0,agent:U===""?null:U,model:W,subagent:w,template:C.trim(),scope:p?h:void 0}},[k,x,h,p,y,w,C,S]),_=g.useCallback(async()=>{const J=M.current,U=e?.trim();if(p||!J||!U||x.trim()===J.description.trim()&&k.trim()===J.agent.trim()&&y.trim()===J.model.trim()&&S.trim()===J.variant.trim()&&w===J.subagent&&C.trim()===J.template.trim())return Vs;if(!C.trim())return vs(t("settings.commands.page.toast.templateRequired"));const W=T(U),Q=Ni(W.model),ee={identity:O,form:{...J,description:W.description||"",agent:W.agent||"",model:Q?`${Q.providerID}/${Q.modelID}`:"",variant:Q?.variant||"",subagent:W.subagent===true,template:W.template||""}};F.current=ee;try{return await i(U,W,c)?(R.current===O&&(M.current=ee.form),Mn):vs(t("settings.commands.page.toast.updateFailed"))}finally{F.current===ee&&(F.current=null)}},[k,T,x,O,p,y,e,c,w,t,C,i,S]),$=ai(_),{requestSave:z}=$,H=async()=>{const J=m.trim().replace(/\s+/g,"-");if(!J){Y.error(t("settings.commands.sidebar.toast.commandNameRequired"));return}if(!C.trim()){Y.error(t("settings.commands.page.toast.templateRequired"));return}if(u.some(U=>U.name===J)){Y.error(t("settings.commands.sidebar.toast.commandExists"));return}D(true);try{await a(T(J),c)?(l(null),Y.success(t("settings.commands.page.toast.created"))):Y.error(t("settings.commands.page.toast.createFailed"))}catch(U){console.error("Error creating command:",U),Y.error(t("settings.commands.page.toast.saveUnexpectedError"))}finally{D(false)}},q=()=>{l(null),r(null)};return e?s.jsxs(ns,{title:p?t("settings.commands.page.title.new"):`/${e}`,description:t(p?"settings.commands.page.subtitle.new":"settings.commands.page.subtitle.edit"),onBlurCapture:$.onBlurCapture,children:[!p&&d&&s.jsx(_r,{legacy:d.legacy===true,path:d.path}),s.jsxs(Qe,{title:t("settings.commands.page.section.identity"),contentClassName:"space-y-0",children:[p&&s.jsxs(at,{settingsItem:"commands.name",label:t("settings.commands.page.field.commandName"),children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground me-1",children:"/"}),s.jsx(Ze,{value:m,onChange:J=>f(J.target.value),placeholder:t("settings.commands.page.field.commandNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Ot,{value:h,onValueChange:J=>v(J),children:[s.jsx(Dt,{className:"w-fit min-w-[100px]",children:s.jsx(_t,{children:t(h==="project"?"settings.common.scope.project":"settings.common.scope.global")})}),s.jsxs(Ft,{align:"end",children:[s.jsx(ht,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ae,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(ht,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ae,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsxs("div",{className:"py-1.5",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.common.field.description")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(Os,{value:x,onChange:J=>b(J.target.value),placeholder:t("settings.commands.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})})]})]}),s.jsxs(Qe,{title:t("settings.commands.page.section.executionContext"),contentClassName:"space-y-0",children:[s.jsx(at,{settingsItem:"commands.agent",label:t("settings.commands.page.field.overrideAgent"),children:s.jsx(vr,{agentName:k,onChange:J=>{j(J),z()},className:xn})}),s.jsx(at,{settingsItem:"commands.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx($n,{providerId:Tn(y)?.providerId??"",modelId:Tn(y)?.modelId??"",onChange:(J,U)=>{N(J&&U?`${J}/${U}`:""),z()},className:xn})}),s.jsx(at,{settingsItem:"commands.variant",label:t("settings.agents.page.field.variant"),info:t("settings.agents.page.field.variantTooltip"),children:s.jsx(Ze,{value:S,onChange:J=>P(J.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!y&&!S,className:"h-8 w-40 rounded-md px-3"})}),s.jsx(at,{settingsItem:"commands.subagent",label:t("settings.commands.page.field.subagent"),info:t("settings.commands.page.field.subagentTooltip"),children:s.jsx(oa,{checked:w,onCheckedChange:J=>{I(J),z()},"aria-label":t("settings.commands.page.field.subagent")})})]}),s.jsxs(Qe,{title:t("settings.commands.page.section.template"),settingsItem:"commands.template",children:[s.jsx(Os,{value:C,onChange:J=>A(J.target.value),placeholder:t("settings.commands.page.field.templatePlaceholder"),rows:12,className:"w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent"}),s.jsxs("p",{className:"mt-2 typography-meta text-muted-foreground",children:[s.jsx("code",{className:"text-foreground",children:"$ARGUMENTS"})," ",t("settings.commands.page.templateHint.userInput")," \xB7"," ",s.jsx("code",{className:"text-foreground",children:"!`cmd`"})," ",t("settings.commands.page.templateHint.shellOutput")," \xB7"," ",s.jsx("code",{className:"text-foreground",children:"@file"})," ",t("settings.commands.page.templateHint.fileContents")]}),p&&s.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[s.jsx(G,{onClick:()=>{H()},disabled:E||!m.trim()||!C.trim(),size:"xs",className:"!font-normal",children:t(E?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(G,{variant:"ghost",onClick:q,disabled:E,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(ae,{name:"terminal-box",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-ui-label",children:t("settings.commands.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.commands.page.empty.description")})]})})};function sn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function mi(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function kn(t,e){return e!==void 0?{ok:false,error:t,parsed:e}:{ok:false,error:t}}function co(t,e,n){const a=_b(n),i=typeof n.url=="string"?n.url.trim():"",o=Wc(n,"env","environment"),l=Wc(n,"headers"),r=sn(n.oauth)?n.oauth:null,c=pi(r,"client_id","clientId"),u=pi(r,"client_secret","clientSecret"),d=pi(r,"scope"),p=pi(r,"redirect_uri","redirectUri"),m=Lb(r,"callback_port","callbackPort"),f=pi(r,"auth_server_metadata_url","authServerMetadataUrl"),h=n.oauth===false||n.oauth===null||n.oauth===void 0?false:!!r&&!!(c||u||d||p||m||f),v=$b(n);return{ok:true,name:t,type:e,command:a,url:i,environment:o,headers:l,oauthEnabled:h,oauthClientId:c,oauthClientSecret:u,oauthScope:d,oauthRedirectUri:p,oauthCallbackPort:m,oauthAuthServerMetadataUrl:f,timeoutStartup:v.startup,timeoutCatalog:v.catalog,timeoutExecution:v.execution,codemode:n.codemode===true?"on":n.codemode===false?"off":"default",disabled:Ub(n),protocol:Kl.find(x=>x===n.protocol)??"legacy"}}function pi(t,...e){if(!t)return"";for(const n of e){const a=t[n];if(typeof a=="string"&&a.trim())return a.trim()}return""}function Lb(t,...e){if(!t)return"";for(const n of e){const a=yi(t[n]);if(a)return a}return""}function yi(t){if(typeof t=="number"&&Number.isFinite(t)&&t>0)return String(Math.floor(t));if(typeof t=="string"&&t.trim()){const e=Number(t);if(Number.isFinite(e)&&e>0)return String(Math.floor(e))}return""}function _b(t){const e=t.command,n=t.args;if(mi(e)&&mi(n))return[...e,...n];if(mi(e))return e;if(typeof e=="string"&&e.trim()){const a=e.trim().split(/\s+/);return mi(n)?[...a,...n]:a}return mi(n)?n:[]}function Wc(t,...e){for(const n of e){const a=t[n];if(!sn(a))continue;const i=Object.entries(a).filter(([o,l])=>o&&typeof l=="string");if(i.length>0)return i.map(([o,l])=>({key:o,value:String(l)}))}return[]}function $b(t){return sn(t.timeout)?{startup:yi(t.timeout.startup),catalog:yi(t.timeout.catalog),execution:yi(t.timeout.execution)}:{startup:"",catalog:"",execution:yi(t.timeout)}}function Ub(t){return t.disabled===true?true:t.disabled===false?false:"enabled"in t?!t.enabled:false}function Kb(t){const e=t.mcpServers;if(sn(e)){const a=Object.keys(e);if(a.length===1){const i=a[0],o=e[i];if(sn(o))return{name:i,entry:o}}if(a.length>1)return null}const n=Object.keys(t).filter(a=>{const i=t[a];return a!=="mcpServers"&&sn(i)});if(n.length===1){const a=n[0],i=t[a];if(pm(i))return{name:a,entry:i}}return null}function pm(t){return t.type==="local"||t.type==="remote"||Array.isArray(t.command)||typeof t.url=="string"||Array.isArray(t.args)}function zb(t,e){let n;try{const c=t.trim();if(!c)return kn("No JSON content provided");n=JSON.parse(c)}catch(c){return kn(c instanceof Error?`Invalid JSON: ${c.message}`:"Invalid JSON")}if(!sn(n))return kn("Expected a JSON object, not an array or primitive");const a=n,i=a.mcpServers;if(sn(i)){const c=Object.keys(i);if(c.length===0)return kn("mcpServers object is empty",n);if(c.length>1)return kn("Paste one server at a time. Found "+c.length+" servers in mcpServers",n);const u=c[0],d=i[u];return sn(d)?co(u,uo(d),d):kn("Server entry is not a valid object",n)}const o=a.mcp,l=sn(o)&&sn(o.servers)?o.servers:o;if(sn(l)){const c=Object.keys(l);if(c.length===0)return kn("mcp object is empty",n);if(c.length>1)return kn("Paste one server at a time. Found "+c.length+" servers in mcp",n);const u=c[0],d=l[u];return sn(d)?co(u,uo(d),d):kn("Server entry in mcp is not a valid object",n)}const r=Kb(a);if(r)return co(r.name,uo(r.entry),r.entry);if(pm(a)){const c=uo(a),u=typeof a.name=="string"&&a.name.trim()?a.name.trim():e?.fallbackName;return co(u,c,a)}return kn("No recognizable MCP server configuration found in JSON",n)}function uo(t){return t.type==="remote"?"remote":t.type==="local"?"local":typeof t.url=="string"&&t.url.trim()?"remote":(Array.isArray(t.command)||typeof t.command=="string"||Array.isArray(t.args),"local")}function Bb(t,e,n){const a=n?.isNewServer??false,i=t.name?G1(t.name):void 0,o=a&&i?i:e.name??"";return{...e,name:o,type:t.type,command:t.type==="local"?t.command:[],url:t.type==="remote"?t.url:"",environment:t.environment,headers:t.type==="remote"?t.headers:[],oauthEnabled:t.type==="remote"?t.oauthEnabled:false,oauthClientId:t.type==="remote"?t.oauthClientId:"",oauthClientSecret:t.type==="remote"?t.oauthClientSecret:"",oauthScope:t.type==="remote"?t.oauthScope:"",oauthRedirectUri:t.type==="remote"?t.oauthRedirectUri:"",oauthCallbackPort:t.type==="remote"?t.oauthCallbackPort:"",oauthAuthServerMetadataUrl:t.type==="remote"?t.oauthAuthServerMetadataUrl:"",timeoutStartup:t.type==="local"?t.timeoutStartup:"",timeoutCatalog:t.timeoutCatalog,timeoutExecution:t.timeoutExecution,codemode:t.codemode,disabled:t.disabled,protocol:t.protocol}}const xl=[],Vb=t=>t===null||/[\\/]opencode\.managed\.json$/.test(t),Ur=(t,e)=>{const n=Fe.c(18),a=e===void 0?0:e;let i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i={status:"loading",hasRead:false,policies:xl,owner:null},n[0]=i):i=n[0];const[o,l]=g.useState(i);let r;n[1]!==t?(r=()=>{let x=false;return l(b=>b.owner===t?{...b,status:"loading"}:{status:"loading",hasRead:false,policies:xl,owner:t}),Ys.getIntegrationPolicies(t).then(b=>{x||l({status:"ready",hasRead:true,policies:b,owner:t})}).catch(b=>{console.warn("[settings] could not read OpenCode integration policies:",b instanceof Error?b.message:String(b)),!x&&l(k=>k.owner===t?{status:"error",hasRead:k.hasRead,policies:k.policies,owner:t}:{status:"error",hasRead:false,policies:xl,owner:t})}),()=>{x=true}},n[1]=t,n[2]=r):r=n[2];let c;n[3]!==t||n[4]!==a?(c=[t,a],n[3]=t,n[4]=a,n[5]=c):c=n[5],g.useEffect(r,c);let u;n[6]!==o.policies?(u=x=>hc(o.policies,x),n[6]=o.policies,n[7]=u):u=n[7];const d=u;let p;n[8]!==o.policies?(p=x=>hc(o.policies.filter(b=>!(b.effect==="deny"&&b.resource===x&&Vb(b.path))),x),n[8]=o.policies,n[9]=p):p=n[9];const m=p;let f;n[10]!==o.policies?(f=x=>wh(o.policies,x)?.effect==="allow",n[10]=o.policies,n[11]=f):f=n[11];const h=f;let v;return n[12]!==h||n[13]!==d||n[14]!==m||n[15]!==o.hasRead||n[16]!==o.status?(v={status:o.status,hasRead:o.hasRead,isBlocked:d,isBlockedByRule:m,isAllowedByRule:h},n[12]=h,n[13]=d,n[14]=m,n[15]=o.hasRead,n[16]=o.status,n[17]=v):v=n[17],v},gm=(t,e)=>Ur(t,0).isBlocked,Hb=t=>{const e="new-mcp-server";let n=e,a=1;for(;t.some(i=>i.name===n);)n=`${e}-${a}`,a+=1;return n},Gc=t=>{const e=Fe.c(13),{status:n,enabled:a,blocked:i}=t,{t:o}=Oe();if(i){let u;e[0]!==o?(u=o("settings.mcp.grid.status.blockedByPolicy"),e[0]=o,e[1]=u):u=e[1];let d;return e[2]!==u?(d=s.jsx(Rs,{tone:"warning",children:u}),e[2]=u,e[3]=d):d=e[3],d}if(!a){let u;e[4]!==o?(u=o("settings.mcp.grid.status.disabled"),e[4]=o,e[5]=u):u=e[5];let d;return e[6]!==u?(d=s.jsx(Rs,{tone:"neutral",children:u}),e[6]=u,e[7]=d):d=e[7],d}let l;e[8]!==n||e[9]!==o?(l=n==="connected"?{tone:"success",label:o("settings.mcp.page.status.label.connected")}:n==="failed"?{tone:"error",label:o("settings.mcp.page.status.label.failed")}:n==="needs_auth"?{tone:"warning",label:o("settings.mcp.page.status.label.needsAuth")}:n==="pending"?{tone:"neutral",label:o("settings.mcp.grid.status.pending")}:null,e[8]=n,e[9]=o,e[10]=l):l=e[10];const r=l;let c;return e[11]!==r?(c=r?s.jsx(Rs,{tone:r.tone,children:r.label}):null,e[11]=r,e[12]=c):c=e[12],c},qb=()=>{const t=Fe.c(135),{t:e}=Oe(),n=en(),{setSelectedMcp:a,setMcpDraft:i,loadMcpConfigs:o,deleteMcp:l}=Pn($s(Wb)),[r,c]=g.useState(null),[u,d]=g.useState(false);let p;t[0]!==n?(p=Ee=>xr(Ee,n),t[0]=n,t[1]=p):p=t[1];const m=Pn(p);let f;t[2]!==n?(f=Ee=>Ee.getStatusForDirectory(n),t[2]=n,t[3]=f):f=t[3];const h=gn(f);let v;t[4]!==n?(v=Ee=>sg(Ee,n),t[4]=n,t[5]=v):v=t[5];const x=Pn(v),b=gm(n),k=gn(Gb),j=gn(Jb),[y,N]=g.useState(false),[S,P]=g.useState("");let w,I;t[6]!==o||t[7]!==n?(w=()=>{o({directory:n})},I=[o,n],t[6]=o,t[7]=n,t[8]=w,t[9]=I):(w=t[8],I=t[9]),g.useEffect(w,I);let C;t[10]!==j||t[11]!==y||t[12]!==k||t[13]!==n?(C=()=>{if(y)return;N(true);const Ee=new Promise(Qb);Promise.all([k({directory:n,silent:true}),Ee]).then(()=>{const Ce=j(n);Ce&&Y.error(Ce)}).finally(()=>N(false))},t[10]=j,t[11]=y,t[12]=k,t[13]=n,t[14]=C):C=t[14];const A=C;let E;t[15]!==m||t[16]!==i||t[17]!==a?(E=()=>{const Ee=Hb(m),Ce={name:Ee,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],...om,oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:false};i(Ce),a(Ee)},t[15]=m,t[16]=i,t[17]=a,t[18]=E):E=t[18];const D=E;let M;t[19]!==l||t[20]!==r||t[21]!==n||t[22]!==e?(M=async()=>{if(!r)return;const Ee=r;d(true);const Ce=await l(Ee,n);Ce.ok?(Ce.reloadFailed?Y.warning(Ce.message||e("settings.mcp.page.toast.serverDeletedReloadFailed",{name:Ee}),{description:Ce.warning||e("settings.mcp.page.toast.refreshListIfStale")}):Y.success(Ce.message||e("settings.mcp.page.toast.serverDeleted",{name:Ee})),c(null)):Y.error(e("settings.mcp.page.toast.deleteFailed")),d(false)},t[19]=l,t[20]=r,t[21]=n,t[22]=e,t[23]=M):M=t[23];const O=M;let R;t[24]!==m?(R=new Set(m.map(Yb)),t[24]=m,t[25]=R):R=t[25];const F=R;let T,_,$,z,H,q,J,U;if(t[26]!==F||t[27]!==x||t[28]!==D||t[29]!==A||t[30]!==b||t[31]!==y||t[32]!==h||t[33]!==S||t[34]!==m||t[35]!==i||t[36]!==a||t[37]!==e){const Ee=x?Object.values(h).filter(Be=>!F.has(Be.name)):[],Ce=[...m.map(Zb),...Ee.map(Xb)],ce=Fa(Ce,S,ev);let ye;t[46]!==S?(ye=S.trim(),t[46]=S,t[47]=ye):ye=t[47];const Z=ye.length>0;T=ns,t[48]!==e?(z=e("settings.page.mcp.title"),t[48]=e,t[49]=z):z=t[49],H=true;const fe=Ce.length>0?{value:S,onChange:P,placeholder:e("settings.mcp.grid.searchPlaceholder")}:null;let Ne;t[50]!==e?(Ne=e("settings.mcp.sidebar.actions.refreshStatusAria"),t[50]=e,t[51]=Ne):Ne=t[51];let Ie;t[52]!==e?(Ie=e("settings.mcp.sidebar.actions.refreshStatusTitle"),t[52]=e,t[53]=Ie):Ie=t[53];const $e=y&&"animate-spin";let L;t[54]!==$e?(L=He("size-4",$e),t[54]=$e,t[55]=L):L=t[55];let se;t[56]!==L?(se=s.jsx(ae,{name:"refresh",className:L}),t[56]=L,t[57]=se):se=t[57];let de;t[58]!==A||t[59]!==y||t[60]!==Ne||t[61]!==Ie||t[62]!==se?(de=s.jsx(G,{variant:"ghost",size:"sm",className:"w-7 shrink-0 px-0 text-muted-foreground",disabled:y,onClick:A,"aria-label":Ne,title:Ie,children:se}),t[58]=A,t[59]=y,t[60]=Ne,t[61]=Ie,t[62]=se,t[63]=de):de=t[63];let je;t[64]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx(ni,{className:"min-w-0 w-56"}),t[64]=je):je=t[64];let De;t[65]!==de?(De=s.jsxs(s.Fragment,{children:[de,je]}),t[65]=de,t[66]=De):De=t[66],t[67]!==fe||t[68]!==De?(q=s.jsx(Mr,{search:fe,actions:De}),t[67]=fe,t[68]=De,t[69]=q):q=t[69],J=Ce.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:e("settings.mcp.grid.empty")}):ce.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:e("settings.mcp.grid.noMatches",{query:S.trim()})}):null,U=si,t[70]!==D||t[71]!==Z||t[72]!==e?(_=Z?null:s.jsx(Vi,{label:e("settings.mcp.sidebar.actions.addServerTitle"),hint:e("settings.mcp.grid.addHint"),onClick:D,settingsItem:"mcp.create"}),t[70]=D,t[71]=Z,t[72]=e,t[73]=_):_=t[73];let We;t[74]!==b||t[75]!==h||t[76]!==i||t[77]!==a||t[78]!==e?(We=Be=>{if(Be.kind==="runtime"){const _e=b(`mcp:${Be.server.name}`);return s.jsx(Rn,{icon:s.jsx(Mi,{name:"server"}),title:Be.server.name,badges:s.jsx(Gc,{status:Be.server.status.status,enabled:Be.server.status.status!=="disabled",blocked:_e}),muted:Be.server.status.status==="disabled"||_e,footer:s.jsx(ei,{children:e("settings.mcp.grid.runtimeProvided")})},Be.server.name)}const Ge=Be.server,Xe=Ge.disabled!==true,tt=b(`mcp:${Ge.name}`),it=Ge.type==="local"?Ge.command?.join(" "):Ge.url;return s.jsx(Rn,{icon:s.jsx(Mi,{name:Ge.type==="local"?"server":"global"}),title:Ge.name,subtitle:it||void 0,badges:s.jsx(Gc,{status:h[Ge.name]?.status.status,enabled:Xe,blocked:tt}),muted:!Xe||tt,footer:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Ge.type==="local"?e("settings.mcp.sidebar.serverType.localTitle"):e("settings.mcp.sidebar.serverType.remoteTitle")}),Ge.scope==="project"?s.jsx(ei,{children:e("settings.mcp.grid.scope.project")}):null]}),onOpen:()=>{i(null),a(Ge.name)},actionsLabel:e("settings.mcp.grid.actionsAria",{name:Ge.name}),actions:[{label:e("settings.common.actions.delete"),icon:"delete-bin",destructive:true,onSelect:()=>c(Ge.name)}]},Ge.name)},t[74]=b,t[75]=h,t[76]=i,t[77]=a,t[78]=e,t[79]=We):We=t[79],$=ce.map(We),t[26]=F,t[27]=x,t[28]=D,t[29]=A,t[30]=b,t[31]=y,t[32]=h,t[33]=S,t[34]=m,t[35]=i,t[36]=a,t[37]=e,t[38]=T,t[39]=_,t[40]=$,t[41]=z,t[42]=H,t[43]=q,t[44]=J,t[45]=U}else T=t[38],_=t[39],$=t[40],z=t[41],H=t[42],q=t[43],J=t[44],U=t[45];let B;t[80]!==_||t[81]!==$||t[82]!==U?(B=s.jsxs("div",{className:U,children:[_,$]}),t[80]=_,t[81]=$,t[82]=U,t[83]=B):B=t[83];const W=r!==null;let Q;t[84]!==u?(Q=Ee=>{!Ee&&!u&&c(null)},t[84]=u,t[85]=Q):Q=t[85];const ee=r??"";let X;t[86]!==e||t[87]!==ee?(X=e("settings.mcp.page.deleteDialog.title",{name:ee}),t[86]=e,t[87]=ee,t[88]=X):X=t[88];let ne;t[89]!==X?(ne=s.jsx(Bt,{children:X}),t[89]=X,t[90]=ne):ne=t[90];let K;t[91]!==e?(K=e("settings.mcp.page.deleteDialog.descriptionPrefix"),t[91]=e,t[92]=K):K=t[92];let ie;t[93]===Symbol.for("react.memo_cache_sentinel")?(ie=s.jsx("code",{className:"text-foreground",children:"opencode.json"}),t[93]=ie):ie=t[93];let le;t[94]!==e?(le=e("settings.mcp.page.deleteDialog.descriptionSuffix"),t[94]=e,t[95]=le):le=t[95];let be;t[96]!==K||t[97]!==le?(be=s.jsxs(Vt,{children:[K," ",ie,"."," ",le]}),t[96]=K,t[97]=le,t[98]=be):be=t[98];let ue;t[99]!==ne||t[100]!==be?(ue=s.jsxs(qt,{children:[ne,be]}),t[99]=ne,t[100]=be,t[101]=ue):ue=t[101];let Pe;t[102]===Symbol.for("react.memo_cache_sentinel")?(Pe=()=>c(null),t[102]=Pe):Pe=t[102];let Ae;t[103]!==e?(Ae=e("settings.common.actions.cancel"),t[103]=e,t[104]=Ae):Ae=t[104];let re;t[105]!==u||t[106]!==Ae?(re=s.jsx(G,{variant:"outline",size:"sm",onClick:Pe,disabled:u,children:Ae}),t[105]=u,t[106]=Ae,t[107]=re):re=t[107];let te;t[108]!==O?(te=()=>{O()},t[108]=O,t[109]=te):te=t[109];let he;t[110]!==u||t[111]!==e?(he=e(u?"settings.mcp.page.actions.deleting":"settings.common.actions.delete"),t[110]=u,t[111]=e,t[112]=he):he=t[112];let xe;t[113]!==u||t[114]!==te||t[115]!==he?(xe=s.jsx(G,{variant:"destructive",size:"sm",onClick:te,disabled:u,children:he}),t[113]=u,t[114]=te,t[115]=he,t[116]=xe):xe=t[116];let ke;t[117]!==re||t[118]!==xe?(ke=s.jsxs(as,{children:[re,xe]}),t[117]=re,t[118]=xe,t[119]=ke):ke=t[119];let we;t[120]!==ue||t[121]!==ke?(we=s.jsxs(Kt,{className:"max-w-md",children:[ue,ke]}),t[120]=ue,t[121]=ke,t[122]=we):we=t[122];let Te;t[123]!==W||t[124]!==Q||t[125]!==we?(Te=s.jsx(Ut,{open:W,onOpenChange:Q,children:we}),t[123]=W,t[124]=Q,t[125]=we,t[126]=Te):Te=t[126];let ge;return t[127]!==T||t[128]!==z||t[129]!==H||t[130]!==q||t[131]!==J||t[132]!==B||t[133]!==Te?(ge=s.jsxs(T,{title:z,namedBySidebar:H,children:[q,J,B,Te]}),t[127]=T,t[128]=z,t[129]=H,t[130]=q,t[131]=J,t[132]=B,t[133]=Te,t[134]=ge):ge=t[134],ge};function Wb(t){return{setSelectedMcp:t.setSelectedMcp,setMcpDraft:t.setMcpDraft,loadMcpConfigs:t.loadMcpConfigs,deleteMcp:t.deleteMcp}}function Gb(t){return t.refresh}function Jb(t){return t.getErrorForDirectory}function Qb(t){return setTimeout(t,500)}function Yb(t){return t.name}function Zb(t){return{kind:"config",server:t}}function Xb(t){return{kind:"runtime",server:t}}function ev(t){return[t.server.name,t.kind==="config"?t.server.type==="local"?t.server.command?.join(" ")??"":t.server.url??"":""]}const bl=t=>t===void 0?"":String(t),vl=t=>{const e=t.trim();if(!e)return null;const n=Number(e);return!Number.isFinite(n)||n<=0?null:n%1e3===0?`${n/1e3}s`:`${n}ms`},yl={legacy:"settings.mcp.page.advanced.protocolOption.legacy",auto:"settings.mcp.page.advanced.protocolOption.auto","2026-07-28":"settings.mcp.page.advanced.protocolOption.revision20260728"},Jc={default:"settings.mcp.page.advanced.codemodeOption.default",on:"settings.mcp.page.advanced.codemodeOption.on",off:"settings.mcp.page.advanced.codemodeOption.off"},tv=t=>{try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return false}},$a=t=>t?.status.status,jl=t=>t?.status.status==="failed"||t?.status.status==="needs_auth"?t.status.error:void 0;function fm(t){const e=[];let n="",a=false,i=false;for(let o=0;o<t.length;o++){const l=t[o];if(l==="'"&&!i){a=!a;continue}if(l==='"'&&!a){i=!i;continue}if((l===" "||l===" ")&&!a&&!i){n&&(e.push(n),n="");continue}n+=l}return n&&e.push(n),e}const sv=t=>{const e=Fe.c(27),{value:n,onChange:a,preview:i,onDetectUrl:o}=t;let l;e[0]!==n?(l=()=>n.join(`
5
5
  `),e[0]=n,e[1]=l):l=e[1];const[r,c]=g.useState(l),u=g.useRef(n);let d,p;e[2]!==n?(d=()=>{JSON.stringify(u.current)!==JSON.stringify(n)&&(u.current=n,c(n.join(`