@openchamber/web 2.6.1 → 2.6.2-canary.20261104.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/assets/{AboutDialog-D-IujH5P.js → AboutDialog-BLUUIZML.js} +1 -1
  2. package/dist/assets/{AboutLogo-Bghz4cno.js → AboutLogo-DiHHd_5t.js} +1 -1
  3. package/dist/assets/{ArchiveView-SQdNDg7X.js → ArchiveView-CwhPe3Y_.js} +1 -1
  4. package/dist/assets/{ChangeRequestDiffUnavailable-uZ8LXZIU.js → ChangeRequestDiffUnavailable-3YgjMJtr.js} +1 -1
  5. package/dist/assets/{ChangedPathLabel-BZHIGJ_0.js → ChangedPathLabel-B6Ig547I.js} +1 -1
  6. package/dist/assets/{CommandPalette-DjCVXkJM.js → CommandPalette-BChv7Yci.js} +1 -1
  7. package/dist/assets/{DiffView-CIlNcbDh.js → DiffView-pFcLbagS.js} +1 -1
  8. package/dist/assets/{FilesView-VMk-uSwN.js → FilesView-Bod-r3C6.js} +1 -1
  9. package/dist/assets/{GitView-BIg-1tUn.js → GitView-C4xsLAUw.js} +1 -1
  10. package/dist/assets/{GuestSurfacePane-BUmmCfBg.js → GuestSurfacePane-BTyjXjRj.js} +1 -1
  11. package/dist/assets/{HelpDialog-DlCrl3jK.js → HelpDialog-jRlVnJ_e.js} +1 -1
  12. package/dist/assets/{IntegrationsCatalogView-tZTRIaCg.js → IntegrationsCatalogView-CjJ3sWIM.js} +1 -1
  13. package/dist/assets/{JsonTreeView-D5DVoS6l.js → JsonTreeView-C7EScp5B.js} +1 -1
  14. package/dist/assets/{MarkdownDiffPreview-DoMO0ER1.js → MarkdownDiffPreview-cPqaSgaj.js} +1 -1
  15. package/dist/assets/{MarkdownRendererImpl-D1KCox5d.js → MarkdownRendererImpl-BcJ1sqsU.js} +3 -3
  16. package/dist/assets/{MemoryDebugPanel-X5DD6Cjd.js → MemoryDebugPanel-D0N9KDmI.js} +1 -1
  17. package/dist/assets/{NoteEditor-_UWC0M0H.js → NoteEditor-DxvVLbA7.js} +1 -1
  18. package/dist/assets/{OnboardingScreen-DBSPDpEj.js → OnboardingScreen-CMeQdpeM.js} +1 -1
  19. package/dist/assets/{OpenCodeStatusDialog-e8gdYqEY.js → OpenCodeStatusDialog-BAv0K4eb.js} +1 -1
  20. package/dist/assets/{OverviewView-Cf5_Harr.js → OverviewView-DyDBexdg.js} +1 -1
  21. package/dist/assets/{PatchDiff-DIWEk4tG.js → PatchDiff-CvabHkAC.js} +1 -1
  22. package/dist/assets/{PlanView-CV7_x4Hj.js → PlanView-DPpR2O_F.js} +1 -1
  23. package/dist/assets/{ProjectActionsDialog-B90g1jby.js → ProjectActionsDialog-B96GmKCc.js} +1 -1
  24. package/dist/assets/{ReplyUiBlock-D2m0ZgRL.js → ReplyUiBlock-BuiEYmcz.js} +1 -1
  25. package/dist/assets/{ReviewCards-D--SZYNA.js → ReviewCards-B219SHVL.js} +1 -1
  26. package/dist/assets/{RunOverview-CGv4KD-i.js → RunOverview-6n10wBYl.js} +1 -1
  27. package/dist/assets/{ScheduledTasksDialog-XjiWbQnf.js → ScheduledTasksDialog-CTkrlYii.js} +1 -1
  28. package/dist/assets/{SettingsView-Cz-oULIY.js → SettingsView-CenZZQat.js} +1 -1
  29. package/dist/assets/{SettingsWindow-BHUNfQBn.js → SettingsWindow-HEw9_GIT.js} +1 -1
  30. package/dist/assets/{SidebarSectionsManager-C1YsRka1.js → SidebarSectionsManager-CEl8jV_W.js} +1 -1
  31. package/dist/assets/{SourceBoardView-Cc3LeYUo.js → SourceBoardView-CJZ3s1XD.js} +1 -1
  32. package/dist/assets/{SpaceAccessDialog-f_DzFvFs.js → SpaceAccessDialog-Ngob2qn9.js} +1 -1
  33. package/dist/assets/{SpaceApplyDialog-CddUu8PS.js → SpaceApplyDialog-BxjDC_0D.js} +1 -1
  34. package/dist/assets/{SpaceRow-DnnOnMYM.js → SpaceRow-CckOV1g8.js} +1 -1
  35. package/dist/assets/{SpaceSetupOutput-BzQQtLdO.js → SpaceSetupOutput-lGqiVX-3.js} +1 -1
  36. package/dist/assets/{SpacesView-BZhH9crf.js → SpacesView-CP5k-k3v.js} +1 -1
  37. package/dist/assets/{SubmoduleDiffSummary-D6Wu1QuT.js → SubmoduleDiffSummary-Cdi9S4gX.js} +1 -1
  38. package/dist/assets/{ToolOutputDialog-BkmKHRdh.js → ToolOutputDialog-08mv6_M5.js} +1 -1
  39. package/dist/assets/{ToolPartDiffPreview-BurYz6UW.js → ToolPartDiffPreview-DRL47sfe.js} +1 -1
  40. package/dist/assets/{UiBlock-Bwx-T68z.js → UiBlock-C47vwIuG.js} +1 -1
  41. package/dist/assets/{UsageStatsView-WPrhgORf.js → UsageStatsView-DCpTVWz3.js} +1 -1
  42. package/dist/assets/{WalkthroughView-BMD1xSij.js → WalkthroughView-DeaBPhAn.js} +1 -1
  43. package/dist/assets/{WorktreesView-BFut-2yK.js → WorktreesView-B1YD_EPW.js} +1 -1
  44. package/dist/assets/{appThemeRegistry-Dk6CF03D.js → appThemeRegistry-hfPZ6say.js} +1 -1
  45. package/dist/assets/{ar-CuYBgoCL.js → ar-BrwaPZTB.js} +1 -1
  46. package/dist/assets/{codeHighlight-BYbxdxkk.js → codeHighlight-CXtTq4co.js} +1 -1
  47. package/dist/assets/{computeVirtualFileMetrics-COD-bZRh.js → computeVirtualFileMetrics-vVCRMHlo.js} +2 -2
  48. package/dist/assets/{contextFileOpenGuard-D_Eh6QOM.js → contextFileOpenGuard-BrUXbAMg.js} +1 -1
  49. package/dist/assets/{date-time-KFcfG8FZ.js → date-time-t6mCSZMr.js} +1 -1
  50. package/dist/assets/{de-Jo819vpe.js → de-DM_yQ7AG.js} +1 -1
  51. package/dist/assets/{es-CV0MRSsN.js → es-DMJlwy06.js} +1 -1
  52. package/dist/assets/{fileContentPoller-dM2aYiRt.js → fileContentPoller-B_D2WQHm.js} +1 -1
  53. package/dist/assets/{flexokiTheme-BL4fG_5M.js → flexokiTheme-DJhpTHWO.js} +1 -1
  54. package/dist/assets/{fr-CdmUjdKh.js → fr-BKEy-Z_2.js} +1 -1
  55. package/dist/assets/{he-B0Jv5rnl.js → he-BnqH_lWh.js} +1 -1
  56. package/dist/assets/{highlights-Cz6HBqYD.js → highlights-hXz5ezHu.js} +1 -1
  57. package/dist/assets/{index-BaQtYnl3.js → index-D6cItOu7.js} +1 -1
  58. package/dist/assets/{initializeSharedPreferences-CiaDh0AM.js → initializeSharedPreferences-BKG_0s4E.js} +1 -1
  59. package/dist/assets/{install-T6u73Zz0.js → install-csQoiut9.js} +1 -1
  60. package/dist/assets/{isDiffPlainText-B8tZAZQ4.js → isDiffPlainText-OMACajs1.js} +1 -1
  61. package/dist/assets/{isFilePlainText-CgNXAeJu.js → isFilePlainText-Z9Wi1AQY.js} +1 -1
  62. package/dist/assets/{ja-BGc1V8I_.js → ja-lqTz_4gG.js} +1 -1
  63. package/dist/assets/{katex.min-BM3LOlr3.js → katex.min-B7gF3rmE.js} +4 -4
  64. package/dist/assets/{ko-CadSaTs-.js → ko-DXd5Gg_L.js} +1 -1
  65. package/dist/assets/{main-b_PAxB6R.js → main-D0VV0_-r.js} +4 -4
  66. package/dist/assets/{main-BX74Pq6m.js → main-DC2rz5Pv.js} +2 -2
  67. package/dist/assets/{miniChat-CzVxcGLZ.js → miniChat-C6te7Cha.js} +2 -2
  68. package/dist/assets/{mobile-DfBoGVRE.js → mobile-h7Y89upC.js} +2 -2
  69. package/dist/assets/{nl-Ds8N-7nU.js → nl-X6CZmwET.js} +1 -1
  70. package/dist/assets/{pageTitle-DcFkBvgW.js → pageTitle-CAd4Kwsy.js} +1 -1
  71. package/dist/assets/{parseDiffFromFile-DEaa1di6.js → parseDiffFromFile-BuLpViZg.js} +1 -1
  72. package/dist/assets/{pierreDiffTint-CS5FWjsh.js → pierreDiffTint-Bda-Leur.js} +1 -1
  73. package/dist/assets/{pl-BAAqSvOD.js → pl-CmAyO7EH.js} +1 -1
  74. package/dist/assets/{pt-BR-CxTCCQt5.js → pt-BR-QNheuCzR.js} +1 -1
  75. package/dist/assets/{relocateRestoredSession-C8x_kYRX.js → relocateRestoredSession-hOOmUC2p.js} +2 -2
  76. package/dist/assets/{renderElectronMiniChatApp-Bwgx8afa.js → renderElectronMiniChatApp-Dg-2lMCR.js} +2 -2
  77. package/dist/assets/{renderMarkdownForExport-DzVoMkQY.js → renderMarkdownForExport-Dy3HSiOK.js} +1 -1
  78. package/dist/assets/{renderMobileApp-0o5iW3gX.js → renderMobileApp-BhpguGxm.js} +3 -3
  79. package/dist/assets/{resolveLanguages-O4KbMEYv.js → resolveLanguages-BF-kRWyQ.js} +1 -1
  80. package/dist/assets/{runtimeEndpointReset-IJE1o-nk.js → runtimeEndpointReset-DUwSilpj.js} +8 -8
  81. package/dist/assets/{scheduledTasksApi-Bt4F6fco.js → scheduledTasksApi-jkEn2fUL.js} +1 -1
  82. package/dist/assets/{shiki-DfHQjW4b.js → shiki-D0FPzA_f.js} +1 -1
  83. package/dist/assets/{space-apply-BWMKP1l4.js → space-apply-De-hlG-f.js} +1 -1
  84. package/dist/assets/{space-close-B5_k2AhX.js → space-close-BQzjlZ-w.js} +1 -1
  85. package/dist/assets/{spaceNetwork-Bww_OVgL.js → spaceNetwork-CVVlgvhL.js} +1 -1
  86. package/dist/assets/{stream-tokenizer-B87hBGmH.js → stream-tokenizer-w3w2i3zK.js} +1 -1
  87. package/dist/assets/{textMateThemeFromAppTheme-BA68BaAw.js → textMateThemeFromAppTheme-B38k_gpV.js} +1 -1
  88. package/dist/assets/{tr-vj7L-0nl.js → tr-4WQrywE1.js} +1 -1
  89. package/dist/assets/{uk-DYlYVGgJ.js → uk-Dos-a0OZ.js} +1 -1
  90. package/dist/assets/{useAppFontEffects-UKWR--vP.js → useAppFontEffects-6HvTeJY2.js} +15 -15
  91. package/dist/assets/{useBranchPullRequestRequest-DJNOWuS3.js → useBranchPullRequestRequest-B8yYsqiw.js} +1 -1
  92. package/dist/assets/{useCallableModelProviders-BVbgbn_M.js → useCallableModelProviders-BLdr2CgV.js} +1 -1
  93. package/dist/assets/{useDiffFindSurface-zju_sQ6_.js → useDiffFindSurface-BVO1E6le.js} +1 -1
  94. package/dist/assets/{useGitCleanLine-DA-nRAvz.js → useGitCleanLine-DEZFq7uh.js} +1 -1
  95. package/dist/assets/{useInlineCommentController-DgJBL64V.js → useInlineCommentController-BiX7K5jy.js} +1 -1
  96. package/dist/assets/{useMarkdownLocalAssets-DFwvtvsy.js → useMarkdownLocalAssets-DM7b941V.js} +1 -1
  97. package/dist/assets/{useRootScrollLock-ywfMiLmM.js → useRootScrollLock-BrNPOsn7.js} +2 -2
  98. package/dist/assets/{useWalkthroughReview-DeioHUwn.js → useWalkthroughReview-kBvgTX6M.js} +1 -1
  99. package/dist/assets/{useWholeFileComment-3Adypnae.js → useWholeFileComment-DrynMs0_.js} +1 -1
  100. package/dist/assets/{useWorktreeArchiveActions-D57vyZ1C.js → useWorktreeArchiveActions-CewTlnGF.js} +1 -1
  101. package/dist/assets/{vendor-codemirror-language-data-CVww3XgZ.js → vendor-codemirror-language-data-BJfFTbvV.js} +2 -2
  102. package/dist/assets/{zh-CN-CNdkQtjY.js → zh-CN-C4Ip1vNN.js} +1 -1
  103. package/dist/assets/{zh-TW-njZbI3nO.js → zh-TW-BmwR7rb1.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 Le,r as He}from"./vendor-react--VO_rL_p.js";import{u as Ys,c as al}from"./vendor-zustand-C9tWdk0j.js";import{u as Oe,I as ee,dz as Fs,mB as ot,aL as xn,am as bp,ae as Yt,B as G,z as Gn,A as Q,mC as Zr,aG as Ve,x as qa,n as ks,bj as cu,b2 as Xa,Y as In,aM as Ia,a1 as il,Q as Ye,bo as xp,d7 as Do,dc as vp,bs as $t,br as Ft,bu as bt,bt as Lt,bq as Kt,y as Qe,mD as Jn,mE as du,mF as yp,d$ as zo,mG as Xr,mH as kp,mI as Oi,mJ as ua,t as Ut,q as zt,D as Bt,l as Vt,F as Ht,o as ns,mK as vr,a4 as Pa,a5 as wa,bf as Gi,bg as Ji,a3 as Aa,a2 as Ta,be as Qi,bd as Yi,kh as Qn,ki as Kn,mL as cs,d1 as us,mM as yr,gM as Wt,V as gt,fl as Tt,cS as $s,fn as ja,mN as Cn,fV as Ts,mO as is,fs as js,mP as ws,mQ as uu,mR as jp,mS as mt,mT as mu,mU as wp,mV as Sp,mW as zi,mX as Np,ex as Xn,mY as hn,mZ as ii,kk as Js,m_ as ei,m$ as pu,n0 as kr,fo as jr,a9 as za,n1 as Gl,n2 as Cp,n3 as ec,n4 as Ip,cV as ol,n5 as tc,gU as Ha,kj as Gt,R as wr,n6 as Sr,n7 as Ka,n8 as gu,n9 as fu,na as Nr,kl as qn,gG as _a,nb as Pp,k_ as Zi,C as oi,aQ as sc,cH as Ap,a$ as Tp,cO as Ep,bc as Mp,ft as Rp,cg as Dp,fu as Op,K as Cr,bE as ui,g6 as Bi,lo as hu,nc as Fp,nd as Lp,d3 as Kp,ne as _p,au as Xi,d5 as Un,nf as es,ng as bu,nh as $p,ni as aa,gW as Qs,nj as ll,nk as Wn,nl as Bo,nm as Up,nn as zp,no as Bp,np as xu,nq as Vp,nr as vu,fW as yu,ns as rl,jg as Is,jh as ku,mv as Vo,eJ as ju,eI as Hp,je as Wp,jf as wu,mw as qp,nt as Gp,nu as Jp,nv as Qp,nw as nc,d2 as Su,nx as Yp,ny as Zp,nz as Xp,nA as eg,nB as tg,nC as Nu,nD as sg,nE as ng,nF as ag,nG as ig,nH as og,nI as lg,nJ as li,nK as rg,nL as cg,nM as Cu,nN as dg,nO as Es,gV as Wa,bS as cn,bT as cl,nP as ug,k$ as Iu,gH as mg,gR as pg,hB as gg,nQ as fg,nR as hg,nS as dl,kM as eo,nT as to,da as bg,db as kl,d9 as Pu,k6 as Au,nU as jl,nV as xg,nW as vg,nX as yg,nY as kg,nZ as jg,n_ as wg,n$ as Sg,o0 as Ng,bN as qs,o1 as Ir,km as Dn,bO as Pr,o2 as Mn,kZ as Cg,o3 as Ig,o4 as Pg,o5 as ri,eE as Ag,o6 as Ho,o7 as va,o8 as Ei,o9 as Tg,oa as Eg,ob as Mg,gN as Rg,oc as gn,od as Gs,oe as Fa,of as ia,og as ac,oh as Oo,oi as Dg,ak as Og,oj as Tu,ok as $a,ol as Fg,om as Lg,k as Ar,on as Kg,es as _g,aE as $g,aD as Ug,cu as zg,dd as Bg,az as Vg,aC as Hg,oo as Wg,bp as qg,k0 as Gg,op as Vi,oq as yi,or as ic,os as na,ot as ka,ou as Jg,ov as Qg,ow as Yg,ox as Zg,oy as wl,oz as oc,oA as Xg,oB as ef,oC as tf,oD as sf,oE as nf,oF as lc,oG as ki,oH as rc,oI as Tr,oJ as af,$ as of,aV as cc,fk as lf,oK as rf,oL as cf,oM as Sl,oN as dc,oO as df,f as la,h as Ba,oP as uc,oQ as uf,oR as mf,oS as pf,oT as ul,oU as gf,av as da,oV as ff,oW as hf,oX as bf,gr as xf,oY as ml,kp as oa,oZ as vf,o_ as yf,o$ as Fi,aw as kf,ay as Eu,ey as jf,a_ as Da,aa as wf,ab as Sf,ez as Nf}from"./useAppFontEffects-UKWR--vP.js";import{j as qt,c9 as Mu,dj as Cf,dk as Jl,dl as If,bG as bn,dm as Pf,z as St,u as ie,l as ms,dn as Hi,dp as Li,dq as ra,dr as Ru,ds as Af,t as fn,dt as Tf,aL as Ea,aI as Jt,cA as Er,bS as Ef,bi as bs,aO as mi,bA as Nl,bD as mc,bB as pc,bJ as ji,ci as Mf,du as Rf,cf as Df,bK as ya,dv as Of,d4 as gc,bC as Ff,dw as Lf,dx as Kf,ca as fc,bZ as so,d8 as _f,dy as $f,dz as Du,dA as Ot,dB as Uf,aK as no,bX as zf,bY as Bf,bT as Mr,bb as Rr,co as Vf,bR as Hf,aZ as pl,cn as Va,dC as Ou,bW as Wo,bd as Fu,dD as Wf,dE as Lu,dF as qf,dG as Gf,bI as Dr,dH as Jf,v as qo,bq as Qf,bj as Ki,dI as Yf,dJ as Ga,dK as hc,dL as bc,dM as xc,dN as vc,dO as Zf,dP as yc,c7 as Xf,M as Ku,dQ as ao,dR as eh,aM as kc,dS as th,dT as sh,r as Ql,dU as nh,dV as jc,dW as ah,b as ih,dX as oh,dY as lh,dZ as rh,d_ as ch,d$ as dh,bE as _u,e0 as $u,e1 as uh,e2 as Yl,e3 as mh,e4 as ph,e5 as gh,e6 as fh,e7 as Uu,e8 as hh,e9 as bh,ea as xh,eb as Zl,ec as wc,ed as vh,ee as Sc,ef as xo,eg as yh,eh as kh,ei as jh,cs as wh,cm as Sh,b_ as Nh,ej as Ch,ek as Ih,el as Ph,em as Ah}from"./katex.min-BM3LOlr3.js";import{aD as Th,ca as Eh,c3 as Cl,c4 as Mh,cb as Rh,cc as Dh,cd as ss,ce as Oh,cf as pi,cg as Os,ch as Wi,ci as Yn,cj as ci,ck as gl,cl as io,cm as di,O as Sa,K as Na,L as Ca,cn as Fh,bL as Ws,co as Lh,cp as Kh,c1 as _h,cq as $h,cr as Uh,cs as zh,bK as Bh,ct as Vh,cu as La,b3 as Xl,ad as Hh,ae as Wh,cv as qh}from"./runtimeEndpointReset-IJE1o-nk.js";import{o as ts,s as Et,e as oo,l as Gh,d as un,n as qi,a as ca,f as Go,_ as fl,u as er}from"./vendor-zod-Csf1sqWl.js";import{n as Jh,M as zu,r as Qh,b as Yh,a as Zh,g as Xh,c as eb,d as tb,e as sb,P as nb,f as ab,h as ib,j as ob,k as Bu,u as Vu,i as Hu,s as Wu,l as lb,m as rb}from"./install-T6u73Zz0.js";import{s as cb,c as db}from"./vendor-yaml-CE-D_49-.js";import{c as Nc,C as Cc,p as ub}from"./flexokiTheme-BL4fG_5M.js";import{u as mb}from"./vendor-tanstack-react-virtual-CqfECoM0.js";import{m as pb}from"./vendor-tanstack-virtual-core-BdFnkr_2.js";import{c as gb}from"./codeHighlight-BYbxdxkk.js";import{getCodeTokenTheme as fb,getThemeRenderName as hb}from"./appThemeRegistry-Dk6CF03D.js";import{E as Ic}from"./vendor-codemirror-view-Ciie9ey-.js";import{Q as qu}from"./vendor-qrcode-Cl8OheHW.js";import{toast as ti}from"./vendor-sonner-Dw26OnzC.js";import{s as bb}from"./vendor-strip-json-comments-5dJlOkP1.js";import{c as xb,h as vb,a as yb,b as kb,P as jb}from"./vendor-base-ui-zhBy6TEG.js";import{u as wb}from"./useCallableModelProviders-BVbgbn_M.js";import{r as Gu,s as Sb}from"./pageTitle-DcFkBvgW.js";import{S as Or,f as Jo}from"./SpaceRow-DnnOnMYM.js";import{_ as Nb}from"./vendor-vite-runtime-DD1OZmLC.js";import{A as Pc}from"./AboutLogo-Bghz4cno.js";const Ac=({label:t})=>{const{t:e}=Oe(),[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 qt("/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:()=>{Fs(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(ot,{label:t,controlClassName:"min-h-8",children:o}):o},Tc="https://github.com/openchamber/openchamber",Ec="https://discord.gg/ZYRSdnwwKA",Mc="https://x.com/openchamber_dev",Cb=800,Ib=async t=>{const e=await bn();return e?e.serverUpdateChannel??(Jl(t)?"canary":"stable"):null},Pb={info:null,checking:!1,available:!1,error:null};function Ab(t){const e=Le.c(5),[n,a]=m.useState(Pb);let i;e[0]!==t?(i=async()=>{if(t){a(Tb);try{const r=await Mh();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 Tb(t){return{...t,checking:!0,error:null}}function Eb(t){const e=Le.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 x=await Rh();return a(x),x}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 x=await Dh(t);l({kind:"installed",version:x})}catch(x){const y=x;l({kind:"failed",error:y instanceof Error?y.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 x=>{await x().catch(Mb);const y=await u();y?.currentVersion&&l(v=>v.kind!=="installed"||v.version&&v.version.replace(/^v/,"")!==y.currentVersion?v:{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 Mb(){}function Rb(t){const[e,n]=m.useState(null);return m.useEffect(()=>{if(!t)return;let a=!1;return Nb(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 Db=({initialUpdateDialogOpen:t=!1})=>{const{t:e}=Oe(),[n,a]=m.useState(t),[i,o]=m.useState(!1),[l,r]=m.useState(null),u=Th(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}=xn(),c=m.useMemo(()=>Mu(),[]),p=Eh(),g=Ab(c||p),f=p?g:null,h=g.check;m.useEffect(()=>{p&&h()},[p,h]);const[b,x]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{if(!p)return;let me=!1;return bp().then(ne=>{me||v(ne)}),()=>{me=!0}},[p]);const w=Rb(c),k=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,ne)=>{const he=Jl(me);return he?e("settings.openchamber.about.canaryVersion",{version:he.release,date:If(he,qa(),Jl(ne))}):me},j=k.available?k.info?.version:null,P=N(l||k.info?.currentVersion||"unknown",j),C=N(y||u.info?.currentVersion||"unknown",j),I=l||f?.info?.currentVersion||"unknown",S=u.runtimeType==="desktop",[A,T]=m.useState(!1),D=u.runtimeType==="web"&&A&&l!==null,[R,O]=m.useState(null);m.useEffect(()=>{if(!S&&!D)return;let me=!1;return(S?Cf():Ib(l??"")).then(he=>{me||O(he)}),()=>{me=!0}},[S,D,l]);const F=Eb(e("opencodeUpdate.toast.failed.description")),E=F.status?.currentVersion??null,M=F.phase.kind==="installed"?null:F.status?.availableVersion??null,[L,z]=m.useState(!1),$=me=>{const ne=N(me?.version||"",me?.currentVersion);return me?.packageManager==="electron"?e("settings.openchamber.about.actions.updateDesktopToVersion",{version:ne}):e("settings.openchamber.about.actions.updateServerToVersion",{version:ne})},W=(()=>{const me=N(k.info?.version||"",k.info?.currentVersion);return c?$(k.info):p?e("settings.openchamber.about.actions.updateAppToVersion",{version:me}):e("settings.openchamber.about.actions.updateOpenChamberToVersion",{version:me})})(),U=me=>!!me?.installBlocked,H=k.available&&U(k.info),K=!!(f?.available&&U(f.info)),_=async me=>{if(me===R)return;const ne=R;if(O(me),!(S?await Pf(me)===me:(await St({serverUpdateChannel:me})).ok)){O(ne),Q.error(e("settings.openchamber.about.toast.updateChannelNotSaved"));return}k.checkForUpdates()},q=R&&s.jsx(Yt,{value:R,onChange:me=>{_(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=()=>{k.checkForUpdates(),f&&f.check(),F.refresh()},ae=async me=>{(await Xa(me)).ok&&(z(!0),setTimeout(()=>z(!1),2e3))},ce=()=>{F.reloadAfterUpgrade(async()=>{await cu({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 ne=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(ks,{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:ne}),s.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{ae(ne)},"aria-label":e(L?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:s.jsx(ee,{name:L?"check":"clipboard",className:"size-4"})})]})]})},de=H?J(k.info):null,pe=!f?.available||f.checking?null:K?J(f.info):s.jsxs(G,{type:"button",size:"sm",variant:"outline",onClick:()=>x(!0),children:[s.jsx(ee,{name:"download",className:"size-4"}),$(f.info)]}),fe=f?s.jsx(Cl,{open:b,onOpenChange:x,info:f.info,downloading:!1,downloaded:!1,progress:null,error:f.error,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"}):null,ve=(()=>{const{phase:me}=F;if(me.kind==="installed")return{action:s.jsx(G,{type:"button",size:"sm",variant:"outline",onClick:ce,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(!M)return null;if(!F.status?.supported)return{action:null,note:s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.openCode.manualUpdate",{version:M})})};const ne=me.kind==="upgrading";return{action:s.jsxs(G,{type:"button",size:"sm",variant:"outline",onClick:()=>{F.upgrade()},disabled:ne,children:[ne?s.jsx(Gn,{className:"size-4"}):s.jsx(ee,{name:"download",className:"size-4"}),ne?e("opencodeUpdate.toast.upgrading.title"):e("settings.openchamber.about.actions.updateOpenCodeToVersion",{version:M})]}),note:me.kind==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:me.error}):null}})(),ye=ve?s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[ve.note,ve.action]}):null;m.useEffect(()=>{let me=!1;return(async()=>{try{const he=await qt("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!he.ok)return;const Re=await he.json().catch(()=>null),ke=typeof Re?.openchamberVersion=="string"&&Re.openchamberVersion.trim().length>0?Re.openchamberVersion.trim():null;me||(r(ke),T(Re?.runtime==="web"))}catch{me||r(null)}})(),()=>{me=!0}},[]);const Ae=f?.checking??!1,te=f?.available??!1,Y=m.useRef(!1);m.useEffect(()=>{if(k.checking)o(!0),Y.current=!0;else if(i){const me=setTimeout(()=>{o(!1);const ne=Ae||te;Y.current&&!k.available&&!k.error&&!ne&&(Q.success(e(c?"settings.openchamber.about.toast.serverLatestVersion":"settings.openchamber.about.toast.latestVersion")),Y.current=!1)},Cb);return()=>clearTimeout(me)}},[e,c,k.checking,i,k.available,k.error,Ae,te]);const ue=k.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(Pc,{size:72}),s.jsx("h2",{className:`mt-4 ${Zr}`,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:P})}),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:I})}),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:P})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:E||e("settings.openchamber.about.state.unknown")})})]})}),s.jsx(Ac,{})]}),q&&s.jsx("div",{className:"flex justify-center",children:q}),s.jsxs("div",{className:"flex justify-center",children:[!k.available&&!k.error&&s.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:X,disabled:ue,className:"w-auto justify-center gap-2",children:[ue?s.jsx(Gn,{className:"size-4"}):s.jsx(ee,{name:"refresh",className:"size-4"}),e(ue?"settings.openchamber.about.state.checking":c?"settings.openchamber.about.actions.checkServerForUpdates":"settings.openchamber.about.actions.checkForUpdates")]}),!ue&&k.available&&!H&&s.jsxs(G,{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]})]}),de,pe&&s.jsx("div",{className:"flex justify-center text-center",children:pe}),ye&&s.jsx("div",{className:"flex justify-center text-center",children:ye}),[k.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: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:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),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:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:Mc,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(Cl,{open:n,onOpenChange:a,info:k.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:k.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:k.runtimeType}),fe]});const be=s.jsx("span",{"aria-hidden":"true",className:"typography-meta text-muted-foreground/60",children:"·"}),Ie=ue?s.jsxs(s.Fragment,{children:[be,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")]})]}):k.available&&!H?s.jsxs(G,{size:"sm",variant:"default",onClick:()=>a(!0),children:[s.jsx(ee,{name:"download",className:"size-4"}),W]}):!k.available&&!k.error?s.jsxs(s.Fragment,{children:[be,s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")})]}):null,Te=me=>s.jsx("span",{className:"typography-meta font-mono text-muted-foreground",children:me}),Fe="min-h-8 flex-wrap @xl:flex-initial",xe=[de,K?pe:null,ve?.note??null,...[k.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(Ve,{divider:!1,children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(Pc,{size:48}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("h2",{className:Zr,children:"OpenChamber"}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[{href:Tc,icon:"github-fill",label:"GitHub"},{href:Ec,icon:"discord-fill",label:"Discord"},{href:Mc,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(Ve,{contentClassName:"space-y-4",children:[s.jsxs("div",{children:[p?s.jsxs(s.Fragment,{children:[s.jsxs(ot,{label:e("settings.openchamber.about.field.appVersion"),controlClassName:Fe,children:[Te(C),Ie]}),s.jsxs(ot,{label:e("settings.openchamber.about.field.serverVersion"),controlClassName:Fe,children:[Te(I),K?null:pe]})]}):s.jsxs(ot,{label:e("settings.openchamber.about.field.version"),controlClassName:Fe,children:[Te(P),Ie]}),s.jsxs(ot,{label:e("settings.openchamber.about.field.updateChannel"),info:q?e("settings.openchamber.about.field.updateChannelHint"):void 0,controlClassName:Fe,children:[q,s.jsx(G,{size:"sm",variant:"outline",onClick:X,disabled:ue,children:e("settings.openchamber.about.actions.checkForUpdates")})]}),s.jsxs(ot,{label:e("settings.openchamber.about.field.openCodeVersion"),controlClassName:Fe,children:[Te(E||e("settings.openchamber.about.state.unknown")),ve?.action]}),s.jsx(Ac,{label:e("settings.openchamber.about.field.instanceUrls")})]}),xe.length>0&&s.jsx("div",{className:"space-y-3",children:xe})]}),s.jsx(Cl,{open:n,onOpenChange:a,info:k.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:k.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:k.runtimeType}),fe]})},Ob=(t,e,n)=>t&&e.some(i=>i.path===t)?t:(e.find(i=>i.id===n)??e[0])?.path??null,vn=()=>{const t=Le.c(4),e=ie(Fb),n=In(Lb),a=In(Kb);let i;return t[0]!==a||t[1]!==n||t[2]!==e?(i=Ob(e,n,a),t[0]=a,t[1]=n,t[2]=e,t[3]=i):i=t[3],i};function Fb(t){return t.settingsProjectPath}function Lb(t){return t.projects}function Kb(t){return t.activeProjectId}const tr=al(t=>({tab:"general",setTab:e=>t({tab:e})})),_b=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"]]),$b=t=>_b.get(t)??null,sr=al(t=>({tab:"messages",setTab:e=>t({tab:e})})),Ub=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"]]),zb=t=>Ub.get(t)??null,gi=t=>{const e=Le.c(73),{className:n}=t,{t:a}=Oe(),{currentTheme:i}=Ia(),o=ie(Bb),[l,r]=m.useState(!1),u=il(In(Vb)),d=vn(),c=ie(Hb),p=ms();let g;e[0]!==d||e[1]!==u?(g=u.find(A=>A.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=A=>{const T=u.find(D=>D.id===A);T&&c(T.path)},e[3]=c,e[4]=u,e[5]=h):h=e[5];const b=h;if(o){let A;e[6]!==n?(A=Ye(n),e[6]=n,e[7]=A):A=e[7];let T;e[8]!==a?(T=a("settings.shared.projectSelector.switchProjectAria"),e[8]=a,e[9]=T):T=e[9];let D;e[10]!==a?(D=a("settings.shared.projectSelector.switchProjectTitle"),e[10]=a,e[11]=D):D=e[11];let R,O;e[12]===Symbol.for("react.memo_cache_sentinel")?(R=()=>r(!0),O=Ye(xp({size:"touch"}),"w-full min-w-0"),e[12]=R,e[13]=O):(R=e[12],O=e[13]);let F;e[14]!==f||e[15]!==i?(F=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]=F):F=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 M;e[18]!==l||e[19]!==T||e[20]!==D||e[21]!==O||e[22]!==F?(M=s.jsxs("button",{type:"button","aria-label":T,title:D,"aria-haspopup":"dialog","aria-expanded":l,onClick:R,className:O,children:[F,E]}),e[18]=l,e[19]=T,e[20]=D,e[21]=O,e[22]=F,e[23]=M):M=e[23];let L;e[24]!==M||e[25]!==A?(L=s.jsx("div",{className:A,children:M}),e[24]=M,e[25]=A,e[26]=L):L=e[26];let z;e[27]===Symbol.for("react.memo_cache_sentinel")?(z=()=>r(!1),e[27]=z):z=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 U;e[30]!==a?(U=a("settings.shared.projectSelector.searchPlaceholder"),e[30]=a,e[31]=U):U=e[31];let H;e[32]!==f.id||e[33]!==i||e[34]!==b||e[35]!==l||e[36]!==u||e[37]!==W||e[38]!==U?(H=s.jsx(vp,{open:l,onClose:z,projects:u,selectedProjectId:$,onSelectProject:b,theme:i,title:W,searchPlaceholder:U}),e[32]=f.id,e[33]=i,e[34]=b,e[35]=l,e[36]=u,e[37]=W,e[38]=U,e[39]=H):H=e[39];let K;return e[40]!==L||e[41]!==H?(K=s.jsxs(s.Fragment,{children:[L,H]}),e[40]=L,e[41]=H,e[42]=K):K=e[42],K}let x;e[43]!==n?(x=Ye(n),e[43]=n,e[44]=x):x=e[44];const y=f.id;let v;e[45]!==b?(v=A=>{A&&b(A)},e[45]=b,e[46]=v):v=e[46];let w;e[47]!==a?(w=a("settings.shared.projectSelector.switchProjectAria"),e[47]=a,e[48]=w):w=e[48];let k;e[49]!==a?(k=a("settings.shared.projectSelector.switchProjectTitle"),e[49]=a,e[50]=k):k=e[50];let N;e[51]!==f||e[52]!==i?(N=s.jsx($t,{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]!==k||e[56]!==N?(j=s.jsx(Ft,{className:"w-full","aria-label":w,title:k,children:N}),e[54]=w,e[55]=k,e[56]=N,e[57]=j):j=e[57];let P;if(e[58]!==i||e[59]!==u){let A;e[61]!==i?(A=T=>s.jsx(bt,{value:T.id,className:"max-w-[24rem] truncate",children:s.jsx(Do,{project:T,theme:i})},T.id),e[61]=i,e[62]=A):A=e[62],P=u.map(A),e[58]=i,e[59]=u,e[60]=P}else P=e[60];let C;e[63]!==P?(C=s.jsx(Lt,{fitContent:!0,children:P}),e[63]=P,e[64]=C):C=e[64];let I;e[65]!==f.id||e[66]!==C||e[67]!==v||e[68]!==j?(I=s.jsxs(Kt,{value:y,onValueChange:v,children:[j,C]}),e[65]=f.id,e[66]=C,e[67]=v,e[68]=j,e[69]=I):I=e[69];let S;return e[70]!==I||e[71]!==x?(S=s.jsx("div",{className:x,children:I}),e[70]=I,e[71]=x,e[72]=S):S=e[72],S};function Bb(t){return t.isMobile}function Vb(t){return t.projects}function Hb(t){return t.setSettingsProjectPath}const Fr=t=>{const e=Le.c(16),{value:n,onChange:a}=t,{t:i}=Oe();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(Qe,{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},Lr=t=>{const e=Le.c(5),{query:n}=t,{t:a}=Oe();let i;e[0]!==n||e[1]!==a?(i=a("settings.common.sidebar.noMatches",{query:n.trim()}),e[0]=n,e[1]=a,e[2]=i):i=e[2];let o;return e[3]!==i?(o=s.jsx("p",{className:"px-2 py-6 text-center typography-meta text-muted-foreground",children:i}),e[3]=i,e[4]=o):o=e[4],o};function Wb(t,e){return`opencode:sidebar-group:${t}:${e}`}const nr=t=>{const e=Le.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=Wb(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 A=localStorage.getItem(d);if(A!==null)return A==="true"}catch{}return r},e[3]=r,e[4]=d,e[5]=p):p=e[5];const[g,f]=He.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]),He.useEffect(h,b);let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=()=>f(qb),e[10]=x):x=e[10];let y;e[11]===Symbol.for("react.memo_cache_sentinel")?(y=Ye("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]=y):y=e[11];const v=!g&&"-rotate-90 rtl:rotate-90";let w;e[12]!==v?(w=Ye("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",v),e[12]=v,e[13]=w):w=e[13];let k;e[14]!==w?(k=s.jsx(ee,{name:"arrow-down-s",className:w}),e[14]=w,e[15]=k):k=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 P;e[20]!==c||e[21]!==g||e[22]!==k||e[23]!==N||e[24]!==j?(P=s.jsxs("button",{type:"button",onClick:x,"aria-expanded":g,"aria-controls":c,className:y,children:[k,N,j]}),e[20]=c,e[21]=g,e[22]=k,e[23]=N,e[24]=j,e[25]=P):P=e[25];const C=!g;let I;e[26]!==l||e[27]!==c||e[28]!==C?(I=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]=I):I=e[29];let S;return e[30]!==P||e[31]!==I?(S=s.jsxs("div",{children:[P,I]}),e[30]=P,e[31]=I,e[32]=S):S=e[32],S};function qb(t){return!t}const Gb=({onItemSelect:t})=>{const{t:e}=Oe(),[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:x,createAgent:y,deleteAgent:v,loadAgents:w,loadDisabledAgents:k,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}))),P=vn(),C=Jn(J=>du(J,P)),I=Jn(J=>yp(J,P)),[S,A]=m.useState(null);m.useEffect(()=>{w(P),k(P)},[w,k,P]);const T=C.filter(J=>zo(J.mode)&&!Xr(J)).length,D=J=>!(zo(J.mode)&&!Xr(J)&&T<=1),R=async(J,de)=>{A(J);try{await N(J,{disabled:de},P),de&&h===J&&b(null),Q.success(de?e("settings.agents.sidebar.toast.agentDisabled",{name:J}):e("settings.agents.sidebar.toast.agentEnabled",{name:J}))}catch{Q.error(e(de?"settings.agents.sidebar.toast.disableFailed":"settings.agents.sidebar.toast.enableFailed"))}finally{A(null)}},O=I.filter(J=>Hi([J.name,J.description],n)),F="bg-background",E=()=>{const J="new-agent";let de=J,pe=1;for(;C.some(fe=>fe.name===de);)de=`${J}-${pe}`,pe++;x({name:de,scope:"user"}),b(de),t?.()},M=async J=>{if(Oi(J)){Q.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}d(J)},L=()=>{d(null)},z=async()=>{if(u){p(!0);try{(await v(u.name,u.scope,P)).ok?(Q.success(e("settings.agents.sidebar.toast.agentDeleted",{name:u.name})),L()):Q.error(e("settings.agents.sidebar.toast.deleteFailed"))}catch(J){const de=J instanceof Error?J.message:"",pe=/built-in|not deletable|not found/i.test(de);Q.error(e(pe?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed"))}p(!1)}},$=async J=>{const de=J.name;let pe=1,fe=`${de}-copy`;for(;C.some(te=>te.name===fe);)pe++,fe=`${de}-copy-${pe}`;const ve=J,ye=await j(J.name,P);if(!ye){Q.error(e("settings.agents.sidebar.toast.renameFailed"));return}const Ae=ye.config.request?.body;x({name:fe,scope:ye.scope??ve.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:Ae?.temperature,top_p:Ae?.top_p,mode:ye.config.mode??ve.mode,permissions:ye.config.permissions??void 0,hidden:ye.config.hidden}),b(fe),t?.()},W=J=>{r(J.name),o(J)},U=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(ve=>ve.name===J)){Q.error(e("settings.agents.sidebar.toast.agentExists"));return}const de=i,pe=await j(i.name,P);if(!pe){Q.error(e("settings.agents.sidebar.toast.renameFailed"));return}(await y({...pe.config,name:J,scope:pe.scope??de.scope},P)).ok?(await v(i.name,de.scope,P)).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)},H=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}},K=new Set(I.map(J=>J.name)),_=C.filter(J=>kp(J)&&!K.has(J.name)),V=_.filter(J=>Hi([J.name,J.description],n)),q=V.filter(Oi),X=V.filter(J=>!Oi(J)),{groupedCustomAgents:ae,ungroupedCustomAgents:ce}=He.useMemo(()=>{const J={},de=[];for(const fe of X){const ve=fe;ve.group?(J[ve.group]||(J[ve.group]=[]),J[ve.group].push(fe)):de.push(fe)}return{groupedCustomAgents:Object.keys(J).sort((fe,ve)=>fe.localeCompare(ve)).map(fe=>({name:fe,agents:J[fe]})),ungroupedCustomAgents:de}},[X]);return s.jsxs("div",{className:Ye("flex h-full flex-col",F),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(gi,{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:_.length})}),s.jsx(G,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:E,children:s.jsx(ee,{name:"add",className:"h-3.5 w-3.5"})})]}),_.length>0?s.jsx(Fr,{value:n,onChange:a}):null]}),s.jsxs(ks,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:[_.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")})]}):V.length===0?s.jsx(Lr,{query:n}):s.jsxs(s.Fragment,{children:[q.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.builtIn")}),q.map(J=>s.jsx(Il,{agent:J,isSelected:h===J.name,onSelect:()=>{b(J.name),t?.()},onDuplicate:()=>{$(J)},onDisable:D(J)?()=>{R(J.name,!0)}:void 0,getAgentModeIcon:H,isMenuOpen:g===J.name,onMenuOpenChange:de=>f(de?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:de})=>s.jsx(nr,{label:J,count:de.length,storageKey:"agents",children:de.map(pe=>s.jsx(Il,{agent:pe,isSelected:h===pe.name,onSelect:()=>{b(pe.name),t?.()},onRename:()=>W(pe),onDelete:()=>M(pe),onDuplicate:()=>{$(pe)},onDisable:D(pe)?()=>{R(pe.name,!0)}:void 0,getAgentModeIcon:H,isMenuOpen:g===pe.name,onMenuOpenChange:fe=>f(fe?pe.name:null)},pe.name))},J)),ce.map(J=>s.jsx(Il,{agent:J,isSelected:h===J.name,onSelect:()=>{b(J.name),t?.()},onRename:()=>W(J),onDelete:()=>M(J),onDuplicate:()=>{$(J)},onDisable:D(J)?()=>{R(J.name,!0)}:void 0,getAgentModeIcon:H,isMenuOpen:g===J.name,onMenuOpenChange:de=>f(de?J.name:null)},J.name))]})]}),O.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.disabled")}),O.map(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(G,{size:"xs",variant:"outline",disabled:S===J.name,onClick:()=>{R(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(Ut,{open:u!==null,onOpenChange:J=>{!J&&!c&&L()},children:s.jsxs(zt,{className:"max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(Vt,{children:e("settings.agents.sidebar.dialog.deleteTitle")}),s.jsx(Ht,{children:e("settings.agents.sidebar.dialog.deleteDescription",{name:u?.name??""})})]}),s.jsxs(ns,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:L,disabled:c,children:e("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",onClick:z,disabled:c,children:e("settings.common.actions.delete")})]})]})}),s.jsx(Ut,{open:i!==null,onOpenChange:J=>!J&&o(null),children:s.jsxs(zt,{children:[s.jsxs(Bt,{children:[s.jsx(Vt,{children:e("settings.agents.sidebar.renameDialog.title")}),s.jsx(Ht,{children:e("settings.agents.sidebar.renameDialog.description",{name:i?.name??""})})]}),s.jsx(Qe,{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"&&U()}}),s.jsxs(ns,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:()=>o(null),children:e("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",onClick:U,children:e("settings.common.actions.rename")})]})]})})]})},Il=t=>{const e=Le.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}=Oe(),f=n;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=vr(),e[0]=h):h=e[0];const b=h,[x,y]=m.useState(!1);let v;e[1]!==o||e[2]!==u||e[3]!==r||e[4]!==l||e[5]!==g?(v=W=>s.jsxs(s.Fragment,{children:[l&&s.jsxs(W,{onClick:U=>{U.stopPropagation(),l()},children:[s.jsx(ee,{name:"edit",className:"h-4 w-4 me-px"}),g("settings.common.actions.rename")]}),s.jsxs(W,{onClick:U=>{U.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:U=>{U.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:U=>{U.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]=v):v=e[6];const w=v,k=a?"bg-interactive-selection":"hover:bg-interactive-hover";let N;e[7]!==k?(N=Ye("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",k),e[7]=k,e[8]=N):N=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=b?void 0:W=>{W.preventDefault(),y(!0)},e[9]=j):j=e[9];let P;e[10]!==N?(P=s.jsx("div",{className:N,onContextMenu:j}),e[10]=N,e[11]=P):P=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 I;e[14]!==n.mode||e[15]!==d?(I=d(n.mode),e[14]=n.mode,e[15]=d,e[16]=I):I=e[16];let S;e[17]!==n||e[18]!==f.scope||e[19]!==g?(S=(f.scope||Oi(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:Oi(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 A;e[21]!==C||e[22]!==I||e[23]!==S?(A=s.jsxs("div",{className:"flex items-center gap-1.5",children:[C,I,S]}),e[21]=C,e[22]=I,e[23]=S,e[24]=A):A=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 D;e[27]!==i||e[28]!==A||e[29]!==T?(D=s.jsxs("button",{onClick:i,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,children:[A,T]}),e[27]=i,e[28]=A,e[29]=T,e[30]=D):D=e[30];let R;e[31]!==p?(R=W=>{W&&y(!1),p(W)},e[31]=p,e[32]=R):R=e[32];let O;e[33]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(Aa,{asChild:!0,children:s.jsx(G,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -me-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(ee,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=O):O=e[33];let F;e[34]!==w?(F=s.jsx(Pa,{align:"end",className:"w-fit min-w-20",children:w(wa)}),e[34]=w,e[35]=F):F=e[35];let E;e[36]!==c||e[37]!==R||e[38]!==F?(E=s.jsxs(Ta,{open:c,onOpenChange:R,children:[O,F]}),e[36]=c,e[37]=R,e[38]=F,e[39]=E):E=e[39];let M;e[40]!==D||e[41]!==E?(M=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[D,E]}),e[40]=D,e[41]=E,e[42]=M):M=e[42];let L;e[43]!==M||e[44]!==P?(L=s.jsx(Qi,{render:P,children:M}),e[43]=M,e[44]=P,e[45]=L):L=e[45];let z;e[46]!==w?(z=s.jsx(Gi,{className:"w-fit min-w-20",children:w(Ji)}),e[46]=w,e[47]=z):z=e[47];let $;return e[48]!==x||e[49]!==L||e[50]!==z?($=s.jsxs(Yi,{open:x,onOpenChange:y,children:[L,z]}),e[48]=x,e[49]=L,e[50]=z,e[51]=$):$=e[51],$},dn={ok:!0,changed:!1},Zn={ok:!0,changed:!0},Ps=t=>({ok:!1,reason:t}),Jb=t=>t instanceof HTMLElement?t.matches('input, textarea, [contenteditable="true"]'):!1,fi=t=>{const{t:e}=Oe(),[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=>{Jb(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}},Qb=["allow","ask","deny"],Yb=["shell","edit","read","glob","grep","patch","webfetch","websearch","skill","subagent","question","external_directory"],Zb=["openchamber","openchamber_schedule","openchamber_web","openchamber_memory","openchamber_knowledge","openchamber_notify","openchamber_render","openchamber_image","openchamber_secret"],Xb=new Set(["bash","task","write","list","lsp","todowrite","todoread","multiedit","doom_loop","plan_enter","plan_exit"]),Ju=t=>Xb.has(t),e1=[{action:"*",resource:"*",effect:"allow"},{action:"read",resource:"*.env",effect:"ask"},{action:"read",resource:"*.env.*",effect:"ask"},{action:"read",resource:"*.env.example",effect:"allow"}],Rc=()=>({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}))}]))}),t1=t=>{const e={global:null,keys:{},source:t.map(n=>({...n}))};for(const n of t){if(Ju(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},s1=t=>t.action!=="*"||t.resource==="*",Ua=(t,e)=>`${t}\0${e}`,n1=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},ar=t=>{const e=n1(t),n=new Set,a=[];for(const o of t.source){if(Ju(o.action))continue;if(!s1(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},a1=(t,e)=>JSON.stringify(ar(t))===JSON.stringify(ar(e)),i1=(t,e)=>{const n=[...e1,...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},o1=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),l1=new Set(["shell","edit","read","glob","grep","patch","webfetch","skill","subagent","external_directory"]),r1={effect:null,patterns:[]},c1=t=>{const e=Le.c(163),{agent:n,registerSave:a,requestSave:i}=t,{t:o}=Oe(),l=Jn(d1),r=Jn(u1);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(Rc),[f,h]=m.useState(Rc),[b,x]=m.useState(!0),[y,v]=m.useState(!1);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w={},e[1]=w):w=e[1];const[k,N]=m.useState(w),[j,P]=m.useState(""),[C,I]=m.useState(0),S=n.name,A=vn(),T=Qn(m1);let D;e[2]!==A?(D=Ge=>yr(Ge,A),e[2]=A,e[3]=D):D=e[3];const R=Qn(D);let O;e[4]!==A?(O=Ge=>Ge.getStatusForDirectory(A),e[4]=A,e[5]=O):O=e[5];const F=Kn(O);let E,M;e[6]!==T||e[7]!==A?(E=()=>{T({directory:A})},M=[T,A],e[6]=T,e[7]=A,e[8]=E,e[9]=M):(E=e[8],M=e[9]),m.useEffect(E,M);let L;e[10]!==S||e[11]!==r||e[12]!==A?(L=()=>{let Ge=!1;return x(!0),v(!1),(async()=>{const ft=await r(S,A);if(Ge)return;if(!ft){v(!0),x(!1);return}const ct=t1(ft.agent);c(ft.global),g(Oa(ct)),h(ct),N({}),x(!1)})(),()=>{Ge=!0}},e[10]=S,e[11]=r,e[12]=A,e[13]=L):L=e[13];let z;e[14]!==S||e[15]!==r||e[16]!==C||e[17]!==A?(z=[S,r,C,A],e[14]=S,e[15]=r,e[16]=C,e[17]=A,e[18]=z):z=e[18],m.useEffect(L,z);let $;e[19]!==S||e[20]!==p||e[21]!==f||e[22]!==A||e[23]!==o||e[24]!==l?($=async()=>a1(f,p)?dn:(await l(S,{permissions:ar(f)},A)).ok?(g(Oa(f)),Zn):Ps(o("settings.agents.page.permissionsEditor.toast.saveFailed")),e[19]=S,e[20]=p,e[21]=f,e[22]=A,e[23]=o,e[24]=l,e[25]=$):$=e[25];const W=$;let U,H;e[26]!==a||e[27]!==W?(U=()=>(a(W),()=>a(null)),H=[a,W],e[26]=a,e[27]=W,e[28]=U,e[29]=H):(U=e[28],H=e[29]),m.useEffect(U,H);let K;e[30]!==R?(K=R.map(p1),e[30]=R,e[31]=K):K=e[31];const _=K;let V;if(e[32]!==_||e[33]!==f.keys){V=[...Yb,...Zb];const Ge=new Set(_.map(g1));let ft;e[35]!==f.keys?(ft=Object.keys(f.keys),e[35]=f.keys,e[36]=ft):ft=e[36];for(const ct of ft)!V.includes(ct)&&!Ge.has(ct)&&V.push(ct);e[32]=_,e[33]=f.keys,e[34]=V}else V=e[34];const q=V;let X;e[37]!==F||e[38]!==o?(X=Ge=>{switch(F?.[Ge]?.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]=F,e[38]=o,e[39]=X):X=e[39];const ae=X;let ce;e[40]!==d||e[41]!==f.global?(ce=Ge=>i1(Ge,{global:d,agentGlobal:f.global}),e[40]=d,e[41]=f.global,e[42]=ce):ce=e[42];const J=ce;let de;e[43]!==i?(de=Ge=>{h(ft=>({...ft,global:Ge})),i()},e[43]=i,e[44]=de):de=e[44];const pe=de;let fe;e[45]!==i?(fe=(Ge,ft)=>{h(ct=>{const Se=Oa(ct),Ze=Se.keys[Ge]??{effect:null,patterns:[]};return Ze.effect=ft,Ze.effect===null&&Ze.patterns.length===0?delete Se.keys[Ge]:Se.keys[Ge]=Ze,Se}),i()},e[45]=i,e[46]=fe):fe=e[46];const ve=fe;let ye;e[47]!==i?(ye=(Ge,ft,ct,Se,Ze)=>{h(at=>{const ht=Oa(at),rt=ht.keys[Ge]??{effect:null,patterns:[]};return rt.patterns[ft]={pattern:ct,effect:Se},ht.keys[Ge]=rt,ht}),Ze&&i()},e[47]=i,e[48]=ye):ye=e[48];const Ae=ye;let te;e[49]===Symbol.for("react.memo_cache_sentinel")?(te=Ge=>{h(ft=>{const ct=Oa(ft),Se=ct.keys[Ge]??{effect:null,patterns:[]};return Se.patterns.push({pattern:"",effect:"allow"}),ct.keys[Ge]=Se,ct}),N(ft=>({...ft,[Ge]:!0}))},e[49]=te):te=e[49];const Y=te;let ue;e[50]!==i?(ue=(Ge,ft)=>{h(ct=>{const Se=Oa(ct),Ze=Se.keys[Ge];return Ze?(Ze.patterns.splice(ft,1),Ze.effect===null&&Ze.patterns.length===0&&delete Se.keys[Ge],Se):ct}),i()},e[50]=i,e[51]=ue):ue=e[51];const be=ue;let Ie;e[52]!==j||e[53]!==i?(Ie=()=>{const Ge=j.trim();!Ge||Ge==="*"||(h(ft=>{if(ft.keys[Ge])return ft;const ct=Oa(ft);return ct.keys[Ge]={effect:"ask",patterns:[]},ct}),P(""),i())},e[52]=j,e[53]=i,e[54]=Ie):Ie=e[54];const Te=Ie;let Fe;e[55]!==o?(Fe=Ge=>o(Ge==="allow"?"settings.agents.page.permissionsEditor.action.allow":Ge==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),e[55]=o,e[56]=Fe):Fe=e[56];const xe=Fe;let me,ne,he,Re,ke,le,De,$e,Me;if(e[57]!==xe||e[58]!==J||e[59]!==k||e[60]!==b||e[61]!==y||e[62]!==_||e[63]!==ae||e[64]!==f.global||e[65]!==f.keys||e[66]!==be||e[67]!==pe||e[68]!==ve||e[69]!==Ae||e[70]!==o||e[71]!==q){Me=Symbol.for("react.early_return_sentinel");e:{const Ge=o("settings.agents.page.permissionsEditor.action.inherit"),ft=o("settings.agents.page.permissionsEditor.action.default");let ct;e[81]!==xe?(ct=qe=>[...qe?[{value:"inherit",label:qe}]:[],...Qb.map(pt=>({value:pt,label:xe(pt)}))],e[81]=xe,e[82]=ct):ct=e[82];const Se=ct,Ze=(qe,pt,wt,yt)=>{const It=yt===void 0?Ge:yt;return s.jsx(Yt,{value:qe??"inherit",options:Se(It),onChange:Nt=>pt(Nt==="inherit"?null:Nt),"aria-label":wt})};if(b){let qe;e[83]!==o?(qe=o("settings.agents.page.section.toolPermissions"),e[83]=o,e[84]=qe):qe=e[84];let pt;e[85]!==o?(pt=o("common.loading"),e[85]=o,e[86]=pt):pt=e[86];let wt;e[87]!==pt?(wt=s.jsx("p",{className:Wt,children:pt}),e[87]=pt,e[88]=wt):wt=e[88];let yt;e[89]!==qe||e[90]!==wt?(yt=s.jsx(Ve,{title:qe,children:wt}),e[89]=qe,e[90]=wt,e[91]=yt):yt=e[91],Me=yt;break e}if(y){let qe;e[92]!==o?(qe=o("settings.agents.page.section.toolPermissions"),e[92]=o,e[93]=qe):qe=e[93];let pt;e[94]!==o?(pt=o("settings.agents.page.permissionsEditor.state.loadFailed"),e[94]=o,e[95]=pt):pt=e[95];let wt;e[96]!==pt?(wt=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:pt}),e[96]=pt,e[97]=wt):wt=e[97];let yt;e[98]===Symbol.for("react.memo_cache_sentinel")?(yt=()=>I(f1),e[98]=yt):yt=e[98];let It;e[99]!==o?(It=o("settings.agents.page.permissionsEditor.actions.retry"),e[99]=o,e[100]=It):It=e[100];let Nt;e[101]!==It?(Nt=s.jsx(G,{variant:"outline",size:"xs",onClick:yt,children:It}),e[101]=It,e[102]=Nt):Nt=e[102];let ze;e[103]!==wt||e[104]!==Nt?(ze=s.jsxs("div",{className:"flex items-center gap-3",children:[wt,Nt]}),e[103]=wt,e[104]=Nt,e[105]=ze):ze=e[105];let ge;e[106]!==qe||e[107]!==ze?(ge=s.jsx(Ve,{title:qe,children:ze}),e[106]=qe,e[107]=ze,e[108]=ge):ge=e[108],Me=ge;break e}const at=(qe,pt,wt)=>{const yt=f.keys[qe]??r1,It=l1.has(qe)||yt.patterns.length>0,Nt=k[qe]===!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:It?()=>N(ze=>({...ze,[qe]:!Nt})):void 0,className:Ye("flex min-w-0 items-center gap-1.5 text-start",!It&&"cursor-default"),"aria-expanded":It?Nt:void 0,children:[s.jsx(ee,{name:Nt&&It?"arrow-down-s":"arrow-right-s",className:Ye("h-3.5 w-3.5 shrink-0 text-muted-foreground",!It&&"opacity-0")}),s.jsx("span",{className:cs,children:pt}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground",children:qe}),wt&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:wt}),yt.effect===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:xe(J(qe))})}),yt.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(yt.patterns.length)})})]}),Ze(yt.effect,ze=>ve(qe,ze),o("settings.agents.page.permissionsEditor.keyAria",{key:qe}))]}),Nt&&It&&s.jsxs("div",{className:"mt-2 space-y-2 ps-5",children:[yt.patterns.map((ze,ge)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Qe,{value:ze.pattern,onChange:Je=>Ae(qe,ge,Je.target.value,ze.effect,!1),placeholder:o("settings.agents.page.permissionsEditor.patternPlaceholder"),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:qe}),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(Yt,{value:ze.effect,options:Se(),onChange:Je=>Ae(qe,ge,ze.pattern,Je,!0),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:qe})}),s.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>be(qe,ge),"aria-label":o("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx(ee,{name:"close",className:"h-3.5 w-3.5"})})]},ge)),s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Y(qe),children:[s.jsx(ee,{name:"add",className:"me-1 h-3.5 w-3.5"}),o("settings.agents.page.permissionsEditor.actions.addRule")]})]})]},qe)};me=Ve,e[109]!==o?(ne=o("settings.agents.page.section.toolPermissions"),e[109]=o,e[110]=ne):ne=e[110],he="agents.permissions",e[111]!==o?(Re=o("settings.agents.page.permissionsEditor.sectionInfo"),e[111]=o,e[112]=Re):Re=e[112],ke="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 rt;e[115]!==ht?(rt=s.jsx("span",{className:cs,children:ht}),e[115]=ht,e[116]=rt):rt=e[116];let xt;e[117]!==o?(xt=o("settings.agents.page.permissionsEditor.defaultInfo"),e[117]=o,e[118]=xt):xt=e[118];let oe;e[119]!==xt?(oe=s.jsx(us,{children:xt}),e[119]=xt,e[120]=oe):oe=e[120];let Z;e[121]!==xe||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:xe(J("*"))})}),e[121]=xe,e[122]=J,e[123]=f.global,e[124]=o,e[125]=Z):Z=e[125];let it;e[126]!==rt||e[127]!==oe||e[128]!==Z?(it=s.jsxs("div",{className:"flex items-center gap-1.5",children:[rt,oe,Z]}),e[126]=rt,e[127]=oe,e[128]=Z,e[129]=it):it=e[129];const jt=f.global;let We;e[130]!==o?(We=o("settings.agents.page.permissionsEditor.defaultAria"),e[130]=o,e[131]=We):We=e[131],le=s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[it,Ze(jt,pe,We,ft)]}),De=s.jsx("div",{children:q.map(qe=>at(qe,o1(qe),null))}),$e=_.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")})]}),_.map(qe=>at(qe.key,qe.server,ae(qe.server)))]})}e[57]=xe,e[58]=J,e[59]=k,e[60]=b,e[61]=y,e[62]=_,e[63]=ae,e[64]=f.global,e[65]=f.keys,e[66]=be,e[67]=pe,e[68]=ve,e[69]=Ae,e[70]=o,e[71]=q,e[72]=me,e[73]=ne,e[74]=he,e[75]=Re,e[76]=ke,e[77]=le,e[78]=De,e[79]=$e,e[80]=Me}else me=e[72],ne=e[73],he=e[74],Re=e[75],ke=e[76],le=e[77],De=e[78],$e=e[79],Me=e[80];if(Me!==Symbol.for("react.early_return_sentinel"))return Me;let se;e[132]===Symbol.for("react.memo_cache_sentinel")?(se=Ge=>P(Ge.target.value),e[132]=se):se=e[132];let Ce;e[133]!==Te?(Ce=Ge=>{Ge.key==="Enter"&&(Ge.preventDefault(),Te())},e[133]=Te,e[134]=Ce):Ce=e[134];let Ne;e[135]!==o?(Ne=o("settings.agents.page.permissionsEditor.customKeyPlaceholder"),e[135]=o,e[136]=Ne):Ne=e[136];let Ee;e[137]!==j||e[138]!==Ce||e[139]!==Ne?(Ee=s.jsx(Qe,{value:j,onChange:se,onKeyDown:Ce,placeholder:Ne,className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),e[137]=j,e[138]=Ce,e[139]=Ne,e[140]=Ee):Ee=e[140];let we;e[141]!==j?(we=j.trim(),e[141]=j,e[142]=we):we=e[142];const Ue=!we;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 nt;e[144]!==o?(nt=o("settings.agents.page.permissionsEditor.actions.addKey"),e[144]=o,e[145]=nt):nt=e[145];let Be;e[146]!==Te||e[147]!==Ue||e[148]!==nt?(Be=s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:Te,disabled:Ue,children:[_e,nt]}),e[146]=Te,e[147]=Ue,e[148]=nt,e[149]=Be):Be=e[149];let tt;e[150]!==Ee||e[151]!==Be?(tt=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-edge-muted pt-3",children:[Ee,Be]}),e[150]=Ee,e[151]=Be,e[152]=tt):tt=e[152];let ut;return e[153]!==me||e[154]!==ne||e[155]!==he||e[156]!==Re||e[157]!==ke||e[158]!==le||e[159]!==De||e[160]!==$e||e[161]!==tt?(ut=s.jsxs(me,{title:ne,settingsItem:he,info:Re,contentClassName:ke,children:[le,De,$e,tt]}),e[153]=me,e[154]=ne,e[155]=he,e[156]=Re,e[157]=ke,e[158]=le,e[159]=De,e[160]=$e,e[161]=tt,e[162]=ut):ut=e[162],ut};function d1(t){return t.updateAgent}function u1(t){return t.fetchAgentPermissions}function m1(t){return t.loadMcpConfigs}function p1(t){return{key:`${t.name}_*`,server:t.name}}function g1(t){return t.key}function f1(t){return t+1}const Kr=t=>{const e=Le.c(11),{legacy:n,path:a,className:i}=t,{t:o}=Oe();if(!n)return null;let l;e[0]!==i?(l=Ye("mb-4 flex items-start gap-1.5",Wt,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},h1=(t,e)=>{const n=ra(e);if(!n)return[];const a=t.find(o=>o.id===n.providerId),i=Af(a?.models,n.modelId);return uu(i)},b1=t=>jp(t)?.toLowerCase()??"",x1=()=>{const{t}=Oe(),e=gt(xe=>xe.providers),{selectedAgentName:n,getAgentByName:a,createAgent:i,updateAgent:o,fetchAgentEntity:l,agentDraft:r,setAgentDraft:u,setSelectedAgent:d}=Jn(Ys(xe=>({selectedAgentName:xe.selectedAgentName,getAgentByName:xe.getAgentByName,createAgent:xe.createAgent,updateAgent:xe.updateAgent,fetchAgentEntity:xe.fetchAgentEntity,agentDraft:xe.agentDraft,setAgentDraft:xe.setAgentDraft,setSelectedAgent:xe.setSelectedAgent}))),c=vn(),p=Jn(xe=>du(xe,c)),g=n?a(n,c):null,f=!!(r&&r.name===n&&!g),h=f?"":g?.description?.trim()??"",b=f?"":g?.system?.trim()??"",[x,y]=m.useState(""),[v,w]=m.useState("user"),[k,N]=m.useState(""),[j,P]=m.useState("subagent"),[C,I]=m.useState(""),[S,A]=m.useState(""),[T,D]=m.useState(void 0),[R,O]=m.useState(void 0),[F,E]=m.useState(void 0),[M,L]=m.useState(""),[z,$]=m.useState(""),[W,U]=m.useState(!1),[H,K]=m.useState(null),_=m.useRef({}),V=m.useRef(null),q=m.useCallback(xe=>{V.current=xe},[]),X=m.useRef(null),ae=JSON.stringify([n,c,f]),ce=m.useRef(ae);ce.current=ae;const J=m.useRef(null),de={description:k,mode:j,model:C,variant:S,steps:T,temperature:R,topP:F,system:M,color:z},pe=m.useRef(de);pe.current=de;const fe=m.useMemo(()=>h1(e,C),[C,e]),ve=fe.length>0,ye=S||"__default",Ae=ve,te=m.useMemo(()=>S&&!fe.includes(S)?[S,...fe]:fe,[S,fe]);m.useEffect(()=>{if(!f||!r)return;J.current=null;const xe=Li(r.model),me=r.name||"",ne=r.scope||"user",he=r.description||"",Re=r.mode||"subagent",ke=xe?`${xe.providerID}/${xe.modelID}`:"",le=xe?.variant||"",De=r.steps??void 0,$e=r.temperature??void 0,Me=r.top_p??void 0,se=r.system||"",Ce="";_.current={},K(null),y(me),w(ne),N(he),P(Re),I(ke),A(le),D(De),O($e),E(Me),L(se),$(Ce),X.current={draftName:me,draftScope:ne,description:he,mode:Re,model:ke,variant:le,steps:De,temperature:$e,topP:Me,system:se,color:Ce}},[r,f]),m.useEffect(()=>{if(f||!n)return;let xe=!1;return(async()=>{const me=await l(n,c);if(xe||ce.current!==ae||!me)return;const ne=me.config;_.current=ne;const he=Li(ne.model),Re=ne.request?.body,ke={draftName:"",draftScope:"user",description:ne.description||"",mode:ne.mode||g?.mode||"subagent",model:he?`${he.providerID}/${he.modelID}`:"",variant:he?.variant||"",steps:ne.steps??void 0,temperature:Re?.temperature,topP:Re?.top_p,system:ne.system||"",color:b1(ne.color)},le=X.current,De=pe.current,$e=le!==null&&(De.description!==le.description||De.mode!==le.mode||De.model!==le.model||De.variant!==le.variant||De.steps!==le.steps||De.temperature!==le.temperature||De.topP!==le.topP||De.system!==le.system||De.color!==le.color);K({legacy:me.legacy===!0,path:me.path,source:me.source}),!(J.current===ae&&$e)&&(J.current=ae,N(ke.description),P(ke.mode),I(ke.model),A(ke.variant),D(ke.steps),O(ke.temperature),E(ke.topP),L(ke.system),$(ke.color),X.current=ke)})(),()=>{xe=!0}},[l,f,g,n,c,ae]);const Y=m.useCallback(xe=>{const me=ra(C.trim()),ne=me?Ru({providerID:me.providerId,modelID:me.modelId,variant:S.trim()||void 0}):null,he=_.current.request,Re={...he?.body};R===void 0?delete Re.temperature:Re.temperature=R,F===void 0?delete Re.top_p:Re.top_p=F;const ke=he?.headers,le={};ke&&Object.keys(ke).length>0&&(le.headers=ke),Object.keys(Re).length>0&&(le.body=Re);const De=k.trim(),$e=M.trim(),Me={name:xe,mode:j,model:ne,steps:T??null,system:$e||(f?void 0:null),request:Object.keys(le).length>0?le:null};return De&&(Me.description=De),z!==(X.current?.color??"")&&(Me.color=z||null),f&&v&&(Me.scope=v),f&&r?.hidden!==void 0&&(Me.hidden=r.hidden),f&&r?.permissions?.length&&(Me.permissions=r.permissions),Me},[r,z,k,v,f,j,C,T,M,R,F,S]),ue=m.useCallback(async()=>{const xe=X.current,me=n?.trim();if(f||!xe||!me)return dn;const ne=V.current?await V.current():dn;if(k===xe.description&&j===xe.mode&&C===xe.model&&S===xe.variant&&T===xe.steps&&R===xe.temperature&&F===xe.topP&&M===xe.system&&z===xe.color||!ne.ok)return ne;const Re=Y(me);return(await o(me,Re,c)).ok?(ce.current!==ae||(_.current={..._.current,model:Re.model,system:Re.system??void 0,steps:Re.steps,request:Re.request??void 0},X.current={...xe,description:k,mode:j,model:C,variant:S,steps:T,temperature:R,topP:F,system:M,color:z}),Zn):Ps(t("settings.agents.page.toast.updateFailed"))},[Y,z,k,f,j,C,n,ae,c,T,M,t,R,F,o,S]),be=fi(ue),{requestSave:Ie}=be,Te=async()=>{const xe=x.trim().replace(/\s+/g,"-");if(!xe){Q.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(p.some(me=>me.name===xe)){Q.error(t("settings.agents.sidebar.toast.agentExists"));return}U(!0);try{(await i(Y(xe),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 ne=me instanceof Error&&me.message?me.message:t("settings.agents.page.toast.saveUnexpectedError");Q.error(ne)}finally{U(!1)}},Fe=()=>{u(null),d(null)};return n?s.jsxs(ss,{title:f?t("settings.agents.page.title.new"):n,description:t(f?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit"),onBlurCapture:be.onBlurCapture,children:[!f&&H&&s.jsx(Kr,{legacy:H.legacy,path:H.path}),!f&&H?.source==="none"&&s.jsxs("p",{className:`mb-4 flex items-start gap-1.5 ${Wt}`,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(Ve,{title:t("settings.agents.page.section.identityRole"),divider:!1,contentClassName:"space-y-3",children:[f&&s.jsxs(ot,{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(Qe,{value:x,onChange:xe=>y(xe.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Kt,{value:v,onValueChange:xe=>w(xe),children:[s.jsx(Ft,{className:"w-fit min-w-[100px]",children:s.jsx($t,{children:t(v==="project"?"settings.common.scope.project":"settings.common.scope.global")})}),s.jsxs(Lt,{align:"end",children:[s.jsx(bt,{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(bt,{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:k,onChange:xe=>N(xe.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(Yt,{"aria-label":t("settings.agents.page.field.mode"),value:j,onChange:xe=>{P(xe),Ie()},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(Oh,{value:z,labels:{empty:t("settings.agents.page.field.colorAutomatic"),swatch:xe=>t("settings.agents.page.field.colorSwatchAria",{color:xe}),custom:t("settings.agents.page.field.colorCustomAria"),hex:t("settings.agents.page.field.colorHexAria")},onChange:xe=>{$(xe),Ie()}})})]}),s.jsxs(Ve,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx(ot,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(ja,{providerId:ra(C)?.providerId??"",modelId:ra(C)?.modelId??"",onChange:(xe,me)=>{I(xe&&me?`${xe}/${me}`:""),A(""),Ie()},className:Cn})}),s.jsx(ot,{settingsItem:"agents.variant",label:t("settings.agents.page.field.variant"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.variantTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.variantHint")})]}),children:Ae?s.jsxs(Kt,{value:ye,onValueChange:xe=>{A(xe==="__default"?"":xe),Ie()},children:[s.jsx(Ft,{className:Ts,children:s.jsx($t,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:xe=>xe==="__default"?t("chat.modelControls.default"):xe})}),s.jsxs(Lt,{children:[s.jsx(bt,{value:"__default",children:t("chat.modelControls.default")}),te.map(xe=>s.jsx(bt,{value:xe,children:xe},xe))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Qe,{value:S,onChange:xe=>A(xe.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!C&&!S,className:"h-8 w-40 rounded-md px-3"}),S&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{A(""),Ie()},className:is,"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(ot,{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(js,{value:R,fallbackValue:.7,onValueChange:O,onClear:()=>{O(void 0),Ie()},min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:ws}),R!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{O(void 0),Ie()},className:is,"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(ot,{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(js,{value:F,fallbackValue:.9,onValueChange:E,onClear:()=>{E(void 0),Ie()},min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:ws}),F!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{E(void 0),Ie()},className:is,"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(ot,{settingsItem:"agents.steps",label:t("settings.agents.page.field.steps"),info:t("settings.agents.page.field.stepsTooltip"),children:[s.jsx(js,{value:T,fallbackValue:20,onValueChange:D,onClear:()=>{D(void 0),Ie()},min:1,max:1e3,step:1,inputMode:"numeric",placeholder:"—",emptyLabel:"—",className:ws}),T!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{D(void 0),Ie()},className:is,"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(Ve,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx($s,{value:M,onChange:xe=>L(xe.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(c1,{agent:g,registerSave:q,requestSave:Ie}),f&&s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[s.jsx(G,{onClick:()=>{Te()},disabled:W||!x.trim(),size:"xs",className:"!font-normal",children:t(W?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(G,{variant:"ghost",onClick:Fe,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 v1(t,e){return t.kind==="file"?t.content:e??""}const Dc=ts({content:Et(),exists:oo(),path:Et().min(1).optional()}),y1=async(t,e)=>{const n=await t.json().catch(()=>null);return typeof n?.error=="string"&&n.error.trim()?n.error:e},k1=t=>t.length>0&&!t.endsWith(`
2
+ import{R as m,j as s,f as Le,r as He}from"./vendor-react--VO_rL_p.js";import{u as Ys,c as al}from"./vendor-zustand-C9tWdk0j.js";import{u as Oe,I as ee,dz as Fs,mB as ot,aL as xn,am as bp,ae as Yt,B as G,z as Gn,A as Q,mC as Zr,aG as Ve,x as qa,n as ks,bj as cu,b2 as Xa,Y as In,aM as Ia,a1 as il,Q as Ye,bo as xp,d7 as Do,dc as vp,bs as $t,br as Ft,bu as bt,bt as Lt,bq as Kt,y as Qe,mD as Jn,mE as du,mF as yp,d$ as zo,mG as Xr,mH as kp,mI as Oi,mJ as ua,t as Ut,q as zt,D as Bt,l as Vt,F as Ht,o as ns,mK as vr,a4 as Pa,a5 as wa,bf as Gi,bg as Ji,a3 as Aa,a2 as Ta,be as Qi,bd as Yi,kh as Qn,ki as Kn,mL as cs,d1 as us,mM as yr,gM as Wt,V as gt,fl as Tt,cS as $s,fn as ja,mN as Cn,fV as Ts,mO as is,fs as js,mP as ws,mQ as uu,mR as jp,mS as mt,mT as mu,mU as wp,mV as Sp,mW as zi,mX as Np,ex as Xn,mY as hn,mZ as ii,kk as Js,m_ as ei,m$ as pu,n0 as kr,fo as jr,a9 as za,n1 as Gl,n2 as Cp,n3 as ec,n4 as Ip,cV as ol,n5 as tc,gU as Ha,kj as Gt,R as wr,n6 as Sr,n7 as Ka,n8 as gu,n9 as fu,na as Nr,kl as qn,gG as _a,nb as Pp,k_ as Zi,C as oi,aQ as sc,cH as Ap,a$ as Tp,cO as Ep,bc as Mp,ft as Rp,cg as Dp,fu as Op,K as Cr,bE as ui,g6 as Bi,lo as hu,nc as Fp,nd as Lp,d3 as Kp,ne as _p,au as Xi,d5 as Un,nf as es,ng as bu,nh as $p,ni as aa,gW as Qs,nj as ll,nk as Wn,nl as Bo,nm as Up,nn as zp,no as Bp,np as xu,nq as Vp,nr as vu,fW as yu,ns as rl,jg as Is,jh as ku,mv as Vo,eJ as ju,eI as Hp,je as Wp,jf as wu,mw as qp,nt as Gp,nu as Jp,nv as Qp,nw as nc,d2 as Su,nx as Yp,ny as Zp,nz as Xp,nA as eg,nB as tg,nC as Nu,nD as sg,nE as ng,nF as ag,nG as ig,nH as og,nI as lg,nJ as li,nK as rg,nL as cg,nM as Cu,nN as dg,nO as Es,gV as Wa,bS as cn,bT as cl,nP as ug,k$ as Iu,gH as mg,gR as pg,hB as gg,nQ as fg,nR as hg,nS as dl,kM as eo,nT as to,da as bg,db as kl,d9 as Pu,k6 as Au,nU as jl,nV as xg,nW as vg,nX as yg,nY as kg,nZ as jg,n_ as wg,n$ as Sg,o0 as Ng,bN as qs,o1 as Ir,km as Dn,bO as Pr,o2 as Mn,kZ as Cg,o3 as Ig,o4 as Pg,o5 as ri,eE as Ag,o6 as Ho,o7 as va,o8 as Ei,o9 as Tg,oa as Eg,ob as Mg,gN as Rg,oc as gn,od as Gs,oe as Fa,of as ia,og as ac,oh as Oo,oi as Dg,ak as Og,oj as Tu,ok as $a,ol as Fg,om as Lg,k as Ar,on as Kg,es as _g,aE as $g,aD as Ug,cu as zg,dd as Bg,az as Vg,aC as Hg,oo as Wg,bp as qg,k0 as Gg,op as Vi,oq as yi,or as ic,os as na,ot as ka,ou as Jg,ov as Qg,ow as Yg,ox as Zg,oy as wl,oz as oc,oA as Xg,oB as ef,oC as tf,oD as sf,oE as nf,oF as lc,oG as ki,oH as rc,oI as Tr,oJ as af,$ as of,aV as cc,fk as lf,oK as rf,oL as cf,oM as Sl,oN as dc,oO as df,f as la,h as Ba,oP as uc,oQ as uf,oR as mf,oS as pf,oT as ul,oU as gf,av as da,oV as ff,oW as hf,oX as bf,gr as xf,oY as ml,kp as oa,oZ as vf,o_ as yf,o$ as Fi,aw as kf,ay as Eu,ey as jf,a_ as Da,aa as wf,ab as Sf,ez as Nf}from"./useAppFontEffects-6HvTeJY2.js";import{j as qt,c9 as Mu,dj as Cf,dk as Jl,dl as If,bG as bn,dm as Pf,z as St,u as ie,l as ms,dn as Hi,dp as Li,dq as ra,dr as Ru,ds as Af,t as fn,dt as Tf,aL as Ea,aI as Jt,cA as Er,bS as Ef,bi as bs,aO as mi,bA as Nl,bD as mc,bB as pc,bJ as ji,ci as Mf,du as Rf,cf as Df,bK as ya,dv as Of,d4 as gc,bC as Ff,dw as Lf,dx as Kf,ca as fc,bZ as so,d8 as _f,dy as $f,dz as Du,dA as Ot,dB as Uf,aK as no,bX as zf,bY as Bf,bT as Mr,bb as Rr,co as Vf,bR as Hf,aZ as pl,cn as Va,dC as Ou,bW as Wo,bd as Fu,dD as Wf,dE as Lu,dF as qf,dG as Gf,bI as Dr,dH as Jf,v as qo,bq as Qf,bj as Ki,dI as Yf,dJ as Ga,dK as hc,dL as bc,dM as xc,dN as vc,dO as Zf,dP as yc,c7 as Xf,M as Ku,dQ as ao,dR as eh,aM as kc,dS as th,dT as sh,r as Ql,dU as nh,dV as jc,dW as ah,b as ih,dX as oh,dY as lh,dZ as rh,d_ as ch,d$ as dh,bE as _u,e0 as $u,e1 as uh,e2 as Yl,e3 as mh,e4 as ph,e5 as gh,e6 as fh,e7 as Uu,e8 as hh,e9 as bh,ea as xh,eb as Zl,ec as wc,ed as vh,ee as Sc,ef as xo,eg as yh,eh as kh,ei as jh,cs as wh,cm as Sh,b_ as Nh,ej as Ch,ek as Ih,el as Ph,em as Ah}from"./katex.min-B7gF3rmE.js";import{aD as Th,ca as Eh,c3 as Cl,c4 as Mh,cb as Rh,cc as Dh,cd as ss,ce as Oh,cf as pi,cg as Os,ch as Wi,ci as Yn,cj as ci,ck as gl,cl as io,cm as di,O as Sa,K as Na,L as Ca,cn as Fh,bL as Ws,co as Lh,cp as Kh,c1 as _h,cq as $h,cr as Uh,cs as zh,bK as Bh,ct as Vh,cu as La,b3 as Xl,ad as Hh,ae as Wh,cv as qh}from"./runtimeEndpointReset-DUwSilpj.js";import{o as ts,s as Et,e as oo,l as Gh,d as un,n as qi,a as ca,f as Go,_ as fl,u as er}from"./vendor-zod-Csf1sqWl.js";import{n as Jh,M as zu,r as Qh,b as Yh,a as Zh,g as Xh,c as eb,d as tb,e as sb,P as nb,f as ab,h as ib,j as ob,k as Bu,u as Vu,i as Hu,s as Wu,l as lb,m as rb}from"./install-csQoiut9.js";import{s as cb,c as db}from"./vendor-yaml-CE-D_49-.js";import{c as Nc,C as Cc,p as ub}from"./flexokiTheme-DJhpTHWO.js";import{u as mb}from"./vendor-tanstack-react-virtual-CqfECoM0.js";import{m as pb}from"./vendor-tanstack-virtual-core-BdFnkr_2.js";import{c as gb}from"./codeHighlight-CXtTq4co.js";import{getCodeTokenTheme as fb,getThemeRenderName as hb}from"./appThemeRegistry-hfPZ6say.js";import{E as Ic}from"./vendor-codemirror-view-Ciie9ey-.js";import{Q as qu}from"./vendor-qrcode-Cl8OheHW.js";import{toast as ti}from"./vendor-sonner-Dw26OnzC.js";import{s as bb}from"./vendor-strip-json-comments-5dJlOkP1.js";import{c as xb,h as vb,a as yb,b as kb,P as jb}from"./vendor-base-ui-zhBy6TEG.js";import{u as wb}from"./useCallableModelProviders-BLdr2CgV.js";import{r as Gu,s as Sb}from"./pageTitle-CAd4Kwsy.js";import{S as Or,f as Jo}from"./SpaceRow-CckOV1g8.js";import{_ as Nb}from"./vendor-vite-runtime-DD1OZmLC.js";import{A as Pc}from"./AboutLogo-DiHHd_5t.js";const Ac=({label:t})=>{const{t:e}=Oe(),[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 qt("/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:()=>{Fs(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(ot,{label:t,controlClassName:"min-h-8",children:o}):o},Tc="https://github.com/openchamber/openchamber",Ec="https://discord.gg/ZYRSdnwwKA",Mc="https://x.com/openchamber_dev",Cb=800,Ib=async t=>{const e=await bn();return e?e.serverUpdateChannel??(Jl(t)?"canary":"stable"):null},Pb={info:null,checking:!1,available:!1,error:null};function Ab(t){const e=Le.c(5),[n,a]=m.useState(Pb);let i;e[0]!==t?(i=async()=>{if(t){a(Tb);try{const r=await Mh();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 Tb(t){return{...t,checking:!0,error:null}}function Eb(t){const e=Le.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 x=await Rh();return a(x),x}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 x=await Dh(t);l({kind:"installed",version:x})}catch(x){const y=x;l({kind:"failed",error:y instanceof Error?y.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 x=>{await x().catch(Mb);const y=await u();y?.currentVersion&&l(v=>v.kind!=="installed"||v.version&&v.version.replace(/^v/,"")!==y.currentVersion?v:{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 Mb(){}function Rb(t){const[e,n]=m.useState(null);return m.useEffect(()=>{if(!t)return;let a=!1;return Nb(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 Db=({initialUpdateDialogOpen:t=!1})=>{const{t:e}=Oe(),[n,a]=m.useState(t),[i,o]=m.useState(!1),[l,r]=m.useState(null),u=Th(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}=xn(),c=m.useMemo(()=>Mu(),[]),p=Eh(),g=Ab(c||p),f=p?g:null,h=g.check;m.useEffect(()=>{p&&h()},[p,h]);const[b,x]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{if(!p)return;let me=!1;return bp().then(ne=>{me||v(ne)}),()=>{me=!0}},[p]);const w=Rb(c),k=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,ne)=>{const he=Jl(me);return he?e("settings.openchamber.about.canaryVersion",{version:he.release,date:If(he,qa(),Jl(ne))}):me},j=k.available?k.info?.version:null,P=N(l||k.info?.currentVersion||"unknown",j),C=N(y||u.info?.currentVersion||"unknown",j),I=l||f?.info?.currentVersion||"unknown",S=u.runtimeType==="desktop",[A,T]=m.useState(!1),D=u.runtimeType==="web"&&A&&l!==null,[R,O]=m.useState(null);m.useEffect(()=>{if(!S&&!D)return;let me=!1;return(S?Cf():Ib(l??"")).then(he=>{me||O(he)}),()=>{me=!0}},[S,D,l]);const F=Eb(e("opencodeUpdate.toast.failed.description")),E=F.status?.currentVersion??null,M=F.phase.kind==="installed"?null:F.status?.availableVersion??null,[L,z]=m.useState(!1),$=me=>{const ne=N(me?.version||"",me?.currentVersion);return me?.packageManager==="electron"?e("settings.openchamber.about.actions.updateDesktopToVersion",{version:ne}):e("settings.openchamber.about.actions.updateServerToVersion",{version:ne})},W=(()=>{const me=N(k.info?.version||"",k.info?.currentVersion);return c?$(k.info):p?e("settings.openchamber.about.actions.updateAppToVersion",{version:me}):e("settings.openchamber.about.actions.updateOpenChamberToVersion",{version:me})})(),U=me=>!!me?.installBlocked,H=k.available&&U(k.info),K=!!(f?.available&&U(f.info)),_=async me=>{if(me===R)return;const ne=R;if(O(me),!(S?await Pf(me)===me:(await St({serverUpdateChannel:me})).ok)){O(ne),Q.error(e("settings.openchamber.about.toast.updateChannelNotSaved"));return}k.checkForUpdates()},q=R&&s.jsx(Yt,{value:R,onChange:me=>{_(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=()=>{k.checkForUpdates(),f&&f.check(),F.refresh()},ae=async me=>{(await Xa(me)).ok&&(z(!0),setTimeout(()=>z(!1),2e3))},ce=()=>{F.reloadAfterUpgrade(async()=>{await cu({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 ne=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(ks,{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:ne}),s.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{ae(ne)},"aria-label":e(L?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:s.jsx(ee,{name:L?"check":"clipboard",className:"size-4"})})]})]})},de=H?J(k.info):null,pe=!f?.available||f.checking?null:K?J(f.info):s.jsxs(G,{type:"button",size:"sm",variant:"outline",onClick:()=>x(!0),children:[s.jsx(ee,{name:"download",className:"size-4"}),$(f.info)]}),fe=f?s.jsx(Cl,{open:b,onOpenChange:x,info:f.info,downloading:!1,downloaded:!1,progress:null,error:f.error,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"}):null,ve=(()=>{const{phase:me}=F;if(me.kind==="installed")return{action:s.jsx(G,{type:"button",size:"sm",variant:"outline",onClick:ce,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(!M)return null;if(!F.status?.supported)return{action:null,note:s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.openCode.manualUpdate",{version:M})})};const ne=me.kind==="upgrading";return{action:s.jsxs(G,{type:"button",size:"sm",variant:"outline",onClick:()=>{F.upgrade()},disabled:ne,children:[ne?s.jsx(Gn,{className:"size-4"}):s.jsx(ee,{name:"download",className:"size-4"}),ne?e("opencodeUpdate.toast.upgrading.title"):e("settings.openchamber.about.actions.updateOpenCodeToVersion",{version:M})]}),note:me.kind==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:me.error}):null}})(),ye=ve?s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[ve.note,ve.action]}):null;m.useEffect(()=>{let me=!1;return(async()=>{try{const he=await qt("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!he.ok)return;const Re=await he.json().catch(()=>null),ke=typeof Re?.openchamberVersion=="string"&&Re.openchamberVersion.trim().length>0?Re.openchamberVersion.trim():null;me||(r(ke),T(Re?.runtime==="web"))}catch{me||r(null)}})(),()=>{me=!0}},[]);const Ae=f?.checking??!1,te=f?.available??!1,Y=m.useRef(!1);m.useEffect(()=>{if(k.checking)o(!0),Y.current=!0;else if(i){const me=setTimeout(()=>{o(!1);const ne=Ae||te;Y.current&&!k.available&&!k.error&&!ne&&(Q.success(e(c?"settings.openchamber.about.toast.serverLatestVersion":"settings.openchamber.about.toast.latestVersion")),Y.current=!1)},Cb);return()=>clearTimeout(me)}},[e,c,k.checking,i,k.available,k.error,Ae,te]);const ue=k.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(Pc,{size:72}),s.jsx("h2",{className:`mt-4 ${Zr}`,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:P})}),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:I})}),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:P})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:E||e("settings.openchamber.about.state.unknown")})})]})}),s.jsx(Ac,{})]}),q&&s.jsx("div",{className:"flex justify-center",children:q}),s.jsxs("div",{className:"flex justify-center",children:[!k.available&&!k.error&&s.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:X,disabled:ue,className:"w-auto justify-center gap-2",children:[ue?s.jsx(Gn,{className:"size-4"}):s.jsx(ee,{name:"refresh",className:"size-4"}),e(ue?"settings.openchamber.about.state.checking":c?"settings.openchamber.about.actions.checkServerForUpdates":"settings.openchamber.about.actions.checkForUpdates")]}),!ue&&k.available&&!H&&s.jsxs(G,{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]})]}),de,pe&&s.jsx("div",{className:"flex justify-center text-center",children:pe}),ye&&s.jsx("div",{className:"flex justify-center text-center",children:ye}),[k.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: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:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),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:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:Mc,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(Cl,{open:n,onOpenChange:a,info:k.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:k.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:k.runtimeType}),fe]});const be=s.jsx("span",{"aria-hidden":"true",className:"typography-meta text-muted-foreground/60",children:"·"}),Ie=ue?s.jsxs(s.Fragment,{children:[be,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")]})]}):k.available&&!H?s.jsxs(G,{size:"sm",variant:"default",onClick:()=>a(!0),children:[s.jsx(ee,{name:"download",className:"size-4"}),W]}):!k.available&&!k.error?s.jsxs(s.Fragment,{children:[be,s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")})]}):null,Te=me=>s.jsx("span",{className:"typography-meta font-mono text-muted-foreground",children:me}),Fe="min-h-8 flex-wrap @xl:flex-initial",xe=[de,K?pe:null,ve?.note??null,...[k.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(Ve,{divider:!1,children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(Pc,{size:48}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("h2",{className:Zr,children:"OpenChamber"}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[{href:Tc,icon:"github-fill",label:"GitHub"},{href:Ec,icon:"discord-fill",label:"Discord"},{href:Mc,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(Ve,{contentClassName:"space-y-4",children:[s.jsxs("div",{children:[p?s.jsxs(s.Fragment,{children:[s.jsxs(ot,{label:e("settings.openchamber.about.field.appVersion"),controlClassName:Fe,children:[Te(C),Ie]}),s.jsxs(ot,{label:e("settings.openchamber.about.field.serverVersion"),controlClassName:Fe,children:[Te(I),K?null:pe]})]}):s.jsxs(ot,{label:e("settings.openchamber.about.field.version"),controlClassName:Fe,children:[Te(P),Ie]}),s.jsxs(ot,{label:e("settings.openchamber.about.field.updateChannel"),info:q?e("settings.openchamber.about.field.updateChannelHint"):void 0,controlClassName:Fe,children:[q,s.jsx(G,{size:"sm",variant:"outline",onClick:X,disabled:ue,children:e("settings.openchamber.about.actions.checkForUpdates")})]}),s.jsxs(ot,{label:e("settings.openchamber.about.field.openCodeVersion"),controlClassName:Fe,children:[Te(E||e("settings.openchamber.about.state.unknown")),ve?.action]}),s.jsx(Ac,{label:e("settings.openchamber.about.field.instanceUrls")})]}),xe.length>0&&s.jsx("div",{className:"space-y-3",children:xe})]}),s.jsx(Cl,{open:n,onOpenChange:a,info:k.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:k.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:k.runtimeType}),fe]})},Ob=(t,e,n)=>t&&e.some(i=>i.path===t)?t:(e.find(i=>i.id===n)??e[0])?.path??null,vn=()=>{const t=Le.c(4),e=ie(Fb),n=In(Lb),a=In(Kb);let i;return t[0]!==a||t[1]!==n||t[2]!==e?(i=Ob(e,n,a),t[0]=a,t[1]=n,t[2]=e,t[3]=i):i=t[3],i};function Fb(t){return t.settingsProjectPath}function Lb(t){return t.projects}function Kb(t){return t.activeProjectId}const tr=al(t=>({tab:"general",setTab:e=>t({tab:e})})),_b=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"]]),$b=t=>_b.get(t)??null,sr=al(t=>({tab:"messages",setTab:e=>t({tab:e})})),Ub=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"]]),zb=t=>Ub.get(t)??null,gi=t=>{const e=Le.c(73),{className:n}=t,{t:a}=Oe(),{currentTheme:i}=Ia(),o=ie(Bb),[l,r]=m.useState(!1),u=il(In(Vb)),d=vn(),c=ie(Hb),p=ms();let g;e[0]!==d||e[1]!==u?(g=u.find(A=>A.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=A=>{const T=u.find(D=>D.id===A);T&&c(T.path)},e[3]=c,e[4]=u,e[5]=h):h=e[5];const b=h;if(o){let A;e[6]!==n?(A=Ye(n),e[6]=n,e[7]=A):A=e[7];let T;e[8]!==a?(T=a("settings.shared.projectSelector.switchProjectAria"),e[8]=a,e[9]=T):T=e[9];let D;e[10]!==a?(D=a("settings.shared.projectSelector.switchProjectTitle"),e[10]=a,e[11]=D):D=e[11];let R,O;e[12]===Symbol.for("react.memo_cache_sentinel")?(R=()=>r(!0),O=Ye(xp({size:"touch"}),"w-full min-w-0"),e[12]=R,e[13]=O):(R=e[12],O=e[13]);let F;e[14]!==f||e[15]!==i?(F=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]=F):F=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 M;e[18]!==l||e[19]!==T||e[20]!==D||e[21]!==O||e[22]!==F?(M=s.jsxs("button",{type:"button","aria-label":T,title:D,"aria-haspopup":"dialog","aria-expanded":l,onClick:R,className:O,children:[F,E]}),e[18]=l,e[19]=T,e[20]=D,e[21]=O,e[22]=F,e[23]=M):M=e[23];let L;e[24]!==M||e[25]!==A?(L=s.jsx("div",{className:A,children:M}),e[24]=M,e[25]=A,e[26]=L):L=e[26];let z;e[27]===Symbol.for("react.memo_cache_sentinel")?(z=()=>r(!1),e[27]=z):z=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 U;e[30]!==a?(U=a("settings.shared.projectSelector.searchPlaceholder"),e[30]=a,e[31]=U):U=e[31];let H;e[32]!==f.id||e[33]!==i||e[34]!==b||e[35]!==l||e[36]!==u||e[37]!==W||e[38]!==U?(H=s.jsx(vp,{open:l,onClose:z,projects:u,selectedProjectId:$,onSelectProject:b,theme:i,title:W,searchPlaceholder:U}),e[32]=f.id,e[33]=i,e[34]=b,e[35]=l,e[36]=u,e[37]=W,e[38]=U,e[39]=H):H=e[39];let K;return e[40]!==L||e[41]!==H?(K=s.jsxs(s.Fragment,{children:[L,H]}),e[40]=L,e[41]=H,e[42]=K):K=e[42],K}let x;e[43]!==n?(x=Ye(n),e[43]=n,e[44]=x):x=e[44];const y=f.id;let v;e[45]!==b?(v=A=>{A&&b(A)},e[45]=b,e[46]=v):v=e[46];let w;e[47]!==a?(w=a("settings.shared.projectSelector.switchProjectAria"),e[47]=a,e[48]=w):w=e[48];let k;e[49]!==a?(k=a("settings.shared.projectSelector.switchProjectTitle"),e[49]=a,e[50]=k):k=e[50];let N;e[51]!==f||e[52]!==i?(N=s.jsx($t,{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]!==k||e[56]!==N?(j=s.jsx(Ft,{className:"w-full","aria-label":w,title:k,children:N}),e[54]=w,e[55]=k,e[56]=N,e[57]=j):j=e[57];let P;if(e[58]!==i||e[59]!==u){let A;e[61]!==i?(A=T=>s.jsx(bt,{value:T.id,className:"max-w-[24rem] truncate",children:s.jsx(Do,{project:T,theme:i})},T.id),e[61]=i,e[62]=A):A=e[62],P=u.map(A),e[58]=i,e[59]=u,e[60]=P}else P=e[60];let C;e[63]!==P?(C=s.jsx(Lt,{fitContent:!0,children:P}),e[63]=P,e[64]=C):C=e[64];let I;e[65]!==f.id||e[66]!==C||e[67]!==v||e[68]!==j?(I=s.jsxs(Kt,{value:y,onValueChange:v,children:[j,C]}),e[65]=f.id,e[66]=C,e[67]=v,e[68]=j,e[69]=I):I=e[69];let S;return e[70]!==I||e[71]!==x?(S=s.jsx("div",{className:x,children:I}),e[70]=I,e[71]=x,e[72]=S):S=e[72],S};function Bb(t){return t.isMobile}function Vb(t){return t.projects}function Hb(t){return t.setSettingsProjectPath}const Fr=t=>{const e=Le.c(16),{value:n,onChange:a}=t,{t:i}=Oe();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(Qe,{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},Lr=t=>{const e=Le.c(5),{query:n}=t,{t:a}=Oe();let i;e[0]!==n||e[1]!==a?(i=a("settings.common.sidebar.noMatches",{query:n.trim()}),e[0]=n,e[1]=a,e[2]=i):i=e[2];let o;return e[3]!==i?(o=s.jsx("p",{className:"px-2 py-6 text-center typography-meta text-muted-foreground",children:i}),e[3]=i,e[4]=o):o=e[4],o};function Wb(t,e){return`opencode:sidebar-group:${t}:${e}`}const nr=t=>{const e=Le.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=Wb(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 A=localStorage.getItem(d);if(A!==null)return A==="true"}catch{}return r},e[3]=r,e[4]=d,e[5]=p):p=e[5];const[g,f]=He.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]),He.useEffect(h,b);let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=()=>f(qb),e[10]=x):x=e[10];let y;e[11]===Symbol.for("react.memo_cache_sentinel")?(y=Ye("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]=y):y=e[11];const v=!g&&"-rotate-90 rtl:rotate-90";let w;e[12]!==v?(w=Ye("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",v),e[12]=v,e[13]=w):w=e[13];let k;e[14]!==w?(k=s.jsx(ee,{name:"arrow-down-s",className:w}),e[14]=w,e[15]=k):k=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 P;e[20]!==c||e[21]!==g||e[22]!==k||e[23]!==N||e[24]!==j?(P=s.jsxs("button",{type:"button",onClick:x,"aria-expanded":g,"aria-controls":c,className:y,children:[k,N,j]}),e[20]=c,e[21]=g,e[22]=k,e[23]=N,e[24]=j,e[25]=P):P=e[25];const C=!g;let I;e[26]!==l||e[27]!==c||e[28]!==C?(I=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]=I):I=e[29];let S;return e[30]!==P||e[31]!==I?(S=s.jsxs("div",{children:[P,I]}),e[30]=P,e[31]=I,e[32]=S):S=e[32],S};function qb(t){return!t}const Gb=({onItemSelect:t})=>{const{t:e}=Oe(),[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:x,createAgent:y,deleteAgent:v,loadAgents:w,loadDisabledAgents:k,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}))),P=vn(),C=Jn(J=>du(J,P)),I=Jn(J=>yp(J,P)),[S,A]=m.useState(null);m.useEffect(()=>{w(P),k(P)},[w,k,P]);const T=C.filter(J=>zo(J.mode)&&!Xr(J)).length,D=J=>!(zo(J.mode)&&!Xr(J)&&T<=1),R=async(J,de)=>{A(J);try{await N(J,{disabled:de},P),de&&h===J&&b(null),Q.success(de?e("settings.agents.sidebar.toast.agentDisabled",{name:J}):e("settings.agents.sidebar.toast.agentEnabled",{name:J}))}catch{Q.error(e(de?"settings.agents.sidebar.toast.disableFailed":"settings.agents.sidebar.toast.enableFailed"))}finally{A(null)}},O=I.filter(J=>Hi([J.name,J.description],n)),F="bg-background",E=()=>{const J="new-agent";let de=J,pe=1;for(;C.some(fe=>fe.name===de);)de=`${J}-${pe}`,pe++;x({name:de,scope:"user"}),b(de),t?.()},M=async J=>{if(Oi(J)){Q.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}d(J)},L=()=>{d(null)},z=async()=>{if(u){p(!0);try{(await v(u.name,u.scope,P)).ok?(Q.success(e("settings.agents.sidebar.toast.agentDeleted",{name:u.name})),L()):Q.error(e("settings.agents.sidebar.toast.deleteFailed"))}catch(J){const de=J instanceof Error?J.message:"",pe=/built-in|not deletable|not found/i.test(de);Q.error(e(pe?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed"))}p(!1)}},$=async J=>{const de=J.name;let pe=1,fe=`${de}-copy`;for(;C.some(te=>te.name===fe);)pe++,fe=`${de}-copy-${pe}`;const ve=J,ye=await j(J.name,P);if(!ye){Q.error(e("settings.agents.sidebar.toast.renameFailed"));return}const Ae=ye.config.request?.body;x({name:fe,scope:ye.scope??ve.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:Ae?.temperature,top_p:Ae?.top_p,mode:ye.config.mode??ve.mode,permissions:ye.config.permissions??void 0,hidden:ye.config.hidden}),b(fe),t?.()},W=J=>{r(J.name),o(J)},U=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(ve=>ve.name===J)){Q.error(e("settings.agents.sidebar.toast.agentExists"));return}const de=i,pe=await j(i.name,P);if(!pe){Q.error(e("settings.agents.sidebar.toast.renameFailed"));return}(await y({...pe.config,name:J,scope:pe.scope??de.scope},P)).ok?(await v(i.name,de.scope,P)).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)},H=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}},K=new Set(I.map(J=>J.name)),_=C.filter(J=>kp(J)&&!K.has(J.name)),V=_.filter(J=>Hi([J.name,J.description],n)),q=V.filter(Oi),X=V.filter(J=>!Oi(J)),{groupedCustomAgents:ae,ungroupedCustomAgents:ce}=He.useMemo(()=>{const J={},de=[];for(const fe of X){const ve=fe;ve.group?(J[ve.group]||(J[ve.group]=[]),J[ve.group].push(fe)):de.push(fe)}return{groupedCustomAgents:Object.keys(J).sort((fe,ve)=>fe.localeCompare(ve)).map(fe=>({name:fe,agents:J[fe]})),ungroupedCustomAgents:de}},[X]);return s.jsxs("div",{className:Ye("flex h-full flex-col",F),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(gi,{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:_.length})}),s.jsx(G,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:E,children:s.jsx(ee,{name:"add",className:"h-3.5 w-3.5"})})]}),_.length>0?s.jsx(Fr,{value:n,onChange:a}):null]}),s.jsxs(ks,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:[_.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")})]}):V.length===0?s.jsx(Lr,{query:n}):s.jsxs(s.Fragment,{children:[q.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.builtIn")}),q.map(J=>s.jsx(Il,{agent:J,isSelected:h===J.name,onSelect:()=>{b(J.name),t?.()},onDuplicate:()=>{$(J)},onDisable:D(J)?()=>{R(J.name,!0)}:void 0,getAgentModeIcon:H,isMenuOpen:g===J.name,onMenuOpenChange:de=>f(de?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:de})=>s.jsx(nr,{label:J,count:de.length,storageKey:"agents",children:de.map(pe=>s.jsx(Il,{agent:pe,isSelected:h===pe.name,onSelect:()=>{b(pe.name),t?.()},onRename:()=>W(pe),onDelete:()=>M(pe),onDuplicate:()=>{$(pe)},onDisable:D(pe)?()=>{R(pe.name,!0)}:void 0,getAgentModeIcon:H,isMenuOpen:g===pe.name,onMenuOpenChange:fe=>f(fe?pe.name:null)},pe.name))},J)),ce.map(J=>s.jsx(Il,{agent:J,isSelected:h===J.name,onSelect:()=>{b(J.name),t?.()},onRename:()=>W(J),onDelete:()=>M(J),onDuplicate:()=>{$(J)},onDisable:D(J)?()=>{R(J.name,!0)}:void 0,getAgentModeIcon:H,isMenuOpen:g===J.name,onMenuOpenChange:de=>f(de?J.name:null)},J.name))]})]}),O.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.disabled")}),O.map(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(G,{size:"xs",variant:"outline",disabled:S===J.name,onClick:()=>{R(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(Ut,{open:u!==null,onOpenChange:J=>{!J&&!c&&L()},children:s.jsxs(zt,{className:"max-w-md",children:[s.jsxs(Bt,{children:[s.jsx(Vt,{children:e("settings.agents.sidebar.dialog.deleteTitle")}),s.jsx(Ht,{children:e("settings.agents.sidebar.dialog.deleteDescription",{name:u?.name??""})})]}),s.jsxs(ns,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:L,disabled:c,children:e("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",onClick:z,disabled:c,children:e("settings.common.actions.delete")})]})]})}),s.jsx(Ut,{open:i!==null,onOpenChange:J=>!J&&o(null),children:s.jsxs(zt,{children:[s.jsxs(Bt,{children:[s.jsx(Vt,{children:e("settings.agents.sidebar.renameDialog.title")}),s.jsx(Ht,{children:e("settings.agents.sidebar.renameDialog.description",{name:i?.name??""})})]}),s.jsx(Qe,{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"&&U()}}),s.jsxs(ns,{children:[s.jsx(G,{size:"sm",variant:"ghost",onClick:()=>o(null),children:e("settings.common.actions.cancel")}),s.jsx(G,{size:"sm",onClick:U,children:e("settings.common.actions.rename")})]})]})})]})},Il=t=>{const e=Le.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}=Oe(),f=n;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=vr(),e[0]=h):h=e[0];const b=h,[x,y]=m.useState(!1);let v;e[1]!==o||e[2]!==u||e[3]!==r||e[4]!==l||e[5]!==g?(v=W=>s.jsxs(s.Fragment,{children:[l&&s.jsxs(W,{onClick:U=>{U.stopPropagation(),l()},children:[s.jsx(ee,{name:"edit",className:"h-4 w-4 me-px"}),g("settings.common.actions.rename")]}),s.jsxs(W,{onClick:U=>{U.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:U=>{U.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:U=>{U.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]=v):v=e[6];const w=v,k=a?"bg-interactive-selection":"hover:bg-interactive-hover";let N;e[7]!==k?(N=Ye("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",k),e[7]=k,e[8]=N):N=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=b?void 0:W=>{W.preventDefault(),y(!0)},e[9]=j):j=e[9];let P;e[10]!==N?(P=s.jsx("div",{className:N,onContextMenu:j}),e[10]=N,e[11]=P):P=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 I;e[14]!==n.mode||e[15]!==d?(I=d(n.mode),e[14]=n.mode,e[15]=d,e[16]=I):I=e[16];let S;e[17]!==n||e[18]!==f.scope||e[19]!==g?(S=(f.scope||Oi(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:Oi(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 A;e[21]!==C||e[22]!==I||e[23]!==S?(A=s.jsxs("div",{className:"flex items-center gap-1.5",children:[C,I,S]}),e[21]=C,e[22]=I,e[23]=S,e[24]=A):A=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 D;e[27]!==i||e[28]!==A||e[29]!==T?(D=s.jsxs("button",{onClick:i,className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,children:[A,T]}),e[27]=i,e[28]=A,e[29]=T,e[30]=D):D=e[30];let R;e[31]!==p?(R=W=>{W&&y(!1),p(W)},e[31]=p,e[32]=R):R=e[32];let O;e[33]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(Aa,{asChild:!0,children:s.jsx(G,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -me-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(ee,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=O):O=e[33];let F;e[34]!==w?(F=s.jsx(Pa,{align:"end",className:"w-fit min-w-20",children:w(wa)}),e[34]=w,e[35]=F):F=e[35];let E;e[36]!==c||e[37]!==R||e[38]!==F?(E=s.jsxs(Ta,{open:c,onOpenChange:R,children:[O,F]}),e[36]=c,e[37]=R,e[38]=F,e[39]=E):E=e[39];let M;e[40]!==D||e[41]!==E?(M=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[D,E]}),e[40]=D,e[41]=E,e[42]=M):M=e[42];let L;e[43]!==M||e[44]!==P?(L=s.jsx(Qi,{render:P,children:M}),e[43]=M,e[44]=P,e[45]=L):L=e[45];let z;e[46]!==w?(z=s.jsx(Gi,{className:"w-fit min-w-20",children:w(Ji)}),e[46]=w,e[47]=z):z=e[47];let $;return e[48]!==x||e[49]!==L||e[50]!==z?($=s.jsxs(Yi,{open:x,onOpenChange:y,children:[L,z]}),e[48]=x,e[49]=L,e[50]=z,e[51]=$):$=e[51],$},dn={ok:!0,changed:!1},Zn={ok:!0,changed:!0},Ps=t=>({ok:!1,reason:t}),Jb=t=>t instanceof HTMLElement?t.matches('input, textarea, [contenteditable="true"]'):!1,fi=t=>{const{t:e}=Oe(),[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=>{Jb(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}},Qb=["allow","ask","deny"],Yb=["shell","edit","read","glob","grep","patch","webfetch","websearch","skill","subagent","question","external_directory"],Zb=["openchamber","openchamber_schedule","openchamber_web","openchamber_memory","openchamber_knowledge","openchamber_notify","openchamber_render","openchamber_image","openchamber_secret"],Xb=new Set(["bash","task","write","list","lsp","todowrite","todoread","multiedit","doom_loop","plan_enter","plan_exit"]),Ju=t=>Xb.has(t),e1=[{action:"*",resource:"*",effect:"allow"},{action:"read",resource:"*.env",effect:"ask"},{action:"read",resource:"*.env.*",effect:"ask"},{action:"read",resource:"*.env.example",effect:"allow"}],Rc=()=>({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}))}]))}),t1=t=>{const e={global:null,keys:{},source:t.map(n=>({...n}))};for(const n of t){if(Ju(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},s1=t=>t.action!=="*"||t.resource==="*",Ua=(t,e)=>`${t}\0${e}`,n1=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},ar=t=>{const e=n1(t),n=new Set,a=[];for(const o of t.source){if(Ju(o.action))continue;if(!s1(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},a1=(t,e)=>JSON.stringify(ar(t))===JSON.stringify(ar(e)),i1=(t,e)=>{const n=[...e1,...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},o1=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),l1=new Set(["shell","edit","read","glob","grep","patch","webfetch","skill","subagent","external_directory"]),r1={effect:null,patterns:[]},c1=t=>{const e=Le.c(163),{agent:n,registerSave:a,requestSave:i}=t,{t:o}=Oe(),l=Jn(d1),r=Jn(u1);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(Rc),[f,h]=m.useState(Rc),[b,x]=m.useState(!0),[y,v]=m.useState(!1);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w={},e[1]=w):w=e[1];const[k,N]=m.useState(w),[j,P]=m.useState(""),[C,I]=m.useState(0),S=n.name,A=vn(),T=Qn(m1);let D;e[2]!==A?(D=Ge=>yr(Ge,A),e[2]=A,e[3]=D):D=e[3];const R=Qn(D);let O;e[4]!==A?(O=Ge=>Ge.getStatusForDirectory(A),e[4]=A,e[5]=O):O=e[5];const F=Kn(O);let E,M;e[6]!==T||e[7]!==A?(E=()=>{T({directory:A})},M=[T,A],e[6]=T,e[7]=A,e[8]=E,e[9]=M):(E=e[8],M=e[9]),m.useEffect(E,M);let L;e[10]!==S||e[11]!==r||e[12]!==A?(L=()=>{let Ge=!1;return x(!0),v(!1),(async()=>{const ft=await r(S,A);if(Ge)return;if(!ft){v(!0),x(!1);return}const ct=t1(ft.agent);c(ft.global),g(Oa(ct)),h(ct),N({}),x(!1)})(),()=>{Ge=!0}},e[10]=S,e[11]=r,e[12]=A,e[13]=L):L=e[13];let z;e[14]!==S||e[15]!==r||e[16]!==C||e[17]!==A?(z=[S,r,C,A],e[14]=S,e[15]=r,e[16]=C,e[17]=A,e[18]=z):z=e[18],m.useEffect(L,z);let $;e[19]!==S||e[20]!==p||e[21]!==f||e[22]!==A||e[23]!==o||e[24]!==l?($=async()=>a1(f,p)?dn:(await l(S,{permissions:ar(f)},A)).ok?(g(Oa(f)),Zn):Ps(o("settings.agents.page.permissionsEditor.toast.saveFailed")),e[19]=S,e[20]=p,e[21]=f,e[22]=A,e[23]=o,e[24]=l,e[25]=$):$=e[25];const W=$;let U,H;e[26]!==a||e[27]!==W?(U=()=>(a(W),()=>a(null)),H=[a,W],e[26]=a,e[27]=W,e[28]=U,e[29]=H):(U=e[28],H=e[29]),m.useEffect(U,H);let K;e[30]!==R?(K=R.map(p1),e[30]=R,e[31]=K):K=e[31];const _=K;let V;if(e[32]!==_||e[33]!==f.keys){V=[...Yb,...Zb];const Ge=new Set(_.map(g1));let ft;e[35]!==f.keys?(ft=Object.keys(f.keys),e[35]=f.keys,e[36]=ft):ft=e[36];for(const ct of ft)!V.includes(ct)&&!Ge.has(ct)&&V.push(ct);e[32]=_,e[33]=f.keys,e[34]=V}else V=e[34];const q=V;let X;e[37]!==F||e[38]!==o?(X=Ge=>{switch(F?.[Ge]?.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]=F,e[38]=o,e[39]=X):X=e[39];const ae=X;let ce;e[40]!==d||e[41]!==f.global?(ce=Ge=>i1(Ge,{global:d,agentGlobal:f.global}),e[40]=d,e[41]=f.global,e[42]=ce):ce=e[42];const J=ce;let de;e[43]!==i?(de=Ge=>{h(ft=>({...ft,global:Ge})),i()},e[43]=i,e[44]=de):de=e[44];const pe=de;let fe;e[45]!==i?(fe=(Ge,ft)=>{h(ct=>{const Se=Oa(ct),Ze=Se.keys[Ge]??{effect:null,patterns:[]};return Ze.effect=ft,Ze.effect===null&&Ze.patterns.length===0?delete Se.keys[Ge]:Se.keys[Ge]=Ze,Se}),i()},e[45]=i,e[46]=fe):fe=e[46];const ve=fe;let ye;e[47]!==i?(ye=(Ge,ft,ct,Se,Ze)=>{h(at=>{const ht=Oa(at),rt=ht.keys[Ge]??{effect:null,patterns:[]};return rt.patterns[ft]={pattern:ct,effect:Se},ht.keys[Ge]=rt,ht}),Ze&&i()},e[47]=i,e[48]=ye):ye=e[48];const Ae=ye;let te;e[49]===Symbol.for("react.memo_cache_sentinel")?(te=Ge=>{h(ft=>{const ct=Oa(ft),Se=ct.keys[Ge]??{effect:null,patterns:[]};return Se.patterns.push({pattern:"",effect:"allow"}),ct.keys[Ge]=Se,ct}),N(ft=>({...ft,[Ge]:!0}))},e[49]=te):te=e[49];const Y=te;let ue;e[50]!==i?(ue=(Ge,ft)=>{h(ct=>{const Se=Oa(ct),Ze=Se.keys[Ge];return Ze?(Ze.patterns.splice(ft,1),Ze.effect===null&&Ze.patterns.length===0&&delete Se.keys[Ge],Se):ct}),i()},e[50]=i,e[51]=ue):ue=e[51];const be=ue;let Ie;e[52]!==j||e[53]!==i?(Ie=()=>{const Ge=j.trim();!Ge||Ge==="*"||(h(ft=>{if(ft.keys[Ge])return ft;const ct=Oa(ft);return ct.keys[Ge]={effect:"ask",patterns:[]},ct}),P(""),i())},e[52]=j,e[53]=i,e[54]=Ie):Ie=e[54];const Te=Ie;let Fe;e[55]!==o?(Fe=Ge=>o(Ge==="allow"?"settings.agents.page.permissionsEditor.action.allow":Ge==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),e[55]=o,e[56]=Fe):Fe=e[56];const xe=Fe;let me,ne,he,Re,ke,le,De,$e,Me;if(e[57]!==xe||e[58]!==J||e[59]!==k||e[60]!==b||e[61]!==y||e[62]!==_||e[63]!==ae||e[64]!==f.global||e[65]!==f.keys||e[66]!==be||e[67]!==pe||e[68]!==ve||e[69]!==Ae||e[70]!==o||e[71]!==q){Me=Symbol.for("react.early_return_sentinel");e:{const Ge=o("settings.agents.page.permissionsEditor.action.inherit"),ft=o("settings.agents.page.permissionsEditor.action.default");let ct;e[81]!==xe?(ct=qe=>[...qe?[{value:"inherit",label:qe}]:[],...Qb.map(pt=>({value:pt,label:xe(pt)}))],e[81]=xe,e[82]=ct):ct=e[82];const Se=ct,Ze=(qe,pt,wt,yt)=>{const It=yt===void 0?Ge:yt;return s.jsx(Yt,{value:qe??"inherit",options:Se(It),onChange:Nt=>pt(Nt==="inherit"?null:Nt),"aria-label":wt})};if(b){let qe;e[83]!==o?(qe=o("settings.agents.page.section.toolPermissions"),e[83]=o,e[84]=qe):qe=e[84];let pt;e[85]!==o?(pt=o("common.loading"),e[85]=o,e[86]=pt):pt=e[86];let wt;e[87]!==pt?(wt=s.jsx("p",{className:Wt,children:pt}),e[87]=pt,e[88]=wt):wt=e[88];let yt;e[89]!==qe||e[90]!==wt?(yt=s.jsx(Ve,{title:qe,children:wt}),e[89]=qe,e[90]=wt,e[91]=yt):yt=e[91],Me=yt;break e}if(y){let qe;e[92]!==o?(qe=o("settings.agents.page.section.toolPermissions"),e[92]=o,e[93]=qe):qe=e[93];let pt;e[94]!==o?(pt=o("settings.agents.page.permissionsEditor.state.loadFailed"),e[94]=o,e[95]=pt):pt=e[95];let wt;e[96]!==pt?(wt=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:pt}),e[96]=pt,e[97]=wt):wt=e[97];let yt;e[98]===Symbol.for("react.memo_cache_sentinel")?(yt=()=>I(f1),e[98]=yt):yt=e[98];let It;e[99]!==o?(It=o("settings.agents.page.permissionsEditor.actions.retry"),e[99]=o,e[100]=It):It=e[100];let Nt;e[101]!==It?(Nt=s.jsx(G,{variant:"outline",size:"xs",onClick:yt,children:It}),e[101]=It,e[102]=Nt):Nt=e[102];let ze;e[103]!==wt||e[104]!==Nt?(ze=s.jsxs("div",{className:"flex items-center gap-3",children:[wt,Nt]}),e[103]=wt,e[104]=Nt,e[105]=ze):ze=e[105];let ge;e[106]!==qe||e[107]!==ze?(ge=s.jsx(Ve,{title:qe,children:ze}),e[106]=qe,e[107]=ze,e[108]=ge):ge=e[108],Me=ge;break e}const at=(qe,pt,wt)=>{const yt=f.keys[qe]??r1,It=l1.has(qe)||yt.patterns.length>0,Nt=k[qe]===!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:It?()=>N(ze=>({...ze,[qe]:!Nt})):void 0,className:Ye("flex min-w-0 items-center gap-1.5 text-start",!It&&"cursor-default"),"aria-expanded":It?Nt:void 0,children:[s.jsx(ee,{name:Nt&&It?"arrow-down-s":"arrow-right-s",className:Ye("h-3.5 w-3.5 shrink-0 text-muted-foreground",!It&&"opacity-0")}),s.jsx("span",{className:cs,children:pt}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground",children:qe}),wt&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:wt}),yt.effect===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:xe(J(qe))})}),yt.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(yt.patterns.length)})})]}),Ze(yt.effect,ze=>ve(qe,ze),o("settings.agents.page.permissionsEditor.keyAria",{key:qe}))]}),Nt&&It&&s.jsxs("div",{className:"mt-2 space-y-2 ps-5",children:[yt.patterns.map((ze,ge)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Qe,{value:ze.pattern,onChange:Je=>Ae(qe,ge,Je.target.value,ze.effect,!1),placeholder:o("settings.agents.page.permissionsEditor.patternPlaceholder"),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:qe}),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(Yt,{value:ze.effect,options:Se(),onChange:Je=>Ae(qe,ge,ze.pattern,Je,!0),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:qe})}),s.jsx(G,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>be(qe,ge),"aria-label":o("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx(ee,{name:"close",className:"h-3.5 w-3.5"})})]},ge)),s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Y(qe),children:[s.jsx(ee,{name:"add",className:"me-1 h-3.5 w-3.5"}),o("settings.agents.page.permissionsEditor.actions.addRule")]})]})]},qe)};me=Ve,e[109]!==o?(ne=o("settings.agents.page.section.toolPermissions"),e[109]=o,e[110]=ne):ne=e[110],he="agents.permissions",e[111]!==o?(Re=o("settings.agents.page.permissionsEditor.sectionInfo"),e[111]=o,e[112]=Re):Re=e[112],ke="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 rt;e[115]!==ht?(rt=s.jsx("span",{className:cs,children:ht}),e[115]=ht,e[116]=rt):rt=e[116];let xt;e[117]!==o?(xt=o("settings.agents.page.permissionsEditor.defaultInfo"),e[117]=o,e[118]=xt):xt=e[118];let oe;e[119]!==xt?(oe=s.jsx(us,{children:xt}),e[119]=xt,e[120]=oe):oe=e[120];let Z;e[121]!==xe||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:xe(J("*"))})}),e[121]=xe,e[122]=J,e[123]=f.global,e[124]=o,e[125]=Z):Z=e[125];let it;e[126]!==rt||e[127]!==oe||e[128]!==Z?(it=s.jsxs("div",{className:"flex items-center gap-1.5",children:[rt,oe,Z]}),e[126]=rt,e[127]=oe,e[128]=Z,e[129]=it):it=e[129];const jt=f.global;let We;e[130]!==o?(We=o("settings.agents.page.permissionsEditor.defaultAria"),e[130]=o,e[131]=We):We=e[131],le=s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[it,Ze(jt,pe,We,ft)]}),De=s.jsx("div",{children:q.map(qe=>at(qe,o1(qe),null))}),$e=_.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")})]}),_.map(qe=>at(qe.key,qe.server,ae(qe.server)))]})}e[57]=xe,e[58]=J,e[59]=k,e[60]=b,e[61]=y,e[62]=_,e[63]=ae,e[64]=f.global,e[65]=f.keys,e[66]=be,e[67]=pe,e[68]=ve,e[69]=Ae,e[70]=o,e[71]=q,e[72]=me,e[73]=ne,e[74]=he,e[75]=Re,e[76]=ke,e[77]=le,e[78]=De,e[79]=$e,e[80]=Me}else me=e[72],ne=e[73],he=e[74],Re=e[75],ke=e[76],le=e[77],De=e[78],$e=e[79],Me=e[80];if(Me!==Symbol.for("react.early_return_sentinel"))return Me;let se;e[132]===Symbol.for("react.memo_cache_sentinel")?(se=Ge=>P(Ge.target.value),e[132]=se):se=e[132];let Ce;e[133]!==Te?(Ce=Ge=>{Ge.key==="Enter"&&(Ge.preventDefault(),Te())},e[133]=Te,e[134]=Ce):Ce=e[134];let Ne;e[135]!==o?(Ne=o("settings.agents.page.permissionsEditor.customKeyPlaceholder"),e[135]=o,e[136]=Ne):Ne=e[136];let Ee;e[137]!==j||e[138]!==Ce||e[139]!==Ne?(Ee=s.jsx(Qe,{value:j,onChange:se,onKeyDown:Ce,placeholder:Ne,className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),e[137]=j,e[138]=Ce,e[139]=Ne,e[140]=Ee):Ee=e[140];let we;e[141]!==j?(we=j.trim(),e[141]=j,e[142]=we):we=e[142];const Ue=!we;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 nt;e[144]!==o?(nt=o("settings.agents.page.permissionsEditor.actions.addKey"),e[144]=o,e[145]=nt):nt=e[145];let Be;e[146]!==Te||e[147]!==Ue||e[148]!==nt?(Be=s.jsxs(G,{variant:"outline",size:"xs",className:"!font-normal",onClick:Te,disabled:Ue,children:[_e,nt]}),e[146]=Te,e[147]=Ue,e[148]=nt,e[149]=Be):Be=e[149];let tt;e[150]!==Ee||e[151]!==Be?(tt=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-edge-muted pt-3",children:[Ee,Be]}),e[150]=Ee,e[151]=Be,e[152]=tt):tt=e[152];let ut;return e[153]!==me||e[154]!==ne||e[155]!==he||e[156]!==Re||e[157]!==ke||e[158]!==le||e[159]!==De||e[160]!==$e||e[161]!==tt?(ut=s.jsxs(me,{title:ne,settingsItem:he,info:Re,contentClassName:ke,children:[le,De,$e,tt]}),e[153]=me,e[154]=ne,e[155]=he,e[156]=Re,e[157]=ke,e[158]=le,e[159]=De,e[160]=$e,e[161]=tt,e[162]=ut):ut=e[162],ut};function d1(t){return t.updateAgent}function u1(t){return t.fetchAgentPermissions}function m1(t){return t.loadMcpConfigs}function p1(t){return{key:`${t.name}_*`,server:t.name}}function g1(t){return t.key}function f1(t){return t+1}const Kr=t=>{const e=Le.c(11),{legacy:n,path:a,className:i}=t,{t:o}=Oe();if(!n)return null;let l;e[0]!==i?(l=Ye("mb-4 flex items-start gap-1.5",Wt,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},h1=(t,e)=>{const n=ra(e);if(!n)return[];const a=t.find(o=>o.id===n.providerId),i=Af(a?.models,n.modelId);return uu(i)},b1=t=>jp(t)?.toLowerCase()??"",x1=()=>{const{t}=Oe(),e=gt(xe=>xe.providers),{selectedAgentName:n,getAgentByName:a,createAgent:i,updateAgent:o,fetchAgentEntity:l,agentDraft:r,setAgentDraft:u,setSelectedAgent:d}=Jn(Ys(xe=>({selectedAgentName:xe.selectedAgentName,getAgentByName:xe.getAgentByName,createAgent:xe.createAgent,updateAgent:xe.updateAgent,fetchAgentEntity:xe.fetchAgentEntity,agentDraft:xe.agentDraft,setAgentDraft:xe.setAgentDraft,setSelectedAgent:xe.setSelectedAgent}))),c=vn(),p=Jn(xe=>du(xe,c)),g=n?a(n,c):null,f=!!(r&&r.name===n&&!g),h=f?"":g?.description?.trim()??"",b=f?"":g?.system?.trim()??"",[x,y]=m.useState(""),[v,w]=m.useState("user"),[k,N]=m.useState(""),[j,P]=m.useState("subagent"),[C,I]=m.useState(""),[S,A]=m.useState(""),[T,D]=m.useState(void 0),[R,O]=m.useState(void 0),[F,E]=m.useState(void 0),[M,L]=m.useState(""),[z,$]=m.useState(""),[W,U]=m.useState(!1),[H,K]=m.useState(null),_=m.useRef({}),V=m.useRef(null),q=m.useCallback(xe=>{V.current=xe},[]),X=m.useRef(null),ae=JSON.stringify([n,c,f]),ce=m.useRef(ae);ce.current=ae;const J=m.useRef(null),de={description:k,mode:j,model:C,variant:S,steps:T,temperature:R,topP:F,system:M,color:z},pe=m.useRef(de);pe.current=de;const fe=m.useMemo(()=>h1(e,C),[C,e]),ve=fe.length>0,ye=S||"__default",Ae=ve,te=m.useMemo(()=>S&&!fe.includes(S)?[S,...fe]:fe,[S,fe]);m.useEffect(()=>{if(!f||!r)return;J.current=null;const xe=Li(r.model),me=r.name||"",ne=r.scope||"user",he=r.description||"",Re=r.mode||"subagent",ke=xe?`${xe.providerID}/${xe.modelID}`:"",le=xe?.variant||"",De=r.steps??void 0,$e=r.temperature??void 0,Me=r.top_p??void 0,se=r.system||"",Ce="";_.current={},K(null),y(me),w(ne),N(he),P(Re),I(ke),A(le),D(De),O($e),E(Me),L(se),$(Ce),X.current={draftName:me,draftScope:ne,description:he,mode:Re,model:ke,variant:le,steps:De,temperature:$e,topP:Me,system:se,color:Ce}},[r,f]),m.useEffect(()=>{if(f||!n)return;let xe=!1;return(async()=>{const me=await l(n,c);if(xe||ce.current!==ae||!me)return;const ne=me.config;_.current=ne;const he=Li(ne.model),Re=ne.request?.body,ke={draftName:"",draftScope:"user",description:ne.description||"",mode:ne.mode||g?.mode||"subagent",model:he?`${he.providerID}/${he.modelID}`:"",variant:he?.variant||"",steps:ne.steps??void 0,temperature:Re?.temperature,topP:Re?.top_p,system:ne.system||"",color:b1(ne.color)},le=X.current,De=pe.current,$e=le!==null&&(De.description!==le.description||De.mode!==le.mode||De.model!==le.model||De.variant!==le.variant||De.steps!==le.steps||De.temperature!==le.temperature||De.topP!==le.topP||De.system!==le.system||De.color!==le.color);K({legacy:me.legacy===!0,path:me.path,source:me.source}),!(J.current===ae&&$e)&&(J.current=ae,N(ke.description),P(ke.mode),I(ke.model),A(ke.variant),D(ke.steps),O(ke.temperature),E(ke.topP),L(ke.system),$(ke.color),X.current=ke)})(),()=>{xe=!0}},[l,f,g,n,c,ae]);const Y=m.useCallback(xe=>{const me=ra(C.trim()),ne=me?Ru({providerID:me.providerId,modelID:me.modelId,variant:S.trim()||void 0}):null,he=_.current.request,Re={...he?.body};R===void 0?delete Re.temperature:Re.temperature=R,F===void 0?delete Re.top_p:Re.top_p=F;const ke=he?.headers,le={};ke&&Object.keys(ke).length>0&&(le.headers=ke),Object.keys(Re).length>0&&(le.body=Re);const De=k.trim(),$e=M.trim(),Me={name:xe,mode:j,model:ne,steps:T??null,system:$e||(f?void 0:null),request:Object.keys(le).length>0?le:null};return De&&(Me.description=De),z!==(X.current?.color??"")&&(Me.color=z||null),f&&v&&(Me.scope=v),f&&r?.hidden!==void 0&&(Me.hidden=r.hidden),f&&r?.permissions?.length&&(Me.permissions=r.permissions),Me},[r,z,k,v,f,j,C,T,M,R,F,S]),ue=m.useCallback(async()=>{const xe=X.current,me=n?.trim();if(f||!xe||!me)return dn;const ne=V.current?await V.current():dn;if(k===xe.description&&j===xe.mode&&C===xe.model&&S===xe.variant&&T===xe.steps&&R===xe.temperature&&F===xe.topP&&M===xe.system&&z===xe.color||!ne.ok)return ne;const Re=Y(me);return(await o(me,Re,c)).ok?(ce.current!==ae||(_.current={..._.current,model:Re.model,system:Re.system??void 0,steps:Re.steps,request:Re.request??void 0},X.current={...xe,description:k,mode:j,model:C,variant:S,steps:T,temperature:R,topP:F,system:M,color:z}),Zn):Ps(t("settings.agents.page.toast.updateFailed"))},[Y,z,k,f,j,C,n,ae,c,T,M,t,R,F,o,S]),be=fi(ue),{requestSave:Ie}=be,Te=async()=>{const xe=x.trim().replace(/\s+/g,"-");if(!xe){Q.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(p.some(me=>me.name===xe)){Q.error(t("settings.agents.sidebar.toast.agentExists"));return}U(!0);try{(await i(Y(xe),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 ne=me instanceof Error&&me.message?me.message:t("settings.agents.page.toast.saveUnexpectedError");Q.error(ne)}finally{U(!1)}},Fe=()=>{u(null),d(null)};return n?s.jsxs(ss,{title:f?t("settings.agents.page.title.new"):n,description:t(f?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit"),onBlurCapture:be.onBlurCapture,children:[!f&&H&&s.jsx(Kr,{legacy:H.legacy,path:H.path}),!f&&H?.source==="none"&&s.jsxs("p",{className:`mb-4 flex items-start gap-1.5 ${Wt}`,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(Ve,{title:t("settings.agents.page.section.identityRole"),divider:!1,contentClassName:"space-y-3",children:[f&&s.jsxs(ot,{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(Qe,{value:x,onChange:xe=>y(xe.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Kt,{value:v,onValueChange:xe=>w(xe),children:[s.jsx(Ft,{className:"w-fit min-w-[100px]",children:s.jsx($t,{children:t(v==="project"?"settings.common.scope.project":"settings.common.scope.global")})}),s.jsxs(Lt,{align:"end",children:[s.jsx(bt,{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(bt,{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:k,onChange:xe=>N(xe.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(Yt,{"aria-label":t("settings.agents.page.field.mode"),value:j,onChange:xe=>{P(xe),Ie()},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(Oh,{value:z,labels:{empty:t("settings.agents.page.field.colorAutomatic"),swatch:xe=>t("settings.agents.page.field.colorSwatchAria",{color:xe}),custom:t("settings.agents.page.field.colorCustomAria"),hex:t("settings.agents.page.field.colorHexAria")},onChange:xe=>{$(xe),Ie()}})})]}),s.jsxs(Ve,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx(ot,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(ja,{providerId:ra(C)?.providerId??"",modelId:ra(C)?.modelId??"",onChange:(xe,me)=>{I(xe&&me?`${xe}/${me}`:""),A(""),Ie()},className:Cn})}),s.jsx(ot,{settingsItem:"agents.variant",label:t("settings.agents.page.field.variant"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.variantTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.variantHint")})]}),children:Ae?s.jsxs(Kt,{value:ye,onValueChange:xe=>{A(xe==="__default"?"":xe),Ie()},children:[s.jsx(Ft,{className:Ts,children:s.jsx($t,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:xe=>xe==="__default"?t("chat.modelControls.default"):xe})}),s.jsxs(Lt,{children:[s.jsx(bt,{value:"__default",children:t("chat.modelControls.default")}),te.map(xe=>s.jsx(bt,{value:xe,children:xe},xe))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Qe,{value:S,onChange:xe=>A(xe.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!C&&!S,className:"h-8 w-40 rounded-md px-3"}),S&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{A(""),Ie()},className:is,"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(ot,{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(js,{value:R,fallbackValue:.7,onValueChange:O,onClear:()=>{O(void 0),Ie()},min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:ws}),R!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{O(void 0),Ie()},className:is,"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(ot,{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(js,{value:F,fallbackValue:.9,onValueChange:E,onClear:()=>{E(void 0),Ie()},min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:ws}),F!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{E(void 0),Ie()},className:is,"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(ot,{settingsItem:"agents.steps",label:t("settings.agents.page.field.steps"),info:t("settings.agents.page.field.stepsTooltip"),children:[s.jsx(js,{value:T,fallbackValue:20,onValueChange:D,onClear:()=>{D(void 0),Ie()},min:1,max:1e3,step:1,inputMode:"numeric",placeholder:"—",emptyLabel:"—",className:ws}),T!==void 0&&s.jsx(G,{size:"sm",type:"button",variant:"ghost",onClick:()=>{D(void 0),Ie()},className:is,"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(Ve,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx($s,{value:M,onChange:xe=>L(xe.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(c1,{agent:g,registerSave:q,requestSave:Ie}),f&&s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[s.jsx(G,{onClick:()=>{Te()},disabled:W||!x.trim(),size:"xs",className:"!font-normal",children:t(W?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(G,{variant:"ghost",onClick:Fe,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 v1(t,e){return t.kind==="file"?t.content:e??""}const Dc=ts({content:Et(),exists:oo(),path:Et().min(1).optional()}),y1=async(t,e)=>{const n=await t.json().catch(()=>null);return typeof n?.error=="string"&&n.error.trim()?n.error:e},k1=t=>t.length>0&&!t.endsWith(`
3
3
  `)?`${t}
4
4
  `:t,vo={prompt:"",responseStyleEnabled:!1,responseStylePreset:"concise",responseStyleCustomInstructions:""},j1=(t,e)=>t==="custom"?e:Sp(t),w1=t=>t==="custom"?"custom":mu(t)?t:"concise",Oc={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"},S1=()=>{const{t}=Oe(),[e,n]=m.useState(""),[a,i]=m.useState("AGENTS.md"),[o,l]=m.useState(vo.responseStyleEnabled),[r,u]=m.useState(vo.responseStylePreset),[d,c]=m.useState(vo.responseStyleCustomInstructions),[p,g]=m.useState(!0),f=m.useRef(null),h=m.useRef(null);m.useEffect(()=>{const k=new AbortController;return(async()=>{try{const[j,P]=await Promise.all([bn(),qt("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:k.signal})]);let C=vo,I;j&&(C={...C,responseStyleEnabled:j.responseStyleEnabled===!0,responseStylePreset:w1(j.responseStylePreset),responseStyleCustomInstructions:j.responseStyleCustomInstructions??""},j.globalBehaviorPrompt!==void 0&&(I=j.globalBehaviorPrompt));let S={kind:"missing"};if(P.ok){const A=Dc.parse(await P.json());if(k.signal.aborted)return;i(A.path??"AGENTS.md"),h.current=A.exists?A.content:null,A.exists&&(S={kind:"file",content:A.content})}C={...C,prompt:v1(S,I)},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)}})(),()=>k.abort()},[]);const b=m.useRef(e);b.current=e,m.useEffect(()=>{let k=null;const N=async()=>{if(document.visibilityState!=="visible"||!f.current)return;k?.abort();const P=new AbortController;k=P;try{const C=await qt("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:P.signal});if(!C.ok)return;const I=Dc.parse(await C.json()),S=f.current;if(P.signal.aborted||!S||!I.exists||I.content===h.current||b.current!==S.prompt)return;h.current=I.content,f.current={...S,prompt:I.content},n(I.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),()=>{k?.abort(),window.removeEventListener("focus",j),document.removeEventListener("visibilitychange",j)}},[]);const x=m.useCallback(async()=>{const k=f.current;if(!k||p)return dn;const N=e!==k.prompt,j=o!==k.responseStyleEnabled||r!==k.responseStylePreset||d!==k.responseStyleCustomInstructions;if(!N&&!j)return dn;const P=N?k1(e):k.prompt;if(N){const I=await qt("/api/behavior/agents-md",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:P,expectedContent:h.current})});if(I.status===409)return Ps(t("settings.behavior.page.toast.agentsMdChangedOnDisk"));if(!I.ok)return Ps(await y1(I,t("settings.behavior.page.toast.saveFailed")));h.current=P,n(S=>S===e?P:S)}return(await St({...N?{globalBehaviorPrompt:P}:{},responseStyleEnabled:o,responseStylePreset:r,responseStyleCustomInstructions:d})).ok?(f.current={prompt:P,responseStyleEnabled:o,responseStylePreset:r,responseStyleCustomInstructions:d},Zn):Ps(t("settings.behavior.page.toast.saveFailed"))},[p,e,d,o,r,t]),y=fi(x),{requestSave:v}=y,w=j1(r,d);return s.jsxs(ss,{title:t("settings.behavior.page.title"),description:t("settings.page.behavior.description"),onBlurCapture:y.onBlurCapture,children:[s.jsx(Ve,{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:k=>n(k.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(Ve,{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:k=>{l(k),v()},disabled:p,label:t("settings.behavior.page.responseStyle.enable"),ariaLabel:t("settings.behavior.page.responseStyle.enableAria")}),s.jsx(ot,{label:t("settings.behavior.page.responseStyle.preset"),alignEnd:!1,children:s.jsxs(Kt,{value:r,onValueChange:k=>{u(k),v()},disabled:p||!o,children:[s.jsx(Ft,{className:Ts,children:s.jsx($t,{children:k=>k==="custom"?t("settings.behavior.page.responseStyle.option.custom"):mu(k)?t(Oc[k]):null})}),s.jsxs(Lt,{children:[wp.map(k=>s.jsx(bt,{value:k,children:t(Oc[k])},k)),s.jsx(bt,{value:"custom",children:t("settings.behavior.page.responseStyle.option.custom")})]})]})}),s.jsx($s,{value:w,onChange:k=>c(k.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"})]})]})},N1=(t,e)=>t.kind===e.kind&&(t.kind!=="provider"||e.kind==="provider"&&t.id===e.id),C1=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"})),_r=t=>{const e=Le.c(8),{t:n}=Oe(),a=zi(M1),i=t.projectOverride!==null;let o;e[0]!==i||e[1]!==a||e[2]!==t.selection||e[3]!==n?(o=u=>{i||N1(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},I1=t=>{const e=Le.c(51),{snapshot:n}=t,{t:a}=Oe(),{choose:i,locked:o}=_r(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 k;e[7]!==a?(k=a("settings.webSearch.option.default"),e[7]=a,e[8]=k):k=e[8];let N;e[9]!==o||e[10]!==k?(N={value:"default",label:k,disabled:o},e[9]=o,e[10]=k,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 P;e[16]!==a?(P=a("settings.webSearch.option.off"),e[16]=a,e[17]=P):P=e[17];let C;e[18]!==o||e[19]!==P?(C={value:"off",label:P,disabled:o},e[18]=o,e[19]=P,e[20]=C):C=e[20];let I;e[21]!==N||e[22]!==j||e[23]!==C?(I=[N,...j,C],e[21]=N,e[22]=j,e[23]=C,e[24]=I):I=e[24],r=I,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(Yt,{"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:Wt,children:d}),e[38]=d,e[39]=b):b=e[39];let x;e[40]!==n.projectOverride||e[41]!==a?(x=n.projectOverride?s.jsx("p",{className:`${Wt} break-all`,children:a("settings.webSearch.state.projectOverride",{path:n.projectOverride})}):null,e[40]=n.projectOverride,e[41]=a,e[42]=x):x=e[42];let y;e[43]!==h||e[44]!==b||e[45]!==x?(y=s.jsxs("div",{className:"space-y-2",children:[h,b,x]}),e[43]=h,e[44]=b,e[45]=x,e[46]=y):y=e[46];let v;return e[47]!==c||e[48]!==p||e[49]!==y?(v=s.jsx(Ve,{title:c,info:p,divider:!1,settingsItem:"web-search.provider",children:y}),e[47]=c,e[48]=p,e[49]=y,e[50]=v):v=e[50],v},P1=t=>{const e=Le.c(32),{entry:n,snapshot:a,onOpen:i}=t,{t:o}=Oe(),{choose:l,locked:r}=_r(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(Os,{tone:"success",children:o("settings.webSearch.card.inUse")}):!c&&g?.kind==="none"?s.jsx(Os,{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 x;e[6]!==g||e[7]!==o||e[8]!==f||e[9]!==c?(x=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]=x):x=e[10];const y=x;let v;e[11]!==l||e[12]!==p||e[13]!==r||e[14]!==u.id||e[15]!==o||e[16]!==c?(v=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]=v):v=e[17];const w=v;let k;e[18]===Symbol.for("react.memo_cache_sentinel")?(k=s.jsx(Wi,{name:"global"}),e[18]=k):k=e[18];const N=u.name;let j;e[19]!==y?(j=y?s.jsx("span",{className:"min-w-0 truncate",children:y}):null,e[19]=y,e[20]=j):j=e[20];const P=!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 I;return e[24]!==w||e[25]!==i||e[26]!==b||e[27]!==u.name||e[28]!==j||e[29]!==P||e[30]!==C?(I=s.jsx(Yn,{icon:k,title:N,badges:b,footer:j,muted:P,onOpen:i,actions:w,actionsLabel:C}),e[24]=w,e[25]=i,e[26]=b,e[27]=u.name,e[28]=j,e[29]=P,e[30]=C,e[31]=I):I=e[31],I},A1=t=>{const e=Le.c(82),{provider:n,access:a,connect:i,locked:o}=t,{t:l}=Oe(),r=zi(R1),u=zi(D1),[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),x=i.kind==="key";let y;if(e[1]!==a.envNames||e[2]!==i.fields||e[3]!==l||e[4]!==x){const M=a.envNames.join(", ");let L;e[6]!==l?(L=$=>[$.description,$.placeholder?l("settings.webSearch.keys.fieldExample",{example:$.placeholder}):null],e[6]=l,e[7]=L):L=e[7];const z=[...i.fields.flatMap(L),a.envNames.length===0?null:x?l("settings.webSearch.keys.envHint",{names:M}):l("settings.webSearch.keys.envHintForm",{names:M})].filter(O1);y=z.length>0?z.map(F1):void 0,e[1]=a.envNames,e[2]=i.fields,e[3]=l,e[4]=x,e[5]=y}else y=e[5];const v=y;let w;e[8]!==g?(w=Object.fromEntries(Object.entries(g).map(L1).filter(K1)),e[8]=g,e[9]=w):w=e[9];const k=w;let N;e[10]!==i.fields||e[11]!==d||e[12]!==k||e[13]!==x?(N=(!x||d.trim()!=="")&&i.fields.every(M=>!M.required||k[M.key]!==void 0),e[10]=i.fields,e[11]=d,e[12]=k,e[13]=x,e[14]=N):N=e[14];const j=N;let P;e[15]!==j||e[16]!==d||e[17]!==k||e[18]!==n.id||e[19]!==n.name||e[20]!==r||e[21]!==l||e[22]!==x?(P=async()=>{if(!j)return;b(!0);const M=await r(n.id,{key:d.trim(),answer:k});b(!1),M?(c(""),f({}),Q.success(x?l("settings.webSearch.toast.keySaved",{provider:n.name}):l("settings.webSearch.toast.connected",{provider:n.name}))):Q.error(x?l("settings.webSearch.toast.keySaveFailed"):l("settings.webSearch.toast.connectFailed",{provider:n.name}))},e[15]=j,e[16]=d,e[17]=k,e[18]=n.id,e[19]=n.name,e[20]=r,e[21]=l,e[22]=x,e[23]=P):P=e[23];const C=P;let I;e[24]!==n.id||e[25]!==u||e[26]!==l?(I=async()=>{b(!0);const M=await u(n.id);b(!1),M||Q.error(l("settings.webSearch.toast.keyRemoveFailed"))},e[24]=n.id,e[25]=u,e[26]=l,e[27]=I):I=e[27];const S=I;let A;e[28]!==C?(A=M=>{M.key==="Enter"&&C()},e[28]=C,e[29]=A):A=e[29];const T=A;let D,R,O,F;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]!==v||e[39]!==o||e[40]!==n.name||e[41]!==T||e[42]!==l||e[43]!==x){let M;e[48]!==g||e[49]!==n.name||e[50]!==T||e[51]!==l?(M=q=>s.jsx(Qe,{type:q.url?"url":"text",value:g[q.key]??"",onChange:X=>f(ae=>({...ae,[q.key]:X.target.value})),onKeyDown:T,placeholder:q.label,"aria-label":l("settings.webSearch.keys.fieldAria",{provider:n.name,field:q.label}),className:"h-8 min-w-0 flex-1 rounded-md px-3 font-mono text-xs"},q.key),e[48]=g,e[49]=n.name,e[50]=T,e[51]=l,e[52]=M):M=e[52];const L=i.fields.map(M);if(x){let q;e[53]===Symbol.for("react.memo_cache_sentinel")?(q=J=>c(J.target.value),e[53]=q):q=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 ce;e[59]!==d||e[60]!==T||e[61]!==X||e[62]!==ae?(ce=s.jsx(Qe,{type:"password",value:d,onChange:q,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]=ce):ce=e[63],L.push(ce)}const z=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 U;e[68]!==z||e[69]!==$||e[70]!==W?(U=s.jsx(G,{size:"xs",disabled:z,onClick:$,children:W}),e[68]=z,e[69]=$,e[70]=W,e[71]=U):U=e[71];const H=U,K=a.key;let _;e[72]!==i.fields[0]||e[73]!==i.fields.length||e[74]!==l||e[75]!==x?(_=x?l("settings.webSearch.keys.label"):i.fields.length===1&&i.fields[0]?i.fields[0].label:l("settings.webSearch.keys.connectionLabel"),e[72]=i.fields[0],e[73]=i.fields.length,e[74]=l,e[75]=x,e[76]=_):_=e[76];const V=_;D=ot,O=V,F=v,R=K.kind==="stored"?s.jsxs("div",{className:`${hn} flex items-center justify-end gap-2`,children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:l(x?"settings.webSearch.keys.saved":"settings.webSearch.keys.connected")}),s.jsx(G,{variant:"outline",size:"xs",disabled:h,onClick:()=>{S()},children:l("settings.webSearch.keys.remove")})]}):K.kind==="env"?s.jsx("span",{className:"typography-meta text-muted-foreground",children:l("settings.webSearch.keys.fromEnv",{name:K.name})}):o?null:L.length===1?s.jsxs("div",{className:`${hn} flex items-center gap-2`,children:[L,H]}):s.jsxs("div",{className:`${hn} flex flex-col gap-2`,children:[L.slice(0,-1).map(_1),s.jsxs("div",{className:"flex items-center gap-2",children:[L.at(-1),H]})]}),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]=v,e[39]=o,e[40]=n.name,e[41]=T,e[42]=l,e[43]=x,e[44]=D,e[45]=R,e[46]=O,e[47]=F}else D=e[44],R=e[45],O=e[46],F=e[47];let E;return e[77]!==D||e[78]!==R||e[79]!==O||e[80]!==F?(E=s.jsx(D,{label:O,info:F,children:R}),e[77]=D,e[78]=R,e[79]=O,e[80]=F,e[81]=E):E=e[81],E},T1=t=>{const e=Le.c(44),{entry:n,snapshot:a,onBack:i}=t,{t:o}=Oe(),{choose:l,locked:r}=_r(a),u=Xn(),{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,x=d.name;let y;e[6]!==o?(y=o("settings.webSearch.detail.back"),e[6]=o,e[7]=y):y=e[7];let v;e[8]!==i||e[9]!==y?(v=s.jsx(ci,{label:y,onClick:i}),e[8]=i,e[9]=y,e[10]=v):v=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 k;e[13]!==l||e[14]!==g||e[15]!==r||e[16]!==d.id||e[17]!==o||e[18]!==p?(k=p&&!g?s.jsx(G,{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]=k):k=e[19];let N;e[20]!==a.projectOverride||e[21]!==o?(N=a.projectOverride?s.jsx("p",{className:`${Wt} 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]!==k||e[25]!==N?(j=s.jsx(Ve,{divider:!1,children:s.jsxs("div",{className:"space-y-2",children:[w,k,N]})}),e[23]=w,e[24]=k,e[25]=N,e[26]=j):j=e[26];let P;e[27]!==u||e[28]!==o?(P=u?s.jsx("p",{className:Wt,children:o("settings.webSearch.keys.enterpriseMode")}):null,e[27]=u,e[28]=o,e[29]=P):P=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:Wt,children:o("settings.webSearch.state.keysUnavailable")}):f?s.jsx(A1,{provider:d,access:c,connect:f,locked:u}):s.jsx("p",{className:Wt,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 I;e[36]!==C||e[37]!==P?(I=s.jsx(Ve,{children:s.jsxs("div",{className:"space-y-4",children:[P,C]})}),e[36]=C,e[37]=P,e[38]=I):I=e[38];let S;return e[39]!==d.name||e[40]!==I||e[41]!==v||e[42]!==j?(S=s.jsxs(ss,{title:x,titleLeading:v,showSaveStatus:!0,children:[j,I]}),e[39]=d.name,e[40]=I,e[41]=v,e[42]=j,e[43]=S):S=e[43],S},E1=()=>{const t=Le.c(16),{t:e}=Oe(),n=zi($1),a=zi(U1),[i,o]=m.useState(null);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=Np(),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?C1(c):[],h=i?f.find(y=>y.provider.id===i)??null:null;if(c&&h){let y;t[11]===Symbol.for("react.memo_cache_sentinel")?(y=()=>o(null),t[11]=y):y=t[11],g=s.jsx(T1,{entry:h,snapshot:c,onBack:y});break e}let b;t[12]!==e?(b=e("settings.page.webSearch.title"),t[12]=e,t[13]=b):b=t[13];let x;t[14]!==e?(x=e("settings.page.webSearch.description"),t[14]=e,t[15]=x):x=t[15],p=s.jsx(ss,{title:b,description:x,showSaveStatus:!0,children:c?s.jsxs(s.Fragment,{children:[s.jsx(I1,{snapshot:c}),s.jsxs(Ve,{title:e("settings.webSearch.section.providers"),info:e("settings.webSearch.section.providersInfo"),settingsItem:"web-search.providers",children:[f.length===0?s.jsx("p",{className:Wt,children:e("settings.webSearch.state.noProviders")}):s.jsx("div",{className:pi,children:f.map(y=>s.jsx(P1,{entry:y,snapshot:c,onOpen:()=>o(y.provider.id)},y.provider.id))}),c.access===null?s.jsx("p",{className:`${Wt} mt-3`,children:e("settings.webSearch.state.keysUnavailable")}):null]})]}):n.kind==="failed"?s.jsx(Ve,{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(G,{variant:"outline",size:"xs",onClick:()=>{a()},children:e("settings.webSearch.actions.retry")})]})}):s.jsx(Ve,{divider:!1,children:s.jsx("p",{className:Wt,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 M1(t){return t.setSelection}function R1(t){return t.saveKey}function D1(t){return t.removeKey}function O1(t){return!!t}function F1(t){return s.jsx("span",{className:"block",children:t},t)}function L1(t){const[e,n]=t;return[e,n.trim()]}function K1(t){const[,e]=t;return e!==""}function _1(t,e){return s.jsx("div",{className:"flex",children:t},e)}function $1(t){return t.state}function U1(t){return t.load}const z1=t=>{const e=Le.c(183),{onItemSelect:n}=t,{t:a}=Oe(),[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),[x,y]=m.useState(null),{selectedCommandName:v,setSelectedCommand:w,setCommandDraft:k,createCommand:N,deleteCommand:j,loadCommands:P}=ii(Ys(B1)),C=vn();let I;e[0]!==C?(I=We=>pu(We,C),e[0]=C,e[1]=I):I=e[1];const S=ii(I);let A;e[2]!==C?(A=We=>kr(We,C),e[2]=C,e[3]=A):A=e[3];const T=Js(A),D=Js(V1);let R,O;e[4]!==P||e[5]!==D||e[6]!==C?(R=()=>{P(C),D(C)},O=[P,D,C],e[4]=P,e[5]=D,e[6]=C,e[7]=R,e[8]=O):(R=e[7],O=e[8]),m.useEffect(R,O);let F;e[9]!==T?(F=new Set(T.map(H1)),e[9]=T,e[10]=F):F=e[10];const E=F;let M;if(e[11]!==S||e[12]!==E){let We;e[14]!==E?(We=qe=>!E.has(qe.name),e[14]=E,e[15]=We):We=e[15],M=S.filter(We),e[11]=S,e[12]=E,e[13]=M}else M=e[13];const L=M;let z,$;e[16]!==v||e[17]!==w||e[18]!==E?(z=()=>{v&&E.has(v)&&w(null)},$=[v,w,E],e[16]=v,e[17]=w,e[18]=E,e[19]=z,e[20]=$):(z=e[19],$=e[20]),m.useEffect(z,$);let W;e[21]!==S||e[22]!==n||e[23]!==k||e[24]!==w?(W=()=>{let We="new-command",qe=1;for(;S.some(pt=>pt.name===We);)We=`new-command-${qe}`,qe++;k({name:We,scope:"user"}),w(We),n?.()},e[21]=S,e[22]=n,e[23]=k,e[24]=w,e[25]=W):W=e[25];const U=W;let H;e[26]!==a?(H=async We=>{if(ei(We)){Q.error(a("settings.commands.sidebar.toast.builtInCannotDelete"));return}p(We),f("delete")},e[26]=a,e[27]=H):H=e[27];const K=H;let _;e[28]===Symbol.for("react.memo_cache_sentinel")?(_=async We=>{ei(We)&&(p(We),f("reset"))},e[28]=_):_=e[28];const V=_;let q;e[29]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{p(null),f(null)},e[29]=q):q=e[29];const X=q;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 ce=ae;let J;e[36]!==S||e[37]!==k||e[38]!==w?(J=We=>{const qe=We.name;let pt=1,wt=`${qe}-copy`;for(;S.some(yt=>yt.name===wt);)pt++,wt=`${qe}-copy-${pt}`;k({name:wt,scope:We.scope||"user",description:We.description,template:We.template,agent:We.agent,model:We.model,subagent:We.subagent}),w(wt)},e[36]=S,e[37]=k,e[38]=w,e[39]=J):J=e[39];const de=J;let pe;e[40]===Symbol.for("react.memo_cache_sentinel")?(pe=We=>{d(We.name),r(We)},e[40]=pe):pe=e[40];const fe=pe;let ve;e[41]!==S||e[42]!==N||e[43]!==j||e[44]!==l||e[45]!==u||e[46]!==w||e[47]!==C||e[48]!==a?(ve=async()=>{if(!l)return;const We=u.trim().replace(/\s+/g,"-");if(!We){Q.error(a("settings.commands.sidebar.toast.commandNameRequired"));return}if(We===l.name){r(null);return}if(S.some(pt=>pt.name===We)){Q.error(a("settings.commands.sidebar.toast.commandExists"));return}await N({name:We,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 "${We}"`),w(We)):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]=ve):ve=e[49];const ye=ve;let Ae,te,Y,ue,be,Ie;if(e[50]!==L||e[51]!==U||e[52]!==K||e[53]!==de||e[54]!==n||e[55]!==x||e[56]!==i||e[57]!==v||e[58]!==w||e[59]!==a){let We;e[66]!==i?(We=et=>Hi([et.name,et.description],i),e[66]=i,e[67]=We):We=e[67];const qe=L.filter(We),pt=qe.filter(ei),wt=qe.filter(W1);e[68]===Symbol.for("react.memo_cache_sentinel")?(be=Ye("flex h-full flex-col","bg-background"),e[68]=be):be=e[68];let yt;e[69]!==a?(yt=a("settings.commands.sidebar.title"),e[69]=a,e[70]=yt):yt=e[70];let It;e[71]!==yt?(It=s.jsx("h2",{className:`${ua} mb-3`,children:yt}),e[71]=yt,e[72]=It):It=e[72];let Nt;e[73]===Symbol.for("react.memo_cache_sentinel")?(Nt=s.jsx(gi,{className:"mb-3"}),e[73]=Nt):Nt=e[73];let ze;e[74]!==L.length||e[75]!==a?(ze=a("settings.commands.sidebar.total",{count:L.length}),e[74]=L.length,e[75]=a,e[76]=ze):ze=e[76];let ge;e[77]!==ze?(ge=s.jsx("span",{className:"typography-meta text-muted-foreground",children:ze}),e[77]=ze,e[78]=ge):ge=e[78];let Je;e[79]===Symbol.for("react.memo_cache_sentinel")?(Je=s.jsx(ee,{name:"add",className:"h-3.5 w-3.5"}),e[79]=Je):Je=e[79];let Xe;e[80]!==U?(Xe=s.jsx(G,{size:"sm","data-settings-item":"commands.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:U,children:Je}),e[80]=U,e[81]=Xe):Xe=e[81];let re;e[82]!==ge||e[83]!==Xe?(re=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ge,Xe]}),e[82]=ge,e[83]=Xe,e[84]=re):re=e[84];let Ke;e[85]!==L.length||e[86]!==i?(Ke=L.length>0?s.jsx(Fr,{value:i,onChange:o}):null,e[85]=L.length,e[86]=i,e[87]=Ke):Ke=e[87],e[88]!==It||e[89]!==re||e[90]!==Ke?(Ie=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[It,Nt,re,Ke]}),e[88]=It,e[89]=re,e[90]=Ke,e[91]=Ie):Ie=e[91],Ae=ks,te="flex-1 min-h-0",Y="space-y-1 px-3 py-2",ue=L.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")})]}):qe.length===0?s.jsx(Lr,{query:i}):s.jsxs(s.Fragment,{children:[pt.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")}),[...pt].sort(q1).map(et=>s.jsx(Fc,{command:et,isSelected:v===et.name,onSelect:()=>{w(et.name),n?.()},onReset:()=>V(et),onDuplicate:()=>de(et),isMenuOpen:x===et.name,onMenuOpenChange:st=>y(st?et.name:null)},et.name))]}),wt.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")}),[...wt].sort(G1).map(et=>s.jsx(Fc,{command:et,isSelected:v===et.name,onSelect:()=>{w(et.name),n?.()},onRename:()=>fe(et),onDelete:()=>K(et),onDuplicate:()=>de(et),isMenuOpen:x===et.name,onMenuOpenChange:st=>y(st?et.name:null)},et.name))]})]}),e[50]=L,e[51]=U,e[52]=K,e[53]=de,e[54]=n,e[55]=x,e[56]=i,e[57]=v,e[58]=w,e[59]=a,e[60]=Ae,e[61]=te,e[62]=Y,e[63]=ue,e[64]=be,e[65]=Ie}else Ae=e[60],te=e[61],Y=e[62],ue=e[63],be=e[64],Ie=e[65];let Te;e[92]!==Ae||e[93]!==te||e[94]!==Y||e[95]!==ue?(Te=s.jsx(Ae,{outerClassName:te,className:Y,children:ue}),e[92]=Ae,e[93]=te,e[94]=Y,e[95]=ue,e[96]=Te):Te=e[96];const Fe=c!==null&&g!==null;let xe;e[97]!==h?(xe=We=>{!We&&!h&&X()},e[97]=h,e[98]=xe):xe=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 ne;e[102]!==me?(ne=s.jsx(Vt,{children:me}),e[102]=me,e[103]=ne):ne=e[103];let he;e[104]!==c?.name||e[105]!==g||e[106]!==a?(he=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]=he):he=e[107];let Re;e[108]!==he?(Re=s.jsx(Ht,{children:he}),e[108]=he,e[109]=Re):Re=e[109];let ke;e[110]!==ne||e[111]!==Re?(ke=s.jsxs(Bt,{children:[ne,Re]}),e[110]=ne,e[111]=Re,e[112]=ke):ke=e[112];let le;e[113]!==a?(le=a("settings.common.actions.cancel"),e[113]=a,e[114]=le):le=e[114];let De;e[115]!==h||e[116]!==le?(De=s.jsx(G,{size:"sm",variant:"ghost",onClick:X,disabled:h,children:le}),e[115]=h,e[116]=le,e[117]=De):De=e[117];let $e;e[118]!==g||e[119]!==a?($e=a(g==="delete"?"settings.common.actions.delete":"settings.common.actions.reset"),e[118]=g,e[119]=a,e[120]=$e):$e=e[120];let Me;e[121]!==ce||e[122]!==h||e[123]!==$e?(Me=s.jsx(G,{size:"sm",onClick:ce,disabled:h,children:$e}),e[121]=ce,e[122]=h,e[123]=$e,e[124]=Me):Me=e[124];let se;e[125]!==De||e[126]!==Me?(se=s.jsxs(ns,{children:[De,Me]}),e[125]=De,e[126]=Me,e[127]=se):se=e[127];let Ce;e[128]!==ke||e[129]!==se?(Ce=s.jsxs(zt,{className:"max-w-md",children:[ke,se]}),e[128]=ke,e[129]=se,e[130]=Ce):Ce=e[130];let Ne;e[131]!==Fe||e[132]!==xe||e[133]!==Ce?(Ne=s.jsx(Ut,{open:Fe,onOpenChange:xe,children:Ce}),e[131]=Fe,e[132]=xe,e[133]=Ce,e[134]=Ne):Ne=e[134];const Ee=l!==null;let we;e[135]===Symbol.for("react.memo_cache_sentinel")?(we=We=>!We&&r(null),e[135]=we):we=e[135];let Ue;e[136]!==a?(Ue=a("settings.commands.sidebar.renameDialog.title"),e[136]=a,e[137]=Ue):Ue=e[137];let _e;e[138]!==Ue?(_e=s.jsx(Vt,{children:Ue}),e[138]=Ue,e[139]=_e):_e=e[139];const nt=l?.name??"";let Be;e[140]!==a||e[141]!==nt?(Be=a("settings.commands.sidebar.renameDialog.description",{name:nt}),e[140]=a,e[141]=nt,e[142]=Be):Be=e[142];let tt;e[143]!==Be?(tt=s.jsx(Ht,{children:Be}),e[143]=Be,e[144]=tt):tt=e[144];let ut;e[145]!==_e||e[146]!==tt?(ut=s.jsxs(Bt,{children:[_e,tt]}),e[145]=_e,e[146]=tt,e[147]=ut):ut=e[147];let Ge;e[148]===Symbol.for("react.memo_cache_sentinel")?(Ge=We=>d(We.target.value),e[148]=Ge):Ge=e[148];let ft;e[149]!==a?(ft=a("settings.commands.sidebar.renameDialog.placeholder"),e[149]=a,e[150]=ft):ft=e[150];let ct;e[151]!==ye?(ct=We=>{We.key==="Enter"&&ye()},e[151]=ye,e[152]=ct):ct=e[152];let Se;e[153]!==u||e[154]!==ft||e[155]!==ct?(Se=s.jsx(Qe,{value:u,onChange:Ge,placeholder:ft,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:ct}),e[153]=u,e[154]=ft,e[155]=ct,e[156]=Se):Se=e[156];let Ze;e[157]===Symbol.for("react.memo_cache_sentinel")?(Ze=()=>r(null),e[157]=Ze):Ze=e[157];let at;e[158]!==a?(at=a("settings.common.actions.cancel"),e[158]=a,e[159]=at):at=e[159];let ht;e[160]!==at?(ht=s.jsx(G,{size:"sm",variant:"ghost",onClick:Ze,children:at}),e[160]=at,e[161]=ht):ht=e[161];let rt;e[162]!==a?(rt=a("settings.common.actions.rename"),e[162]=a,e[163]=rt):rt=e[163];let xt;e[164]!==ye||e[165]!==rt?(xt=s.jsx(G,{size:"sm",onClick:ye,children:rt}),e[164]=ye,e[165]=rt,e[166]=xt):xt=e[166];let oe;e[167]!==ht||e[168]!==xt?(oe=s.jsxs(ns,{children:[ht,xt]}),e[167]=ht,e[168]=xt,e[169]=oe):oe=e[169];let Z;e[170]!==ut||e[171]!==Se||e[172]!==oe?(Z=s.jsxs(zt,{children:[ut,Se,oe]}),e[170]=ut,e[171]=Se,e[172]=oe,e[173]=Z):Z=e[173];let it;e[174]!==Ee||e[175]!==Z?(it=s.jsx(Ut,{open:Ee,onOpenChange:we,children:Z}),e[174]=Ee,e[175]=Z,e[176]=it):it=e[176];let jt;return e[177]!==be||e[178]!==Ie||e[179]!==Te||e[180]!==Ne||e[181]!==it?(jt=s.jsxs("div",{className:be,children:[Ie,Te,Ne,it]}),e[177]=be,e[178]=Ie,e[179]=Te,e[180]=Ne,e[181]=it,e[182]=jt):jt=e[182],jt},Fc=t=>{const e=Le.c(47),{command:n,isSelected:a,onSelect:i,onDelete:o,onReset:l,onRename:r,onDuplicate:u,isMenuOpen:d,onMenuOpenChange:c}=t,{t:p}=Oe();let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=vr(),e[0]=g):g=e[0];const f=g,[h,b]=m.useState(!1);let x;e[1]!==o||e[2]!==u||e[3]!==r||e[4]!==l||e[5]!==p?(x=L=>s.jsxs(s.Fragment,{children:[r&&s.jsxs(L,{onClick:z=>{z.stopPropagation(),r()},children:[s.jsx(ee,{name:"edit",className:"h-4 w-4 me-px"}),p("settings.common.actions.rename")]}),s.jsxs(L,{onClick:z=>{z.stopPropagation(),u()},children:[s.jsx(ee,{name:"file-copy",className:"h-4 w-4 me-px"}),p("settings.common.actions.duplicate")]}),l&&s.jsxs(L,{onClick:z=>{z.stopPropagation(),l()},children:[s.jsx(ee,{name:"restart",className:"h-4 w-4 me-px"}),p("settings.common.actions.reset")]}),o&&s.jsxs(L,{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"}),p("settings.common.actions.delete")]})]}),e[1]=o,e[2]=u,e[3]=r,e[4]=l,e[5]=p,e[6]=x):x=e[6];const y=x,v=a?"bg-interactive-selection":"hover:bg-interactive-hover";let w;e[7]!==v?(w=Ye("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",v),e[7]=v,e[8]=w):w=e[8];let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=f?void 0:L=>{L.preventDefault(),b(!0)},e[9]=k):k=e[9];let N;e[10]!==w?(N=s.jsx("div",{className:w,onContextMenu:k}),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 P;e[14]!==n||e[15]!==p?(P=(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]=P):P=e[16];let C;e[17]!==j||e[18]!==P?(C=s.jsxs("div",{className:"flex items-center gap-2",children:[j,P]}),e[17]=j,e[18]=P,e[19]=C):C=e[19];let I;e[20]!==n.description?(I=n.description&&s.jsx("div",{className:"typography-micro text-muted-foreground truncate leading-tight",children:n.description}),e[20]=n.description,e[21]=I):I=e[21];let S;e[22]!==i||e[23]!==I||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,I]}),e[22]=i,e[23]=I,e[24]=C,e[25]=S):S=e[25];let A;e[26]!==c?(A=L=>{L&&b(!1),c(L)},e[26]=c,e[27]=A):A=e[27];let T;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(Aa,{asChild:!0,children:s.jsx(G,{size:"sm",variant:"ghost",className:"h-6 w-6 px-0 flex-shrink-0 -me-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(ee,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[28]=T):T=e[28];let D;e[29]!==y?(D=s.jsx(Pa,{align:"end",className:"w-fit min-w-20",children:y(wa)}),e[29]=y,e[30]=D):D=e[30];let R;e[31]!==d||e[32]!==A||e[33]!==D?(R=s.jsxs(Ta,{open:d,onOpenChange:A,children:[T,D]}),e[31]=d,e[32]=A,e[33]=D,e[34]=R):R=e[34];let O;e[35]!==S||e[36]!==R?(O=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[S,R]}),e[35]=S,e[36]=R,e[37]=O):O=e[37];let F;e[38]!==O||e[39]!==N?(F=s.jsx(Qi,{render:N,children:O}),e[38]=O,e[39]=N,e[40]=F):F=e[40];let E;e[41]!==y?(E=s.jsx(Gi,{className:"w-fit min-w-20",children:y(Ji)}),e[41]=y,e[42]=E):E=e[42];let M;return e[43]!==h||e[44]!==F||e[45]!==E?(M=s.jsxs(Yi,{open:h,onOpenChange:b,children:[F,E]}),e[43]=h,e[44]=F,e[45]=E,e[46]=M):M=e[46],M};function B1(t){return{selectedCommandName:t.selectedCommandName,setSelectedCommand:t.setSelectedCommand,setCommandDraft:t.setCommandDraft,createCommand:t.createCommand,deleteCommand:t.deleteCommand,loadCommands:t.loadCommands}}function V1(t){return t.loadSkills}function H1(t){return t.name}function W1(t){return!ei(t)}function q1(t,e){return t.name.localeCompare(e.name)}function G1(t,e){return t.name.localeCompare(e.name)}const J1=()=>{const{t}=Oe(),{selectedCommandName:e,getCommandByName:n,createCommand:a,updateCommand:i,commandDraft:o,setCommandDraft:l,setSelectedCommand:r}=ii(Ys(H=>({selectedCommandName:H.selectedCommandName,getCommandByName:H.getCommandByName,createCommand:H.createCommand,updateCommand:H.updateCommand,commandDraft:H.commandDraft,setCommandDraft:H.setCommandDraft,setSelectedCommand:H.setSelectedCommand}))),u=vn(),d=ii(H=>pu(H,u)),c=e?n(e,u):null,p=!!(o&&o.name===e&&!c),[g,f]=m.useState(""),[h,b]=m.useState("user"),[x,y]=m.useState(""),[v,w]=m.useState(""),[k,N]=m.useState(""),[j,P]=m.useState(""),[C,I]=m.useState(!1),[S,A]=m.useState(""),[T,D]=m.useState(!1),R=m.useRef(null),O=JSON.stringify([u,e]),F=m.useRef(null),E=m.useRef(null);m.useEffect(()=>{const H=F.current===O;if(F.current=O,p&&o){const K=o.name||"",_=o.scope||"user",V=o.description||"",q=o.agent||"",X=Li(o.model),ae=X?`${X.providerID}/${X.modelID}`:"",ce=X?.variant||"",J=o.subagent===!0,de=o.template||"";f(K),b(_),y(V),w(q),N(ae),P(ce),I(J),A(de),R.current={draftName:K,draftScope:_,description:V,agent:q,model:ae,variant:ce,subagent:J,template:de}}else if(c){const K=c.description||"",_=c.agent||"",V=Li(c.model),q=V?`${V.providerID}/${V.modelID}`:"",X=V?.variant||"",ae=c.subagent===!0,ce=c.template||"",J=E.current,de=[R.current,J?.identity===O?J.form:null];if(H&&de.some(pe=>pe&&pe.description===K&&pe.agent===_&&pe.model===q&&pe.variant===X&&pe.subagent===ae&&pe.template===ce))return;y(K),w(_),N(q),P(X),I(ae),A(ce),R.current={draftName:"",draftScope:"user",description:K,agent:_,model:q,variant:X,subagent:ae,template:ce}}},[c,p,e,d,o,O]);const M=m.useCallback(H=>{const K=v.trim(),_=ra(k.trim()),V=_?Ru({providerID:_.providerId,modelID:_.modelId,variant:j.trim()||void 0}):null;return{name:H,description:x.trim()||void 0,agent:K===""?null:K,model:V,subagent:C,template:S.trim(),scope:p?h:void 0}},[v,x,h,p,k,C,S,j]),L=m.useCallback(async()=>{const H=R.current,K=e?.trim();if(p||!H||!K||x.trim()===H.description.trim()&&v.trim()===H.agent.trim()&&k.trim()===H.model.trim()&&j.trim()===H.variant.trim()&&C===H.subagent&&S.trim()===H.template.trim())return dn;if(!S.trim())return Ps(t("settings.commands.page.toast.templateRequired"));const V=M(K),q=Li(V.model),X={identity:O,form:{...H,description:V.description||"",agent:V.agent||"",model:q?`${q.providerID}/${q.modelID}`:"",variant:q?.variant||"",subagent:V.subagent===!0,template:V.template||""}};E.current=X;try{return await i(K,V,u)?(F.current===O&&(R.current=X.form),Zn):Ps(t("settings.commands.page.toast.updateFailed"))}finally{E.current===X&&(E.current=null)}},[v,M,x,O,p,k,e,u,C,t,S,i,j]),z=fi(L),{requestSave:$}=z,W=async()=>{const H=g.trim().replace(/\s+/g,"-");if(!H){Q.error(t("settings.commands.sidebar.toast.commandNameRequired"));return}if(!S.trim()){Q.error(t("settings.commands.page.toast.templateRequired"));return}if(d.some(K=>K.name===H)){Q.error(t("settings.commands.sidebar.toast.commandExists"));return}D(!0);try{await a(M(H),u)?(l(null),Q.success(t("settings.commands.page.toast.created"))):Q.error(t("settings.commands.page.toast.createFailed"))}catch(K){console.error("Error creating command:",K),Q.error(t("settings.commands.page.toast.saveUnexpectedError"))}finally{D(!1)}},U=()=>{l(null),r(null)};return e?s.jsxs(ss,{title:p?t("settings.commands.page.title.new"):`/${e}`,description:t(p?"settings.commands.page.subtitle.new":"settings.commands.page.subtitle.edit"),onBlurCapture:z.onBlurCapture,children:[!p&&c&&s.jsx(Kr,{legacy:c.legacy===!0,path:c.path}),s.jsxs(Ve,{title:t("settings.commands.page.section.identity"),divider:!1,contentClassName:"space-y-0",children:[p&&s.jsxs(ot,{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(Qe,{value:g,onChange:H=>f(H.target.value),placeholder:t("settings.commands.page.field.commandNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Kt,{value:h,onValueChange:H=>b(H),children:[s.jsx(Ft,{className:"w-fit min-w-[100px]",children:s.jsx($t,{children:t(h==="project"?"settings.common.scope.project":"settings.common.scope.global")})}),s.jsxs(Lt,{align:"end",children:[s.jsx(bt,{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(bt,{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:x,onChange:H=>y(H.target.value),placeholder:t("settings.commands.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})})]})]}),s.jsxs(Ve,{title:t("settings.commands.page.section.executionContext"),contentClassName:"space-y-0",children:[s.jsx(ot,{settingsItem:"commands.agent",label:t("settings.commands.page.field.overrideAgent"),children:s.jsx(jr,{agentName:v,onChange:H=>{w(H),$()},className:Cn})}),s.jsx(ot,{settingsItem:"commands.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(ja,{providerId:ra(k)?.providerId??"",modelId:ra(k)?.modelId??"",onChange:(H,K)=>{N(H&&K?`${H}/${K}`:""),$()},className:Cn})}),s.jsx(ot,{settingsItem:"commands.variant",label:t("settings.agents.page.field.variant"),info:t("settings.agents.page.field.variantTooltip"),children:s.jsx(Qe,{value:j,onChange:H=>P(H.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!k&&!j,className:"h-8 w-40 rounded-md px-3"})}),s.jsx(ot,{settingsItem:"commands.subagent",label:t("settings.commands.page.field.subagent"),info:t("settings.commands.page.field.subagentTooltip"),children:s.jsx(za,{checked:C,onCheckedChange:H=>{I(H),$()},"aria-label":t("settings.commands.page.field.subagent")})})]}),s.jsxs(Ve,{title:t("settings.commands.page.section.template"),settingsItem:"commands.template",children:[s.jsx($s,{value:S,onChange:H=>A(H.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(G,{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(G,{variant:"ghost",onClick:U,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 Nn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function wi(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function Vn(t,e){return e!==void 0?{ok:!1,error:t,parsed:e}:{ok:!1,error:t}}function yo(t,e,n){const a=Y1(n),i=typeof n.url=="string"?n.url.trim():"",o=Lc(n,"env","environment"),l=Lc(n,"headers"),r=Nn(n.oauth)?n.oauth:null,u=Si(r,"client_id","clientId"),d=Si(r,"client_secret","clientSecret"),c=Si(r,"scope"),p=Si(r,"redirect_uri","redirectUri"),g=Q1(r,"callback_port","callbackPort"),f=Si(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=Z1(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:X1(n),protocol:Gl.find(x=>x===n.protocol)??"legacy"}}function Si(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 Q1(t,...e){if(!t)return"";for(const n of e){const a=Mi(t[n]);if(a)return a}return""}function Mi(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 Y1(t){const e=t.command,n=t.args;if(wi(e)&&wi(n))return[...e,...n];if(wi(e))return e;if(typeof e=="string"&&e.trim()){const a=e.trim().split(/\s+/);return wi(n)?[...a,...n]:a}return wi(n)?n:[]}function Lc(t,...e){for(const n of e){const a=t[n];if(!Nn(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 Z1(t){return Nn(t.timeout)?{startup:Mi(t.timeout.startup),catalog:Mi(t.timeout.catalog),execution:Mi(t.timeout.execution)}:{startup:"",catalog:"",execution:Mi(t.timeout)}}function X1(t){return t.disabled===!0?!0:t.disabled===!1?!1:"enabled"in t?!t.enabled:!1}function ex(t){const e=t.mcpServers;if(Nn(e)){const a=Object.keys(e);if(a.length===1){const i=a[0],o=e[i];if(Nn(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"&&Nn(i)});if(n.length===1){const a=n[0],i=t[a];if(Qu(i))return{name:a,entry:i}}return null}function Qu(t){return t.type==="local"||t.type==="remote"||Array.isArray(t.command)||typeof t.url=="string"||Array.isArray(t.args)}function tx(t,e){let n;try{const u=t.trim();if(!u)return Vn("No JSON content provided");n=JSON.parse(u)}catch(u){return Vn(u instanceof Error?`Invalid JSON: ${u.message}`:"Invalid JSON")}if(!Nn(n))return Vn("Expected a JSON object, not an array or primitive");const a=n,i=a.mcpServers;if(Nn(i)){const u=Object.keys(i);if(u.length===0)return Vn("mcpServers object is empty",n);if(u.length>1)return Vn("Paste one server at a time. Found "+u.length+" servers in mcpServers",n);const d=u[0],c=i[d];return Nn(c)?yo(d,ko(c),c):Vn("Server entry is not a valid object",n)}const o=a.mcp,l=Nn(o)&&Nn(o.servers)?o.servers:o;if(Nn(l)){const u=Object.keys(l);if(u.length===0)return Vn("mcp object is empty",n);if(u.length>1)return Vn("Paste one server at a time. Found "+u.length+" servers in mcp",n);const d=u[0],c=l[d];return Nn(c)?yo(d,ko(c),c):Vn("Server entry in mcp is not a valid object",n)}const r=ex(a);if(r)return yo(r.name,ko(r.entry),r.entry);if(Qu(a)){const u=ko(a),d=typeof a.name=="string"&&a.name.trim()?a.name.trim():e?.fallbackName;return yo(d,u,a)}return Vn("No recognizable MCP server configuration found in JSON",n)}function ko(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 sx(t,e,n){const a=n?.isNewServer??!1,i=t.name?Jh(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 Kc=[],Yu=t=>{const e=Le.c(5),[n,a]=m.useState(Kc);let i,o;e[0]!==t?(i=()=>{let r=!1;return a(Kc),fn.getIntegrationPolicies(t).then(u=>{r||a(u)}).catch(nx),()=>{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=>Tf(n,r),e[3]=n,e[4]=l):l=e[4],l};function nx(t){console.warn("[settings] could not read OpenCode integration policies:",t instanceof Error?t.message:String(t))}const ax=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},_c=t=>{const e=Le.c(13),{status:n,enabled:a,blocked:i}=t,{t:o}=Oe();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(Os,{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(Os,{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(Os,{tone:r.tone,children:r.label}):null,e[11]=r,e[12]=u):u=e[12],u},ix=()=>{const t=Le.c(134),{t:e}=Oe(),n=vn(),{setSelectedMcp:a,setMcpDraft:i,loadMcpConfigs:o,deleteMcp:l}=Qn(Ys(ox)),[r,u]=m.useState(null),[d,c]=m.useState(!1);let p;t[0]!==n?(p=ne=>yr(ne,n),t[0]=n,t[1]=p):p=t[1];const g=Qn(p);let f;t[2]!==n?(f=ne=>ne.getStatusForDirectory(n),t[2]=n,t[3]=f):f=t[3];const h=Kn(f);let b;t[4]!==n?(b=ne=>Cp(ne,n),t[4]=n,t[5]=b):b=t[5];const x=Qn(b),y=Yu(n),v=Kn(lx),w=Kn(rx),[k,N]=m.useState(!1),[j,P]=m.useState("");let C,I;t[6]!==o||t[7]!==n?(C=()=>{o({directory:n})},I=[o,n],t[6]=o,t[7]=n,t[8]=C,t[9]=I):(C=t[8],I=t[9]),m.useEffect(C,I);let S;t[10]!==w||t[11]!==k||t[12]!==v||t[13]!==n?(S=()=>{if(k)return;N(!0);const ne=new Promise(cx);Promise.all([v({directory:n,silent:!0}),ne]).then(()=>{const he=w(n);he&&Q.error(he)}).finally(()=>N(!1))},t[10]=w,t[11]=k,t[12]=v,t[13]=n,t[14]=S):S=t[14];const A=S;let T;t[15]!==g||t[16]!==i||t[17]!==a?(T=()=>{const ne=ax(g),he={name:ne,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],...zu,oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1};i(he),a(ne)},t[15]=g,t[16]=i,t[17]=a,t[18]=T):T=t[18];const D=T;let R;t[19]!==l||t[20]!==r||t[21]!==n||t[22]!==e?(R=async()=>{if(!r)return;const ne=r;c(!0);const he=await l(ne,n);he.ok?(he.reloadFailed?Q.warning(he.message||e("settings.mcp.page.toast.serverDeletedReloadFailed",{name:ne}),{description:he.warning||e("settings.mcp.page.toast.refreshListIfStale")}):Q.success(he.message||e("settings.mcp.page.toast.serverDeleted",{name:ne})),u(null)):Q.error(e("settings.mcp.page.toast.deleteFailed")),c(!1)},t[19]=l,t[20]=r,t[21]=n,t[22]=e,t[23]=R):R=t[23];const O=R;let F;t[24]!==g?(F=new Set(g.map(dx)),t[24]=g,t[25]=F):F=t[25];const E=F;let M,L,z,$,W,U,H,K,_;if(t[26]!==E||t[27]!==x||t[28]!==D||t[29]!==A||t[30]!==y||t[31]!==k||t[32]!==h||t[33]!==j||t[34]!==g||t[35]!==i||t[36]!==a||t[37]!==e){const ne=x?Object.values(h).filter(we=>!E.has(we.name)):[],he=[...g.map(ux),...ne.map(mx)],Re=Ea(he,j,px);let ke;t[47]!==j?(ke=j.trim(),t[47]=j,t[48]=ke):ke=t[48];const le=ke.length>0;M=ss,t[49]!==e?($=e("settings.page.mcp.title"),t[49]=e,t[50]=$):$=t[50],t[51]!==e?(W=e("settings.mcp.grid.description"),t[51]=e,t[52]=W):W=t[52];let De;t[53]===Symbol.for("react.memo_cache_sentinel")?(De=s.jsx(gi,{className:"min-w-0 flex-1 @xl:w-56 @xl:flex-none"}),t[53]=De):De=t[53];let $e;t[54]!==e?($e=e("settings.mcp.sidebar.actions.refreshStatusAria"),t[54]=e,t[55]=$e):$e=t[55];let Me;t[56]!==e?(Me=e("settings.mcp.sidebar.actions.refreshStatusTitle"),t[56]=e,t[57]=Me):Me=t[57];const se=k&&"animate-spin";let Ce;t[58]!==se?(Ce=Ye("size-4",se),t[58]=se,t[59]=Ce):Ce=t[59];let Ne;t[60]!==Ce?(Ne=s.jsx(ee,{name:"refresh",className:Ce}),t[60]=Ce,t[61]=Ne):Ne=t[61],t[62]!==A||t[63]!==k||t[64]!==$e||t[65]!==Me||t[66]!==Ne?(U=s.jsxs("div",{className:"flex w-full items-center gap-2 @xl:w-auto",children:[De,s.jsx(G,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0 text-muted-foreground",disabled:k,onClick:A,"aria-label":$e,title:Me,children:Ne})]}),t[62]=A,t[63]=k,t[64]=$e,t[65]=Me,t[66]=Ne,t[67]=U):U=t[67],H=he.length>0?s.jsx(gl,{value:j,onChange:P,placeholder:e("settings.mcp.grid.searchPlaceholder")}):null,K=he.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:e("settings.mcp.grid.empty")}):Re.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:e("settings.mcp.grid.noMatches",{query:j.trim()})}):null,_=pi,t[68]!==D||t[69]!==le||t[70]!==e?(L=le?null:s.jsx(io,{label:e("settings.mcp.sidebar.actions.addServerTitle"),hint:e("settings.mcp.grid.addHint"),onClick:D,settingsItem:"mcp.create"}),t[68]=D,t[69]=le,t[70]=e,t[71]=L):L=t[71];let Ee;t[72]!==y||t[73]!==h||t[74]!==i||t[75]!==a||t[76]!==e?(Ee=we=>{if(we.kind==="runtime"){const tt=y(`mcp:${we.server.name}`);return s.jsx(Yn,{icon:s.jsx(Wi,{name:"server"}),title:we.server.name,badges:s.jsx(_c,{status:we.server.status.status,enabled:we.server.status.status!=="disabled",blocked:tt}),muted:we.server.status.status==="disabled"||tt,footer:s.jsx(di,{children:e("settings.mcp.grid.runtimeProvided")})},we.server.name)}const Ue=we.server,_e=Ue.disabled!==!0,nt=y(`mcp:${Ue.name}`),Be=Ue.type==="local"?Ue.command?.join(" "):Ue.url;return s.jsx(Yn,{icon:s.jsx(Wi,{name:Ue.type==="local"?"server":"global"}),title:Ue.name,subtitle:Be||void 0,badges:s.jsx(_c,{status:h[Ue.name]?.status.status,enabled:_e,blocked:nt}),muted:!_e||nt,footer:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Ue.type==="local"?e("settings.mcp.sidebar.serverType.localTitle"):e("settings.mcp.sidebar.serverType.remoteTitle")}),Ue.scope==="project"?s.jsx(di,{children:e("settings.mcp.grid.scope.project")}):null]}),onOpen:()=>{i(null),a(Ue.name)},actionsLabel:e("settings.mcp.grid.actionsAria",{name:Ue.name}),actions:[{label:e("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onSelect:()=>u(Ue.name)}]},Ue.name)},t[72]=y,t[73]=h,t[74]=i,t[75]=a,t[76]=e,t[77]=Ee):Ee=t[77],z=Re.map(Ee),t[26]=E,t[27]=x,t[28]=D,t[29]=A,t[30]=y,t[31]=k,t[32]=h,t[33]=j,t[34]=g,t[35]=i,t[36]=a,t[37]=e,t[38]=M,t[39]=L,t[40]=z,t[41]=$,t[42]=W,t[43]=U,t[44]=H,t[45]=K,t[46]=_}else M=t[38],L=t[39],z=t[40],$=t[41],W=t[42],U=t[43],H=t[44],K=t[45],_=t[46];let V;t[78]!==L||t[79]!==z||t[80]!==_?(V=s.jsxs("div",{className:_,children:[L,z]}),t[78]=L,t[79]=z,t[80]=_,t[81]=V):V=t[81];const q=r!==null;let X;t[82]!==d?(X=ne=>{!ne&&!d&&u(null)},t[82]=d,t[83]=X):X=t[83];const ae=r??"";let ce;t[84]!==e||t[85]!==ae?(ce=e("settings.mcp.page.deleteDialog.title",{name:ae}),t[84]=e,t[85]=ae,t[86]=ce):ce=t[86];let J;t[87]!==ce?(J=s.jsx(Vt,{children:ce}),t[87]=ce,t[88]=J):J=t[88];let de;t[89]!==e?(de=e("settings.mcp.page.deleteDialog.descriptionPrefix"),t[89]=e,t[90]=de):de=t[90];let pe;t[91]===Symbol.for("react.memo_cache_sentinel")?(pe=s.jsx("code",{className:"text-foreground",children:"opencode.json"}),t[91]=pe):pe=t[91];let fe;t[92]!==e?(fe=e("settings.mcp.page.deleteDialog.descriptionSuffix"),t[92]=e,t[93]=fe):fe=t[93];let ve;t[94]!==de||t[95]!==fe?(ve=s.jsxs(Ht,{children:[de," ",pe,"."," ",fe]}),t[94]=de,t[95]=fe,t[96]=ve):ve=t[96];let ye;t[97]!==J||t[98]!==ve?(ye=s.jsxs(Bt,{children:[J,ve]}),t[97]=J,t[98]=ve,t[99]=ye):ye=t[99];let Ae;t[100]===Symbol.for("react.memo_cache_sentinel")?(Ae=()=>u(null),t[100]=Ae):Ae=t[100];let te;t[101]!==e?(te=e("settings.common.actions.cancel"),t[101]=e,t[102]=te):te=t[102];let Y;t[103]!==d||t[104]!==te?(Y=s.jsx(G,{variant:"outline",size:"sm",onClick:Ae,disabled:d,children:te}),t[103]=d,t[104]=te,t[105]=Y):Y=t[105];let ue;t[106]!==O?(ue=()=>{O()},t[106]=O,t[107]=ue):ue=t[107];let be;t[108]!==d||t[109]!==e?(be=e(d?"settings.mcp.page.actions.deleting":"settings.common.actions.delete"),t[108]=d,t[109]=e,t[110]=be):be=t[110];let Ie;t[111]!==d||t[112]!==ue||t[113]!==be?(Ie=s.jsx(G,{variant:"destructive",size:"sm",onClick:ue,disabled:d,children:be}),t[111]=d,t[112]=ue,t[113]=be,t[114]=Ie):Ie=t[114];let Te;t[115]!==Y||t[116]!==Ie?(Te=s.jsxs(ns,{children:[Y,Ie]}),t[115]=Y,t[116]=Ie,t[117]=Te):Te=t[117];let Fe;t[118]!==ye||t[119]!==Te?(Fe=s.jsxs(zt,{className:"max-w-md",children:[ye,Te]}),t[118]=ye,t[119]=Te,t[120]=Fe):Fe=t[120];let xe;t[121]!==q||t[122]!==X||t[123]!==Fe?(xe=s.jsx(Ut,{open:q,onOpenChange:X,children:Fe}),t[121]=q,t[122]=X,t[123]=Fe,t[124]=xe):xe=t[124];let me;return t[125]!==M||t[126]!==$||t[127]!==W||t[128]!==U||t[129]!==H||t[130]!==K||t[131]!==V||t[132]!==xe?(me=s.jsxs(M,{title:$,description:W,headerEnd:U,children:[H,K,V,xe]}),t[125]=M,t[126]=$,t[127]=W,t[128]=U,t[129]=H,t[130]=K,t[131]=V,t[132]=xe,t[133]=me):me=t[133],me};function ox(t){return{setSelectedMcp:t.setSelectedMcp,setMcpDraft:t.setMcpDraft,loadMcpConfigs:t.loadMcpConfigs,deleteMcp:t.deleteMcp}}function lx(t){return t.refresh}function rx(t){return t.getErrorForDirectory}function cx(t){return setTimeout(t,500)}function dx(t){return t.name}function ux(t){return{kind:"config",server:t}}function mx(t){return{kind:"runtime",server:t}}function px(t){return[t.server.name,t.kind==="config"?t.server.type==="local"?t.server.command?.join(" ")??"":t.server.url??"":""]}const Pl=t=>t===void 0?"":String(t),Al=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`},Tl={legacy:"settings.mcp.page.advanced.protocolOption.legacy",auto:"settings.mcp.page.advanced.protocolOption.auto","2026-07-28":"settings.mcp.page.advanced.protocolOption.revision20260728"},$c={default:"settings.mcp.page.advanced.codemodeOption.default",on:"settings.mcp.page.advanced.codemodeOption.on",off:"settings.mcp.page.advanced.codemodeOption.off"},gx=t=>{try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}},Ja=t=>t?.status.status,El=t=>t?.status.status==="failed"||t?.status.status==="needs_auth"?t.status.error:void 0;function Zu(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 fx=t=>{const e=Le.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(`