@openchamber/web 2.5.4-canary.20261102.1 → 2.6.0

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 (107) hide show
  1. package/dist/assets/{AboutDialog-BlnajGrT.js → AboutDialog-DBDN-gwQ.js} +1 -1
  2. package/dist/assets/{AboutLogo-3M1SBBNZ.js → AboutLogo-BP87552a.js} +1 -1
  3. package/dist/assets/{ArchiveView-CPilj1fC.js → ArchiveView-GN7gU2qK.js} +1 -1
  4. package/dist/assets/{ChangeRequestDiffUnavailable-BduBYMgG.js → ChangeRequestDiffUnavailable-B28oeUds.js} +1 -1
  5. package/dist/assets/{ChangedPathLabel-DIy75LK1.js → ChangedPathLabel-DV4XTf6K.js} +1 -1
  6. package/dist/assets/{CommandPalette-C2nQAx5k.js → CommandPalette-Dvsy8IHV.js} +1 -1
  7. package/dist/assets/{DiffView-BVTlvbXB.js → DiffView-BXm5iGeW.js} +1 -1
  8. package/dist/assets/{FilesView-BN8-zteg.js → FilesView-CAXuJLle.js} +1 -1
  9. package/dist/assets/{GitView-DG6bleRy.js → GitView-D29soKpK.js} +1 -1
  10. package/dist/assets/{GuestSurfacePane-B90hZ3u8.js → GuestSurfacePane-Dw0Um8RG.js} +1 -1
  11. package/dist/assets/{HelpDialog-aRFswWNg.js → HelpDialog-DuO4UnZT.js} +1 -1
  12. package/dist/assets/{IntegrationsCatalogView-C4cPdrsB.js → IntegrationsCatalogView-BrLbP8hQ.js} +1 -1
  13. package/dist/assets/{JsonTreeView-UaVQcUQZ.js → JsonTreeView-ZZKmvRSL.js} +1 -1
  14. package/dist/assets/{MarkdownDiffPreview-BC6CVMO-.js → MarkdownDiffPreview-DuH8ODuS.js} +1 -1
  15. package/dist/assets/{MarkdownRendererImpl-UOgKmPXx.js → MarkdownRendererImpl-DNGYmQPH.js} +3 -3
  16. package/dist/assets/{MemoryDebugPanel-4r-pUuYH.js → MemoryDebugPanel-C7shSvtT.js} +1 -1
  17. package/dist/assets/{NoteEditor-CrOcUYK6.js → NoteEditor-Ba3KW2rV.js} +1 -1
  18. package/dist/assets/{OnboardingScreen-BzcxV-Pg.js → OnboardingScreen-CIyOLCq2.js} +1 -1
  19. package/dist/assets/{OpenCodeStatusDialog-Cco26DIb.js → OpenCodeStatusDialog-ByN8gJ51.js} +1 -1
  20. package/dist/assets/{OverviewView-D2CAYo9U.js → OverviewView-B6SMyBTp.js} +1 -1
  21. package/dist/assets/{PatchDiff-CwCGfs3K.js → PatchDiff-C8jKkgEf.js} +1 -1
  22. package/dist/assets/{PlanView-B5oRyYG6.js → PlanView-NMKJpsCH.js} +1 -1
  23. package/dist/assets/{ProjectActionsDialog-D__fK8j6.js → ProjectActionsDialog-Ctr7-_lb.js} +1 -1
  24. package/dist/assets/{ReplyUiBlock-CevfJFOA.js → ReplyUiBlock-C-C95eJ_.js} +1 -1
  25. package/dist/assets/{RunOverview-tWVSr7oD.js → RunOverview-DNSvGB7-.js} +1 -1
  26. package/dist/assets/{ScheduledTasksDialog-DzOKDUcr.js → ScheduledTasksDialog-BNXOjpPY.js} +1 -1
  27. package/dist/assets/{SettingsView-BrKo0dlB.js → SettingsView-ug8Oinyr.js} +1 -1
  28. package/dist/assets/{SettingsWindow-Bp2lUZJd.js → SettingsWindow-CKUU5T8p.js} +1 -1
  29. package/dist/assets/{SidebarSectionsManager-D_zpJXup.js → SidebarSectionsManager-DWJwQwVi.js} +1 -1
  30. package/dist/assets/{SourceBoardView-DyHe-IJ9.js → SourceBoardView-BQittQF3.js} +1 -1
  31. package/dist/assets/{SpaceAccessDialog-D9BfvyIU.js → SpaceAccessDialog-CeZrOBod.js} +1 -1
  32. package/dist/assets/{SpaceApplyDialog-eVW7H9pP.js → SpaceApplyDialog-DurN0_0Z.js} +1 -1
  33. package/dist/assets/{SpaceRow-D5b9hpb6.js → SpaceRow-BkgNrW0R.js} +1 -1
  34. package/dist/assets/{SpaceSetupOutput-CSNazSK9.js → SpaceSetupOutput-BDkJcYrl.js} +1 -1
  35. package/dist/assets/{SpacesView-J3QlOZyh.js → SpacesView-D6UCwVZp.js} +1 -1
  36. package/dist/assets/{SubmoduleDiffSummary-DDba6A3F.js → SubmoduleDiffSummary-BK5RTTC4.js} +1 -1
  37. package/dist/assets/{ToolOutputDialog-DwVHGaT7.js → ToolOutputDialog-CAenoFSA.js} +1 -1
  38. package/dist/assets/{ToolPartDiffPreview-DGVHMbBa.js → ToolPartDiffPreview-CdjYwDyA.js} +1 -1
  39. package/dist/assets/{UiBlock-BUISMIAx.js → UiBlock-t2ea_iLd.js} +1 -1
  40. package/dist/assets/{UsageStatsView-DDvD7HrF.js → UsageStatsView-D2AXngeb.js} +1 -1
  41. package/dist/assets/{Virtualizer-D1iGS21w.js → Virtualizer-V759EvEY.js} +1 -1
  42. package/dist/assets/{WalkthroughView-D-YJlvdW.js → WalkthroughView-CiQk4Tg_.js} +1 -1
  43. package/dist/assets/{WorktreesView-Cl1aGit2.js → WorktreesView-Bmnk7eXM.js} +1 -1
  44. package/dist/assets/{appThemeRegistry-C0l0I3bB.js → appThemeRegistry-D4EuLaGF.js} +1 -1
  45. package/dist/assets/{ar-BMUyLF4s.js → ar-9I6l4EAU.js} +1 -1
  46. package/dist/assets/{codeHighlight-D6SsoBS5.js → codeHighlight-DD239VMc.js} +1 -1
  47. package/dist/assets/{computeVirtualFileMetrics-ClD-wmbl.js → computeVirtualFileMetrics-BhVDZ-oP.js} +2 -2
  48. package/dist/assets/{contextFileOpenGuard-xnSVLGTm.js → contextFileOpenGuard-D9Z0ay-I.js} +1 -1
  49. package/dist/assets/{date-time-C71h4UaZ.js → date-time-DlgUVVwY.js} +1 -1
  50. package/dist/assets/{de-CQLqnHpw.js → de-CPlTX8kA.js} +1 -1
  51. package/dist/assets/{es-B3v3FeB5.js → es-BMaNboo9.js} +1 -1
  52. package/dist/assets/{fileContentPoller-VaU-YZvx.js → fileContentPoller-paKtimZt.js} +1 -1
  53. package/dist/assets/{flexokiTheme-rJIJ5F0h.js → flexokiTheme-Bv37aHkq.js} +1 -1
  54. package/dist/assets/{fr-BhSq3naw.js → fr-onOdSl19.js} +1 -1
  55. package/dist/assets/{he-CP8ZMKnK.js → he-CgCCGzpX.js} +1 -1
  56. package/dist/assets/{highlights-CMBoVVUU.js → highlights-ByNnuo4t.js} +1 -1
  57. package/dist/assets/{index-D_HDYLit.js → index-BKnb59RH.js} +1 -1
  58. package/dist/assets/{initializeSharedPreferences-Dcg_PAzE.js → initializeSharedPreferences-CFrNmgg0.js} +1 -1
  59. package/dist/assets/{install-Bi-8zdru.js → install-EEjacdUD.js} +1 -1
  60. package/dist/assets/{isDiffPlainText-un0acoNx.js → isDiffPlainText-DUd8YJX0.js} +1 -1
  61. package/dist/assets/{isFilePlainText-DDOfZj67.js → isFilePlainText-BqR4iT-Y.js} +1 -1
  62. package/dist/assets/{ja-C8tOrbJB.js → ja-CYYy1_I8.js} +1 -1
  63. package/dist/assets/{katex.min-CgNRvQ_w.js → katex.min-BBVkbKQY.js} +4 -4
  64. package/dist/assets/{ko-CY1yC8a5.js → ko-CupS3Elm.js} +1 -1
  65. package/dist/assets/{main-B1TR2-UX.js → main-B3MbWk_e.js} +2 -2
  66. package/dist/assets/{main-JYDeJYln.js → main-Kwo8IqqZ.js} +4 -4
  67. package/dist/assets/{miniChat-BdSabZ16.js → miniChat-DelNi_yP.js} +2 -2
  68. package/dist/assets/{mobile-6VDGY-4S.js → mobile-BIso4MdY.js} +2 -2
  69. package/dist/assets/{nl-CuD--zTY.js → nl-Di3GhSHB.js} +1 -1
  70. package/dist/assets/{pageTitle-BC5zJMdk.js → pageTitle-BL2yQcTV.js} +1 -1
  71. package/dist/assets/{parseDiffFromFile-Byzf7qzN.js → parseDiffFromFile-31PZ3lnE.js} +1 -1
  72. package/dist/assets/{pierreDiffTint-cWVXxsPO.js → pierreDiffTint-igvBfgMB.js} +1 -1
  73. package/dist/assets/{pl-BXcO7hE0.js → pl-DEy-fwio.js} +1 -1
  74. package/dist/assets/{pt-BR-DrHl5_ZJ.js → pt-BR-Cqzgn2Hs.js} +1 -1
  75. package/dist/assets/{relocateRestoredSession-CO5ZxywG.js → relocateRestoredSession-CGvQdGRX.js} +2 -2
  76. package/dist/assets/{renderElectronMiniChatApp-D9pG0xDR.js → renderElectronMiniChatApp-hBJHkIHQ.js} +2 -2
  77. package/dist/assets/{renderMarkdownForExport-CLEtE-8l.js → renderMarkdownForExport-DWj11Yob.js} +1 -1
  78. package/dist/assets/{renderMobileApp-D3MEjWXH.js → renderMobileApp-Bzps4LvM.js} +3 -3
  79. package/dist/assets/{resolveLanguages-BpEzCAf_.js → resolveLanguages-DHAaVkki.js} +1 -1
  80. package/dist/assets/{runtimeEndpointReset-DUwj747k.js → runtimeEndpointReset-BPYbd6uu.js} +5 -5
  81. package/dist/assets/{scheduledTasksApi-BHdrsdIS.js → scheduledTasksApi-D6FhT0TU.js} +1 -1
  82. package/dist/assets/{shiki-ju2dHiNP.js → shiki-y7boL955.js} +1 -1
  83. package/dist/assets/{space-apply-CJ--MPJt.js → space-apply-9idN6j4k.js} +1 -1
  84. package/dist/assets/{space-close-DSKwop1P.js → space-close-CjDS5mSo.js} +1 -1
  85. package/dist/assets/{spaceNetwork-CbJeZ9x4.js → spaceNetwork-DeZE7V6c.js} +1 -1
  86. package/dist/assets/{stream-tokenizer-Bg2NW8qQ.js → stream-tokenizer-UaU7yP0V.js} +1 -1
  87. package/dist/assets/{textMateThemeFromAppTheme-108bUvwW.js → textMateThemeFromAppTheme-fsNcE7v2.js} +1 -1
  88. package/dist/assets/{tr-CV2XAmxp.js → tr-DL0uHNVd.js} +1 -1
  89. package/dist/assets/{uk-C6Tim3xD.js → uk-qdUsCGYW.js} +1 -1
  90. package/dist/assets/{useAppFontEffects-DDoHSSlY.js → useAppFontEffects-DpDiWkkc.js} +16 -16
  91. package/dist/assets/{useBranchPullRequestRequest-BC4V7QMF.js → useBranchPullRequestRequest-Cbky4ZeH.js} +1 -1
  92. package/dist/assets/{useCallableModelProviders-BB_1v9xa.js → useCallableModelProviders-Y8rZzgJF.js} +1 -1
  93. package/dist/assets/{useDiffFindSurface-DfL3ULLr.js → useDiffFindSurface-B7KQR8iQ.js} +1 -1
  94. package/dist/assets/{useGitCleanLine-B2KRxywl.js → useGitCleanLine-D6E5eJm2.js} +1 -1
  95. package/dist/assets/{useInlineCommentController-NSFEerSF.js → useInlineCommentController-CF8aQO6-.js} +1 -1
  96. package/dist/assets/{useMarkdownLocalAssets-BWW9xfAF.js → useMarkdownLocalAssets-BXBlTj-y.js} +1 -1
  97. package/dist/assets/{useRootScrollLock-C2bSfyyH.js → useRootScrollLock-3qp1KaTm.js} +2 -2
  98. package/dist/assets/{useWalkthroughReview-Dfkwhv3f.js → useWalkthroughReview-BNHJ06yD.js} +1 -1
  99. package/dist/assets/{useWholeFileComment-BHyRIJhM.js → useWholeFileComment-CisbVgb0.js} +1 -1
  100. package/dist/assets/{useWorktreeArchiveActions-BCFMfuLI.js → useWorktreeArchiveActions-03WxbHUV.js} +1 -1
  101. package/dist/assets/{vendor-codemirror-language-data-Bx5Pax1-.js → vendor-codemirror-language-data-C6MZftZF.js} +2 -2
  102. package/dist/assets/{zh-CN-CdcXp4lU.js → zh-CN-B3B6hhd4.js} +1 -1
  103. package/dist/assets/{zh-TW-D8q2c56h.js → zh-TW-CBU98qnu.js} +1 -1
  104. package/dist/index.html +2 -2
  105. package/dist/mini-chat.html +2 -2
  106. package/dist/mobile.html +2 -2
  107. 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 m,j as s,f as Fe,r as Ue}from"./vendor-react--VO_rL_p.js";import{u as Ys,c as nl}from"./vendor-zustand-C9tWdk0j.js";import{u as Re,I as ee,dl as Os,lJ as it,aK as bn,am as hp,ae as Qt,B as q,z as Gn,A as Q,lK as Qr,aG as ze,x as qa,n as js,bh as ru,b0 as Xa,Y as Cn,aL as Ia,a1 as al,Q as Je,bm as bp,d0 as Do,d5 as xp,bq as Kt,bp as Ot,bs as xt,br as Ft,bo as Lt,y as Ye,lL as Jn,lM as cu,lN as vp,eS as Uo,lO as Yr,lP as yp,lQ as Ri,lR as ua,t as _t,q as $t,D as zt,l as Bt,F as Vt,o as ss,lS as xr,a4 as Pa,a5 as wa,bd as qi,be as Gi,a3 as Aa,a2 as Ta,bc as Ji,bb as Qi,jz as ia,jA as Kn,lT as cs,cX as us,lU as vr,go as Ht,V as pt,f8 as Tt,cM as _s,fa as ja,lV as Nn,fN as As,lW as as,ff as ws,lX as Ss,lY as du,lZ as kp,l_ as mt,l$ as uu,m0 as jp,m1 as wp,m2 as Ui,m3 as Sp,e1 as Yn,m4 as In,m5 as ii,jC as Js,m6 as ei,m7 as mu,m8 as yr,fb as kr,a9 as za,m9 as ql,ma as Zr,mb as Np,cP as il,mc as Xr,gs as Ha,jB as qt,R as jr,md as wr,me as Ka,mf as pu,mg as gu,mh as Sr,jD as qn,mi as Cp,ka as Yi,C as oi,aP as ec,cB as Ip,aZ as Pp,cI as Ap,ba as Tp,fg as Ep,ca as Mp,fh as Dp,K as fu,bB as di,fZ as zi,kA as hu,mj as Rp,mk as Op,cZ as Fp,ml as Lp,au as Zi,c$ as $n,mm as Xt,mn as bu,mo as Kp,mp as sa,gu as Qs,mq as ol,mr as Hn,ms as zo,mt as _p,mu as $p,mv as Up,mw as xu,mx as zp,my as vu,fO as yu,mz as ll,iE as bs,lD as Bo,ed as ku,ec as Bp,iC as Vp,iD as ju,lE as Hp,mA as Wp,iF as qp,mB as Gp,mC as Jp,mD as tc,cY as wu,mE as Qp,mF as Yp,mG as Zp,mH as Xp,mI as eg,mJ as Su,mK as tg,mL as sg,mM as ng,mN as ag,mO as ig,mP as og,mQ as li,mR as lg,mS as rg,mT as Nu,mU as cg,mV as Ts,gt as Wa,bO as cn,bP as rl,mW as dg,kb as Cu,gk as ug,gq as mg,h3 as pg,mX as gg,mY as fg,mZ as cl,k1 as Xi,m_ as eo,d3 as hg,d4 as yl,d2 as Iu,jo as Pu,m$ as kl,n0 as bg,n1 as xg,n2 as vg,n3 as yg,n4 as kg,n5 as jg,n6 as wg,n7 as Sg,bJ as qs,n8 as Nr,jE as Rn,bK as Cr,n9 as Mn,k9 as Ng,na as Cg,nb as Ig,nc as ri,e8 as Pg,nd as Vo,ne as va,nf as Ti,ng as Ag,nh as Tg,ni as Eg,nj as gn,nk as Gs,nl as Fa,nm as na,nn as sc,no as Ro,np as Mg,ak as Dg,nq as Au,nr as _a,ns as Rg,nt as Og,k as Ir,nu as Fg,dY as Lg,aE as Kg,aD as _g,cn as $g,d6 as Ug,az as zg,aC as Bg,nv as Vg,bn as Hg,ji as Wg,nw as Bi,nx as vi,ny as nc,nz as ta,nA as ka,nB as qg,nC as Gg,nD as Jg,nE as Qg,nF as jl,nG as ac,nH as Yg,nI as Zg,nJ as Xg,nK as ef,nL as tf,nM as ic,nN as yi,nO as oc,nP as Pr,nQ as sf,$ as nf,aU as lc,f7 as af,nR as of,nS as lf,nT as wl,nU as rc,nV as rf,f as oa,h as Ba,nW as cc,nX as cf,nY as df,nZ as uf,n_ as dl,n$ as mf,av as ca,o0 as pf,o1 as gf,o2 as ff,gf as hf,o3 as ul,jH as aa,o4 as bf,o5 as xf,o6 as Oi,aw as vf,ay as Tu,e2 as yf,aY as Ra,aa as kf,ab as jf,e3 as wf}from"./useAppFontEffects-DDoHSSlY.js";import{j as Wt,c6 as Eu,dh as Sf,di as Gl,dj as Nf,bG as hn,dk as Cf,z as It,u as ie,l as ms,dl as Vi,dm as Fi,dn as la,dp as Mu,dq as If,t as fn,dr as Pf,aJ as Ea,aG as Gt,cx as Ar,bQ as Af,bg as xs,aM as ui,bA as Sl,bD as dc,bB as uc,bJ as ki,cg as Tf,ds as Ef,cd as Mf,bK as ya,dt as Df,d2 as mc,bC as Rf,du as Of,dv as Ff,c7 as pc,bX as to,d6 as Lf,dw as Kf,dx as Du,dy as Rt,dz as _f,aI as so,bV as $f,bW as Uf,bR as Tr,b9 as Er,cm as zf,bP as Bf,aX as ml,cl as Va,dA as Ru,bU as Ho,bb as Ou,dB as Vf,dC as Fu,dD as Hf,dE as Wf,bI as Mr,dF as qf,v as Wo,bq as Gf,bh as Li,dG as Jf,dH as Ga,dI as gc,dJ as fc,dK as hc,dL as bc,dM as Qf,dN as xc,c4 as Yf,L as Lu,dO as no,dP as Zf,aK as vc,dQ as Xf,dR as eh,r as Jl,dS as th,dT as yc,dU as sh,b as nh,dV as ah,dW as ih,dX as oh,dY as lh,dZ as rh,bE as Ku,d_ as _u,d$ as ch,e0 as Ql,e1 as dh,e2 as uh,e3 as mh,e4 as ph,e5 as $u,e6 as gh,e7 as fh,e8 as hh,e9 as Yl,ea as kc,eb as bh,ec as jc,ed as bo,ee as xh,ef as vh,eg as yh,cq as kh,ck as jh,bY as wh,eh as Sh,ei as Nh,ej as Ch,ek as Ih}from"./katex.min-CgNRvQ_w.js";import{aP as Ph,cy as Ah,cr as Nl,cs as Th,cz as Eh,cA as Mh,cB as ts,cC as Dh,cD as mi,cE as Rs,cF as qo,cG as da,cH as ci,cI as pl,cJ as ao,cK as Hi,Q as Sa,O as Na,P as Ca,at as $a,cL as Rh,c7 as Ws,cM as Oh,cN as Fh,au as Lh,cp as Kh,cO as _h,cP as $h,cQ as Uh,c6 as zh,cR as Bh,cS as La,bh as Zl,aa as Vh,ab as Hh,cT as Wh}from"./runtimeEndpointReset-DUwj747k.js";import{o as es,s as Et,e as io,l as qh,d as un,n as Wi,a as ra,f as Go,_ as gl,u as Xl}from"./vendor-zod-Csf1sqWl.js";import{n as Gh,M as Uu,r as Jh,b as Qh,a as wc,c as Yh,d as Zh,e as Xh,P as eb,f as tb,g as sb,h as nb,j as zu,u as Bu,i as Vu,s as Hu,k as ab,l as ib}from"./install-Bi-8zdru.js";import{s as ob,c as lb}from"./vendor-yaml-CE-D_49-.js";import{c as Sc,C as Nc,p as rb}from"./flexokiTheme-rJIJ5F0h.js";import{u as cb}from"./vendor-tanstack-react-virtual-C_IilPt1.js";import{m as db}from"./vendor-tanstack-virtual-core-DsQgKrou.js";import{c as ub}from"./codeHighlight-D6SsoBS5.js";import{getCodeTokenTheme as mb}from"./appThemeRegistry-C0l0I3bB.js";import{E as Cc}from"./vendor-codemirror-view-Ciie9ey-.js";import{Q as Wu}from"./vendor-qrcode-Cl8OheHW.js";import{toast as ti}from"./vendor-sonner-Dw26OnzC.js";import{s as pb}from"./vendor-strip-json-comments-5dJlOkP1.js";import{c as gb,h as fb,a as hb,b as bb,P as xb}from"./vendor-base-ui-zhBy6TEG.js";import{u as vb}from"./useCallableModelProviders-BB_1v9xa.js";import{r as qu,s as yb}from"./pageTitle-BC5zJMdk.js";import{S as Dr,f as Jo}from"./SpaceRow-D5b9hpb6.js";import{_ as kb}from"./vendor-vite-runtime-DD1OZmLC.js";import{A as Ic}from"./AboutLogo-3M1SBBNZ.js";const Pc=({label:t})=>{const{t:e}=Re(),[n,a]=m.useState(null);m.useEffect(()=>{let l=!1;const r=typeof AbortController<"u"?new AbortController:void 0;return(async()=>{try{const d=await Wt("/api/system/info",{signal:r?.signal,headers:{Accept:"application/json"}});if(!d.ok)return;const c=await d.json().catch(()=>null);if(!c||l)return;const p=typeof c.port=="number"&&Number.isFinite(c.port)&&c.port>0?c.port:null,g=typeof c.tunnelUrl=="string"&&c.tunnelUrl.trim().length>0?c.tunnelUrl.trim():null;a({port:p,tunnelUrl:g})}catch{}})(),()=>{l=!0,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:()=>{Os(l.url)},children:[s.jsx("span",{className:"max-w-64 truncate font-mono",children:l.url}),s.jsx(ee,{name:"external-link",className:"size-3.5 shrink-0"})]},l.key))});return t?s.jsx(it,{label:t,controlClassName:"min-h-8",children:o}):o},Ac="https://github.com/openchamber/openchamber",Tc="https://discord.gg/ZYRSdnwwKA",Ec="https://x.com/openchamber_dev",jb=800,wb=async t=>{const e=await hn();return e?e.serverUpdateChannel??(Gl(t)?"canary":"stable"):null},Sb={info:null,checking:!1,available:!1,error:null};function Nb(t){const e=Fe.c(5),[n,a]=m.useState(Sb);let i;e[0]!==t?(i=async()=>{if(t){a(Cb);try{const r=await Th();a({info:r,checking:!1,available:r.available,error:null})}catch(r){const u=r;a({info:null,checking:!1,available:!1,error:u instanceof Error?u.message:String(u)})}}},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 Cb(t){return{...t,checking:!0,error:null}}function Ib(t){const e=Fe.c(11),[n,a]=m.useState(null);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={kind:"idle"},e[0]=i):i=e[0];const[o,l]=m.useState(i);let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=async()=>{try{const v=await Eh();return a(v),v}catch{return null}},e[1]=r):r=e[1];const u=r;let d,c;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{u()},c=[u],e[2]=d,e[3]=c):(d=e[2],c=e[3]),m.useEffect(d,c);let p;e[4]!==t?(p=async()=>{l({kind:"upgrading"});try{const v=await Mh(t);l({kind:"installed",version:v})}catch(v){const k=v;l({kind:"failed",error:k instanceof Error?k.message:t})}},e[4]=t,e[5]=p):p=e[5];const g=p;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=async v=>{await v().catch(Pb);const k=await u();k?.currentVersion&&l(x=>x.kind!=="installed"||x.version&&x.version.replace(/^v/,"")!==k.currentVersion?x:{kind:"idle"})},e[6]=f):f=e[6];const h=f;let b;return e[7]!==o||e[8]!==n||e[9]!==g?(b={status:n,phase:o,refresh:u,upgrade:g,reloadAfterUpgrade:h},e[7]=o,e[8]=n,e[9]=g,e[10]=b):b=e[10],b}function Pb(){}function Ab(t){const[e,n]=m.useState(null);return m.useEffect(()=>{if(!t)return;let a=!1;return kb(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=!0}},[t]),e}const Tb=({initialUpdateDialogOpen:t=!1})=>{const{t:e}=Re(),[n,a]=m.useState(t),[i,o]=m.useState(!1),[l,r]=m.useState(null),u=Ph(Ys(me=>({info:me.info,checking:me.checking,available:me.available,error:me.error,downloading:me.downloading,downloaded:me.downloaded,installing:me.installing,progress:me.progress,runtimeType:me.runtimeType,checkForUpdates:me.checkForUpdates,downloadUpdate:me.downloadUpdate,restartToUpdate:me.restartToUpdate}))),{isMobile:d}=bn(),c=m.useMemo(()=>Eu(),[]),p=Ah(),g=Nb(c||p),f=p?g:null,h=g.check;m.useEffect(()=>{p&&h()},[p,h]);const[b,v]=m.useState(!1),[k,x]=m.useState(null);m.useEffect(()=>{if(!p)return;let me=!1;return hp().then(le=>{me||x(le)}),()=>{me=!0}},[p]);const w=Ab(c),y=c?{info:g.info,checking:g.checking,available:g.available,error:g.error,checkForUpdates:g.check,runtimeType:"web"}:{info:u.info,checking:u.checking,available:u.available,error:u.error,checkForUpdates:u.checkForUpdates,runtimeType:u.runtimeType},N=(me,le)=>{const te=Gl(me);return te?e("settings.openchamber.about.canaryVersion",{version:te.release,date:Nf(te,qa(),Gl(le))}):me},j=y.available?y.info?.version:null,A=N(l||y.info?.currentVersion||"unknown",j),C=N(k||u.info?.currentVersion||"unknown",j),P=l||f?.info?.currentVersion||"unknown",S=u.runtimeType==="desktop",[I,T]=m.useState(!1),O=u.runtimeType==="web"&&I&&l!==null,[M,K]=m.useState(null);m.useEffect(()=>{if(!S&&!O)return;let me=!1;return(S?Sf():wb(l??"")).then(te=>{me||K(te)}),()=>{me=!0}},[S,O,l]);const L=Ib(e("opencodeUpdate.toast.failed.description")),E=L.status?.currentVersion??null,D=L.phase.kind==="installed"?null:L.status?.availableVersion??null,[R,U]=m.useState(!1),$=me=>{const le=N(me?.version||"",me?.currentVersion);return me?.packageManager==="electron"?e("settings.openchamber.about.actions.updateDesktopToVersion",{version:le}):e("settings.openchamber.about.actions.updateServerToVersion",{version:le})},W=(()=>{const me=N(y.info?.version||"",y.info?.currentVersion);return c?$(y.info):p?e("settings.openchamber.about.actions.updateAppToVersion",{version:me}):e("settings.openchamber.about.actions.updateOpenChamberToVersion",{version:me})})(),z=me=>!!me?.installBlocked,_=y.available&&z(y.info),F=!!(f?.available&&z(f.info)),V=async me=>{if(me===M)return;const le=M;if(K(me),!(S?await Cf(me)===me:(await It({serverUpdateChannel:me})).ok)){K(le),Q.error(e("settings.openchamber.about.toast.updateChannelNotSaved"));return}y.checkForUpdates()},G=M&&s.jsx(Qt,{value:M,onChange:me=>{V(me)},"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)]"}]}),X=()=>{y.checkForUpdates(),f&&f.check(),L.refresh()},ae=async me=>{(await Xa(me)).ok&&(U(!0),setTimeout(()=>U(!1),2e3))},de=()=>{L.reloadAfterUpgrade(async()=>{await ru({message:e("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]})})},J=me=>{if(me?.installBlocked==="desktop-host")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:me.version||""})});if(me?.installBlocked==="manual-install")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.manualInstallUpdate",{version:N(me.version||"")})});const le=me?.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(me?.version||"")})}),s.jsxs("div",{className:"flex items-center gap-2 oc-tile-inset rounded-md p-1 ps-3",children:[s.jsx(js,{as:"code",outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-w-0",fillContainer:!1,className:"whitespace-nowrap font-mono text-sm text-foreground",children:le}),s.jsx(q,{type:"button",variant:"ghost",size:"icon",onClick:()=>{ae(le)},"aria-label":e(R?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:s.jsx(ee,{name:R?"check":"clipboard",className:"size-4"})})]})]})},ue=_?J(y.info):null,be=!f?.available||f.checking?null:F?J(f.info):s.jsxs(q,{type:"button",size:"sm",variant:"outline",onClick:()=>v(!0),children:[s.jsx(ee,{name:"download",className:"size-4"}),$(f.info)]}),fe=f?s.jsx(Nl,{open:b,onOpenChange:v,info:f.info,downloading:!1,downloaded:!1,progress:null,error:f.error,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"}):null,he=(()=>{const{phase:me}=L;if(me.kind==="installed")return{action:s.jsx(q,{type:"button",size:"sm",variant:"outline",onClick:de,children:e("opencodeUpdate.toast.actions.reload")}),note:s.jsx("p",{className:"typography-meta text-muted-foreground",children:me.version?e("settings.openchamber.about.openCode.installedVersion",{version:me.version}):e("settings.openchamber.about.openCode.installed")})};if(!D)return null;if(!L.status?.supported)return{action:null,note:s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.openCode.manualUpdate",{version:D})})};const le=me.kind==="upgrading";return{action:s.jsxs(q,{type:"button",size:"sm",variant:"outline",onClick:()=>{L.upgrade()},disabled:le,children:[le?s.jsx(Gn,{className:"size-4"}):s.jsx(ee,{name:"download",className:"size-4"}),le?e("opencodeUpdate.toast.upgrading.title"):e("settings.openchamber.about.actions.updateOpenCodeToVersion",{version:D})]}),note:me.kind==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:me.error}):null}})(),ye=he?s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[he.note,he.action]}):null;m.useEffect(()=>{let me=!1;return(async()=>{try{const te=await Wt("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!te.ok)return;const Ne=await te.json().catch(()=>null),re=typeof Ne?.openchamberVersion=="string"&&Ne.openchamberVersion.trim().length>0?Ne.openchamberVersion.trim():null;me||(r(re),T(Ne?.runtime==="web"))}catch{me||r(null)}})(),()=>{me=!0}},[]);const Te=f?.checking??!1,oe=f?.available??!1,Y=m.useRef(!1);m.useEffect(()=>{if(y.checking)o(!0),Y.current=!0;else if(i){const me=setTimeout(()=>{o(!1);const le=Te||oe;Y.current&&!y.available&&!y.error&&!le&&(Q.success(e(c?"settings.openchamber.about.toast.serverLatestVersion":"settings.openchamber.about.toast.latestVersion")),Y.current=!1)},jb);return()=>clearTimeout(me)}},[e,c,y.checking,i,y.available,y.error,Te,oe]);const ve=y.checking||i;if(d)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(Ic,{size:72}),s.jsx("h2",{className:`mt-4 ${Qr}`,children:"OpenChamber"}),s.jsx("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:c?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:A})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:E||e("settings.openchamber.about.state.unknown")})}),w&&s.jsx("p",{children:e("settings.openchamber.about.native.appVersion",{version:w})})]}):p?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.appVersionLabel",{version:C})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:P})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:E||e("settings.openchamber.about.state.unknown")})})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:A})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:E||e("settings.openchamber.about.state.unknown")})})]})}),s.jsx(Pc,{})]}),G&&s.jsx("div",{className:"flex justify-center",children:G}),s.jsxs("div",{className:"flex justify-center",children:[!y.available&&!y.error&&s.jsxs(q,{type:"button",variant:"outline",size:"sm",onClick:X,disabled:ve,className:"w-auto justify-center gap-2",children:[ve?s.jsx(Gn,{className:"size-4"}):s.jsx(ee,{name:"refresh",className:"size-4"}),e(ve?"settings.openchamber.about.state.checking":c?"settings.openchamber.about.actions.checkServerForUpdates":"settings.openchamber.about.actions.checkForUpdates")]}),!ve&&y.available&&!_&&s.jsxs(q,{type:"button",variant:"default",size:"sm",onClick:()=>a(!0),className:"w-auto justify-center gap-2",children:[s.jsx(ee,{name:"download",className:"size-4"}),W]})]}),ue,be&&s.jsx("div",{className:"flex justify-center text-center",children:be}),ye&&s.jsx("div",{className:"flex justify-center text-center",children:ye}),[y.error,f?.error].filter(Boolean).map(me=>s.jsx("p",{className:"rounded-xl bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:me},me)),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:Ac,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(ee,{name:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:Tc,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(ee,{name:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:Ec,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(ee,{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")}),s.jsx(Nl,{open:n,onOpenChange:a,info:y.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:y.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:y.runtimeType}),fe]});const xe=s.jsx("span",{"aria-hidden":"true",className:"typography-meta text-muted-foreground/60",children:"·"}),Ce=ve?s.jsxs(s.Fragment,{children:[xe,s.jsxs("span",{className:"flex items-center gap-1.5 typography-meta text-muted-foreground",children:[s.jsx(Gn,{className:"size-4"}),e("settings.openchamber.about.state.checking")]})]}):y.available&&!_?s.jsxs(q,{size:"sm",variant:"default",onClick:()=>a(!0),children:[s.jsx(ee,{name:"download",className:"size-4"}),W]}):!y.available&&!y.error?s.jsxs(s.Fragment,{children:[xe,s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")})]}):null,Se=me=>s.jsx("span",{className:"typography-meta font-mono text-muted-foreground",children:me}),Me="min-h-8 flex-wrap @xl:flex-initial",pe=[ue,F?be:null,he?.note??null,...[y.error,f?.error].filter(Boolean).map(me=>s.jsx("p",{className:"rounded-lg bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:me},me))].filter(Boolean);return s.jsxs(s.Fragment,{children:[s.jsx(ze,{divider:!1,children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(Ic,{size:48}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("h2",{className:Qr,children:"OpenChamber"}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[{href:Ac,icon:"github-fill",label:"GitHub"},{href:Tc,icon:"discord-fill",label:"Discord"},{href:Ec,icon:"twitter-xfill",label:"@openchamber_dev"}].map(me=>s.jsxs("a",{href:me.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(ee,{name:me.icon,className:"size-4"}),s.jsx("span",{children:me.label})]},me.href))})]})]})}),s.jsxs(ze,{contentClassName:"space-y-4",children:[s.jsxs("div",{children:[p?s.jsxs(s.Fragment,{children:[s.jsxs(it,{label:e("settings.openchamber.about.field.appVersion"),controlClassName:Me,children:[Se(C),Ce]}),s.jsxs(it,{label:e("settings.openchamber.about.field.serverVersion"),controlClassName:Me,children:[Se(P),F?null:be]})]}):s.jsxs(it,{label:e("settings.openchamber.about.field.version"),controlClassName:Me,children:[Se(A),Ce]}),s.jsxs(it,{label:e("settings.openchamber.about.field.updateChannel"),info:G?e("settings.openchamber.about.field.updateChannelHint"):void 0,controlClassName:Me,children:[G,s.jsx(q,{size:"sm",variant:"outline",onClick:X,disabled:ve,children:e("settings.openchamber.about.actions.checkForUpdates")})]}),s.jsxs(it,{label:e("settings.openchamber.about.field.openCodeVersion"),controlClassName:Me,children:[Se(E||e("settings.openchamber.about.state.unknown")),he?.action]}),s.jsx(Pc,{label:e("settings.openchamber.about.field.instanceUrls")})]}),pe.length>0&&s.jsx("div",{className:"space-y-3",children:pe})]}),s.jsx(Nl,{open:n,onOpenChange:a,info:y.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:y.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:y.runtimeType}),fe]})},Eb=(t,e,n)=>t&&e.some(i=>i.path===t)?t:(e.find(i=>i.id===n)??e[0])?.path??null,xn=()=>{const t=Fe.c(4),e=ie(Mb),n=Cn(Db),a=Cn(Rb);let i;return t[0]!==a||t[1]!==n||t[2]!==e?(i=Eb(e,n,a),t[0]=a,t[1]=n,t[2]=e,t[3]=i):i=t[3],i};function Mb(t){return t.settingsProjectPath}function Db(t){return t.projects}function Rb(t){return t.activeProjectId}const er=nl(t=>({tab:"general",setTab:e=>t({tab:e})})),Ob=new Map([["projects.default-agent","general"],["projects.default-model","general"],["projects.default-thinking","general"],["projects.shared","general"],["projects.shared.plansDir","general"],["projects.actions","actions"],["projects.worktree","worktrees"],["projects.worktree.setup.wait","worktrees"],["projects.worktree.setup.replace","worktrees"],["projects.environment","environment"]]),Fb=t=>Ob.get(t)??null,tr=nl(t=>({tab:"messages",setTab:e=>t({tab:e})})),Lb=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.wide-layout","messages"],["chat.prompt-navigator","messages"],["chat.collapsible-user-messages","messages"],["chat.sticky-user-header","messages"],["chat.inline-assistant-actions","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.follow-up-behavior","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"]]),Kb=t=>Lb.get(t)??null,pi=t=>{const e=Fe.c(73),{className:n}=t,{t:a}=Re(),{currentTheme:i}=Ia(),o=ie(_b),[l,r]=m.useState(!1),u=al(Cn($b)),d=xn(),c=ie(Ub),p=ms();let g;e[0]!==d||e[1]!==u?(g=u.find(I=>I.path===d)??u[0]??null,e[0]=d,e[1]=u,e[2]=g):g=e[2];const f=g;if(p||!f)return null;let h;e[3]!==c||e[4]!==u?(h=I=>{const T=u.find(O=>O.id===I);T&&c(T.path)},e[3]=c,e[4]=u,e[5]=h):h=e[5];const b=h;if(o){let I;e[6]!==n?(I=Je(n),e[6]=n,e[7]=I):I=e[7];let T;e[8]!==a?(T=a("settings.shared.projectSelector.switchProjectAria"),e[8]=a,e[9]=T):T=e[9];let O;e[10]!==a?(O=a("settings.shared.projectSelector.switchProjectTitle"),e[10]=a,e[11]=O):O=e[11];let M,K;e[12]===Symbol.for("react.memo_cache_sentinel")?(M=()=>r(!0),K=Je(bp({size:"touch"}),"w-full min-w-0"),e[12]=M,e[13]=K):(M=e[12],K=e[13]);let L;e[14]!==f||e[15]!==i?(L=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:s.jsx(Do,{project:f,theme:i})}),e[14]=f,e[15]=i,e[16]=L):L=e[16];let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(ee,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[17]=E):E=e[17];let D;e[18]!==l||e[19]!==T||e[20]!==O||e[21]!==K||e[22]!==L?(D=s.jsxs("button",{type:"button","aria-label":T,title:O,"aria-haspopup":"dialog","aria-expanded":l,onClick:M,className:K,children:[L,E]}),e[18]=l,e[19]=T,e[20]=O,e[21]=K,e[22]=L,e[23]=D):D=e[23];let R;e[24]!==D||e[25]!==I?(R=s.jsx("div",{className:I,children:D}),e[24]=D,e[25]=I,e[26]=R):R=e[26];let U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=()=>r(!1),e[27]=U):U=e[27];const $=f.id;let W;e[28]!==a?(W=a("settings.shared.projectSelector.sheetTitle"),e[28]=a,e[29]=W):W=e[29];let z;e[30]!==a?(z=a("settings.shared.projectSelector.searchPlaceholder"),e[30]=a,e[31]=z):z=e[31];let _;e[32]!==f.id||e[33]!==i||e[34]!==b||e[35]!==l||e[36]!==u||e[37]!==W||e[38]!==z?(_=s.jsx(xp,{open:l,onClose:U,projects:u,selectedProjectId:$,onSelectProject:b,theme:i,title:W,searchPlaceholder:z}),e[32]=f.id,e[33]=i,e[34]=b,e[35]=l,e[36]=u,e[37]=W,e[38]=z,e[39]=_):_=e[39];let F;return e[40]!==R||e[41]!==_?(F=s.jsxs(s.Fragment,{children:[R,_]}),e[40]=R,e[41]=_,e[42]=F):F=e[42],F}let v;e[43]!==n?(v=Je(n),e[43]=n,e[44]=v):v=e[44];const k=f.id;let x;e[45]!==b?(x=I=>{I&&b(I)},e[45]=b,e[46]=x):x=e[46];let w;e[47]!==a?(w=a("settings.shared.projectSelector.switchProjectAria"),e[47]=a,e[48]=w):w=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(Kt,{children:s.jsx(Do,{project:f,theme:i})}),e[51]=f,e[52]=i,e[53]=N):N=e[53];let j;e[54]!==w||e[55]!==y||e[56]!==N?(j=s.jsx(Ot,{className:"w-full","aria-label":w,title:y,children:N}),e[54]=w,e[55]=y,e[56]=N,e[57]=j):j=e[57];let A;if(e[58]!==i||e[59]!==u){let I;e[61]!==i?(I=T=>s.jsx(xt,{value:T.id,className:"max-w-[24rem] truncate",children:s.jsx(Do,{project:T,theme:i})},T.id),e[61]=i,e[62]=I):I=e[62],A=u.map(I),e[58]=i,e[59]=u,e[60]=A}else A=e[60];let C;e[63]!==A?(C=s.jsx(Ft,{fitContent:!0,children:A}),e[63]=A,e[64]=C):C=e[64];let P;e[65]!==f.id||e[66]!==C||e[67]!==x||e[68]!==j?(P=s.jsxs(Lt,{value:k,onValueChange:x,children:[j,C]}),e[65]=f.id,e[66]=C,e[67]=x,e[68]=j,e[69]=P):P=e[69];let S;return e[70]!==P||e[71]!==v?(S=s.jsx("div",{className:v,children:P}),e[70]=P,e[71]=v,e[72]=S):S=e[72],S};function _b(t){return t.isMobile}function $b(t){return t.projects}function Ub(t){return t.setSettingsProjectPath}const Rr=t=>{const e=Fe.c(16),{value:n,onChange:a}=t,{t:i}=Re();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(ee,{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":!0}),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 u;e[6]!==i?(u=i("settings.common.sidebar.searchPlaceholder"),e[6]=i,e[7]=u):u=e[7];let d;e[8]!==i?(d=i("settings.common.sidebar.searchPlaceholder"),e[8]=i,e[9]=d):d=e[9];let c;return e[10]!==l||e[11]!==r||e[12]!==u||e[13]!==d||e[14]!==n?(c=s.jsxs("div",{className:"relative mt-3",children:[o,s.jsx(Ye,{value:n,onChange:l,onKeyDown:r,placeholder:u,"aria-label":d,className:"h-8 ps-7 typography-meta"})]}),e[10]=l,e[11]=r,e[12]=u,e[13]=d,e[14]=n,e[15]=c):c=e[15],c},Or=t=>{const e=Fe.c(5),{query:n}=t,{t:a}=Re();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 zb(t,e){return`opencode:sidebar-group:${t}:${e}`}const sr=t=>{const e=Fe.c(33),{label:n,count:a,storageKey:i,defaultExpanded:o,children:l}=t,r=o===void 0?!0:o;let u;e[0]!==n||e[1]!==i?(u=zb(i,n),e[0]=n,e[1]=i,e[2]=u):u=e[2];const d=u,c=m.useId();let p;e[3]!==r||e[4]!==d?(p=()=>{try{const I=localStorage.getItem(d);if(I!==null)return I==="true"}catch{}return r},e[3]=r,e[4]=d,e[5]=p):p=e[5];const[g,f]=Ue.useState(p);let h,b;e[6]!==g||e[7]!==d?(h=()=>{try{localStorage.setItem(d,String(g))}catch{}},b=[d,g],e[6]=g,e[7]=d,e[8]=h,e[9]=b):(h=e[8],b=e[9]),Ue.useEffect(h,b);let v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=()=>f(Bb),e[10]=v):v=e[10];let k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k=Je("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]=k):k=e[11];const x=!g&&"-rotate-90 rtl:rotate-90";let w;e[12]!==x?(w=Je("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",x),e[12]=x,e[13]=w):w=e[13];let y;e[14]!==w?(y=s.jsx(ee,{name:"arrow-down-s",className:w}),e[14]=w,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 j;e[18]!==a?(j=s.jsx("span",{className:"ms-1 tabular-nums opacity-60",children:a}),e[18]=a,e[19]=j):j=e[19];let A;e[20]!==c||e[21]!==g||e[22]!==y||e[23]!==N||e[24]!==j?(A=s.jsxs("button",{type:"button",onClick:v,"aria-expanded":g,"aria-controls":c,className:k,children:[y,N,j]}),e[20]=c,e[21]=g,e[22]=y,e[23]=N,e[24]=j,e[25]=A):A=e[25];const C=!g;let P;e[26]!==l||e[27]!==c||e[28]!==C?(P=s.jsx("div",{id:c,hidden:C,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]=c,e[28]=C,e[29]=P):P=e[29];let S;return e[30]!==A||e[31]!==P?(S=s.jsxs("div",{children:[A,P]}),e[30]=A,e[31]=P,e[32]=S):S=e[32],S};function Bb(t){return!t}const Vb=({onItemSelect:t})=>{const{t:e}=Re(),[n,a]=m.useState(""),[i,o]=m.useState(null),[l,r]=m.useState(""),[u,d]=m.useState(null),[c,p]=m.useState(!1),[g,f]=m.useState(null),{selectedAgentName:h,setSelectedAgent:b,setAgentDraft:v,createAgent:k,deleteAgent:x,loadAgents:w,loadDisabledAgents:y,updateAgent:N,fetchAgentEntity:j}=Jn(Ys(J=>({selectedAgentName:J.selectedAgentName,setSelectedAgent:J.setSelectedAgent,setAgentDraft:J.setAgentDraft,createAgent:J.createAgent,deleteAgent:J.deleteAgent,loadAgents:J.loadAgents,loadDisabledAgents:J.loadDisabledAgents,updateAgent:J.updateAgent,fetchAgentEntity:J.fetchAgentEntity}))),A=xn(),C=Jn(J=>cu(J,A)),P=Jn(J=>vp(J,A)),[S,I]=m.useState(null);m.useEffect(()=>{w(A),y(A)},[w,y,A]);const T=C.filter(J=>Uo(J.mode)&&!Yr(J)).length,O=J=>!(Uo(J.mode)&&!Yr(J)&&T<=1),M=async(J,ue)=>{I(J);try{await N(J,{disabled:ue},A),ue&&h===J&&b(null),Q.success(ue?e("settings.agents.sidebar.toast.agentDisabled",{name:J}):e("settings.agents.sidebar.toast.agentEnabled",{name:J}))}catch{Q.error(e(ue?"settings.agents.sidebar.toast.disableFailed":"settings.agents.sidebar.toast.enableFailed"))}finally{I(null)}},K=P.filter(J=>Vi([J.name,J.description],n)),L="bg-background",E=()=>{const J="new-agent";let ue=J,be=1;for(;C.some(fe=>fe.name===ue);)ue=`${J}-${be}`,be++;v({name:ue,scope:"user"}),b(ue),t?.()},D=async J=>{if(Ri(J)){Q.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}d(J)},R=()=>{d(null)},U=async()=>{if(u){p(!0);try{(await x(u.name,u.scope,A)).ok?(Q.success(e("settings.agents.sidebar.toast.agentDeleted",{name:u.name})),R()):Q.error(e("settings.agents.sidebar.toast.deleteFailed"))}catch(J){const ue=J instanceof Error?J.message:"",be=/built-in|not deletable|not found/i.test(ue);Q.error(e(be?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed"))}p(!1)}},$=async J=>{const ue=J.name;let be=1,fe=`${ue}-copy`;for(;C.some(oe=>oe.name===fe);)be++,fe=`${ue}-copy-${be}`;const he=J,ye=await j(J.name,A);if(!ye){Q.error(e("settings.agents.sidebar.toast.renameFailed"));return}const Te=ye.config.request?.body;v({name:fe,scope:ye.scope??he.scope??"user",description:ye.config.description??void 0,model:ye.config.model??null,system:ye.config.system??void 0,steps:ye.config.steps??void 0,temperature:Te?.temperature,top_p:Te?.top_p,mode:ye.config.mode??he.mode,permissions:ye.config.permissions??void 0,hidden:ye.config.hidden}),b(fe),t?.()},W=J=>{r(J.name),o(J)},z=async()=>{if(!i)return;const J=l.trim().replace(/\s+/g,"-");if(!J){Q.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(J===i.name){o(null);return}if(C.some(he=>he.name===J)){Q.error(e("settings.agents.sidebar.toast.agentExists"));return}const ue=i,be=await j(i.name,A);if(!be){Q.error(e("settings.agents.sidebar.toast.renameFailed"));return}(await k({...be.config,name:J,scope:be.scope??ue.scope},A)).ok?(await x(i.name,ue.scope,A)).ok?(Q.success(e("settings.agents.sidebar.toast.agentRenamed",{name:J})),b(J)):Q.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed")):Q.error(e("settings.agents.sidebar.toast.renameFailed")),o(null)},_=J=>{switch(J){case"primary":return s.jsx(ee,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return s.jsx(ee,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return s.jsx(ee,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},F=new Set(P.map(J=>J.name)),V=C.filter(J=>yp(J)&&!F.has(J.name)),H=V.filter(J=>Vi([J.name,J.description],n)),G=H.filter(Ri),X=H.filter(J=>!Ri(J)),{groupedCustomAgents:ae,ungroupedCustomAgents:de}=Ue.useMemo(()=>{const J={},ue=[];for(const fe of X){const he=fe;he.group?(J[he.group]||(J[he.group]=[]),J[he.group].push(fe)):ue.push(fe)}return{groupedCustomAgents:Object.keys(J).sort((fe,he)=>fe.localeCompare(he)).map(fe=>({name:fe,agents:J[fe]})),ungroupedCustomAgents:ue}},[X]);return s.jsxs("div",{className:Je("flex h-full flex-col",L),children:[s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[s.jsx("h2",{className:`${ua} mb-3`,children:e("settings.agents.sidebar.title")}),s.jsx(pi,{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:V.length})}),s.jsx(q,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:E,children:s.jsx(ee,{name:"add",className:"h-3.5 w-3.5"})})]}),V.length>0?s.jsx(Rr,{value:n,onChange:a}):null]}),s.jsxs(js,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:[V.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(ee,{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")})]}):H.length===0?s.jsx(Or,{query:n}):s.jsxs(s.Fragment,{children:[G.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")}),G.map(J=>s.jsx(Cl,{agent:J,isSelected:h===J.name,onSelect:()=>{b(J.name),t?.()},onDuplicate:()=>{$(J)},onDisable:O(J)?()=>{M(J.name,!0)}:void 0,getAgentModeIcon:_,isMenuOpen:g===J.name,onMenuOpenChange:ue=>f(ue?J.name:null)},J.name))]}),X.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")}),ae.map(({name:J,agents:ue})=>s.jsx(sr,{label:J,count:ue.length,storageKey:"agents",children:ue.map(be=>s.jsx(Cl,{agent:be,isSelected:h===be.name,onSelect:()=>{b(be.name),t?.()},onRename:()=>W(be),onDelete:()=>D(be),onDuplicate:()=>{$(be)},onDisable:O(be)?()=>{M(be.name,!0)}:void 0,getAgentModeIcon:_,isMenuOpen:g===be.name,onMenuOpenChange:fe=>f(fe?be.name:null)},be.name))},J)),de.map(J=>s.jsx(Cl,{agent:J,isSelected:h===J.name,onSelect:()=>{b(J.name),t?.()},onRename:()=>W(J),onDelete:()=>D(J),onDuplicate:()=>{$(J)},onDisable:O(J)?()=>{M(J.name,!0)}:void 0,getAgentModeIcon:_,isMenuOpen:g===J.name,onMenuOpenChange:ue=>f(ue?J.name:null)},J.name))]})]}),K.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")}),K.map(J=>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:J.name}),J.description?s.jsx("div",{className:"typography-micro truncate leading-tight text-muted-foreground",children:J.description}):null]}),s.jsx(q,{size:"xs",variant:"outline",disabled:S===J.name,onClick:()=>{M(J.name,!1)},"aria-label":e("settings.agents.sidebar.actions.enableAria",{name:J.name}),children:e("settings.agents.sidebar.actions.enable")})]},J.name))]})]}),s.jsx(_t,{open:u!==null,onOpenChange:J=>{!J&&!c&&R()},children:s.jsxs($t,{className:"max-w-md",children:[s.jsxs(zt,{children:[s.jsx(Bt,{children:e("settings.agents.sidebar.dialog.deleteTitle")}),s.jsx(Vt,{children:e("settings.agents.sidebar.dialog.deleteDescription",{name:u?.name??""})})]}),s.jsxs(ss,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:R,disabled:c,children:e("settings.common.actions.cancel")}),s.jsx(q,{size:"sm",onClick:U,disabled:c,children:e("settings.common.actions.delete")})]})]})}),s.jsx(_t,{open:i!==null,onOpenChange:J=>!J&&o(null),children:s.jsxs($t,{children:[s.jsxs(zt,{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(Ye,{value:l,onChange:J=>r(J.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:J=>{J.key==="Enter"&&z()}}),s.jsxs(ss,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>o(null),children:e("settings.common.actions.cancel")}),s.jsx(q,{size:"sm",onClick:z,children:e("settings.common.actions.rename")})]})]})})]})},Cl=t=>{const e=Fe.c(52),{agent:n,isSelected:a,onSelect:i,onDelete:o,onRename:l,onDuplicate:r,onDisable:u,getAgentModeIcon:d,isMenuOpen:c,onMenuOpenChange:p}=t,{t:g}=Re(),f=n;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=xr(),e[0]=h):h=e[0];const b=h,[v,k]=m.useState(!1);let x;e[1]!==o||e[2]!==u||e[3]!==r||e[4]!==l||e[5]!==g?(x=W=>s.jsxs(s.Fragment,{children:[l&&s.jsxs(W,{onClick:z=>{z.stopPropagation(),l()},children:[s.jsx(ee,{name:"edit",className:"h-4 w-4 me-px"}),g("settings.common.actions.rename")]}),s.jsxs(W,{onClick:z=>{z.stopPropagation(),r()},children:[s.jsx(ee,{name:"file-copy",className:"h-4 w-4 me-px"}),g("settings.common.actions.duplicate")]}),u&&s.jsxs(W,{onClick:z=>{z.stopPropagation(),u()},children:[s.jsx(ee,{name:"eye-off",className:"h-4 w-4 me-px"}),g("settings.agents.sidebar.actions.disable")]}),o&&s.jsxs(W,{onClick:z=>{z.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[s.jsx(ee,{name:"delete-bin",className:"h-4 w-4 me-px"}),g("settings.common.actions.delete")]})]}),e[1]=o,e[2]=u,e[3]=r,e[4]=l,e[5]=g,e[6]=x):x=e[6];const w=x,y=a?"bg-interactive-selection":"hover:bg-interactive-hover";let N;e[7]!==y?(N=Je("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 j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=b?void 0:W=>{W.preventDefault(),k(!0)},e[9]=j):j=e[9];let A;e[10]!==N?(A=s.jsx("div",{className:N,onContextMenu:j}),e[10]=N,e[11]=A):A=e[11];let C;e[12]!==n.name?(C=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n.name}),e[12]=n.name,e[13]=C):C=e[13];let P;e[14]!==n.mode||e[15]!==d?(P=d(n.mode),e[14]=n.mode,e[15]=d,e[16]=P):P=e[16];let S;e[17]!==n||e[18]!==f.scope||e[19]!==g?(S=(f.scope||Ri(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:Ri(n)?g("settings.agents.sidebar.badge.system"):f.scope}),e[17]=n,e[18]=f.scope,e[19]=g,e[20]=S):S=e[20];let I;e[21]!==C||e[22]!==P||e[23]!==S?(I=s.jsxs("div",{className:"flex items-center gap-1.5",children:[C,P,S]}),e[21]=C,e[22]=P,e[23]=S,e[24]=I):I=e[24];let T;e[25]!==n.description?(T=n.description&&s.jsx("div",{className:"typography-micro text-muted-foreground truncate leading-tight",children:n.description}),e[25]=n.description,e[26]=T):T=e[26];let O;e[27]!==i||e[28]!==I||e[29]!==T?(O=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:[I,T]}),e[27]=i,e[28]=I,e[29]=T,e[30]=O):O=e[30];let M;e[31]!==p?(M=W=>{W&&k(!1),p(W)},e[31]=p,e[32]=M):M=e[32];let K;e[33]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(Aa,{asChild:!0,children:s.jsx(q,{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",children:s.jsx(ee,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=K):K=e[33];let L;e[34]!==w?(L=s.jsx(Pa,{align:"end",className:"w-fit min-w-20",children:w(wa)}),e[34]=w,e[35]=L):L=e[35];let E;e[36]!==c||e[37]!==M||e[38]!==L?(E=s.jsxs(Ta,{open:c,onOpenChange:M,children:[K,L]}),e[36]=c,e[37]=M,e[38]=L,e[39]=E):E=e[39];let D;e[40]!==O||e[41]!==E?(D=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[O,E]}),e[40]=O,e[41]=E,e[42]=D):D=e[42];let R;e[43]!==D||e[44]!==A?(R=s.jsx(Ji,{render:A,children:D}),e[43]=D,e[44]=A,e[45]=R):R=e[45];let U;e[46]!==w?(U=s.jsx(qi,{className:"w-fit min-w-20",children:w(Gi)}),e[46]=w,e[47]=U):U=e[47];let $;return e[48]!==v||e[49]!==R||e[50]!==U?($=s.jsxs(Qi,{open:v,onOpenChange:k,children:[R,U]}),e[48]=v,e[49]=R,e[50]=U,e[51]=$):$=e[51],$},dn={ok:!0,changed:!1},Qn={ok:!0,changed:!0},Ps=t=>({ok:!1,reason:t}),Hb=t=>t instanceof HTMLElement?t.matches('input, textarea, [contenteditable="true"]'):!1,gi=t=>{const{t:e}=Re(),[n,a]=m.useState(0),i=m.useRef(t);i.current=t;const o=m.useRef(e);o.current=e;const l=m.useRef(!1),r=m.useRef(!1),u=m.useRef(!1),d=m.useCallback(()=>{a(g=>g+1)},[]),c=m.useCallback(g=>{Hb(g.target)&&d()},[d]),p=m.useCallback(async()=>{l.current=!0;try{for(;;){r.current=!1;let g;try{g=await i.current()}catch(f){g={ok:!1,reason:f instanceof Error?f.message:String(f)}}if(!u.current)return;if(!r.current){g.ok||Q.error(o.current("settings.common.status.saveFailedReason",{reason:g.reason}));return}}}finally{l.current=!1}},[]);return m.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]),m.useEffect(()=>{if(n!==0){if(l.current){r.current=!0;return}p()}},[n,p]),{requestSave:d,onBlurCapture:c}},Wb=["allow","ask","deny"],qb=["shell","edit","read","glob","grep","patch","webfetch","websearch","skill","subagent","question","external_directory"],Gb=["openchamber","openchamber_schedule","openchamber_web","openchamber_memory","openchamber_knowledge","openchamber_notify","openchamber_render","openchamber_image","openchamber_secret"],Jb=new Set(["bash","task","write","list","lsp","todowrite","todoread","multiedit","doom_loop","plan_enter","plan_exit"]),Gu=t=>Jb.has(t),Qb=[{action:"*",resource:"*",effect:"allow"},{action:"read",resource:"*.env",effect:"ask"},{action:"read",resource:"*.env.*",effect:"ask"},{action:"read",resource:"*.env.example",effect:"allow"}],Mc=()=>({global:null,keys:{},source:[]}),Oa=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}))}]))}),Yb=t=>{const e={global:null,keys:{},source:t.map(n=>({...n}))};for(const n of t){if(Gu(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},Zb=t=>t.action!=="*"||t.resource==="*",Ua=(t,e)=>`${t}\0${e}`,Xb=t=>{const e=new Map;t.global!==null&&e.set(Ua("*","*"),t.global);for(const[n,a]of Object.entries(t.keys)){a.effect!==null&&e.set(Ua(n,"*"),a.effect);for(const i of a.patterns){const o=i.pattern.trim();o.length!==0&&e.set(Ua(n,o),i.effect)}}return e},nr=t=>{const e=Xb(t),n=new Set,a=[];for(const o of t.source){if(Gu(o.action))continue;if(!Zb(o)){a.push({...o});continue}const l=Ua(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=Ua("*","*");t.global!==null&&!n.has(i)&&a.unshift({action:"*",resource:"*",effect:t.global});for(const[o,l]of Object.entries(t.keys)){const r=Ua(o,"*");if(l.effect!==null&&!n.has(r)){const u=a.findIndex(c=>c.action===o),d={action:o,resource:"*",effect:l.effect};u>=0?a.splice(u,0,d):a.push(d)}for(const u of l.patterns){const d=u.pattern.trim();if(d.length===0)continue;const c=Ua(o,d),p=e.get(c);p===void 0||n.has(c)||(n.add(c),a.push({action:o,resource:d,effect:p}))}}return a},e1=(t,e)=>JSON.stringify(nr(t))===JSON.stringify(nr(e)),t1=(t,e)=>{const n=[...Qb,...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},s1=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),n1=new Set(["shell","edit","read","glob","grep","patch","webfetch","skill","subagent","external_directory"]),a1={effect:null,patterns:[]},i1=t=>{const e=Fe.c(163),{agent:n,registerSave:a,requestSave:i}=t,{t:o}=Re(),l=Jn(o1),r=Jn(l1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],e[0]=u):u=e[0];const[d,c]=m.useState(u),[p,g]=m.useState(Mc),[f,h]=m.useState(Mc),[b,v]=m.useState(!0),[k,x]=m.useState(!1);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w={},e[1]=w):w=e[1];const[y,N]=m.useState(w),[j,A]=m.useState(""),[C,P]=m.useState(0),S=n.name,I=xn(),T=ia(r1);let O;e[2]!==I?(O=qe=>vr(qe,I),e[2]=I,e[3]=O):O=e[3];const M=ia(O);let K;e[4]!==I?(K=qe=>qe.getStatusForDirectory(I),e[4]=I,e[5]=K):K=e[5];const L=Kn(K);let E,D;e[6]!==T||e[7]!==I?(E=()=>{T({directory:I})},D=[T,I],e[6]=T,e[7]=I,e[8]=E,e[9]=D):(E=e[8],D=e[9]),m.useEffect(E,D);let R;e[10]!==S||e[11]!==r||e[12]!==I?(R=()=>{let qe=!1;return v(!0),x(!1),(async()=>{const gt=await r(S,I);if(qe)return;if(!gt){x(!0),v(!1);return}const lt=Yb(gt.agent);c(gt.global),g(Oa(lt)),h(lt),N({}),v(!1)})(),()=>{qe=!0}},e[10]=S,e[11]=r,e[12]=I,e[13]=R):R=e[13];let U;e[14]!==S||e[15]!==r||e[16]!==C||e[17]!==I?(U=[S,r,C,I],e[14]=S,e[15]=r,e[16]=C,e[17]=I,e[18]=U):U=e[18],m.useEffect(R,U);let $;e[19]!==S||e[20]!==p||e[21]!==f||e[22]!==I||e[23]!==o||e[24]!==l?($=async()=>e1(f,p)?dn:(await l(S,{permissions:nr(f)},I)).ok?(g(Oa(f)),Qn):Ps(o("settings.agents.page.permissionsEditor.toast.saveFailed")),e[19]=S,e[20]=p,e[21]=f,e[22]=I,e[23]=o,e[24]=l,e[25]=$):$=e[25];const W=$;let z,_;e[26]!==a||e[27]!==W?(z=()=>(a(W),()=>a(null)),_=[a,W],e[26]=a,e[27]=W,e[28]=z,e[29]=_):(z=e[28],_=e[29]),m.useEffect(z,_);let F;e[30]!==M?(F=M.map(c1),e[30]=M,e[31]=F):F=e[31];const V=F;let H;if(e[32]!==V||e[33]!==f.keys){H=[...qb,...Gb];const qe=new Set(V.map(d1));let gt;e[35]!==f.keys?(gt=Object.keys(f.keys),e[35]=f.keys,e[36]=gt):gt=e[36];for(const lt of gt)!H.includes(lt)&&!qe.has(lt)&&H.push(lt);e[32]=V,e[33]=f.keys,e[34]=H}else H=e[34];const G=H;let X;e[37]!==L||e[38]!==o?(X=qe=>{switch(L?.[qe]?.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]=L,e[38]=o,e[39]=X):X=e[39];const ae=X;let de;e[40]!==d||e[41]!==f.global?(de=qe=>t1(qe,{global:d,agentGlobal:f.global}),e[40]=d,e[41]=f.global,e[42]=de):de=e[42];const J=de;let ue;e[43]!==i?(ue=qe=>{h(gt=>({...gt,global:qe})),i()},e[43]=i,e[44]=ue):ue=e[44];const be=ue;let fe;e[45]!==i?(fe=(qe,gt)=>{h(lt=>{const we=Oa(lt),Qe=we.keys[qe]??{effect:null,patterns:[]};return Qe.effect=gt,Qe.effect===null&&Qe.patterns.length===0?delete we.keys[qe]:we.keys[qe]=Qe,we}),i()},e[45]=i,e[46]=fe):fe=e[46];const he=fe;let ye;e[47]!==i?(ye=(qe,gt,lt,we,Qe)=>{h(tt=>{const ht=Oa(tt),at=ht.keys[qe]??{effect:null,patterns:[]};return at.patterns[gt]={pattern:lt,effect:we},ht.keys[qe]=at,ht}),Qe&&i()},e[47]=i,e[48]=ye):ye=e[48];const Te=ye;let oe;e[49]===Symbol.for("react.memo_cache_sentinel")?(oe=qe=>{h(gt=>{const lt=Oa(gt),we=lt.keys[qe]??{effect:null,patterns:[]};return we.patterns.push({pattern:"",effect:"allow"}),lt.keys[qe]=we,lt}),N(gt=>({...gt,[qe]:!0}))},e[49]=oe):oe=e[49];const Y=oe;let ve;e[50]!==i?(ve=(qe,gt)=>{h(lt=>{const we=Oa(lt),Qe=we.keys[qe];return Qe?(Qe.patterns.splice(gt,1),Qe.effect===null&&Qe.patterns.length===0&&delete we.keys[qe],we):lt}),i()},e[50]=i,e[51]=ve):ve=e[51];const xe=ve;let Ce;e[52]!==j||e[53]!==i?(Ce=()=>{const qe=j.trim();!qe||qe==="*"||(h(gt=>{if(gt.keys[qe])return gt;const lt=Oa(gt);return lt.keys[qe]={effect:"ask",patterns:[]},lt}),A(""),i())},e[52]=j,e[53]=i,e[54]=Ce):Ce=e[54];const Se=Ce;let Me;e[55]!==o?(Me=qe=>o(qe==="allow"?"settings.agents.page.permissionsEditor.action.allow":qe==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),e[55]=o,e[56]=Me):Me=e[56];const pe=Me;let me,le,te,Ne,re,ge,Oe,Ke,Le;if(e[57]!==pe||e[58]!==J||e[59]!==y||e[60]!==b||e[61]!==k||e[62]!==V||e[63]!==ae||e[64]!==f.global||e[65]!==f.keys||e[66]!==xe||e[67]!==be||e[68]!==he||e[69]!==Te||e[70]!==o||e[71]!==G){Le=Symbol.for("react.early_return_sentinel");e:{const qe=o("settings.agents.page.permissionsEditor.action.inherit"),gt=o("settings.agents.page.permissionsEditor.action.default");let lt;e[81]!==pe?(lt=Ge=>[...Ge?[{value:"inherit",label:Ge}]:[],...Wb.map(ct=>({value:ct,label:pe(ct)}))],e[81]=pe,e[82]=lt):lt=e[82];const we=lt,Qe=(Ge,ct,Ct,jt)=>{const Nt=jt===void 0?qe:jt;return s.jsx(Qt,{value:Ge??"inherit",options:we(Nt),onChange:ke=>ct(ke==="inherit"?null:ke),"aria-label":Ct})};if(b){let Ge;e[83]!==o?(Ge=o("settings.agents.page.section.toolPermissions"),e[83]=o,e[84]=Ge):Ge=e[84];let ct;e[85]!==o?(ct=o("common.loading"),e[85]=o,e[86]=ct):ct=e[86];let Ct;e[87]!==ct?(Ct=s.jsx("p",{className:Ht,children:ct}),e[87]=ct,e[88]=Ct):Ct=e[88];let jt;e[89]!==Ge||e[90]!==Ct?(jt=s.jsx(ze,{title:Ge,children:Ct}),e[89]=Ge,e[90]=Ct,e[91]=jt):jt=e[91],Le=jt;break e}if(k){let Ge;e[92]!==o?(Ge=o("settings.agents.page.section.toolPermissions"),e[92]=o,e[93]=Ge):Ge=e[93];let ct;e[94]!==o?(ct=o("settings.agents.page.permissionsEditor.state.loadFailed"),e[94]=o,e[95]=ct):ct=e[95];let Ct;e[96]!==ct?(Ct=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:ct}),e[96]=ct,e[97]=Ct):Ct=e[97];let jt;e[98]===Symbol.for("react.memo_cache_sentinel")?(jt=()=>P(u1),e[98]=jt):jt=e[98];let Nt;e[99]!==o?(Nt=o("settings.agents.page.permissionsEditor.actions.retry"),e[99]=o,e[100]=Nt):Nt=e[100];let ke;e[101]!==Nt?(ke=s.jsx(q,{variant:"outline",size:"xs",onClick:jt,children:Nt}),e[101]=Nt,e[102]=ke):ke=e[102];let Ee;e[103]!==Ct||e[104]!==ke?(Ee=s.jsxs("div",{className:"flex items-center gap-3",children:[Ct,ke]}),e[103]=Ct,e[104]=ke,e[105]=Ee):Ee=e[105];let We;e[106]!==Ge||e[107]!==Ee?(We=s.jsx(ze,{title:Ge,children:Ee}),e[106]=Ge,e[107]=Ee,e[108]=We):We=e[108],Le=We;break e}const tt=(Ge,ct,Ct)=>{const jt=f.keys[Ge]??a1,Nt=n1.has(Ge)||jt.patterns.length>0,ke=y[Ge]===!0;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:Nt?()=>N(Ee=>({...Ee,[Ge]:!ke})):void 0,className:Je("flex min-w-0 items-center gap-1.5 text-start",!Nt&&"cursor-default"),"aria-expanded":Nt?ke:void 0,children:[s.jsx(ee,{name:ke&&Nt?"arrow-down-s":"arrow-right-s",className:Je("h-3.5 w-3.5 shrink-0 text-muted-foreground",!Nt&&"opacity-0")}),s.jsx("span",{className:cs,children:ct}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground",children:Ge}),Ct&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:Ct}),jt.effect===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:pe(J(Ge))})}),jt.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(jt.patterns.length)})})]}),Qe(jt.effect,Ee=>he(Ge,Ee),o("settings.agents.page.permissionsEditor.keyAria",{key:Ge}))]}),ke&&Nt&&s.jsxs("div",{className:"mt-2 space-y-2 ps-5",children:[jt.patterns.map((Ee,We)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Ye,{value:Ee.pattern,onChange:vt=>Te(Ge,We,vt.target.value,Ee.effect,!1),placeholder:o("settings.agents.page.permissionsEditor.patternPlaceholder"),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:Ge}),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(Qt,{value:Ee.effect,options:we(),onChange:vt=>Te(Ge,We,Ee.pattern,vt,!0),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:Ge})}),s.jsx(q,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>xe(Ge,We),"aria-label":o("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx(ee,{name:"close",className:"h-3.5 w-3.5"})})]},We)),s.jsxs(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Y(Ge),children:[s.jsx(ee,{name:"add",className:"me-1 h-3.5 w-3.5"}),o("settings.agents.page.permissionsEditor.actions.addRule")]})]})]},Ge)};me=ze,e[109]!==o?(le=o("settings.agents.page.section.toolPermissions"),e[109]=o,e[110]=le):le=e[110],te="agents.permissions",e[111]!==o?(Ne=o("settings.agents.page.permissionsEditor.sectionInfo"),e[111]=o,e[112]=Ne):Ne=e[112],re="space-y-4";let ht;e[113]!==o?(ht=o("settings.agents.page.permissionsEditor.defaultLabel"),e[113]=o,e[114]=ht):ht=e[114];let at;e[115]!==ht?(at=s.jsx("span",{className:cs,children:ht}),e[115]=ht,e[116]=at):at=e[116];let kt;e[117]!==o?(kt=o("settings.agents.page.permissionsEditor.defaultInfo"),e[117]=o,e[118]=kt):kt=e[118];let se;e[119]!==kt?(se=s.jsx(us,{children:kt}),e[119]=kt,e[120]=se):se=e[120];let Z;e[121]!==pe||e[122]!==J||e[123]!==f.global||e[124]!==o?(Z=f.global===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:pe(J("*"))})}),e[121]=pe,e[122]=J,e[123]=f.global,e[124]=o,e[125]=Z):Z=e[125];let nt;e[126]!==at||e[127]!==se||e[128]!==Z?(nt=s.jsxs("div",{className:"flex items-center gap-1.5",children:[at,se,Z]}),e[126]=at,e[127]=se,e[128]=Z,e[129]=nt):nt=e[129];const St=f.global;let He;e[130]!==o?(He=o("settings.agents.page.permissionsEditor.defaultAria"),e[130]=o,e[131]=He):He=e[131],ge=s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[nt,Qe(St,be,He,gt)]}),Oe=s.jsx("div",{children:G.map(Ge=>tt(Ge,s1(Ge),null))}),Ke=V.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:cs,children:o("settings.agents.page.permissionsEditor.mcpTitle")}),s.jsx(us,{children:o("settings.agents.page.permissionsEditor.mcpInfo")})]}),V.map(Ge=>tt(Ge.key,Ge.server,ae(Ge.server)))]})}e[57]=pe,e[58]=J,e[59]=y,e[60]=b,e[61]=k,e[62]=V,e[63]=ae,e[64]=f.global,e[65]=f.keys,e[66]=xe,e[67]=be,e[68]=he,e[69]=Te,e[70]=o,e[71]=G,e[72]=me,e[73]=le,e[74]=te,e[75]=Ne,e[76]=re,e[77]=ge,e[78]=Oe,e[79]=Ke,e[80]=Le}else me=e[72],le=e[73],te=e[74],Ne=e[75],re=e[76],ge=e[77],Oe=e[78],Ke=e[79],Le=e[80];if(Le!==Symbol.for("react.early_return_sentinel"))return Le;let ne;e[132]===Symbol.for("react.memo_cache_sentinel")?(ne=qe=>A(qe.target.value),e[132]=ne):ne=e[132];let Ie;e[133]!==Se?(Ie=qe=>{qe.key==="Enter"&&(qe.preventDefault(),Se())},e[133]=Se,e[134]=Ie):Ie=e[134];let Pe;e[135]!==o?(Pe=o("settings.agents.page.permissionsEditor.customKeyPlaceholder"),e[135]=o,e[136]=Pe):Pe=e[136];let De;e[137]!==j||e[138]!==Ie||e[139]!==Pe?(De=s.jsx(Ye,{value:j,onChange:ne,onKeyDown:Ie,placeholder:Pe,className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),e[137]=j,e[138]=Ie,e[139]=Pe,e[140]=De):De=e[140];let Be;e[141]!==j?(Be=j.trim(),e[141]=j,e[142]=Be):Be=e[142];const bt=!Be;let $e;e[143]===Symbol.for("react.memo_cache_sentinel")?($e=s.jsx(ee,{name:"add",className:"me-1 h-3.5 w-3.5"}),e[143]=$e):$e=e[143];let dt;e[144]!==o?(dt=o("settings.agents.page.permissionsEditor.actions.addKey"),e[144]=o,e[145]=dt):dt=e[145];let Ve;e[146]!==Se||e[147]!==bt||e[148]!==dt?(Ve=s.jsxs(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:Se,disabled:bt,children:[$e,dt]}),e[146]=Se,e[147]=bt,e[148]=dt,e[149]=Ve):Ve=e[149];let st;e[150]!==De||e[151]!==Ve?(st=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-edge-muted pt-3",children:[De,Ve]}),e[150]=De,e[151]=Ve,e[152]=st):st=e[152];let ut;return e[153]!==me||e[154]!==le||e[155]!==te||e[156]!==Ne||e[157]!==re||e[158]!==ge||e[159]!==Oe||e[160]!==Ke||e[161]!==st?(ut=s.jsxs(me,{title:le,settingsItem:te,info:Ne,contentClassName:re,children:[ge,Oe,Ke,st]}),e[153]=me,e[154]=le,e[155]=te,e[156]=Ne,e[157]=re,e[158]=ge,e[159]=Oe,e[160]=Ke,e[161]=st,e[162]=ut):ut=e[162],ut};function o1(t){return t.updateAgent}function l1(t){return t.fetchAgentPermissions}function r1(t){return t.loadMcpConfigs}function c1(t){return{key:`${t.name}_*`,server:t.name}}function d1(t){return t.key}function u1(t){return t+1}const Fr=t=>{const e=Fe.c(11),{legacy:n,path:a,className:i}=t,{t:o}=Re();if(!n)return null;let l;e[0]!==i?(l=Je("mb-4 flex items-start gap-1.5",Ht,i),e[0]=i,e[1]=l):l=e[1];const r=a??void 0;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(ee,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 opacity-70"}),e[2]=u):u=e[2];let d;e[3]!==o?(d=o("settings.common.legacyFormat.note"),e[3]=o,e[4]=d):d=e[4];let c;e[5]!==d?(c=s.jsx("span",{children:d}),e[5]=d,e[6]=c):c=e[6];let p;return e[7]!==l||e[8]!==r||e[9]!==c?(p=s.jsxs("p",{className:l,title:r,children:[u,c]}),e[7]=l,e[8]=r,e[9]=c,e[10]=p):p=e[10],p},m1=(t,e)=>{const n=la(e);if(!n)return[];const a=t.find(o=>o.id===n.providerId),i=If(a?.models,n.modelId);return du(i)},p1=t=>kp(t)?.toLowerCase()??"",g1=()=>{const{t}=Re(),e=pt(pe=>pe.providers),{selectedAgentName:n,getAgentByName:a,createAgent:i,updateAgent:o,fetchAgentEntity:l,agentDraft:r,setAgentDraft:u,setSelectedAgent:d}=Jn(Ys(pe=>({selectedAgentName:pe.selectedAgentName,getAgentByName:pe.getAgentByName,createAgent:pe.createAgent,updateAgent:pe.updateAgent,fetchAgentEntity:pe.fetchAgentEntity,agentDraft:pe.agentDraft,setAgentDraft:pe.setAgentDraft,setSelectedAgent:pe.setSelectedAgent}))),c=xn(),p=Jn(pe=>cu(pe,c)),g=n?a(n,c):null,f=!!(r&&r.name===n&&!g),h=f?"":g?.description?.trim()??"",b=f?"":g?.system?.trim()??"",[v,k]=m.useState(""),[x,w]=m.useState("user"),[y,N]=m.useState(""),[j,A]=m.useState("subagent"),[C,P]=m.useState(""),[S,I]=m.useState(""),[T,O]=m.useState(void 0),[M,K]=m.useState(void 0),[L,E]=m.useState(void 0),[D,R]=m.useState(""),[U,$]=m.useState(""),[W,z]=m.useState(!1),[_,F]=m.useState(null),V=m.useRef({}),H=m.useRef(null),G=m.useCallback(pe=>{H.current=pe},[]),X=m.useRef(null),ae=JSON.stringify([n,c,f]),de=m.useRef(ae);de.current=ae;const J=m.useRef(null),ue={description:y,mode:j,model:C,variant:S,steps:T,temperature:M,topP:L,system:D,color:U},be=m.useRef(ue);be.current=ue;const fe=m.useMemo(()=>m1(e,C),[C,e]),he=fe.length>0,ye=S||"__default",Te=he,oe=m.useMemo(()=>S&&!fe.includes(S)?[S,...fe]:fe,[S,fe]);m.useEffect(()=>{if(!f||!r)return;J.current=null;const pe=Fi(r.model),me=r.name||"",le=r.scope||"user",te=r.description||"",Ne=r.mode||"subagent",re=pe?`${pe.providerID}/${pe.modelID}`:"",ge=pe?.variant||"",Oe=r.steps??void 0,Ke=r.temperature??void 0,Le=r.top_p??void 0,ne=r.system||"",Ie="";V.current={},F(null),k(me),w(le),N(te),A(Ne),P(re),I(ge),O(Oe),K(Ke),E(Le),R(ne),$(Ie),X.current={draftName:me,draftScope:le,description:te,mode:Ne,model:re,variant:ge,steps:Oe,temperature:Ke,topP:Le,system:ne,color:Ie}},[r,f]),m.useEffect(()=>{if(f||!n)return;let pe=!1;return(async()=>{const me=await l(n,c);if(pe||de.current!==ae||!me)return;const le=me.config;V.current=le;const te=Fi(le.model),Ne=le.request?.body,re={draftName:"",draftScope:"user",description:le.description||"",mode:le.mode||g?.mode||"subagent",model:te?`${te.providerID}/${te.modelID}`:"",variant:te?.variant||"",steps:le.steps??void 0,temperature:Ne?.temperature,topP:Ne?.top_p,system:le.system||"",color:p1(le.color)},ge=X.current,Oe=be.current,Ke=ge!==null&&(Oe.description!==ge.description||Oe.mode!==ge.mode||Oe.model!==ge.model||Oe.variant!==ge.variant||Oe.steps!==ge.steps||Oe.temperature!==ge.temperature||Oe.topP!==ge.topP||Oe.system!==ge.system||Oe.color!==ge.color);F({legacy:me.legacy===!0,path:me.path,source:me.source}),!(J.current===ae&&Ke)&&(J.current=ae,N(re.description),A(re.mode),P(re.model),I(re.variant),O(re.steps),K(re.temperature),E(re.topP),R(re.system),$(re.color),X.current=re)})(),()=>{pe=!0}},[l,f,g,n,c,ae]);const Y=m.useCallback(pe=>{const me=la(C.trim()),le=me?Mu({providerID:me.providerId,modelID:me.modelId,variant:S.trim()||void 0}):null,te=V.current.request,Ne={...te?.body};M===void 0?delete Ne.temperature:Ne.temperature=M,L===void 0?delete Ne.top_p:Ne.top_p=L;const re=te?.headers,ge={};re&&Object.keys(re).length>0&&(ge.headers=re),Object.keys(Ne).length>0&&(ge.body=Ne);const Oe=y.trim(),Ke=D.trim(),Le={name:pe,mode:j,model:le,steps:T??null,system:Ke||(f?void 0:null),request:Object.keys(ge).length>0?ge:null};return Oe&&(Le.description=Oe),U!==(X.current?.color??"")&&(Le.color=U||null),f&&x&&(Le.scope=x),f&&r?.hidden!==void 0&&(Le.hidden=r.hidden),f&&r?.permissions?.length&&(Le.permissions=r.permissions),Le},[r,U,y,x,f,j,C,T,D,M,L,S]),ve=m.useCallback(async()=>{const pe=X.current,me=n?.trim();if(f||!pe||!me)return dn;const le=H.current?await H.current():dn;if(y===pe.description&&j===pe.mode&&C===pe.model&&S===pe.variant&&T===pe.steps&&M===pe.temperature&&L===pe.topP&&D===pe.system&&U===pe.color||!le.ok)return le;const Ne=Y(me);return(await o(me,Ne,c)).ok?(de.current!==ae||(V.current={...V.current,model:Ne.model,system:Ne.system??void 0,steps:Ne.steps,request:Ne.request??void 0},X.current={...pe,description:y,mode:j,model:C,variant:S,steps:T,temperature:M,topP:L,system:D,color:U}),Qn):Ps(t("settings.agents.page.toast.updateFailed"))},[Y,U,y,f,j,C,n,ae,c,T,D,t,M,L,o,S]),xe=gi(ve),{requestSave:Ce}=xe,Se=async()=>{const pe=v.trim().replace(/\s+/g,"-");if(!pe){Q.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(p.some(me=>me.name===pe)){Q.error(t("settings.agents.sidebar.toast.agentExists"));return}z(!0);try{(await i(Y(pe),c)).ok?(u(null),Q.success(t("settings.agents.page.toast.created"))):Q.error(t("settings.agents.page.toast.createFailed"))}catch(me){console.error("Error creating agent:",me);const le=me instanceof Error&&me.message?me.message:t("settings.agents.page.toast.saveUnexpectedError");Q.error(le)}finally{z(!1)}},Me=()=>{u(null),d(null)};return n?s.jsxs(ts,{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&&_&&s.jsx(Fr,{legacy:_.legacy,path:_.path}),!f&&_?.source==="none"&&s.jsxs("p",{className:`mb-4 flex items-start gap-1.5 ${Ht}`,children:[s.jsx(ee,{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(ze,{title:t("settings.agents.page.section.identityRole"),divider:!1,contentClassName:"space-y-3",children:[f&&s.jsxs(it,{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(Ye,{value:v,onChange:pe=>k(pe.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Lt,{value:x,onValueChange:pe=>w(pe),children:[s.jsx(Ot,{className:"w-fit min-w-[100px]",children:s.jsx(Kt,{children:t(x==="project"?"settings.common.scope.project":"settings.common.scope.global")})}),s.jsxs(Ft,{align:"end",children:[s.jsx(xt,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ee,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(xt,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ee,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsx(Tt,{label:t("settings.common.field.description"),controlClassName:"w-full max-w-none",children:s.jsx(_s,{value:y,onChange:pe=>N(pe.target.value),placeholder:h||t("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})}),s.jsx(Tt,{settingsItem:"agents.mode",label:t("settings.agents.page.field.mode"),info:t("settings.agents.page.field.modeTooltip"),children:s.jsx(Qt,{"aria-label":t("settings.agents.page.field.mode"),value:j,onChange:pe=>{A(pe),Ce()},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(Tt,{settingsItem:"agents.color",label:t("settings.agents.page.field.color"),info:t("settings.agents.page.field.colorTooltip"),children:s.jsx(Dh,{value:U,labels:{empty:t("settings.agents.page.field.colorAutomatic"),swatch:pe=>t("settings.agents.page.field.colorSwatchAria",{color:pe}),custom:t("settings.agents.page.field.colorCustomAria"),hex:t("settings.agents.page.field.colorHexAria")},onChange:pe=>{$(pe),Ce()}})})]}),s.jsxs(ze,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx(it,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(ja,{providerId:la(C)?.providerId??"",modelId:la(C)?.modelId??"",onChange:(pe,me)=>{P(pe&&me?`${pe}/${me}`:""),I(""),Ce()},className:Nn})}),s.jsx(it,{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:Te?s.jsxs(Lt,{value:ye,onValueChange:pe=>{I(pe==="__default"?"":pe),Ce()},children:[s.jsx(Ot,{className:As,children:s.jsx(Kt,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:pe=>pe==="__default"?t("chat.modelControls.default"):pe})}),s.jsxs(Ft,{children:[s.jsx(xt,{value:"__default",children:t("chat.modelControls.default")}),oe.map(pe=>s.jsx(xt,{value:pe,children:pe},pe))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ye,{value:S,onChange:pe=>I(pe.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!C&&!S,className:"h-8 w-40 rounded-md px-3"}),S&&s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{I(""),Ce()},className:as,"aria-label":t("settings.common.actions.clear"),title:t("settings.common.actions.clear"),children:s.jsx(ee,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsxs(it,{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(ws,{value:M,fallbackValue:.7,onValueChange:K,onClear:()=>{K(void 0),Ce()},min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:Ss}),M!==void 0&&s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{K(void 0),Ce()},className:as,"aria-label":t("settings.agents.page.field.clearTemperatureAria"),title:t("settings.common.actions.clear"),children:s.jsx(ee,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(it,{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(ws,{value:L,fallbackValue:.9,onValueChange:E,onClear:()=>{E(void 0),Ce()},min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:Ss}),L!==void 0&&s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{E(void 0),Ce()},className:as,"aria-label":t("settings.agents.page.field.clearTopPAria"),title:t("settings.common.actions.clear"),children:s.jsx(ee,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(it,{settingsItem:"agents.steps",label:t("settings.agents.page.field.steps"),info:t("settings.agents.page.field.stepsTooltip"),children:[s.jsx(ws,{value:T,fallbackValue:20,onValueChange:O,onClear:()=>{O(void 0),Ce()},min:1,max:1e3,step:1,inputMode:"numeric",placeholder:"—",emptyLabel:"—",className:Ss}),T!==void 0&&s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{O(void 0),Ce()},className:as,"aria-label":t("settings.agents.page.field.clearStepsAria"),title:t("settings.common.actions.clear"),children:s.jsx(ee,{name:"close",className:"h-3.5 w-3.5"})})]})]}),s.jsx(ze,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx(_s,{value:D,onChange:pe=>R(pe.target.value),placeholder:b||t("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent"})}),!f&&g&&s.jsx(i1,{agent:g,registerSave:G,requestSave:Ce}),f&&s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[s.jsx(q,{onClick:()=>{Se()},disabled:W||!v.trim(),size:"xs",className:"!font-normal",children:t(W?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(q,{variant:"ghost",onClick:Me,disabled:W,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(ee,{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 f1(t,e){return t.kind==="file"?t.content:e??""}const Dc=es({content:Et(),exists:io(),path:Et().min(1).optional()}),h1=async(t,e)=>{const n=await t.json().catch(()=>null);return typeof n?.error=="string"&&n.error.trim()?n.error:e},b1=t=>t.length>0&&!t.endsWith(`
2
+ import{R as m,j as s,f as Fe,r as Ue}from"./vendor-react--VO_rL_p.js";import{u as Ys,c as nl}from"./vendor-zustand-C9tWdk0j.js";import{u as Re,I as ee,dl as Os,lJ as it,aK as bn,am as hp,ae as Qt,B as q,z as Gn,A as Q,lK as Qr,aG as ze,x as qa,n as js,bh as ru,b0 as Xa,Y as Cn,aL as Ia,a1 as al,Q as Je,bm as bp,d0 as Do,d5 as xp,bq as Kt,bp as Ot,bs as xt,br as Ft,bo as Lt,y as Ye,lL as Jn,lM as cu,lN as vp,eS as Uo,lO as Yr,lP as yp,lQ as Ri,lR as ua,t as _t,q as $t,D as zt,l as Bt,F as Vt,o as ss,lS as xr,a4 as Pa,a5 as wa,bd as qi,be as Gi,a3 as Aa,a2 as Ta,bc as Ji,bb as Qi,jz as ia,jA as Kn,lT as cs,cX as us,lU as vr,go as Ht,V as pt,f8 as Tt,cM as _s,fa as ja,lV as Nn,fN as As,lW as as,ff as ws,lX as Ss,lY as du,lZ as kp,l_ as mt,l$ as uu,m0 as jp,m1 as wp,m2 as Ui,m3 as Sp,e1 as Yn,m4 as In,m5 as ii,jC as Js,m6 as ei,m7 as mu,m8 as yr,fb as kr,a9 as za,m9 as ql,ma as Zr,mb as Np,cP as il,mc as Xr,gs as Ha,jB as qt,R as jr,md as wr,me as Ka,mf as pu,mg as gu,mh as Sr,jD as qn,mi as Cp,ka as Yi,C as oi,aP as ec,cB as Ip,aZ as Pp,cI as Ap,ba as Tp,fg as Ep,ca as Mp,fh as Dp,K as fu,bB as di,fZ as zi,kA as hu,mj as Rp,mk as Op,cZ as Fp,ml as Lp,au as Zi,c$ as $n,mm as Xt,mn as bu,mo as Kp,mp as sa,gu as Qs,mq as ol,mr as Hn,ms as zo,mt as _p,mu as $p,mv as Up,mw as xu,mx as zp,my as vu,fO as yu,mz as ll,iE as bs,lD as Bo,ed as ku,ec as Bp,iC as Vp,iD as ju,lE as Hp,mA as Wp,iF as qp,mB as Gp,mC as Jp,mD as tc,cY as wu,mE as Qp,mF as Yp,mG as Zp,mH as Xp,mI as eg,mJ as Su,mK as tg,mL as sg,mM as ng,mN as ag,mO as ig,mP as og,mQ as li,mR as lg,mS as rg,mT as Nu,mU as cg,mV as Ts,gt as Wa,bO as cn,bP as rl,mW as dg,kb as Cu,gk as ug,gq as mg,h3 as pg,mX as gg,mY as fg,mZ as cl,k1 as Xi,m_ as eo,d3 as hg,d4 as yl,d2 as Iu,jo as Pu,m$ as kl,n0 as bg,n1 as xg,n2 as vg,n3 as yg,n4 as kg,n5 as jg,n6 as wg,n7 as Sg,bJ as qs,n8 as Nr,jE as Rn,bK as Cr,n9 as Mn,k9 as Ng,na as Cg,nb as Ig,nc as ri,e8 as Pg,nd as Vo,ne as va,nf as Ti,ng as Ag,nh as Tg,ni as Eg,nj as gn,nk as Gs,nl as Fa,nm as na,nn as sc,no as Ro,np as Mg,ak as Dg,nq as Au,nr as _a,ns as Rg,nt as Og,k as Ir,nu as Fg,dY as Lg,aE as Kg,aD as _g,cn as $g,d6 as Ug,az as zg,aC as Bg,nv as Vg,bn as Hg,ji as Wg,nw as Bi,nx as vi,ny as nc,nz as ta,nA as ka,nB as qg,nC as Gg,nD as Jg,nE as Qg,nF as jl,nG as ac,nH as Yg,nI as Zg,nJ as Xg,nK as ef,nL as tf,nM as ic,nN as yi,nO as oc,nP as Pr,nQ as sf,$ as nf,aU as lc,f7 as af,nR as of,nS as lf,nT as wl,nU as rc,nV as rf,f as oa,h as Ba,nW as cc,nX as cf,nY as df,nZ as uf,n_ as dl,n$ as mf,av as ca,o0 as pf,o1 as gf,o2 as ff,gf as hf,o3 as ul,jH as aa,o4 as bf,o5 as xf,o6 as Oi,aw as vf,ay as Tu,e2 as yf,aY as Ra,aa as kf,ab as jf,e3 as wf}from"./useAppFontEffects-DpDiWkkc.js";import{j as Wt,c6 as Eu,dh as Sf,di as Gl,dj as Nf,bG as hn,dk as Cf,z as It,u as ie,l as ms,dl as Vi,dm as Fi,dn as la,dp as Mu,dq as If,t as fn,dr as Pf,aJ as Ea,aG as Gt,cx as Ar,bQ as Af,bg as xs,aM as ui,bA as Sl,bD as dc,bB as uc,bJ as ki,cg as Tf,ds as Ef,cd as Mf,bK as ya,dt as Df,d2 as mc,bC as Rf,du as Of,dv as Ff,c7 as pc,bX as to,d6 as Lf,dw as Kf,dx as Du,dy as Rt,dz as _f,aI as so,bV as $f,bW as Uf,bR as Tr,b9 as Er,cm as zf,bP as Bf,aX as ml,cl as Va,dA as Ru,bU as Ho,bb as Ou,dB as Vf,dC as Fu,dD as Hf,dE as Wf,bI as Mr,dF as qf,v as Wo,bq as Gf,bh as Li,dG as Jf,dH as Ga,dI as gc,dJ as fc,dK as hc,dL as bc,dM as Qf,dN as xc,c4 as Yf,L as Lu,dO as no,dP as Zf,aK as vc,dQ as Xf,dR as eh,r as Jl,dS as th,dT as yc,dU as sh,b as nh,dV as ah,dW as ih,dX as oh,dY as lh,dZ as rh,bE as Ku,d_ as _u,d$ as ch,e0 as Ql,e1 as dh,e2 as uh,e3 as mh,e4 as ph,e5 as $u,e6 as gh,e7 as fh,e8 as hh,e9 as Yl,ea as kc,eb as bh,ec as jc,ed as bo,ee as xh,ef as vh,eg as yh,cq as kh,ck as jh,bY as wh,eh as Sh,ei as Nh,ej as Ch,ek as Ih}from"./katex.min-BBVkbKQY.js";import{aP as Ph,cy as Ah,cr as Nl,cs as Th,cz as Eh,cA as Mh,cB as ts,cC as Dh,cD as mi,cE as Rs,cF as qo,cG as da,cH as ci,cI as pl,cJ as ao,cK as Hi,Q as Sa,O as Na,P as Ca,at as $a,cL as Rh,c7 as Ws,cM as Oh,cN as Fh,au as Lh,cp as Kh,cO as _h,cP as $h,cQ as Uh,c6 as zh,cR as Bh,cS as La,bh as Zl,aa as Vh,ab as Hh,cT as Wh}from"./runtimeEndpointReset-BPYbd6uu.js";import{o as es,s as Et,e as io,l as qh,d as un,n as Wi,a as ra,f as Go,_ as gl,u as Xl}from"./vendor-zod-Csf1sqWl.js";import{n as Gh,M as Uu,r as Jh,b as Qh,a as wc,c as Yh,d as Zh,e as Xh,P as eb,f as tb,g as sb,h as nb,j as zu,u as Bu,i as Vu,s as Hu,k as ab,l as ib}from"./install-EEjacdUD.js";import{s as ob,c as lb}from"./vendor-yaml-CE-D_49-.js";import{c as Sc,C as Nc,p as rb}from"./flexokiTheme-Bv37aHkq.js";import{u as cb}from"./vendor-tanstack-react-virtual-C_IilPt1.js";import{m as db}from"./vendor-tanstack-virtual-core-DsQgKrou.js";import{c as ub}from"./codeHighlight-DD239VMc.js";import{getCodeTokenTheme as mb}from"./appThemeRegistry-D4EuLaGF.js";import{E as Cc}from"./vendor-codemirror-view-Ciie9ey-.js";import{Q as Wu}from"./vendor-qrcode-Cl8OheHW.js";import{toast as ti}from"./vendor-sonner-Dw26OnzC.js";import{s as pb}from"./vendor-strip-json-comments-5dJlOkP1.js";import{c as gb,h as fb,a as hb,b as bb,P as xb}from"./vendor-base-ui-zhBy6TEG.js";import{u as vb}from"./useCallableModelProviders-Y8rZzgJF.js";import{r as qu,s as yb}from"./pageTitle-BL2yQcTV.js";import{S as Dr,f as Jo}from"./SpaceRow-BkgNrW0R.js";import{_ as kb}from"./vendor-vite-runtime-DD1OZmLC.js";import{A as Ic}from"./AboutLogo-BP87552a.js";const Pc=({label:t})=>{const{t:e}=Re(),[n,a]=m.useState(null);m.useEffect(()=>{let l=!1;const r=typeof AbortController<"u"?new AbortController:void 0;return(async()=>{try{const d=await Wt("/api/system/info",{signal:r?.signal,headers:{Accept:"application/json"}});if(!d.ok)return;const c=await d.json().catch(()=>null);if(!c||l)return;const p=typeof c.port=="number"&&Number.isFinite(c.port)&&c.port>0?c.port:null,g=typeof c.tunnelUrl=="string"&&c.tunnelUrl.trim().length>0?c.tunnelUrl.trim():null;a({port:p,tunnelUrl:g})}catch{}})(),()=>{l=!0,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:()=>{Os(l.url)},children:[s.jsx("span",{className:"max-w-64 truncate font-mono",children:l.url}),s.jsx(ee,{name:"external-link",className:"size-3.5 shrink-0"})]},l.key))});return t?s.jsx(it,{label:t,controlClassName:"min-h-8",children:o}):o},Ac="https://github.com/openchamber/openchamber",Tc="https://discord.gg/ZYRSdnwwKA",Ec="https://x.com/openchamber_dev",jb=800,wb=async t=>{const e=await hn();return e?e.serverUpdateChannel??(Gl(t)?"canary":"stable"):null},Sb={info:null,checking:!1,available:!1,error:null};function Nb(t){const e=Fe.c(5),[n,a]=m.useState(Sb);let i;e[0]!==t?(i=async()=>{if(t){a(Cb);try{const r=await Th();a({info:r,checking:!1,available:r.available,error:null})}catch(r){const u=r;a({info:null,checking:!1,available:!1,error:u instanceof Error?u.message:String(u)})}}},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 Cb(t){return{...t,checking:!0,error:null}}function Ib(t){const e=Fe.c(11),[n,a]=m.useState(null);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={kind:"idle"},e[0]=i):i=e[0];const[o,l]=m.useState(i);let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=async()=>{try{const v=await Eh();return a(v),v}catch{return null}},e[1]=r):r=e[1];const u=r;let d,c;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{u()},c=[u],e[2]=d,e[3]=c):(d=e[2],c=e[3]),m.useEffect(d,c);let p;e[4]!==t?(p=async()=>{l({kind:"upgrading"});try{const v=await Mh(t);l({kind:"installed",version:v})}catch(v){const k=v;l({kind:"failed",error:k instanceof Error?k.message:t})}},e[4]=t,e[5]=p):p=e[5];const g=p;let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=async v=>{await v().catch(Pb);const k=await u();k?.currentVersion&&l(x=>x.kind!=="installed"||x.version&&x.version.replace(/^v/,"")!==k.currentVersion?x:{kind:"idle"})},e[6]=f):f=e[6];const h=f;let b;return e[7]!==o||e[8]!==n||e[9]!==g?(b={status:n,phase:o,refresh:u,upgrade:g,reloadAfterUpgrade:h},e[7]=o,e[8]=n,e[9]=g,e[10]=b):b=e[10],b}function Pb(){}function Ab(t){const[e,n]=m.useState(null);return m.useEffect(()=>{if(!t)return;let a=!1;return kb(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=!0}},[t]),e}const Tb=({initialUpdateDialogOpen:t=!1})=>{const{t:e}=Re(),[n,a]=m.useState(t),[i,o]=m.useState(!1),[l,r]=m.useState(null),u=Ph(Ys(me=>({info:me.info,checking:me.checking,available:me.available,error:me.error,downloading:me.downloading,downloaded:me.downloaded,installing:me.installing,progress:me.progress,runtimeType:me.runtimeType,checkForUpdates:me.checkForUpdates,downloadUpdate:me.downloadUpdate,restartToUpdate:me.restartToUpdate}))),{isMobile:d}=bn(),c=m.useMemo(()=>Eu(),[]),p=Ah(),g=Nb(c||p),f=p?g:null,h=g.check;m.useEffect(()=>{p&&h()},[p,h]);const[b,v]=m.useState(!1),[k,x]=m.useState(null);m.useEffect(()=>{if(!p)return;let me=!1;return hp().then(le=>{me||x(le)}),()=>{me=!0}},[p]);const w=Ab(c),y=c?{info:g.info,checking:g.checking,available:g.available,error:g.error,checkForUpdates:g.check,runtimeType:"web"}:{info:u.info,checking:u.checking,available:u.available,error:u.error,checkForUpdates:u.checkForUpdates,runtimeType:u.runtimeType},N=(me,le)=>{const te=Gl(me);return te?e("settings.openchamber.about.canaryVersion",{version:te.release,date:Nf(te,qa(),Gl(le))}):me},j=y.available?y.info?.version:null,A=N(l||y.info?.currentVersion||"unknown",j),C=N(k||u.info?.currentVersion||"unknown",j),P=l||f?.info?.currentVersion||"unknown",S=u.runtimeType==="desktop",[I,T]=m.useState(!1),O=u.runtimeType==="web"&&I&&l!==null,[M,K]=m.useState(null);m.useEffect(()=>{if(!S&&!O)return;let me=!1;return(S?Sf():wb(l??"")).then(te=>{me||K(te)}),()=>{me=!0}},[S,O,l]);const L=Ib(e("opencodeUpdate.toast.failed.description")),E=L.status?.currentVersion??null,D=L.phase.kind==="installed"?null:L.status?.availableVersion??null,[R,U]=m.useState(!1),$=me=>{const le=N(me?.version||"",me?.currentVersion);return me?.packageManager==="electron"?e("settings.openchamber.about.actions.updateDesktopToVersion",{version:le}):e("settings.openchamber.about.actions.updateServerToVersion",{version:le})},W=(()=>{const me=N(y.info?.version||"",y.info?.currentVersion);return c?$(y.info):p?e("settings.openchamber.about.actions.updateAppToVersion",{version:me}):e("settings.openchamber.about.actions.updateOpenChamberToVersion",{version:me})})(),z=me=>!!me?.installBlocked,_=y.available&&z(y.info),F=!!(f?.available&&z(f.info)),V=async me=>{if(me===M)return;const le=M;if(K(me),!(S?await Cf(me)===me:(await It({serverUpdateChannel:me})).ok)){K(le),Q.error(e("settings.openchamber.about.toast.updateChannelNotSaved"));return}y.checkForUpdates()},G=M&&s.jsx(Qt,{value:M,onChange:me=>{V(me)},"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)]"}]}),X=()=>{y.checkForUpdates(),f&&f.check(),L.refresh()},ae=async me=>{(await Xa(me)).ok&&(U(!0),setTimeout(()=>U(!1),2e3))},de=()=>{L.reloadAfterUpgrade(async()=>{await ru({message:e("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]})})},J=me=>{if(me?.installBlocked==="desktop-host")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:me.version||""})});if(me?.installBlocked==="manual-install")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.manualInstallUpdate",{version:N(me.version||"")})});const le=me?.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(me?.version||"")})}),s.jsxs("div",{className:"flex items-center gap-2 oc-tile-inset rounded-md p-1 ps-3",children:[s.jsx(js,{as:"code",outerClassName:"overlay-scrollbar-wrapper--no-gutter flex-1 min-w-0",fillContainer:!1,className:"whitespace-nowrap font-mono text-sm text-foreground",children:le}),s.jsx(q,{type:"button",variant:"ghost",size:"icon",onClick:()=>{ae(le)},"aria-label":e(R?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:s.jsx(ee,{name:R?"check":"clipboard",className:"size-4"})})]})]})},ue=_?J(y.info):null,be=!f?.available||f.checking?null:F?J(f.info):s.jsxs(q,{type:"button",size:"sm",variant:"outline",onClick:()=>v(!0),children:[s.jsx(ee,{name:"download",className:"size-4"}),$(f.info)]}),fe=f?s.jsx(Nl,{open:b,onOpenChange:v,info:f.info,downloading:!1,downloaded:!1,progress:null,error:f.error,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"}):null,he=(()=>{const{phase:me}=L;if(me.kind==="installed")return{action:s.jsx(q,{type:"button",size:"sm",variant:"outline",onClick:de,children:e("opencodeUpdate.toast.actions.reload")}),note:s.jsx("p",{className:"typography-meta text-muted-foreground",children:me.version?e("settings.openchamber.about.openCode.installedVersion",{version:me.version}):e("settings.openchamber.about.openCode.installed")})};if(!D)return null;if(!L.status?.supported)return{action:null,note:s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.openCode.manualUpdate",{version:D})})};const le=me.kind==="upgrading";return{action:s.jsxs(q,{type:"button",size:"sm",variant:"outline",onClick:()=>{L.upgrade()},disabled:le,children:[le?s.jsx(Gn,{className:"size-4"}):s.jsx(ee,{name:"download",className:"size-4"}),le?e("opencodeUpdate.toast.upgrading.title"):e("settings.openchamber.about.actions.updateOpenCodeToVersion",{version:D})]}),note:me.kind==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:me.error}):null}})(),ye=he?s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[he.note,he.action]}):null;m.useEffect(()=>{let me=!1;return(async()=>{try{const te=await Wt("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!te.ok)return;const Ne=await te.json().catch(()=>null),re=typeof Ne?.openchamberVersion=="string"&&Ne.openchamberVersion.trim().length>0?Ne.openchamberVersion.trim():null;me||(r(re),T(Ne?.runtime==="web"))}catch{me||r(null)}})(),()=>{me=!0}},[]);const Te=f?.checking??!1,oe=f?.available??!1,Y=m.useRef(!1);m.useEffect(()=>{if(y.checking)o(!0),Y.current=!0;else if(i){const me=setTimeout(()=>{o(!1);const le=Te||oe;Y.current&&!y.available&&!y.error&&!le&&(Q.success(e(c?"settings.openchamber.about.toast.serverLatestVersion":"settings.openchamber.about.toast.latestVersion")),Y.current=!1)},jb);return()=>clearTimeout(me)}},[e,c,y.checking,i,y.available,y.error,Te,oe]);const ve=y.checking||i;if(d)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(Ic,{size:72}),s.jsx("h2",{className:`mt-4 ${Qr}`,children:"OpenChamber"}),s.jsx("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:c?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:A})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:E||e("settings.openchamber.about.state.unknown")})}),w&&s.jsx("p",{children:e("settings.openchamber.about.native.appVersion",{version:w})})]}):p?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.appVersionLabel",{version:C})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:P})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:E||e("settings.openchamber.about.state.unknown")})})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:A})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:E||e("settings.openchamber.about.state.unknown")})})]})}),s.jsx(Pc,{})]}),G&&s.jsx("div",{className:"flex justify-center",children:G}),s.jsxs("div",{className:"flex justify-center",children:[!y.available&&!y.error&&s.jsxs(q,{type:"button",variant:"outline",size:"sm",onClick:X,disabled:ve,className:"w-auto justify-center gap-2",children:[ve?s.jsx(Gn,{className:"size-4"}):s.jsx(ee,{name:"refresh",className:"size-4"}),e(ve?"settings.openchamber.about.state.checking":c?"settings.openchamber.about.actions.checkServerForUpdates":"settings.openchamber.about.actions.checkForUpdates")]}),!ve&&y.available&&!_&&s.jsxs(q,{type:"button",variant:"default",size:"sm",onClick:()=>a(!0),className:"w-auto justify-center gap-2",children:[s.jsx(ee,{name:"download",className:"size-4"}),W]})]}),ue,be&&s.jsx("div",{className:"flex justify-center text-center",children:be}),ye&&s.jsx("div",{className:"flex justify-center text-center",children:ye}),[y.error,f?.error].filter(Boolean).map(me=>s.jsx("p",{className:"rounded-xl bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:me},me)),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:Ac,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(ee,{name:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:Tc,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(ee,{name:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:Ec,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(ee,{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")}),s.jsx(Nl,{open:n,onOpenChange:a,info:y.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:y.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:y.runtimeType}),fe]});const xe=s.jsx("span",{"aria-hidden":"true",className:"typography-meta text-muted-foreground/60",children:"·"}),Ce=ve?s.jsxs(s.Fragment,{children:[xe,s.jsxs("span",{className:"flex items-center gap-1.5 typography-meta text-muted-foreground",children:[s.jsx(Gn,{className:"size-4"}),e("settings.openchamber.about.state.checking")]})]}):y.available&&!_?s.jsxs(q,{size:"sm",variant:"default",onClick:()=>a(!0),children:[s.jsx(ee,{name:"download",className:"size-4"}),W]}):!y.available&&!y.error?s.jsxs(s.Fragment,{children:[xe,s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")})]}):null,Se=me=>s.jsx("span",{className:"typography-meta font-mono text-muted-foreground",children:me}),Me="min-h-8 flex-wrap @xl:flex-initial",pe=[ue,F?be:null,he?.note??null,...[y.error,f?.error].filter(Boolean).map(me=>s.jsx("p",{className:"rounded-lg bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:me},me))].filter(Boolean);return s.jsxs(s.Fragment,{children:[s.jsx(ze,{divider:!1,children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(Ic,{size:48}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("h2",{className:Qr,children:"OpenChamber"}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[{href:Ac,icon:"github-fill",label:"GitHub"},{href:Tc,icon:"discord-fill",label:"Discord"},{href:Ec,icon:"twitter-xfill",label:"@openchamber_dev"}].map(me=>s.jsxs("a",{href:me.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(ee,{name:me.icon,className:"size-4"}),s.jsx("span",{children:me.label})]},me.href))})]})]})}),s.jsxs(ze,{contentClassName:"space-y-4",children:[s.jsxs("div",{children:[p?s.jsxs(s.Fragment,{children:[s.jsxs(it,{label:e("settings.openchamber.about.field.appVersion"),controlClassName:Me,children:[Se(C),Ce]}),s.jsxs(it,{label:e("settings.openchamber.about.field.serverVersion"),controlClassName:Me,children:[Se(P),F?null:be]})]}):s.jsxs(it,{label:e("settings.openchamber.about.field.version"),controlClassName:Me,children:[Se(A),Ce]}),s.jsxs(it,{label:e("settings.openchamber.about.field.updateChannel"),info:G?e("settings.openchamber.about.field.updateChannelHint"):void 0,controlClassName:Me,children:[G,s.jsx(q,{size:"sm",variant:"outline",onClick:X,disabled:ve,children:e("settings.openchamber.about.actions.checkForUpdates")})]}),s.jsxs(it,{label:e("settings.openchamber.about.field.openCodeVersion"),controlClassName:Me,children:[Se(E||e("settings.openchamber.about.state.unknown")),he?.action]}),s.jsx(Pc,{label:e("settings.openchamber.about.field.instanceUrls")})]}),pe.length>0&&s.jsx("div",{className:"space-y-3",children:pe})]}),s.jsx(Nl,{open:n,onOpenChange:a,info:y.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:y.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:y.runtimeType}),fe]})},Eb=(t,e,n)=>t&&e.some(i=>i.path===t)?t:(e.find(i=>i.id===n)??e[0])?.path??null,xn=()=>{const t=Fe.c(4),e=ie(Mb),n=Cn(Db),a=Cn(Rb);let i;return t[0]!==a||t[1]!==n||t[2]!==e?(i=Eb(e,n,a),t[0]=a,t[1]=n,t[2]=e,t[3]=i):i=t[3],i};function Mb(t){return t.settingsProjectPath}function Db(t){return t.projects}function Rb(t){return t.activeProjectId}const er=nl(t=>({tab:"general",setTab:e=>t({tab:e})})),Ob=new Map([["projects.default-agent","general"],["projects.default-model","general"],["projects.default-thinking","general"],["projects.shared","general"],["projects.shared.plansDir","general"],["projects.actions","actions"],["projects.worktree","worktrees"],["projects.worktree.setup.wait","worktrees"],["projects.worktree.setup.replace","worktrees"],["projects.environment","environment"]]),Fb=t=>Ob.get(t)??null,tr=nl(t=>({tab:"messages",setTab:e=>t({tab:e})})),Lb=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.wide-layout","messages"],["chat.prompt-navigator","messages"],["chat.collapsible-user-messages","messages"],["chat.sticky-user-header","messages"],["chat.inline-assistant-actions","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.follow-up-behavior","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"]]),Kb=t=>Lb.get(t)??null,pi=t=>{const e=Fe.c(73),{className:n}=t,{t:a}=Re(),{currentTheme:i}=Ia(),o=ie(_b),[l,r]=m.useState(!1),u=al(Cn($b)),d=xn(),c=ie(Ub),p=ms();let g;e[0]!==d||e[1]!==u?(g=u.find(I=>I.path===d)??u[0]??null,e[0]=d,e[1]=u,e[2]=g):g=e[2];const f=g;if(p||!f)return null;let h;e[3]!==c||e[4]!==u?(h=I=>{const T=u.find(O=>O.id===I);T&&c(T.path)},e[3]=c,e[4]=u,e[5]=h):h=e[5];const b=h;if(o){let I;e[6]!==n?(I=Je(n),e[6]=n,e[7]=I):I=e[7];let T;e[8]!==a?(T=a("settings.shared.projectSelector.switchProjectAria"),e[8]=a,e[9]=T):T=e[9];let O;e[10]!==a?(O=a("settings.shared.projectSelector.switchProjectTitle"),e[10]=a,e[11]=O):O=e[11];let M,K;e[12]===Symbol.for("react.memo_cache_sentinel")?(M=()=>r(!0),K=Je(bp({size:"touch"}),"w-full min-w-0"),e[12]=M,e[13]=K):(M=e[12],K=e[13]);let L;e[14]!==f||e[15]!==i?(L=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:s.jsx(Do,{project:f,theme:i})}),e[14]=f,e[15]=i,e[16]=L):L=e[16];let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(ee,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[17]=E):E=e[17];let D;e[18]!==l||e[19]!==T||e[20]!==O||e[21]!==K||e[22]!==L?(D=s.jsxs("button",{type:"button","aria-label":T,title:O,"aria-haspopup":"dialog","aria-expanded":l,onClick:M,className:K,children:[L,E]}),e[18]=l,e[19]=T,e[20]=O,e[21]=K,e[22]=L,e[23]=D):D=e[23];let R;e[24]!==D||e[25]!==I?(R=s.jsx("div",{className:I,children:D}),e[24]=D,e[25]=I,e[26]=R):R=e[26];let U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=()=>r(!1),e[27]=U):U=e[27];const $=f.id;let W;e[28]!==a?(W=a("settings.shared.projectSelector.sheetTitle"),e[28]=a,e[29]=W):W=e[29];let z;e[30]!==a?(z=a("settings.shared.projectSelector.searchPlaceholder"),e[30]=a,e[31]=z):z=e[31];let _;e[32]!==f.id||e[33]!==i||e[34]!==b||e[35]!==l||e[36]!==u||e[37]!==W||e[38]!==z?(_=s.jsx(xp,{open:l,onClose:U,projects:u,selectedProjectId:$,onSelectProject:b,theme:i,title:W,searchPlaceholder:z}),e[32]=f.id,e[33]=i,e[34]=b,e[35]=l,e[36]=u,e[37]=W,e[38]=z,e[39]=_):_=e[39];let F;return e[40]!==R||e[41]!==_?(F=s.jsxs(s.Fragment,{children:[R,_]}),e[40]=R,e[41]=_,e[42]=F):F=e[42],F}let v;e[43]!==n?(v=Je(n),e[43]=n,e[44]=v):v=e[44];const k=f.id;let x;e[45]!==b?(x=I=>{I&&b(I)},e[45]=b,e[46]=x):x=e[46];let w;e[47]!==a?(w=a("settings.shared.projectSelector.switchProjectAria"),e[47]=a,e[48]=w):w=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(Kt,{children:s.jsx(Do,{project:f,theme:i})}),e[51]=f,e[52]=i,e[53]=N):N=e[53];let j;e[54]!==w||e[55]!==y||e[56]!==N?(j=s.jsx(Ot,{className:"w-full","aria-label":w,title:y,children:N}),e[54]=w,e[55]=y,e[56]=N,e[57]=j):j=e[57];let A;if(e[58]!==i||e[59]!==u){let I;e[61]!==i?(I=T=>s.jsx(xt,{value:T.id,className:"max-w-[24rem] truncate",children:s.jsx(Do,{project:T,theme:i})},T.id),e[61]=i,e[62]=I):I=e[62],A=u.map(I),e[58]=i,e[59]=u,e[60]=A}else A=e[60];let C;e[63]!==A?(C=s.jsx(Ft,{fitContent:!0,children:A}),e[63]=A,e[64]=C):C=e[64];let P;e[65]!==f.id||e[66]!==C||e[67]!==x||e[68]!==j?(P=s.jsxs(Lt,{value:k,onValueChange:x,children:[j,C]}),e[65]=f.id,e[66]=C,e[67]=x,e[68]=j,e[69]=P):P=e[69];let S;return e[70]!==P||e[71]!==v?(S=s.jsx("div",{className:v,children:P}),e[70]=P,e[71]=v,e[72]=S):S=e[72],S};function _b(t){return t.isMobile}function $b(t){return t.projects}function Ub(t){return t.setSettingsProjectPath}const Rr=t=>{const e=Fe.c(16),{value:n,onChange:a}=t,{t:i}=Re();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(ee,{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":!0}),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 u;e[6]!==i?(u=i("settings.common.sidebar.searchPlaceholder"),e[6]=i,e[7]=u):u=e[7];let d;e[8]!==i?(d=i("settings.common.sidebar.searchPlaceholder"),e[8]=i,e[9]=d):d=e[9];let c;return e[10]!==l||e[11]!==r||e[12]!==u||e[13]!==d||e[14]!==n?(c=s.jsxs("div",{className:"relative mt-3",children:[o,s.jsx(Ye,{value:n,onChange:l,onKeyDown:r,placeholder:u,"aria-label":d,className:"h-8 ps-7 typography-meta"})]}),e[10]=l,e[11]=r,e[12]=u,e[13]=d,e[14]=n,e[15]=c):c=e[15],c},Or=t=>{const e=Fe.c(5),{query:n}=t,{t:a}=Re();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 zb(t,e){return`opencode:sidebar-group:${t}:${e}`}const sr=t=>{const e=Fe.c(33),{label:n,count:a,storageKey:i,defaultExpanded:o,children:l}=t,r=o===void 0?!0:o;let u;e[0]!==n||e[1]!==i?(u=zb(i,n),e[0]=n,e[1]=i,e[2]=u):u=e[2];const d=u,c=m.useId();let p;e[3]!==r||e[4]!==d?(p=()=>{try{const I=localStorage.getItem(d);if(I!==null)return I==="true"}catch{}return r},e[3]=r,e[4]=d,e[5]=p):p=e[5];const[g,f]=Ue.useState(p);let h,b;e[6]!==g||e[7]!==d?(h=()=>{try{localStorage.setItem(d,String(g))}catch{}},b=[d,g],e[6]=g,e[7]=d,e[8]=h,e[9]=b):(h=e[8],b=e[9]),Ue.useEffect(h,b);let v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=()=>f(Bb),e[10]=v):v=e[10];let k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k=Je("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]=k):k=e[11];const x=!g&&"-rotate-90 rtl:rotate-90";let w;e[12]!==x?(w=Je("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",x),e[12]=x,e[13]=w):w=e[13];let y;e[14]!==w?(y=s.jsx(ee,{name:"arrow-down-s",className:w}),e[14]=w,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 j;e[18]!==a?(j=s.jsx("span",{className:"ms-1 tabular-nums opacity-60",children:a}),e[18]=a,e[19]=j):j=e[19];let A;e[20]!==c||e[21]!==g||e[22]!==y||e[23]!==N||e[24]!==j?(A=s.jsxs("button",{type:"button",onClick:v,"aria-expanded":g,"aria-controls":c,className:k,children:[y,N,j]}),e[20]=c,e[21]=g,e[22]=y,e[23]=N,e[24]=j,e[25]=A):A=e[25];const C=!g;let P;e[26]!==l||e[27]!==c||e[28]!==C?(P=s.jsx("div",{id:c,hidden:C,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]=c,e[28]=C,e[29]=P):P=e[29];let S;return e[30]!==A||e[31]!==P?(S=s.jsxs("div",{children:[A,P]}),e[30]=A,e[31]=P,e[32]=S):S=e[32],S};function Bb(t){return!t}const Vb=({onItemSelect:t})=>{const{t:e}=Re(),[n,a]=m.useState(""),[i,o]=m.useState(null),[l,r]=m.useState(""),[u,d]=m.useState(null),[c,p]=m.useState(!1),[g,f]=m.useState(null),{selectedAgentName:h,setSelectedAgent:b,setAgentDraft:v,createAgent:k,deleteAgent:x,loadAgents:w,loadDisabledAgents:y,updateAgent:N,fetchAgentEntity:j}=Jn(Ys(J=>({selectedAgentName:J.selectedAgentName,setSelectedAgent:J.setSelectedAgent,setAgentDraft:J.setAgentDraft,createAgent:J.createAgent,deleteAgent:J.deleteAgent,loadAgents:J.loadAgents,loadDisabledAgents:J.loadDisabledAgents,updateAgent:J.updateAgent,fetchAgentEntity:J.fetchAgentEntity}))),A=xn(),C=Jn(J=>cu(J,A)),P=Jn(J=>vp(J,A)),[S,I]=m.useState(null);m.useEffect(()=>{w(A),y(A)},[w,y,A]);const T=C.filter(J=>Uo(J.mode)&&!Yr(J)).length,O=J=>!(Uo(J.mode)&&!Yr(J)&&T<=1),M=async(J,ue)=>{I(J);try{await N(J,{disabled:ue},A),ue&&h===J&&b(null),Q.success(ue?e("settings.agents.sidebar.toast.agentDisabled",{name:J}):e("settings.agents.sidebar.toast.agentEnabled",{name:J}))}catch{Q.error(e(ue?"settings.agents.sidebar.toast.disableFailed":"settings.agents.sidebar.toast.enableFailed"))}finally{I(null)}},K=P.filter(J=>Vi([J.name,J.description],n)),L="bg-background",E=()=>{const J="new-agent";let ue=J,be=1;for(;C.some(fe=>fe.name===ue);)ue=`${J}-${be}`,be++;v({name:ue,scope:"user"}),b(ue),t?.()},D=async J=>{if(Ri(J)){Q.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}d(J)},R=()=>{d(null)},U=async()=>{if(u){p(!0);try{(await x(u.name,u.scope,A)).ok?(Q.success(e("settings.agents.sidebar.toast.agentDeleted",{name:u.name})),R()):Q.error(e("settings.agents.sidebar.toast.deleteFailed"))}catch(J){const ue=J instanceof Error?J.message:"",be=/built-in|not deletable|not found/i.test(ue);Q.error(e(be?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed"))}p(!1)}},$=async J=>{const ue=J.name;let be=1,fe=`${ue}-copy`;for(;C.some(oe=>oe.name===fe);)be++,fe=`${ue}-copy-${be}`;const he=J,ye=await j(J.name,A);if(!ye){Q.error(e("settings.agents.sidebar.toast.renameFailed"));return}const Te=ye.config.request?.body;v({name:fe,scope:ye.scope??he.scope??"user",description:ye.config.description??void 0,model:ye.config.model??null,system:ye.config.system??void 0,steps:ye.config.steps??void 0,temperature:Te?.temperature,top_p:Te?.top_p,mode:ye.config.mode??he.mode,permissions:ye.config.permissions??void 0,hidden:ye.config.hidden}),b(fe),t?.()},W=J=>{r(J.name),o(J)},z=async()=>{if(!i)return;const J=l.trim().replace(/\s+/g,"-");if(!J){Q.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(J===i.name){o(null);return}if(C.some(he=>he.name===J)){Q.error(e("settings.agents.sidebar.toast.agentExists"));return}const ue=i,be=await j(i.name,A);if(!be){Q.error(e("settings.agents.sidebar.toast.renameFailed"));return}(await k({...be.config,name:J,scope:be.scope??ue.scope},A)).ok?(await x(i.name,ue.scope,A)).ok?(Q.success(e("settings.agents.sidebar.toast.agentRenamed",{name:J})),b(J)):Q.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed")):Q.error(e("settings.agents.sidebar.toast.renameFailed")),o(null)},_=J=>{switch(J){case"primary":return s.jsx(ee,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return s.jsx(ee,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return s.jsx(ee,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},F=new Set(P.map(J=>J.name)),V=C.filter(J=>yp(J)&&!F.has(J.name)),H=V.filter(J=>Vi([J.name,J.description],n)),G=H.filter(Ri),X=H.filter(J=>!Ri(J)),{groupedCustomAgents:ae,ungroupedCustomAgents:de}=Ue.useMemo(()=>{const J={},ue=[];for(const fe of X){const he=fe;he.group?(J[he.group]||(J[he.group]=[]),J[he.group].push(fe)):ue.push(fe)}return{groupedCustomAgents:Object.keys(J).sort((fe,he)=>fe.localeCompare(he)).map(fe=>({name:fe,agents:J[fe]})),ungroupedCustomAgents:ue}},[X]);return s.jsxs("div",{className:Je("flex h-full flex-col",L),children:[s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[s.jsx("h2",{className:`${ua} mb-3`,children:e("settings.agents.sidebar.title")}),s.jsx(pi,{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:V.length})}),s.jsx(q,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:E,children:s.jsx(ee,{name:"add",className:"h-3.5 w-3.5"})})]}),V.length>0?s.jsx(Rr,{value:n,onChange:a}):null]}),s.jsxs(js,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:[V.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(ee,{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")})]}):H.length===0?s.jsx(Or,{query:n}):s.jsxs(s.Fragment,{children:[G.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")}),G.map(J=>s.jsx(Cl,{agent:J,isSelected:h===J.name,onSelect:()=>{b(J.name),t?.()},onDuplicate:()=>{$(J)},onDisable:O(J)?()=>{M(J.name,!0)}:void 0,getAgentModeIcon:_,isMenuOpen:g===J.name,onMenuOpenChange:ue=>f(ue?J.name:null)},J.name))]}),X.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")}),ae.map(({name:J,agents:ue})=>s.jsx(sr,{label:J,count:ue.length,storageKey:"agents",children:ue.map(be=>s.jsx(Cl,{agent:be,isSelected:h===be.name,onSelect:()=>{b(be.name),t?.()},onRename:()=>W(be),onDelete:()=>D(be),onDuplicate:()=>{$(be)},onDisable:O(be)?()=>{M(be.name,!0)}:void 0,getAgentModeIcon:_,isMenuOpen:g===be.name,onMenuOpenChange:fe=>f(fe?be.name:null)},be.name))},J)),de.map(J=>s.jsx(Cl,{agent:J,isSelected:h===J.name,onSelect:()=>{b(J.name),t?.()},onRename:()=>W(J),onDelete:()=>D(J),onDuplicate:()=>{$(J)},onDisable:O(J)?()=>{M(J.name,!0)}:void 0,getAgentModeIcon:_,isMenuOpen:g===J.name,onMenuOpenChange:ue=>f(ue?J.name:null)},J.name))]})]}),K.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")}),K.map(J=>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:J.name}),J.description?s.jsx("div",{className:"typography-micro truncate leading-tight text-muted-foreground",children:J.description}):null]}),s.jsx(q,{size:"xs",variant:"outline",disabled:S===J.name,onClick:()=>{M(J.name,!1)},"aria-label":e("settings.agents.sidebar.actions.enableAria",{name:J.name}),children:e("settings.agents.sidebar.actions.enable")})]},J.name))]})]}),s.jsx(_t,{open:u!==null,onOpenChange:J=>{!J&&!c&&R()},children:s.jsxs($t,{className:"max-w-md",children:[s.jsxs(zt,{children:[s.jsx(Bt,{children:e("settings.agents.sidebar.dialog.deleteTitle")}),s.jsx(Vt,{children:e("settings.agents.sidebar.dialog.deleteDescription",{name:u?.name??""})})]}),s.jsxs(ss,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:R,disabled:c,children:e("settings.common.actions.cancel")}),s.jsx(q,{size:"sm",onClick:U,disabled:c,children:e("settings.common.actions.delete")})]})]})}),s.jsx(_t,{open:i!==null,onOpenChange:J=>!J&&o(null),children:s.jsxs($t,{children:[s.jsxs(zt,{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(Ye,{value:l,onChange:J=>r(J.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:J=>{J.key==="Enter"&&z()}}),s.jsxs(ss,{children:[s.jsx(q,{size:"sm",variant:"ghost",onClick:()=>o(null),children:e("settings.common.actions.cancel")}),s.jsx(q,{size:"sm",onClick:z,children:e("settings.common.actions.rename")})]})]})})]})},Cl=t=>{const e=Fe.c(52),{agent:n,isSelected:a,onSelect:i,onDelete:o,onRename:l,onDuplicate:r,onDisable:u,getAgentModeIcon:d,isMenuOpen:c,onMenuOpenChange:p}=t,{t:g}=Re(),f=n;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=xr(),e[0]=h):h=e[0];const b=h,[v,k]=m.useState(!1);let x;e[1]!==o||e[2]!==u||e[3]!==r||e[4]!==l||e[5]!==g?(x=W=>s.jsxs(s.Fragment,{children:[l&&s.jsxs(W,{onClick:z=>{z.stopPropagation(),l()},children:[s.jsx(ee,{name:"edit",className:"h-4 w-4 me-px"}),g("settings.common.actions.rename")]}),s.jsxs(W,{onClick:z=>{z.stopPropagation(),r()},children:[s.jsx(ee,{name:"file-copy",className:"h-4 w-4 me-px"}),g("settings.common.actions.duplicate")]}),u&&s.jsxs(W,{onClick:z=>{z.stopPropagation(),u()},children:[s.jsx(ee,{name:"eye-off",className:"h-4 w-4 me-px"}),g("settings.agents.sidebar.actions.disable")]}),o&&s.jsxs(W,{onClick:z=>{z.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[s.jsx(ee,{name:"delete-bin",className:"h-4 w-4 me-px"}),g("settings.common.actions.delete")]})]}),e[1]=o,e[2]=u,e[3]=r,e[4]=l,e[5]=g,e[6]=x):x=e[6];const w=x,y=a?"bg-interactive-selection":"hover:bg-interactive-hover";let N;e[7]!==y?(N=Je("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 j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=b?void 0:W=>{W.preventDefault(),k(!0)},e[9]=j):j=e[9];let A;e[10]!==N?(A=s.jsx("div",{className:N,onContextMenu:j}),e[10]=N,e[11]=A):A=e[11];let C;e[12]!==n.name?(C=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:n.name}),e[12]=n.name,e[13]=C):C=e[13];let P;e[14]!==n.mode||e[15]!==d?(P=d(n.mode),e[14]=n.mode,e[15]=d,e[16]=P):P=e[16];let S;e[17]!==n||e[18]!==f.scope||e[19]!==g?(S=(f.scope||Ri(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:Ri(n)?g("settings.agents.sidebar.badge.system"):f.scope}),e[17]=n,e[18]=f.scope,e[19]=g,e[20]=S):S=e[20];let I;e[21]!==C||e[22]!==P||e[23]!==S?(I=s.jsxs("div",{className:"flex items-center gap-1.5",children:[C,P,S]}),e[21]=C,e[22]=P,e[23]=S,e[24]=I):I=e[24];let T;e[25]!==n.description?(T=n.description&&s.jsx("div",{className:"typography-micro text-muted-foreground truncate leading-tight",children:n.description}),e[25]=n.description,e[26]=T):T=e[26];let O;e[27]!==i||e[28]!==I||e[29]!==T?(O=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:[I,T]}),e[27]=i,e[28]=I,e[29]=T,e[30]=O):O=e[30];let M;e[31]!==p?(M=W=>{W&&k(!1),p(W)},e[31]=p,e[32]=M):M=e[32];let K;e[33]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(Aa,{asChild:!0,children:s.jsx(q,{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",children:s.jsx(ee,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=K):K=e[33];let L;e[34]!==w?(L=s.jsx(Pa,{align:"end",className:"w-fit min-w-20",children:w(wa)}),e[34]=w,e[35]=L):L=e[35];let E;e[36]!==c||e[37]!==M||e[38]!==L?(E=s.jsxs(Ta,{open:c,onOpenChange:M,children:[K,L]}),e[36]=c,e[37]=M,e[38]=L,e[39]=E):E=e[39];let D;e[40]!==O||e[41]!==E?(D=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[O,E]}),e[40]=O,e[41]=E,e[42]=D):D=e[42];let R;e[43]!==D||e[44]!==A?(R=s.jsx(Ji,{render:A,children:D}),e[43]=D,e[44]=A,e[45]=R):R=e[45];let U;e[46]!==w?(U=s.jsx(qi,{className:"w-fit min-w-20",children:w(Gi)}),e[46]=w,e[47]=U):U=e[47];let $;return e[48]!==v||e[49]!==R||e[50]!==U?($=s.jsxs(Qi,{open:v,onOpenChange:k,children:[R,U]}),e[48]=v,e[49]=R,e[50]=U,e[51]=$):$=e[51],$},dn={ok:!0,changed:!1},Qn={ok:!0,changed:!0},Ps=t=>({ok:!1,reason:t}),Hb=t=>t instanceof HTMLElement?t.matches('input, textarea, [contenteditable="true"]'):!1,gi=t=>{const{t:e}=Re(),[n,a]=m.useState(0),i=m.useRef(t);i.current=t;const o=m.useRef(e);o.current=e;const l=m.useRef(!1),r=m.useRef(!1),u=m.useRef(!1),d=m.useCallback(()=>{a(g=>g+1)},[]),c=m.useCallback(g=>{Hb(g.target)&&d()},[d]),p=m.useCallback(async()=>{l.current=!0;try{for(;;){r.current=!1;let g;try{g=await i.current()}catch(f){g={ok:!1,reason:f instanceof Error?f.message:String(f)}}if(!u.current)return;if(!r.current){g.ok||Q.error(o.current("settings.common.status.saveFailedReason",{reason:g.reason}));return}}}finally{l.current=!1}},[]);return m.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]),m.useEffect(()=>{if(n!==0){if(l.current){r.current=!0;return}p()}},[n,p]),{requestSave:d,onBlurCapture:c}},Wb=["allow","ask","deny"],qb=["shell","edit","read","glob","grep","patch","webfetch","websearch","skill","subagent","question","external_directory"],Gb=["openchamber","openchamber_schedule","openchamber_web","openchamber_memory","openchamber_knowledge","openchamber_notify","openchamber_render","openchamber_image","openchamber_secret"],Jb=new Set(["bash","task","write","list","lsp","todowrite","todoread","multiedit","doom_loop","plan_enter","plan_exit"]),Gu=t=>Jb.has(t),Qb=[{action:"*",resource:"*",effect:"allow"},{action:"read",resource:"*.env",effect:"ask"},{action:"read",resource:"*.env.*",effect:"ask"},{action:"read",resource:"*.env.example",effect:"allow"}],Mc=()=>({global:null,keys:{},source:[]}),Oa=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}))}]))}),Yb=t=>{const e={global:null,keys:{},source:t.map(n=>({...n}))};for(const n of t){if(Gu(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},Zb=t=>t.action!=="*"||t.resource==="*",Ua=(t,e)=>`${t}\0${e}`,Xb=t=>{const e=new Map;t.global!==null&&e.set(Ua("*","*"),t.global);for(const[n,a]of Object.entries(t.keys)){a.effect!==null&&e.set(Ua(n,"*"),a.effect);for(const i of a.patterns){const o=i.pattern.trim();o.length!==0&&e.set(Ua(n,o),i.effect)}}return e},nr=t=>{const e=Xb(t),n=new Set,a=[];for(const o of t.source){if(Gu(o.action))continue;if(!Zb(o)){a.push({...o});continue}const l=Ua(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=Ua("*","*");t.global!==null&&!n.has(i)&&a.unshift({action:"*",resource:"*",effect:t.global});for(const[o,l]of Object.entries(t.keys)){const r=Ua(o,"*");if(l.effect!==null&&!n.has(r)){const u=a.findIndex(c=>c.action===o),d={action:o,resource:"*",effect:l.effect};u>=0?a.splice(u,0,d):a.push(d)}for(const u of l.patterns){const d=u.pattern.trim();if(d.length===0)continue;const c=Ua(o,d),p=e.get(c);p===void 0||n.has(c)||(n.add(c),a.push({action:o,resource:d,effect:p}))}}return a},e1=(t,e)=>JSON.stringify(nr(t))===JSON.stringify(nr(e)),t1=(t,e)=>{const n=[...Qb,...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},s1=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),n1=new Set(["shell","edit","read","glob","grep","patch","webfetch","skill","subagent","external_directory"]),a1={effect:null,patterns:[]},i1=t=>{const e=Fe.c(163),{agent:n,registerSave:a,requestSave:i}=t,{t:o}=Re(),l=Jn(o1),r=Jn(l1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],e[0]=u):u=e[0];const[d,c]=m.useState(u),[p,g]=m.useState(Mc),[f,h]=m.useState(Mc),[b,v]=m.useState(!0),[k,x]=m.useState(!1);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w={},e[1]=w):w=e[1];const[y,N]=m.useState(w),[j,A]=m.useState(""),[C,P]=m.useState(0),S=n.name,I=xn(),T=ia(r1);let O;e[2]!==I?(O=qe=>vr(qe,I),e[2]=I,e[3]=O):O=e[3];const M=ia(O);let K;e[4]!==I?(K=qe=>qe.getStatusForDirectory(I),e[4]=I,e[5]=K):K=e[5];const L=Kn(K);let E,D;e[6]!==T||e[7]!==I?(E=()=>{T({directory:I})},D=[T,I],e[6]=T,e[7]=I,e[8]=E,e[9]=D):(E=e[8],D=e[9]),m.useEffect(E,D);let R;e[10]!==S||e[11]!==r||e[12]!==I?(R=()=>{let qe=!1;return v(!0),x(!1),(async()=>{const gt=await r(S,I);if(qe)return;if(!gt){x(!0),v(!1);return}const lt=Yb(gt.agent);c(gt.global),g(Oa(lt)),h(lt),N({}),v(!1)})(),()=>{qe=!0}},e[10]=S,e[11]=r,e[12]=I,e[13]=R):R=e[13];let U;e[14]!==S||e[15]!==r||e[16]!==C||e[17]!==I?(U=[S,r,C,I],e[14]=S,e[15]=r,e[16]=C,e[17]=I,e[18]=U):U=e[18],m.useEffect(R,U);let $;e[19]!==S||e[20]!==p||e[21]!==f||e[22]!==I||e[23]!==o||e[24]!==l?($=async()=>e1(f,p)?dn:(await l(S,{permissions:nr(f)},I)).ok?(g(Oa(f)),Qn):Ps(o("settings.agents.page.permissionsEditor.toast.saveFailed")),e[19]=S,e[20]=p,e[21]=f,e[22]=I,e[23]=o,e[24]=l,e[25]=$):$=e[25];const W=$;let z,_;e[26]!==a||e[27]!==W?(z=()=>(a(W),()=>a(null)),_=[a,W],e[26]=a,e[27]=W,e[28]=z,e[29]=_):(z=e[28],_=e[29]),m.useEffect(z,_);let F;e[30]!==M?(F=M.map(c1),e[30]=M,e[31]=F):F=e[31];const V=F;let H;if(e[32]!==V||e[33]!==f.keys){H=[...qb,...Gb];const qe=new Set(V.map(d1));let gt;e[35]!==f.keys?(gt=Object.keys(f.keys),e[35]=f.keys,e[36]=gt):gt=e[36];for(const lt of gt)!H.includes(lt)&&!qe.has(lt)&&H.push(lt);e[32]=V,e[33]=f.keys,e[34]=H}else H=e[34];const G=H;let X;e[37]!==L||e[38]!==o?(X=qe=>{switch(L?.[qe]?.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]=L,e[38]=o,e[39]=X):X=e[39];const ae=X;let de;e[40]!==d||e[41]!==f.global?(de=qe=>t1(qe,{global:d,agentGlobal:f.global}),e[40]=d,e[41]=f.global,e[42]=de):de=e[42];const J=de;let ue;e[43]!==i?(ue=qe=>{h(gt=>({...gt,global:qe})),i()},e[43]=i,e[44]=ue):ue=e[44];const be=ue;let fe;e[45]!==i?(fe=(qe,gt)=>{h(lt=>{const we=Oa(lt),Qe=we.keys[qe]??{effect:null,patterns:[]};return Qe.effect=gt,Qe.effect===null&&Qe.patterns.length===0?delete we.keys[qe]:we.keys[qe]=Qe,we}),i()},e[45]=i,e[46]=fe):fe=e[46];const he=fe;let ye;e[47]!==i?(ye=(qe,gt,lt,we,Qe)=>{h(tt=>{const ht=Oa(tt),at=ht.keys[qe]??{effect:null,patterns:[]};return at.patterns[gt]={pattern:lt,effect:we},ht.keys[qe]=at,ht}),Qe&&i()},e[47]=i,e[48]=ye):ye=e[48];const Te=ye;let oe;e[49]===Symbol.for("react.memo_cache_sentinel")?(oe=qe=>{h(gt=>{const lt=Oa(gt),we=lt.keys[qe]??{effect:null,patterns:[]};return we.patterns.push({pattern:"",effect:"allow"}),lt.keys[qe]=we,lt}),N(gt=>({...gt,[qe]:!0}))},e[49]=oe):oe=e[49];const Y=oe;let ve;e[50]!==i?(ve=(qe,gt)=>{h(lt=>{const we=Oa(lt),Qe=we.keys[qe];return Qe?(Qe.patterns.splice(gt,1),Qe.effect===null&&Qe.patterns.length===0&&delete we.keys[qe],we):lt}),i()},e[50]=i,e[51]=ve):ve=e[51];const xe=ve;let Ce;e[52]!==j||e[53]!==i?(Ce=()=>{const qe=j.trim();!qe||qe==="*"||(h(gt=>{if(gt.keys[qe])return gt;const lt=Oa(gt);return lt.keys[qe]={effect:"ask",patterns:[]},lt}),A(""),i())},e[52]=j,e[53]=i,e[54]=Ce):Ce=e[54];const Se=Ce;let Me;e[55]!==o?(Me=qe=>o(qe==="allow"?"settings.agents.page.permissionsEditor.action.allow":qe==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),e[55]=o,e[56]=Me):Me=e[56];const pe=Me;let me,le,te,Ne,re,ge,Oe,Ke,Le;if(e[57]!==pe||e[58]!==J||e[59]!==y||e[60]!==b||e[61]!==k||e[62]!==V||e[63]!==ae||e[64]!==f.global||e[65]!==f.keys||e[66]!==xe||e[67]!==be||e[68]!==he||e[69]!==Te||e[70]!==o||e[71]!==G){Le=Symbol.for("react.early_return_sentinel");e:{const qe=o("settings.agents.page.permissionsEditor.action.inherit"),gt=o("settings.agents.page.permissionsEditor.action.default");let lt;e[81]!==pe?(lt=Ge=>[...Ge?[{value:"inherit",label:Ge}]:[],...Wb.map(ct=>({value:ct,label:pe(ct)}))],e[81]=pe,e[82]=lt):lt=e[82];const we=lt,Qe=(Ge,ct,Ct,jt)=>{const Nt=jt===void 0?qe:jt;return s.jsx(Qt,{value:Ge??"inherit",options:we(Nt),onChange:ke=>ct(ke==="inherit"?null:ke),"aria-label":Ct})};if(b){let Ge;e[83]!==o?(Ge=o("settings.agents.page.section.toolPermissions"),e[83]=o,e[84]=Ge):Ge=e[84];let ct;e[85]!==o?(ct=o("common.loading"),e[85]=o,e[86]=ct):ct=e[86];let Ct;e[87]!==ct?(Ct=s.jsx("p",{className:Ht,children:ct}),e[87]=ct,e[88]=Ct):Ct=e[88];let jt;e[89]!==Ge||e[90]!==Ct?(jt=s.jsx(ze,{title:Ge,children:Ct}),e[89]=Ge,e[90]=Ct,e[91]=jt):jt=e[91],Le=jt;break e}if(k){let Ge;e[92]!==o?(Ge=o("settings.agents.page.section.toolPermissions"),e[92]=o,e[93]=Ge):Ge=e[93];let ct;e[94]!==o?(ct=o("settings.agents.page.permissionsEditor.state.loadFailed"),e[94]=o,e[95]=ct):ct=e[95];let Ct;e[96]!==ct?(Ct=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:ct}),e[96]=ct,e[97]=Ct):Ct=e[97];let jt;e[98]===Symbol.for("react.memo_cache_sentinel")?(jt=()=>P(u1),e[98]=jt):jt=e[98];let Nt;e[99]!==o?(Nt=o("settings.agents.page.permissionsEditor.actions.retry"),e[99]=o,e[100]=Nt):Nt=e[100];let ke;e[101]!==Nt?(ke=s.jsx(q,{variant:"outline",size:"xs",onClick:jt,children:Nt}),e[101]=Nt,e[102]=ke):ke=e[102];let Ee;e[103]!==Ct||e[104]!==ke?(Ee=s.jsxs("div",{className:"flex items-center gap-3",children:[Ct,ke]}),e[103]=Ct,e[104]=ke,e[105]=Ee):Ee=e[105];let We;e[106]!==Ge||e[107]!==Ee?(We=s.jsx(ze,{title:Ge,children:Ee}),e[106]=Ge,e[107]=Ee,e[108]=We):We=e[108],Le=We;break e}const tt=(Ge,ct,Ct)=>{const jt=f.keys[Ge]??a1,Nt=n1.has(Ge)||jt.patterns.length>0,ke=y[Ge]===!0;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:Nt?()=>N(Ee=>({...Ee,[Ge]:!ke})):void 0,className:Je("flex min-w-0 items-center gap-1.5 text-start",!Nt&&"cursor-default"),"aria-expanded":Nt?ke:void 0,children:[s.jsx(ee,{name:ke&&Nt?"arrow-down-s":"arrow-right-s",className:Je("h-3.5 w-3.5 shrink-0 text-muted-foreground",!Nt&&"opacity-0")}),s.jsx("span",{className:cs,children:ct}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground",children:Ge}),Ct&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:Ct}),jt.effect===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:pe(J(Ge))})}),jt.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(jt.patterns.length)})})]}),Qe(jt.effect,Ee=>he(Ge,Ee),o("settings.agents.page.permissionsEditor.keyAria",{key:Ge}))]}),ke&&Nt&&s.jsxs("div",{className:"mt-2 space-y-2 ps-5",children:[jt.patterns.map((Ee,We)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Ye,{value:Ee.pattern,onChange:vt=>Te(Ge,We,vt.target.value,Ee.effect,!1),placeholder:o("settings.agents.page.permissionsEditor.patternPlaceholder"),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:Ge}),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(Qt,{value:Ee.effect,options:we(),onChange:vt=>Te(Ge,We,Ee.pattern,vt,!0),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:Ge})}),s.jsx(q,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>xe(Ge,We),"aria-label":o("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx(ee,{name:"close",className:"h-3.5 w-3.5"})})]},We)),s.jsxs(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Y(Ge),children:[s.jsx(ee,{name:"add",className:"me-1 h-3.5 w-3.5"}),o("settings.agents.page.permissionsEditor.actions.addRule")]})]})]},Ge)};me=ze,e[109]!==o?(le=o("settings.agents.page.section.toolPermissions"),e[109]=o,e[110]=le):le=e[110],te="agents.permissions",e[111]!==o?(Ne=o("settings.agents.page.permissionsEditor.sectionInfo"),e[111]=o,e[112]=Ne):Ne=e[112],re="space-y-4";let ht;e[113]!==o?(ht=o("settings.agents.page.permissionsEditor.defaultLabel"),e[113]=o,e[114]=ht):ht=e[114];let at;e[115]!==ht?(at=s.jsx("span",{className:cs,children:ht}),e[115]=ht,e[116]=at):at=e[116];let kt;e[117]!==o?(kt=o("settings.agents.page.permissionsEditor.defaultInfo"),e[117]=o,e[118]=kt):kt=e[118];let se;e[119]!==kt?(se=s.jsx(us,{children:kt}),e[119]=kt,e[120]=se):se=e[120];let Z;e[121]!==pe||e[122]!==J||e[123]!==f.global||e[124]!==o?(Z=f.global===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:pe(J("*"))})}),e[121]=pe,e[122]=J,e[123]=f.global,e[124]=o,e[125]=Z):Z=e[125];let nt;e[126]!==at||e[127]!==se||e[128]!==Z?(nt=s.jsxs("div",{className:"flex items-center gap-1.5",children:[at,se,Z]}),e[126]=at,e[127]=se,e[128]=Z,e[129]=nt):nt=e[129];const St=f.global;let He;e[130]!==o?(He=o("settings.agents.page.permissionsEditor.defaultAria"),e[130]=o,e[131]=He):He=e[131],ge=s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[nt,Qe(St,be,He,gt)]}),Oe=s.jsx("div",{children:G.map(Ge=>tt(Ge,s1(Ge),null))}),Ke=V.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:cs,children:o("settings.agents.page.permissionsEditor.mcpTitle")}),s.jsx(us,{children:o("settings.agents.page.permissionsEditor.mcpInfo")})]}),V.map(Ge=>tt(Ge.key,Ge.server,ae(Ge.server)))]})}e[57]=pe,e[58]=J,e[59]=y,e[60]=b,e[61]=k,e[62]=V,e[63]=ae,e[64]=f.global,e[65]=f.keys,e[66]=xe,e[67]=be,e[68]=he,e[69]=Te,e[70]=o,e[71]=G,e[72]=me,e[73]=le,e[74]=te,e[75]=Ne,e[76]=re,e[77]=ge,e[78]=Oe,e[79]=Ke,e[80]=Le}else me=e[72],le=e[73],te=e[74],Ne=e[75],re=e[76],ge=e[77],Oe=e[78],Ke=e[79],Le=e[80];if(Le!==Symbol.for("react.early_return_sentinel"))return Le;let ne;e[132]===Symbol.for("react.memo_cache_sentinel")?(ne=qe=>A(qe.target.value),e[132]=ne):ne=e[132];let Ie;e[133]!==Se?(Ie=qe=>{qe.key==="Enter"&&(qe.preventDefault(),Se())},e[133]=Se,e[134]=Ie):Ie=e[134];let Pe;e[135]!==o?(Pe=o("settings.agents.page.permissionsEditor.customKeyPlaceholder"),e[135]=o,e[136]=Pe):Pe=e[136];let De;e[137]!==j||e[138]!==Ie||e[139]!==Pe?(De=s.jsx(Ye,{value:j,onChange:ne,onKeyDown:Ie,placeholder:Pe,className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),e[137]=j,e[138]=Ie,e[139]=Pe,e[140]=De):De=e[140];let Be;e[141]!==j?(Be=j.trim(),e[141]=j,e[142]=Be):Be=e[142];const bt=!Be;let $e;e[143]===Symbol.for("react.memo_cache_sentinel")?($e=s.jsx(ee,{name:"add",className:"me-1 h-3.5 w-3.5"}),e[143]=$e):$e=e[143];let dt;e[144]!==o?(dt=o("settings.agents.page.permissionsEditor.actions.addKey"),e[144]=o,e[145]=dt):dt=e[145];let Ve;e[146]!==Se||e[147]!==bt||e[148]!==dt?(Ve=s.jsxs(q,{variant:"outline",size:"xs",className:"!font-normal",onClick:Se,disabled:bt,children:[$e,dt]}),e[146]=Se,e[147]=bt,e[148]=dt,e[149]=Ve):Ve=e[149];let st;e[150]!==De||e[151]!==Ve?(st=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-edge-muted pt-3",children:[De,Ve]}),e[150]=De,e[151]=Ve,e[152]=st):st=e[152];let ut;return e[153]!==me||e[154]!==le||e[155]!==te||e[156]!==Ne||e[157]!==re||e[158]!==ge||e[159]!==Oe||e[160]!==Ke||e[161]!==st?(ut=s.jsxs(me,{title:le,settingsItem:te,info:Ne,contentClassName:re,children:[ge,Oe,Ke,st]}),e[153]=me,e[154]=le,e[155]=te,e[156]=Ne,e[157]=re,e[158]=ge,e[159]=Oe,e[160]=Ke,e[161]=st,e[162]=ut):ut=e[162],ut};function o1(t){return t.updateAgent}function l1(t){return t.fetchAgentPermissions}function r1(t){return t.loadMcpConfigs}function c1(t){return{key:`${t.name}_*`,server:t.name}}function d1(t){return t.key}function u1(t){return t+1}const Fr=t=>{const e=Fe.c(11),{legacy:n,path:a,className:i}=t,{t:o}=Re();if(!n)return null;let l;e[0]!==i?(l=Je("mb-4 flex items-start gap-1.5",Ht,i),e[0]=i,e[1]=l):l=e[1];const r=a??void 0;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(ee,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 opacity-70"}),e[2]=u):u=e[2];let d;e[3]!==o?(d=o("settings.common.legacyFormat.note"),e[3]=o,e[4]=d):d=e[4];let c;e[5]!==d?(c=s.jsx("span",{children:d}),e[5]=d,e[6]=c):c=e[6];let p;return e[7]!==l||e[8]!==r||e[9]!==c?(p=s.jsxs("p",{className:l,title:r,children:[u,c]}),e[7]=l,e[8]=r,e[9]=c,e[10]=p):p=e[10],p},m1=(t,e)=>{const n=la(e);if(!n)return[];const a=t.find(o=>o.id===n.providerId),i=If(a?.models,n.modelId);return du(i)},p1=t=>kp(t)?.toLowerCase()??"",g1=()=>{const{t}=Re(),e=pt(pe=>pe.providers),{selectedAgentName:n,getAgentByName:a,createAgent:i,updateAgent:o,fetchAgentEntity:l,agentDraft:r,setAgentDraft:u,setSelectedAgent:d}=Jn(Ys(pe=>({selectedAgentName:pe.selectedAgentName,getAgentByName:pe.getAgentByName,createAgent:pe.createAgent,updateAgent:pe.updateAgent,fetchAgentEntity:pe.fetchAgentEntity,agentDraft:pe.agentDraft,setAgentDraft:pe.setAgentDraft,setSelectedAgent:pe.setSelectedAgent}))),c=xn(),p=Jn(pe=>cu(pe,c)),g=n?a(n,c):null,f=!!(r&&r.name===n&&!g),h=f?"":g?.description?.trim()??"",b=f?"":g?.system?.trim()??"",[v,k]=m.useState(""),[x,w]=m.useState("user"),[y,N]=m.useState(""),[j,A]=m.useState("subagent"),[C,P]=m.useState(""),[S,I]=m.useState(""),[T,O]=m.useState(void 0),[M,K]=m.useState(void 0),[L,E]=m.useState(void 0),[D,R]=m.useState(""),[U,$]=m.useState(""),[W,z]=m.useState(!1),[_,F]=m.useState(null),V=m.useRef({}),H=m.useRef(null),G=m.useCallback(pe=>{H.current=pe},[]),X=m.useRef(null),ae=JSON.stringify([n,c,f]),de=m.useRef(ae);de.current=ae;const J=m.useRef(null),ue={description:y,mode:j,model:C,variant:S,steps:T,temperature:M,topP:L,system:D,color:U},be=m.useRef(ue);be.current=ue;const fe=m.useMemo(()=>m1(e,C),[C,e]),he=fe.length>0,ye=S||"__default",Te=he,oe=m.useMemo(()=>S&&!fe.includes(S)?[S,...fe]:fe,[S,fe]);m.useEffect(()=>{if(!f||!r)return;J.current=null;const pe=Fi(r.model),me=r.name||"",le=r.scope||"user",te=r.description||"",Ne=r.mode||"subagent",re=pe?`${pe.providerID}/${pe.modelID}`:"",ge=pe?.variant||"",Oe=r.steps??void 0,Ke=r.temperature??void 0,Le=r.top_p??void 0,ne=r.system||"",Ie="";V.current={},F(null),k(me),w(le),N(te),A(Ne),P(re),I(ge),O(Oe),K(Ke),E(Le),R(ne),$(Ie),X.current={draftName:me,draftScope:le,description:te,mode:Ne,model:re,variant:ge,steps:Oe,temperature:Ke,topP:Le,system:ne,color:Ie}},[r,f]),m.useEffect(()=>{if(f||!n)return;let pe=!1;return(async()=>{const me=await l(n,c);if(pe||de.current!==ae||!me)return;const le=me.config;V.current=le;const te=Fi(le.model),Ne=le.request?.body,re={draftName:"",draftScope:"user",description:le.description||"",mode:le.mode||g?.mode||"subagent",model:te?`${te.providerID}/${te.modelID}`:"",variant:te?.variant||"",steps:le.steps??void 0,temperature:Ne?.temperature,topP:Ne?.top_p,system:le.system||"",color:p1(le.color)},ge=X.current,Oe=be.current,Ke=ge!==null&&(Oe.description!==ge.description||Oe.mode!==ge.mode||Oe.model!==ge.model||Oe.variant!==ge.variant||Oe.steps!==ge.steps||Oe.temperature!==ge.temperature||Oe.topP!==ge.topP||Oe.system!==ge.system||Oe.color!==ge.color);F({legacy:me.legacy===!0,path:me.path,source:me.source}),!(J.current===ae&&Ke)&&(J.current=ae,N(re.description),A(re.mode),P(re.model),I(re.variant),O(re.steps),K(re.temperature),E(re.topP),R(re.system),$(re.color),X.current=re)})(),()=>{pe=!0}},[l,f,g,n,c,ae]);const Y=m.useCallback(pe=>{const me=la(C.trim()),le=me?Mu({providerID:me.providerId,modelID:me.modelId,variant:S.trim()||void 0}):null,te=V.current.request,Ne={...te?.body};M===void 0?delete Ne.temperature:Ne.temperature=M,L===void 0?delete Ne.top_p:Ne.top_p=L;const re=te?.headers,ge={};re&&Object.keys(re).length>0&&(ge.headers=re),Object.keys(Ne).length>0&&(ge.body=Ne);const Oe=y.trim(),Ke=D.trim(),Le={name:pe,mode:j,model:le,steps:T??null,system:Ke||(f?void 0:null),request:Object.keys(ge).length>0?ge:null};return Oe&&(Le.description=Oe),U!==(X.current?.color??"")&&(Le.color=U||null),f&&x&&(Le.scope=x),f&&r?.hidden!==void 0&&(Le.hidden=r.hidden),f&&r?.permissions?.length&&(Le.permissions=r.permissions),Le},[r,U,y,x,f,j,C,T,D,M,L,S]),ve=m.useCallback(async()=>{const pe=X.current,me=n?.trim();if(f||!pe||!me)return dn;const le=H.current?await H.current():dn;if(y===pe.description&&j===pe.mode&&C===pe.model&&S===pe.variant&&T===pe.steps&&M===pe.temperature&&L===pe.topP&&D===pe.system&&U===pe.color||!le.ok)return le;const Ne=Y(me);return(await o(me,Ne,c)).ok?(de.current!==ae||(V.current={...V.current,model:Ne.model,system:Ne.system??void 0,steps:Ne.steps,request:Ne.request??void 0},X.current={...pe,description:y,mode:j,model:C,variant:S,steps:T,temperature:M,topP:L,system:D,color:U}),Qn):Ps(t("settings.agents.page.toast.updateFailed"))},[Y,U,y,f,j,C,n,ae,c,T,D,t,M,L,o,S]),xe=gi(ve),{requestSave:Ce}=xe,Se=async()=>{const pe=v.trim().replace(/\s+/g,"-");if(!pe){Q.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(p.some(me=>me.name===pe)){Q.error(t("settings.agents.sidebar.toast.agentExists"));return}z(!0);try{(await i(Y(pe),c)).ok?(u(null),Q.success(t("settings.agents.page.toast.created"))):Q.error(t("settings.agents.page.toast.createFailed"))}catch(me){console.error("Error creating agent:",me);const le=me instanceof Error&&me.message?me.message:t("settings.agents.page.toast.saveUnexpectedError");Q.error(le)}finally{z(!1)}},Me=()=>{u(null),d(null)};return n?s.jsxs(ts,{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&&_&&s.jsx(Fr,{legacy:_.legacy,path:_.path}),!f&&_?.source==="none"&&s.jsxs("p",{className:`mb-4 flex items-start gap-1.5 ${Ht}`,children:[s.jsx(ee,{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(ze,{title:t("settings.agents.page.section.identityRole"),divider:!1,contentClassName:"space-y-3",children:[f&&s.jsxs(it,{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(Ye,{value:v,onChange:pe=>k(pe.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Lt,{value:x,onValueChange:pe=>w(pe),children:[s.jsx(Ot,{className:"w-fit min-w-[100px]",children:s.jsx(Kt,{children:t(x==="project"?"settings.common.scope.project":"settings.common.scope.global")})}),s.jsxs(Ft,{align:"end",children:[s.jsx(xt,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ee,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(xt,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ee,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsx(Tt,{label:t("settings.common.field.description"),controlClassName:"w-full max-w-none",children:s.jsx(_s,{value:y,onChange:pe=>N(pe.target.value),placeholder:h||t("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})}),s.jsx(Tt,{settingsItem:"agents.mode",label:t("settings.agents.page.field.mode"),info:t("settings.agents.page.field.modeTooltip"),children:s.jsx(Qt,{"aria-label":t("settings.agents.page.field.mode"),value:j,onChange:pe=>{A(pe),Ce()},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(Tt,{settingsItem:"agents.color",label:t("settings.agents.page.field.color"),info:t("settings.agents.page.field.colorTooltip"),children:s.jsx(Dh,{value:U,labels:{empty:t("settings.agents.page.field.colorAutomatic"),swatch:pe=>t("settings.agents.page.field.colorSwatchAria",{color:pe}),custom:t("settings.agents.page.field.colorCustomAria"),hex:t("settings.agents.page.field.colorHexAria")},onChange:pe=>{$(pe),Ce()}})})]}),s.jsxs(ze,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx(it,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(ja,{providerId:la(C)?.providerId??"",modelId:la(C)?.modelId??"",onChange:(pe,me)=>{P(pe&&me?`${pe}/${me}`:""),I(""),Ce()},className:Nn})}),s.jsx(it,{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:Te?s.jsxs(Lt,{value:ye,onValueChange:pe=>{I(pe==="__default"?"":pe),Ce()},children:[s.jsx(Ot,{className:As,children:s.jsx(Kt,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:pe=>pe==="__default"?t("chat.modelControls.default"):pe})}),s.jsxs(Ft,{children:[s.jsx(xt,{value:"__default",children:t("chat.modelControls.default")}),oe.map(pe=>s.jsx(xt,{value:pe,children:pe},pe))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ye,{value:S,onChange:pe=>I(pe.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!C&&!S,className:"h-8 w-40 rounded-md px-3"}),S&&s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{I(""),Ce()},className:as,"aria-label":t("settings.common.actions.clear"),title:t("settings.common.actions.clear"),children:s.jsx(ee,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsxs(it,{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(ws,{value:M,fallbackValue:.7,onValueChange:K,onClear:()=>{K(void 0),Ce()},min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:Ss}),M!==void 0&&s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{K(void 0),Ce()},className:as,"aria-label":t("settings.agents.page.field.clearTemperatureAria"),title:t("settings.common.actions.clear"),children:s.jsx(ee,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(it,{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(ws,{value:L,fallbackValue:.9,onValueChange:E,onClear:()=>{E(void 0),Ce()},min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:Ss}),L!==void 0&&s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{E(void 0),Ce()},className:as,"aria-label":t("settings.agents.page.field.clearTopPAria"),title:t("settings.common.actions.clear"),children:s.jsx(ee,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(it,{settingsItem:"agents.steps",label:t("settings.agents.page.field.steps"),info:t("settings.agents.page.field.stepsTooltip"),children:[s.jsx(ws,{value:T,fallbackValue:20,onValueChange:O,onClear:()=>{O(void 0),Ce()},min:1,max:1e3,step:1,inputMode:"numeric",placeholder:"—",emptyLabel:"—",className:Ss}),T!==void 0&&s.jsx(q,{size:"sm",type:"button",variant:"ghost",onClick:()=>{O(void 0),Ce()},className:as,"aria-label":t("settings.agents.page.field.clearStepsAria"),title:t("settings.common.actions.clear"),children:s.jsx(ee,{name:"close",className:"h-3.5 w-3.5"})})]})]}),s.jsx(ze,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx(_s,{value:D,onChange:pe=>R(pe.target.value),placeholder:b||t("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent"})}),!f&&g&&s.jsx(i1,{agent:g,registerSave:G,requestSave:Ce}),f&&s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[s.jsx(q,{onClick:()=>{Se()},disabled:W||!v.trim(),size:"xs",className:"!font-normal",children:t(W?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(q,{variant:"ghost",onClick:Me,disabled:W,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(ee,{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 f1(t,e){return t.kind==="file"?t.content:e??""}const Dc=es({content:Et(),exists:io(),path:Et().min(1).optional()}),h1=async(t,e)=>{const n=await t.json().catch(()=>null);return typeof n?.error=="string"&&n.error.trim()?n.error:e},b1=t=>t.length>0&&!t.endsWith(`
3
3
  `)?`${t}
4
4
  `:t,xo={prompt:"",responseStyleEnabled:!1,responseStylePreset:"concise",responseStyleCustomInstructions:""},x1=(t,e)=>t==="custom"?e:wp(t),v1=t=>t==="custom"?"custom":uu(t)?t:"concise",Rc={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"},y1=()=>{const{t}=Re(),[e,n]=m.useState(""),[a,i]=m.useState("AGENTS.md"),[o,l]=m.useState(xo.responseStyleEnabled),[r,u]=m.useState(xo.responseStylePreset),[d,c]=m.useState(xo.responseStyleCustomInstructions),[p,g]=m.useState(!0),f=m.useRef(null),h=m.useRef(null);m.useEffect(()=>{const y=new AbortController;return(async()=>{try{const[j,A]=await Promise.all([hn(),Wt("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:y.signal})]);let C=xo,P;j&&(C={...C,responseStyleEnabled:j.responseStyleEnabled===!0,responseStylePreset:v1(j.responseStylePreset),responseStyleCustomInstructions:j.responseStyleCustomInstructions??""},j.globalBehaviorPrompt!==void 0&&(P=j.globalBehaviorPrompt));let S={kind:"missing"};if(A.ok){const I=Dc.parse(await A.json());if(y.signal.aborted)return;i(I.path??"AGENTS.md"),h.current=I.exists?I.content:null,I.exists&&(S={kind:"file",content:I.content})}C={...C,prompt:f1(S,P)},n(C.prompt),l(C.responseStyleEnabled),u(C.responseStylePreset),c(C.responseStyleCustomInstructions),f.current=C}catch(j){j.name!=="AbortError"&&console.warn("Failed to load behavior settings:",j)}finally{g(!1)}})(),()=>y.abort()},[]);const b=m.useRef(e);b.current=e,m.useEffect(()=>{let y=null;const N=async()=>{if(document.visibilityState!=="visible"||!f.current)return;y?.abort();const A=new AbortController;y=A;try{const C=await Wt("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:A.signal});if(!C.ok)return;const P=Dc.parse(await C.json()),S=f.current;if(A.signal.aborted||!S||!P.exists||P.content===h.current||b.current!==S.prompt)return;h.current=P.content,f.current={...S,prompt:P.content},n(P.content)}catch(C){C instanceof DOMException&&C.name==="AbortError"||console.warn("Failed to refresh AGENTS.md:",C)}},j=()=>{N()};return window.addEventListener("focus",j),document.addEventListener("visibilitychange",j),()=>{y?.abort(),window.removeEventListener("focus",j),document.removeEventListener("visibilitychange",j)}},[]);const v=m.useCallback(async()=>{const y=f.current;if(!y||p)return dn;const N=e!==y.prompt,j=o!==y.responseStyleEnabled||r!==y.responseStylePreset||d!==y.responseStyleCustomInstructions;if(!N&&!j)return dn;const A=N?b1(e):y.prompt;if(N){const P=await Wt("/api/behavior/agents-md",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:A,expectedContent:h.current})});if(P.status===409)return Ps(t("settings.behavior.page.toast.agentsMdChangedOnDisk"));if(!P.ok)return Ps(await h1(P,t("settings.behavior.page.toast.saveFailed")));h.current=A,n(S=>S===e?A:S)}return(await It({...N?{globalBehaviorPrompt:A}:{},responseStyleEnabled:o,responseStylePreset:r,responseStyleCustomInstructions:d})).ok?(f.current={prompt:A,responseStyleEnabled:o,responseStylePreset:r,responseStyleCustomInstructions:d},Qn):Ps(t("settings.behavior.page.toast.saveFailed"))},[p,e,d,o,r,t]),k=gi(v),{requestSave:x}=k,w=x1(r,d);return s.jsxs(ts,{title:t("settings.behavior.page.title"),description:t("settings.page.behavior.description"),onBlurCapture:k.onBlurCapture,children:[s.jsx(ze,{title:t("settings.behavior.page.section.systemPrompt"),divider:!1,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(_s,{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(ze,{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(mt,{checked:o,onChange:y=>{l(y),x()},disabled:p,label:t("settings.behavior.page.responseStyle.enable"),ariaLabel:t("settings.behavior.page.responseStyle.enableAria")}),s.jsx(it,{label:t("settings.behavior.page.responseStyle.preset"),alignEnd:!1,children:s.jsxs(Lt,{value:r,onValueChange:y=>{u(y),x()},disabled:p||!o,children:[s.jsx(Ot,{className:As,children:s.jsx(Kt,{children:y=>y==="custom"?t("settings.behavior.page.responseStyle.option.custom"):uu(y)?t(Rc[y]):null})}),s.jsxs(Ft,{children:[jp.map(y=>s.jsx(xt,{value:y,children:t(Rc[y])},y)),s.jsx(xt,{value:"custom",children:t("settings.behavior.page.responseStyle.option.custom")})]})]})}),s.jsx(_s,{value:w,onChange:y=>c(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"})]})]})},k1=(t,e)=>t.kind===e.kind&&(t.kind!=="provider"||e.kind==="provider"&&t.id===e.id),j1=t=>[...t.providers.map(e=>({provider:e,access:t.access?.[e.id]??null,usable:!0})),...t.connectable.map(e=>({provider:e,access:t.access?.[e.id]??null,usable:!1}))].sort((e,n)=>e.provider.name.localeCompare(n.provider.name,void 0,{sensitivity:"base"})),Lr=t=>{const e=Fe.c(8),{t:n}=Re(),a=Ui(P1),i=t.projectOverride!==null;let o;e[0]!==i||e[1]!==a||e[2]!==t.selection||e[3]!==n?(o=u=>{i||k1(u,t.selection)||a(u).then(d=>{d||Q.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},w1=t=>{const e=Fe.c(51),{snapshot:n}=t,{t:a}=Re(),{choose:i,locked:o}=Lr(n),l=n.selection;let r,u;if(e[0]!==o||e[1]!==l.id||e[2]!==l.kind||e[3]!==n.providers||e[4]!==a){const w=l.kind==="provider"?n.providers.find(S=>S.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 j;e[12]!==o||e[13]!==n.providers.length||e[14]!==a?(j=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]=j):j=e[15];let A;e[16]!==a?(A=a("settings.webSearch.option.off"),e[16]=a,e[17]=A):A=e[17];let C;e[18]!==o||e[19]!==A?(C={value:"off",label:A,disabled:o},e[18]=o,e[19]=A,e[20]=C):C=e[20];let P;e[21]!==N||e[22]!==j||e[23]!==C?(P=[N,...j,C],e[21]=N,e[22]=j,e[23]=C,e[24]=P):P=e[24],r=P,u=l.kind==="default"?a("settings.webSearch.option.defaultDescription"):l.kind==="random"?a("settings.webSearch.option.randomDescription"):l.kind==="off"?a("settings.webSearch.mode.offDescription"):w?a("settings.webSearch.mode.providerDescription",{provider:w}):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]=u}else r=e[5],u=e[6];const d=u;let c;e[25]!==a?(c=a("settings.webSearch.section.provider"),e[25]=a,e[26]=c):c=e[26];let p;e[27]!==a?(p=a("settings.webSearch.section.providerInfo"),e[27]=a,e[28]=p):p=e[28];let g;e[29]!==a?(g=a("settings.webSearch.section.provider"),e[29]=a,e[30]=g):g=e[30];let f;e[31]!==i?(f=w=>{w!=="provider"&&i({kind:w})},e[31]=i,e[32]=f):f=e[32];let h;e[33]!==r||e[34]!==l.kind||e[35]!==g||e[36]!==f?(h=s.jsx(Qt,{"aria-label":g,value:l.kind,options:r,onChange:f}),e[33]=r,e[34]=l.kind,e[35]=g,e[36]=f,e[37]=h):h=e[37];let b;e[38]!==d?(b=s.jsx("p",{className:Ht,children:d}),e[38]=d,e[39]=b):b=e[39];let v;e[40]!==n.projectOverride||e[41]!==a?(v=n.projectOverride?s.jsx("p",{className:`${Ht} break-all`,children:a("settings.webSearch.state.projectOverride",{path:n.projectOverride})}):null,e[40]=n.projectOverride,e[41]=a,e[42]=v):v=e[42];let k;e[43]!==h||e[44]!==b||e[45]!==v?(k=s.jsxs("div",{className:"space-y-2",children:[h,b,v]}),e[43]=h,e[44]=b,e[45]=v,e[46]=k):k=e[46];let x;return e[47]!==c||e[48]!==p||e[49]!==k?(x=s.jsx(ze,{title:c,info:p,divider:!1,settingsItem:"web-search.provider",children:k}),e[47]=c,e[48]=p,e[49]=k,e[50]=x):x=e[50],x},S1=t=>{const e=Fe.c(32),{entry:n,snapshot:a,onOpen:i}=t,{t:o}=Re(),{choose:l,locked:r}=Lr(a),{provider:u,access:d,usable:c}=n,p=a.selection.kind==="provider"&&a.selection.id===u.id,g=d?.key,f=d?.connect?.kind==="key";let h;e[0]!==p||e[1]!==g?.kind||e[2]!==o||e[3]!==f||e[4]!==c?(h=p?s.jsx(Rs,{tone:"success",children:o("settings.webSearch.card.inUse")}):!c&&g?.kind==="none"?s.jsx(Rs,{tone:"warning",children:o(f?"settings.webSearch.card.needsKey":"settings.webSearch.card.needsSetup")}):null,e[0]=p,e[1]=g?.kind,e[2]=o,e[3]=f,e[4]=c,e[5]=h):h=e[5];const b=h;let v;e[6]!==g||e[7]!==o||e[8]!==f||e[9]!==c?(v=g?.kind==="stored"?o(f?"settings.webSearch.keys.saved":"settings.webSearch.keys.connected"):g?.kind==="env"?o("settings.webSearch.keys.fromEnv",{name:g.name}):c&&g?.kind==="none"?o("settings.webSearch.card.keyOptional"):null,e[6]=g,e[7]=o,e[8]=f,e[9]=c,e[10]=v):v=e[10];const k=v;let x;e[11]!==l||e[12]!==p||e[13]!==r||e[14]!==u.id||e[15]!==o||e[16]!==c?(x=c&&!p&&!r?[{label:o("settings.webSearch.actions.use"),icon:"check",onSelect:()=>l({kind:"provider",id:u.id})}]:[],e[11]=l,e[12]=p,e[13]=r,e[14]=u.id,e[15]=o,e[16]=c,e[17]=x):x=e[17];const w=x;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(qo,{name:"global"}),e[18]=y):y=e[18];const N=u.name;let j;e[19]!==k?(j=k?s.jsx("span",{className:"min-w-0 truncate",children:k}):null,e[19]=k,e[20]=j):j=e[20];const A=!c&&g?.kind==="none";let C;e[21]!==u.name||e[22]!==o?(C=o("settings.webSearch.card.actions",{provider:u.name}),e[21]=u.name,e[22]=o,e[23]=C):C=e[23];let P;return e[24]!==w||e[25]!==i||e[26]!==b||e[27]!==u.name||e[28]!==j||e[29]!==A||e[30]!==C?(P=s.jsx(da,{icon:y,title:N,badges:b,footer:j,muted:A,onOpen:i,actions:w,actionsLabel:C}),e[24]=w,e[25]=i,e[26]=b,e[27]=u.name,e[28]=j,e[29]=A,e[30]=C,e[31]=P):P=e[31],P},N1=t=>{const e=Fe.c(82),{provider:n,access:a,connect:i,locked:o}=t,{t:l}=Re(),r=Ui(A1),u=Ui(T1),[d,c]=m.useState("");let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];const[g,f]=m.useState(p),[h,b]=m.useState(!1),v=i.kind==="key";let k;if(e[1]!==a.envNames||e[2]!==i.fields||e[3]!==l||e[4]!==v){const D=a.envNames.join(", ");let R;e[6]!==l?(R=$=>[$.description,$.placeholder?l("settings.webSearch.keys.fieldExample",{example:$.placeholder}):null],e[6]=l,e[7]=R):R=e[7];const U=[...i.fields.flatMap(R),a.envNames.length===0?null:v?l("settings.webSearch.keys.envHint",{names:D}):l("settings.webSearch.keys.envHintForm",{names:D})].filter(E1);k=U.length>0?U.map(M1):void 0,e[1]=a.envNames,e[2]=i.fields,e[3]=l,e[4]=v,e[5]=k}else k=e[5];const x=k;let w;e[8]!==g?(w=Object.fromEntries(Object.entries(g).map(D1).filter(R1)),e[8]=g,e[9]=w):w=e[9];const y=w;let N;e[10]!==i.fields||e[11]!==d||e[12]!==y||e[13]!==v?(N=(!v||d.trim()!=="")&&i.fields.every(D=>!D.required||y[D.key]!==void 0),e[10]=i.fields,e[11]=d,e[12]=y,e[13]=v,e[14]=N):N=e[14];const j=N;let A;e[15]!==j||e[16]!==d||e[17]!==y||e[18]!==n.id||e[19]!==n.name||e[20]!==r||e[21]!==l||e[22]!==v?(A=async()=>{if(!j)return;b(!0);const D=await r(n.id,{key:d.trim(),answer:y});b(!1),D?(c(""),f({}),Q.success(v?l("settings.webSearch.toast.keySaved",{provider:n.name}):l("settings.webSearch.toast.connected",{provider:n.name}))):Q.error(v?l("settings.webSearch.toast.keySaveFailed"):l("settings.webSearch.toast.connectFailed",{provider:n.name}))},e[15]=j,e[16]=d,e[17]=y,e[18]=n.id,e[19]=n.name,e[20]=r,e[21]=l,e[22]=v,e[23]=A):A=e[23];const C=A;let P;e[24]!==n.id||e[25]!==u||e[26]!==l?(P=async()=>{b(!0);const D=await u(n.id);b(!1),D||Q.error(l("settings.webSearch.toast.keyRemoveFailed"))},e[24]=n.id,e[25]=u,e[26]=l,e[27]=P):P=e[27];const S=P;let I;e[28]!==C?(I=D=>{D.key==="Enter"&&C()},e[28]=C,e[29]=I):I=e[29];const T=I;let O,M,K,L;if(e[30]!==a.key||e[31]!==g||e[32]!==h||e[33]!==j||e[34]!==i.fields||e[35]!==d||e[36]!==S||e[37]!==C||e[38]!==x||e[39]!==o||e[40]!==n.name||e[41]!==T||e[42]!==l||e[43]!==v){let D;e[48]!==g||e[49]!==n.name||e[50]!==T||e[51]!==l?(D=G=>s.jsx(Ye,{type:G.url?"url":"text",value:g[G.key]??"",onChange:X=>f(ae=>({...ae,[G.key]:X.target.value})),onKeyDown:T,placeholder:G.label,"aria-label":l("settings.webSearch.keys.fieldAria",{provider:n.name,field:G.label}),className:"h-8 min-w-0 flex-1 rounded-md px-3 font-mono text-xs"},G.key),e[48]=g,e[49]=n.name,e[50]=T,e[51]=l,e[52]=D):D=e[52];const R=i.fields.map(D);if(v){let G;e[53]===Symbol.for("react.memo_cache_sentinel")?(G=J=>c(J.target.value),e[53]=G):G=e[53];let X;e[54]!==l?(X=l("settings.webSearch.keys.placeholder"),e[54]=l,e[55]=X):X=e[55];let ae;e[56]!==n.name||e[57]!==l?(ae=l("settings.webSearch.keys.inputAria",{provider:n.name}),e[56]=n.name,e[57]=l,e[58]=ae):ae=e[58];let de;e[59]!==d||e[60]!==T||e[61]!==X||e[62]!==ae?(de=s.jsx(Ye,{type:"password",value:d,onChange:G,onKeyDown:T,placeholder:X,"aria-label":ae,className:"h-8 min-w-0 flex-1 rounded-md px-3 font-mono text-xs"},"key"),e[59]=d,e[60]=T,e[61]=X,e[62]=ae,e[63]=de):de=e[63],R.push(de)}const U=h||!j;let $;e[64]!==C?($=()=>{C()},e[64]=C,e[65]=$):$=e[65];let W;e[66]!==l?(W=l("settings.webSearch.keys.save"),e[66]=l,e[67]=W):W=e[67];let z;e[68]!==U||e[69]!==$||e[70]!==W?(z=s.jsx(q,{size:"xs",disabled:U,onClick:$,children:W}),e[68]=U,e[69]=$,e[70]=W,e[71]=z):z=e[71];const _=z,F=a.key;let V;e[72]!==i.fields[0]||e[73]!==i.fields.length||e[74]!==l||e[75]!==v?(V=v?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]=v,e[76]=V):V=e[76];const H=V;O=it,K=H,L=x,M=F.kind==="stored"?s.jsxs("div",{className:`${In} flex items-center justify-end gap-2`,children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:l(v?"settings.webSearch.keys.saved":"settings.webSearch.keys.connected")}),s.jsx(q,{variant:"outline",size:"xs",disabled:h,onClick:()=>{S()},children:l("settings.webSearch.keys.remove")})]}):F.kind==="env"?s.jsx("span",{className:"typography-meta text-muted-foreground",children:l("settings.webSearch.keys.fromEnv",{name:F.name})}):o?null:R.length===1?s.jsxs("div",{className:`${In} flex items-center gap-2`,children:[R,_]}):s.jsxs("div",{className:`${In} flex flex-col gap-2`,children:[R.slice(0,-1).map(O1),s.jsxs("div",{className:"flex items-center gap-2",children:[R.at(-1),_]})]}),e[30]=a.key,e[31]=g,e[32]=h,e[33]=j,e[34]=i.fields,e[35]=d,e[36]=S,e[37]=C,e[38]=x,e[39]=o,e[40]=n.name,e[41]=T,e[42]=l,e[43]=v,e[44]=O,e[45]=M,e[46]=K,e[47]=L}else O=e[44],M=e[45],K=e[46],L=e[47];let E;return e[77]!==O||e[78]!==M||e[79]!==K||e[80]!==L?(E=s.jsx(O,{label:K,info:L,children:M}),e[77]=O,e[78]=M,e[79]=K,e[80]=L,e[81]=E):E=e[81],E},C1=t=>{const e=Fe.c(44),{entry:n,snapshot:a,onBack:i}=t,{t:o}=Re(),{choose:l,locked:r}=Lr(a),u=Yn(),{provider:d,access:c,usable:p}=n,g=a.selection.kind==="provider"&&a.selection.id===d.id,f=c?.connect??null;let h;e[0]!==f?.kind||e[1]!==g||e[2]!==d.name||e[3]!==o||e[4]!==p?(h=g?o("settings.webSearch.mode.providerDescription",{provider:d.name}):p?null:f?.kind==="form"?o("settings.webSearch.detail.needsSetup",{provider:d.name}):o("settings.webSearch.detail.needsKey",{provider:d.name}),e[0]=f?.kind,e[1]=g,e[2]=d.name,e[3]=o,e[4]=p,e[5]=h):h=e[5];const b=h,v=d.name;let k;e[6]!==o?(k=o("settings.webSearch.detail.back"),e[6]=o,e[7]=k):k=e[7];let x;e[8]!==i||e[9]!==k?(x=s.jsx(ci,{label:k,onClick:i}),e[8]=i,e[9]=k,e[10]=x):x=e[10];let w;e[11]!==b?(w=b?s.jsx("p",{className:"typography-meta text-foreground",children:b}):null,e[11]=b,e[12]=w):w=e[12];let y;e[13]!==l||e[14]!==g||e[15]!==r||e[16]!==d.id||e[17]!==o||e[18]!==p?(y=p&&!g?s.jsx(q,{size:"sm",disabled:r,onClick:()=>l({kind:"provider",id:d.id}),children:o("settings.webSearch.actions.use")}):null,e[13]=l,e[14]=g,e[15]=r,e[16]=d.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:`${Ht} 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 j;e[23]!==w||e[24]!==y||e[25]!==N?(j=s.jsx(ze,{divider:!1,children:s.jsxs("div",{className:"space-y-2",children:[w,y,N]})}),e[23]=w,e[24]=y,e[25]=N,e[26]=j):j=e[26];let A;e[27]!==u||e[28]!==o?(A=u?s.jsx("p",{className:Ht,children:o("settings.webSearch.keys.enterpriseMode")}):null,e[27]=u,e[28]=o,e[29]=A):A=e[29];let C;e[30]!==c||e[31]!==f||e[32]!==u||e[33]!==d||e[34]!==o?(C=c===null?s.jsx("p",{className:Ht,children:o("settings.webSearch.state.keysUnavailable")}):f?s.jsx(N1,{provider:d,access:c,connect:f,locked:u}):s.jsx("p",{className:Ht,children:o("settings.webSearch.detail.noKey")}),e[30]=c,e[31]=f,e[32]=u,e[33]=d,e[34]=o,e[35]=C):C=e[35];let P;e[36]!==C||e[37]!==A?(P=s.jsx(ze,{children:s.jsxs("div",{className:"space-y-4",children:[A,C]})}),e[36]=C,e[37]=A,e[38]=P):P=e[38];let S;return e[39]!==d.name||e[40]!==P||e[41]!==x||e[42]!==j?(S=s.jsxs(ts,{title:v,titleLeading:x,showSaveStatus:!0,children:[j,P]}),e[39]=d.name,e[40]=P,e[41]=x,e[42]=j,e[43]=S):S=e[43],S},I1=()=>{const t=Fe.c(16),{t:e}=Re(),n=Ui(F1),a=Ui(L1),[i,o]=m.useState(null);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=Sp(),t[0]=l):l=t[0];const r=l;let u,d;t[1]!==a?(u=()=>{a()},d=[a,r],t[1]=a,t[2]=u,t[3]=d):(u=t[2],d=t[3]),m.useEffect(u,d);const c=n.kind==="ready"&&n.snapshot.scope===r?n.snapshot:null;let p,g;if(t[4]!==a||t[5]!==i||t[6]!==c||t[7]!==n.kind||t[8]!==e){g=Symbol.for("react.early_return_sentinel");e:{const f=c?j1(c):[],h=i?f.find(k=>k.provider.id===i)??null:null;if(c&&h){let k;t[11]===Symbol.for("react.memo_cache_sentinel")?(k=()=>o(null),t[11]=k):k=t[11],g=s.jsx(C1,{entry:h,snapshot:c,onBack:k});break e}let b;t[12]!==e?(b=e("settings.page.webSearch.title"),t[12]=e,t[13]=b):b=t[13];let v;t[14]!==e?(v=e("settings.page.webSearch.description"),t[14]=e,t[15]=v):v=t[15],p=s.jsx(ts,{title:b,description:v,showSaveStatus:!0,children:c?s.jsxs(s.Fragment,{children:[s.jsx(w1,{snapshot:c}),s.jsxs(ze,{title:e("settings.webSearch.section.providers"),info:e("settings.webSearch.section.providersInfo"),settingsItem:"web-search.providers",children:[f.length===0?s.jsx("p",{className:Ht,children:e("settings.webSearch.state.noProviders")}):s.jsx("div",{className:mi,children:f.map(k=>s.jsx(S1,{entry:k,snapshot:c,onOpen:()=>o(k.provider.id)},k.provider.id))}),c.access===null?s.jsx("p",{className:`${Ht} mt-3`,children:e("settings.webSearch.state.keysUnavailable")}):null]})]}):n.kind==="failed"?s.jsx(ze,{divider:!1,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(q,{variant:"outline",size:"xs",onClick:()=>{a()},children:e("settings.webSearch.actions.retry")})]})}):s.jsx(ze,{divider:!1,children:s.jsx("p",{className:Ht,children:e("settings.webSearch.state.loading")})})})}t[4]=a,t[5]=i,t[6]=c,t[7]=n.kind,t[8]=e,t[9]=p,t[10]=g}else p=t[9],g=t[10];return g!==Symbol.for("react.early_return_sentinel")?g:p};function P1(t){return t.setSelection}function A1(t){return t.saveKey}function T1(t){return t.removeKey}function E1(t){return!!t}function M1(t){return s.jsx("span",{className:"block",children:t},t)}function D1(t){const[e,n]=t;return[e,n.trim()]}function R1(t){const[,e]=t;return e!==""}function O1(t,e){return s.jsx("div",{className:"flex",children:t},e)}function F1(t){return t.state}function L1(t){return t.load}const K1=t=>{const e=Fe.c(183),{onItemSelect:n}=t,{t:a}=Re(),[i,o]=m.useState(""),[l,r]=m.useState(null),[u,d]=m.useState(""),[c,p]=m.useState(null),[g,f]=m.useState(null),[h,b]=m.useState(!1),[v,k]=m.useState(null),{selectedCommandName:x,setSelectedCommand:w,setCommandDraft:y,createCommand:N,deleteCommand:j,loadCommands:A}=ii(Ys(_1)),C=xn();let P;e[0]!==C?(P=He=>mu(He,C),e[0]=C,e[1]=P):P=e[1];const S=ii(P);let I;e[2]!==C?(I=He=>yr(He,C),e[2]=C,e[3]=I):I=e[3];const T=Js(I),O=Js($1);let M,K;e[4]!==A||e[5]!==O||e[6]!==C?(M=()=>{A(C),O(C)},K=[A,O,C],e[4]=A,e[5]=O,e[6]=C,e[7]=M,e[8]=K):(M=e[7],K=e[8]),m.useEffect(M,K);let L;e[9]!==T?(L=new Set(T.map(U1)),e[9]=T,e[10]=L):L=e[10];const E=L;let D;if(e[11]!==S||e[12]!==E){let He;e[14]!==E?(He=Ge=>!E.has(Ge.name),e[14]=E,e[15]=He):He=e[15],D=S.filter(He),e[11]=S,e[12]=E,e[13]=D}else D=e[13];const R=D;let U,$;e[16]!==x||e[17]!==w||e[18]!==E?(U=()=>{x&&E.has(x)&&w(null)},$=[x,w,E],e[16]=x,e[17]=w,e[18]=E,e[19]=U,e[20]=$):(U=e[19],$=e[20]),m.useEffect(U,$);let W;e[21]!==S||e[22]!==n||e[23]!==y||e[24]!==w?(W=()=>{let He="new-command",Ge=1;for(;S.some(ct=>ct.name===He);)He=`new-command-${Ge}`,Ge++;y({name:He,scope:"user"}),w(He),n?.()},e[21]=S,e[22]=n,e[23]=y,e[24]=w,e[25]=W):W=e[25];const z=W;let _;e[26]!==a?(_=async He=>{if(ei(He)){Q.error(a("settings.commands.sidebar.toast.builtInCannotDelete"));return}p(He),f("delete")},e[26]=a,e[27]=_):_=e[27];const F=_;let V;e[28]===Symbol.for("react.memo_cache_sentinel")?(V=async He=>{ei(He)&&(p(He),f("reset"))},e[28]=V):V=e[28];const H=V;let G;e[29]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{p(null),f(null)},e[29]=G):G=e[29];const X=G;let ae;e[30]!==c||e[31]!==g||e[32]!==j||e[33]!==C||e[34]!==a?(ae=async()=>{if(!c||!g)return;b(!0),await j(c.name,C)?(g==="delete"?Q.success(a("settings.commands.sidebar.toast.commandDeleted",{name:c.name})):Q.success(a("settings.commands.sidebar.toast.commandReset",{name:c.name})),X()):g==="delete"?Q.error(a("settings.commands.sidebar.toast.deleteFailed")):Q.error(a("settings.commands.sidebar.toast.resetFailed")),b(!1)},e[30]=c,e[31]=g,e[32]=j,e[33]=C,e[34]=a,e[35]=ae):ae=e[35];const de=ae;let J;e[36]!==S||e[37]!==y||e[38]!==w?(J=He=>{const Ge=He.name;let ct=1,Ct=`${Ge}-copy`;for(;S.some(jt=>jt.name===Ct);)ct++,Ct=`${Ge}-copy-${ct}`;y({name:Ct,scope:He.scope||"user",description:He.description,template:He.template,agent:He.agent,model:He.model,subagent:He.subagent}),w(Ct)},e[36]=S,e[37]=y,e[38]=w,e[39]=J):J=e[39];const ue=J;let be;e[40]===Symbol.for("react.memo_cache_sentinel")?(be=He=>{d(He.name),r(He)},e[40]=be):be=e[40];const fe=be;let he;e[41]!==S||e[42]!==N||e[43]!==j||e[44]!==l||e[45]!==u||e[46]!==w||e[47]!==C||e[48]!==a?(he=async()=>{if(!l)return;const He=u.trim().replace(/\s+/g,"-");if(!He){Q.error(a("settings.commands.sidebar.toast.commandNameRequired"));return}if(He===l.name){r(null);return}if(S.some(ct=>ct.name===He)){Q.error(a("settings.commands.sidebar.toast.commandExists"));return}await N({name:He,description:l.description,template:l.template,agent:l.agent,model:l.model,subagent:l.subagent,scope:l.scope},C)?await j(l.name,C)?(Q.success(`Command renamed to "${He}"`),w(He)):Q.error(a("settings.commands.sidebar.toast.removeOldAfterRenameFailed")):Q.error(a("settings.commands.sidebar.toast.renameFailed")),r(null)},e[41]=S,e[42]=N,e[43]=j,e[44]=l,e[45]=u,e[46]=w,e[47]=C,e[48]=a,e[49]=he):he=e[49];const ye=he;let Te,oe,Y,ve,xe,Ce;if(e[50]!==R||e[51]!==z||e[52]!==F||e[53]!==ue||e[54]!==n||e[55]!==v||e[56]!==i||e[57]!==x||e[58]!==w||e[59]!==a){let He;e[66]!==i?(He=Xe=>Vi([Xe.name,Xe.description],i),e[66]=i,e[67]=He):He=e[67];const Ge=R.filter(He),ct=Ge.filter(ei),Ct=Ge.filter(z1);e[68]===Symbol.for("react.memo_cache_sentinel")?(xe=Je("flex h-full flex-col","bg-background"),e[68]=xe):xe=e[68];let jt;e[69]!==a?(jt=a("settings.commands.sidebar.title"),e[69]=a,e[70]=jt):jt=e[70];let Nt;e[71]!==jt?(Nt=s.jsx("h2",{className:`${ua} mb-3`,children:jt}),e[71]=jt,e[72]=Nt):Nt=e[72];let ke;e[73]===Symbol.for("react.memo_cache_sentinel")?(ke=s.jsx(pi,{className:"mb-3"}),e[73]=ke):ke=e[73];let Ee;e[74]!==R.length||e[75]!==a?(Ee=a("settings.commands.sidebar.total",{count:R.length}),e[74]=R.length,e[75]=a,e[76]=Ee):Ee=e[76];let We;e[77]!==Ee?(We=s.jsx("span",{className:"typography-meta text-muted-foreground",children:Ee}),e[77]=Ee,e[78]=We):We=e[78];let vt;e[79]===Symbol.for("react.memo_cache_sentinel")?(vt=s.jsx(ee,{name:"add",className:"h-3.5 w-3.5"}),e[79]=vt):vt=e[79];let ft;e[80]!==z?(ft=s.jsx(q,{size:"sm","data-settings-item":"commands.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:z,children:vt}),e[80]=z,e[81]=ft):ft=e[81];let ce;e[82]!==We||e[83]!==ft?(ce=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[We,ft]}),e[82]=We,e[83]=ft,e[84]=ce):ce=e[84];let _e;e[85]!==R.length||e[86]!==i?(_e=R.length>0?s.jsx(Rr,{value:i,onChange:o}):null,e[85]=R.length,e[86]=i,e[87]=_e):_e=e[87],e[88]!==Nt||e[89]!==ce||e[90]!==_e?(Ce=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[Nt,ke,ce,_e]}),e[88]=Nt,e[89]=ce,e[90]=_e,e[91]=Ce):Ce=e[91],Te=js,oe="flex-1 min-h-0",Y="space-y-1 px-3 py-2",ve=R.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(ee,{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")})]}):Ge.length===0?s.jsx(Or,{query:i}):s.jsxs(s.Fragment,{children:[ct.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")}),[...ct].sort(B1).map(Xe=>s.jsx(Oc,{command:Xe,isSelected:x===Xe.name,onSelect:()=>{w(Xe.name),n?.()},onReset:()=>H(Xe),onDuplicate:()=>ue(Xe),isMenuOpen:v===Xe.name,onMenuOpenChange:ot=>k(ot?Xe.name:null)},Xe.name))]}),Ct.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")}),[...Ct].sort(V1).map(Xe=>s.jsx(Oc,{command:Xe,isSelected:x===Xe.name,onSelect:()=>{w(Xe.name),n?.()},onRename:()=>fe(Xe),onDelete:()=>F(Xe),onDuplicate:()=>ue(Xe),isMenuOpen:v===Xe.name,onMenuOpenChange:ot=>k(ot?Xe.name:null)},Xe.name))]})]}),e[50]=R,e[51]=z,e[52]=F,e[53]=ue,e[54]=n,e[55]=v,e[56]=i,e[57]=x,e[58]=w,e[59]=a,e[60]=Te,e[61]=oe,e[62]=Y,e[63]=ve,e[64]=xe,e[65]=Ce}else Te=e[60],oe=e[61],Y=e[62],ve=e[63],xe=e[64],Ce=e[65];let Se;e[92]!==Te||e[93]!==oe||e[94]!==Y||e[95]!==ve?(Se=s.jsx(Te,{outerClassName:oe,className:Y,children:ve}),e[92]=Te,e[93]=oe,e[94]=Y,e[95]=ve,e[96]=Se):Se=e[96];const Me=c!==null&&g!==null;let pe;e[97]!==h?(pe=He=>{!He&&!h&&X()},e[97]=h,e[98]=pe):pe=e[98];let me;e[99]!==g||e[100]!==a?(me=a(g==="delete"?"settings.commands.sidebar.dialog.deleteTitle":"settings.commands.sidebar.dialog.resetTitle"),e[99]=g,e[100]=a,e[101]=me):me=e[101];let le;e[102]!==me?(le=s.jsx(Bt,{children:me}),e[102]=me,e[103]=le):le=e[103];let te;e[104]!==c?.name||e[105]!==g||e[106]!==a?(te=g==="delete"?a("settings.commands.sidebar.dialog.deleteDescription",{name:c?.name??""}):a("settings.commands.sidebar.dialog.resetDescription",{name:c?.name??""}),e[104]=c?.name,e[105]=g,e[106]=a,e[107]=te):te=e[107];let Ne;e[108]!==te?(Ne=s.jsx(Vt,{children:te}),e[108]=te,e[109]=Ne):Ne=e[109];let re;e[110]!==le||e[111]!==Ne?(re=s.jsxs(zt,{children:[le,Ne]}),e[110]=le,e[111]=Ne,e[112]=re):re=e[112];let ge;e[113]!==a?(ge=a("settings.common.actions.cancel"),e[113]=a,e[114]=ge):ge=e[114];let Oe;e[115]!==h||e[116]!==ge?(Oe=s.jsx(q,{size:"sm",variant:"ghost",onClick:X,disabled:h,children:ge}),e[115]=h,e[116]=ge,e[117]=Oe):Oe=e[117];let Ke;e[118]!==g||e[119]!==a?(Ke=a(g==="delete"?"settings.common.actions.delete":"settings.common.actions.reset"),e[118]=g,e[119]=a,e[120]=Ke):Ke=e[120];let Le;e[121]!==de||e[122]!==h||e[123]!==Ke?(Le=s.jsx(q,{size:"sm",onClick:de,disabled:h,children:Ke}),e[121]=de,e[122]=h,e[123]=Ke,e[124]=Le):Le=e[124];let ne;e[125]!==Oe||e[126]!==Le?(ne=s.jsxs(ss,{children:[Oe,Le]}),e[125]=Oe,e[126]=Le,e[127]=ne):ne=e[127];let Ie;e[128]!==re||e[129]!==ne?(Ie=s.jsxs($t,{className:"max-w-md",children:[re,ne]}),e[128]=re,e[129]=ne,e[130]=Ie):Ie=e[130];let Pe;e[131]!==Me||e[132]!==pe||e[133]!==Ie?(Pe=s.jsx(_t,{open:Me,onOpenChange:pe,children:Ie}),e[131]=Me,e[132]=pe,e[133]=Ie,e[134]=Pe):Pe=e[134];const De=l!==null;let Be;e[135]===Symbol.for("react.memo_cache_sentinel")?(Be=He=>!He&&r(null),e[135]=Be):Be=e[135];let bt;e[136]!==a?(bt=a("settings.commands.sidebar.renameDialog.title"),e[136]=a,e[137]=bt):bt=e[137];let $e;e[138]!==bt?($e=s.jsx(Bt,{children:bt}),e[138]=bt,e[139]=$e):$e=e[139];const dt=l?.name??"";let Ve;e[140]!==a||e[141]!==dt?(Ve=a("settings.commands.sidebar.renameDialog.description",{name:dt}),e[140]=a,e[141]=dt,e[142]=Ve):Ve=e[142];let st;e[143]!==Ve?(st=s.jsx(Vt,{children:Ve}),e[143]=Ve,e[144]=st):st=e[144];let ut;e[145]!==$e||e[146]!==st?(ut=s.jsxs(zt,{children:[$e,st]}),e[145]=$e,e[146]=st,e[147]=ut):ut=e[147];let qe;e[148]===Symbol.for("react.memo_cache_sentinel")?(qe=He=>d(He.target.value),e[148]=qe):qe=e[148];let gt;e[149]!==a?(gt=a("settings.commands.sidebar.renameDialog.placeholder"),e[149]=a,e[150]=gt):gt=e[150];let lt;e[151]!==ye?(lt=He=>{He.key==="Enter"&&ye()},e[151]=ye,e[152]=lt):lt=e[152];let we;e[153]!==u||e[154]!==gt||e[155]!==lt?(we=s.jsx(Ye,{value:u,onChange:qe,placeholder:gt,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:lt}),e[153]=u,e[154]=gt,e[155]=lt,e[156]=we):we=e[156];let Qe;e[157]===Symbol.for("react.memo_cache_sentinel")?(Qe=()=>r(null),e[157]=Qe):Qe=e[157];let tt;e[158]!==a?(tt=a("settings.common.actions.cancel"),e[158]=a,e[159]=tt):tt=e[159];let ht;e[160]!==tt?(ht=s.jsx(q,{size:"sm",variant:"ghost",onClick:Qe,children:tt}),e[160]=tt,e[161]=ht):ht=e[161];let at;e[162]!==a?(at=a("settings.common.actions.rename"),e[162]=a,e[163]=at):at=e[163];let kt;e[164]!==ye||e[165]!==at?(kt=s.jsx(q,{size:"sm",onClick:ye,children:at}),e[164]=ye,e[165]=at,e[166]=kt):kt=e[166];let se;e[167]!==ht||e[168]!==kt?(se=s.jsxs(ss,{children:[ht,kt]}),e[167]=ht,e[168]=kt,e[169]=se):se=e[169];let Z;e[170]!==ut||e[171]!==we||e[172]!==se?(Z=s.jsxs($t,{children:[ut,we,se]}),e[170]=ut,e[171]=we,e[172]=se,e[173]=Z):Z=e[173];let nt;e[174]!==De||e[175]!==Z?(nt=s.jsx(_t,{open:De,onOpenChange:Be,children:Z}),e[174]=De,e[175]=Z,e[176]=nt):nt=e[176];let St;return e[177]!==xe||e[178]!==Ce||e[179]!==Se||e[180]!==Pe||e[181]!==nt?(St=s.jsxs("div",{className:xe,children:[Ce,Se,Pe,nt]}),e[177]=xe,e[178]=Ce,e[179]=Se,e[180]=Pe,e[181]=nt,e[182]=St):St=e[182],St},Oc=t=>{const e=Fe.c(47),{command:n,isSelected:a,onSelect:i,onDelete:o,onReset:l,onRename:r,onDuplicate:u,isMenuOpen:d,onMenuOpenChange:c}=t,{t:p}=Re();let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=xr(),e[0]=g):g=e[0];const f=g,[h,b]=m.useState(!1);let v;e[1]!==o||e[2]!==u||e[3]!==r||e[4]!==l||e[5]!==p?(v=R=>s.jsxs(s.Fragment,{children:[r&&s.jsxs(R,{onClick:U=>{U.stopPropagation(),r()},children:[s.jsx(ee,{name:"edit",className:"h-4 w-4 me-px"}),p("settings.common.actions.rename")]}),s.jsxs(R,{onClick:U=>{U.stopPropagation(),u()},children:[s.jsx(ee,{name:"file-copy",className:"h-4 w-4 me-px"}),p("settings.common.actions.duplicate")]}),l&&s.jsxs(R,{onClick:U=>{U.stopPropagation(),l()},children:[s.jsx(ee,{name:"restart",className:"h-4 w-4 me-px"}),p("settings.common.actions.reset")]}),o&&s.jsxs(R,{onClick:U=>{U.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[s.jsx(ee,{name:"delete-bin",className:"h-4 w-4 me-px"}),p("settings.common.actions.delete")]})]}),e[1]=o,e[2]=u,e[3]=r,e[4]=l,e[5]=p,e[6]=v):v=e[6];const k=v,x=a?"bg-interactive-selection":"hover:bg-interactive-hover";let w;e[7]!==x?(w=Je("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",x),e[7]=x,e[8]=w):w=e[8];let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=f?void 0:R=>{R.preventDefault(),b(!0)},e[9]=y):y=e[9];let N;e[10]!==w?(N=s.jsx("div",{className:w,onContextMenu:y}),e[10]=w,e[11]=N):N=e[11];let j;e[12]!==n.name?(j=s.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["/",n.name]}),e[12]=n.name,e[13]=j):j=e[13];let A;e[14]!==n||e[15]!==p?(A=(n.scope||ei(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:ei(n)?p("settings.agents.sidebar.badge.system"):n.scope}),e[14]=n,e[15]=p,e[16]=A):A=e[16];let C;e[17]!==j||e[18]!==A?(C=s.jsxs("div",{className:"flex items-center gap-2",children:[j,A]}),e[17]=j,e[18]=A,e[19]=C):C=e[19];let P;e[20]!==n.description?(P=n.description&&s.jsx("div",{className:"typography-micro text-muted-foreground truncate leading-tight",children:n.description}),e[20]=n.description,e[21]=P):P=e[21];let S;e[22]!==i||e[23]!==P||e[24]!==C?(S=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:[C,P]}),e[22]=i,e[23]=P,e[24]=C,e[25]=S):S=e[25];let I;e[26]!==c?(I=R=>{R&&b(!1),c(R)},e[26]=c,e[27]=I):I=e[27];let T;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(Aa,{asChild:!0,children:s.jsx(q,{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",children:s.jsx(ee,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[28]=T):T=e[28];let O;e[29]!==k?(O=s.jsx(Pa,{align:"end",className:"w-fit min-w-20",children:k(wa)}),e[29]=k,e[30]=O):O=e[30];let M;e[31]!==d||e[32]!==I||e[33]!==O?(M=s.jsxs(Ta,{open:d,onOpenChange:I,children:[T,O]}),e[31]=d,e[32]=I,e[33]=O,e[34]=M):M=e[34];let K;e[35]!==S||e[36]!==M?(K=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[S,M]}),e[35]=S,e[36]=M,e[37]=K):K=e[37];let L;e[38]!==K||e[39]!==N?(L=s.jsx(Ji,{render:N,children:K}),e[38]=K,e[39]=N,e[40]=L):L=e[40];let E;e[41]!==k?(E=s.jsx(qi,{className:"w-fit min-w-20",children:k(Gi)}),e[41]=k,e[42]=E):E=e[42];let D;return e[43]!==h||e[44]!==L||e[45]!==E?(D=s.jsxs(Qi,{open:h,onOpenChange:b,children:[L,E]}),e[43]=h,e[44]=L,e[45]=E,e[46]=D):D=e[46],D};function _1(t){return{selectedCommandName:t.selectedCommandName,setSelectedCommand:t.setSelectedCommand,setCommandDraft:t.setCommandDraft,createCommand:t.createCommand,deleteCommand:t.deleteCommand,loadCommands:t.loadCommands}}function $1(t){return t.loadSkills}function U1(t){return t.name}function z1(t){return!ei(t)}function B1(t,e){return t.name.localeCompare(e.name)}function V1(t,e){return t.name.localeCompare(e.name)}const H1=()=>{const{t}=Re(),{selectedCommandName:e,getCommandByName:n,createCommand:a,updateCommand:i,commandDraft:o,setCommandDraft:l,setSelectedCommand:r}=ii(Ys(_=>({selectedCommandName:_.selectedCommandName,getCommandByName:_.getCommandByName,createCommand:_.createCommand,updateCommand:_.updateCommand,commandDraft:_.commandDraft,setCommandDraft:_.setCommandDraft,setSelectedCommand:_.setSelectedCommand}))),u=xn(),d=ii(_=>mu(_,u)),c=e?n(e,u):null,p=!!(o&&o.name===e&&!c),[g,f]=m.useState(""),[h,b]=m.useState("user"),[v,k]=m.useState(""),[x,w]=m.useState(""),[y,N]=m.useState(""),[j,A]=m.useState(""),[C,P]=m.useState(!1),[S,I]=m.useState(""),[T,O]=m.useState(!1),M=m.useRef(null),K=JSON.stringify([u,e]),L=m.useRef(null),E=m.useRef(null);m.useEffect(()=>{const _=L.current===K;if(L.current=K,p&&o){const F=o.name||"",V=o.scope||"user",H=o.description||"",G=o.agent||"",X=Fi(o.model),ae=X?`${X.providerID}/${X.modelID}`:"",de=X?.variant||"",J=o.subagent===!0,ue=o.template||"";f(F),b(V),k(H),w(G),N(ae),A(de),P(J),I(ue),M.current={draftName:F,draftScope:V,description:H,agent:G,model:ae,variant:de,subagent:J,template:ue}}else if(c){const F=c.description||"",V=c.agent||"",H=Fi(c.model),G=H?`${H.providerID}/${H.modelID}`:"",X=H?.variant||"",ae=c.subagent===!0,de=c.template||"",J=E.current,ue=[M.current,J?.identity===K?J.form:null];if(_&&ue.some(be=>be&&be.description===F&&be.agent===V&&be.model===G&&be.variant===X&&be.subagent===ae&&be.template===de))return;k(F),w(V),N(G),A(X),P(ae),I(de),M.current={draftName:"",draftScope:"user",description:F,agent:V,model:G,variant:X,subagent:ae,template:de}}},[c,p,e,d,o,K]);const D=m.useCallback(_=>{const F=x.trim(),V=la(y.trim()),H=V?Mu({providerID:V.providerId,modelID:V.modelId,variant:j.trim()||void 0}):null;return{name:_,description:v.trim()||void 0,agent:F===""?null:F,model:H,subagent:C,template:S.trim(),scope:p?h:void 0}},[x,v,h,p,y,C,S,j]),R=m.useCallback(async()=>{const _=M.current,F=e?.trim();if(p||!_||!F||v.trim()===_.description.trim()&&x.trim()===_.agent.trim()&&y.trim()===_.model.trim()&&j.trim()===_.variant.trim()&&C===_.subagent&&S.trim()===_.template.trim())return dn;if(!S.trim())return Ps(t("settings.commands.page.toast.templateRequired"));const H=D(F),G=Fi(H.model),X={identity:K,form:{..._,description:H.description||"",agent:H.agent||"",model:G?`${G.providerID}/${G.modelID}`:"",variant:G?.variant||"",subagent:H.subagent===!0,template:H.template||""}};E.current=X;try{return await i(F,H,u)?(L.current===K&&(M.current=X.form),Qn):Ps(t("settings.commands.page.toast.updateFailed"))}finally{E.current===X&&(E.current=null)}},[x,D,v,K,p,y,e,u,C,t,S,i,j]),U=gi(R),{requestSave:$}=U,W=async()=>{const _=g.trim().replace(/\s+/g,"-");if(!_){Q.error(t("settings.commands.sidebar.toast.commandNameRequired"));return}if(!S.trim()){Q.error(t("settings.commands.page.toast.templateRequired"));return}if(d.some(F=>F.name===_)){Q.error(t("settings.commands.sidebar.toast.commandExists"));return}O(!0);try{await a(D(_),u)?(l(null),Q.success(t("settings.commands.page.toast.created"))):Q.error(t("settings.commands.page.toast.createFailed"))}catch(F){console.error("Error creating command:",F),Q.error(t("settings.commands.page.toast.saveUnexpectedError"))}finally{O(!1)}},z=()=>{l(null),r(null)};return e?s.jsxs(ts,{title:p?t("settings.commands.page.title.new"):`/${e}`,description:t(p?"settings.commands.page.subtitle.new":"settings.commands.page.subtitle.edit"),onBlurCapture:U.onBlurCapture,children:[!p&&c&&s.jsx(Fr,{legacy:c.legacy===!0,path:c.path}),s.jsxs(ze,{title:t("settings.commands.page.section.identity"),divider:!1,contentClassName:"space-y-0",children:[p&&s.jsxs(it,{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(Ye,{value:g,onChange:_=>f(_.target.value),placeholder:t("settings.commands.page.field.commandNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Lt,{value:h,onValueChange:_=>b(_),children:[s.jsx(Ot,{className:"w-fit min-w-[100px]",children:s.jsx(Kt,{children:t(h==="project"?"settings.common.scope.project":"settings.common.scope.global")})}),s.jsxs(Ft,{align:"end",children:[s.jsx(xt,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ee,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(xt,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ee,{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(_s,{value:v,onChange:_=>k(_.target.value),placeholder:t("settings.commands.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})})]})]}),s.jsxs(ze,{title:t("settings.commands.page.section.executionContext"),contentClassName:"space-y-0",children:[s.jsx(it,{settingsItem:"commands.agent",label:t("settings.commands.page.field.overrideAgent"),children:s.jsx(kr,{agentName:x,onChange:_=>{w(_),$()},className:Nn})}),s.jsx(it,{settingsItem:"commands.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(ja,{providerId:la(y)?.providerId??"",modelId:la(y)?.modelId??"",onChange:(_,F)=>{N(_&&F?`${_}/${F}`:""),$()},className:Nn})}),s.jsx(it,{settingsItem:"commands.variant",label:t("settings.agents.page.field.variant"),info:t("settings.agents.page.field.variantTooltip"),children:s.jsx(Ye,{value:j,onChange:_=>A(_.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!y&&!j,className:"h-8 w-40 rounded-md px-3"})}),s.jsx(it,{settingsItem:"commands.subagent",label:t("settings.commands.page.field.subagent"),info:t("settings.commands.page.field.subagentTooltip"),children:s.jsx(za,{checked:C,onCheckedChange:_=>{P(_),$()},"aria-label":t("settings.commands.page.field.subagent")})})]}),s.jsxs(ze,{title:t("settings.commands.page.section.template"),settingsItem:"commands.template",children:[s.jsx(_s,{value:S,onChange:_=>I(_.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")," ·"," ",s.jsx("code",{className:"text-foreground",children:"!`cmd`"})," ",t("settings.commands.page.templateHint.shellOutput")," ·"," ",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(q,{onClick:()=>{W()},disabled:T||!g.trim()||!S.trim(),size:"xs",className:"!font-normal",children:t(T?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(q,{variant:"ghost",onClick:z,disabled:T,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(ee,{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 ji(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function Bn(t,e){return e!==void 0?{ok:!1,error:t,parsed:e}:{ok:!1,error:t}}function vo(t,e,n){const a=q1(n),i=typeof n.url=="string"?n.url.trim():"",o=Fc(n,"env","environment"),l=Fc(n,"headers"),r=Sn(n.oauth)?n.oauth:null,u=wi(r,"client_id","clientId"),d=wi(r,"client_secret","clientSecret"),c=wi(r,"scope"),p=wi(r,"redirect_uri","redirectUri"),g=W1(r,"callback_port","callbackPort"),f=wi(r,"auth_server_metadata_url","authServerMetadataUrl"),h=n.oauth===!1||n.oauth===null||n.oauth===void 0?!1:!!r&&!!(u||d||c||p||g||f),b=G1(n);return{ok:!0,name:t,type:e,command:a,url:i,environment:o,headers:l,oauthEnabled:h,oauthClientId:u,oauthClientSecret:d,oauthScope:c,oauthRedirectUri:p,oauthCallbackPort:g,oauthAuthServerMetadataUrl:f,timeoutStartup:b.startup,timeoutCatalog:b.catalog,timeoutExecution:b.execution,codemode:n.codemode===!0?"on":n.codemode===!1?"off":"default",disabled:J1(n),protocol:ql.find(v=>v===n.protocol)??"legacy"}}function wi(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 W1(t,...e){if(!t)return"";for(const n of e){const a=Ei(t[n]);if(a)return a}return""}function Ei(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 q1(t){const e=t.command,n=t.args;if(ji(e)&&ji(n))return[...e,...n];if(ji(e))return e;if(typeof e=="string"&&e.trim()){const a=e.trim().split(/\s+/);return ji(n)?[...a,...n]:a}return ji(n)?n:[]}function Fc(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 G1(t){return Sn(t.timeout)?{startup:Ei(t.timeout.startup),catalog:Ei(t.timeout.catalog),execution:Ei(t.timeout.execution)}:{startup:"",catalog:"",execution:Ei(t.timeout)}}function J1(t){return t.disabled===!0?!0:t.disabled===!1?!1:"enabled"in t?!t.enabled:!1}function Q1(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(Ju(i))return{name:a,entry:i}}return null}function Ju(t){return t.type==="local"||t.type==="remote"||Array.isArray(t.command)||typeof t.url=="string"||Array.isArray(t.args)}function Y1(t,e){let n;try{const u=t.trim();if(!u)return Bn("No JSON content provided");n=JSON.parse(u)}catch(u){return Bn(u instanceof Error?`Invalid JSON: ${u.message}`:"Invalid JSON")}if(!Sn(n))return Bn("Expected a JSON object, not an array or primitive");const a=n,i=a.mcpServers;if(Sn(i)){const u=Object.keys(i);if(u.length===0)return Bn("mcpServers object is empty",n);if(u.length>1)return Bn("Paste one server at a time. Found "+u.length+" servers in mcpServers",n);const d=u[0],c=i[d];return Sn(c)?vo(d,yo(c),c):Bn("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 u=Object.keys(l);if(u.length===0)return Bn("mcp object is empty",n);if(u.length>1)return Bn("Paste one server at a time. Found "+u.length+" servers in mcp",n);const d=u[0],c=l[d];return Sn(c)?vo(d,yo(c),c):Bn("Server entry in mcp is not a valid object",n)}const r=Q1(a);if(r)return vo(r.name,yo(r.entry),r.entry);if(Ju(a)){const u=yo(a),d=typeof a.name=="string"&&a.name.trim()?a.name.trim():e?.fallbackName;return vo(d,u,a)}return Bn("No recognizable MCP server configuration found in JSON",n)}function yo(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 Z1(t,e,n){const a=n?.isNewServer??!1,i=t.name?Gh(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:!1,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 Lc=[],Qu=t=>{const e=Fe.c(5),[n,a]=m.useState(Lc);let i,o;e[0]!==t?(i=()=>{let r=!1;return a(Lc),fn.getIntegrationPolicies(t).then(u=>{r||a(u)}).catch(X1),()=>{r=!0}},o=[t],e[0]=t,e[1]=i,e[2]=o):(i=e[1],o=e[2]),m.useEffect(i,o);let l;return e[3]!==n?(l=r=>Pf(n,r),e[3]=n,e[4]=l):l=e[4],l};function X1(t){console.warn("[settings] could not read OpenCode integration policies:",t instanceof Error?t.message:String(t))}const ex=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},tx=t=>{const e=Fe.c(13),{status:n,enabled:a,blocked:i}=t,{t:o}=Re();if(i){let d;e[0]!==o?(d=o("settings.mcp.grid.status.blockedByPolicy"),e[0]=o,e[1]=d):d=e[1];let c;return e[2]!==d?(c=s.jsx(Rs,{tone:"warning",children:d}),e[2]=d,e[3]=c):c=e[3],c}if(!a){let d;e[4]!==o?(d=o("settings.mcp.grid.status.disabled"),e[4]=o,e[5]=d):d=e[5];let c;return e[6]!==d?(c=s.jsx(Rs,{tone:"neutral",children:d}),e[6]=d,e[7]=c):c=e[7],c}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 u;return e[11]!==r?(u=r?s.jsx(Rs,{tone:r.tone,children:r.label}):null,e[11]=r,e[12]=u):u=e[12],u},sx=()=>{const t=Fe.c(132),{t:e}=Re(),n=xn(),{setSelectedMcp:a,setMcpDraft:i,loadMcpConfigs:o,deleteMcp:l}=ia(Ys(nx)),[r,u]=m.useState(null),[d,c]=m.useState(!1);let p;t[0]!==n?(p=Se=>vr(Se,n),t[0]=n,t[1]=p):p=t[1];const g=ia(p);let f;t[2]!==n?(f=Se=>Se.getStatusForDirectory(n),t[2]=n,t[3]=f):f=t[3];const h=Kn(f),b=Qu(n),v=Kn(ax),k=Kn(ix),[x,w]=m.useState(!1),[y,N]=m.useState("");let j,A;t[4]!==o||t[5]!==n?(j=()=>{o({directory:n})},A=[o,n],t[4]=o,t[5]=n,t[6]=j,t[7]=A):(j=t[6],A=t[7]),m.useEffect(j,A);let C;t[8]!==k||t[9]!==x||t[10]!==v||t[11]!==n?(C=()=>{if(x)return;w(!0);const Se=new Promise(ox);Promise.all([v({directory:n,silent:!0}),Se]).then(()=>{const Me=k(n);Me&&Q.error(Me)}).finally(()=>w(!1))},t[8]=k,t[9]=x,t[10]=v,t[11]=n,t[12]=C):C=t[12];const P=C;let S;t[13]!==g||t[14]!==i||t[15]!==a?(S=()=>{const Se=ex(g),Me={name:Se,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],...Uu,oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1};i(Me),a(Se)},t[13]=g,t[14]=i,t[15]=a,t[16]=S):S=t[16];const I=S;let T;t[17]!==l||t[18]!==r||t[19]!==n||t[20]!==e?(T=async()=>{if(!r)return;const Se=r;c(!0);const Me=await l(Se,n);Me.ok?(Me.reloadFailed?Q.warning(Me.message||e("settings.mcp.page.toast.serverDeletedReloadFailed",{name:Se}),{description:Me.warning||e("settings.mcp.page.toast.refreshListIfStale")}):Q.success(Me.message||e("settings.mcp.page.toast.serverDeleted",{name:Se})),u(null)):Q.error(e("settings.mcp.page.toast.deleteFailed")),c(!1)},t[17]=l,t[18]=r,t[19]=n,t[20]=e,t[21]=T):T=t[21];const O=T;let M,K,L,E,D,R,U,$,W;if(t[22]!==I||t[23]!==P||t[24]!==b||t[25]!==x||t[26]!==h||t[27]!==y||t[28]!==g||t[29]!==i||t[30]!==a||t[31]!==e){const Se=Ea([...g],y,lx);let Me;t[41]!==y?(Me=y.trim(),t[41]=y,t[42]=Me):Me=t[42];const pe=Me.length>0;M=ts,t[43]!==e?(K=e("settings.page.mcp.title"),t[43]=e,t[44]=K):K=t[44],t[45]!==e?(L=e("settings.mcp.grid.description"),t[45]=e,t[46]=L):L=t[46];let me;t[47]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(pi,{className:"min-w-0 flex-1 @xl:w-56 @xl:flex-none"}),t[47]=me):me=t[47];let le;t[48]!==e?(le=e("settings.mcp.sidebar.actions.refreshStatusAria"),t[48]=e,t[49]=le):le=t[49];let te;t[50]!==e?(te=e("settings.mcp.sidebar.actions.refreshStatusTitle"),t[50]=e,t[51]=te):te=t[51];const Ne=x&&"animate-spin";let re;t[52]!==Ne?(re=Je("size-4",Ne),t[52]=Ne,t[53]=re):re=t[53];let ge;t[54]!==re?(ge=s.jsx(ee,{name:"refresh",className:re}),t[54]=re,t[55]=ge):ge=t[55],t[56]!==P||t[57]!==x||t[58]!==le||t[59]!==te||t[60]!==ge?(E=s.jsxs("div",{className:"flex w-full items-center gap-2 @xl:w-auto",children:[me,s.jsx(q,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0 text-muted-foreground",disabled:x,onClick:P,"aria-label":le,title:te,children:ge})]}),t[56]=P,t[57]=x,t[58]=le,t[59]=te,t[60]=ge,t[61]=E):E=t[61],t[62]!==y||t[63]!==g.length||t[64]!==e?(D=g.length>0?s.jsx(pl,{value:y,onChange:N,placeholder:e("settings.mcp.grid.searchPlaceholder")}):null,t[62]=y,t[63]=g.length,t[64]=e,t[65]=D):D=t[65],R=g.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:e("settings.mcp.grid.empty")}):Se.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:e("settings.mcp.grid.noMatches",{query:y.trim()})}):null,U=mi,t[66]!==I||t[67]!==pe||t[68]!==e?($=pe?null:s.jsx(ao,{label:e("settings.mcp.sidebar.actions.addServerTitle"),hint:e("settings.mcp.grid.addHint"),onClick:I,settingsItem:"mcp.create"}),t[66]=I,t[67]=pe,t[68]=e,t[69]=$):$=t[69];let Oe;t[70]!==b||t[71]!==h||t[72]!==i||t[73]!==a||t[74]!==e?(Oe=Ke=>{const Le=Ke.disabled!==!0,ne=b(`mcp:${Ke.name}`),Ie=Ke.type==="local"?Ke.command?.join(" "):Ke.url;return s.jsx(da,{icon:s.jsx(qo,{name:Ke.type==="local"?"server":"global"}),title:Ke.name,subtitle:Ie||void 0,badges:s.jsx(tx,{status:h[Ke.name]?.status.status,enabled:Le,blocked:ne}),muted:!Le||ne,footer:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Ke.type==="local"?e("settings.mcp.sidebar.serverType.localTitle"):e("settings.mcp.sidebar.serverType.remoteTitle")}),Ke.scope==="project"?s.jsx(Hi,{children:e("settings.mcp.grid.scope.project")}):null]}),onOpen:()=>{i(null),a(Ke.name)},actionsLabel:e("settings.mcp.grid.actionsAria",{name:Ke.name}),actions:[{label:e("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onSelect:()=>u(Ke.name)}]},Ke.name)},t[70]=b,t[71]=h,t[72]=i,t[73]=a,t[74]=e,t[75]=Oe):Oe=t[75],W=Se.map(Oe),t[22]=I,t[23]=P,t[24]=b,t[25]=x,t[26]=h,t[27]=y,t[28]=g,t[29]=i,t[30]=a,t[31]=e,t[32]=M,t[33]=K,t[34]=L,t[35]=E,t[36]=D,t[37]=R,t[38]=U,t[39]=$,t[40]=W}else M=t[32],K=t[33],L=t[34],E=t[35],D=t[36],R=t[37],U=t[38],$=t[39],W=t[40];let z;t[76]!==U||t[77]!==$||t[78]!==W?(z=s.jsxs("div",{className:U,children:[$,W]}),t[76]=U,t[77]=$,t[78]=W,t[79]=z):z=t[79];const _=r!==null;let F;t[80]!==d?(F=Se=>{!Se&&!d&&u(null)},t[80]=d,t[81]=F):F=t[81];const V=r??"";let H;t[82]!==e||t[83]!==V?(H=e("settings.mcp.page.deleteDialog.title",{name:V}),t[82]=e,t[83]=V,t[84]=H):H=t[84];let G;t[85]!==H?(G=s.jsx(Bt,{children:H}),t[85]=H,t[86]=G):G=t[86];let X;t[87]!==e?(X=e("settings.mcp.page.deleteDialog.descriptionPrefix"),t[87]=e,t[88]=X):X=t[88];let ae;t[89]===Symbol.for("react.memo_cache_sentinel")?(ae=s.jsx("code",{className:"text-foreground",children:"opencode.json"}),t[89]=ae):ae=t[89];let de;t[90]!==e?(de=e("settings.mcp.page.deleteDialog.descriptionSuffix"),t[90]=e,t[91]=de):de=t[91];let J;t[92]!==X||t[93]!==de?(J=s.jsxs(Vt,{children:[X," ",ae,"."," ",de]}),t[92]=X,t[93]=de,t[94]=J):J=t[94];let ue;t[95]!==G||t[96]!==J?(ue=s.jsxs(zt,{children:[G,J]}),t[95]=G,t[96]=J,t[97]=ue):ue=t[97];let be;t[98]===Symbol.for("react.memo_cache_sentinel")?(be=()=>u(null),t[98]=be):be=t[98];let fe;t[99]!==e?(fe=e("settings.common.actions.cancel"),t[99]=e,t[100]=fe):fe=t[100];let he;t[101]!==d||t[102]!==fe?(he=s.jsx(q,{variant:"outline",size:"sm",onClick:be,disabled:d,children:fe}),t[101]=d,t[102]=fe,t[103]=he):he=t[103];let ye;t[104]!==O?(ye=()=>{O()},t[104]=O,t[105]=ye):ye=t[105];let Te;t[106]!==d||t[107]!==e?(Te=e(d?"settings.mcp.page.actions.deleting":"settings.common.actions.delete"),t[106]=d,t[107]=e,t[108]=Te):Te=t[108];let oe;t[109]!==d||t[110]!==ye||t[111]!==Te?(oe=s.jsx(q,{variant:"destructive",size:"sm",onClick:ye,disabled:d,children:Te}),t[109]=d,t[110]=ye,t[111]=Te,t[112]=oe):oe=t[112];let Y;t[113]!==he||t[114]!==oe?(Y=s.jsxs(ss,{children:[he,oe]}),t[113]=he,t[114]=oe,t[115]=Y):Y=t[115];let ve;t[116]!==ue||t[117]!==Y?(ve=s.jsxs($t,{className:"max-w-md",children:[ue,Y]}),t[116]=ue,t[117]=Y,t[118]=ve):ve=t[118];let xe;t[119]!==_||t[120]!==F||t[121]!==ve?(xe=s.jsx(_t,{open:_,onOpenChange:F,children:ve}),t[119]=_,t[120]=F,t[121]=ve,t[122]=xe):xe=t[122];let Ce;return t[123]!==M||t[124]!==K||t[125]!==L||t[126]!==E||t[127]!==D||t[128]!==R||t[129]!==z||t[130]!==xe?(Ce=s.jsxs(M,{title:K,description:L,headerEnd:E,children:[D,R,z,xe]}),t[123]=M,t[124]=K,t[125]=L,t[126]=E,t[127]=D,t[128]=R,t[129]=z,t[130]=xe,t[131]=Ce):Ce=t[131],Ce};function nx(t){return{setSelectedMcp:t.setSelectedMcp,setMcpDraft:t.setMcpDraft,loadMcpConfigs:t.loadMcpConfigs,deleteMcp:t.deleteMcp}}function ax(t){return t.refresh}function ix(t){return t.getErrorForDirectory}function ox(t){return setTimeout(t,500)}function lx(t){return[t.name,t.type==="local"?t.command?.join(" ")??"":t.url??""]}const Il=t=>t===void 0?"":String(t),Pl=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`},Al={legacy:"settings.mcp.page.advanced.protocolOption.legacy",auto:"settings.mcp.page.advanced.protocolOption.auto","2026-07-28":"settings.mcp.page.advanced.protocolOption.revision20260728"},Kc={default:"settings.mcp.page.advanced.codemodeOption.default",on:"settings.mcp.page.advanced.codemodeOption.on",off:"settings.mcp.page.advanced.codemodeOption.off"},rx=t=>{try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}},Ja=t=>t?.status.status,Tl=t=>t?.status.status==="failed"||t?.status.status==="needs_auth"?t.status.error:void 0;function Yu(t){const e=[];let n="",a=!1,i=!1;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 cx=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,u]=m.useState(l),d=m.useRef(n);let c,p;e[2]!==n?(c=()=>{JSON.stringify(d.current)!==JSON.stringify(n)&&(d.current=n,u(n.join(`