@vantran-se/openchamber-web 2.4.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/assets/{AboutDialog-BItSBkkK.js → AboutDialog-C8mAGhnz.js} +1 -1
  2. package/dist/assets/{ArchiveView-CEGi3y1V.js → ArchiveView-4-LVDLmf.js} +1 -1
  3. package/dist/assets/{ChangedPathLabel-CQNGnF-T.js → ChangedPathLabel-BCiU4QDF.js} +1 -1
  4. package/dist/assets/{CommandPalette-DWX1HV4m.js → CommandPalette-DEcmPHdC.js} +1 -1
  5. package/dist/assets/{DiffView-Be1Xoy_F.js → DiffView-CaDZ4gTk.js} +3 -3
  6. package/dist/assets/{FilesView-DONPk8-K.js → FilesView-Csrs_BGv.js} +1 -1
  7. package/dist/assets/{GitView-D10y-u46.js → GitView-DvxCZgCW.js} +3 -3
  8. package/dist/assets/{GuestSurfacePane-Cot0OO7x.js → GuestSurfacePane-DNg0xBTD.js} +1 -1
  9. package/dist/assets/{HelpDialog-Bw836_tH.js → HelpDialog-CLyz3_xd.js} +1 -1
  10. package/dist/assets/{InProgressOperationBanner-saAihIub.js → InProgressOperationBanner-BVDKUDqn.js} +2 -2
  11. package/dist/assets/{IntegrationsCatalogView-BtdMeTHf.js → IntegrationsCatalogView-u1gS0Vk8.js} +1 -1
  12. package/dist/assets/{JsonTreeView-BOQC0uTM.js → JsonTreeView-BpJU14WJ.js} +1 -1
  13. package/dist/assets/{MarkdownRendererImpl-CuZntPVf.js → MarkdownRendererImpl-t3OoYn_0.js} +1 -1
  14. package/dist/assets/{MemoryDebugPanel-BZgSuf-z.js → MemoryDebugPanel-9z1jGWze.js} +1 -1
  15. package/dist/assets/{OnboardingScreen-Bx2h2w69.js → OnboardingScreen-xzT7ckY0.js} +1 -1
  16. package/dist/assets/{OpenCodeStatusDialog-N9JgIC1p.js → OpenCodeStatusDialog-skpJZSjK.js} +1 -1
  17. package/dist/assets/{PatchDiff-Ca_Ci2CX.js → PatchDiff-BWW_8bob.js} +1 -1
  18. package/dist/assets/{PierreDiffViewer-Ck0P8Q2W.js → PierreDiffViewer-BZDNV4Uj.js} +1 -1
  19. package/dist/assets/{PlanView-dx70wKWR.js → PlanView-D7wshtfZ.js} +1 -1
  20. package/dist/assets/{ProjectActionsDialog-BS20dYCJ.js → ProjectActionsDialog-BPh74BCt.js} +1 -1
  21. package/dist/assets/{PullRequestComparisonSelector-DOW9_VlK.js → PullRequestComparisonSelector-BBdU2rL1.js} +3 -3
  22. package/dist/assets/{RunOverview-DtxjzGnX.js → RunOverview-Cngm2OOp.js} +2 -2
  23. package/dist/assets/{ScheduledTasksDialog-HcypGtky.js → ScheduledTasksDialog-DUjDdkw2.js} +1 -1
  24. package/dist/assets/{SettingsView-IBrGwDoM.js → SettingsView-CCZOw018.js} +2 -2
  25. package/dist/assets/{SettingsWindow-Bugr9Hmx.js → SettingsWindow-Cndsj5Vu.js} +1 -1
  26. package/dist/assets/{SourceBoardView-BD5rmib8.js → SourceBoardView-8Wp0oUvB.js} +1 -1
  27. package/dist/assets/{SpaceAccessDialog-BYhp5gfB.js → SpaceAccessDialog-CxfCzTpe.js} +1 -1
  28. package/dist/assets/{SpaceApplyDialog-CC0axZal.js → SpaceApplyDialog-CYp0A76N.js} +1 -1
  29. package/dist/assets/{SpaceRow-DDWTQgfP.js → SpaceRow-CQp4PkPJ.js} +1 -1
  30. package/dist/assets/{SpaceSetupOutput-BqurG7V4.js → SpaceSetupOutput-RNo0mWrR.js} +1 -1
  31. package/dist/assets/{SpacesView-Bcbb9aXY.js → SpacesView-BwcDCv3D.js} +1 -1
  32. package/dist/assets/{SubmoduleDiffSummary-BS1PSa4l.js → SubmoduleDiffSummary-BQduif5s.js} +1 -1
  33. package/dist/assets/{ToolOutputDialog-DXWQ17Fv.js → ToolOutputDialog-BVCvqYsK.js} +1 -1
  34. package/dist/assets/{ToolPartDiffPreview-DXRs6cSg.js → ToolPartDiffPreview-BXpCHBW9.js} +1 -1
  35. package/dist/assets/{UsageStatsView-DFVydqMY.js → UsageStatsView-CsC_RzAH.js} +1 -1
  36. package/dist/assets/{Virtualizer-B8rX50qD.js → Virtualizer-nenVQKi3.js} +1 -1
  37. package/dist/assets/{WalkthroughView-CECS5lDs.js → WalkthroughView-CdIYpttA.js} +1 -1
  38. package/dist/assets/{WorktreesView-FH0uzPQG.js → WorktreesView-D102xE1o.js} +1 -1
  39. package/dist/assets/{appThemeRegistry-CnS_OWEL.js → appThemeRegistry-BWap7OfW.js} +1 -1
  40. package/dist/assets/{ar-BlEU--PN.js → ar-9CiK5cuu.js} +3 -3
  41. package/dist/assets/{computeVirtualFileMetrics-rZJ-MSfY.js → computeVirtualFileMetrics-DDyA16hp.js} +1 -1
  42. package/dist/assets/{de-DWs4Mcjc.js → de-Drq6oIkP.js} +3 -3
  43. package/dist/assets/{decorate-Bbbyq0tX.js → decorate-CemSwkUs.js} +1 -1
  44. package/dist/assets/{es-k5T7CE97.js → es-0bkFr34F.js} +3 -3
  45. package/dist/assets/{flexokiTheme-DECIbITo.js → flexokiTheme-PoX6Vqyn.js} +1 -1
  46. package/dist/assets/{fr-CzmypgZ8.js → fr-CjgWVupK.js} +3 -3
  47. package/dist/assets/{he-DdkxJnUn.js → he-BrJa9oPB.js} +4 -4
  48. package/dist/assets/{index-DElZNtel.js → index-B2WHEal3.js} +1 -1
  49. package/dist/assets/{initializeSharedPreferences-C5qncsHs.js → initializeSharedPreferences-1Vo6G7CM.js} +1 -1
  50. package/dist/assets/{install-D-H6uk7D.js → install-FletzeYD.js} +1 -1
  51. package/dist/assets/{isDiffPlainText-DMFSMXcK.js → isDiffPlainText-yXcpftjI.js} +1 -1
  52. package/dist/assets/{isFilePlainText-BQGSJxcX.js → isFilePlainText-Dpm-_Qu8.js} +1 -1
  53. package/dist/assets/{ja-Qqkyglaf.js → ja-cfyrqWPa.js} +3 -3
  54. package/dist/assets/katex.min-F4TD1ekM.js +69 -0
  55. package/dist/assets/{ko-B8idPK2d.js → ko-herKAlGO.js} +3 -3
  56. package/dist/assets/{main-DMdUGpFx.js → main-CO7wKNtS.js} +2 -2
  57. package/dist/assets/{main-CcnDurk6.js → main-DN47yDMe.js} +19 -19
  58. package/dist/assets/markdownCore-BY21GJ_M.js +10 -0
  59. package/dist/assets/{miniChat-B8DW3cmv.js → miniChat-BmFJFQph.js} +2 -2
  60. package/dist/assets/{mobile-Caqsx1Op.js → mobile-DTi98S93.js} +2 -2
  61. package/dist/assets/{moveWorkspacePath-By4gjwmW.js → moveWorkspacePath-CENAo75W.js} +1 -1
  62. package/dist/assets/{nl-CFXZKHp7.js → nl-mZ4VCoiQ.js} +3 -3
  63. package/dist/assets/{parseDiffFromFile-C9ASoy7R.js → parseDiffFromFile-BSmRvd3V.js} +1 -1
  64. package/dist/assets/{pierreDiffTint-IfgQ6oty.js → pierreDiffTint-cyYFR1bm.js} +1 -1
  65. package/dist/assets/{pl-slLgZWDu.js → pl-C98lvkcZ.js} +4 -4
  66. package/dist/assets/{pt-BR-C319g_nn.js → pt-BR-CB63WPLS.js} +3 -3
  67. package/dist/assets/{relocateRestoredSession-DBWTClOj.js → relocateRestoredSession-D8Sf_FG_.js} +1 -1
  68. package/dist/assets/{renderElectronMiniChatApp-C5irgP-w.js → renderElectronMiniChatApp-DmQ8i5jp.js} +2 -2
  69. package/dist/assets/{renderMobileApp-DnyN_ARh.js → renderMobileApp-CND9CafV.js} +3 -3
  70. package/dist/assets/{restartOpenCode-VU-OEAvZ.js → restartOpenCode-D8ExMl55.js} +1 -1
  71. package/dist/assets/{runtimeEndpointReset-BJUtkqal.js → runtimeEndpointReset-lg1O2gVX.js} +3 -3
  72. package/dist/assets/{scheduledTasksApi-FZ9stPNl.js → scheduledTasksApi-CJBNpwgy.js} +1 -1
  73. package/dist/assets/{selectionMarkdown-DV_HvvmZ.js → selectionMarkdown-B_3WTOUr.js} +1 -1
  74. package/dist/assets/{shikiHighlight-BKmAuapa.js → shikiHighlight-DBj_a_TN.js} +1 -1
  75. package/dist/assets/{space-apply-Br_BRuH8.js → space-apply-COMscpEL.js} +1 -1
  76. package/dist/assets/{space-close-D_1iLJrX.js → space-close-DDLvYCUc.js} +1 -1
  77. package/dist/assets/{spaceNetwork-Dcj-qJy-.js → spaceNetwork-CNxs51y4.js} +1 -1
  78. package/dist/assets/{textMateThemeFromAppTheme-Bye_bpEL.js → textMateThemeFromAppTheme-tYpAceV3.js} +1 -1
  79. package/dist/assets/{tr-DNnJ5oqk.js → tr-C5KUa-8X.js} +3 -3
  80. package/dist/assets/{uk-Bw0BJwHw.js → uk-D44Grdmc.js} +3 -3
  81. package/dist/assets/{useAppFontEffects-d9vsRNKm.js → useAppFontEffects-Dm6zEvrf.js} +200 -199
  82. package/dist/assets/{useCallableModelProviders-8CrUkERW.js → useCallableModelProviders-BK3j8Sde.js} +1 -1
  83. package/dist/assets/{useDiffFindSurface-sw5jZ-9V.js → useDiffFindSurface-CaCh-qt2.js} +1 -1
  84. package/dist/assets/{useInlineCommentController-Cw5IRM5Y.js → useInlineCommentController-a2JepiF3.js} +1 -1
  85. package/dist/assets/{useMarkdownLocalAssets-D3a1j44d.js → useMarkdownLocalAssets-BEApAshz.js} +2 -2
  86. package/dist/assets/{useRootScrollLock-BWsNuapq.js → useRootScrollLock-mqVhK2HB.js} +2 -2
  87. package/dist/assets/{useWalkthroughReview-D7I1H6_J.js → useWalkthroughReview-BspAr9Aa.js} +1 -1
  88. package/dist/assets/{vendor-codemirror-language-data-DP_Bh3S8.js → vendor-codemirror-language-data-VzNDjH03.js} +2 -2
  89. package/dist/assets/{zh-CN-Brx5Btej.js → zh-CN-DwBC4Qtd.js} +3 -3
  90. package/dist/assets/{zh-TW-WokiutLA.js → zh-TW-DXEqDBAm.js} +3 -3
  91. package/dist/index.html +2 -2
  92. package/dist/mini-chat.html +2 -2
  93. package/dist/mobile.html +2 -2
  94. package/package.json +2 -2
  95. package/server/index.js +4 -2
  96. package/server/lib/git/service.test.js +1 -1
  97. package/server/lib/opencode/openchamber-routes.test.js +1 -0
  98. package/server/lib/opencode/settings-helpers.js +2 -2
  99. package/server/lib/opencode/settings-helpers.test.js +1 -1
  100. package/server/lib/opencode/settings-registry.json +1 -1
  101. package/server/lib/outbound-proxy.test.js +2 -2
  102. package/server/lib/spaces/tools.test.js +2 -2
  103. package/dist/assets/katex.min-u4DtE8E5.js +0 -69
  104. package/dist/assets/markdownCore-BwFkWhmZ.js +0 -10
@@ -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 De,r as Ke}from"./vendor-react-BUCujlKS.js";import{u as Ee,B as H,I as te,cx as Ks,aF as Zs,ad as jm,z as va,A as q,ac as km,hT as wm,aC as $e,hU as Vt,a2 as Ed,aA as Ai,a5 as on,aG as za,c2 as zo,N as ze,be as Sm,cd as tr,cf as Nm,c9 as Kt,ca as Ct,c3 as bt,cb as It,cc as Pt,y as qe,hV as Cn,hW as Md,hX as Cm,cK as Co,hY as Al,hk as Fi,hZ as Im,h_ as Ti,h$ as Wn,n as Os,t as Tt,q as Et,D as Rt,l as Ot,F as Ft,o as Wt,i0 as tl,aT as ya,aU as fa,gG as zi,gI as Ui,aS as ja,aR as ka,gM as Bi,gN as Vi,hq as $n,hp as gn,c0 as ts,c6 as Xt,hr as sl,fh as _t,a1 as ft,i1 as st,cH as St,cL as Cs,cI as Fa,i2 as an,eu as Es,i3 as Yt,cP as ds,i4 as us,i5 as Dd,i6 as Pm,i7 as ct,i8 as Rd,i9 as Am,ia as Tm,ib as Li,ic as Em,df as Pn,id as rn,ie as ti,hQ as Js,ig as Qa,ih as Od,ii as nl,cJ as al,hs as La,ij as Mr,L as wa,ik as Tl,il as Mm,cD as Uo,im as El,fl as $a,hP as Lt,R as il,io as ol,ip as Ma,iq as Fd,hR as Nn,ir as Dm,C as si,x as Bo,aK as Ml,bT as Rm,aW as Om,P as Fm,cR as Lm,cS as Km,cT as _m,en as Ld,b7 as oi,eU as Ki,is as Kd,it as $m,iu as zm,c5 as Um,iv as Bm,al as Hi,c8 as ln,iw as Bt,ix as _d,iy as Vm,iz as Ln,fn as Ts,iA as Vo,iB as wn,iC as Io,iD as Hm,iE as $d,iF as qm,gV as ls,iG as Po,dt as zd,ds as Wm,gT as Gm,gU as Jm,iH as Qm,iI as Ym,gW as Zm,iJ as Xm,iK as ep,iL as Dl,c4 as Ud,iM as tp,iN as sr,iO as Rl,iP as sp,iQ as np,iR as ap,iS as ip,iT as Ao,iU as bs,fm as ni,b9 as Fs,ba as Ho,iV as op,iW as Bd,fd as rp,fj as lp,g9 as cp,iX as dp,iY as nr,iZ as Vd,i_ as rl,i$ as ll,j0 as up,j1 as mp,j2 as pp,j3 as gp,j4 as fp,j5 as hp,j6 as bp,j7 as xp,bl as Ps,hS as nn,bm as cl,hF as Hd,j8 as Ws,j9 as qd,ce as Va,ja as vp,jb as yp,jc as ai,dp as jp,jd as Ei,je as ma,jf as Wd,jg as kp,jh as wp,ji as Sp,jj as Vs,jk as As,jl as Ta,jm as Kn,jn as Ol,jo,jp as Np,aa as Cp,jq as Gd,jr as Da,js as Ip,jt as Pp,k as dl,ju as Ap,da as Tp,az as Ep,ay as Mp,br as Dp,cg as Rp,as as Op,av as Fp,jv as Lp,b0 as Kp,hy as _p,jw as _i,jx as fi,jy as Fl,jz as Fn,jA as ga,jB as $p,jC as zp,jD as Up,jE as Bp,jF as ar,jG as Ll,jH as Vp,jI as Hp,jJ as qp,jK as Wp,jL as Gp,jM as Kl,jN as hi,jO as Jp,jP as ul,jQ as Qp,G as Yp,aO as _l,cG as Zp,jR as Xp,jS as ir,f as zn,h as Ka,jT as $l,jU as eg,jV as tg,jW as sg,jX as qo,jY as ng,am as Hn,jZ as ag,j_ as ig,j$ as og,f2 as rg,k0 as Wo,k1 as _n,k2 as lg,k3 as cg,an as dg,ap as Jd,dg as ug,aV as Ia,V as mg,W as pg,dh as gg}from"./useAppFontEffects-d9vsRNKm.js";import{k as $t,bk as Qd,u as re,l as os,bE as Mi,bF as Un,bG as Yd,bH as fg,aU as jt,aR as fn,t as Qs,bI as hg,a5 as Zt,a$ as bg,ax as is,b4 as ri,aL as or,aO as zl,aM as Ul,aV as bi,bt as xg,bJ as vg,bq as yg,aW as Ea,bK as jg,bL as Bl,aN as kg,bM as wg,bN as Sg,bl as Vl,b3 as qi,bO as Ng,bP as Cg,bQ as Zd,bR as Mt,bS as Ig,ap as Pg,aq as Ag,bT as ml,a_ as Tg,ae as Xd,bU as eu,b2 as tu,bz as _a,bV as su,bW as Eg,bX as Mg,aT as pl,bY as Dg,a7 as Go,bv as To,aE as Rg,ay as Di,bZ as Og,b_ as Ha,b$ as Hl,c0 as ql,c1 as Wl,c2 as Gl,c3 as Jl,bi as Fg,y as nu,c4 as Wi,c5 as Lg,c6 as Ql,c7 as Kg,c8 as _g,r as Dr,c9 as $g,ca as Yl,cb as zg,b as Ug,cc as Bg,cd as Vg,ce as Hg,cf as qg,cg as Wg,aP as au,ch as iu,ci as Gg,cj as Rr,ck as Jg,cl as Qg,cm as Yg,cn as Zg,co as ou,cp as Xg,cq as ef,cr as tf,cs as Or,ct as Zl,cu as sf,cv as Xl,cw as oo,cx as nf,cy as af,cz as of,bD as rf,by as lf,b8 as cf,cA as df,cB as uf,cC as mf,cD as pf}from"./katex.min-u4DtE8E5.js";import{u as _s,c as Jo}from"./vendor-zustand-BAGL70zf.js";import{ac as gf,aR as ff,aS as rr,aT as hf,aU as bf,aV as xf,aW as qt,aX as vf,aY as li,aZ as js,a_ as Eo,a$ as qn,b0 as ii,b1 as Qo,b2 as Gi,b3 as $i,h as ha,f as ba,g as xa,R as Ra,b4 as yf,b5 as Is,b6 as jf,b7 as ru,b8 as kf,b9 as lu,U as wf,ba as Sf,bb as Nf,bc as Cf,bd as If,be as Pf,bf as Ga,bg as Af,bh as Fr,A as Tf,B as Ef,bi as Mf}from"./runtimeEndpointReset-BJUtkqal.js";import{o as as,s as wt,b as Ji,l as Df,a as Ys,r as Bn,u as Lr,n as Mo,_ as cu,c as Kr}from"./vendor-zod-DDir2TeQ.js";import{n as Rf,M as du,r as Of,a as Ff,b as Lf,c as Kf,d as _f,P as $f,f as zf,e as Uf,g as Bf,h as _r,u as uu,i as mu,s as pu,j as Vf,k as Hf}from"./install-D-H6uk7D.js";import{s as qf,c as Wf}from"./vendor-yaml-CE-D_49-.js";import{c as ec,C as tc,P as Gf,p as Jf}from"./flexokiTheme-DECIbITo.js";import{s as Qf}from"./shikiHighlight-BKmAuapa.js";import{getResolvedShikiTheme as Yf}from"./appThemeRegistry-CnS_OWEL.js";import{E as sc}from"./vendor-codemirror-view-B66jUSmE.js";import{Q as gu}from"./vendor-qrcode-DTJ12-WC.js";import{toast as Ya}from"./vendor-sonner-DFyL3AvE.js";import{s as Zf}from"./vendor-strip-json-comments-5dJlOkP1.js";import{h as Xf,P as eh,e as th,f as sh,g as nh}from"./vendor-base-ui-CPKyhvxM.js";import{u as ah}from"./useCallableModelProviders-8CrUkERW.js";import{r as fu}from"./restartOpenCode-VU-OEAvZ.js";import{S as gl}from"./SpaceRow-DDWTQgfP.js";import{_ as ih}from"./vendor-vite-runtime-DD1OZmLC.js";const nc=()=>{const{t}=Ee(),[e,a]=m.useState(null);m.useEffect(()=>{let i=!1;const o=typeof AbortController<"u"?new AbortController:void 0;return(async()=>{try{const c=await $t("/api/system/info",{signal:o?.signal,headers:{Accept:"application/json"}});if(!c.ok)return;const u=await c.json().catch(()=>null);if(!u||i)return;const d=typeof u.port=="number"&&Number.isFinite(u.port)&&u.port>0?u.port:null,l=typeof u.tunnelUrl=="string"&&u.tunnelUrl.trim().length>0?u.tunnelUrl.trim():null;a({port:d,tunnelUrl:l})}catch{}})(),()=>{i=!0,o?.abort()}},[]);const n=[];return e?.port!==null&&e?.port!==void 0&&n.push({key:"application",label:t("settings.openchamber.about.field.applicationUrl"),url:`http://localhost:${e.port}/`}),e?.tunnelUrl&&n.push({key:"tunnel",label:t("settings.openchamber.about.field.tunnelUrl"),url:e.tunnelUrl}),n.length===0?null:s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.map(i=>s.jsxs(H,{type:"button",variant:"outline",size:"sm",title:i.label,className:"max-w-full gap-1.5 px-2.5",onClick:()=>{Ks(i.url)},children:[s.jsx(te,{name:"external-link",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"max-w-64 truncate font-mono typography-micro",children:i.url})]},i.key))})},ac="https://github.com/openchamber/openchamber",oh="https://discord.gg/ZYRSdnwwKA",ic="https://x.com/openchamber_dev",rh=800,lh={info:null,checking:!1,available:!1,error:null};function ch(t){const e=De.c(5),[a,n]=m.useState(lh);let i;e[0]!==t?(i=async()=>{if(t){n(dh);try{const c=await hf();n({info:c,checking:!1,available:c.available,error:null})}catch(c){const u=c;n({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 r;return e[2]!==o||e[3]!==a?(r={...a,check:o},e[2]=o,e[3]=a,e[4]=r):r=e[4],r}function dh(t){return{...t,checking:!0,error:null}}function uh(t){const e=De.c(11),[a,n]=m.useState(null);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={kind:"idle"},e[0]=i):i=e[0];const[o,r]=m.useState(i);let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=async()=>{try{const b=await bf();return n(b),b}catch{return null}},e[1]=c):c=e[1];const u=c;let d,l;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{u()},l=[u],e[2]=d,e[3]=l):(d=e[2],l=e[3]),m.useEffect(d,l);let f;e[4]!==t?(f=async()=>{r({kind:"upgrading"});try{const b=await xf(t);r({kind:"installed",version:b})}catch(b){const x=b;r({kind:"failed",error:x instanceof Error?x.message:t})}},e[4]=t,e[5]=f):f=e[5];const p=f;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=async b=>{await b().catch(mh);const x=await u();x?.currentVersion&&r(w=>w.kind!=="installed"||w.version&&w.version.replace(/^v/,"")!==x.currentVersion?w:{kind:"idle"})},e[6]=g):g=e[6];const h=g;let y;return e[7]!==o||e[8]!==a||e[9]!==p?(y={status:a,phase:o,refresh:u,upgrade:p,reloadAfterUpgrade:h},e[7]=o,e[8]=a,e[9]=p,e[10]=y):y=e[10],y}function mh(){}function ph(t){const[e,a]=m.useState(null);return m.useEffect(()=>{if(!t)return;let n=!1;return ih(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=>{n||a(i.version.trim()||null)}).catch(()=>{}),()=>{n=!0}},[t]),e}const gh=({initialUpdateDialogOpen:t=!1})=>{const{t:e}=Ee(),[a,n]=m.useState(t),[i,o]=m.useState(!1),[r,c]=m.useState(null),u=gf(_s(G=>({info:G.info,checking:G.checking,available:G.available,error:G.error,downloading:G.downloading,downloaded:G.downloaded,installing:G.installing,progress:G.progress,runtimeType:G.runtimeType,checkForUpdates:G.checkForUpdates,downloadUpdate:G.downloadUpdate,restartToUpdate:G.restartToUpdate}))),{isMobile:d}=Zs(),l=m.useMemo(()=>Qd(),[]),f=ff(),p=ch(l||f),g=f?p:null,h=p.check;m.useEffect(()=>{f&&h()},[f,h]);const[y,b]=m.useState(!1),[x,w]=m.useState(null);m.useEffect(()=>{if(!f)return;let G=!1;return jm().then(le=>{G||w(le)}),()=>{G=!0}},[f]);const S=ph(l),v=l?{info:p.info,checking:p.checking,available:p.available,error:p.error,checkForUpdates:p.check,runtimeType:"web"}:{info:u.info,checking:u.checking,available:u.available,error:u.error,checkForUpdates:u.checkForUpdates,runtimeType:u.runtimeType},A=r||v.info?.currentVersion||"unknown",I=x||u.info?.currentVersion||"unknown",N=r||g?.info?.currentVersion||"unknown",k=uh(e("opencodeUpdate.toast.failed.description")),P=k.status?.currentVersion??null,j=k.phase.kind==="installed"?null:k.status?.availableVersion??null,[C,E]=m.useState(!1),F=G=>{const le=G?.version||"";return G?.packageManager==="electron"?e("settings.openchamber.about.actions.updateDesktopToVersion",{version:le}):e("settings.openchamber.about.actions.updateServerToVersion",{version:le})},O=(()=>{const G=v.info?.version||"";return l?F(v.info):f?e("settings.openchamber.about.actions.updateAppToVersion",{version:G}):e("settings.openchamber.about.actions.updateOpenChamberToVersion",{version:G})})(),K=G=>!!G?.installBlocked,D=v.available&&K(v.info),M=!!(g?.available&&K(g.info)),T=()=>{v.checkForUpdates(),g&&g.check(),k.refresh()},R=async G=>{(await Ai(G)).ok&&(E(!0),setTimeout(()=>E(!1),2e3))},$=()=>{k.reloadAfterUpgrade(async()=>{await Ed({message:e("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]})})},z=G=>{if(G?.installBlocked==="desktop-host")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:G.version||""})});if(G?.installBlocked==="manual-install")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.manualInstallUpdate",{version:G.version||""})});const le=G?.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:G?.version||""})}),s.jsxs("div",{className:"flex items-center gap-2 oc-tile-inset rounded-md p-1 ps-3",children:[s.jsx("code",{className:"flex-1 overflow-x-auto whitespace-nowrap font-mono text-sm text-foreground",children:le}),s.jsx(H,{type:"button",variant:"ghost",size:"icon",onClick:()=>{R(le)},"aria-label":e(C?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:s.jsx(te,{name:C?"check":"clipboard",className:"size-4"})})]})]})},Q=D?z(v.info):null,V=!g?.available||g.checking?null:M?z(g.info):s.jsxs(H,{type:"button",size:"sm",variant:"outline",onClick:()=>b(!0),children:[s.jsx(te,{name:"download",className:"size-4"}),F(g.info)]}),L=g?s.jsx(rr,{open:y,onOpenChange:b,info:g.info,downloading:!1,downloaded:!1,progress:null,error:g.error,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"}):null,B=(()=>{const{phase:G}=k;if(G.kind==="installed")return s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:G.version?e("settings.openchamber.about.openCode.installedVersion",{version:G.version}):e("settings.openchamber.about.openCode.installed")}),s.jsx(H,{type:"button",size:"sm",variant:"outline",onClick:$,children:e("opencodeUpdate.toast.actions.reload")})]});if(!j)return null;if(!k.status?.supported)return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.openCode.manualUpdate",{version:j})});const le=G.kind==="upgrading";return s.jsxs("div",{className:"space-y-2",children:[s.jsxs(H,{type:"button",size:"sm",variant:"outline",onClick:()=>{k.upgrade()},disabled:le,children:[le?s.jsx(va,{className:"size-4"}):s.jsx(te,{name:"download",className:"size-4"}),le?e("opencodeUpdate.toast.upgrading.title"):e("settings.openchamber.about.actions.updateOpenCodeToVersion",{version:j})]}),G.kind==="failed"&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:G.error})]})})();m.useEffect(()=>{let G=!1;return(async()=>{try{const J=await $t("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!J.ok)return;const me=await J.json().catch(()=>null),fe=typeof me?.openchamberVersion=="string"&&me.openchamberVersion.trim().length>0?me.openchamberVersion.trim():null;G||c(fe)}catch{G||c(null)}})(),()=>{G=!0}},[]);const W=g?.checking??!1,Y=g?.available??!1,ae=m.useRef(!1);m.useEffect(()=>{if(v.checking)o(!0),ae.current=!0;else if(i){const G=setTimeout(()=>{o(!1);const le=W||Y;ae.current&&!v.available&&!v.error&&!le&&(q.success(e(l?"settings.openchamber.about.toast.serverLatestVersion":"settings.openchamber.about.toast.latestVersion")),ae.current=!1)},rh);return()=>clearTimeout(G)}},[e,l,v.checking,i,v.available,v.error,W,Y]);const ee=v.checking||i;return d?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(km,{width:72,height:72}),s.jsx("h2",{className:`mt-4 ${wm}`,children:"OpenChamber"}),s.jsx("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:l?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:A})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:P||e("settings.openchamber.about.state.unknown")})}),S&&s.jsx("p",{children:e("settings.openchamber.about.native.appVersion",{version:S})})]}):f?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.appVersionLabel",{version:I})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:N})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:P||e("settings.openchamber.about.state.unknown")})})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:A})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:P||e("settings.openchamber.about.state.unknown")})})]})}),s.jsx(nc,{})]}),s.jsxs("div",{className:"flex justify-center",children:[!v.available&&!v.error&&s.jsxs(H,{type:"button",variant:"outline",size:"sm",onClick:T,disabled:ee,className:"w-auto justify-center gap-2",children:[ee?s.jsx(te,{name:"loader",className:"size-4 animate-spin"}):s.jsx(te,{name:"refresh",className:"size-4"}),e(ee?"settings.openchamber.about.state.checking":l?"settings.openchamber.about.actions.checkServerForUpdates":"settings.openchamber.about.actions.checkForUpdates")]}),!ee&&v.available&&!D&&s.jsxs(H,{type:"button",variant:"default",size:"sm",onClick:()=>n(!0),className:"w-auto justify-center gap-2",children:[s.jsx(te,{name:"download",className:"size-4"}),O]})]}),Q,V&&s.jsx("div",{className:"flex justify-center text-center",children:V}),B&&s.jsx("div",{className:"flex justify-center text-center",children:B}),[v.error,g?.error].filter(Boolean).map(G=>s.jsx("p",{className:"rounded-xl bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:G},G)),s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsxs("div",{className:"flex items-center justify-center gap-5",children:[s.jsxs("a",{href:ac,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(te,{name:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:oh,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(te,{name:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:ic,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(te,{name:"twitter-xfill",className:"size-5"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"text-center typography-ui text-muted-foreground/60",children:e("aboutDialog.footerNote")}),s.jsx(rr,{open:a,onOpenChange:n,info:v.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:v.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:v.runtimeType}),L]}):s.jsxs($e,{divider:!1,children:[s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center justify-between gap-4 px-4 py-3 border-b border-border/40",children:[f?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Vt,children:e("settings.openchamber.about.field.appVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:I})]}),s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Vt,children:e("settings.openchamber.about.field.serverVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:N})]})]}):s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Vt,children:e("settings.openchamber.about.field.version")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:A})]}),s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Vt,children:e("settings.openchamber.about.field.openCodeVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:P||e("settings.openchamber.about.state.unknown")})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[v.checking&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(te,{name:"loader",className:"h-4 w-4 animate-spin"}),s.jsx("span",{className:"typography-meta",children:e("settings.openchamber.about.state.checking")})]}),!v.checking&&v.available&&!D&&s.jsxs(H,{size:"sm",variant:"default",onClick:()=>n(!0),children:[s.jsx(te,{name:"download",className:"h-4 w-4 me-1"}),O]}),!v.checking&&!v.available&&!v.error&&s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")}),s.jsx(H,{size:"sm",variant:"outline",onClick:T,disabled:v.checking,children:e("settings.openchamber.about.actions.checkForUpdates")})]})]}),Q&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:Q}),V&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:V}),B&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:B}),[v.error,g?.error].filter(Boolean).map(G=>s.jsx("div",{className:"px-3 py-2 border-b border-border/40",children:s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:G})},G)),s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-4 py-3 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsx("span",{className:Vt,children:e("settings.openchamber.about.field.instanceUrls")}),s.jsx(nc,{})]}),s.jsxs("div",{className:"flex items-center gap-4 px-4 py-4",children:[s.jsxs("a",{href:ac,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx(te,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:ic,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx(te,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]})]}),s.jsx(rr,{open:a,onOpenChange:n,info:v.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:v.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:v.runtimeType}),L]})},fh=(t,e,a)=>t&&e.some(i=>i.path===t)?t:(e.find(i=>i.id===a)??e[0])?.path??null,Hs=()=>{const t=De.c(4),e=re(hh),a=on(bh),n=on(xh);let i;return t[0]!==n||t[1]!==a||t[2]!==e?(i=fh(e,a,n),t[0]=n,t[1]=a,t[2]=e,t[3]=i):i=t[3],i};function hh(t){return t.settingsProjectPath}function bh(t){return t.projects}function xh(t){return t.activeProjectId}const $r=Jo(t=>({tab:"general",setTab:e=>t({tab:e})})),vh=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"]]),yh=t=>vh.get(t)??null,zr=Jo(t=>({tab:"messages",setTab:e=>t({tab:e})})),jh=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-images-for-text-models","composer"],["chat.persist-drafts","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"]]),kh=t=>jh.get(t)??null,Qi=t=>{const e=De.c(73),{className:a}=t,{t:n}=Ee(),{currentTheme:i}=za(),o=re(wh),[r,c]=m.useState(!1),u=zo(on(Sh)),d=Hs(),l=re(Nh),f=os();let p;e[0]!==d||e[1]!==u?(p=u.find(C=>C.path===d)??u[0]??null,e[0]=d,e[1]=u,e[2]=p):p=e[2];const g=p;if(f||!g)return null;let h;e[3]!==l||e[4]!==u?(h=C=>{const E=u.find(F=>F.id===C);E&&l(E.path)},e[3]=l,e[4]=u,e[5]=h):h=e[5];const y=h;if(o){let C;e[6]!==a?(C=ze(a),e[6]=a,e[7]=C):C=e[7];let E;e[8]!==n?(E=n("settings.shared.projectSelector.switchProjectAria"),e[8]=n,e[9]=E):E=e[9];let F;e[10]!==n?(F=n("settings.shared.projectSelector.switchProjectTitle"),e[10]=n,e[11]=F):F=e[11];let O,K;e[12]===Symbol.for("react.memo_cache_sentinel")?(O=()=>c(!0),K=ze(Sm({size:"touch"}),"w-full min-w-0"),e[12]=O,e[13]=K):(O=e[12],K=e[13]);let D;e[14]!==g||e[15]!==i?(D=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:s.jsx(tr,{project:g,theme:i})}),e[14]=g,e[15]=i,e[16]=D):D=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(te,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[17]=M):M=e[17];let T;e[18]!==r||e[19]!==E||e[20]!==F||e[21]!==K||e[22]!==D?(T=s.jsxs("button",{type:"button","aria-label":E,title:F,"aria-haspopup":"dialog","aria-expanded":r,onClick:O,className:K,children:[D,M]}),e[18]=r,e[19]=E,e[20]=F,e[21]=K,e[22]=D,e[23]=T):T=e[23];let R;e[24]!==T||e[25]!==C?(R=s.jsx("div",{className:C,children:T}),e[24]=T,e[25]=C,e[26]=R):R=e[26];let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($=()=>c(!1),e[27]=$):$=e[27];const z=g.id;let Q;e[28]!==n?(Q=n("settings.shared.projectSelector.sheetTitle"),e[28]=n,e[29]=Q):Q=e[29];let V;e[30]!==n?(V=n("settings.shared.projectSelector.searchPlaceholder"),e[30]=n,e[31]=V):V=e[31];let L;e[32]!==g.id||e[33]!==i||e[34]!==y||e[35]!==r||e[36]!==u||e[37]!==Q||e[38]!==V?(L=s.jsx(Nm,{open:r,onClose:$,projects:u,selectedProjectId:z,onSelectProject:y,theme:i,title:Q,searchPlaceholder:V}),e[32]=g.id,e[33]=i,e[34]=y,e[35]=r,e[36]=u,e[37]=Q,e[38]=V,e[39]=L):L=e[39];let B;return e[40]!==R||e[41]!==L?(B=s.jsxs(s.Fragment,{children:[R,L]}),e[40]=R,e[41]=L,e[42]=B):B=e[42],B}let b;e[43]!==a?(b=ze(a),e[43]=a,e[44]=b):b=e[44];const x=g.id;let w;e[45]!==y?(w=C=>{C&&y(C)},e[45]=y,e[46]=w):w=e[46];let S;e[47]!==n?(S=n("settings.shared.projectSelector.switchProjectAria"),e[47]=n,e[48]=S):S=e[48];let v;e[49]!==n?(v=n("settings.shared.projectSelector.switchProjectTitle"),e[49]=n,e[50]=v):v=e[50];let A;e[51]!==g||e[52]!==i?(A=s.jsx(Kt,{children:s.jsx(tr,{project:g,theme:i})}),e[51]=g,e[52]=i,e[53]=A):A=e[53];let I;e[54]!==S||e[55]!==v||e[56]!==A?(I=s.jsx(Ct,{className:"w-full","aria-label":S,title:v,children:A}),e[54]=S,e[55]=v,e[56]=A,e[57]=I):I=e[57];let N;if(e[58]!==i||e[59]!==u){let C;e[61]!==i?(C=E=>s.jsx(bt,{value:E.id,className:"max-w-[24rem] truncate",children:s.jsx(tr,{project:E,theme:i})},E.id),e[61]=i,e[62]=C):C=e[62],N=u.map(C),e[58]=i,e[59]=u,e[60]=N}else N=e[60];let k;e[63]!==N?(k=s.jsx(It,{fitContent:!0,children:N}),e[63]=N,e[64]=k):k=e[64];let P;e[65]!==g.id||e[66]!==k||e[67]!==w||e[68]!==I?(P=s.jsxs(Pt,{value:x,onValueChange:w,children:[I,k]}),e[65]=g.id,e[66]=k,e[67]=w,e[68]=I,e[69]=P):P=e[69];let j;return e[70]!==P||e[71]!==b?(j=s.jsx("div",{className:b,children:P}),e[70]=P,e[71]=b,e[72]=j):j=e[72],j};function wh(t){return t.isMobile}function Sh(t){return t.projects}function Nh(t){return t.setSettingsProjectPath}const fl=t=>{const e=De.c(16),{value:a,onChange:n}=t,{t:i}=Ee();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(te,{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 r;e[1]!==n?(r=f=>n(f.target.value),e[1]=n,e[2]=r):r=e[2];let c;e[3]!==n||e[4]!==a?(c=f=>{f.key==="Escape"&&a&&(f.preventDefault(),f.stopPropagation(),n(""))},e[3]=n,e[4]=a,e[5]=c):c=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 l;return e[10]!==r||e[11]!==c||e[12]!==u||e[13]!==d||e[14]!==a?(l=s.jsxs("div",{className:"relative mt-3",children:[o,s.jsx(qe,{value:a,onChange:r,onKeyDown:c,placeholder:u,"aria-label":d,className:"h-8 ps-7 typography-meta"})]}),e[10]=r,e[11]=c,e[12]=u,e[13]=d,e[14]=a,e[15]=l):l=e[15],l},hl=t=>{const e=De.c(5),{query:a}=t,{t:n}=Ee();let i;e[0]!==a||e[1]!==n?(i=n("settings.common.sidebar.noMatches",{query:a.trim()}),e[0]=a,e[1]=n,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 Ch(t,e){return`opencode:sidebar-group:${t}:${e}`}const Ur=t=>{const e=De.c(33),{label:a,count:n,storageKey:i,defaultExpanded:o,children:r}=t,c=o===void 0?!0:o;let u;e[0]!==a||e[1]!==i?(u=Ch(i,a),e[0]=a,e[1]=i,e[2]=u):u=e[2];const d=u,l=m.useId();let f;e[3]!==c||e[4]!==d?(f=()=>{try{const C=localStorage.getItem(d);if(C!==null)return C==="true"}catch{}return c},e[3]=c,e[4]=d,e[5]=f):f=e[5];const[p,g]=Ke.useState(f);let h,y;e[6]!==p||e[7]!==d?(h=()=>{try{localStorage.setItem(d,String(p))}catch{}},y=[d,p],e[6]=p,e[7]=d,e[8]=h,e[9]=y):(h=e[8],y=e[9]),Ke.useEffect(h,y);let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=()=>g(Ih),e[10]=b):b=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=ze("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]=x):x=e[11];const w=!p&&"-rotate-90 rtl:rotate-90";let S;e[12]!==w?(S=ze("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",w),e[12]=w,e[13]=S):S=e[13];let v;e[14]!==S?(v=s.jsx(te,{name:"arrow-down-s",className:S}),e[14]=S,e[15]=v):v=e[15];let A;e[16]!==a?(A=s.jsx("span",{className:"flex-1 truncate",children:a}),e[16]=a,e[17]=A):A=e[17];let I;e[18]!==n?(I=s.jsx("span",{className:"ms-1 tabular-nums opacity-60",children:n}),e[18]=n,e[19]=I):I=e[19];let N;e[20]!==l||e[21]!==p||e[22]!==v||e[23]!==A||e[24]!==I?(N=s.jsxs("button",{type:"button",onClick:b,"aria-expanded":p,"aria-controls":l,className:x,children:[v,A,I]}),e[20]=l,e[21]=p,e[22]=v,e[23]=A,e[24]=I,e[25]=N):N=e[25];const k=!p;let P;e[26]!==r||e[27]!==l||e[28]!==k?(P=s.jsx("div",{id:l,hidden:k,className:"mt-0.5 space-y-0.5 ms-2 ps-3 border-s-2 border-[var(--interactive-border)]",children:r}),e[26]=r,e[27]=l,e[28]=k,e[29]=P):P=e[29];let j;return e[30]!==N||e[31]!==P?(j=s.jsxs("div",{children:[N,P]}),e[30]=N,e[31]=P,e[32]=j):j=e[32],j};function Ih(t){return!t}const Ph=({onItemSelect:t})=>{const{t:e}=Ee(),[a,n]=m.useState(""),[i,o]=m.useState(null),[r,c]=m.useState(""),[u,d]=m.useState(null),[l,f]=m.useState(!1),[p,g]=m.useState(null),{selectedAgentName:h,setSelectedAgent:y,setAgentDraft:b,createAgent:x,deleteAgent:w,loadAgents:S,loadDisabledAgents:v,updateAgent:A,fetchAgentEntity:I}=Cn(_s(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}))),N=Hs(),k=Cn(J=>Md(J,N)),P=Cn(J=>Cm(J,N)),[j,C]=m.useState(null);m.useEffect(()=>{S(N),v(N)},[S,v,N]);const E=k.filter(J=>Co(J.mode)&&!Al(J)).length,F=J=>!(Co(J.mode)&&!Al(J)&&E<=1),O=async(J,me)=>{C(J);try{await A(J,{disabled:me},N),me&&h===J&&y(null),q.success(me?e("settings.agents.sidebar.toast.agentDisabled",{name:J}):e("settings.agents.sidebar.toast.agentEnabled",{name:J}))}catch{q.error(e(me?"settings.agents.sidebar.toast.disableFailed":"settings.agents.sidebar.toast.enableFailed"))}finally{C(null)}},K=P.filter(J=>Fi([J.name,J.description],a)),D="bg-background",M=()=>{const J="new-agent";let me=J,fe=1;for(;k.some(oe=>oe.name===me);)me=`${J}-${fe}`,fe++;b({name:me,scope:"user"}),y(me),t?.()},T=async J=>{if(Ti(J)){q.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}d(J)},R=()=>{d(null)},$=async()=>{if(u){f(!0);try{(await w(u.name,u.scope,N)).ok?(q.success(e("settings.agents.sidebar.toast.agentDeleted",{name:u.name})),R()):q.error(e("settings.agents.sidebar.toast.deleteFailed"))}catch(J){const me=J instanceof Error?J.message:"",fe=/built-in|not deletable|not found/i.test(me);q.error(e(fe?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed"))}f(!1)}},z=async J=>{const me=J.name;let fe=1,oe=`${me}-copy`;for(;k.some(be=>be.name===oe);)fe++,oe=`${me}-copy-${fe}`;const pe=J,se=await I(J.name,N);if(!se){q.error(e("settings.agents.sidebar.toast.renameFailed"));return}const ve=se.config.request?.body;b({name:oe,scope:se.scope??pe.scope??"user",description:se.config.description??void 0,model:se.config.model??null,system:se.config.system??void 0,steps:se.config.steps??void 0,temperature:ve?.temperature,top_p:ve?.top_p,mode:se.config.mode??pe.mode,permissions:se.config.permissions??void 0,hidden:se.config.hidden}),y(oe),t?.()},Q=J=>{c(J.name),o(J)},V=async()=>{if(!i)return;const J=r.trim().replace(/\s+/g,"-");if(!J){q.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(J===i.name){o(null);return}if(k.some(pe=>pe.name===J)){q.error(e("settings.agents.sidebar.toast.agentExists"));return}const me=i,fe=await I(i.name,N);if(!fe){q.error(e("settings.agents.sidebar.toast.renameFailed"));return}(await x({...fe.config,name:J,scope:fe.scope??me.scope},N)).ok?(await w(i.name,me.scope,N)).ok?(q.success(e("settings.agents.sidebar.toast.agentRenamed",{name:J})),y(J)):q.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed")):q.error(e("settings.agents.sidebar.toast.renameFailed")),o(null)},L=J=>{switch(J){case"primary":return s.jsx(te,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return s.jsx(te,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return s.jsx(te,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},B=new Set(P.map(J=>J.name)),W=k.filter(J=>Im(J)&&!B.has(J.name)),Y=W.filter(J=>Fi([J.name,J.description],a)),ae=Y.filter(Ti),ee=Y.filter(J=>!Ti(J)),{groupedCustomAgents:G,ungroupedCustomAgents:le}=Ke.useMemo(()=>{const J={},me=[];for(const oe of ee){const pe=oe;pe.group?(J[pe.group]||(J[pe.group]=[]),J[pe.group].push(oe)):me.push(oe)}return{groupedCustomAgents:Object.keys(J).sort((oe,pe)=>oe.localeCompare(pe)).map(oe=>({name:oe,agents:J[oe]})),ungroupedCustomAgents:me}},[ee]);return s.jsxs("div",{className:ze("flex h-full flex-col",D),children:[s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[s.jsx("h2",{className:`${Wn} mb-3`,children:e("settings.agents.sidebar.title")}),s.jsx(Qi,{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:W.length})}),s.jsx(H,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:M,children:s.jsx(te,{name:"add",className:"h-3.5 w-3.5"})})]}),W.length>0?s.jsx(fl,{value:a,onChange:n}):null]}),s.jsxs(Os,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:[W.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(te,{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")})]}):Y.length===0?s.jsx(hl,{query:a}):s.jsxs(s.Fragment,{children:[ae.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")}),ae.map(J=>s.jsx(lr,{agent:J,isSelected:h===J.name,onSelect:()=>{y(J.name),t?.()},onDuplicate:()=>{z(J)},onDisable:F(J)?()=>{O(J.name,!0)}:void 0,getAgentModeIcon:L,isMenuOpen:p===J.name,onMenuOpenChange:me=>g(me?J.name:null)},J.name))]}),ee.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.custom")}),G.map(({name:J,agents:me})=>s.jsx(Ur,{label:J,count:me.length,storageKey:"agents",children:me.map(fe=>s.jsx(lr,{agent:fe,isSelected:h===fe.name,onSelect:()=>{y(fe.name),t?.()},onRename:()=>Q(fe),onDelete:()=>T(fe),onDuplicate:()=>{z(fe)},onDisable:F(fe)?()=>{O(fe.name,!0)}:void 0,getAgentModeIcon:L,isMenuOpen:p===fe.name,onMenuOpenChange:oe=>g(oe?fe.name:null)},fe.name))},J)),le.map(J=>s.jsx(lr,{agent:J,isSelected:h===J.name,onSelect:()=>{y(J.name),t?.()},onRename:()=>Q(J),onDelete:()=>T(J),onDuplicate:()=>{z(J)},onDisable:F(J)?()=>{O(J.name,!0)}:void 0,getAgentModeIcon:L,isMenuOpen:p===J.name,onMenuOpenChange:me=>g(me?J.name:null)},J.name))]})]}),K.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.disabled")}),K.map(J=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-1.5 py-1",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"typography-ui-label truncate text-muted-foreground",children:J.name}),J.description?s.jsx("div",{className:"typography-micro truncate leading-tight text-muted-foreground/60",children:J.description}):null]}),s.jsx(H,{size:"xs",variant:"outline",disabled:j===J.name,onClick:()=>{O(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(Tt,{open:u!==null,onOpenChange:J=>{!J&&!l&&R()},children:s.jsxs(Et,{className:"max-w-md",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:e("settings.agents.sidebar.dialog.deleteTitle")}),s.jsx(Ft,{children:e("settings.agents.sidebar.dialog.deleteDescription",{name:u?.name??""})})]}),s.jsxs(Wt,{children:[s.jsx(H,{size:"sm",variant:"ghost",onClick:R,disabled:l,children:e("settings.common.actions.cancel")}),s.jsx(H,{size:"sm",onClick:$,disabled:l,children:e("settings.common.actions.delete")})]})]})}),s.jsx(Tt,{open:i!==null,onOpenChange:J=>!J&&o(null),children:s.jsxs(Et,{children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:e("settings.agents.sidebar.renameDialog.title")}),s.jsx(Ft,{children:e("settings.agents.sidebar.renameDialog.description",{name:i?.name??""})})]}),s.jsx(qe,{value:r,onChange:J=>c(J.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:J=>{J.key==="Enter"&&V()}}),s.jsxs(Wt,{children:[s.jsx(H,{size:"sm",variant:"ghost",onClick:()=>o(null),children:e("settings.common.actions.cancel")}),s.jsx(H,{size:"sm",onClick:V,children:e("settings.common.actions.rename")})]})]})})]})},lr=t=>{const e=De.c(52),{agent:a,isSelected:n,onSelect:i,onDelete:o,onRename:r,onDuplicate:c,onDisable:u,getAgentModeIcon:d,isMenuOpen:l,onMenuOpenChange:f}=t,{t:p}=Ee(),g=a;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=tl(),e[0]=h):h=e[0];const y=h,[b,x]=m.useState(!1);let w;e[1]!==o||e[2]!==u||e[3]!==c||e[4]!==r||e[5]!==p?(w=Q=>s.jsxs(s.Fragment,{children:[r&&s.jsxs(Q,{onClick:V=>{V.stopPropagation(),r()},children:[s.jsx(te,{name:"edit",className:"h-4 w-4 me-px"}),p("settings.common.actions.rename")]}),s.jsxs(Q,{onClick:V=>{V.stopPropagation(),c()},children:[s.jsx(te,{name:"file-copy",className:"h-4 w-4 me-px"}),p("settings.common.actions.duplicate")]}),u&&s.jsxs(Q,{onClick:V=>{V.stopPropagation(),u()},children:[s.jsx(te,{name:"eye-off",className:"h-4 w-4 me-px"}),p("settings.agents.sidebar.actions.disable")]}),o&&s.jsxs(Q,{onClick:V=>{V.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[s.jsx(te,{name:"delete-bin",className:"h-4 w-4 me-px"}),p("settings.common.actions.delete")]})]}),e[1]=o,e[2]=u,e[3]=c,e[4]=r,e[5]=p,e[6]=w):w=e[6];const S=w,v=n?"bg-interactive-selection":"hover:bg-interactive-hover";let A;e[7]!==v?(A=ze("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",v),e[7]=v,e[8]=A):A=e[8];let I;e[9]===Symbol.for("react.memo_cache_sentinel")?(I=y?void 0:Q=>{Q.preventDefault(),x(!0)},e[9]=I):I=e[9];let N;e[10]!==A?(N=s.jsx("div",{className:A,onContextMenu:I}),e[10]=A,e[11]=N):N=e[11];let k;e[12]!==a.name?(k=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a.name}),e[12]=a.name,e[13]=k):k=e[13];let P;e[14]!==a.mode||e[15]!==d?(P=d(a.mode),e[14]=a.mode,e[15]=d,e[16]=P):P=e[16];let j;e[17]!==a||e[18]!==g.scope||e[19]!==p?(j=(g.scope||Ti(a))&&s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:Ti(a)?p("settings.agents.sidebar.badge.system"):g.scope}),e[17]=a,e[18]=g.scope,e[19]=p,e[20]=j):j=e[20];let C;e[21]!==k||e[22]!==P||e[23]!==j?(C=s.jsxs("div",{className:"flex items-center gap-1.5",children:[k,P,j]}),e[21]=k,e[22]=P,e[23]=j,e[24]=C):C=e[24];let E;e[25]!==a.description?(E=a.description&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a.description}),e[25]=a.description,e[26]=E):E=e[26];let F;e[27]!==i||e[28]!==C||e[29]!==E?(F=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,E]}),e[27]=i,e[28]=C,e[29]=E,e[30]=F):F=e[30];let O;e[31]!==f?(O=Q=>{Q&&x(!1),f(Q)},e[31]=f,e[32]=O):O=e[32];let K;e[33]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(ja,{asChild:!0,children:s.jsx(H,{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(te,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=K):K=e[33];let D;e[34]!==S?(D=s.jsx(ya,{align:"end",className:"w-fit min-w-20",children:S(fa)}),e[34]=S,e[35]=D):D=e[35];let M;e[36]!==l||e[37]!==O||e[38]!==D?(M=s.jsxs(ka,{open:l,onOpenChange:O,children:[K,D]}),e[36]=l,e[37]=O,e[38]=D,e[39]=M):M=e[39];let T;e[40]!==F||e[41]!==M?(T=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[F,M]}),e[40]=F,e[41]=M,e[42]=T):T=e[42];let R;e[43]!==T||e[44]!==N?(R=s.jsx(Bi,{render:N,children:T}),e[43]=T,e[44]=N,e[45]=R):R=e[45];let $;e[46]!==S?($=s.jsx(zi,{className:"w-fit min-w-20",children:S(Ui)}),e[46]=S,e[47]=$):$=e[47];let z;return e[48]!==b||e[49]!==R||e[50]!==$?(z=s.jsxs(Vi,{open:b,onOpenChange:x,children:[R,$]}),e[48]=b,e[49]=R,e[50]=$,e[51]=z):z=e[51],z},Ls={ok:!0,changed:!1},In={ok:!0,changed:!0},gs=t=>({ok:!1,reason:t}),Ah=t=>t instanceof HTMLElement?t.matches('input, textarea, [contenteditable="true"]'):!1,ci=t=>{const{t:e}=Ee(),[a,n]=m.useState(0),i=m.useRef(t);i.current=t;const o=m.useRef(e);o.current=e;const r=m.useRef(!1),c=m.useRef(!1),u=m.useRef(!1),d=m.useCallback(()=>{n(p=>p+1)},[]),l=m.useCallback(p=>{Ah(p.target)&&d()},[d]),f=m.useCallback(async()=>{r.current=!0;try{for(;;){c.current=!1;let p;try{p=await i.current()}catch(g){p={ok:!1,reason:g instanceof Error?g.message:String(g)}}if(!u.current)return;if(!c.current){p.ok||q.error(o.current("settings.common.status.saveFailedReason",{reason:p.reason}));return}}}finally{r.current=!1}},[]);return m.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]),m.useEffect(()=>{if(a!==0){if(r.current){c.current=!0;return}f()}},[a,f]),{requestSave:d,onBlurCapture:l}},Th=["allow","ask","deny"],Eh=["shell","edit","read","glob","grep","patch","webfetch","websearch","skill","subagent","question","external_directory"],Mh=["openchamber","openchamber_schedule","openchamber_web","openchamber_memory","openchamber_knowledge","openchamber_notify","openchamber_render"],Dh=new Set(["bash","task","write","list","lsp","todowrite","todoread","multiedit","doom_loop","plan_enter","plan_exit"]),hu=t=>Dh.has(t),Rh=[{action:"*",resource:"*",effect:"allow"},{action:"read",resource:"*.env",effect:"ask"},{action:"read",resource:"*.env.*",effect:"ask"},{action:"read",resource:"*.env.example",effect:"allow"}],oc=()=>({global:null,keys:{},source:[]}),Pa=t=>({global:t.global,source:t.source,keys:Object.fromEntries(Object.entries(t.keys).map(([e,a])=>[e,{effect:a.effect,patterns:a.patterns.map(n=>({...n}))}]))}),Oh=t=>{const e={global:null,keys:{},source:t.map(a=>({...a}))};for(const a of t){if(hu(a.action))continue;if(a.action==="*"){a.resource==="*"&&(e.global=a.effect);continue}const n=e.keys[a.action]??{effect:null,patterns:[]};if(a.resource==="*")n.effect=a.effect;else{const i=n.patterns.findIndex(o=>o.pattern===a.resource);i>=0?n.patterns[i]={pattern:a.resource,effect:a.effect}:n.patterns.push({pattern:a.resource,effect:a.effect})}e.keys[a.action]=n}return e},Fh=t=>t.action!=="*"||t.resource==="*",Oa=(t,e)=>`${t}\0${e}`,Lh=t=>{const e=new Map;t.global!==null&&e.set(Oa("*","*"),t.global);for(const[a,n]of Object.entries(t.keys)){n.effect!==null&&e.set(Oa(a,"*"),n.effect);for(const i of n.patterns){const o=i.pattern.trim();o.length!==0&&e.set(Oa(a,o),i.effect)}}return e},Br=t=>{const e=Lh(t),a=new Set,n=[];for(const o of t.source){if(hu(o.action))continue;if(!Fh(o)){n.push({...o});continue}const r=Oa(o.action,o.resource),c=e.get(r);c!==void 0&&(n.push({action:o.action,resource:o.resource,effect:c}),a.add(r))}const i=Oa("*","*");t.global!==null&&!a.has(i)&&n.unshift({action:"*",resource:"*",effect:t.global});for(const[o,r]of Object.entries(t.keys)){const c=Oa(o,"*");if(r.effect!==null&&!a.has(c)){const u=n.findIndex(l=>l.action===o),d={action:o,resource:"*",effect:r.effect};u>=0?n.splice(u,0,d):n.push(d)}for(const u of r.patterns){const d=u.pattern.trim();if(d.length===0)continue;const l=Oa(o,d),f=e.get(l);f===void 0||a.has(l)||(a.add(l),n.push({action:o,resource:d,effect:f}))}}return n},Kh=(t,e)=>JSON.stringify(Br(t))===JSON.stringify(Br(e)),_h=(t,e)=>{const a=[...Rh,...e.global,...e.agentGlobal?[{action:"*",resource:"*",effect:e.agentGlobal}]:[]];let n="ask";for(const i of a)i.resource==="*"&&(i.action==="*"||i.action===t)&&(n=i.effect);return n},$h=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),zh=new Set(["shell","edit","read","glob","grep","patch","webfetch","skill","subagent","external_directory"]),Uh={effect:null,patterns:[]},Bh=t=>{const e=De.c(163),{agent:a,registerSave:n,requestSave:i}=t,{t:o}=Ee(),r=Cn(Vh),c=Cn(Hh);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],e[0]=u):u=e[0];const[d,l]=m.useState(u),[f,p]=m.useState(oc),[g,h]=m.useState(oc),[y,b]=m.useState(!0),[x,w]=m.useState(!1);let S;e[1]===Symbol.for("react.memo_cache_sentinel")?(S={},e[1]=S):S=e[1];const[v,A]=m.useState(S),[I,N]=m.useState(""),[k,P]=m.useState(0),j=a.name,C=Hs(),E=$n(qh);let F;e[2]!==C?(F=Be=>sl(Be,C),e[2]=C,e[3]=F):F=e[3];const O=$n(F);let K;e[4]!==C?(K=Be=>Be.getStatusForDirectory(C),e[4]=C,e[5]=K):K=e[5];const D=gn(K);let M,T;e[6]!==E||e[7]!==C?(M=()=>{E({directory:C})},T=[E,C],e[6]=E,e[7]=C,e[8]=M,e[9]=T):(M=e[8],T=e[9]),m.useEffect(M,T);let R;e[10]!==j||e[11]!==c||e[12]!==C?(R=()=>{let Be=!1;return b(!0),w(!1),(async()=>{const ot=await c(j,C);if(Be)return;if(!ot){w(!0),b(!1);return}const et=Oh(ot.agent);l(ot.global),p(Pa(et)),h(et),A({}),b(!1)})(),()=>{Be=!0}},e[10]=j,e[11]=c,e[12]=C,e[13]=R):R=e[13];let $;e[14]!==j||e[15]!==c||e[16]!==k||e[17]!==C?($=[j,c,k,C],e[14]=j,e[15]=c,e[16]=k,e[17]=C,e[18]=$):$=e[18],m.useEffect(R,$);let z;e[19]!==j||e[20]!==f||e[21]!==g||e[22]!==C||e[23]!==o||e[24]!==r?(z=async()=>Kh(g,f)?Ls:(await r(j,{permissions:Br(g)},C)).ok?(p(Pa(g)),In):gs(o("settings.agents.page.permissionsEditor.toast.saveFailed")),e[19]=j,e[20]=f,e[21]=g,e[22]=C,e[23]=o,e[24]=r,e[25]=z):z=e[25];const Q=z;let V,L;e[26]!==n||e[27]!==Q?(V=()=>(n(Q),()=>n(null)),L=[n,Q],e[26]=n,e[27]=Q,e[28]=V,e[29]=L):(V=e[28],L=e[29]),m.useEffect(V,L);let B;e[30]!==O?(B=O.map(Wh),e[30]=O,e[31]=B):B=e[31];const W=B;let Y;if(e[32]!==W||e[33]!==g.keys){Y=[...Eh,...Mh];const Be=new Set(W.map(Gh));let ot;e[35]!==g.keys?(ot=Object.keys(g.keys),e[35]=g.keys,e[36]=ot):ot=e[36];for(const et of ot)!Y.includes(et)&&!Be.has(et)&&Y.push(et);e[32]=W,e[33]=g.keys,e[34]=Y}else Y=e[34];const ae=Y;let ee;e[37]!==D||e[38]!==o?(ee=Be=>{switch(D?.[Be]?.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]=D,e[38]=o,e[39]=ee):ee=e[39];const G=ee;let le;e[40]!==d||e[41]!==g.global?(le=Be=>_h(Be,{global:d,agentGlobal:g.global}),e[40]=d,e[41]=g.global,e[42]=le):le=e[42];const J=le;let me;e[43]!==i?(me=Be=>{h(ot=>({...ot,global:Be})),i()},e[43]=i,e[44]=me):me=e[44];const fe=me;let oe;e[45]!==i?(oe=(Be,ot)=>{h(et=>{const ye=Pa(et),Z=ye.keys[Be]??{effect:null,patterns:[]};return Z.effect=ot,Z.effect===null&&Z.patterns.length===0?delete ye.keys[Be]:ye.keys[Be]=Z,ye}),i()},e[45]=i,e[46]=oe):oe=e[46];const pe=oe;let se;e[47]!==i?(se=(Be,ot,et,ye,Z)=>{h(Oe=>{const Ve=Pa(Oe),X=Ve.keys[Be]??{effect:null,patterns:[]};return X.patterns[ot]={pattern:et,effect:ye},Ve.keys[Be]=X,Ve}),Z&&i()},e[47]=i,e[48]=se):se=e[48];const ve=se;let be;e[49]===Symbol.for("react.memo_cache_sentinel")?(be=Be=>{h(ot=>{const et=Pa(ot),ye=et.keys[Be]??{effect:null,patterns:[]};return ye.patterns.push({pattern:"",effect:"allow"}),et.keys[Be]=ye,et}),A(ot=>({...ot,[Be]:!0}))},e[49]=be):be=e[49];const ne=be;let we;e[50]!==i?(we=(Be,ot)=>{h(et=>{const ye=Pa(et),Z=ye.keys[Be];return Z?(Z.patterns.splice(ot,1),Z.effect===null&&Z.patterns.length===0&&delete ye.keys[Be],ye):et}),i()},e[50]=i,e[51]=we):we=e[51];const Ne=we;let Ie;e[52]!==I||e[53]!==i?(Ie=()=>{const Be=I.trim();!Be||Be==="*"||(h(ot=>{if(ot.keys[Be])return ot;const et=Pa(ot);return et.keys[Be]={effect:"ask",patterns:[]},et}),N(""),i())},e[52]=I,e[53]=i,e[54]=Ie):Ie=e[54];const Ce=Ie;let Me;e[55]!==o?(Me=Be=>o(Be==="allow"?"settings.agents.page.permissionsEditor.action.allow":Be==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),e[55]=o,e[56]=Me):Me=e[56];const he=Me;let Pe,Re,ce,je,de,ie,xe,Se,Le;if(e[57]!==he||e[58]!==J||e[59]!==v||e[60]!==y||e[61]!==x||e[62]!==W||e[63]!==G||e[64]!==g.global||e[65]!==g.keys||e[66]!==Ne||e[67]!==fe||e[68]!==pe||e[69]!==ve||e[70]!==o||e[71]!==ae){Le=Symbol.for("react.early_return_sentinel");e:{const Be=o("settings.agents.page.permissionsEditor.action.inherit"),ot=o("settings.agents.page.permissionsEditor.action.default");let et;e[81]!==he?(et=Je=>[...Je?[{value:"inherit",label:Je}]:[],...Th.map(mt=>({value:mt,label:he(mt)}))],e[81]=he,e[82]=et):et=e[82];const ye=et,Z=(Je,mt,Qe,_)=>{const ge=_===void 0?Be:_;return s.jsx(Xt,{value:Je??"inherit",options:ye(ge),onChange:Ae=>mt(Ae==="inherit"?null:Ae),"aria-label":Qe})};if(y){let Je;e[83]!==o?(Je=o("settings.agents.page.section.toolPermissions"),e[83]=o,e[84]=Je):Je=e[84];let mt;e[85]!==o?(mt=o("common.loading"),e[85]=o,e[86]=mt):mt=e[86];let Qe;e[87]!==mt?(Qe=s.jsx("p",{className:_t,children:mt}),e[87]=mt,e[88]=Qe):Qe=e[88];let _;e[89]!==Je||e[90]!==Qe?(_=s.jsx($e,{title:Je,children:Qe}),e[89]=Je,e[90]=Qe,e[91]=_):_=e[91],Le=_;break e}if(x){let Je;e[92]!==o?(Je=o("settings.agents.page.section.toolPermissions"),e[92]=o,e[93]=Je):Je=e[93];let mt;e[94]!==o?(mt=o("settings.agents.page.permissionsEditor.state.loadFailed"),e[94]=o,e[95]=mt):mt=e[95];let Qe;e[96]!==mt?(Qe=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:mt}),e[96]=mt,e[97]=Qe):Qe=e[97];let _;e[98]===Symbol.for("react.memo_cache_sentinel")?(_=()=>P(Jh),e[98]=_):_=e[98];let ge;e[99]!==o?(ge=o("settings.agents.page.permissionsEditor.actions.retry"),e[99]=o,e[100]=ge):ge=e[100];let Ae;e[101]!==ge?(Ae=s.jsx(H,{variant:"outline",size:"xs",onClick:_,children:ge}),e[101]=ge,e[102]=Ae):Ae=e[102];let Te;e[103]!==Qe||e[104]!==Ae?(Te=s.jsxs("div",{className:"flex items-center gap-3",children:[Qe,Ae]}),e[103]=Qe,e[104]=Ae,e[105]=Te):Te=e[105];let Ge;e[106]!==Je||e[107]!==Te?(Ge=s.jsx($e,{title:Je,children:Te}),e[106]=Je,e[107]=Te,e[108]=Ge):Ge=e[108],Le=Ge;break e}const Oe=(Je,mt,Qe)=>{const _=g.keys[Je]??Uh,ge=zh.has(Je)||_.patterns.length>0,Ae=v[Je]===!0;return s.jsxs("div",{className:"border-t border-border/40 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:ge?()=>A(Te=>({...Te,[Je]:!Ae})):void 0,className:ze("flex min-w-0 items-center gap-1.5 text-start",!ge&&"cursor-default"),"aria-expanded":ge?Ae:void 0,children:[s.jsx(te,{name:Ae&&ge?"arrow-down-s":"arrow-right-s",className:ze("h-3.5 w-3.5 shrink-0 text-muted-foreground",!ge&&"opacity-0")}),s.jsx("span",{className:Vt,children:mt}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground/70",children:Je}),Qe&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:Qe}),_.effect===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:he(J(Je))})}),_.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(_.patterns.length)})})]}),Z(_.effect,Te=>pe(Je,Te),o("settings.agents.page.permissionsEditor.keyAria",{key:Je}))]}),Ae&&ge&&s.jsxs("div",{className:"mt-2 space-y-2 ps-5",children:[_.patterns.map((Te,Ge)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(qe,{value:Te.pattern,onChange:ue=>ve(Je,Ge,ue.target.value,Te.effect,!1),placeholder:o("settings.agents.page.permissionsEditor.patternPlaceholder"),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:Je}),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(Xt,{value:Te.effect,options:ye(),onChange:ue=>ve(Je,Ge,Te.pattern,ue,!0),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:Je})}),s.jsx(H,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>Ne(Je,Ge),"aria-label":o("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx(te,{name:"close",className:"h-3.5 w-3.5"})})]},Ge)),s.jsxs(H,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ne(Je),children:[s.jsx(te,{name:"add",className:"me-1 h-3.5 w-3.5"}),o("settings.agents.page.permissionsEditor.actions.addRule")]})]})]},Je)};Pe=$e,e[109]!==o?(Re=o("settings.agents.page.section.toolPermissions"),e[109]=o,e[110]=Re):Re=e[110],ce="agents.permissions",e[111]!==o?(je=o("settings.agents.page.permissionsEditor.sectionInfo"),e[111]=o,e[112]=je):je=e[112],de="space-y-4";let Ve;e[113]!==o?(Ve=o("settings.agents.page.permissionsEditor.defaultLabel"),e[113]=o,e[114]=Ve):Ve=e[114];let X;e[115]!==Ve?(X=s.jsx("span",{className:Vt,children:Ve}),e[115]=Ve,e[116]=X):X=e[116];let _e;e[117]!==o?(_e=o("settings.agents.page.permissionsEditor.defaultInfo"),e[117]=o,e[118]=_e):_e=e[118];let nt;e[119]!==_e?(nt=s.jsx(ts,{children:_e}),e[119]=_e,e[120]=nt):nt=e[120];let ht;e[121]!==he||e[122]!==J||e[123]!==g.global||e[124]!==o?(ht=g.global===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:he(J("*"))})}),e[121]=he,e[122]=J,e[123]=g.global,e[124]=o,e[125]=ht):ht=e[125];let yt;e[126]!==X||e[127]!==nt||e[128]!==ht?(yt=s.jsxs("div",{className:"flex items-center gap-1.5",children:[X,nt,ht]}),e[126]=X,e[127]=nt,e[128]=ht,e[129]=yt):yt=e[129];const kt=g.global;let He;e[130]!==o?(He=o("settings.agents.page.permissionsEditor.defaultAria"),e[130]=o,e[131]=He):He=e[131],ie=s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[yt,Z(kt,fe,He,ot)]}),xe=s.jsx("div",{children:ae.map(Je=>Oe(Je,$h(Je),null))}),Se=W.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border/40 pt-3 pb-1",children:[s.jsx("span",{className:Vt,children:o("settings.agents.page.permissionsEditor.mcpTitle")}),s.jsx(ts,{children:o("settings.agents.page.permissionsEditor.mcpInfo")})]}),W.map(Je=>Oe(Je.key,Je.server,G(Je.server)))]})}e[57]=he,e[58]=J,e[59]=v,e[60]=y,e[61]=x,e[62]=W,e[63]=G,e[64]=g.global,e[65]=g.keys,e[66]=Ne,e[67]=fe,e[68]=pe,e[69]=ve,e[70]=o,e[71]=ae,e[72]=Pe,e[73]=Re,e[74]=ce,e[75]=je,e[76]=de,e[77]=ie,e[78]=xe,e[79]=Se,e[80]=Le}else Pe=e[72],Re=e[73],ce=e[74],je=e[75],de=e[76],ie=e[77],xe=e[78],Se=e[79],Le=e[80];if(Le!==Symbol.for("react.early_return_sentinel"))return Le;let Ue;e[132]===Symbol.for("react.memo_cache_sentinel")?(Ue=Be=>N(Be.target.value),e[132]=Ue):Ue=e[132];let Ye;e[133]!==Ce?(Ye=Be=>{Be.key==="Enter"&&(Be.preventDefault(),Ce())},e[133]=Ce,e[134]=Ye):Ye=e[134];let lt;e[135]!==o?(lt=o("settings.agents.page.permissionsEditor.customKeyPlaceholder"),e[135]=o,e[136]=lt):lt=e[136];let at;e[137]!==I||e[138]!==Ye||e[139]!==lt?(at=s.jsx(qe,{value:I,onChange:Ue,onKeyDown:Ye,placeholder:lt,className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),e[137]=I,e[138]=Ye,e[139]=lt,e[140]=at):at=e[140];let ut;e[141]!==I?(ut=I.trim(),e[141]=I,e[142]=ut):ut=e[142];const vt=!ut;let We;e[143]===Symbol.for("react.memo_cache_sentinel")?(We=s.jsx(te,{name:"add",className:"me-1 h-3.5 w-3.5"}),e[143]=We):We=e[143];let Ze;e[144]!==o?(Ze=o("settings.agents.page.permissionsEditor.actions.addKey"),e[144]=o,e[145]=Ze):Ze=e[145];let Xe;e[146]!==Ce||e[147]!==vt||e[148]!==Ze?(Xe=s.jsxs(H,{variant:"outline",size:"xs",className:"!font-normal",onClick:Ce,disabled:vt,children:[We,Ze]}),e[146]=Ce,e[147]=vt,e[148]=Ze,e[149]=Xe):Xe=e[149];let it;e[150]!==at||e[151]!==Xe?(it=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-border/40 pt-3",children:[at,Xe]}),e[150]=at,e[151]=Xe,e[152]=it):it=e[152];let dt;return e[153]!==Pe||e[154]!==Re||e[155]!==ce||e[156]!==je||e[157]!==de||e[158]!==ie||e[159]!==xe||e[160]!==Se||e[161]!==it?(dt=s.jsxs(Pe,{title:Re,settingsItem:ce,info:je,contentClassName:de,children:[ie,xe,Se,it]}),e[153]=Pe,e[154]=Re,e[155]=ce,e[156]=je,e[157]=de,e[158]=ie,e[159]=xe,e[160]=Se,e[161]=it,e[162]=dt):dt=e[162],dt};function Vh(t){return t.updateAgent}function Hh(t){return t.fetchAgentPermissions}function qh(t){return t.loadMcpConfigs}function Wh(t){return{key:`${t.name}_*`,server:t.name}}function Gh(t){return t.key}function Jh(t){return t+1}const bl=t=>{const e=De.c(11),{legacy:a,path:n,className:i}=t,{t:o}=Ee();if(!a)return null;let r;e[0]!==i?(r=ze("mb-4 flex items-start gap-1.5",_t,i),e[0]=i,e[1]=r):r=e[1];const c=n??void 0;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(te,{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 l;e[5]!==d?(l=s.jsx("span",{children:d}),e[5]=d,e[6]=l):l=e[6];let f;return e[7]!==r||e[8]!==c||e[9]!==l?(f=s.jsxs("p",{className:r,title:c,children:[u,l]}),e[7]=r,e[8]=c,e[9]=l,e[10]=f):f=e[10],f},Qh=(t,e)=>{const a=Un(e);if(!a)return[];const n=t.find(o=>o.id===a.providerId),i=fg(n?.models,a.modelId);return Dd(i)},Yh=t=>Pm(t)?.toLowerCase()??"",Zh=()=>{const{t}=Ee(),e=ft(he=>he.providers),{selectedAgentName:a,getAgentByName:n,createAgent:i,updateAgent:o,fetchAgentEntity:r,agentDraft:c,setAgentDraft:u,setSelectedAgent:d}=Cn(_s(he=>({selectedAgentName:he.selectedAgentName,getAgentByName:he.getAgentByName,createAgent:he.createAgent,updateAgent:he.updateAgent,fetchAgentEntity:he.fetchAgentEntity,agentDraft:he.agentDraft,setAgentDraft:he.setAgentDraft,setSelectedAgent:he.setSelectedAgent}))),l=Hs(),f=Cn(he=>Md(he,l)),p=a?n(a,l):null,g=!!(c&&c.name===a&&!p),h=g?"":p?.description?.trim()??"",y=g?"":p?.system?.trim()??"",[b,x]=m.useState(""),[w,S]=m.useState("user"),[v,A]=m.useState(""),[I,N]=m.useState("subagent"),[k,P]=m.useState(""),[j,C]=m.useState(""),[E,F]=m.useState(void 0),[O,K]=m.useState(void 0),[D,M]=m.useState(void 0),[T,R]=m.useState(""),[$,z]=m.useState(""),[Q,V]=m.useState(!1),[L,B]=m.useState(null),W=m.useRef({}),Y=m.useRef(null),ae=m.useCallback(he=>{Y.current=he},[]),ee=m.useRef(null),G=JSON.stringify([a,l,g]),le=m.useRef(G);le.current=G;const J=m.useRef(null),me={description:v,mode:I,model:k,variant:j,steps:E,temperature:O,topP:D,system:T,color:$},fe=m.useRef(me);fe.current=me;const oe=m.useMemo(()=>Qh(e,k),[k,e]),pe=oe.length>0,se=j||"__default",ve=pe,be=m.useMemo(()=>j&&!oe.includes(j)?[j,...oe]:oe,[j,oe]);m.useEffect(()=>{if(!g||!c)return;J.current=null;const he=Mi(c.model),Pe=c.name||"",Re=c.scope||"user",ce=c.description||"",je=c.mode||"subagent",de=he?`${he.providerID}/${he.modelID}`:"",ie=he?.variant||"",xe=c.steps??void 0,Se=c.temperature??void 0,Le=c.top_p??void 0,Ue=c.system||"",Ye="";W.current={},B(null),x(Pe),S(Re),A(ce),N(je),P(de),C(ie),F(xe),K(Se),M(Le),R(Ue),z(Ye),ee.current={draftName:Pe,draftScope:Re,description:ce,mode:je,model:de,variant:ie,steps:xe,temperature:Se,topP:Le,system:Ue,color:Ye}},[c,g]),m.useEffect(()=>{if(g||!a)return;let he=!1;return(async()=>{const Pe=await r(a,l);if(he||le.current!==G||!Pe)return;const Re=Pe.config;W.current=Re;const ce=Mi(Re.model),je=Re.request?.body,de={draftName:"",draftScope:"user",description:Re.description||"",mode:Re.mode||p?.mode||"subagent",model:ce?`${ce.providerID}/${ce.modelID}`:"",variant:ce?.variant||"",steps:Re.steps??void 0,temperature:je?.temperature,topP:je?.top_p,system:Re.system||"",color:Yh(Re.color)},ie=ee.current,xe=fe.current,Se=ie!==null&&(xe.description!==ie.description||xe.mode!==ie.mode||xe.model!==ie.model||xe.variant!==ie.variant||xe.steps!==ie.steps||xe.temperature!==ie.temperature||xe.topP!==ie.topP||xe.system!==ie.system||xe.color!==ie.color);B({legacy:Pe.legacy===!0,path:Pe.path,source:Pe.source}),!(J.current===G&&Se)&&(J.current=G,A(de.description),N(de.mode),P(de.model),C(de.variant),F(de.steps),K(de.temperature),M(de.topP),R(de.system),z(de.color),ee.current=de)})(),()=>{he=!0}},[r,g,p,a,l,G]);const ne=m.useCallback(he=>{const Pe=Un(k.trim()),Re=Pe?Yd({providerID:Pe.providerId,modelID:Pe.modelId,variant:j.trim()||void 0}):null,ce=W.current.request,je={...ce?.body};O===void 0?delete je.temperature:je.temperature=O,D===void 0?delete je.top_p:je.top_p=D;const de=ce?.headers,ie={};de&&Object.keys(de).length>0&&(ie.headers=de),Object.keys(je).length>0&&(ie.body=je);const xe=v.trim(),Se=T.trim(),Le={name:he,mode:I,model:Re,steps:E??null,system:Se||(g?void 0:null),request:Object.keys(ie).length>0?ie:null};return xe&&(Le.description=xe),$!==(ee.current?.color??"")&&(Le.color=$||null),g&&w&&(Le.scope=w),g&&c?.hidden!==void 0&&(Le.hidden=c.hidden),g&&c?.permissions?.length&&(Le.permissions=c.permissions),Le},[c,$,v,w,g,I,k,E,T,O,D,j]),we=m.useCallback(async()=>{const he=ee.current,Pe=a?.trim();if(g||!he||!Pe)return Ls;const Re=Y.current?await Y.current():Ls;if(v===he.description&&I===he.mode&&k===he.model&&j===he.variant&&E===he.steps&&O===he.temperature&&D===he.topP&&T===he.system&&$===he.color||!Re.ok)return Re;const je=ne(Pe);return(await o(Pe,je,l)).ok?(le.current!==G||(W.current={...W.current,model:je.model,system:je.system??void 0,steps:je.steps,request:je.request??void 0},ee.current={...he,description:v,mode:I,model:k,variant:j,steps:E,temperature:O,topP:D,system:T,color:$}),In):gs(t("settings.agents.page.toast.updateFailed"))},[ne,$,v,g,I,k,a,G,l,E,T,t,O,D,o,j]),Ne=ci(we),{requestSave:Ie}=Ne,Ce=async()=>{const he=b.trim().replace(/\s+/g,"-");if(!he){q.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(f.some(Pe=>Pe.name===he)){q.error(t("settings.agents.sidebar.toast.agentExists"));return}V(!0);try{(await i(ne(he),l)).ok?(u(null),q.success(t("settings.agents.page.toast.created"))):q.error(t("settings.agents.page.toast.createFailed"))}catch(Pe){console.error("Error creating agent:",Pe);const Re=Pe instanceof Error&&Pe.message?Pe.message:t("settings.agents.page.toast.saveUnexpectedError");q.error(Re)}finally{V(!1)}},Me=()=>{u(null),d(null)};return a?s.jsxs(qt,{title:g?t("settings.agents.page.title.new"):a,description:t(g?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit"),onBlurCapture:Ne.onBlurCapture,children:[!g&&L&&s.jsx(bl,{legacy:L.legacy,path:L.path}),!g&&L?.source==="none"&&s.jsxs("p",{className:`mb-4 flex items-start gap-1.5 ${_t}`,children:[s.jsx(te,{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($e,{title:t("settings.agents.page.section.identityRole"),divider:!1,contentClassName:"space-y-3",children:[g&&s.jsxs(st,{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:b,onChange:he=>x(he.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Pt,{value:w,onValueChange:he=>S(he),children:[s.jsx(Ct,{className:"w-fit min-w-[100px]",children:s.jsx(Kt,{placeholder:t("settings.agents.page.field.scopePlaceholder")})}),s.jsxs(It,{align:"end",children:[s.jsx(bt,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(te,{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(te,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsx(St,{label:t("settings.common.field.description"),controlClassName:"w-full max-w-none",children:s.jsx(Cs,{value:v,onChange:he=>A(he.target.value),placeholder:h||t("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})}),s.jsx(St,{settingsItem:"agents.mode",label:t("settings.agents.page.field.mode"),info:t("settings.agents.page.field.modeTooltip"),children:s.jsx(Xt,{"aria-label":t("settings.agents.page.field.mode"),value:I,onChange:he=>{N(he),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(St,{settingsItem:"agents.color",label:t("settings.agents.page.field.color"),info:t("settings.agents.page.field.colorTooltip"),children:s.jsx(vf,{value:$,labels:{empty:t("settings.agents.page.field.colorAutomatic"),swatch:he=>t("settings.agents.page.field.colorSwatchAria",{color:he}),custom:t("settings.agents.page.field.colorCustomAria"),hex:t("settings.agents.page.field.colorHexAria")},onChange:he=>{z(he),Ie()}})})]}),s.jsxs($e,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx(st,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(Fa,{providerId:Un(k)?.providerId??"",modelId:Un(k)?.modelId??"",onChange:(he,Pe)=>{P(he&&Pe?`${he}/${Pe}`:""),C(""),Ie()},className:an})}),s.jsx(st,{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:ve?s.jsxs(Pt,{value:se,onValueChange:he=>{C(he==="__default"?"":he),Ie()},children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:he=>he==="__default"?t("chat.modelControls.default"):he})}),s.jsxs(It,{children:[s.jsx(bt,{value:"__default",children:t("chat.modelControls.default")}),be.map(he=>s.jsx(bt,{value:he,children:he},he))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(qe,{value:j,onChange:he=>C(he.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!k&&!j,className:"h-8 w-40 rounded-md px-3"}),j&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{C(""),Ie()},className:Yt,"aria-label":t("settings.common.actions.clear"),title:t("settings.common.actions.clear"),children:s.jsx(te,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsxs(st,{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(ds,{value:O,fallbackValue:.7,onValueChange:K,onClear:()=>{K(void 0),Ie()},min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:us}),O!==void 0&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{K(void 0),Ie()},className:Yt,"aria-label":t("settings.agents.page.field.clearTemperatureAria"),title:t("settings.common.actions.clear"),children:s.jsx(te,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(st,{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(ds,{value:D,fallbackValue:.9,onValueChange:M,onClear:()=>{M(void 0),Ie()},min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:us}),D!==void 0&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{M(void 0),Ie()},className:Yt,"aria-label":t("settings.agents.page.field.clearTopPAria"),title:t("settings.common.actions.clear"),children:s.jsx(te,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(st,{settingsItem:"agents.steps",label:t("settings.agents.page.field.steps"),info:t("settings.agents.page.field.stepsTooltip"),children:[s.jsx(ds,{value:E,fallbackValue:20,onValueChange:F,onClear:()=>{F(void 0),Ie()},min:1,max:1e3,step:1,inputMode:"numeric",placeholder:"—",emptyLabel:"—",className:us}),E!==void 0&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{F(void 0),Ie()},className:Yt,"aria-label":t("settings.agents.page.field.clearStepsAria"),title:t("settings.common.actions.clear"),children:s.jsx(te,{name:"close",className:"h-3.5 w-3.5"})})]})]}),s.jsx($e,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx(Cs,{value:T,onChange:he=>R(he.target.value),placeholder:y||t("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent"})}),!g&&p&&s.jsx(Bh,{agent:p,registerSave:ae,requestSave:Ie}),g&&s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[s.jsx(H,{onClick:()=>{Ce()},disabled:Q||!b.trim(),size:"xs",className:"!font-normal",children:t(Q?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(H,{variant:"ghost",onClick:Me,disabled:Q,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(te,{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 Xh(t,e){return t.kind==="file"?t.content:e??""}const rc=as({content:wt(),exists:Ji(),path:wt().min(1).optional()}),eb=async(t,e)=>{const a=await t.json().catch(()=>null);return typeof a?.error=="string"&&a.error.trim()?a.error:e},tb=t=>t.length>0&&!t.endsWith(`
2
+ import{R as m,j as s,f as De,r as Ke}from"./vendor-react-BUCujlKS.js";import{u as Ee,B as H,I as te,cy as Ks,aF as Zs,ad as jm,z as va,A as q,ac as km,hU as wm,aC as $e,hV as Vt,a2 as Ed,aA as Ai,a5 as on,aG as za,c3 as zo,N as ze,be as Sm,ce as tr,cg as Nm,ca as Kt,cb as Ct,c4 as bt,cc as It,cd as Pt,y as qe,hW as Cn,hX as Md,hY as Cm,cL as Co,hZ as Al,hl as Fi,h_ as Im,h$ as Ti,i0 as Wn,n as Os,t as Tt,q as Et,D as Rt,l as Ot,F as Ft,o as Wt,i1 as tl,aT as ya,aU as fa,gH as zi,gJ as Ui,aS as ja,aR as ka,gN as Bi,gO as Vi,hr as $n,hq as gn,c1 as ts,c7 as Xt,hs as sl,fi as _t,a1 as ft,i2 as st,cI as St,cM as Cs,cJ as Fa,i3 as an,ev as Es,i4 as Yt,cQ as ds,i5 as us,i6 as Dd,i7 as Pm,i8 as ct,i9 as Rd,ia as Am,ib as Tm,ic as Li,id as Em,dg as Pn,ie as rn,ig as ti,hR as Js,ih as Qa,ii as Od,ij as nl,cK as al,ht as La,ik as Mr,L as wa,il as Tl,im as Mm,cE as Uo,io as El,fm as $a,hQ as Lt,R as il,ip as ol,iq as Ma,ir as Fd,hS as Nn,is as Dm,C as si,x as Bo,aK as Ml,bU as Rm,aW as Om,P as Fm,cS as Lm,cT as Km,cU as _m,eo as Ld,b7 as oi,eV as Ki,it as Kd,iu as $m,iv as zm,c6 as Um,iw as Bm,al as Hi,c9 as ln,ix as Bt,iy as _d,iz as Vm,iA as Ln,fo as Ts,iB as Vo,iC as wn,iD as Io,iE as Hm,iF as $d,iG as qm,gW as ls,iH as Po,du as zd,dt as Wm,gU as Gm,gV as Jm,iI as Qm,iJ as Ym,gX as Zm,iK as Xm,iL as ep,iM as Dl,c5 as Ud,iN as tp,iO as sr,iP as Rl,iQ as sp,iR as np,iS as ap,iT as ip,iU as Ao,iV as bs,fn as ni,b9 as Fs,ba as Ho,iW as op,iX as Bd,fe as rp,fk as lp,ga as cp,iY as dp,iZ as nr,i_ as Vd,i$ as rl,j0 as ll,j1 as up,j2 as mp,j3 as pp,j4 as gp,j5 as fp,j6 as hp,j7 as bp,j8 as xp,bl as Ps,hT as nn,bm as cl,hG as Hd,j9 as Ws,ja as qd,cf as Va,jb as vp,jc as yp,jd as ai,dq as jp,je as Ei,jf as ma,jg as Wd,jh as kp,ji as wp,jj as Sp,jk as Vs,jl as As,jm as Ta,jn as Kn,jo as Ol,jp as jo,jq as Np,aa as Cp,jr as Gd,js as Da,jt as Ip,ju as Pp,k as dl,jv as Ap,db as Tp,az as Ep,ay as Mp,br as Dp,ch as Rp,as as Op,av as Fp,jw as Lp,b0 as Kp,hz as _p,jx as _i,jy as fi,jz as Fl,jA as Fn,jB as ga,jC as $p,jD as zp,jE as Up,jF as Bp,jG as ar,jH as Ll,jI as Vp,jJ as Hp,jK as qp,jL as Wp,jM as Gp,jN as Kl,jO as hi,jP as Jp,jQ as ul,jR as Qp,G as Yp,aO as _l,cH as Zp,jS as Xp,jT as ir,f as zn,h as Ka,jU as $l,jV as eg,jW as tg,jX as sg,jY as qo,jZ as ng,am as Hn,j_ as ag,j$ as ig,k0 as og,f3 as rg,k1 as Wo,k2 as _n,k3 as lg,k4 as cg,an as dg,ap as Jd,dh as ug,aV as Ia,V as mg,W as pg,di as gg}from"./useAppFontEffects-Dm6zEvrf.js";import{k as $t,bk as Qd,u as re,l as os,bE as Mi,bF as Un,bG as Yd,bH as fg,aU as jt,aR as fn,t as Qs,bI as hg,a5 as Zt,a$ as bg,ax as is,b4 as ri,aL as or,aO as zl,aM as Ul,aV as bi,bt as xg,bJ as vg,bq as yg,aW as Ea,bK as jg,bL as Bl,aN as kg,bM as wg,bN as Sg,bl as Vl,b3 as qi,bO as Ng,bP as Cg,bQ as Zd,bR as Mt,bS as Ig,ap as Pg,aq as Ag,bT as ml,a_ as Tg,ae as Xd,bU as eu,b2 as tu,bz as _a,bV as su,bW as Eg,bX as Mg,aT as pl,bY as Dg,a7 as Go,bv as To,aE as Rg,ay as Di,bZ as Og,b_ as Ha,b$ as Hl,c0 as ql,c1 as Wl,c2 as Gl,c3 as Jl,bi as Fg,y as nu,c4 as Wi,c5 as Lg,c6 as Ql,c7 as Kg,c8 as _g,r as Dr,c9 as $g,ca as Yl,cb as zg,b as Ug,cc as Bg,cd as Vg,ce as Hg,cf as qg,cg as Wg,aP as au,ch as iu,ci as Gg,cj as Rr,ck as Jg,cl as Qg,cm as Yg,cn as Zg,co as ou,cp as Xg,cq as ef,cr as tf,cs as Or,ct as Zl,cu as sf,cv as Xl,cw as oo,cx as nf,cy as af,cz as of,bD as rf,by as lf,b8 as cf,cA as df,cB as uf,cC as mf,cD as pf}from"./katex.min-F4TD1ekM.js";import{u as _s,c as Jo}from"./vendor-zustand-BAGL70zf.js";import{ac as gf,aR as ff,aS as rr,aT as hf,aU as bf,aV as xf,aW as qt,aX as vf,aY as li,aZ as js,a_ as Eo,a$ as qn,b0 as ii,b1 as Qo,b2 as Gi,b3 as $i,h as ha,f as ba,g as xa,R as Ra,b4 as yf,b5 as Is,b6 as jf,b7 as ru,b8 as kf,b9 as lu,U as wf,ba as Sf,bb as Nf,bc as Cf,bd as If,be as Pf,bf as Ga,bg as Af,bh as Fr,A as Tf,B as Ef,bi as Mf}from"./runtimeEndpointReset-lg1O2gVX.js";import{o as as,s as wt,b as Ji,l as Df,a as Ys,r as Bn,u as Lr,n as Mo,_ as cu,c as Kr}from"./vendor-zod-DDir2TeQ.js";import{n as Rf,M as du,r as Of,a as Ff,b as Lf,c as Kf,d as _f,P as $f,f as zf,e as Uf,g as Bf,h as _r,u as uu,i as mu,s as pu,j as Vf,k as Hf}from"./install-FletzeYD.js";import{s as qf,c as Wf}from"./vendor-yaml-CE-D_49-.js";import{c as ec,C as tc,P as Gf,p as Jf}from"./flexokiTheme-PoX6Vqyn.js";import{s as Qf}from"./shikiHighlight-DBj_a_TN.js";import{getResolvedShikiTheme as Yf}from"./appThemeRegistry-BWap7OfW.js";import{E as sc}from"./vendor-codemirror-view-B66jUSmE.js";import{Q as gu}from"./vendor-qrcode-DTJ12-WC.js";import{toast as Ya}from"./vendor-sonner-DFyL3AvE.js";import{s as Zf}from"./vendor-strip-json-comments-5dJlOkP1.js";import{h as Xf,P as eh,e as th,f as sh,g as nh}from"./vendor-base-ui-CPKyhvxM.js";import{u as ah}from"./useCallableModelProviders-BK3j8Sde.js";import{r as fu}from"./restartOpenCode-D8ExMl55.js";import{S as gl}from"./SpaceRow-CQp4PkPJ.js";import{_ as ih}from"./vendor-vite-runtime-DD1OZmLC.js";const nc=()=>{const{t}=Ee(),[e,a]=m.useState(null);m.useEffect(()=>{let i=!1;const o=typeof AbortController<"u"?new AbortController:void 0;return(async()=>{try{const c=await $t("/api/system/info",{signal:o?.signal,headers:{Accept:"application/json"}});if(!c.ok)return;const u=await c.json().catch(()=>null);if(!u||i)return;const d=typeof u.port=="number"&&Number.isFinite(u.port)&&u.port>0?u.port:null,l=typeof u.tunnelUrl=="string"&&u.tunnelUrl.trim().length>0?u.tunnelUrl.trim():null;a({port:d,tunnelUrl:l})}catch{}})(),()=>{i=!0,o?.abort()}},[]);const n=[];return e?.port!==null&&e?.port!==void 0&&n.push({key:"application",label:t("settings.openchamber.about.field.applicationUrl"),url:`http://localhost:${e.port}/`}),e?.tunnelUrl&&n.push({key:"tunnel",label:t("settings.openchamber.about.field.tunnelUrl"),url:e.tunnelUrl}),n.length===0?null:s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.map(i=>s.jsxs(H,{type:"button",variant:"outline",size:"sm",title:i.label,className:"max-w-full gap-1.5 px-2.5",onClick:()=>{Ks(i.url)},children:[s.jsx(te,{name:"external-link",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"max-w-64 truncate font-mono typography-micro",children:i.url})]},i.key))})},ac="https://github.com/openchamber/openchamber",oh="https://discord.gg/ZYRSdnwwKA",ic="https://x.com/openchamber_dev",rh=800,lh={info:null,checking:!1,available:!1,error:null};function ch(t){const e=De.c(5),[a,n]=m.useState(lh);let i;e[0]!==t?(i=async()=>{if(t){n(dh);try{const c=await hf();n({info:c,checking:!1,available:c.available,error:null})}catch(c){const u=c;n({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 r;return e[2]!==o||e[3]!==a?(r={...a,check:o},e[2]=o,e[3]=a,e[4]=r):r=e[4],r}function dh(t){return{...t,checking:!0,error:null}}function uh(t){const e=De.c(11),[a,n]=m.useState(null);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={kind:"idle"},e[0]=i):i=e[0];const[o,r]=m.useState(i);let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=async()=>{try{const b=await bf();return n(b),b}catch{return null}},e[1]=c):c=e[1];const u=c;let d,l;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{u()},l=[u],e[2]=d,e[3]=l):(d=e[2],l=e[3]),m.useEffect(d,l);let f;e[4]!==t?(f=async()=>{r({kind:"upgrading"});try{const b=await xf(t);r({kind:"installed",version:b})}catch(b){const x=b;r({kind:"failed",error:x instanceof Error?x.message:t})}},e[4]=t,e[5]=f):f=e[5];const p=f;let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=async b=>{await b().catch(mh);const x=await u();x?.currentVersion&&r(w=>w.kind!=="installed"||w.version&&w.version.replace(/^v/,"")!==x.currentVersion?w:{kind:"idle"})},e[6]=g):g=e[6];const h=g;let y;return e[7]!==o||e[8]!==a||e[9]!==p?(y={status:a,phase:o,refresh:u,upgrade:p,reloadAfterUpgrade:h},e[7]=o,e[8]=a,e[9]=p,e[10]=y):y=e[10],y}function mh(){}function ph(t){const[e,a]=m.useState(null);return m.useEffect(()=>{if(!t)return;let n=!1;return ih(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=>{n||a(i.version.trim()||null)}).catch(()=>{}),()=>{n=!0}},[t]),e}const gh=({initialUpdateDialogOpen:t=!1})=>{const{t:e}=Ee(),[a,n]=m.useState(t),[i,o]=m.useState(!1),[r,c]=m.useState(null),u=gf(_s(G=>({info:G.info,checking:G.checking,available:G.available,error:G.error,downloading:G.downloading,downloaded:G.downloaded,installing:G.installing,progress:G.progress,runtimeType:G.runtimeType,checkForUpdates:G.checkForUpdates,downloadUpdate:G.downloadUpdate,restartToUpdate:G.restartToUpdate}))),{isMobile:d}=Zs(),l=m.useMemo(()=>Qd(),[]),f=ff(),p=ch(l||f),g=f?p:null,h=p.check;m.useEffect(()=>{f&&h()},[f,h]);const[y,b]=m.useState(!1),[x,w]=m.useState(null);m.useEffect(()=>{if(!f)return;let G=!1;return jm().then(le=>{G||w(le)}),()=>{G=!0}},[f]);const S=ph(l),v=l?{info:p.info,checking:p.checking,available:p.available,error:p.error,checkForUpdates:p.check,runtimeType:"web"}:{info:u.info,checking:u.checking,available:u.available,error:u.error,checkForUpdates:u.checkForUpdates,runtimeType:u.runtimeType},A=r||v.info?.currentVersion||"unknown",I=x||u.info?.currentVersion||"unknown",N=r||g?.info?.currentVersion||"unknown",k=uh(e("opencodeUpdate.toast.failed.description")),P=k.status?.currentVersion??null,j=k.phase.kind==="installed"?null:k.status?.availableVersion??null,[C,E]=m.useState(!1),F=G=>{const le=G?.version||"";return G?.packageManager==="electron"?e("settings.openchamber.about.actions.updateDesktopToVersion",{version:le}):e("settings.openchamber.about.actions.updateServerToVersion",{version:le})},O=(()=>{const G=v.info?.version||"";return l?F(v.info):f?e("settings.openchamber.about.actions.updateAppToVersion",{version:G}):e("settings.openchamber.about.actions.updateOpenChamberToVersion",{version:G})})(),K=G=>!!G?.installBlocked,D=v.available&&K(v.info),M=!!(g?.available&&K(g.info)),T=()=>{v.checkForUpdates(),g&&g.check(),k.refresh()},R=async G=>{(await Ai(G)).ok&&(E(!0),setTimeout(()=>E(!1),2e3))},$=()=>{k.reloadAfterUpgrade(async()=>{await Ed({message:e("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]})})},z=G=>{if(G?.installBlocked==="desktop-host")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("updateDialog.desktopHostInstall",{version:G.version||""})});if(G?.installBlocked==="manual-install")return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.manualInstallUpdate",{version:G.version||""})});const le=G?.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:G?.version||""})}),s.jsxs("div",{className:"flex items-center gap-2 oc-tile-inset rounded-md p-1 ps-3",children:[s.jsx("code",{className:"flex-1 overflow-x-auto whitespace-nowrap font-mono text-sm text-foreground",children:le}),s.jsx(H,{type:"button",variant:"ghost",size:"icon",onClick:()=>{R(le)},"aria-label":e(C?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:s.jsx(te,{name:C?"check":"clipboard",className:"size-4"})})]})]})},Q=D?z(v.info):null,V=!g?.available||g.checking?null:M?z(g.info):s.jsxs(H,{type:"button",size:"sm",variant:"outline",onClick:()=>b(!0),children:[s.jsx(te,{name:"download",className:"size-4"}),F(g.info)]}),L=g?s.jsx(rr,{open:y,onOpenChange:b,info:g.info,downloading:!1,downloaded:!1,progress:null,error:g.error,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"}):null,B=(()=>{const{phase:G}=k;if(G.kind==="installed")return s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:G.version?e("settings.openchamber.about.openCode.installedVersion",{version:G.version}):e("settings.openchamber.about.openCode.installed")}),s.jsx(H,{type:"button",size:"sm",variant:"outline",onClick:$,children:e("opencodeUpdate.toast.actions.reload")})]});if(!j)return null;if(!k.status?.supported)return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.openCode.manualUpdate",{version:j})});const le=G.kind==="upgrading";return s.jsxs("div",{className:"space-y-2",children:[s.jsxs(H,{type:"button",size:"sm",variant:"outline",onClick:()=>{k.upgrade()},disabled:le,children:[le?s.jsx(va,{className:"size-4"}):s.jsx(te,{name:"download",className:"size-4"}),le?e("opencodeUpdate.toast.upgrading.title"):e("settings.openchamber.about.actions.updateOpenCodeToVersion",{version:j})]}),G.kind==="failed"&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:G.error})]})})();m.useEffect(()=>{let G=!1;return(async()=>{try{const J=await $t("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!J.ok)return;const me=await J.json().catch(()=>null),fe=typeof me?.openchamberVersion=="string"&&me.openchamberVersion.trim().length>0?me.openchamberVersion.trim():null;G||c(fe)}catch{G||c(null)}})(),()=>{G=!0}},[]);const W=g?.checking??!1,Y=g?.available??!1,ae=m.useRef(!1);m.useEffect(()=>{if(v.checking)o(!0),ae.current=!0;else if(i){const G=setTimeout(()=>{o(!1);const le=W||Y;ae.current&&!v.available&&!v.error&&!le&&(q.success(e(l?"settings.openchamber.about.toast.serverLatestVersion":"settings.openchamber.about.toast.latestVersion")),ae.current=!1)},rh);return()=>clearTimeout(G)}},[e,l,v.checking,i,v.available,v.error,W,Y]);const ee=v.checking||i;return d?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(km,{width:72,height:72}),s.jsx("h2",{className:`mt-4 ${wm}`,children:"OpenChamber"}),s.jsx("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:l?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:A})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:P||e("settings.openchamber.about.state.unknown")})}),S&&s.jsx("p",{children:e("settings.openchamber.about.native.appVersion",{version:S})})]}):f?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.appVersionLabel",{version:I})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:N})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:P||e("settings.openchamber.about.state.unknown")})})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:A})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:P||e("settings.openchamber.about.state.unknown")})})]})}),s.jsx(nc,{})]}),s.jsxs("div",{className:"flex justify-center",children:[!v.available&&!v.error&&s.jsxs(H,{type:"button",variant:"outline",size:"sm",onClick:T,disabled:ee,className:"w-auto justify-center gap-2",children:[ee?s.jsx(te,{name:"loader",className:"size-4 animate-spin"}):s.jsx(te,{name:"refresh",className:"size-4"}),e(ee?"settings.openchamber.about.state.checking":l?"settings.openchamber.about.actions.checkServerForUpdates":"settings.openchamber.about.actions.checkForUpdates")]}),!ee&&v.available&&!D&&s.jsxs(H,{type:"button",variant:"default",size:"sm",onClick:()=>n(!0),className:"w-auto justify-center gap-2",children:[s.jsx(te,{name:"download",className:"size-4"}),O]})]}),Q,V&&s.jsx("div",{className:"flex justify-center text-center",children:V}),B&&s.jsx("div",{className:"flex justify-center text-center",children:B}),[v.error,g?.error].filter(Boolean).map(G=>s.jsx("p",{className:"rounded-xl bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:G},G)),s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsxs("div",{className:"flex items-center justify-center gap-5",children:[s.jsxs("a",{href:ac,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx(te,{name:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:oh,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(te,{name:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:ic,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(te,{name:"twitter-xfill",className:"size-5"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"text-center typography-ui text-muted-foreground/60",children:e("aboutDialog.footerNote")}),s.jsx(rr,{open:a,onOpenChange:n,info:v.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:v.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:v.runtimeType}),L]}):s.jsxs($e,{divider:!1,children:[s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center justify-between gap-4 px-4 py-3 border-b border-border/40",children:[f?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Vt,children:e("settings.openchamber.about.field.appVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:I})]}),s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Vt,children:e("settings.openchamber.about.field.serverVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:N})]})]}):s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Vt,children:e("settings.openchamber.about.field.version")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:A})]}),s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Vt,children:e("settings.openchamber.about.field.openCodeVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:P||e("settings.openchamber.about.state.unknown")})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[v.checking&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(te,{name:"loader",className:"h-4 w-4 animate-spin"}),s.jsx("span",{className:"typography-meta",children:e("settings.openchamber.about.state.checking")})]}),!v.checking&&v.available&&!D&&s.jsxs(H,{size:"sm",variant:"default",onClick:()=>n(!0),children:[s.jsx(te,{name:"download",className:"h-4 w-4 me-1"}),O]}),!v.checking&&!v.available&&!v.error&&s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")}),s.jsx(H,{size:"sm",variant:"outline",onClick:T,disabled:v.checking,children:e("settings.openchamber.about.actions.checkForUpdates")})]})]}),Q&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:Q}),V&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:V}),B&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:B}),[v.error,g?.error].filter(Boolean).map(G=>s.jsx("div",{className:"px-3 py-2 border-b border-border/40",children:s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:G})},G)),s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-4 py-3 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsx("span",{className:Vt,children:e("settings.openchamber.about.field.instanceUrls")}),s.jsx(nc,{})]}),s.jsxs("div",{className:"flex items-center gap-4 px-4 py-4",children:[s.jsxs("a",{href:ac,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx(te,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:ic,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx(te,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]})]}),s.jsx(rr,{open:a,onOpenChange:n,info:v.info,downloading:u.downloading,downloaded:u.downloaded,installing:u.installing,progress:u.progress,error:v.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:v.runtimeType}),L]})},fh=(t,e,a)=>t&&e.some(i=>i.path===t)?t:(e.find(i=>i.id===a)??e[0])?.path??null,Hs=()=>{const t=De.c(4),e=re(hh),a=on(bh),n=on(xh);let i;return t[0]!==n||t[1]!==a||t[2]!==e?(i=fh(e,a,n),t[0]=n,t[1]=a,t[2]=e,t[3]=i):i=t[3],i};function hh(t){return t.settingsProjectPath}function bh(t){return t.projects}function xh(t){return t.activeProjectId}const $r=Jo(t=>({tab:"general",setTab:e=>t({tab:e})})),vh=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"]]),yh=t=>vh.get(t)??null,zr=Jo(t=>({tab:"messages",setTab:e=>t({tab:e})})),jh=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.persist-drafts","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"]]),kh=t=>jh.get(t)??null,Qi=t=>{const e=De.c(73),{className:a}=t,{t:n}=Ee(),{currentTheme:i}=za(),o=re(wh),[r,c]=m.useState(!1),u=zo(on(Sh)),d=Hs(),l=re(Nh),f=os();let p;e[0]!==d||e[1]!==u?(p=u.find(C=>C.path===d)??u[0]??null,e[0]=d,e[1]=u,e[2]=p):p=e[2];const g=p;if(f||!g)return null;let h;e[3]!==l||e[4]!==u?(h=C=>{const E=u.find(F=>F.id===C);E&&l(E.path)},e[3]=l,e[4]=u,e[5]=h):h=e[5];const y=h;if(o){let C;e[6]!==a?(C=ze(a),e[6]=a,e[7]=C):C=e[7];let E;e[8]!==n?(E=n("settings.shared.projectSelector.switchProjectAria"),e[8]=n,e[9]=E):E=e[9];let F;e[10]!==n?(F=n("settings.shared.projectSelector.switchProjectTitle"),e[10]=n,e[11]=F):F=e[11];let O,K;e[12]===Symbol.for("react.memo_cache_sentinel")?(O=()=>c(!0),K=ze(Sm({size:"touch"}),"w-full min-w-0"),e[12]=O,e[13]=K):(O=e[12],K=e[13]);let D;e[14]!==g||e[15]!==i?(D=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:s.jsx(tr,{project:g,theme:i})}),e[14]=g,e[15]=i,e[16]=D):D=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx(te,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[17]=M):M=e[17];let T;e[18]!==r||e[19]!==E||e[20]!==F||e[21]!==K||e[22]!==D?(T=s.jsxs("button",{type:"button","aria-label":E,title:F,"aria-haspopup":"dialog","aria-expanded":r,onClick:O,className:K,children:[D,M]}),e[18]=r,e[19]=E,e[20]=F,e[21]=K,e[22]=D,e[23]=T):T=e[23];let R;e[24]!==T||e[25]!==C?(R=s.jsx("div",{className:C,children:T}),e[24]=T,e[25]=C,e[26]=R):R=e[26];let $;e[27]===Symbol.for("react.memo_cache_sentinel")?($=()=>c(!1),e[27]=$):$=e[27];const z=g.id;let Q;e[28]!==n?(Q=n("settings.shared.projectSelector.sheetTitle"),e[28]=n,e[29]=Q):Q=e[29];let V;e[30]!==n?(V=n("settings.shared.projectSelector.searchPlaceholder"),e[30]=n,e[31]=V):V=e[31];let L;e[32]!==g.id||e[33]!==i||e[34]!==y||e[35]!==r||e[36]!==u||e[37]!==Q||e[38]!==V?(L=s.jsx(Nm,{open:r,onClose:$,projects:u,selectedProjectId:z,onSelectProject:y,theme:i,title:Q,searchPlaceholder:V}),e[32]=g.id,e[33]=i,e[34]=y,e[35]=r,e[36]=u,e[37]=Q,e[38]=V,e[39]=L):L=e[39];let B;return e[40]!==R||e[41]!==L?(B=s.jsxs(s.Fragment,{children:[R,L]}),e[40]=R,e[41]=L,e[42]=B):B=e[42],B}let b;e[43]!==a?(b=ze(a),e[43]=a,e[44]=b):b=e[44];const x=g.id;let w;e[45]!==y?(w=C=>{C&&y(C)},e[45]=y,e[46]=w):w=e[46];let S;e[47]!==n?(S=n("settings.shared.projectSelector.switchProjectAria"),e[47]=n,e[48]=S):S=e[48];let v;e[49]!==n?(v=n("settings.shared.projectSelector.switchProjectTitle"),e[49]=n,e[50]=v):v=e[50];let A;e[51]!==g||e[52]!==i?(A=s.jsx(Kt,{children:s.jsx(tr,{project:g,theme:i})}),e[51]=g,e[52]=i,e[53]=A):A=e[53];let I;e[54]!==S||e[55]!==v||e[56]!==A?(I=s.jsx(Ct,{className:"w-full","aria-label":S,title:v,children:A}),e[54]=S,e[55]=v,e[56]=A,e[57]=I):I=e[57];let N;if(e[58]!==i||e[59]!==u){let C;e[61]!==i?(C=E=>s.jsx(bt,{value:E.id,className:"max-w-[24rem] truncate",children:s.jsx(tr,{project:E,theme:i})},E.id),e[61]=i,e[62]=C):C=e[62],N=u.map(C),e[58]=i,e[59]=u,e[60]=N}else N=e[60];let k;e[63]!==N?(k=s.jsx(It,{fitContent:!0,children:N}),e[63]=N,e[64]=k):k=e[64];let P;e[65]!==g.id||e[66]!==k||e[67]!==w||e[68]!==I?(P=s.jsxs(Pt,{value:x,onValueChange:w,children:[I,k]}),e[65]=g.id,e[66]=k,e[67]=w,e[68]=I,e[69]=P):P=e[69];let j;return e[70]!==P||e[71]!==b?(j=s.jsx("div",{className:b,children:P}),e[70]=P,e[71]=b,e[72]=j):j=e[72],j};function wh(t){return t.isMobile}function Sh(t){return t.projects}function Nh(t){return t.setSettingsProjectPath}const fl=t=>{const e=De.c(16),{value:a,onChange:n}=t,{t:i}=Ee();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(te,{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 r;e[1]!==n?(r=f=>n(f.target.value),e[1]=n,e[2]=r):r=e[2];let c;e[3]!==n||e[4]!==a?(c=f=>{f.key==="Escape"&&a&&(f.preventDefault(),f.stopPropagation(),n(""))},e[3]=n,e[4]=a,e[5]=c):c=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 l;return e[10]!==r||e[11]!==c||e[12]!==u||e[13]!==d||e[14]!==a?(l=s.jsxs("div",{className:"relative mt-3",children:[o,s.jsx(qe,{value:a,onChange:r,onKeyDown:c,placeholder:u,"aria-label":d,className:"h-8 ps-7 typography-meta"})]}),e[10]=r,e[11]=c,e[12]=u,e[13]=d,e[14]=a,e[15]=l):l=e[15],l},hl=t=>{const e=De.c(5),{query:a}=t,{t:n}=Ee();let i;e[0]!==a||e[1]!==n?(i=n("settings.common.sidebar.noMatches",{query:a.trim()}),e[0]=a,e[1]=n,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 Ch(t,e){return`opencode:sidebar-group:${t}:${e}`}const Ur=t=>{const e=De.c(33),{label:a,count:n,storageKey:i,defaultExpanded:o,children:r}=t,c=o===void 0?!0:o;let u;e[0]!==a||e[1]!==i?(u=Ch(i,a),e[0]=a,e[1]=i,e[2]=u):u=e[2];const d=u,l=m.useId();let f;e[3]!==c||e[4]!==d?(f=()=>{try{const C=localStorage.getItem(d);if(C!==null)return C==="true"}catch{}return c},e[3]=c,e[4]=d,e[5]=f):f=e[5];const[p,g]=Ke.useState(f);let h,y;e[6]!==p||e[7]!==d?(h=()=>{try{localStorage.setItem(d,String(p))}catch{}},y=[d,p],e[6]=p,e[7]=d,e[8]=h,e[9]=y):(h=e[8],y=e[9]),Ke.useEffect(h,y);let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=()=>g(Ih),e[10]=b):b=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=ze("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]=x):x=e[11];const w=!p&&"-rotate-90 rtl:rotate-90";let S;e[12]!==w?(S=ze("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",w),e[12]=w,e[13]=S):S=e[13];let v;e[14]!==S?(v=s.jsx(te,{name:"arrow-down-s",className:S}),e[14]=S,e[15]=v):v=e[15];let A;e[16]!==a?(A=s.jsx("span",{className:"flex-1 truncate",children:a}),e[16]=a,e[17]=A):A=e[17];let I;e[18]!==n?(I=s.jsx("span",{className:"ms-1 tabular-nums opacity-60",children:n}),e[18]=n,e[19]=I):I=e[19];let N;e[20]!==l||e[21]!==p||e[22]!==v||e[23]!==A||e[24]!==I?(N=s.jsxs("button",{type:"button",onClick:b,"aria-expanded":p,"aria-controls":l,className:x,children:[v,A,I]}),e[20]=l,e[21]=p,e[22]=v,e[23]=A,e[24]=I,e[25]=N):N=e[25];const k=!p;let P;e[26]!==r||e[27]!==l||e[28]!==k?(P=s.jsx("div",{id:l,hidden:k,className:"mt-0.5 space-y-0.5 ms-2 ps-3 border-s-2 border-[var(--interactive-border)]",children:r}),e[26]=r,e[27]=l,e[28]=k,e[29]=P):P=e[29];let j;return e[30]!==N||e[31]!==P?(j=s.jsxs("div",{children:[N,P]}),e[30]=N,e[31]=P,e[32]=j):j=e[32],j};function Ih(t){return!t}const Ph=({onItemSelect:t})=>{const{t:e}=Ee(),[a,n]=m.useState(""),[i,o]=m.useState(null),[r,c]=m.useState(""),[u,d]=m.useState(null),[l,f]=m.useState(!1),[p,g]=m.useState(null),{selectedAgentName:h,setSelectedAgent:y,setAgentDraft:b,createAgent:x,deleteAgent:w,loadAgents:S,loadDisabledAgents:v,updateAgent:A,fetchAgentEntity:I}=Cn(_s(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}))),N=Hs(),k=Cn(J=>Md(J,N)),P=Cn(J=>Cm(J,N)),[j,C]=m.useState(null);m.useEffect(()=>{S(N),v(N)},[S,v,N]);const E=k.filter(J=>Co(J.mode)&&!Al(J)).length,F=J=>!(Co(J.mode)&&!Al(J)&&E<=1),O=async(J,me)=>{C(J);try{await A(J,{disabled:me},N),me&&h===J&&y(null),q.success(me?e("settings.agents.sidebar.toast.agentDisabled",{name:J}):e("settings.agents.sidebar.toast.agentEnabled",{name:J}))}catch{q.error(e(me?"settings.agents.sidebar.toast.disableFailed":"settings.agents.sidebar.toast.enableFailed"))}finally{C(null)}},K=P.filter(J=>Fi([J.name,J.description],a)),D="bg-background",M=()=>{const J="new-agent";let me=J,fe=1;for(;k.some(oe=>oe.name===me);)me=`${J}-${fe}`,fe++;b({name:me,scope:"user"}),y(me),t?.()},T=async J=>{if(Ti(J)){q.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}d(J)},R=()=>{d(null)},$=async()=>{if(u){f(!0);try{(await w(u.name,u.scope,N)).ok?(q.success(e("settings.agents.sidebar.toast.agentDeleted",{name:u.name})),R()):q.error(e("settings.agents.sidebar.toast.deleteFailed"))}catch(J){const me=J instanceof Error?J.message:"",fe=/built-in|not deletable|not found/i.test(me);q.error(e(fe?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed"))}f(!1)}},z=async J=>{const me=J.name;let fe=1,oe=`${me}-copy`;for(;k.some(be=>be.name===oe);)fe++,oe=`${me}-copy-${fe}`;const pe=J,se=await I(J.name,N);if(!se){q.error(e("settings.agents.sidebar.toast.renameFailed"));return}const ve=se.config.request?.body;b({name:oe,scope:se.scope??pe.scope??"user",description:se.config.description??void 0,model:se.config.model??null,system:se.config.system??void 0,steps:se.config.steps??void 0,temperature:ve?.temperature,top_p:ve?.top_p,mode:se.config.mode??pe.mode,permissions:se.config.permissions??void 0,hidden:se.config.hidden}),y(oe),t?.()},Q=J=>{c(J.name),o(J)},V=async()=>{if(!i)return;const J=r.trim().replace(/\s+/g,"-");if(!J){q.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(J===i.name){o(null);return}if(k.some(pe=>pe.name===J)){q.error(e("settings.agents.sidebar.toast.agentExists"));return}const me=i,fe=await I(i.name,N);if(!fe){q.error(e("settings.agents.sidebar.toast.renameFailed"));return}(await x({...fe.config,name:J,scope:fe.scope??me.scope},N)).ok?(await w(i.name,me.scope,N)).ok?(q.success(e("settings.agents.sidebar.toast.agentRenamed",{name:J})),y(J)):q.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed")):q.error(e("settings.agents.sidebar.toast.renameFailed")),o(null)},L=J=>{switch(J){case"primary":return s.jsx(te,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return s.jsx(te,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return s.jsx(te,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},B=new Set(P.map(J=>J.name)),W=k.filter(J=>Im(J)&&!B.has(J.name)),Y=W.filter(J=>Fi([J.name,J.description],a)),ae=Y.filter(Ti),ee=Y.filter(J=>!Ti(J)),{groupedCustomAgents:G,ungroupedCustomAgents:le}=Ke.useMemo(()=>{const J={},me=[];for(const oe of ee){const pe=oe;pe.group?(J[pe.group]||(J[pe.group]=[]),J[pe.group].push(oe)):me.push(oe)}return{groupedCustomAgents:Object.keys(J).sort((oe,pe)=>oe.localeCompare(pe)).map(oe=>({name:oe,agents:J[oe]})),ungroupedCustomAgents:me}},[ee]);return s.jsxs("div",{className:ze("flex h-full flex-col",D),children:[s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[s.jsx("h2",{className:`${Wn} mb-3`,children:e("settings.agents.sidebar.title")}),s.jsx(Qi,{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:W.length})}),s.jsx(H,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:M,children:s.jsx(te,{name:"add",className:"h-3.5 w-3.5"})})]}),W.length>0?s.jsx(fl,{value:a,onChange:n}):null]}),s.jsxs(Os,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:[W.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(te,{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")})]}):Y.length===0?s.jsx(hl,{query:a}):s.jsxs(s.Fragment,{children:[ae.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")}),ae.map(J=>s.jsx(lr,{agent:J,isSelected:h===J.name,onSelect:()=>{y(J.name),t?.()},onDuplicate:()=>{z(J)},onDisable:F(J)?()=>{O(J.name,!0)}:void 0,getAgentModeIcon:L,isMenuOpen:p===J.name,onMenuOpenChange:me=>g(me?J.name:null)},J.name))]}),ee.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.custom")}),G.map(({name:J,agents:me})=>s.jsx(Ur,{label:J,count:me.length,storageKey:"agents",children:me.map(fe=>s.jsx(lr,{agent:fe,isSelected:h===fe.name,onSelect:()=>{y(fe.name),t?.()},onRename:()=>Q(fe),onDelete:()=>T(fe),onDuplicate:()=>{z(fe)},onDisable:F(fe)?()=>{O(fe.name,!0)}:void 0,getAgentModeIcon:L,isMenuOpen:p===fe.name,onMenuOpenChange:oe=>g(oe?fe.name:null)},fe.name))},J)),le.map(J=>s.jsx(lr,{agent:J,isSelected:h===J.name,onSelect:()=>{y(J.name),t?.()},onRename:()=>Q(J),onDelete:()=>T(J),onDuplicate:()=>{z(J)},onDisable:F(J)?()=>{O(J.name,!0)}:void 0,getAgentModeIcon:L,isMenuOpen:p===J.name,onMenuOpenChange:me=>g(me?J.name:null)},J.name))]})]}),K.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.disabled")}),K.map(J=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-1.5 py-1",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"typography-ui-label truncate text-muted-foreground",children:J.name}),J.description?s.jsx("div",{className:"typography-micro truncate leading-tight text-muted-foreground/60",children:J.description}):null]}),s.jsx(H,{size:"xs",variant:"outline",disabled:j===J.name,onClick:()=>{O(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(Tt,{open:u!==null,onOpenChange:J=>{!J&&!l&&R()},children:s.jsxs(Et,{className:"max-w-md",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:e("settings.agents.sidebar.dialog.deleteTitle")}),s.jsx(Ft,{children:e("settings.agents.sidebar.dialog.deleteDescription",{name:u?.name??""})})]}),s.jsxs(Wt,{children:[s.jsx(H,{size:"sm",variant:"ghost",onClick:R,disabled:l,children:e("settings.common.actions.cancel")}),s.jsx(H,{size:"sm",onClick:$,disabled:l,children:e("settings.common.actions.delete")})]})]})}),s.jsx(Tt,{open:i!==null,onOpenChange:J=>!J&&o(null),children:s.jsxs(Et,{children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:e("settings.agents.sidebar.renameDialog.title")}),s.jsx(Ft,{children:e("settings.agents.sidebar.renameDialog.description",{name:i?.name??""})})]}),s.jsx(qe,{value:r,onChange:J=>c(J.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:J=>{J.key==="Enter"&&V()}}),s.jsxs(Wt,{children:[s.jsx(H,{size:"sm",variant:"ghost",onClick:()=>o(null),children:e("settings.common.actions.cancel")}),s.jsx(H,{size:"sm",onClick:V,children:e("settings.common.actions.rename")})]})]})})]})},lr=t=>{const e=De.c(52),{agent:a,isSelected:n,onSelect:i,onDelete:o,onRename:r,onDuplicate:c,onDisable:u,getAgentModeIcon:d,isMenuOpen:l,onMenuOpenChange:f}=t,{t:p}=Ee(),g=a;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=tl(),e[0]=h):h=e[0];const y=h,[b,x]=m.useState(!1);let w;e[1]!==o||e[2]!==u||e[3]!==c||e[4]!==r||e[5]!==p?(w=Q=>s.jsxs(s.Fragment,{children:[r&&s.jsxs(Q,{onClick:V=>{V.stopPropagation(),r()},children:[s.jsx(te,{name:"edit",className:"h-4 w-4 me-px"}),p("settings.common.actions.rename")]}),s.jsxs(Q,{onClick:V=>{V.stopPropagation(),c()},children:[s.jsx(te,{name:"file-copy",className:"h-4 w-4 me-px"}),p("settings.common.actions.duplicate")]}),u&&s.jsxs(Q,{onClick:V=>{V.stopPropagation(),u()},children:[s.jsx(te,{name:"eye-off",className:"h-4 w-4 me-px"}),p("settings.agents.sidebar.actions.disable")]}),o&&s.jsxs(Q,{onClick:V=>{V.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[s.jsx(te,{name:"delete-bin",className:"h-4 w-4 me-px"}),p("settings.common.actions.delete")]})]}),e[1]=o,e[2]=u,e[3]=c,e[4]=r,e[5]=p,e[6]=w):w=e[6];const S=w,v=n?"bg-interactive-selection":"hover:bg-interactive-hover";let A;e[7]!==v?(A=ze("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",v),e[7]=v,e[8]=A):A=e[8];let I;e[9]===Symbol.for("react.memo_cache_sentinel")?(I=y?void 0:Q=>{Q.preventDefault(),x(!0)},e[9]=I):I=e[9];let N;e[10]!==A?(N=s.jsx("div",{className:A,onContextMenu:I}),e[10]=A,e[11]=N):N=e[11];let k;e[12]!==a.name?(k=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a.name}),e[12]=a.name,e[13]=k):k=e[13];let P;e[14]!==a.mode||e[15]!==d?(P=d(a.mode),e[14]=a.mode,e[15]=d,e[16]=P):P=e[16];let j;e[17]!==a||e[18]!==g.scope||e[19]!==p?(j=(g.scope||Ti(a))&&s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:Ti(a)?p("settings.agents.sidebar.badge.system"):g.scope}),e[17]=a,e[18]=g.scope,e[19]=p,e[20]=j):j=e[20];let C;e[21]!==k||e[22]!==P||e[23]!==j?(C=s.jsxs("div",{className:"flex items-center gap-1.5",children:[k,P,j]}),e[21]=k,e[22]=P,e[23]=j,e[24]=C):C=e[24];let E;e[25]!==a.description?(E=a.description&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a.description}),e[25]=a.description,e[26]=E):E=e[26];let F;e[27]!==i||e[28]!==C||e[29]!==E?(F=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,E]}),e[27]=i,e[28]=C,e[29]=E,e[30]=F):F=e[30];let O;e[31]!==f?(O=Q=>{Q&&x(!1),f(Q)},e[31]=f,e[32]=O):O=e[32];let K;e[33]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(ja,{asChild:!0,children:s.jsx(H,{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(te,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=K):K=e[33];let D;e[34]!==S?(D=s.jsx(ya,{align:"end",className:"w-fit min-w-20",children:S(fa)}),e[34]=S,e[35]=D):D=e[35];let M;e[36]!==l||e[37]!==O||e[38]!==D?(M=s.jsxs(ka,{open:l,onOpenChange:O,children:[K,D]}),e[36]=l,e[37]=O,e[38]=D,e[39]=M):M=e[39];let T;e[40]!==F||e[41]!==M?(T=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[F,M]}),e[40]=F,e[41]=M,e[42]=T):T=e[42];let R;e[43]!==T||e[44]!==N?(R=s.jsx(Bi,{render:N,children:T}),e[43]=T,e[44]=N,e[45]=R):R=e[45];let $;e[46]!==S?($=s.jsx(zi,{className:"w-fit min-w-20",children:S(Ui)}),e[46]=S,e[47]=$):$=e[47];let z;return e[48]!==b||e[49]!==R||e[50]!==$?(z=s.jsxs(Vi,{open:b,onOpenChange:x,children:[R,$]}),e[48]=b,e[49]=R,e[50]=$,e[51]=z):z=e[51],z},Ls={ok:!0,changed:!1},In={ok:!0,changed:!0},gs=t=>({ok:!1,reason:t}),Ah=t=>t instanceof HTMLElement?t.matches('input, textarea, [contenteditable="true"]'):!1,ci=t=>{const{t:e}=Ee(),[a,n]=m.useState(0),i=m.useRef(t);i.current=t;const o=m.useRef(e);o.current=e;const r=m.useRef(!1),c=m.useRef(!1),u=m.useRef(!1),d=m.useCallback(()=>{n(p=>p+1)},[]),l=m.useCallback(p=>{Ah(p.target)&&d()},[d]),f=m.useCallback(async()=>{r.current=!0;try{for(;;){c.current=!1;let p;try{p=await i.current()}catch(g){p={ok:!1,reason:g instanceof Error?g.message:String(g)}}if(!u.current)return;if(!c.current){p.ok||q.error(o.current("settings.common.status.saveFailedReason",{reason:p.reason}));return}}}finally{r.current=!1}},[]);return m.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]),m.useEffect(()=>{if(a!==0){if(r.current){c.current=!0;return}f()}},[a,f]),{requestSave:d,onBlurCapture:l}},Th=["allow","ask","deny"],Eh=["shell","edit","read","glob","grep","patch","webfetch","websearch","skill","subagent","question","external_directory"],Mh=["openchamber","openchamber_schedule","openchamber_web","openchamber_memory","openchamber_knowledge","openchamber_notify","openchamber_render"],Dh=new Set(["bash","task","write","list","lsp","todowrite","todoread","multiedit","doom_loop","plan_enter","plan_exit"]),hu=t=>Dh.has(t),Rh=[{action:"*",resource:"*",effect:"allow"},{action:"read",resource:"*.env",effect:"ask"},{action:"read",resource:"*.env.*",effect:"ask"},{action:"read",resource:"*.env.example",effect:"allow"}],oc=()=>({global:null,keys:{},source:[]}),Pa=t=>({global:t.global,source:t.source,keys:Object.fromEntries(Object.entries(t.keys).map(([e,a])=>[e,{effect:a.effect,patterns:a.patterns.map(n=>({...n}))}]))}),Oh=t=>{const e={global:null,keys:{},source:t.map(a=>({...a}))};for(const a of t){if(hu(a.action))continue;if(a.action==="*"){a.resource==="*"&&(e.global=a.effect);continue}const n=e.keys[a.action]??{effect:null,patterns:[]};if(a.resource==="*")n.effect=a.effect;else{const i=n.patterns.findIndex(o=>o.pattern===a.resource);i>=0?n.patterns[i]={pattern:a.resource,effect:a.effect}:n.patterns.push({pattern:a.resource,effect:a.effect})}e.keys[a.action]=n}return e},Fh=t=>t.action!=="*"||t.resource==="*",Oa=(t,e)=>`${t}\0${e}`,Lh=t=>{const e=new Map;t.global!==null&&e.set(Oa("*","*"),t.global);for(const[a,n]of Object.entries(t.keys)){n.effect!==null&&e.set(Oa(a,"*"),n.effect);for(const i of n.patterns){const o=i.pattern.trim();o.length!==0&&e.set(Oa(a,o),i.effect)}}return e},Br=t=>{const e=Lh(t),a=new Set,n=[];for(const o of t.source){if(hu(o.action))continue;if(!Fh(o)){n.push({...o});continue}const r=Oa(o.action,o.resource),c=e.get(r);c!==void 0&&(n.push({action:o.action,resource:o.resource,effect:c}),a.add(r))}const i=Oa("*","*");t.global!==null&&!a.has(i)&&n.unshift({action:"*",resource:"*",effect:t.global});for(const[o,r]of Object.entries(t.keys)){const c=Oa(o,"*");if(r.effect!==null&&!a.has(c)){const u=n.findIndex(l=>l.action===o),d={action:o,resource:"*",effect:r.effect};u>=0?n.splice(u,0,d):n.push(d)}for(const u of r.patterns){const d=u.pattern.trim();if(d.length===0)continue;const l=Oa(o,d),f=e.get(l);f===void 0||a.has(l)||(a.add(l),n.push({action:o,resource:d,effect:f}))}}return n},Kh=(t,e)=>JSON.stringify(Br(t))===JSON.stringify(Br(e)),_h=(t,e)=>{const a=[...Rh,...e.global,...e.agentGlobal?[{action:"*",resource:"*",effect:e.agentGlobal}]:[]];let n="ask";for(const i of a)i.resource==="*"&&(i.action==="*"||i.action===t)&&(n=i.effect);return n},$h=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),zh=new Set(["shell","edit","read","glob","grep","patch","webfetch","skill","subagent","external_directory"]),Uh={effect:null,patterns:[]},Bh=t=>{const e=De.c(163),{agent:a,registerSave:n,requestSave:i}=t,{t:o}=Ee(),r=Cn(Vh),c=Cn(Hh);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],e[0]=u):u=e[0];const[d,l]=m.useState(u),[f,p]=m.useState(oc),[g,h]=m.useState(oc),[y,b]=m.useState(!0),[x,w]=m.useState(!1);let S;e[1]===Symbol.for("react.memo_cache_sentinel")?(S={},e[1]=S):S=e[1];const[v,A]=m.useState(S),[I,N]=m.useState(""),[k,P]=m.useState(0),j=a.name,C=Hs(),E=$n(qh);let F;e[2]!==C?(F=Be=>sl(Be,C),e[2]=C,e[3]=F):F=e[3];const O=$n(F);let K;e[4]!==C?(K=Be=>Be.getStatusForDirectory(C),e[4]=C,e[5]=K):K=e[5];const D=gn(K);let M,T;e[6]!==E||e[7]!==C?(M=()=>{E({directory:C})},T=[E,C],e[6]=E,e[7]=C,e[8]=M,e[9]=T):(M=e[8],T=e[9]),m.useEffect(M,T);let R;e[10]!==j||e[11]!==c||e[12]!==C?(R=()=>{let Be=!1;return b(!0),w(!1),(async()=>{const ot=await c(j,C);if(Be)return;if(!ot){w(!0),b(!1);return}const et=Oh(ot.agent);l(ot.global),p(Pa(et)),h(et),A({}),b(!1)})(),()=>{Be=!0}},e[10]=j,e[11]=c,e[12]=C,e[13]=R):R=e[13];let $;e[14]!==j||e[15]!==c||e[16]!==k||e[17]!==C?($=[j,c,k,C],e[14]=j,e[15]=c,e[16]=k,e[17]=C,e[18]=$):$=e[18],m.useEffect(R,$);let z;e[19]!==j||e[20]!==f||e[21]!==g||e[22]!==C||e[23]!==o||e[24]!==r?(z=async()=>Kh(g,f)?Ls:(await r(j,{permissions:Br(g)},C)).ok?(p(Pa(g)),In):gs(o("settings.agents.page.permissionsEditor.toast.saveFailed")),e[19]=j,e[20]=f,e[21]=g,e[22]=C,e[23]=o,e[24]=r,e[25]=z):z=e[25];const Q=z;let V,L;e[26]!==n||e[27]!==Q?(V=()=>(n(Q),()=>n(null)),L=[n,Q],e[26]=n,e[27]=Q,e[28]=V,e[29]=L):(V=e[28],L=e[29]),m.useEffect(V,L);let B;e[30]!==O?(B=O.map(Wh),e[30]=O,e[31]=B):B=e[31];const W=B;let Y;if(e[32]!==W||e[33]!==g.keys){Y=[...Eh,...Mh];const Be=new Set(W.map(Gh));let ot;e[35]!==g.keys?(ot=Object.keys(g.keys),e[35]=g.keys,e[36]=ot):ot=e[36];for(const et of ot)!Y.includes(et)&&!Be.has(et)&&Y.push(et);e[32]=W,e[33]=g.keys,e[34]=Y}else Y=e[34];const ae=Y;let ee;e[37]!==D||e[38]!==o?(ee=Be=>{switch(D?.[Be]?.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]=D,e[38]=o,e[39]=ee):ee=e[39];const G=ee;let le;e[40]!==d||e[41]!==g.global?(le=Be=>_h(Be,{global:d,agentGlobal:g.global}),e[40]=d,e[41]=g.global,e[42]=le):le=e[42];const J=le;let me;e[43]!==i?(me=Be=>{h(ot=>({...ot,global:Be})),i()},e[43]=i,e[44]=me):me=e[44];const fe=me;let oe;e[45]!==i?(oe=(Be,ot)=>{h(et=>{const ye=Pa(et),Z=ye.keys[Be]??{effect:null,patterns:[]};return Z.effect=ot,Z.effect===null&&Z.patterns.length===0?delete ye.keys[Be]:ye.keys[Be]=Z,ye}),i()},e[45]=i,e[46]=oe):oe=e[46];const pe=oe;let se;e[47]!==i?(se=(Be,ot,et,ye,Z)=>{h(Oe=>{const Ve=Pa(Oe),X=Ve.keys[Be]??{effect:null,patterns:[]};return X.patterns[ot]={pattern:et,effect:ye},Ve.keys[Be]=X,Ve}),Z&&i()},e[47]=i,e[48]=se):se=e[48];const ve=se;let be;e[49]===Symbol.for("react.memo_cache_sentinel")?(be=Be=>{h(ot=>{const et=Pa(ot),ye=et.keys[Be]??{effect:null,patterns:[]};return ye.patterns.push({pattern:"",effect:"allow"}),et.keys[Be]=ye,et}),A(ot=>({...ot,[Be]:!0}))},e[49]=be):be=e[49];const ne=be;let we;e[50]!==i?(we=(Be,ot)=>{h(et=>{const ye=Pa(et),Z=ye.keys[Be];return Z?(Z.patterns.splice(ot,1),Z.effect===null&&Z.patterns.length===0&&delete ye.keys[Be],ye):et}),i()},e[50]=i,e[51]=we):we=e[51];const Ne=we;let Ie;e[52]!==I||e[53]!==i?(Ie=()=>{const Be=I.trim();!Be||Be==="*"||(h(ot=>{if(ot.keys[Be])return ot;const et=Pa(ot);return et.keys[Be]={effect:"ask",patterns:[]},et}),N(""),i())},e[52]=I,e[53]=i,e[54]=Ie):Ie=e[54];const Ce=Ie;let Me;e[55]!==o?(Me=Be=>o(Be==="allow"?"settings.agents.page.permissionsEditor.action.allow":Be==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),e[55]=o,e[56]=Me):Me=e[56];const he=Me;let Pe,Re,ce,je,de,ie,xe,Se,Le;if(e[57]!==he||e[58]!==J||e[59]!==v||e[60]!==y||e[61]!==x||e[62]!==W||e[63]!==G||e[64]!==g.global||e[65]!==g.keys||e[66]!==Ne||e[67]!==fe||e[68]!==pe||e[69]!==ve||e[70]!==o||e[71]!==ae){Le=Symbol.for("react.early_return_sentinel");e:{const Be=o("settings.agents.page.permissionsEditor.action.inherit"),ot=o("settings.agents.page.permissionsEditor.action.default");let et;e[81]!==he?(et=Je=>[...Je?[{value:"inherit",label:Je}]:[],...Th.map(mt=>({value:mt,label:he(mt)}))],e[81]=he,e[82]=et):et=e[82];const ye=et,Z=(Je,mt,Qe,_)=>{const ge=_===void 0?Be:_;return s.jsx(Xt,{value:Je??"inherit",options:ye(ge),onChange:Ae=>mt(Ae==="inherit"?null:Ae),"aria-label":Qe})};if(y){let Je;e[83]!==o?(Je=o("settings.agents.page.section.toolPermissions"),e[83]=o,e[84]=Je):Je=e[84];let mt;e[85]!==o?(mt=o("common.loading"),e[85]=o,e[86]=mt):mt=e[86];let Qe;e[87]!==mt?(Qe=s.jsx("p",{className:_t,children:mt}),e[87]=mt,e[88]=Qe):Qe=e[88];let _;e[89]!==Je||e[90]!==Qe?(_=s.jsx($e,{title:Je,children:Qe}),e[89]=Je,e[90]=Qe,e[91]=_):_=e[91],Le=_;break e}if(x){let Je;e[92]!==o?(Je=o("settings.agents.page.section.toolPermissions"),e[92]=o,e[93]=Je):Je=e[93];let mt;e[94]!==o?(mt=o("settings.agents.page.permissionsEditor.state.loadFailed"),e[94]=o,e[95]=mt):mt=e[95];let Qe;e[96]!==mt?(Qe=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:mt}),e[96]=mt,e[97]=Qe):Qe=e[97];let _;e[98]===Symbol.for("react.memo_cache_sentinel")?(_=()=>P(Jh),e[98]=_):_=e[98];let ge;e[99]!==o?(ge=o("settings.agents.page.permissionsEditor.actions.retry"),e[99]=o,e[100]=ge):ge=e[100];let Ae;e[101]!==ge?(Ae=s.jsx(H,{variant:"outline",size:"xs",onClick:_,children:ge}),e[101]=ge,e[102]=Ae):Ae=e[102];let Te;e[103]!==Qe||e[104]!==Ae?(Te=s.jsxs("div",{className:"flex items-center gap-3",children:[Qe,Ae]}),e[103]=Qe,e[104]=Ae,e[105]=Te):Te=e[105];let Ge;e[106]!==Je||e[107]!==Te?(Ge=s.jsx($e,{title:Je,children:Te}),e[106]=Je,e[107]=Te,e[108]=Ge):Ge=e[108],Le=Ge;break e}const Oe=(Je,mt,Qe)=>{const _=g.keys[Je]??Uh,ge=zh.has(Je)||_.patterns.length>0,Ae=v[Je]===!0;return s.jsxs("div",{className:"border-t border-border/40 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:ge?()=>A(Te=>({...Te,[Je]:!Ae})):void 0,className:ze("flex min-w-0 items-center gap-1.5 text-start",!ge&&"cursor-default"),"aria-expanded":ge?Ae:void 0,children:[s.jsx(te,{name:Ae&&ge?"arrow-down-s":"arrow-right-s",className:ze("h-3.5 w-3.5 shrink-0 text-muted-foreground",!ge&&"opacity-0")}),s.jsx("span",{className:Vt,children:mt}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground/70",children:Je}),Qe&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:Qe}),_.effect===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:he(J(Je))})}),_.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(_.patterns.length)})})]}),Z(_.effect,Te=>pe(Je,Te),o("settings.agents.page.permissionsEditor.keyAria",{key:Je}))]}),Ae&&ge&&s.jsxs("div",{className:"mt-2 space-y-2 ps-5",children:[_.patterns.map((Te,Ge)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(qe,{value:Te.pattern,onChange:ue=>ve(Je,Ge,ue.target.value,Te.effect,!1),placeholder:o("settings.agents.page.permissionsEditor.patternPlaceholder"),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:Je}),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(Xt,{value:Te.effect,options:ye(),onChange:ue=>ve(Je,Ge,Te.pattern,ue,!0),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:Je})}),s.jsx(H,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>Ne(Je,Ge),"aria-label":o("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx(te,{name:"close",className:"h-3.5 w-3.5"})})]},Ge)),s.jsxs(H,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ne(Je),children:[s.jsx(te,{name:"add",className:"me-1 h-3.5 w-3.5"}),o("settings.agents.page.permissionsEditor.actions.addRule")]})]})]},Je)};Pe=$e,e[109]!==o?(Re=o("settings.agents.page.section.toolPermissions"),e[109]=o,e[110]=Re):Re=e[110],ce="agents.permissions",e[111]!==o?(je=o("settings.agents.page.permissionsEditor.sectionInfo"),e[111]=o,e[112]=je):je=e[112],de="space-y-4";let Ve;e[113]!==o?(Ve=o("settings.agents.page.permissionsEditor.defaultLabel"),e[113]=o,e[114]=Ve):Ve=e[114];let X;e[115]!==Ve?(X=s.jsx("span",{className:Vt,children:Ve}),e[115]=Ve,e[116]=X):X=e[116];let _e;e[117]!==o?(_e=o("settings.agents.page.permissionsEditor.defaultInfo"),e[117]=o,e[118]=_e):_e=e[118];let nt;e[119]!==_e?(nt=s.jsx(ts,{children:_e}),e[119]=_e,e[120]=nt):nt=e[120];let ht;e[121]!==he||e[122]!==J||e[123]!==g.global||e[124]!==o?(ht=g.global===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:he(J("*"))})}),e[121]=he,e[122]=J,e[123]=g.global,e[124]=o,e[125]=ht):ht=e[125];let yt;e[126]!==X||e[127]!==nt||e[128]!==ht?(yt=s.jsxs("div",{className:"flex items-center gap-1.5",children:[X,nt,ht]}),e[126]=X,e[127]=nt,e[128]=ht,e[129]=yt):yt=e[129];const kt=g.global;let He;e[130]!==o?(He=o("settings.agents.page.permissionsEditor.defaultAria"),e[130]=o,e[131]=He):He=e[131],ie=s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[yt,Z(kt,fe,He,ot)]}),xe=s.jsx("div",{children:ae.map(Je=>Oe(Je,$h(Je),null))}),Se=W.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border/40 pt-3 pb-1",children:[s.jsx("span",{className:Vt,children:o("settings.agents.page.permissionsEditor.mcpTitle")}),s.jsx(ts,{children:o("settings.agents.page.permissionsEditor.mcpInfo")})]}),W.map(Je=>Oe(Je.key,Je.server,G(Je.server)))]})}e[57]=he,e[58]=J,e[59]=v,e[60]=y,e[61]=x,e[62]=W,e[63]=G,e[64]=g.global,e[65]=g.keys,e[66]=Ne,e[67]=fe,e[68]=pe,e[69]=ve,e[70]=o,e[71]=ae,e[72]=Pe,e[73]=Re,e[74]=ce,e[75]=je,e[76]=de,e[77]=ie,e[78]=xe,e[79]=Se,e[80]=Le}else Pe=e[72],Re=e[73],ce=e[74],je=e[75],de=e[76],ie=e[77],xe=e[78],Se=e[79],Le=e[80];if(Le!==Symbol.for("react.early_return_sentinel"))return Le;let Ue;e[132]===Symbol.for("react.memo_cache_sentinel")?(Ue=Be=>N(Be.target.value),e[132]=Ue):Ue=e[132];let Ye;e[133]!==Ce?(Ye=Be=>{Be.key==="Enter"&&(Be.preventDefault(),Ce())},e[133]=Ce,e[134]=Ye):Ye=e[134];let lt;e[135]!==o?(lt=o("settings.agents.page.permissionsEditor.customKeyPlaceholder"),e[135]=o,e[136]=lt):lt=e[136];let at;e[137]!==I||e[138]!==Ye||e[139]!==lt?(at=s.jsx(qe,{value:I,onChange:Ue,onKeyDown:Ye,placeholder:lt,className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),e[137]=I,e[138]=Ye,e[139]=lt,e[140]=at):at=e[140];let ut;e[141]!==I?(ut=I.trim(),e[141]=I,e[142]=ut):ut=e[142];const vt=!ut;let We;e[143]===Symbol.for("react.memo_cache_sentinel")?(We=s.jsx(te,{name:"add",className:"me-1 h-3.5 w-3.5"}),e[143]=We):We=e[143];let Ze;e[144]!==o?(Ze=o("settings.agents.page.permissionsEditor.actions.addKey"),e[144]=o,e[145]=Ze):Ze=e[145];let Xe;e[146]!==Ce||e[147]!==vt||e[148]!==Ze?(Xe=s.jsxs(H,{variant:"outline",size:"xs",className:"!font-normal",onClick:Ce,disabled:vt,children:[We,Ze]}),e[146]=Ce,e[147]=vt,e[148]=Ze,e[149]=Xe):Xe=e[149];let it;e[150]!==at||e[151]!==Xe?(it=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-border/40 pt-3",children:[at,Xe]}),e[150]=at,e[151]=Xe,e[152]=it):it=e[152];let dt;return e[153]!==Pe||e[154]!==Re||e[155]!==ce||e[156]!==je||e[157]!==de||e[158]!==ie||e[159]!==xe||e[160]!==Se||e[161]!==it?(dt=s.jsxs(Pe,{title:Re,settingsItem:ce,info:je,contentClassName:de,children:[ie,xe,Se,it]}),e[153]=Pe,e[154]=Re,e[155]=ce,e[156]=je,e[157]=de,e[158]=ie,e[159]=xe,e[160]=Se,e[161]=it,e[162]=dt):dt=e[162],dt};function Vh(t){return t.updateAgent}function Hh(t){return t.fetchAgentPermissions}function qh(t){return t.loadMcpConfigs}function Wh(t){return{key:`${t.name}_*`,server:t.name}}function Gh(t){return t.key}function Jh(t){return t+1}const bl=t=>{const e=De.c(11),{legacy:a,path:n,className:i}=t,{t:o}=Ee();if(!a)return null;let r;e[0]!==i?(r=ze("mb-4 flex items-start gap-1.5",_t,i),e[0]=i,e[1]=r):r=e[1];const c=n??void 0;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(te,{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 l;e[5]!==d?(l=s.jsx("span",{children:d}),e[5]=d,e[6]=l):l=e[6];let f;return e[7]!==r||e[8]!==c||e[9]!==l?(f=s.jsxs("p",{className:r,title:c,children:[u,l]}),e[7]=r,e[8]=c,e[9]=l,e[10]=f):f=e[10],f},Qh=(t,e)=>{const a=Un(e);if(!a)return[];const n=t.find(o=>o.id===a.providerId),i=fg(n?.models,a.modelId);return Dd(i)},Yh=t=>Pm(t)?.toLowerCase()??"",Zh=()=>{const{t}=Ee(),e=ft(he=>he.providers),{selectedAgentName:a,getAgentByName:n,createAgent:i,updateAgent:o,fetchAgentEntity:r,agentDraft:c,setAgentDraft:u,setSelectedAgent:d}=Cn(_s(he=>({selectedAgentName:he.selectedAgentName,getAgentByName:he.getAgentByName,createAgent:he.createAgent,updateAgent:he.updateAgent,fetchAgentEntity:he.fetchAgentEntity,agentDraft:he.agentDraft,setAgentDraft:he.setAgentDraft,setSelectedAgent:he.setSelectedAgent}))),l=Hs(),f=Cn(he=>Md(he,l)),p=a?n(a,l):null,g=!!(c&&c.name===a&&!p),h=g?"":p?.description?.trim()??"",y=g?"":p?.system?.trim()??"",[b,x]=m.useState(""),[w,S]=m.useState("user"),[v,A]=m.useState(""),[I,N]=m.useState("subagent"),[k,P]=m.useState(""),[j,C]=m.useState(""),[E,F]=m.useState(void 0),[O,K]=m.useState(void 0),[D,M]=m.useState(void 0),[T,R]=m.useState(""),[$,z]=m.useState(""),[Q,V]=m.useState(!1),[L,B]=m.useState(null),W=m.useRef({}),Y=m.useRef(null),ae=m.useCallback(he=>{Y.current=he},[]),ee=m.useRef(null),G=JSON.stringify([a,l,g]),le=m.useRef(G);le.current=G;const J=m.useRef(null),me={description:v,mode:I,model:k,variant:j,steps:E,temperature:O,topP:D,system:T,color:$},fe=m.useRef(me);fe.current=me;const oe=m.useMemo(()=>Qh(e,k),[k,e]),pe=oe.length>0,se=j||"__default",ve=pe,be=m.useMemo(()=>j&&!oe.includes(j)?[j,...oe]:oe,[j,oe]);m.useEffect(()=>{if(!g||!c)return;J.current=null;const he=Mi(c.model),Pe=c.name||"",Re=c.scope||"user",ce=c.description||"",je=c.mode||"subagent",de=he?`${he.providerID}/${he.modelID}`:"",ie=he?.variant||"",xe=c.steps??void 0,Se=c.temperature??void 0,Le=c.top_p??void 0,Ue=c.system||"",Ye="";W.current={},B(null),x(Pe),S(Re),A(ce),N(je),P(de),C(ie),F(xe),K(Se),M(Le),R(Ue),z(Ye),ee.current={draftName:Pe,draftScope:Re,description:ce,mode:je,model:de,variant:ie,steps:xe,temperature:Se,topP:Le,system:Ue,color:Ye}},[c,g]),m.useEffect(()=>{if(g||!a)return;let he=!1;return(async()=>{const Pe=await r(a,l);if(he||le.current!==G||!Pe)return;const Re=Pe.config;W.current=Re;const ce=Mi(Re.model),je=Re.request?.body,de={draftName:"",draftScope:"user",description:Re.description||"",mode:Re.mode||p?.mode||"subagent",model:ce?`${ce.providerID}/${ce.modelID}`:"",variant:ce?.variant||"",steps:Re.steps??void 0,temperature:je?.temperature,topP:je?.top_p,system:Re.system||"",color:Yh(Re.color)},ie=ee.current,xe=fe.current,Se=ie!==null&&(xe.description!==ie.description||xe.mode!==ie.mode||xe.model!==ie.model||xe.variant!==ie.variant||xe.steps!==ie.steps||xe.temperature!==ie.temperature||xe.topP!==ie.topP||xe.system!==ie.system||xe.color!==ie.color);B({legacy:Pe.legacy===!0,path:Pe.path,source:Pe.source}),!(J.current===G&&Se)&&(J.current=G,A(de.description),N(de.mode),P(de.model),C(de.variant),F(de.steps),K(de.temperature),M(de.topP),R(de.system),z(de.color),ee.current=de)})(),()=>{he=!0}},[r,g,p,a,l,G]);const ne=m.useCallback(he=>{const Pe=Un(k.trim()),Re=Pe?Yd({providerID:Pe.providerId,modelID:Pe.modelId,variant:j.trim()||void 0}):null,ce=W.current.request,je={...ce?.body};O===void 0?delete je.temperature:je.temperature=O,D===void 0?delete je.top_p:je.top_p=D;const de=ce?.headers,ie={};de&&Object.keys(de).length>0&&(ie.headers=de),Object.keys(je).length>0&&(ie.body=je);const xe=v.trim(),Se=T.trim(),Le={name:he,mode:I,model:Re,steps:E??null,system:Se||(g?void 0:null),request:Object.keys(ie).length>0?ie:null};return xe&&(Le.description=xe),$!==(ee.current?.color??"")&&(Le.color=$||null),g&&w&&(Le.scope=w),g&&c?.hidden!==void 0&&(Le.hidden=c.hidden),g&&c?.permissions?.length&&(Le.permissions=c.permissions),Le},[c,$,v,w,g,I,k,E,T,O,D,j]),we=m.useCallback(async()=>{const he=ee.current,Pe=a?.trim();if(g||!he||!Pe)return Ls;const Re=Y.current?await Y.current():Ls;if(v===he.description&&I===he.mode&&k===he.model&&j===he.variant&&E===he.steps&&O===he.temperature&&D===he.topP&&T===he.system&&$===he.color||!Re.ok)return Re;const je=ne(Pe);return(await o(Pe,je,l)).ok?(le.current!==G||(W.current={...W.current,model:je.model,system:je.system??void 0,steps:je.steps,request:je.request??void 0},ee.current={...he,description:v,mode:I,model:k,variant:j,steps:E,temperature:O,topP:D,system:T,color:$}),In):gs(t("settings.agents.page.toast.updateFailed"))},[ne,$,v,g,I,k,a,G,l,E,T,t,O,D,o,j]),Ne=ci(we),{requestSave:Ie}=Ne,Ce=async()=>{const he=b.trim().replace(/\s+/g,"-");if(!he){q.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(f.some(Pe=>Pe.name===he)){q.error(t("settings.agents.sidebar.toast.agentExists"));return}V(!0);try{(await i(ne(he),l)).ok?(u(null),q.success(t("settings.agents.page.toast.created"))):q.error(t("settings.agents.page.toast.createFailed"))}catch(Pe){console.error("Error creating agent:",Pe);const Re=Pe instanceof Error&&Pe.message?Pe.message:t("settings.agents.page.toast.saveUnexpectedError");q.error(Re)}finally{V(!1)}},Me=()=>{u(null),d(null)};return a?s.jsxs(qt,{title:g?t("settings.agents.page.title.new"):a,description:t(g?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit"),onBlurCapture:Ne.onBlurCapture,children:[!g&&L&&s.jsx(bl,{legacy:L.legacy,path:L.path}),!g&&L?.source==="none"&&s.jsxs("p",{className:`mb-4 flex items-start gap-1.5 ${_t}`,children:[s.jsx(te,{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($e,{title:t("settings.agents.page.section.identityRole"),divider:!1,contentClassName:"space-y-3",children:[g&&s.jsxs(st,{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:b,onChange:he=>x(he.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Pt,{value:w,onValueChange:he=>S(he),children:[s.jsx(Ct,{className:"w-fit min-w-[100px]",children:s.jsx(Kt,{placeholder:t("settings.agents.page.field.scopePlaceholder")})}),s.jsxs(It,{align:"end",children:[s.jsx(bt,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(te,{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(te,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsx(St,{label:t("settings.common.field.description"),controlClassName:"w-full max-w-none",children:s.jsx(Cs,{value:v,onChange:he=>A(he.target.value),placeholder:h||t("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})}),s.jsx(St,{settingsItem:"agents.mode",label:t("settings.agents.page.field.mode"),info:t("settings.agents.page.field.modeTooltip"),children:s.jsx(Xt,{"aria-label":t("settings.agents.page.field.mode"),value:I,onChange:he=>{N(he),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(St,{settingsItem:"agents.color",label:t("settings.agents.page.field.color"),info:t("settings.agents.page.field.colorTooltip"),children:s.jsx(vf,{value:$,labels:{empty:t("settings.agents.page.field.colorAutomatic"),swatch:he=>t("settings.agents.page.field.colorSwatchAria",{color:he}),custom:t("settings.agents.page.field.colorCustomAria"),hex:t("settings.agents.page.field.colorHexAria")},onChange:he=>{z(he),Ie()}})})]}),s.jsxs($e,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx(st,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(Fa,{providerId:Un(k)?.providerId??"",modelId:Un(k)?.modelId??"",onChange:(he,Pe)=>{P(he&&Pe?`${he}/${Pe}`:""),C(""),Ie()},className:an})}),s.jsx(st,{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:ve?s.jsxs(Pt,{value:se,onValueChange:he=>{C(he==="__default"?"":he),Ie()},children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:he=>he==="__default"?t("chat.modelControls.default"):he})}),s.jsxs(It,{children:[s.jsx(bt,{value:"__default",children:t("chat.modelControls.default")}),be.map(he=>s.jsx(bt,{value:he,children:he},he))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(qe,{value:j,onChange:he=>C(he.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!k&&!j,className:"h-8 w-40 rounded-md px-3"}),j&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{C(""),Ie()},className:Yt,"aria-label":t("settings.common.actions.clear"),title:t("settings.common.actions.clear"),children:s.jsx(te,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsxs(st,{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(ds,{value:O,fallbackValue:.7,onValueChange:K,onClear:()=>{K(void 0),Ie()},min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:us}),O!==void 0&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{K(void 0),Ie()},className:Yt,"aria-label":t("settings.agents.page.field.clearTemperatureAria"),title:t("settings.common.actions.clear"),children:s.jsx(te,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(st,{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(ds,{value:D,fallbackValue:.9,onValueChange:M,onClear:()=>{M(void 0),Ie()},min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:us}),D!==void 0&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{M(void 0),Ie()},className:Yt,"aria-label":t("settings.agents.page.field.clearTopPAria"),title:t("settings.common.actions.clear"),children:s.jsx(te,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(st,{settingsItem:"agents.steps",label:t("settings.agents.page.field.steps"),info:t("settings.agents.page.field.stepsTooltip"),children:[s.jsx(ds,{value:E,fallbackValue:20,onValueChange:F,onClear:()=>{F(void 0),Ie()},min:1,max:1e3,step:1,inputMode:"numeric",placeholder:"—",emptyLabel:"—",className:us}),E!==void 0&&s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{F(void 0),Ie()},className:Yt,"aria-label":t("settings.agents.page.field.clearStepsAria"),title:t("settings.common.actions.clear"),children:s.jsx(te,{name:"close",className:"h-3.5 w-3.5"})})]})]}),s.jsx($e,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx(Cs,{value:T,onChange:he=>R(he.target.value),placeholder:y||t("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent"})}),!g&&p&&s.jsx(Bh,{agent:p,registerSave:ae,requestSave:Ie}),g&&s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[s.jsx(H,{onClick:()=>{Ce()},disabled:Q||!b.trim(),size:"xs",className:"!font-normal",children:t(Q?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(H,{variant:"ghost",onClick:Me,disabled:Q,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(te,{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 Xh(t,e){return t.kind==="file"?t.content:e??""}const rc=as({content:wt(),exists:Ji(),path:wt().min(1).optional()}),eb=async(t,e)=>{const a=await t.json().catch(()=>null);return typeof a?.error=="string"&&a.error.trim()?a.error:e},tb=t=>t.length>0&&!t.endsWith(`
3
3
  `)?`${t}
4
4
  `:t,ro={prompt:"",responseStyleEnabled:!1,responseStylePreset:"concise",responseStyleCustomInstructions:""},sb=(t,e)=>t==="custom"?e:Tm(t),nb=t=>t==="custom"?"custom":Rd(t)?t:"concise",lc={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"},ab=()=>{const{t}=Ee(),[e,a]=m.useState(""),[n,i]=m.useState("AGENTS.md"),[o,r]=m.useState(ro.responseStyleEnabled),[c,u]=m.useState(ro.responseStylePreset),[d,l]=m.useState(ro.responseStyleCustomInstructions),[f,p]=m.useState(!0),g=m.useRef(null),h=m.useRef(null);m.useEffect(()=>{const v=new AbortController;return(async()=>{try{const[I,N]=await Promise.all([fn(),$t("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:v.signal})]);let k=ro,P;I&&(k={...k,responseStyleEnabled:I.responseStyleEnabled===!0,responseStylePreset:nb(I.responseStylePreset),responseStyleCustomInstructions:I.responseStyleCustomInstructions??""},I.globalBehaviorPrompt!==void 0&&(P=I.globalBehaviorPrompt));let j={kind:"missing"};if(N.ok){const C=rc.parse(await N.json());if(v.signal.aborted)return;i(C.path??"AGENTS.md"),h.current=C.exists?C.content:null,C.exists&&(j={kind:"file",content:C.content})}k={...k,prompt:Xh(j,P)},a(k.prompt),r(k.responseStyleEnabled),u(k.responseStylePreset),l(k.responseStyleCustomInstructions),g.current=k}catch(I){I.name!=="AbortError"&&console.warn("Failed to load behavior settings:",I)}finally{p(!1)}})(),()=>v.abort()},[]);const y=m.useRef(e);y.current=e,m.useEffect(()=>{let v=null;const A=async()=>{if(document.visibilityState!=="visible"||!g.current)return;v?.abort();const N=new AbortController;v=N;try{const k=await $t("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:N.signal});if(!k.ok)return;const P=rc.parse(await k.json()),j=g.current;if(N.signal.aborted||!j||!P.exists||P.content===h.current||y.current!==j.prompt)return;h.current=P.content,g.current={...j,prompt:P.content},a(P.content)}catch(k){k instanceof DOMException&&k.name==="AbortError"||console.warn("Failed to refresh AGENTS.md:",k)}},I=()=>{A()};return window.addEventListener("focus",I),document.addEventListener("visibilitychange",I),()=>{v?.abort(),window.removeEventListener("focus",I),document.removeEventListener("visibilitychange",I)}},[]);const b=m.useCallback(async()=>{const v=g.current;if(!v||f)return Ls;const A=e!==v.prompt,I=o!==v.responseStyleEnabled||c!==v.responseStylePreset||d!==v.responseStyleCustomInstructions;if(!A&&!I)return Ls;const N=A?tb(e):v.prompt;if(A){const P=await $t("/api/behavior/agents-md",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:N,expectedContent:h.current})});if(P.status===409)return gs(t("settings.behavior.page.toast.agentsMdChangedOnDisk"));if(!P.ok)return gs(await eb(P,t("settings.behavior.page.toast.saveFailed")));h.current=N,a(j=>j===e?N:j)}return(await jt({...A?{globalBehaviorPrompt:N}:{},responseStyleEnabled:o,responseStylePreset:c,responseStyleCustomInstructions:d})).ok?(g.current={prompt:N,responseStyleEnabled:o,responseStylePreset:c,responseStyleCustomInstructions:d},In):gs(t("settings.behavior.page.toast.saveFailed"))},[f,e,d,o,c,t]),x=ci(b),{requestSave:w}=x,S=sb(c,d);return s.jsxs(qt,{title:t("settings.behavior.page.title"),description:t("settings.page.behavior.description"),onBlurCapture:x.onBlurCapture,children:[s.jsx($e,{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:n})})]}),settingsItem:"behavior.system-prompt",contentClassName:"space-y-3",children:s.jsx(Cs,{value:e,onChange:v=>a(v.target.value),placeholder:t("settings.behavior.page.field.systemPromptPlaceholder"),rows:12,disabled:f,outerClassName:"min-h-[160px] max-h-[70vh]",className:"w-full font-mono typography-meta bg-transparent"})}),s.jsxs($e,{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(ct,{checked:o,onChange:v=>{r(v),w()},disabled:f,label:t("settings.behavior.page.responseStyle.enable"),ariaLabel:t("settings.behavior.page.responseStyle.enableAria")}),s.jsx(st,{label:t("settings.behavior.page.responseStyle.preset"),alignEnd:!1,children:s.jsxs(Pt,{value:c,onValueChange:v=>{u(v),w()},disabled:f||!o,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{children:v=>v==="custom"?t("settings.behavior.page.responseStyle.option.custom"):Rd(v)?t(lc[v]):null})}),s.jsxs(It,{children:[Am.map(v=>s.jsx(bt,{value:v,children:t(lc[v])},v)),s.jsx(bt,{value:"custom",children:t("settings.behavior.page.responseStyle.option.custom")})]})]})}),s.jsx(Cs,{value:S,onChange:v=>l(v.target.value),placeholder:t("settings.behavior.page.responseStyle.customPlaceholder"),rows:5,disabled:f||!o||c!=="custom",outerClassName:"min-h-[120px]",className:"w-full font-mono typography-meta bg-transparent"})]})]})},ib=(t,e)=>t.kind===e.kind&&(t.kind!=="provider"||e.kind==="provider"&&t.id===e.id),ob=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,a)=>e.provider.name.localeCompare(a.provider.name,void 0,{sensitivity:"base"})),xl=t=>{const e=De.c(8),{t:a}=Ee(),n=Li(mb),i=t.projectOverride!==null;let o;e[0]!==i||e[1]!==n||e[2]!==t.selection||e[3]!==a?(o=u=>{i||ib(u,t.selection)||n(u).then(d=>{d||q.error(a("settings.webSearch.toast.saveFailed"))})},e[0]=i,e[1]=n,e[2]=t.selection,e[3]=a,e[4]=o):o=e[4];const r=o;let c;return e[5]!==r||e[6]!==i?(c={choose:r,locked:i},e[5]=r,e[6]=i,e[7]=c):c=e[7],c},rb=t=>{const e=De.c(51),{snapshot:a}=t,{t:n}=Ee(),{choose:i,locked:o}=xl(a),r=a.selection;let c,u;if(e[0]!==o||e[1]!==r.id||e[2]!==r.kind||e[3]!==a.providers||e[4]!==n){const S=r.kind==="provider"?a.providers.find(j=>j.id===r.id)?.name??null:null;let v;e[7]!==n?(v=n("settings.webSearch.option.default"),e[7]=n,e[8]=v):v=e[8];let A;e[9]!==o||e[10]!==v?(A={value:"default",label:v,disabled:o},e[9]=o,e[10]=v,e[11]=A):A=e[11];let I;e[12]!==o||e[13]!==a.providers.length||e[14]!==n?(I=a.providers.length>0?[{value:"random",label:n("settings.webSearch.option.random"),disabled:o}]:[],e[12]=o,e[13]=a.providers.length,e[14]=n,e[15]=I):I=e[15];let N;e[16]!==n?(N=n("settings.webSearch.option.off"),e[16]=n,e[17]=N):N=e[17];let k;e[18]!==o||e[19]!==N?(k={value:"off",label:N,disabled:o},e[18]=o,e[19]=N,e[20]=k):k=e[20];let P;e[21]!==A||e[22]!==I||e[23]!==k?(P=[A,...I,k],e[21]=A,e[22]=I,e[23]=k,e[24]=P):P=e[24],c=P,u=r.kind==="default"?n("settings.webSearch.option.defaultDescription"):r.kind==="random"?n("settings.webSearch.option.randomDescription"):r.kind==="off"?n("settings.webSearch.mode.offDescription"):S?n("settings.webSearch.mode.providerDescription",{provider:S}):n("settings.webSearch.mode.missingDescription",{provider:r.id}),e[0]=o,e[1]=r.id,e[2]=r.kind,e[3]=a.providers,e[4]=n,e[5]=c,e[6]=u}else c=e[5],u=e[6];const d=u;let l;e[25]!==n?(l=n("settings.webSearch.section.provider"),e[25]=n,e[26]=l):l=e[26];let f;e[27]!==n?(f=n("settings.webSearch.section.providerInfo"),e[27]=n,e[28]=f):f=e[28];let p;e[29]!==n?(p=n("settings.webSearch.section.provider"),e[29]=n,e[30]=p):p=e[30];let g;e[31]!==i?(g=S=>{S!=="provider"&&i({kind:S})},e[31]=i,e[32]=g):g=e[32];let h;e[33]!==c||e[34]!==r.kind||e[35]!==p||e[36]!==g?(h=s.jsx(Xt,{"aria-label":p,value:r.kind,options:c,onChange:g}),e[33]=c,e[34]=r.kind,e[35]=p,e[36]=g,e[37]=h):h=e[37];let y;e[38]!==d?(y=s.jsx("p",{className:_t,children:d}),e[38]=d,e[39]=y):y=e[39];let b;e[40]!==a.projectOverride||e[41]!==n?(b=a.projectOverride?s.jsx("p",{className:`${_t} break-all`,children:n("settings.webSearch.state.projectOverride",{path:a.projectOverride})}):null,e[40]=a.projectOverride,e[41]=n,e[42]=b):b=e[42];let x;e[43]!==h||e[44]!==y||e[45]!==b?(x=s.jsxs("div",{className:"space-y-2",children:[h,y,b]}),e[43]=h,e[44]=y,e[45]=b,e[46]=x):x=e[46];let w;return e[47]!==l||e[48]!==f||e[49]!==x?(w=s.jsx($e,{title:l,info:f,divider:!1,settingsItem:"web-search.provider",children:x}),e[47]=l,e[48]=f,e[49]=x,e[50]=w):w=e[50],w},lb=t=>{const e=De.c(32),{entry:a,snapshot:n,onOpen:i}=t,{t:o}=Ee(),{choose:r,locked:c}=xl(n),{provider:u,access:d,usable:l}=a,f=n.selection.kind==="provider"&&n.selection.id===u.id,p=d?.key,g=d?.connect?.kind==="key";let h;e[0]!==f||e[1]!==p?.kind||e[2]!==o||e[3]!==g||e[4]!==l?(h=f?s.jsx(js,{tone:"success",children:o("settings.webSearch.card.inUse")}):!l&&p?.kind==="none"?s.jsx(js,{tone:"warning",children:o(g?"settings.webSearch.card.needsKey":"settings.webSearch.card.needsSetup")}):null,e[0]=f,e[1]=p?.kind,e[2]=o,e[3]=g,e[4]=l,e[5]=h):h=e[5];const y=h;let b;e[6]!==p||e[7]!==o||e[8]!==g||e[9]!==l?(b=p?.kind==="stored"?o(g?"settings.webSearch.keys.saved":"settings.webSearch.keys.connected"):p?.kind==="env"?o("settings.webSearch.keys.fromEnv",{name:p.name}):l&&p?.kind==="none"?o("settings.webSearch.card.keyOptional"):null,e[6]=p,e[7]=o,e[8]=g,e[9]=l,e[10]=b):b=e[10];const x=b;let w;e[11]!==r||e[12]!==f||e[13]!==c||e[14]!==u.id||e[15]!==o||e[16]!==l?(w=l&&!f&&!c?[{label:o("settings.webSearch.actions.use"),icon:"check",onSelect:()=>r({kind:"provider",id:u.id})}]:[],e[11]=r,e[12]=f,e[13]=c,e[14]=u.id,e[15]=o,e[16]=l,e[17]=w):w=e[17];const S=w;let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(Eo,{name:"global"}),e[18]=v):v=e[18];const A=u.name;let I;e[19]!==x?(I=x?s.jsx("span",{className:"min-w-0 truncate",children:x}):null,e[19]=x,e[20]=I):I=e[20];const N=!l&&p?.kind==="none";let k;e[21]!==u.name||e[22]!==o?(k=o("settings.webSearch.card.actions",{provider:u.name}),e[21]=u.name,e[22]=o,e[23]=k):k=e[23];let P;return e[24]!==S||e[25]!==i||e[26]!==y||e[27]!==u.name||e[28]!==I||e[29]!==N||e[30]!==k?(P=s.jsx(qn,{icon:v,title:A,badges:y,footer:I,muted:N,onOpen:i,actions:S,actionsLabel:k}),e[24]=S,e[25]=i,e[26]=y,e[27]=u.name,e[28]=I,e[29]=N,e[30]=k,e[31]=P):P=e[31],P},cb=t=>{const e=De.c(82),{provider:a,access:n,connect:i,locked:o}=t,{t:r}=Ee(),c=Li(pb),u=Li(gb),[d,l]=m.useState("");let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];const[p,g]=m.useState(f),[h,y]=m.useState(!1),b=i.kind==="key";let x;if(e[1]!==n.envNames||e[2]!==i.fields||e[3]!==r||e[4]!==b){const T=n.envNames.join(", ");let R;e[6]!==r?(R=z=>[z.description,z.placeholder?r("settings.webSearch.keys.fieldExample",{example:z.placeholder}):null],e[6]=r,e[7]=R):R=e[7];const $=[...i.fields.flatMap(R),n.envNames.length===0?null:b?r("settings.webSearch.keys.envHint",{names:T}):r("settings.webSearch.keys.envHintForm",{names:T})].filter(fb);x=$.length>0?$.map(hb):void 0,e[1]=n.envNames,e[2]=i.fields,e[3]=r,e[4]=b,e[5]=x}else x=e[5];const w=x;let S;e[8]!==p?(S=Object.fromEntries(Object.entries(p).map(bb).filter(xb)),e[8]=p,e[9]=S):S=e[9];const v=S;let A;e[10]!==i.fields||e[11]!==d||e[12]!==v||e[13]!==b?(A=(!b||d.trim()!=="")&&i.fields.every(T=>!T.required||v[T.key]!==void 0),e[10]=i.fields,e[11]=d,e[12]=v,e[13]=b,e[14]=A):A=e[14];const I=A;let N;e[15]!==I||e[16]!==d||e[17]!==v||e[18]!==a.id||e[19]!==a.name||e[20]!==c||e[21]!==r||e[22]!==b?(N=async()=>{if(!I)return;y(!0);const T=await c(a.id,{key:d.trim(),answer:v});y(!1),T?(l(""),g({}),q.success(b?r("settings.webSearch.toast.keySaved",{provider:a.name}):r("settings.webSearch.toast.connected",{provider:a.name}))):q.error(b?r("settings.webSearch.toast.keySaveFailed"):r("settings.webSearch.toast.connectFailed",{provider:a.name}))},e[15]=I,e[16]=d,e[17]=v,e[18]=a.id,e[19]=a.name,e[20]=c,e[21]=r,e[22]=b,e[23]=N):N=e[23];const k=N;let P;e[24]!==a.id||e[25]!==u||e[26]!==r?(P=async()=>{y(!0);const T=await u(a.id);y(!1),T||q.error(r("settings.webSearch.toast.keyRemoveFailed"))},e[24]=a.id,e[25]=u,e[26]=r,e[27]=P):P=e[27];const j=P;let C;e[28]!==k?(C=T=>{T.key==="Enter"&&k()},e[28]=k,e[29]=C):C=e[29];const E=C;let F,O,K,D;if(e[30]!==n.key||e[31]!==p||e[32]!==h||e[33]!==I||e[34]!==i.fields||e[35]!==d||e[36]!==j||e[37]!==k||e[38]!==w||e[39]!==o||e[40]!==a.name||e[41]!==E||e[42]!==r||e[43]!==b){let T;e[48]!==p||e[49]!==a.name||e[50]!==E||e[51]!==r?(T=ae=>s.jsx(qe,{type:ae.url?"url":"text",value:p[ae.key]??"",onChange:ee=>g(G=>({...G,[ae.key]:ee.target.value})),onKeyDown:E,placeholder:ae.label,"aria-label":r("settings.webSearch.keys.fieldAria",{provider:a.name,field:ae.label}),className:"h-8 min-w-0 flex-1 rounded-md px-3 font-mono text-xs"},ae.key),e[48]=p,e[49]=a.name,e[50]=E,e[51]=r,e[52]=T):T=e[52];const R=i.fields.map(T);if(b){let ae;e[53]===Symbol.for("react.memo_cache_sentinel")?(ae=J=>l(J.target.value),e[53]=ae):ae=e[53];let ee;e[54]!==r?(ee=r("settings.webSearch.keys.placeholder"),e[54]=r,e[55]=ee):ee=e[55];let G;e[56]!==a.name||e[57]!==r?(G=r("settings.webSearch.keys.inputAria",{provider:a.name}),e[56]=a.name,e[57]=r,e[58]=G):G=e[58];let le;e[59]!==d||e[60]!==E||e[61]!==ee||e[62]!==G?(le=s.jsx(qe,{type:"password",value:d,onChange:ae,onKeyDown:E,placeholder:ee,"aria-label":G,className:"h-8 min-w-0 flex-1 rounded-md px-3 font-mono text-xs"},"key"),e[59]=d,e[60]=E,e[61]=ee,e[62]=G,e[63]=le):le=e[63],R.push(le)}const $=h||!I;let z;e[64]!==k?(z=()=>{k()},e[64]=k,e[65]=z):z=e[65];let Q;e[66]!==r?(Q=r("settings.webSearch.keys.save"),e[66]=r,e[67]=Q):Q=e[67];let V;e[68]!==$||e[69]!==z||e[70]!==Q?(V=s.jsx(H,{size:"xs",disabled:$,onClick:z,children:Q}),e[68]=$,e[69]=z,e[70]=Q,e[71]=V):V=e[71];const L=V,B=n.key;let W;e[72]!==i.fields[0]||e[73]!==i.fields.length||e[74]!==r||e[75]!==b?(W=b?r("settings.webSearch.keys.label"):i.fields.length===1&&i.fields[0]?i.fields[0].label:r("settings.webSearch.keys.connectionLabel"),e[72]=i.fields[0],e[73]=i.fields.length,e[74]=r,e[75]=b,e[76]=W):W=e[76];const Y=W;F=st,K=Y,D=w,O=B.kind==="stored"?s.jsxs("div",{className:`${rn} flex items-center justify-end gap-2`,children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:r(b?"settings.webSearch.keys.saved":"settings.webSearch.keys.connected")}),s.jsx(H,{variant:"outline",size:"xs",disabled:h,onClick:()=>{j()},children:r("settings.webSearch.keys.remove")})]}):B.kind==="env"?s.jsx("span",{className:"typography-meta text-muted-foreground",children:r("settings.webSearch.keys.fromEnv",{name:B.name})}):o?null:R.length===1?s.jsxs("div",{className:`${rn} flex items-center gap-2`,children:[R,L]}):s.jsxs("div",{className:`${rn} flex flex-col gap-2`,children:[R.slice(0,-1).map(vb),s.jsxs("div",{className:"flex items-center gap-2",children:[R.at(-1),L]})]}),e[30]=n.key,e[31]=p,e[32]=h,e[33]=I,e[34]=i.fields,e[35]=d,e[36]=j,e[37]=k,e[38]=w,e[39]=o,e[40]=a.name,e[41]=E,e[42]=r,e[43]=b,e[44]=F,e[45]=O,e[46]=K,e[47]=D}else F=e[44],O=e[45],K=e[46],D=e[47];let M;return e[77]!==F||e[78]!==O||e[79]!==K||e[80]!==D?(M=s.jsx(F,{label:K,info:D,children:O}),e[77]=F,e[78]=O,e[79]=K,e[80]=D,e[81]=M):M=e[81],M},db=t=>{const e=De.c(44),{entry:a,snapshot:n,onBack:i}=t,{t:o}=Ee(),{choose:r,locked:c}=xl(n),u=Pn(),{provider:d,access:l,usable:f}=a,p=n.selection.kind==="provider"&&n.selection.id===d.id,g=l?.connect??null;let h;e[0]!==g?.kind||e[1]!==p||e[2]!==d.name||e[3]!==o||e[4]!==f?(h=p?o("settings.webSearch.mode.providerDescription",{provider:d.name}):f?null:g?.kind==="form"?o("settings.webSearch.detail.needsSetup",{provider:d.name}):o("settings.webSearch.detail.needsKey",{provider:d.name}),e[0]=g?.kind,e[1]=p,e[2]=d.name,e[3]=o,e[4]=f,e[5]=h):h=e[5];const y=h,b=d.name;let x;e[6]!==o?(x=o("settings.webSearch.detail.back"),e[6]=o,e[7]=x):x=e[7];let w;e[8]!==i||e[9]!==x?(w=s.jsx(ii,{label:x,onClick:i}),e[8]=i,e[9]=x,e[10]=w):w=e[10];let S;e[11]!==y?(S=y?s.jsx("p",{className:"typography-meta text-foreground",children:y}):null,e[11]=y,e[12]=S):S=e[12];let v;e[13]!==r||e[14]!==p||e[15]!==c||e[16]!==d.id||e[17]!==o||e[18]!==f?(v=f&&!p?s.jsx(H,{size:"sm",disabled:c,onClick:()=>r({kind:"provider",id:d.id}),children:o("settings.webSearch.actions.use")}):null,e[13]=r,e[14]=p,e[15]=c,e[16]=d.id,e[17]=o,e[18]=f,e[19]=v):v=e[19];let A;e[20]!==n.projectOverride||e[21]!==o?(A=n.projectOverride?s.jsx("p",{className:`${_t} break-all`,children:o("settings.webSearch.state.projectOverride",{path:n.projectOverride})}):null,e[20]=n.projectOverride,e[21]=o,e[22]=A):A=e[22];let I;e[23]!==S||e[24]!==v||e[25]!==A?(I=s.jsx($e,{divider:!1,children:s.jsxs("div",{className:"space-y-2",children:[S,v,A]})}),e[23]=S,e[24]=v,e[25]=A,e[26]=I):I=e[26];let N;e[27]!==u||e[28]!==o?(N=u?s.jsx("p",{className:_t,children:o("settings.webSearch.keys.enterpriseMode")}):null,e[27]=u,e[28]=o,e[29]=N):N=e[29];let k;e[30]!==l||e[31]!==g||e[32]!==u||e[33]!==d||e[34]!==o?(k=l===null?s.jsx("p",{className:_t,children:o("settings.webSearch.state.keysUnavailable")}):g?s.jsx(cb,{provider:d,access:l,connect:g,locked:u}):s.jsx("p",{className:_t,children:o("settings.webSearch.detail.noKey")}),e[30]=l,e[31]=g,e[32]=u,e[33]=d,e[34]=o,e[35]=k):k=e[35];let P;e[36]!==k||e[37]!==N?(P=s.jsx($e,{children:s.jsxs("div",{className:"space-y-4",children:[N,k]})}),e[36]=k,e[37]=N,e[38]=P):P=e[38];let j;return e[39]!==d.name||e[40]!==P||e[41]!==w||e[42]!==I?(j=s.jsxs(qt,{title:b,titleLeading:w,showSaveStatus:!0,children:[I,P]}),e[39]=d.name,e[40]=P,e[41]=w,e[42]=I,e[43]=j):j=e[43],j},ub=()=>{const t=De.c(16),{t:e}=Ee(),a=Li(yb),n=Li(jb),[i,o]=m.useState(null);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=Em(),t[0]=r):r=t[0];const c=r;let u,d;t[1]!==n?(u=()=>{n()},d=[n,c],t[1]=n,t[2]=u,t[3]=d):(u=t[2],d=t[3]),m.useEffect(u,d);const l=a.kind==="ready"&&a.snapshot.scope===c?a.snapshot:null;let f,p;if(t[4]!==n||t[5]!==i||t[6]!==l||t[7]!==a.kind||t[8]!==e){p=Symbol.for("react.early_return_sentinel");e:{const g=l?ob(l):[],h=i?g.find(x=>x.provider.id===i)??null:null;if(l&&h){let x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=()=>o(null),t[11]=x):x=t[11],p=s.jsx(db,{entry:h,snapshot:l,onBack:x});break e}let y;t[12]!==e?(y=e("settings.page.webSearch.title"),t[12]=e,t[13]=y):y=t[13];let b;t[14]!==e?(b=e("settings.page.webSearch.description"),t[14]=e,t[15]=b):b=t[15],f=s.jsx(qt,{title:y,description:b,showSaveStatus:!0,children:l?s.jsxs(s.Fragment,{children:[s.jsx(rb,{snapshot:l}),s.jsxs($e,{title:e("settings.webSearch.section.providers"),info:e("settings.webSearch.section.providersInfo"),settingsItem:"web-search.providers",children:[g.length===0?s.jsx("p",{className:_t,children:e("settings.webSearch.state.noProviders")}):s.jsx("div",{className:li,children:g.map(x=>s.jsx(lb,{entry:x,snapshot:l,onOpen:()=>o(x.provider.id)},x.provider.id))}),l.access===null?s.jsx("p",{className:`${_t} mt-3`,children:e("settings.webSearch.state.keysUnavailable")}):null]})]}):a.kind==="failed"?s.jsx($e,{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(H,{variant:"outline",size:"xs",onClick:()=>{n()},children:e("settings.webSearch.actions.retry")})]})}):s.jsx($e,{divider:!1,children:s.jsx("p",{className:_t,children:e("settings.webSearch.state.loading")})})})}t[4]=n,t[5]=i,t[6]=l,t[7]=a.kind,t[8]=e,t[9]=f,t[10]=p}else f=t[9],p=t[10];return p!==Symbol.for("react.early_return_sentinel")?p:f};function mb(t){return t.setSelection}function pb(t){return t.saveKey}function gb(t){return t.removeKey}function fb(t){return!!t}function hb(t){return s.jsx("span",{className:"block",children:t},t)}function bb(t){const[e,a]=t;return[e,a.trim()]}function xb(t){const[,e]=t;return e!==""}function vb(t,e){return s.jsx("div",{className:"flex",children:t},e)}function yb(t){return t.state}function jb(t){return t.load}const kb=t=>{const e=De.c(183),{onItemSelect:a}=t,{t:n}=Ee(),[i,o]=m.useState(""),[r,c]=m.useState(null),[u,d]=m.useState(""),[l,f]=m.useState(null),[p,g]=m.useState(null),[h,y]=m.useState(!1),[b,x]=m.useState(null),{selectedCommandName:w,setSelectedCommand:S,setCommandDraft:v,createCommand:A,deleteCommand:I,loadCommands:N}=ti(_s(wb)),k=Hs();let P;e[0]!==k?(P=He=>Od(He,k),e[0]=k,e[1]=P):P=e[1];const j=ti(P);let C;e[2]!==k?(C=He=>nl(He,k),e[2]=k,e[3]=C):C=e[3];const E=Js(C),F=Js(Sb);let O,K;e[4]!==N||e[5]!==F||e[6]!==k?(O=()=>{N(k),F(k)},K=[N,F,k],e[4]=N,e[5]=F,e[6]=k,e[7]=O,e[8]=K):(O=e[7],K=e[8]),m.useEffect(O,K);let D;e[9]!==E?(D=new Set(E.map(Nb)),e[9]=E,e[10]=D):D=e[10];const M=D;let T;if(e[11]!==j||e[12]!==M){let He;e[14]!==M?(He=Je=>!M.has(Je.name),e[14]=M,e[15]=He):He=e[15],T=j.filter(He),e[11]=j,e[12]=M,e[13]=T}else T=e[13];const R=T;let $,z;e[16]!==w||e[17]!==S||e[18]!==M?($=()=>{w&&M.has(w)&&S(null)},z=[w,S,M],e[16]=w,e[17]=S,e[18]=M,e[19]=$,e[20]=z):($=e[19],z=e[20]),m.useEffect($,z);let Q;e[21]!==j||e[22]!==a||e[23]!==v||e[24]!==S?(Q=()=>{let He="new-command",Je=1;for(;j.some(mt=>mt.name===He);)He=`new-command-${Je}`,Je++;v({name:He,scope:"user"}),S(He),a?.()},e[21]=j,e[22]=a,e[23]=v,e[24]=S,e[25]=Q):Q=e[25];const V=Q;let L;e[26]!==n?(L=async He=>{if(Qa(He)){q.error(n("settings.commands.sidebar.toast.builtInCannotDelete"));return}f(He),g("delete")},e[26]=n,e[27]=L):L=e[27];const B=L;let W;e[28]===Symbol.for("react.memo_cache_sentinel")?(W=async He=>{Qa(He)&&(f(He),g("reset"))},e[28]=W):W=e[28];const Y=W;let ae;e[29]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>{f(null),g(null)},e[29]=ae):ae=e[29];const ee=ae;let G;e[30]!==l||e[31]!==p||e[32]!==I||e[33]!==k||e[34]!==n?(G=async()=>{if(!l||!p)return;y(!0),await I(l.name,k)?(p==="delete"?q.success(n("settings.commands.sidebar.toast.commandDeleted",{name:l.name})):q.success(n("settings.commands.sidebar.toast.commandReset",{name:l.name})),ee()):p==="delete"?q.error(n("settings.commands.sidebar.toast.deleteFailed")):q.error(n("settings.commands.sidebar.toast.resetFailed")),y(!1)},e[30]=l,e[31]=p,e[32]=I,e[33]=k,e[34]=n,e[35]=G):G=e[35];const le=G;let J;e[36]!==j||e[37]!==v||e[38]!==S?(J=He=>{const Je=He.name;let mt=1,Qe=`${Je}-copy`;for(;j.some(_=>_.name===Qe);)mt++,Qe=`${Je}-copy-${mt}`;v({name:Qe,scope:He.scope||"user",description:He.description,template:He.template,agent:He.agent,model:He.model,subagent:He.subagent}),S(Qe)},e[36]=j,e[37]=v,e[38]=S,e[39]=J):J=e[39];const me=J;let fe;e[40]===Symbol.for("react.memo_cache_sentinel")?(fe=He=>{d(He.name),c(He)},e[40]=fe):fe=e[40];const oe=fe;let pe;e[41]!==j||e[42]!==A||e[43]!==I||e[44]!==r||e[45]!==u||e[46]!==S||e[47]!==k||e[48]!==n?(pe=async()=>{if(!r)return;const He=u.trim().replace(/\s+/g,"-");if(!He){q.error(n("settings.commands.sidebar.toast.commandNameRequired"));return}if(He===r.name){c(null);return}if(j.some(mt=>mt.name===He)){q.error(n("settings.commands.sidebar.toast.commandExists"));return}await A({name:He,description:r.description,template:r.template,agent:r.agent,model:r.model,subagent:r.subagent,scope:r.scope},k)?await I(r.name,k)?(q.success(`Command renamed to "${He}"`),S(He)):q.error(n("settings.commands.sidebar.toast.removeOldAfterRenameFailed")):q.error(n("settings.commands.sidebar.toast.renameFailed")),c(null)},e[41]=j,e[42]=A,e[43]=I,e[44]=r,e[45]=u,e[46]=S,e[47]=k,e[48]=n,e[49]=pe):pe=e[49];const se=pe;let ve,be,ne,we,Ne,Ie;if(e[50]!==R||e[51]!==V||e[52]!==B||e[53]!==me||e[54]!==a||e[55]!==b||e[56]!==i||e[57]!==w||e[58]!==S||e[59]!==n){let He;e[66]!==i?(He=Nt=>Fi([Nt.name,Nt.description],i),e[66]=i,e[67]=He):He=e[67];const Je=R.filter(He),mt=Je.filter(Qa),Qe=Je.filter(Cb);e[68]===Symbol.for("react.memo_cache_sentinel")?(Ne=ze("flex h-full flex-col","bg-background"),e[68]=Ne):Ne=e[68];let _;e[69]!==n?(_=n("settings.commands.sidebar.title"),e[69]=n,e[70]=_):_=e[70];let ge;e[71]!==_?(ge=s.jsx("h2",{className:`${Wn} mb-3`,children:_}),e[71]=_,e[72]=ge):ge=e[72];let Ae;e[73]===Symbol.for("react.memo_cache_sentinel")?(Ae=s.jsx(Qi,{className:"mb-3"}),e[73]=Ae):Ae=e[73];let Te;e[74]!==R.length||e[75]!==n?(Te=n("settings.commands.sidebar.total",{count:R.length}),e[74]=R.length,e[75]=n,e[76]=Te):Te=e[76];let Ge;e[77]!==Te?(Ge=s.jsx("span",{className:"typography-meta text-muted-foreground",children:Te}),e[77]=Te,e[78]=Ge):Ge=e[78];let ue;e[79]===Symbol.for("react.memo_cache_sentinel")?(ue=s.jsx(te,{name:"add",className:"h-3.5 w-3.5"}),e[79]=ue):ue=e[79];let Fe;e[80]!==V?(Fe=s.jsx(H,{size:"sm","data-settings-item":"commands.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:V,children:ue}),e[80]=V,e[81]=Fe):Fe=e[81];let pt;e[82]!==Ge||e[83]!==Fe?(pt=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Ge,Fe]}),e[82]=Ge,e[83]=Fe,e[84]=pt):pt=e[84];let At;e[85]!==R.length||e[86]!==i?(At=R.length>0?s.jsx(fl,{value:i,onChange:o}):null,e[85]=R.length,e[86]=i,e[87]=At):At=e[87],e[88]!==ge||e[89]!==pt||e[90]!==At?(Ie=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[ge,Ae,pt,At]}),e[88]=ge,e[89]=pt,e[90]=At,e[91]=Ie):Ie=e[91],ve=Os,be="flex-1 min-h-0",ne="space-y-1 px-3 py-2",we=R.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx(te,{name:"terminal-box",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:n("settings.commands.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.commands.sidebar.empty.description")})]}):Je.length===0?s.jsx(hl,{query:i}):s.jsxs(s.Fragment,{children:[mt.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:n("settings.commands.sidebar.section.builtIn")}),[...mt].sort(Ib).map(Nt=>s.jsx(cc,{command:Nt,isSelected:w===Nt.name,onSelect:()=>{S(Nt.name),a?.()},onReset:()=>Y(Nt),onDuplicate:()=>me(Nt),isMenuOpen:b===Nt.name,onMenuOpenChange:zt=>x(zt?Nt.name:null)},Nt.name))]}),Qe.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:n("settings.commands.sidebar.section.custom")}),[...Qe].sort(Pb).map(Nt=>s.jsx(cc,{command:Nt,isSelected:w===Nt.name,onSelect:()=>{S(Nt.name),a?.()},onRename:()=>oe(Nt),onDelete:()=>B(Nt),onDuplicate:()=>me(Nt),isMenuOpen:b===Nt.name,onMenuOpenChange:zt=>x(zt?Nt.name:null)},Nt.name))]})]}),e[50]=R,e[51]=V,e[52]=B,e[53]=me,e[54]=a,e[55]=b,e[56]=i,e[57]=w,e[58]=S,e[59]=n,e[60]=ve,e[61]=be,e[62]=ne,e[63]=we,e[64]=Ne,e[65]=Ie}else ve=e[60],be=e[61],ne=e[62],we=e[63],Ne=e[64],Ie=e[65];let Ce;e[92]!==ve||e[93]!==be||e[94]!==ne||e[95]!==we?(Ce=s.jsx(ve,{outerClassName:be,className:ne,children:we}),e[92]=ve,e[93]=be,e[94]=ne,e[95]=we,e[96]=Ce):Ce=e[96];const Me=l!==null&&p!==null;let he;e[97]!==h?(he=He=>{!He&&!h&&ee()},e[97]=h,e[98]=he):he=e[98];let Pe;e[99]!==p||e[100]!==n?(Pe=n(p==="delete"?"settings.commands.sidebar.dialog.deleteTitle":"settings.commands.sidebar.dialog.resetTitle"),e[99]=p,e[100]=n,e[101]=Pe):Pe=e[101];let Re;e[102]!==Pe?(Re=s.jsx(Ot,{children:Pe}),e[102]=Pe,e[103]=Re):Re=e[103];let ce;e[104]!==l?.name||e[105]!==p||e[106]!==n?(ce=p==="delete"?n("settings.commands.sidebar.dialog.deleteDescription",{name:l?.name??""}):n("settings.commands.sidebar.dialog.resetDescription",{name:l?.name??""}),e[104]=l?.name,e[105]=p,e[106]=n,e[107]=ce):ce=e[107];let je;e[108]!==ce?(je=s.jsx(Ft,{children:ce}),e[108]=ce,e[109]=je):je=e[109];let de;e[110]!==Re||e[111]!==je?(de=s.jsxs(Rt,{children:[Re,je]}),e[110]=Re,e[111]=je,e[112]=de):de=e[112];let ie;e[113]!==n?(ie=n("settings.common.actions.cancel"),e[113]=n,e[114]=ie):ie=e[114];let xe;e[115]!==h||e[116]!==ie?(xe=s.jsx(H,{size:"sm",variant:"ghost",onClick:ee,disabled:h,children:ie}),e[115]=h,e[116]=ie,e[117]=xe):xe=e[117];let Se;e[118]!==p||e[119]!==n?(Se=n(p==="delete"?"settings.common.actions.delete":"settings.common.actions.reset"),e[118]=p,e[119]=n,e[120]=Se):Se=e[120];let Le;e[121]!==le||e[122]!==h||e[123]!==Se?(Le=s.jsx(H,{size:"sm",onClick:le,disabled:h,children:Se}),e[121]=le,e[122]=h,e[123]=Se,e[124]=Le):Le=e[124];let Ue;e[125]!==xe||e[126]!==Le?(Ue=s.jsxs(Wt,{children:[xe,Le]}),e[125]=xe,e[126]=Le,e[127]=Ue):Ue=e[127];let Ye;e[128]!==de||e[129]!==Ue?(Ye=s.jsxs(Et,{className:"max-w-md",children:[de,Ue]}),e[128]=de,e[129]=Ue,e[130]=Ye):Ye=e[130];let lt;e[131]!==Me||e[132]!==he||e[133]!==Ye?(lt=s.jsx(Tt,{open:Me,onOpenChange:he,children:Ye}),e[131]=Me,e[132]=he,e[133]=Ye,e[134]=lt):lt=e[134];const at=r!==null;let ut;e[135]===Symbol.for("react.memo_cache_sentinel")?(ut=He=>!He&&c(null),e[135]=ut):ut=e[135];let vt;e[136]!==n?(vt=n("settings.commands.sidebar.renameDialog.title"),e[136]=n,e[137]=vt):vt=e[137];let We;e[138]!==vt?(We=s.jsx(Ot,{children:vt}),e[138]=vt,e[139]=We):We=e[139];const Ze=r?.name??"";let Xe;e[140]!==n||e[141]!==Ze?(Xe=n("settings.commands.sidebar.renameDialog.description",{name:Ze}),e[140]=n,e[141]=Ze,e[142]=Xe):Xe=e[142];let it;e[143]!==Xe?(it=s.jsx(Ft,{children:Xe}),e[143]=Xe,e[144]=it):it=e[144];let dt;e[145]!==We||e[146]!==it?(dt=s.jsxs(Rt,{children:[We,it]}),e[145]=We,e[146]=it,e[147]=dt):dt=e[147];let Be;e[148]===Symbol.for("react.memo_cache_sentinel")?(Be=He=>d(He.target.value),e[148]=Be):Be=e[148];let ot;e[149]!==n?(ot=n("settings.commands.sidebar.renameDialog.placeholder"),e[149]=n,e[150]=ot):ot=e[150];let et;e[151]!==se?(et=He=>{He.key==="Enter"&&se()},e[151]=se,e[152]=et):et=e[152];let ye;e[153]!==u||e[154]!==ot||e[155]!==et?(ye=s.jsx(qe,{value:u,onChange:Be,placeholder:ot,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:et}),e[153]=u,e[154]=ot,e[155]=et,e[156]=ye):ye=e[156];let Z;e[157]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>c(null),e[157]=Z):Z=e[157];let Oe;e[158]!==n?(Oe=n("settings.common.actions.cancel"),e[158]=n,e[159]=Oe):Oe=e[159];let Ve;e[160]!==Oe?(Ve=s.jsx(H,{size:"sm",variant:"ghost",onClick:Z,children:Oe}),e[160]=Oe,e[161]=Ve):Ve=e[161];let X;e[162]!==n?(X=n("settings.common.actions.rename"),e[162]=n,e[163]=X):X=e[163];let _e;e[164]!==se||e[165]!==X?(_e=s.jsx(H,{size:"sm",onClick:se,children:X}),e[164]=se,e[165]=X,e[166]=_e):_e=e[166];let nt;e[167]!==Ve||e[168]!==_e?(nt=s.jsxs(Wt,{children:[Ve,_e]}),e[167]=Ve,e[168]=_e,e[169]=nt):nt=e[169];let ht;e[170]!==dt||e[171]!==ye||e[172]!==nt?(ht=s.jsxs(Et,{children:[dt,ye,nt]}),e[170]=dt,e[171]=ye,e[172]=nt,e[173]=ht):ht=e[173];let yt;e[174]!==at||e[175]!==ht?(yt=s.jsx(Tt,{open:at,onOpenChange:ut,children:ht}),e[174]=at,e[175]=ht,e[176]=yt):yt=e[176];let kt;return e[177]!==Ne||e[178]!==Ie||e[179]!==Ce||e[180]!==lt||e[181]!==yt?(kt=s.jsxs("div",{className:Ne,children:[Ie,Ce,lt,yt]}),e[177]=Ne,e[178]=Ie,e[179]=Ce,e[180]=lt,e[181]=yt,e[182]=kt):kt=e[182],kt},cc=t=>{const e=De.c(47),{command:a,isSelected:n,onSelect:i,onDelete:o,onReset:r,onRename:c,onDuplicate:u,isMenuOpen:d,onMenuOpenChange:l}=t,{t:f}=Ee();let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=tl(),e[0]=p):p=e[0];const g=p,[h,y]=m.useState(!1);let b;e[1]!==o||e[2]!==u||e[3]!==c||e[4]!==r||e[5]!==f?(b=R=>s.jsxs(s.Fragment,{children:[c&&s.jsxs(R,{onClick:$=>{$.stopPropagation(),c()},children:[s.jsx(te,{name:"edit",className:"h-4 w-4 me-px"}),f("settings.common.actions.rename")]}),s.jsxs(R,{onClick:$=>{$.stopPropagation(),u()},children:[s.jsx(te,{name:"file-copy",className:"h-4 w-4 me-px"}),f("settings.common.actions.duplicate")]}),r&&s.jsxs(R,{onClick:$=>{$.stopPropagation(),r()},children:[s.jsx(te,{name:"restart",className:"h-4 w-4 me-px"}),f("settings.common.actions.reset")]}),o&&s.jsxs(R,{onClick:$=>{$.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[s.jsx(te,{name:"delete-bin",className:"h-4 w-4 me-px"}),f("settings.common.actions.delete")]})]}),e[1]=o,e[2]=u,e[3]=c,e[4]=r,e[5]=f,e[6]=b):b=e[6];const x=b,w=n?"bg-interactive-selection":"hover:bg-interactive-hover";let S;e[7]!==w?(S=ze("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",w),e[7]=w,e[8]=S):S=e[8];let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=g?void 0:R=>{R.preventDefault(),y(!0)},e[9]=v):v=e[9];let A;e[10]!==S?(A=s.jsx("div",{className:S,onContextMenu:v}),e[10]=S,e[11]=A):A=e[11];let I;e[12]!==a.name?(I=s.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["/",a.name]}),e[12]=a.name,e[13]=I):I=e[13];let N;e[14]!==a||e[15]!==f?(N=(a.scope||Qa(a))&&s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:Qa(a)?f("settings.agents.sidebar.badge.system"):a.scope}),e[14]=a,e[15]=f,e[16]=N):N=e[16];let k;e[17]!==I||e[18]!==N?(k=s.jsxs("div",{className:"flex items-center gap-2",children:[I,N]}),e[17]=I,e[18]=N,e[19]=k):k=e[19];let P;e[20]!==a.description?(P=a.description&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a.description}),e[20]=a.description,e[21]=P):P=e[21];let j;e[22]!==i||e[23]!==P||e[24]!==k?(j=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:[k,P]}),e[22]=i,e[23]=P,e[24]=k,e[25]=j):j=e[25];let C;e[26]!==l?(C=R=>{R&&y(!1),l(R)},e[26]=l,e[27]=C):C=e[27];let E;e[28]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(ja,{asChild:!0,children:s.jsx(H,{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(te,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[28]=E):E=e[28];let F;e[29]!==x?(F=s.jsx(ya,{align:"end",className:"w-fit min-w-20",children:x(fa)}),e[29]=x,e[30]=F):F=e[30];let O;e[31]!==d||e[32]!==C||e[33]!==F?(O=s.jsxs(ka,{open:d,onOpenChange:C,children:[E,F]}),e[31]=d,e[32]=C,e[33]=F,e[34]=O):O=e[34];let K;e[35]!==j||e[36]!==O?(K=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[j,O]}),e[35]=j,e[36]=O,e[37]=K):K=e[37];let D;e[38]!==K||e[39]!==A?(D=s.jsx(Bi,{render:A,children:K}),e[38]=K,e[39]=A,e[40]=D):D=e[40];let M;e[41]!==x?(M=s.jsx(zi,{className:"w-fit min-w-20",children:x(Ui)}),e[41]=x,e[42]=M):M=e[42];let T;return e[43]!==h||e[44]!==D||e[45]!==M?(T=s.jsxs(Vi,{open:h,onOpenChange:y,children:[D,M]}),e[43]=h,e[44]=D,e[45]=M,e[46]=T):T=e[46],T};function wb(t){return{selectedCommandName:t.selectedCommandName,setSelectedCommand:t.setSelectedCommand,setCommandDraft:t.setCommandDraft,createCommand:t.createCommand,deleteCommand:t.deleteCommand,loadCommands:t.loadCommands}}function Sb(t){return t.loadSkills}function Nb(t){return t.name}function Cb(t){return!Qa(t)}function Ib(t,e){return t.name.localeCompare(e.name)}function Pb(t,e){return t.name.localeCompare(e.name)}const Ab=()=>{const{t}=Ee(),{selectedCommandName:e,getCommandByName:a,createCommand:n,updateCommand:i,commandDraft:o,setCommandDraft:r,setSelectedCommand:c}=ti(_s(L=>({selectedCommandName:L.selectedCommandName,getCommandByName:L.getCommandByName,createCommand:L.createCommand,updateCommand:L.updateCommand,commandDraft:L.commandDraft,setCommandDraft:L.setCommandDraft,setSelectedCommand:L.setSelectedCommand}))),u=Hs(),d=ti(L=>Od(L,u)),l=e?a(e,u):null,f=!!(o&&o.name===e&&!l),[p,g]=m.useState(""),[h,y]=m.useState("user"),[b,x]=m.useState(""),[w,S]=m.useState(""),[v,A]=m.useState(""),[I,N]=m.useState(""),[k,P]=m.useState(!1),[j,C]=m.useState(""),[E,F]=m.useState(!1),O=m.useRef(null),K=JSON.stringify([u,e]),D=m.useRef(null),M=m.useRef(null);m.useEffect(()=>{const L=D.current===K;if(D.current=K,f&&o){const B=o.name||"",W=o.scope||"user",Y=o.description||"",ae=o.agent||"",ee=Mi(o.model),G=ee?`${ee.providerID}/${ee.modelID}`:"",le=ee?.variant||"",J=o.subagent===!0,me=o.template||"";g(B),y(W),x(Y),S(ae),A(G),N(le),P(J),C(me),O.current={draftName:B,draftScope:W,description:Y,agent:ae,model:G,variant:le,subagent:J,template:me}}else if(l){const B=l.description||"",W=l.agent||"",Y=Mi(l.model),ae=Y?`${Y.providerID}/${Y.modelID}`:"",ee=Y?.variant||"",G=l.subagent===!0,le=l.template||"",J=M.current,me=[O.current,J?.identity===K?J.form:null];if(L&&me.some(fe=>fe&&fe.description===B&&fe.agent===W&&fe.model===ae&&fe.variant===ee&&fe.subagent===G&&fe.template===le))return;x(B),S(W),A(ae),N(ee),P(G),C(le),O.current={draftName:"",draftScope:"user",description:B,agent:W,model:ae,variant:ee,subagent:G,template:le}}},[l,f,e,d,o,K]);const T=m.useCallback(L=>{const B=w.trim(),W=Un(v.trim()),Y=W?Yd({providerID:W.providerId,modelID:W.modelId,variant:I.trim()||void 0}):null;return{name:L,description:b.trim()||void 0,agent:B===""?null:B,model:Y,subagent:k,template:j.trim(),scope:f?h:void 0}},[w,b,h,f,v,k,j,I]),R=m.useCallback(async()=>{const L=O.current,B=e?.trim();if(f||!L||!B||b.trim()===L.description.trim()&&w.trim()===L.agent.trim()&&v.trim()===L.model.trim()&&I.trim()===L.variant.trim()&&k===L.subagent&&j.trim()===L.template.trim())return Ls;if(!j.trim())return gs(t("settings.commands.page.toast.templateRequired"));const Y=T(B),ae=Mi(Y.model),ee={identity:K,form:{...L,description:Y.description||"",agent:Y.agent||"",model:ae?`${ae.providerID}/${ae.modelID}`:"",variant:ae?.variant||"",subagent:Y.subagent===!0,template:Y.template||""}};M.current=ee;try{return await i(B,Y,u)?(D.current===K&&(O.current=ee.form),In):gs(t("settings.commands.page.toast.updateFailed"))}finally{M.current===ee&&(M.current=null)}},[w,T,b,K,f,v,e,u,k,t,j,i,I]),$=ci(R),{requestSave:z}=$,Q=async()=>{const L=p.trim().replace(/\s+/g,"-");if(!L){q.error(t("settings.commands.sidebar.toast.commandNameRequired"));return}if(!j.trim()){q.error(t("settings.commands.page.toast.templateRequired"));return}if(d.some(B=>B.name===L)){q.error(t("settings.commands.sidebar.toast.commandExists"));return}F(!0);try{await n(T(L),u)?(r(null),q.success(t("settings.commands.page.toast.created"))):q.error(t("settings.commands.page.toast.createFailed"))}catch(B){console.error("Error creating command:",B),q.error(t("settings.commands.page.toast.saveUnexpectedError"))}finally{F(!1)}},V=()=>{r(null),c(null)};return e?s.jsxs(qt,{title:f?t("settings.commands.page.title.new"):`/${e}`,description:t(f?"settings.commands.page.subtitle.new":"settings.commands.page.subtitle.edit"),onBlurCapture:$.onBlurCapture,children:[!f&&l&&s.jsx(bl,{legacy:l.legacy===!0,path:l.path}),s.jsxs($e,{title:t("settings.commands.page.section.identity"),divider:!1,contentClassName:"space-y-0",children:[f&&s.jsxs(st,{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:p,onChange:L=>g(L.target.value),placeholder:t("settings.commands.page.field.commandNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Pt,{value:h,onValueChange:L=>y(L),children:[s.jsx(Ct,{className:"w-fit min-w-[100px]",children:s.jsx(Kt,{placeholder:t("settings.agents.page.field.scopePlaceholder")})}),s.jsxs(It,{align:"end",children:[s.jsx(bt,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(te,{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(te,{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(Cs,{value:b,onChange:L=>x(L.target.value),placeholder:t("settings.commands.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})})]})]}),s.jsxs($e,{title:t("settings.commands.page.section.executionContext"),contentClassName:"space-y-0",children:[s.jsx(st,{settingsItem:"commands.agent",label:t("settings.commands.page.field.overrideAgent"),children:s.jsx(al,{agentName:w,onChange:L=>{S(L),z()},className:an})}),s.jsx(st,{settingsItem:"commands.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(Fa,{providerId:Un(v)?.providerId??"",modelId:Un(v)?.modelId??"",onChange:(L,B)=>{A(L&&B?`${L}/${B}`:""),z()},className:an})}),s.jsx(st,{settingsItem:"commands.variant",label:t("settings.agents.page.field.variant"),info:t("settings.agents.page.field.variantTooltip"),children:s.jsx(qe,{value:I,onChange:L=>N(L.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!v&&!I,className:"h-8 w-40 rounded-md px-3"})}),s.jsx(st,{settingsItem:"commands.subagent",label:t("settings.commands.page.field.subagent"),info:t("settings.commands.page.field.subagentTooltip"),children:s.jsx(La,{checked:k,onCheckedChange:L=>{P(L),z()},"aria-label":t("settings.commands.page.field.subagent")})})]}),s.jsxs($e,{title:t("settings.commands.page.section.template"),settingsItem:"commands.template",children:[s.jsx(Cs,{value:j,onChange:L=>C(L.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")]}),f&&s.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[s.jsx(H,{onClick:()=>{Q()},disabled:E||!p.trim()||!j.trim(),size:"xs",className:"!font-normal",children:t(E?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(H,{variant:"ghost",onClick:V,disabled:E,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(te,{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 Gs(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function xi(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function kn(t,e){return e!==void 0?{ok:!1,error:t,parsed:e}:{ok:!1,error:t}}function lo(t,e,a){const n=Eb(a),i=typeof a.url=="string"?a.url.trim():"",o=dc(a,"env","environment"),r=dc(a,"headers"),c=Gs(a.oauth)?a.oauth:null,u=vi(c,"client_id","clientId"),d=vi(c,"client_secret","clientSecret"),l=vi(c,"scope"),f=vi(c,"redirect_uri","redirectUri"),p=Tb(c,"callback_port","callbackPort"),g=vi(c,"auth_server_metadata_url","authServerMetadataUrl"),h=a.oauth===!1||a.oauth===null||a.oauth===void 0?!1:!!c&&!!(u||d||l||f||p||g),y=Mb(a);return{ok:!0,name:t,type:e,command:n,url:i,environment:o,headers:r,oauthEnabled:h,oauthClientId:u,oauthClientSecret:d,oauthScope:l,oauthRedirectUri:f,oauthCallbackPort:p,oauthAuthServerMetadataUrl:g,timeoutStartup:y.startup,timeoutCatalog:y.catalog,timeoutExecution:y.execution,codemode:a.codemode===!0?"on":a.codemode===!1?"off":"default",disabled:Db(a),protocol:Mr.find(b=>b===a.protocol)??"legacy"}}function vi(t,...e){if(!t)return"";for(const a of e){const n=t[a];if(typeof n=="string"&&n.trim())return n.trim()}return""}function Tb(t,...e){if(!t)return"";for(const a of e){const n=Ci(t[a]);if(n)return n}return""}function Ci(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 Eb(t){const e=t.command,a=t.args;if(xi(e)&&xi(a))return[...e,...a];if(xi(e))return e;if(typeof e=="string"&&e.trim()){const n=e.trim().split(/\s+/);return xi(a)?[...n,...a]:n}return xi(a)?a:[]}function dc(t,...e){for(const a of e){const n=t[a];if(!Gs(n))continue;const i=Object.entries(n).filter(([o,r])=>o&&typeof r=="string");if(i.length>0)return i.map(([o,r])=>({key:o,value:String(r)}))}return[]}function Mb(t){return Gs(t.timeout)?{startup:Ci(t.timeout.startup),catalog:Ci(t.timeout.catalog),execution:Ci(t.timeout.execution)}:{startup:"",catalog:"",execution:Ci(t.timeout)}}function Db(t){return t.disabled===!0?!0:t.disabled===!1?!1:"enabled"in t?!t.enabled:!1}function Rb(t){const e=t.mcpServers;if(Gs(e)){const n=Object.keys(e);if(n.length===1){const i=n[0],o=e[i];if(Gs(o))return{name:i,entry:o}}if(n.length>1)return null}const a=Object.keys(t).filter(n=>{const i=t[n];return n!=="mcpServers"&&Gs(i)});if(a.length===1){const n=a[0],i=t[n];if(bu(i))return{name:n,entry:i}}return null}function bu(t){return t.type==="local"||t.type==="remote"||Array.isArray(t.command)||typeof t.url=="string"||Array.isArray(t.args)}function Ob(t,e){let a;try{const u=t.trim();if(!u)return kn("No JSON content provided");a=JSON.parse(u)}catch(u){return kn(u instanceof Error?`Invalid JSON: ${u.message}`:"Invalid JSON")}if(!Gs(a))return kn("Expected a JSON object, not an array or primitive");const n=a,i=n.mcpServers;if(Gs(i)){const u=Object.keys(i);if(u.length===0)return kn("mcpServers object is empty",a);if(u.length>1)return kn("Paste one server at a time. Found "+u.length+" servers in mcpServers",a);const d=u[0],l=i[d];return Gs(l)?lo(d,co(l),l):kn("Server entry is not a valid object",a)}const o=n.mcp,r=Gs(o)&&Gs(o.servers)?o.servers:o;if(Gs(r)){const u=Object.keys(r);if(u.length===0)return kn("mcp object is empty",a);if(u.length>1)return kn("Paste one server at a time. Found "+u.length+" servers in mcp",a);const d=u[0],l=r[d];return Gs(l)?lo(d,co(l),l):kn("Server entry in mcp is not a valid object",a)}const c=Rb(n);if(c)return lo(c.name,co(c.entry),c.entry);if(bu(n)){const u=co(n),d=typeof n.name=="string"&&n.name.trim()?n.name.trim():e?.fallbackName;return lo(d,u,n)}return kn("No recognizable MCP server configuration found in JSON",a)}function co(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 Fb(t,e,a){const n=a?.isNewServer??!1,i=t.name?Rf(t.name):void 0,o=n&&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 uc=[],vl=t=>{const e=De.c(5),[a,n]=m.useState(uc);let i,o;e[0]!==t?(i=()=>{let c=!1;return n(uc),Qs.getIntegrationPolicies(t).then(u=>{c||n(u)}).catch(Lb),()=>{c=!0}},o=[t],e[0]=t,e[1]=i,e[2]=o):(i=e[1],o=e[2]),m.useEffect(i,o);let r;return e[3]!==a?(r=c=>hg(a,c),e[3]=a,e[4]=r):r=e[4],r};function Lb(t){console.warn("[settings] could not read OpenCode integration policies:",t instanceof Error?t.message:String(t))}const Kb=t=>{const e="new-mcp-server";let a=e,n=1;for(;t.some(i=>i.name===a);)a=`${e}-${n}`,n+=1;return a},_b=t=>{const e=De.c(13),{status:a,enabled:n,blocked:i}=t,{t:o}=Ee();if(i){let d;e[0]!==o?(d=o("settings.mcp.grid.status.blockedByPolicy"),e[0]=o,e[1]=d):d=e[1];let l;return e[2]!==d?(l=s.jsx(js,{tone:"warning",children:d}),e[2]=d,e[3]=l):l=e[3],l}if(!n){let d;e[4]!==o?(d=o("settings.mcp.grid.status.disabled"),e[4]=o,e[5]=d):d=e[5];let l;return e[6]!==d?(l=s.jsx(js,{tone:"neutral",children:d}),e[6]=d,e[7]=l):l=e[7],l}let r;e[8]!==a||e[9]!==o?(r=a==="connected"?{tone:"success",label:o("settings.mcp.page.status.label.connected")}:a==="failed"?{tone:"error",label:o("settings.mcp.page.status.label.failed")}:a==="needs_auth"?{tone:"warning",label:o("settings.mcp.page.status.label.needsAuth")}:a==="pending"?{tone:"neutral",label:o("settings.mcp.grid.status.pending")}:null,e[8]=a,e[9]=o,e[10]=r):r=e[10];const c=r;let u;return e[11]!==c?(u=c?s.jsx(js,{tone:c.tone,children:c.label}):null,e[11]=c,e[12]=u):u=e[12],u},$b=()=>{const t=De.c(132),{t:e}=Ee(),a=Hs(),{setSelectedMcp:n,setMcpDraft:i,loadMcpConfigs:o,deleteMcp:r}=$n(_s(zb)),[c,u]=m.useState(null),[d,l]=m.useState(!1);let f;t[0]!==a?(f=Ce=>sl(Ce,a),t[0]=a,t[1]=f):f=t[1];const p=$n(f);let g;t[2]!==a?(g=Ce=>Ce.getStatusForDirectory(a),t[2]=a,t[3]=g):g=t[3];const h=gn(g),y=vl(a),b=gn(Ub),x=gn(Bb),[w,S]=m.useState(!1),[v,A]=m.useState("");let I,N;t[4]!==o||t[5]!==a?(I=()=>{o({directory:a})},N=[o,a],t[4]=o,t[5]=a,t[6]=I,t[7]=N):(I=t[6],N=t[7]),m.useEffect(I,N);let k;t[8]!==x||t[9]!==w||t[10]!==b||t[11]!==a?(k=()=>{if(w)return;S(!0);const Ce=new Promise(Vb);Promise.all([b({directory:a,silent:!0}),Ce]).then(()=>{const Me=x(a);Me&&q.error(Me)}).finally(()=>S(!1))},t[8]=x,t[9]=w,t[10]=b,t[11]=a,t[12]=k):k=t[12];const P=k;let j;t[13]!==p||t[14]!==i||t[15]!==n?(j=()=>{const Ce=Kb(p),Me={name:Ce,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],...du,oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1};i(Me),n(Ce)},t[13]=p,t[14]=i,t[15]=n,t[16]=j):j=t[16];const C=j;let E;t[17]!==r||t[18]!==c||t[19]!==a||t[20]!==e?(E=async()=>{if(!c)return;const Ce=c;l(!0);const Me=await r(Ce,a);Me.ok?(Me.reloadFailed?q.warning(Me.message||e("settings.mcp.page.toast.serverDeletedReloadFailed",{name:Ce}),{description:Me.warning||e("settings.mcp.page.toast.refreshListIfStale")}):q.success(Me.message||e("settings.mcp.page.toast.serverDeleted",{name:Ce})),u(null)):q.error(e("settings.mcp.page.toast.deleteFailed")),l(!1)},t[17]=r,t[18]=c,t[19]=a,t[20]=e,t[21]=E):E=t[21];const F=E;let O,K,D,M,T,R,$,z,Q;if(t[22]!==C||t[23]!==P||t[24]!==y||t[25]!==w||t[26]!==h||t[27]!==v||t[28]!==p||t[29]!==i||t[30]!==n||t[31]!==e){const Ce=wa([...p],v,Hb);let Me;t[41]!==v?(Me=v.trim(),t[41]=v,t[42]=Me):Me=t[42];const he=Me.length>0;O=qt,t[43]!==e?(K=e("settings.page.mcp.title"),t[43]=e,t[44]=K):K=t[44],t[45]!==e?(D=e("settings.mcp.grid.description"),t[45]=e,t[46]=D):D=t[46];let Pe;t[47]===Symbol.for("react.memo_cache_sentinel")?(Pe=s.jsx(Qi,{className:"min-w-0 flex-1 @xl:w-56 @xl:flex-none"}),t[47]=Pe):Pe=t[47];let Re;t[48]!==e?(Re=e("settings.mcp.sidebar.actions.refreshStatusAria"),t[48]=e,t[49]=Re):Re=t[49];let ce;t[50]!==e?(ce=e("settings.mcp.sidebar.actions.refreshStatusTitle"),t[50]=e,t[51]=ce):ce=t[51];const je=w&&"animate-spin";let de;t[52]!==je?(de=ze("size-4",je),t[52]=je,t[53]=de):de=t[53];let ie;t[54]!==de?(ie=s.jsx(te,{name:"refresh",className:de}),t[54]=de,t[55]=ie):ie=t[55],t[56]!==P||t[57]!==w||t[58]!==Re||t[59]!==ce||t[60]!==ie?(M=s.jsxs("div",{className:"flex w-full items-center gap-2 @xl:w-auto",children:[Pe,s.jsx(H,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0 text-muted-foreground",disabled:w,onClick:P,"aria-label":Re,title:ce,children:ie})]}),t[56]=P,t[57]=w,t[58]=Re,t[59]=ce,t[60]=ie,t[61]=M):M=t[61],t[62]!==v||t[63]!==p.length||t[64]!==e?(T=p.length>0?s.jsx(Qo,{value:v,onChange:A,placeholder:e("settings.mcp.grid.searchPlaceholder")}):null,t[62]=v,t[63]=p.length,t[64]=e,t[65]=T):T=t[65],R=p.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:e("settings.mcp.grid.empty")}):Ce.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:e("settings.mcp.grid.noMatches",{query:v.trim()})}):null,$=li,t[66]!==C||t[67]!==he||t[68]!==e?(z=he?null:s.jsx(Gi,{label:e("settings.mcp.sidebar.actions.addServerTitle"),hint:e("settings.mcp.grid.addHint"),onClick:C,settingsItem:"mcp.create"}),t[66]=C,t[67]=he,t[68]=e,t[69]=z):z=t[69];let xe;t[70]!==y||t[71]!==h||t[72]!==i||t[73]!==n||t[74]!==e?(xe=Se=>{const Le=Se.disabled!==!0,Ue=y(`mcp:${Se.name}`),Ye=Se.type==="local"?Se.command?.join(" "):Se.url;return s.jsx(qn,{icon:s.jsx(Eo,{name:Se.type==="local"?"server":"global"}),title:Se.name,subtitle:Ye||void 0,badges:s.jsx(_b,{status:h[Se.name]?.status.status,enabled:Le,blocked:Ue}),muted:!Le||Ue,footer:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Se.type==="local"?e("settings.mcp.sidebar.serverType.localTitle"):e("settings.mcp.sidebar.serverType.remoteTitle")}),Se.scope==="project"?s.jsx($i,{children:e("settings.mcp.grid.scope.project")}):null]}),onOpen:()=>{i(null),n(Se.name)},actionsLabel:e("settings.mcp.grid.actionsAria",{name:Se.name}),actions:[{label:e("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onSelect:()=>u(Se.name)}]},Se.name)},t[70]=y,t[71]=h,t[72]=i,t[73]=n,t[74]=e,t[75]=xe):xe=t[75],Q=Ce.map(xe),t[22]=C,t[23]=P,t[24]=y,t[25]=w,t[26]=h,t[27]=v,t[28]=p,t[29]=i,t[30]=n,t[31]=e,t[32]=O,t[33]=K,t[34]=D,t[35]=M,t[36]=T,t[37]=R,t[38]=$,t[39]=z,t[40]=Q}else O=t[32],K=t[33],D=t[34],M=t[35],T=t[36],R=t[37],$=t[38],z=t[39],Q=t[40];let V;t[76]!==$||t[77]!==z||t[78]!==Q?(V=s.jsxs("div",{className:$,children:[z,Q]}),t[76]=$,t[77]=z,t[78]=Q,t[79]=V):V=t[79];const L=c!==null;let B;t[80]!==d?(B=Ce=>{!Ce&&!d&&u(null)},t[80]=d,t[81]=B):B=t[81];const W=c??"";let Y;t[82]!==e||t[83]!==W?(Y=e("settings.mcp.page.deleteDialog.title",{name:W}),t[82]=e,t[83]=W,t[84]=Y):Y=t[84];let ae;t[85]!==Y?(ae=s.jsx(Ot,{children:Y}),t[85]=Y,t[86]=ae):ae=t[86];let ee;t[87]!==e?(ee=e("settings.mcp.page.deleteDialog.descriptionPrefix"),t[87]=e,t[88]=ee):ee=t[88];let G;t[89]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx("code",{className:"text-foreground",children:"opencode.json"}),t[89]=G):G=t[89];let le;t[90]!==e?(le=e("settings.mcp.page.deleteDialog.descriptionSuffix"),t[90]=e,t[91]=le):le=t[91];let J;t[92]!==ee||t[93]!==le?(J=s.jsxs(Ft,{children:[ee," ",G,"."," ",le]}),t[92]=ee,t[93]=le,t[94]=J):J=t[94];let me;t[95]!==ae||t[96]!==J?(me=s.jsxs(Rt,{children:[ae,J]}),t[95]=ae,t[96]=J,t[97]=me):me=t[97];let fe;t[98]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>u(null),t[98]=fe):fe=t[98];let oe;t[99]!==e?(oe=e("settings.common.actions.cancel"),t[99]=e,t[100]=oe):oe=t[100];let pe;t[101]!==d||t[102]!==oe?(pe=s.jsx(H,{variant:"outline",size:"sm",onClick:fe,disabled:d,children:oe}),t[101]=d,t[102]=oe,t[103]=pe):pe=t[103];let se;t[104]!==F?(se=()=>{F()},t[104]=F,t[105]=se):se=t[105];let ve;t[106]!==d||t[107]!==e?(ve=e(d?"settings.mcp.page.actions.deleting":"settings.common.actions.delete"),t[106]=d,t[107]=e,t[108]=ve):ve=t[108];let be;t[109]!==d||t[110]!==se||t[111]!==ve?(be=s.jsx(H,{variant:"destructive",size:"sm",onClick:se,disabled:d,children:ve}),t[109]=d,t[110]=se,t[111]=ve,t[112]=be):be=t[112];let ne;t[113]!==pe||t[114]!==be?(ne=s.jsxs(Wt,{children:[pe,be]}),t[113]=pe,t[114]=be,t[115]=ne):ne=t[115];let we;t[116]!==me||t[117]!==ne?(we=s.jsxs(Et,{className:"max-w-md",children:[me,ne]}),t[116]=me,t[117]=ne,t[118]=we):we=t[118];let Ne;t[119]!==L||t[120]!==B||t[121]!==we?(Ne=s.jsx(Tt,{open:L,onOpenChange:B,children:we}),t[119]=L,t[120]=B,t[121]=we,t[122]=Ne):Ne=t[122];let Ie;return t[123]!==O||t[124]!==K||t[125]!==D||t[126]!==M||t[127]!==T||t[128]!==R||t[129]!==V||t[130]!==Ne?(Ie=s.jsxs(O,{title:K,description:D,headerEnd:M,children:[T,R,V,Ne]}),t[123]=O,t[124]=K,t[125]=D,t[126]=M,t[127]=T,t[128]=R,t[129]=V,t[130]=Ne,t[131]=Ie):Ie=t[131],Ie};function zb(t){return{setSelectedMcp:t.setSelectedMcp,setMcpDraft:t.setMcpDraft,loadMcpConfigs:t.loadMcpConfigs,deleteMcp:t.deleteMcp}}function Ub(t){return t.refresh}function Bb(t){return t.getErrorForDirectory}function Vb(t){return setTimeout(t,500)}function Hb(t){return[t.name,t.type==="local"?t.command?.join(" ")??"":t.url??""]}const cr=t=>t===void 0?"":String(t),dr=t=>{const e=t.trim();if(!e)return null;const a=Number(e);return!Number.isFinite(a)||a<=0?null:a%1e3===0?`${a/1e3}s`:`${a}ms`},ur={legacy:"settings.mcp.page.advanced.protocolOption.legacy",auto:"settings.mcp.page.advanced.protocolOption.auto","2026-07-28":"settings.mcp.page.advanced.protocolOption.revision20260728"},mc={default:"settings.mcp.page.advanced.codemodeOption.default",on:"settings.mcp.page.advanced.codemodeOption.on",off:"settings.mcp.page.advanced.codemodeOption.off"},qb=t=>{try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}},yi=t=>t?.status.status,mr=t=>t?.status.status==="failed"||t?.status.status==="needs_auth"?t.status.error:void 0;function xu(t){const e=[];let a="",n=!1,i=!1;for(let o=0;o<t.length;o++){const r=t[o];if(r==="'"&&!i){n=!n;continue}if(r==='"'&&!n){i=!i;continue}if((r===" "||r===" ")&&!n&&!i){a&&(e.push(a),a="");continue}a+=r}return a&&e.push(a),e}const Wb=t=>{const e=De.c(27),{value:a,onChange:n,preview:i,onDetectUrl:o}=t;let r;e[0]!==a?(r=()=>a.join(`
5
5
  `),e[0]=a,e[1]=r):r=e[1];const[c,u]=m.useState(r),d=m.useRef(a);let l,f;e[2]!==a?(l=()=>{JSON.stringify(d.current)!==JSON.stringify(a)&&(d.current=a,u(a.join(`
@@ -27,4 +27,4 @@ ${n}`:`
27
27
  `}`},Mv=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Iu=t=>{const e=t.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!e)return{description:null,instructions:t};let a=null;try{const n=Wf(e[1]);if(Mv(n)){const i=n.description;typeof i=="string"&&(a=i)}}catch{a=null}return{description:a,instructions:e[2].replace(/^\r?\n/,"")}},Dv=(t,e)=>{const a=Iu(t);return ko(e,a.instructions)},Rv=()=>{const{t}=Ee(),{currentTheme:e}=za(),{selectedSkillName:a,getSkillByName:n,getSkillDetail:i,createSkill:o,updateSkill:r,skillDraft:c,setSkillDraft:u,setSelectedSkill:d}=Js(_s(ye=>({selectedSkillName:ye.selectedSkillName,getSkillByName:ye.getSkillByName,getSkillDetail:ye.getSkillDetail,createSkill:ye.createSkill,updateSkill:ye.updateSkill,skillDraft:ye.skillDraft,setSkillDraft:ye.setSkillDraft,setSelectedSkill:ye.setSelectedSkill}))),l=Hs(),f=Js(ye=>nl(ye,l)),p=a?n(a,l):null,g=!!(c&&c.name===a&&!p),h=!!(a&&!p&&!c),y=p?.path==="<built-in>";m.useEffect(()=>{h&&d(null)},[h,d]);const[b,x]=m.useState(""),[w,S]=m.useState("user"),[v,A]=m.useState("opencode"),[I,N]=m.useState(""),[k,P]=m.useState(""),[j,C]=m.useState(!1),[E,F]=m.useState(()=>ko("","")),[O,K]=m.useState("edit"),[D,M]=m.useState([]),[T,R]=m.useState([]),[$,z]=m.useState(!1),[Q,V]=m.useState(!1),[L,B]=m.useState(""),[W,Y]=m.useState(""),[ae,ee]=m.useState(!1),[G,le]=m.useState(!1),[J,me]=m.useState(""),[fe,oe]=m.useState(""),[pe,se]=m.useState(null),[ve,be]=m.useState(!1),[ne,we]=m.useState(""),[Ne,Ie]=m.useState(null),[Ce,Me]=m.useState(!1),he=pe?fe!==ne:J.trim()!=="",Pe=m.useCallback(ye=>{switch(ye){case"project-opencode":return t("settings.skills.location.option.projectOpencode.label");case"user-claude":return t("settings.skills.location.option.userClaude.label");case"project-claude":return t("settings.skills.location.option.projectClaude.label");case"user-agents":return t("settings.skills.location.option.userAgents.label");case"project-agents":return t("settings.skills.location.option.projectAgents.label");default:return t("settings.skills.location.option.userOpencode.label")}},[t]),Re=m.useCallback(ye=>{switch(ye){case"project-opencode":return t("settings.skills.location.option.projectOpencode.description");case"user-claude":return t("settings.skills.location.option.userClaude.description");case"project-claude":return t("settings.skills.location.option.projectClaude.description");case"user-agents":return t("settings.skills.location.option.userAgents.description");case"project-agents":return t("settings.skills.location.option.projectAgents.description");default:return t("settings.skills.location.option.userOpencode.description")}},[t]),ce=JSON.stringify([l,a,p?.path,g]),je=m.useRef(null),de=m.useRef({key:ce,markdown:E,disableModelInvocation:j});de.current={key:ce,markdown:E,disableModelInvocation:j};const ie=m.useRef(""),xe=m.useRef(!1);m.useEffect(()=>{let ye=!1;const Z=(Ve,X,_e)=>{if(de.current.key!==ce)return;const nt=ko(Ve,X),ht=je.current===ce,yt=ht&&de.current.markdown!==ie.current,kt=ht&&de.current.disableModelInvocation!==xe.current;je.current=ce,ie.current=nt,xe.current=_e,yt||(N(Ve),P(X),F(nt)),kt||C(_e)};return(async()=>{if(g&&c){V(!1);const Ve=c.description||"",X=c.instructions||"";x(c.name||""),S(c.scope||"user"),A(c.source==="agents"?"agents":"opencode"),Z(Ve,X,!1),B(""),Y(""),ee(!1),M([]),R(c.pendingFiles||[])}else if(a&&p){V(je.current!==ce);try{const Ve=await i(a,l);if(!ye&&de.current.key===ce&&Ve){const X=Ve.sources.md,_e=X.description||"",nt=X.instructions||"",ht=X.disableModelInvocation===!0;Z(_e,nt,ht),B(_e),Y(nt),ee(ht),M(X.supportingFiles||[])}}catch(Ve){console.error("Failed to load skill details:",Ve)}finally{ye||V(!1)}}})(),()=>{ye=!0}},[p,g,a,l,f,c,i,ce]);const Se=re(ye=>ye.editorFontSize),Le=m.useMemo(()=>{const ye=[ec(e,{fontSize:Se})],Z=Ml(Tv);return Z&&ye.push(Z),ye.push(sc.lineWrapping),ye},[e,Se]),Ue=m.useMemo(()=>{const ye=J.trim()||"supporting-file.md",Z=Rm(ye),Oe=!!Z&&Z!=="markdown",Ve=[ec(e,Oe?{syntaxColors:!1,fontSize:Se}:{fontSize:Se})],X=Ml(ye);return X&&Ve.push(X),Oe&&Z&&Ve.push(Qf({language:Z,themeName:e.metadata.id,theme:Yf(e)})),Ve.push(sc.lineWrapping),Ve},[e,J,Se]),Ye=m.useCallback(ye=>{N(ye),F(Z=>Dv(Z,ye))},[]),lt=m.useCallback(ye=>{F(ye);const Z=Iu(ye);N(Z.description??""),P(Z.instructions)},[]),at=ye=>ye?!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(ye)||ye.length>64?t("settings.skills.page.toast.invalidSkillName"):null:t("settings.skills.page.toast.skillNameRequired"),ut=m.useCallback(async()=>{const ye=a?.trim();return g||y||!ye||I===L&&k===W&&j===ae?Ls:I.trim()?await r(ye,{name:ye,description:I.trim(),instructions:k.trim()||void 0,targetPath:p?.path,disableModelInvocation:j},l)?(de.current.key===ce&&(ie.current=ko(I,k),xe.current=j,B(I),Y(k),ee(j)),In):gs(t("settings.skills.page.toast.updateSkillFailed")):gs(t("settings.skills.page.toast.descriptionRequired"))},[I,k,j,g,y,L,W,ae,p?.path,a,l,ce,t,r]),vt=ci(ut),We=ye=>{C(ye),g||vt.requestSave()},Ze=async()=>{const ye=b.trim().replace(/\s+/g,"-").toLowerCase(),Z=at(ye);if(Z){q.error(Z);return}if(!I.trim()){q.error(t("settings.skills.page.toast.descriptionRequired"));return}if(f.some(Oe=>Oe.name===ye)){q.error(t("settings.skills.page.toast.skillExists"));return}z(!0);try{const Oe={name:ye,description:I.trim(),instructions:k.trim()||void 0,scope:w,source:v,supportingFiles:T.length>0?T:void 0,disableModelInvocation:j};await o(Oe,l)?(u(null),R([]),d(ye),q.success(t("settings.skills.page.toast.skillCreated"))):q.error(t("settings.skills.page.toast.createSkillFailed"))}catch(Oe){console.error("Error creating skill:",Oe),q.error(t("settings.skills.page.toast.saveUnexpectedError"))}finally{z(!1)}},Xe=()=>{u(null),d(null)},it=()=>{se(null),me(""),oe(""),we(""),le(!0)},dt=async ye=>{if(se(ye),me(ye),g){const Oe=T.find(Ve=>Ve.path===ye)?.content||"";oe(Oe),we(Oe),le(!0);return}if(a){be(!0),le(!0);try{const{readSupportingFile:Z}=Js.getState(),Oe=await Z(a,ye,l);oe(Oe||""),we(Oe||"")}catch{q.error(t("settings.skills.page.toast.loadFileContentFailed")),oe(""),we("")}finally{be(!1)}}},Be=async()=>{if(!J.trim()){q.error(t("settings.skills.page.toast.fileNameRequired"));return}const ye=J.trim(),Z=pe!==null;if(g){if(Z)R(X=>X.map(_e=>_e.path===pe?{path:ye,content:fe}:_e)),q.success(t("settings.skills.page.toast.fileUpdated",{path:ye}));else{if(T.some(X=>X.path===ye)){q.error(t("settings.skills.page.toast.fileExists"));return}R(X=>[...X,{path:ye,content:fe}]),q.success(t("settings.skills.page.toast.fileAdded",{path:ye}))}le(!1),se(null);return}if(!a){q.error(t("settings.skills.page.toast.noSkillSelected"));return}const{writeSupportingFile:Oe}=Js.getState();if(await Oe(a,ye,fe,l)){q.success(Z?t("settings.skills.page.toast.fileUpdated",{path:ye}):t("settings.skills.page.toast.fileCreated",{path:ye})),le(!1),se(null);const X=await i(a,l);X&&M(X.sources.md.supportingFiles||[])}else q.error(t(Z?"settings.skills.page.toast.updateFileFailed":"settings.skills.page.toast.createFileFailed"))},ot=ye=>{if(g){R(Z=>Z.filter(Oe=>Oe.path!==ye)),q.success(t("settings.skills.page.toast.fileRemoved",{path:ye}));return}a&&Ie(ye)},et=async()=>{if(!Ne||!a)return;Me(!0);const{deleteSupportingFile:ye}=Js.getState();if(await ye(a,Ne,l)){q.success(t("settings.skills.page.toast.fileDeleted",{path:Ne}));const Oe=await i(a,l);Oe&&M(Oe.sources.md.supportingFiles||[]),Ie(null)}else q.error(t("settings.skills.page.toast.deleteFileFailed"));Me(!1)};return!a&&!c||h?s.jsx("div",{className:"flex h-full items-center justify-center px-4",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(te,{name:"book-open",className:"mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50"}),s.jsx("p",{className:"typography-ui-label",children:t("settings.skills.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.skills.page.empty.description")})]})}):Q?s.jsx("div",{className:"flex h-full items-center justify-center px-4",children:s.jsx("div",{className:"text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label",children:t("settings.skills.page.loading.details")})})}):s.jsxs(s.Fragment,{children:[s.jsxs(qt,{title:g?t("settings.skills.page.title.newSkill"):a,description:p?t("settings.skills.page.subtitle.skillLocation",{location:Pe(Ri(p.scope,p.source))}):t("settings.skills.page.subtitle.newSkill"),onBlurCapture:vt.onBlurCapture,children:[s.jsxs($e,{title:t("settings.skills.page.section.basicInformation"),divider:!1,settingsItem:"skills.basic-information",contentClassName:"space-y-0",children:[g&&s.jsxs(st,{label:t("settings.skills.page.field.skillNameLocation"),info:t("settings.skills.page.field.skillNameHint"),children:[s.jsx(qe,{value:b,onChange:ye=>x(ye.target.value.toLowerCase().replace(/\s+/g,"-")),placeholder:t("settings.skills.page.field.skillNamePlaceholder"),className:"h-7 w-40 px-2"}),s.jsxs(Pt,{value:Ri(w,v),onValueChange:ye=>{const Z=Cu(ye);S(Z.scope),A(Z.source==="agents"?"agents":"opencode")},children:[s.jsxs(Ct,{className:"w-fit gap-1.5",children:[w==="user"?s.jsx(te,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx(te,{name:"folder",className:"h-3.5 w-3.5"}),v==="agents"?s.jsx(te,{name:"robot-2",className:"h-3.5 w-3.5"}):null,s.jsx("span",{children:Pe(Ri(w,v))})]}),s.jsx(It,{align:"start",children:Oo.map(ye=>s.jsx(bt,{value:ye.value,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[ye.scope==="user"?s.jsx(te,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx(te,{name:"folder",className:"h-3.5 w-3.5"}),ye.source==="agents"?s.jsx(te,{name:"robot-2",className:"h-3.5 w-3.5"}):null,s.jsx("span",{children:Pe(ye.value)})]}),s.jsx("span",{className:"typography-micro text-muted-foreground ms-6",children:Re(ye.value)})]})},ye.value))})]})]}),s.jsx(St,{label:s.jsxs(s.Fragment,{children:[t("settings.common.field.description")," ",s.jsx("span",{className:"text-[var(--status-error)]",children:"*"})]}),info:t("settings.skills.page.field.descriptionHint"),controlClassName:"w-full max-w-none",children:s.jsx(Cs,{value:I,onChange:ye=>Ye(ye.target.value),placeholder:t("settings.skills.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent",disabled:y})}),s.jsx(ct,{checked:j,onChange:We,label:t("settings.skills.page.field.disableModelInvocation"),info:t("settings.skills.page.field.disableModelInvocationHint"),disabled:y,className:"pt-2"})]}),s.jsx($e,{title:t("settings.skills.page.section.instructions"),headerAction:s.jsx(Gf,{currentMode:O==="preview"?"preview":"edit",onToggle:()=>K(ye=>ye==="preview"?"edit":"preview")}),settingsItem:"skills.instructions",children:s.jsx("div",{className:ze("overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background",Ev),onKeyDown:ye=>{ye.key==="Enter"&&(ye.metaKey||ye.ctrlKey)&&(ye.preventDefault(),vt.requestSave())},children:O==="preview"?s.jsx(Os,{outerClassName:"h-full",className:"h-full",children:s.jsx("div",{className:"min-h-full px-4 py-3",children:s.jsx(Om,{content:E,className:"typography-markdown-body",frontmatter:"hide",enableFileReferences:!1})})}):s.jsx(tc,{value:E,onChange:lt,readOnly:y,extensions:Le,className:"h-full",enableSearch:!0})})}),s.jsx($e,{title:t("settings.skills.page.section.supportingFiles"),headerAction:s.jsxs(H,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:it,disabled:y,children:[s.jsx(te,{name:"add",className:"h-3.5 w-3.5"})," ",t("settings.skills.page.actions.addFile")]}),settingsItem:"skills.supporting-files",children:(()=>{const ye=g?T:D;return ye.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground py-1.5",children:t("settings.skills.page.supportingFiles.empty")}):s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:ye.map(Z=>s.jsxs("div",{className:"flex items-center gap-2 py-1.5 cursor-pointer group",onClick:()=>dt(Z.path),children:[s.jsx(te,{name:"file",className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Z.path}),g&&s.jsx("span",{className:"typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0",children:t("settings.skills.page.badge.pending")}),!y&&s.jsx(H,{size:"sm",variant:"ghost",className:"h-5 w-5 px-0 flex-shrink-0 text-muted-foreground hover:text-[var(--status-error)] opacity-0 group-hover:opacity-100 transition-opacity",onClick:Oe=>{Oe.stopPropagation(),ot(Z.path)},children:s.jsx(te,{name:"delete-bin",className:"h-3 w-3"})})]},Z.path))})})()}),g&&s.jsx($e,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(H,{onClick:()=>{Ze()},disabled:$||!b.trim()||!I.trim(),size:"xs",className:"!font-normal",children:t($?"settings.common.actions.saving":"settings.skills.page.actions.createSkill")}),s.jsx(H,{variant:"ghost",onClick:Xe,disabled:$,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})})]}),s.jsx(Tt,{open:Ne!==null,onOpenChange:ye=>{!ye&&!Ce&&Ie(null)},children:s.jsxs(Et,{className:"max-w-md",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:t("settings.skills.page.deleteFileDialog.title")}),s.jsx(Ft,{children:t("settings.skills.page.deleteFileDialog.description",{path:Ne??""})})]}),s.jsxs(Wt,{children:[s.jsx(H,{size:"sm",variant:"ghost",onClick:()=>Ie(null),disabled:Ce,children:t("settings.common.actions.cancel")}),s.jsx(H,{size:"sm",variant:"destructive",onClick:et,disabled:Ce,children:t("settings.common.actions.delete")})]})]})}),s.jsx(Tt,{open:G,onOpenChange:ye=>{if(ye){le(!0);return}if(pe!==null&&fe!==ne){Be();return}le(!1),se(null)},children:s.jsxs(Et,{className:"max-w-3xl max-h-[85vh] flex flex-col",children:[s.jsxs(Rt,{className:"flex-shrink-0",children:[s.jsx(Ot,{children:t(pe?"settings.skills.page.fileDialog.titleEdit":"settings.skills.page.fileDialog.titleAdd")}),s.jsx(Ft,{children:t(pe?"settings.skills.page.fileDialog.descriptionEdit":"settings.skills.page.fileDialog.descriptionAdd")})]}),ve?s.jsx("div",{className:"flex-1 flex items-center justify-center py-8",children:s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.skills.page.loading.fileContent")})}):s.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col pt-2",children:[s.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("label",{className:Vt,children:t("settings.skills.page.fileDialog.field.filePath")}),!pe&&s.jsx(ts,{children:t("settings.skills.page.fileDialog.field.filePathHint")})]}),s.jsx(qe,{value:J,onChange:ye=>me(ye.target.value),placeholder:t("settings.skills.page.fileDialog.field.filePathPlaceholder"),className:"text-foreground placeholder:text-muted-foreground focus-visible:ring-ring",disabled:pe!==null})]}),s.jsxs("div",{className:"space-y-2 flex-1 min-h-0 flex flex-col",children:[s.jsx("label",{className:`${Vt} flex-shrink-0`,children:t("settings.skills.page.fileDialog.field.content")}),s.jsx("div",{className:"h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background",children:s.jsx(tc,{value:fe,onChange:oe,extensions:Ue,className:"h-full",enableSearch:!0})})]})]}),s.jsx(Wt,{className:"mt-4",children:pe?s.jsx(H,{size:"sm",onClick:()=>{Be()},disabled:ve,children:t("settings.common.actions.close")}):s.jsxs(s.Fragment,{children:[s.jsx(H,{size:"sm",variant:"ghost",onClick:()=>{le(!1),se(null)},children:t("settings.common.actions.cancel")}),s.jsx(H,{size:"sm",onClick:()=>{Be()},disabled:ve||!he,children:t("settings.skills.page.actions.createFile")})]})})]})})]})},vc=t=>{const e=De.c(2),{view:a}=t,n=a===void 0?"installed":a;let i;return e[0]!==n?(i=n==="catalog"?s.jsx(Av,{}):s.jsx(Rv,{}),e[0]=n,e[1]=i):i=e[1],i};function Ov(){}const Fv=t=>{const e=De.c(26),{header:a,footer:n,children:i,className:o,variant:r}=t,c=r===void 0?"sidebar":r,u=os(),d=m.useRef(null),[l,f]=m.useState(!1),[p,g]=m.useState(!1),h=c==="background"||u?"bg-background":"bg-sidebar",y=h==="bg-background"?"var(--surface-background)":"var(--surface-muted)";let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const E=d.current;if(!E){f(!1),g(!1);return}if(!(E.scrollHeight>E.clientHeight+1)){f(!1),g(!1);return}f(E.scrollTop>1),g(E.scrollTop+E.clientHeight<E.scrollHeight-1)},e[0]=b):b=e[0];const x=b;let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{x()},e[1]=w):w=e[1];let S;e[2]!==i?(S=[i,x],e[2]=i,e[3]=S):S=e[3],m.useEffect(w,S);let v,A;e[4]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const E=d.current;if(!E)return;const F=()=>x();return E.addEventListener("scroll",F,{passive:!0}),()=>E.removeEventListener("scroll",F)},A=[x],e[4]=v,e[5]=A):(v=e[4],A=e[5]),m.useEffect(v,A);let I;e[6]!==h||e[7]!==o?(I=ze("flex h-full flex-col",h,o),e[6]=h,e[7]=o,e[8]=I):I=e[8];let N;e[9]!==i?(N=s.jsx(Os,{ref:d,outerClassName:"flex-1 min-h-0",className:"space-y-0.5 px-3 py-2 overflow-x-hidden",children:i}),e[9]=i,e[10]=N):N=e[10];let k;e[11]!==y||e[12]!==l?(k=l&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-4",style:{background:`linear-gradient(to bottom, ${y} 0%, transparent 100%)`}}),e[11]=y,e[12]=l,e[13]=k):k=e[13];let P;e[14]!==y||e[15]!==p?(P=p&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-6",style:{background:`linear-gradient(to top, ${y} 0%, transparent 100%)`}}),e[14]=y,e[15]=p,e[16]=P):P=e[16];let j;e[17]!==P||e[18]!==N||e[19]!==k?(j=s.jsxs("div",{className:"relative flex flex-1 min-h-0 flex-col",children:[N,k,P]}),e[17]=P,e[18]=N,e[19]=k,e[20]=j):j=e[20];let C;return e[21]!==n||e[22]!==a||e[23]!==j||e[24]!==I?(C=s.jsxs("div",{className:I,children:[a,j,n]}),e[21]=n,e[22]=a,e[23]=j,e[24]=I,e[25]=C):C=e[25],C},Lv=t=>{const e=De.c(23),{title:a,metadata:n,selected:i,onSelect:o,icon:r,actions:c,className:u}=t,d=i===void 0?!1:i,l=c&&c.length>0,f=d?"bg-interactive-selection":"hover:bg-interactive-hover";let p;e[0]!==u||e[1]!==f?(p=ze("group relative flex items-center rounded-md px-1.5 py-0.5 transition-all duration-200",f,u),e[0]=u,e[1]=f,e[2]=p):p=e[2];let g;e[3]!==a?(g=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a}),e[3]=a,e[4]=g):g=e[4];let h;e[5]!==r||e[6]!==g?(h=s.jsxs("div",{className:"flex items-center gap-1.5",children:[r,g]}),e[5]=r,e[6]=g,e[7]=h):h=e[7];let y;e[8]!==n?(y=n&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:n}),e[8]=n,e[9]=y):y=e[9];let b;e[10]!==o||e[11]!==h||e[12]!==y?(b=s.jsxs("button",{onClick:o,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:[h,y]}),e[10]=o,e[11]=h,e[12]=y,e[13]=b):b=e[13];let x;e[14]!==c||e[15]!==l?(x=l&&s.jsxs(ka,{children:[s.jsx(ja,{asChild:!0,children:s.jsx(H,{size:"icon",variant:"ghost",className:"h-6 w-6 flex-shrink-0 -me-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",children:s.jsx(te,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(ya,{align:"end",className:"w-fit min-w-20",children:c.map(Kv)})]}),e[14]=c,e[15]=l,e[16]=x):x=e[16];let w;e[17]!==b||e[18]!==x?(w=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[b,x]}),e[17]=b,e[18]=x,e[19]=w):w=e[19];let S;return e[20]!==p||e[21]!==w?(S=s.jsx("div",{className:p,children:w}),e[20]=p,e[21]=w,e[22]=S):S=e[22],S};function Kv(t){const e=t.icon;return s.jsxs(fa,{onClick:a=>{a.stopPropagation(),t.onClick()},className:ze(t.destructive&&"text-destructive focus:text-destructive"),children:[e&&s.jsx(te,{name:e,className:"h-4 w-4 me-px"}),t.label]},t.label)}const _v=t=>{const e=De.c(38),{onItemSelect:a}=t,{t:n}=Ee(),i=zo(on($v)),o=re(zv),r=re(Uv),{currentTheme:c}=za();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=os(),e[0]=u):u=e[0];const d=u,l=Bv;let f,p;e[1]!==i||e[2]!==o||e[3]!==r?(f=()=>{if(i.length===0){o!==null&&r(null);return}o&&i.some(N=>N.id===o)||r(i[0].id)},p=[i,o,r],e[1]=i,e[2]=o,e[3]=r,e[4]=f,e[5]=p):(f=e[4],p=e[5]),m.useEffect(f,p);let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=ze("border-b px-3","pt-4 pb-3"),e[6]=g):g=e[6];let h;e[7]!==n?(h=n("settings.page.projects.title"),e[7]=n,e[8]=h):h=e[8];let y;e[9]!==h?(y=s.jsx("h2",{className:`${Wn} mb-3`,children:h}),e[9]=h,e[10]=y):y=e[10];let b;e[11]!==i.length||e[12]!==n?(b=n("settings.projects.sidebar.total",{count:i.length}),e[11]=i.length,e[12]=n,e[13]=b):b=e[13];let x;e[14]!==b?(x=s.jsx("span",{className:"typography-meta text-muted-foreground",children:b}),e[14]=b,e[15]=x):x=e[15];let w;e[16]!==n?(w=!d&&s.jsx(H,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:l,"aria-label":n("settings.projects.sidebar.actions.addProject"),children:s.jsx(te,{name:"add",className:"size-4"})}),e[16]=n,e[17]=w):w=e[17];let S;e[18]!==x||e[19]!==w?(S=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[x,w]}),e[18]=x,e[19]=w,e[20]=S):S=e[20];let v;e[21]!==S||e[22]!==y?(v=s.jsxs("div",{className:g,children:[y,S]}),e[21]=S,e[22]=y,e[23]=v):v=e[23];let A;if(e[24]!==c||e[25]!==a||e[26]!==i||e[27]!==o||e[28]!==r){let N;e[30]!==c||e[31]!==a||e[32]!==o||e[33]!==r?(N=k=>{const P=k.id===o,j=k.icon?Lm[k.icon]:null,C=Km(k.color),E=j?s.jsx(te,{name:j,className:ze("h-4 w-4",P?"text-foreground":"text-muted-foreground/70"),style:C?{color:C}:void 0}):s.jsx(te,{name:"folder",className:ze("h-4 w-4",P?"text-foreground":"text-muted-foreground/70"),style:C?{color:C}:void 0}),F=k.iconImage?s.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:k.iconBackground?{backgroundColor:k.iconBackground}:void 0,children:s.jsx(_m,{project:k,options:{themeVariant:c.metadata.variant,iconColor:c.colors.surface.foreground},className:"h-full w-full object-contain",fallback:E})}):E;return s.jsx(Lv,{title:k.label||k.path,icon:F,selected:P,onSelect:()=>{r(k.id),a?.()}},k.id)},e[30]=c,e[31]=a,e[32]=o,e[33]=r,e[34]=N):N=e[34],A=i.map(N),e[24]=c,e[25]=a,e[26]=i,e[27]=o,e[28]=r,e[29]=A}else A=e[29];let I;return e[35]!==v||e[36]!==A?(I=s.jsx(Fv,{variant:"background",header:v,children:A}),e[35]=v,e[36]=A,e[37]=I):I=e[37],I};function $v(t){return t.projects}function zv(t){return t.settingsProjectsSelectedId}function Uv(t){return t.setSettingsProjectsSelectedId}function Bv(){Fm.requestDirectoryDialog()}const Vv=()=>{const t=De.c(43),{t:e}=Ee(),{isMobile:a}=Zs(),n=on(Hv),i=on(qv),o=on(Wv),{confirm:r,dialog:c}=Ld(),u=re(Gv),d=re(Jv),l=re(Qv),f=re(Yv),p=$r(Zv),g=$r(Xv);let h;e:{if(!u){h=null;break e}let C;t[0]!==n||t[1]!==u?(C=n.find(E=>E.id===u)??null,t[0]=n,t[1]=u,t[2]=C):C=t[2],h=C}const y=h;let b,x;t[3]!==n||t[4]!==u||t[5]!==d?(b=()=>{if(n.length===0){d(null);return}u&&n.some(C=>C.id===u)||d(n[0].id)},x=[n,u,d],t[3]=n,t[4]=u,t[5]=d,t[6]=b,t[7]=x):(b=t[6],x=t[7]),m.useEffect(b,x);let w;t[8]!==y||t[9]!==i?(w=async C=>{y&&i(y.id,{label:C.label,icon:C.icon,color:C.color,iconBackground:C.iconBackground,defaultAgent:C.defaultAgent??null,defaultModel:C.defaultModel??null,defaultVariant:C.defaultVariant??null})},t[8]=y,t[9]=i,t[10]=w):w=t[10];const S=w,v=y?.id??null;let A;e:{if(a||!v){A=void 0;break e}let C;t[11]!==v||t[12]!==l||t[13]!==f?(C=()=>{l(!1),f(v)},t[11]=v,t[12]=l,t[13]=f,t[14]=C):C=t[14],A=C}const I=A;let N;e:{if(!y){N=void 0;break e}const{id:C,label:E,path:F}=y;let O;t[15]!==E||t[16]!==F?(O=E?.trim()||F.split(/[\\/]/).pop()||F,t[15]=E,t[16]=F,t[17]=O):O=t[17];const K=O;let D;t[18]!==r||t[19]!==C||t[20]!==K||t[21]!==o||t[22]!==e?(D=()=>{r({title:e("settings.projects.page.closeDialog.title",{name:K}),message:e("settings.projects.page.closeDialog.message"),action:e("settings.projects.page.actions.closeProject"),destructive:!0}).then(M=>{M&&o(C)})},t[18]=r,t[19]=C,t[20]=K,t[21]=o,t[22]=e,t[23]=D):D=t[23],N=D}const k=N;if(!y){let C;t[24]!==e?(C=e("settings.page.projects.title"),t[24]=e,t[25]=C):C=t[25];let E;t[26]!==e?(E=e("settings.projects.page.empty.noProjects"),t[26]=e,t[27]=E):E=t[27];let F;t[28]!==E?(F=s.jsx("p",{className:"typography-meta text-muted-foreground",children:E}),t[28]=E,t[29]=F):F=t[29];let O;return t[30]!==C||t[31]!==F?(O=s.jsx(qt,{title:C,showSaveStatus:!0,children:F}),t[30]=C,t[31]=F,t[32]=O):O=t[32],O}let P;t[33]!==k||t[34]!==S||t[35]!==I||t[36]!==y||t[37]!==g||t[38]!==p?(P=s.jsx(yf,{frame:"page",project:y,onIdentitySave:S,tab:p,onTabChange:g,onOpenWorktrees:I,onCloseProject:k}),t[33]=k,t[34]=S,t[35]=I,t[36]=y,t[37]=g,t[38]=p,t[39]=P):P=t[39];let j;return t[40]!==c||t[41]!==P?(j=s.jsxs(s.Fragment,{children:[P,c]}),t[40]=c,t[41]=P,t[42]=j):j=t[42],j};function Hv(t){return t.projects}function qv(t){return t.updateProjectMeta}function Wv(t){return t.removeProject}function Gv(t){return t.settingsProjectsSelectedId}function Jv(t){return t.setSettingsProjectsSelectedId}function Qv(t){return t.setSettingsDialogOpen}function Yv(t){return t.setWorktreesPageProjectId}function Zv(t){return t.tab}function Xv(t){return t.setTab}const e1=as({clientToken:wt().trim().min(1)}),t1=as({error:Df("Invalid or expired pairing session")}),s1=async t=>{const e=await t.json().catch(()=>null);if(!t.ok)return t.status===400&&t1.safeParse(e).success?{kind:"rejected"}:{kind:"http-error",status:t.status};const a=e1.safeParse(e);return a.success?{kind:"success",token:a.data.clientToken}:{kind:"invalid-response"}},n1=3e4;function a1({clientAuth:t}){const{t:e}=Ee(),{confirm:a,dialog:n}=Ld(),[i,o]=m.useState(!1),[r,c]=m.useState(!1);m.useEffect(()=>{let d=!1;const l=()=>{t.getRelayHostStatus().then(p=>{d||o(p.identityConflict)}).catch(()=>{})};l();const f=window.setInterval(l,n1);return()=>{d=!0,window.clearInterval(f)}},[t]);const u=async()=>{if(await a({title:e("settings.remoteInstances.clientAuth.relayConflict.confirmTitle"),message:e("settings.remoteInstances.clientAuth.relayConflict.confirmMessage"),action:e("settings.remoteInstances.clientAuth.relayConflict.confirmAction")})){c(!0);try{const l=await t.resetRelayIdentity();o(l.identityConflict),q.success(e("settings.remoteInstances.clientAuth.relayConflict.toast.success"))}catch{q.error(e("settings.remoteInstances.clientAuth.relayConflict.toast.failed"))}finally{c(!1)}}};return s.jsxs(s.Fragment,{children:[i?s.jsxs("div",{className:"flex max-w-[40rem] items-start gap-3 rounded-lg bg-[var(--status-warning)]/10 p-3",children:[s.jsx(te,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("p",{className:"typography-ui-label text-foreground",children:e("settings.remoteInstances.clientAuth.relayConflict.title")}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.remoteInstances.clientAuth.relayConflict.description")}),s.jsx(H,{type:"button",size:"xs",variant:"outline",className:"mt-1.5",disabled:r,onClick:()=>{u()},children:e("settings.remoteInstances.clientAuth.relayConflict.action")})]})]}):null,n]})}function i1(t){const e=De.c(42),{t:a}=Ee(),[n,i]=Ke.useState(null),o=Ke.useRef(null),r=Ke.useRef(null);let c,u;e[0]!==t?(c=()=>(r.current=t,i(null),()=>{r.current=null;const K=o.current;o.current=null,K?.(null)}),u=[t],e[0]=t,e[1]=c,e[2]=u):(c=e[1],u=e[2]),Ke.useEffect(c,u);let d;e[3]!==t?(d=(K,D)=>{const M=D===void 0?"settings.common.actions.saveChanges":D;return!t||r.current!==t||o.current?Promise.resolve(null):new Promise(T=>{o.current=T,i({messageKey:K,actionKey:M})})},e[3]=t,e[4]=d):d=e[4];const l=d;let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=K=>{const D=o.current;o.current=null,i(null),D?.(K)},e[5]=f):f=e[5];const p=f,g=n!==null;let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=K=>{K||p(!1)},e[6]=h):h=e[6];let y;e[7]!==a?(y=a("settings.remoteInstances.page.title"),e[7]=a,e[8]=y):y=e[8];let b;e[9]!==y?(b=s.jsx(Ot,{children:y}),e[9]=y,e[10]=b):b=e[10];let x;e[11]!==n||e[12]!==a?(x=n?a(n.messageKey):null,e[11]=n,e[12]=a,e[13]=x):x=e[13];let w;e[14]!==x?(w=s.jsx(Ft,{children:x}),e[14]=x,e[15]=w):w=e[15];let S;e[16]!==b||e[17]!==w?(S=s.jsxs(Rt,{children:[b,w]}),e[16]=b,e[17]=w,e[18]=S):S=e[18];let v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=()=>p(!1),e[19]=v):v=e[19];let A;e[20]!==a?(A=a("settings.common.actions.cancel"),e[20]=a,e[21]=A):A=e[21];let I;e[22]!==A?(I=s.jsx(H,{variant:"outline",autoFocus:!0,onClick:v,children:A}),e[22]=A,e[23]=I):I=e[23];let N;e[24]===Symbol.for("react.memo_cache_sentinel")?(N=()=>p(!0),e[24]=N):N=e[24];let k;e[25]!==n||e[26]!==a?(k=n?a(n.actionKey):null,e[25]=n,e[26]=a,e[27]=k):k=e[27];let P;e[28]!==k?(P=s.jsx(H,{onClick:N,children:k}),e[28]=k,e[29]=P):P=e[29];let j;e[30]!==I||e[31]!==P?(j=s.jsxs(Wt,{children:[I,P]}),e[30]=I,e[31]=P,e[32]=j):j=e[32];let C;e[33]!==S||e[34]!==j?(C=s.jsxs(Et,{children:[S,j]}),e[33]=S,e[34]=j,e[35]=C):C=e[35];let E;e[36]!==C||e[37]!==g?(E=s.jsx(Tt,{open:g,onOpenChange:h,children:C}),e[36]=C,e[37]=g,e[38]=E):E=e[38];const F=E;let O;return e[39]!==l||e[40]!==F?(O={confirm:l,dialog:F},e[39]=l,e[40]=F,e[41]=O):O=e[41],O}const wo=()=>Math.floor(2e4+Math.random()*3e4),o1=t=>{const e=(t instanceof Error?t.message:String(t)).toLowerCase();return e.includes("address already in use")||e.includes("eaddrinuse")||e.includes("port already in use")},r1=()=>{if(typeof navigator>"u")return;const t=(navigator.userAgent||"").toLowerCase();if(t.includes("mac"))return"macos";if(t.includes("win"))return"windows";if(t.includes("linux"))return"linux"},yc=t=>{switch((t||"").toLowerCase()){case"ios":return"iOS";case"android":return"Android";case"macos":case"darwin":return"macOS";case"windows":case"win32":return"Windows";case"linux":return"Linux";default:return null}},jc=t=>{switch(t){case"config_resolved":return"settings.remoteInstances.page.phase.resolvingConfiguration";case"auth_check":return"settings.remoteInstances.page.phase.checkingAuth";case"master_connecting":return"settings.remoteInstances.page.phase.establishingSsh";case"remote_probe":return"settings.remoteInstances.page.phase.probingRemote";case"installing":return"settings.remoteInstances.page.phase.installingOpenChamber";case"updating":return"settings.remoteInstances.page.phase.updatingOpenChamber";case"server_detecting":return"settings.remoteInstances.page.phase.detectingServer";case"server_starting":return"settings.remoteInstances.page.phase.startingServer";case"forwarding":return"settings.remoteInstances.page.phase.forwardingPorts";case"ready":return"settings.remoteInstances.sidebar.phase.ready";case"degraded":return"settings.remoteInstances.page.phase.reconnecting";case"error":return"settings.remoteInstances.sidebar.phase.error";default:return"settings.remoteInstances.sidebar.phase.idle"}},l1=new Set(["config_resolved","auth_check","master_connecting","remote_probe","installing","updating","server_detecting","server_starting","forwarding"]),Oi=t=>!!(t&&l1.has(t)),kc=t=>t==="ready"?"ready":t==="error"?"error":t==="degraded"||Oi(t)?"connecting":"idle",wc=t=>{switch(t){case"ready":return"settings.remoteInstances.page.state.ready";case"connecting":return"settings.remoteInstances.page.state.connecting";case"error":return"settings.remoteInstances.page.state.problem";default:return"settings.remoteInstances.page.state.notConnected"}},c1=t=>{const e=(t||"").toLowerCase();return e?e.includes("ui authentication")||e.includes("ui password")?"uiPassword":e.includes("already in use")||e.includes("eaddrinuse")?"localPort":e.includes("neither bun nor npm")?"noRuntime":e.includes("opencode cli is not installed")?"noOpencode":e.includes("requires a ui password")?"uiPassword":e.includes("preferred remote openchamber port")?"externalPort":null:null},Sc={noRuntime:"settings.remoteInstances.page.error.hint.noRuntime",noOpencode:"settings.remoteInstances.page.error.hint.noOpencode"},d1=t=>t==="noRuntime"?Sc.noRuntime:t==="noOpencode"?Sc.noOpencode:null,Nc=t=>t==="ready"?"bg-[var(--status-success)]":t==="error"?"bg-[var(--status-error)]":t==="degraded"||Oi(t)?"bg-[var(--status-warning)]":"bg-muted-foreground/40",go=t=>{const e=De.c(5),{className:a,waiting:n}=t,o=Hi(n===void 0?!1:n);let r;e[0]!==o||e[1]!==a?(r=ze("size-1.5 shrink-0 rounded-full",a,o),e[0]=o,e[1]=a,e[2]=r):r=e[2];let c;return e[3]!==r?(c=s.jsx("span",{className:r}),e[3]=r,e[4]=c):c=e[4],c},u1=t=>t.type==="dynamic"?`${t.localHost||"127.0.0.1"}:${t.localPort||0}`:t.type==="remote"?`${t.remoteHost||"127.0.0.1"}:${t.remotePort||0} -> ${t.localHost||"127.0.0.1"}:${t.localPort||0}`:`${t.localHost||"127.0.0.1"}:${t.localPort||0} -> ${t.remoteHost||"127.0.0.1"}:${t.remotePort||0}`,m1=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:"local",localHost:"127.0.0.1",localPort:wo(),remoteHost:"127.0.0.1",remotePort:80}),p1=t=>t.trim().replace(/\*/g,"host").replace(/\?/g,"x")||"user@host",sn=t=>{const e=De.c(7),{label:a,hint:n}=t;let i;e[0]!==a?(i=s.jsx("span",{children:a}),e[0]=a,e[1]=i):i=e[1];let o;e[2]!==n?(o=s.jsx(ts,{contentClassName:"max-w-xs",children:n}),e[2]=n,e[3]=o):o=e[3];let r;return e[4]!==i||e[5]!==o?(r=s.jsxs("span",{className:`inline-flex items-center gap-1 ${Vt}`,children:[i,o]}),e[4]=i,e[5]=o,e[6]=r):r=e[6],r},g1=t=>{switch(t){case"remote":return"settings.remoteInstances.page.forwardTypeDescription.remote";case"dynamic":return"settings.remoteInstances.page.forwardTypeDescription.dynamic";default:return"settings.remoteInstances.page.forwardTypeDescription.local"}},Cc=(t,e)=>{const a=(t||"").trim();return`${!a||a==="127.0.0.1"||a==="::1"?"localhost":a}:${e||0}`},f1=t=>{const e=(t||"").trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},h1=t=>{const e=t.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!e)return t;const a=Number(e[1]),n=Number.isFinite(a)?new Date(a).toISOString():e[1],i=(e[2]||"INFO").toUpperCase(),o=e[3]||"";return`[${n}] [${i}] ${o}`},Hr=(t="",e="")=>({id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`header-${Date.now()}-${Math.random().toString(16).slice(2)}`,name:t,value:e}),b1=t=>t.trim().toLowerCase()==="authorization",pr=t=>{const e={};for(const a of t){const n=a.name.trim(),i=a.value.trim();n&&i&&!b1(n)&&(e[n]=i)}return Object.keys(e).length>0?e:void 0},x1=t=>Object.entries(t||{}).map(([e,a])=>Hr(e,a)),Pu=()=>{if(typeof window>"u")return null;const e=qi()||window.location.href;try{const a=Number(new URL(e).port||window.location.port);return Number.isFinite(a)&&a>0?a:null}catch{const a=Number(window.location.port);return Number.isFinite(a)&&a>0?a:null}},Ic=t=>{try{const e=new URL(t).hostname.toLowerCase();return e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="[::1]"}catch{return!1}},v1=async()=>{const t=Ea(qi())||window.location.origin;if(!is()||!ri()||(await fn())?.desktopLanAccessActive!==!0)return t;const a=await Zd(),n=Pu();return!a||!n?t:`http://${a}:${n}`},Pc=t=>{const e=t.trim();if(e)try{window.location.assign(e)}catch{window.location.href=e}},y1=t=>{const e=t.sshCommand.trim(),a=t.nickname?.trim(),n=t.portForwards.map(i=>({...i,localHost:i.localHost?.trim()||"127.0.0.1",localPort:typeof i.localPort=="number"?Math.max(1,Math.min(65535,Math.round(i.localPort))):void 0,remoteHost:i.remoteHost?.trim(),remotePort:typeof i.remotePort=="number"?Math.max(1,Math.min(65535,Math.round(i.remotePort))):void 0}));return{...t,sshCommand:e,...a?{nickname:a}:{nickname:void 0},connectionTimeoutSec:Math.max(5,Math.min(240,Math.round(t.connectionTimeoutSec||60))),localForward:{...t.localForward,bindHost:t.localForward.bindHost==="localhost"||t.localForward.bindHost==="0.0.0.0"?t.localForward.bindHost:"127.0.0.1",preferredLocalPort:typeof t.localForward.preferredLocalPort=="number"?Math.max(1,Math.min(65535,Math.round(t.localForward.preferredLocalPort))):void 0},remoteOpenchamber:{...t.remoteOpenchamber,preferredPort:typeof t.remoteOpenchamber.preferredPort=="number"?Math.max(1,Math.min(65535,Math.round(t.remoteOpenchamber.preferredPort))):void 0},portForwards:n}},j1=()=>{const{t}=Ee(),e=re(U=>U.timeFormatPreference),{clientAuth:a}=oi(),n=is(),i=Is(U=>U.instances),o=Is(U=>U.statusesById),r=Is(U=>U.importCandidates),c=Is(U=>U.isLoading),u=Is(U=>U.isImportsLoading),d=Is(U=>U.isSaving),l=Is(U=>U.error),f=Is(U=>U.load),p=Is(U=>U.loadImports),g=Is(U=>U.refreshStatuses),h=Is(U=>U.upsertInstance),y=Is(U=>U.createFromCommand),b=Is(U=>U.removeInstance),x=Is(U=>U.connect),w=Is(U=>U.disconnect),S=Is(U=>U.retry),v=re(U=>U.settingsRemoteInstancesSelectedId),A=re(U=>U.setSettingsRemoteInstancesSelectedId),I=re(U=>U.setSettingsDialogOpen),{confirm:N,dialog:k}=i1(v),P=m.useMemo(()=>v&&i.find(U=>U.id===v)||null,[i,v]),[j,C]=m.useState(null),[E,F]=m.useState(!1),[O,K]=m.useState(!1),[D,M]=m.useState(null),[T,R]=m.useState([]),[$,z]=m.useState(null),[Q,V]=m.useState(""),[L,B]=m.useState(!1),[W,Y]=m.useState({}),[ae,ee]=m.useState(!1),[G,le]=m.useState(!1),[J,me]=m.useState([]),[fe,oe]=m.useState({}),[pe,se]=m.useState("local"),[ve,be]=m.useState(!1),[ne,we]=m.useState(!1),[Ne,Ie]=m.useState(""),[Ce,Me]=m.useState(""),[he,Pe]=m.useState(""),[Re,ce]=m.useState([]),[je,de]=m.useState(""),[ie,xe]=m.useState(null),[Se,Le]=m.useState(!1),[Ue,Ye]=m.useState(!1),[lt,at]=m.useState(!1),[ut,vt]=m.useState(null),[We,Ze]=m.useState(""),[Xe,it]=m.useState(""),[dt,Be]=m.useState(""),[ot,et]=m.useState([]),[ye,Z]=m.useState([]),[Oe,Ve]=m.useState([]),[X,_e]=m.useState(!1),[nt,ht]=m.useState(""),[yt,kt]=m.useState(null),[He,Je]=m.useState(null),[mt,Qe]=m.useState(null),[_,ge]=m.useState(null),[Ae,Te]=m.useState(!1),[Ge,ue]=m.useState(!1),[Fe,pt]=m.useState("configure"),[At,Nt]=m.useState(!1),[zt,es]=m.useState("relay"),[ss,fs]=m.useState(!0),[Gt,ms]=m.useState(null),cs=Ki(U=>U.networkAccessBlocked),ps=!Gt||Gt.lanUrl?t("settings.remoteInstances.clientAuth.addDevice.transport.lanHint"):is()?ri()?t(cs?"settings.openchamber.desktopNetwork.field.enterpriseBlocked":"settings.remoteInstances.clientAuth.addDevice.transport.lanUnavailableDesktopHint"):t("settings.remoteInstances.clientAuth.addDevice.transport.lanHint"):t("settings.remoteInstances.clientAuth.addDevice.transport.lanUnavailableServerHint"),hs=m.useMemo(()=>ye.filter(U=>!!U.revokedAt).length,[ye]),[ks,ws]=m.useState(!1),[Xs,Dt]=m.useState("saved"),[hn,An]=m.useState(""),[cn,Tn]=m.useState(""),[bn,En]=m.useState(""),[Mn,$s]=m.useState(!1);m.useEffect(()=>{f(),p()},[f,p]);const Dn=m.useCallback(async()=>{be(!0),xe(null);try{const U=await or();me(U.hosts||[]),se(U.defaultHostId||"local")}catch(U){xe(U instanceof Error?U.message:String(U))}finally{be(!1)}},[]);m.useEffect(()=>{Dn()},[Dn]);const vs=m.useCallback(async(U,ke=pe)=>{we(!0),xe(null);try{return await zl({hosts:U,defaultHostId:ke,initialHostChoiceCompleted:!0}),me(U),se(ke),!0}catch(tt){return xe(tt instanceof Error?tt.message:String(tt)),!1}finally{we(!1)}},[pe]),Gn=m.useCallback(async()=>{const U=Ul(Ce);if(!U){xe(t("desktopHostSwitcher.error.invalidUrl"));return}const ke=U.persistedUrl,xt={id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,label:Ne.trim()||bi(ke),url:ke,apiUrl:ke,...he.trim()?{clientToken:he.trim()}:{},...pr(Re)?{requestHeaders:pr(Re)}:{}};await vs([xt,...J],pe)&&(Ie(""),Me(""),Pe(""),ce([]),Le(!1),U.redeemUrl&&Pc(U.redeemUrl))},[pe,Re,J,Ne,he,Ce,vs,t]),Ua=m.useCallback(async()=>{xe(null);const U=xg(je);if(!U){xe(t("settings.remoteInstances.direct.error.invalidConnectLink"));return}const ke=await vg().catch(()=>""),tt=JSON.stringify({pairingId:U.pairingId,secret:U.secret,clientLabel:U.label||"OpenChamber Desktop",clientKind:"desktop",deviceName:"OpenChamber Desktop",devicePlatform:r1(),...ke?{dedupeKey:`desktop:${ke}`}:{}}),xt={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:tt};let Ht=null;const Ds=async Qt=>{const Us=await s1(Qt);switch(Us.kind){case"success":return Us.token;case"rejected":Ht=t("desktopHostSwitcher.error.pairingRejected");break;case"http-error":Ht??=t("desktopHostSwitcher.error.pairingFailed",{status:Us.status});break;case"invalid-response":Ht??=t("desktopHostSwitcher.error.pairingInvalidResponse");break}return null},ca=[...U.candidates].sort((Qt,Us)=>(Qt.type==="relay"?1:0)-(Us.type==="relay"?1:0));let Ns=null;for(const Qt of ca){if(Qt.type==="relay"){const ao=yg({relayUrl:Qt.relayUrl,serverId:Qt.serverId,hostEncPubJwk:Qt.hostEncPubJwk,...Qt.grant?{grant:Qt.grant}:{}});try{const io=await ao.fetch("/api/client-auth/pairing/redeem",{...xt,signal:AbortSignal.timeout(15e3)}),Pl=await Ds(io);if(Pl){Ns={kind:"relay",relay:{relayUrl:Qt.relayUrl,serverId:Qt.serverId,hostEncPubJwk:Qt.hostEncPubJwk},token:Pl};break}}catch{}finally{ao.close()}continue}const Us=Ea(Qt.url);if(Us)try{const ao=await fetch(`${Us}/api/client-auth/pairing/redeem`,{...xt,signal:AbortSignal.timeout(15e3)}),io=await Ds(ao);if(io){Ns={kind:"direct",url:Us,token:io};break}}catch{}}if(!Ns){xe(Ht||t("mobile.connect.error.unreachable"));return}const tn=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,Ca=U.candidates.find(Qt=>Qt.type==="relay"),da=Ns.kind==="relay"?Ns.relay:Ca?{relayUrl:Ca.relayUrl,serverId:Ca.serverId,hostEncPubJwk:Ca.hostEncPubJwk}:void 0,to=U.candidates.filter(Qt=>Qt.type!=="relay").map(Qt=>Ea(Qt.url)).find(Qt=>!!Qt),so=Ns.kind==="direct"?Ns.url:to,{token:Ut}=Ns,rs=so||(da?jg(da.serverId):null);if(!rs){xe(t("settings.remoteInstances.direct.error.invalidConnectLink"));return}const gi={url:rs,apiUrl:so||void 0,clientToken:Ut,...da?{relay:da}:{}},no=J.find(Qt=>da?Qt.relay?.serverId===da.serverId:!Qt.relay&&Ea(Qt.apiUrl||Qt.url)===rs);if(no){const Qt=J.map(Us=>Us.id===no.id?{...Us,label:U.label||Us.label,...gi}:Us);if(!await vs(Qt,pe))return}else if(!await vs([{id:tn(),label:U.label||bi(rs),...gi},...J],pe))return;de(""),xe(null),Ye(!1)},[je,pe,J,vs,t]),Jn=m.useCallback(async U=>{const ke=J.filter(xt=>xt.id!==U);await vs(ke,pe===U?"local":pe)&&ut===U&&vt(null)},[pe,ut,J,vs]),ui=m.useCallback(U=>{vt(U.id),Ze(U.label),it(U.apiUrl||U.url),Be(U.clientToken||""),et(x1(U.requestHeaders)),xe(null)},[]),Qn=m.useCallback(async()=>{if(!ut)return;const U=Ul(Xe);if(!U){xe(t("desktopHostSwitcher.error.invalidUrl"));return}const ke=U.persistedUrl,tt=J.map(xt=>xt.id===ut?{...xt,label:We.trim()||bi(ke),url:ke,apiUrl:ke,clientToken:dt.trim()||void 0,requestHeaders:pr(ot)}:xt);await vs(tt,pe)&&(vt(null),U.redeemUrl&&Pc(U.redeemUrl))},[pe,ot,We,dt,Xe,ut,J,vs,t]),Yn=m.useCallback(async()=>{const U=cn.trim();if(!U){q.error(t("settings.remoteInstances.page.toast.sshCommandRequired"));return}const ke=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await y(ke,U,bn.trim()||t("settings.remoteInstances.sidebar.newSshInstanceName")),A(ke),ws(!1),Tn(""),En(""),q.success(t("settings.remoteInstances.page.toast.instanceCreated"))}catch(tt){q.error(t("settings.remoteInstances.sidebar.toast.createFailed"),{description:tt instanceof Error?tt.message:String(tt)})}},[y,A,cn,bn,t]),Zn=m.useCallback(()=>{An(""),Dt(r.length>0?"saved":"manual"),ws(!0)},[r.length]),mi=m.useCallback(async U=>{await vs(J,U)},[J,vs]);m.useEffect(()=>{if(!n||J.length===0)return;let U=!1;return Promise.all(J.map(async ke=>{const tt=()=>Cg(ke.relay,{clientToken:ke.clientToken||null,requestHeaders:ke.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(ke.relay&&!ke.apiUrl)return[ke.id,await tt()];const xt=Ea(Bl(ke));if(!xt)return[ke.id,ke.relay?await tt():{status:"unreachable",latencyMs:0}];const Ht=await kg(xt,{clientToken:ke.clientToken||null,requestHeaders:ke.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(Ht.status==="unreachable"&&ke.relay){const Ds=await tt();if(Ds.status==="ok"||Ds.status==="relay-limit")return[ke.id,Ds]}return[ke.id,Ht]})).then(ke=>{U||oe(Object.fromEntries(ke))}),()=>{U=!0}},[J,n]);const ys=m.useCallback(async U=>{if(a){U?.silent||_e(!0),U?.silent||kt(null);try{const[ke,tt]=await Promise.all([a.listClients(),a.listPendingPairings().catch(()=>null)]);Z(ke),tt&&Ve(tt)}catch(ke){U?.silent||kt(ke instanceof Error?ke.message:String(ke))}finally{U?.silent||_e(!1)}}},[a]),xn=m.useRef(!1);m.useEffect(()=>{if(!(!Ge||Fe!=="result"||!mt)){if(Oe.some(U=>U.id===mt)){xn.current=!0;return}xn.current&&(Qe(null),ue(!1),ye.some(U=>U.pairingId===mt)&&q.success(t("settings.remoteInstances.clientAuth.addDevice.connectedToast")))}},[Ge,Fe,mt,Oe,ye,t]);const Xn=m.useCallback(async U=>{if(a)try{await a.cancelPairing(U),Ve(ke=>ke.filter(tt=>tt.id!==U)),await ys({silent:!0})}catch(ke){kt(ke instanceof Error?ke.message:String(ke))}},[a,ys]);m.useEffect(()=>{if(!a)return;ys();const U=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||ys({silent:!0})},5e3);return()=>window.clearInterval(U)},[a,ys]);const Sa=m.useCallback(async()=>{if(a?.getPairingTransports)try{const xt=await a.getPairingTransports();return{localUrl:xt.local,lanUrl:xt.lan,relayAvailable:xt.relayAvailable}}catch{}const U=Pu(),ke=U?`http://127.0.0.1:${U}`:Ic(window.location.origin)?window.location.origin:null;let tt=null;try{const xt=Ea(await v1());tt=xt&&!Ic(xt)?xt:null}catch{}return{localUrl:ke,lanUrl:tt,relayAvailable:!0}},[a]),ea=m.useCallback(async()=>{kt(null),Je(null),ge(null),Te(!1),Qe(null),pt("configure"),fs(!0),ue(!0);const U=await Sa();ms(U),es(U.relayAvailable?"relay":U.lanUrl?"lan":"local")},[Sa]),ta=m.useCallback(async()=>{if(!(!a?.createPairingSession||!Gt)){kt(null),Nt(!0);try{const U=nt.trim()||void 0;let ke,tt,xt=!0;zt==="local"?(ke=Gt.localUrl??void 0,tt=!1):zt==="lan"?(ke=Gt.lanUrl??void 0,tt=ss):ss&&Gt.lanUrl?(ke=Gt.lanUrl,tt=!0):(xt=!1,tt=!0);const{pairing:Ht,server:Ds}=await a.createPairingSession({label:U,allowedClientKinds:["mobile","desktop"],serverUrl:ke,includeRelay:tt,includeDirect:xt}),ca=wg({pairingId:Ht.id,secret:Ht.secret,label:Ds.label,fingerprint:Ht.fingerprint??void 0,expiresAt:Ht.expiresAt,candidates:Ds.candidates}),Ns=Sg(ca);Je(Ns),ge(await gu.toDataURL(Ns,{width:1024,margin:2,errorCorrectionLevel:"L"})),Te(!1),xn.current=!1,Qe(Ht.id),pt("result"),await ys({silent:!0})}catch(U){kt(U instanceof Error?U.message:String(U))}finally{Nt(!1)}}},[a,Gt,zt,ss,nt,ys]),sa=m.useCallback(()=>{He&&Ai(He).then(U=>{U.ok&&(Te(!0),window.setTimeout(()=>Te(!1),2e3))})},[He]),na=m.useCallback(async U=>{if(!a)return;const ke=U.clientKind==="desktop-local";kt(null);try{if(await a.revokeClient(U.id),ke&&is()){const tt=await or();await zl({hosts:tt.hosts,defaultHostId:tt.defaultHostId,initialHostChoiceCompleted:tt.initialHostChoiceCompleted,localClientToken:null}),Z(xt=>xt.map(Ht=>Ht.id===U.id?{...Ht,revokedAt:new Date().toISOString()}:Ht)),Vl({apiBaseUrl:qi(),clientToken:null,runtimeKey:"local"});return}await ys()}catch(tt){kt(tt instanceof Error?tt.message:String(tt))}},[a,ys]),aa=m.useCallback(async()=>{if(a){kt(null);try{await a.purgeRevokedClients(),await ys()}catch(U){kt(U instanceof Error?U.message:String(U))}}},[a,ys]);m.useEffect(()=>{C(P)},[P]),m.useEffect(()=>{$s(!1)},[v]),m.useEffect(()=>{if(!v)return;const U=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||g()},2e3);return()=>{window.clearInterval(U)}},[g,v]);const xs=v?o[v]:null,Ss=xs?.phase,dn=Ss==="ready",qs=Ss==="degraded",ia=Kd(qs),vn=Oi(Ss),Ms=dn||(vn||qs),oa=xs?Math.max(0,ia-xs.updatedAtMs):0,un=qs&&oa>12e3,ra=vn||qs&&!un,mn=kc(Ss),en=mn==="error"?c1(xs?.detail):null,yn=d1(en),la=m.useMemo(()=>!j||!P?!1:JSON.stringify(j)!==JSON.stringify(P),[j,P]),ns=m.useCallback(U=>{C(ke=>ke&&U(ke))},[]),Ba=m.useCallback(async()=>{if(!j)return;const U=y1(j);if(!U.sshCommand.trim()){q.error(t("settings.remoteInstances.page.toast.sshCommandRequired"));return}if(U.remoteOpenchamber.mode==="external"&&!U.remoteOpenchamber.preferredPort){q.error(t("settings.remoteInstances.page.validation.externalPortRequired")),$s(!0);return}if(U.remoteOpenchamber.mode==="managed"&&U.remoteOpenchamber.bindHost==="0.0.0.0"&&!U.auth.openchamberPassword?.value?.trim()){q.error(t("settings.remoteInstances.page.validation.remoteLanNeedsPassword")),$s(!0),window.setTimeout(()=>Yi.current?.focus(),0);return}if(!(U.localForward.bindHost==="0.0.0.0"&&!await N("settings.remoteInstances.page.confirm.bindAllInterfaces"))){if(U.auth.sshPassword?.enabled&&U.auth.sshPassword.value?.trim()&&U.auth.sshPassword.store!=="settings"){const ke=await N("settings.remoteInstances.page.confirm.storeSshPasswordPlaintext");if(ke===null)return;U.auth.sshPassword.store=ke?"settings":"never",ke||(U.auth.sshPassword.value=void 0)}if(U.auth.openchamberPassword?.enabled&&U.auth.openchamberPassword.value?.trim()&&U.auth.openchamberPassword.store!=="settings"){const ke=await N("settings.remoteInstances.page.confirm.storeUiPasswordPlaintext");if(ke===null)return;U.auth.openchamberPassword.store=ke?"settings":"never",ke||(U.auth.openchamberPassword.value=void 0)}try{await h(U),q.success(t("settings.remoteInstances.page.toast.instanceSaved"))}catch(ke){q.error(t("settings.remoteInstances.page.toast.saveFailed"),{description:ke instanceof Error?ke.message:String(ke)})}}},[N,j,t,h]),rt=m.useCallback(async(U,ke)=>{const tt=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await y(tt,`ssh ${ke}`,U),A(tt),q.success(t("settings.remoteInstances.page.toast.instanceCreated")),!0}catch(xt){return q.error(t("settings.remoteInstances.sidebar.toast.createFailed"),{description:xt instanceof Error?xt.message:String(xt)}),!1}},[y,A,t]),gt=m.useCallback(()=>{L||(z(null),V(""))},[L]),Jt=m.useCallback((U,ke)=>{if(ws(!1),ke){z(U),V(p1(U));return}rt(U,U)},[rt]),zs=m.useMemo(()=>wa(r,hn,U=>[U.host,U.sshCommand]),[r,hn]),jn=m.useCallback(async U=>{const tt=(await or().catch(()=>null))?.hosts.find(Ht=>Ht.id===U),xt=tt?Ea(Bl(tt)):null;if(!tt||!xt){q.error(t("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}Vl({apiBaseUrl:xt,clientToken:tt.clientToken||null,requestHeaders:tt.requestHeaders||null,runtimeKey:Ng(tt),sshForwarded:tt.sshForwarded===!0}),I(!1)},[I,t]),Rn=m.useCallback(async()=>{const U=$,ke=Q.trim();if(U){if(!ke){q.error(t("settings.remoteInstances.page.toast.destinationRequired"));return}B(!0);try{await rt(U,ke)&&(z(null),V(""))}finally{B(!1)}}},[rt,Q,$,t]),pn=m.useCallback(async()=>{if(P)try{await x(P.id);return}catch(U){if(!o1(U)||!await N("settings.remoteInstances.sidebar.confirm.localPortInUseRetry","settings.remoteInstances.sidebar.actions.retry"))throw U;const tt={...P,localForward:{...P.localForward,preferredLocalPort:wo()}};await h(tt),await x(tt.id),q.success(t("settings.remoteInstances.sidebar.toast.retriedWithRandomPort"))}},[N,x,P,t,h]),Yi=m.useRef(null),Il=m.useRef(null),um=m.useCallback(async U=>{if(P){if(U==="localPort"){const ke={...P,localForward:{...P.localForward,preferredLocalPort:wo()}};try{await h(ke),await x(ke.id),q.success(t("settings.remoteInstances.sidebar.toast.retriedWithRandomPort"))}catch(tt){q.error(t("settings.remoteInstances.page.toast.connectFailed"),{description:tt instanceof Error?tt.message:String(tt)})}return}$s(!0),window.setTimeout(()=>{if(U==="uiPassword"){Yi.current?.focus();return}Il.current?.scrollIntoView({block:"center"})},0)}},[x,P,t,h]),Zi=m.useCallback(async U=>(await $m(U,600)).map(tt=>h1(tt)),[]),mm=m.useCallback(async()=>{if(j){F(!0),K(!0),M(null);try{const U=await Zi(j.id);R(U)}catch(U){R([]),M(U instanceof Error?U.message:String(U))}finally{K(!1)}}},[j,Zi]);m.useEffect(()=>{if(!E||!j)return;let U=!1;const ke=async()=>{try{const xt=await Zi(j.id);U||(R(xt),M(null))}catch(xt){U||M(xt instanceof Error?xt.message:String(xt))}};ke();const tt=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||ke()},1e3);return()=>{U=!0,window.clearInterval(tt)}},[j,E,Zi]);const Xi=m.useMemo(()=>T.join(`
28
28
  `),[T]),pm=m.useCallback(()=>{if(!Xi.trim()){q.error(t("settings.remoteInstances.page.toast.noLogsToCopy"));return}Ai(Xi).then(U=>{U.ok&&q.success(t("settings.remoteInstances.page.toast.logsCopied"))})},[Xi,t]),gm=m.useCallback(async()=>{if(j)try{await zm(j.id),R([]),q.success(t("settings.remoteInstances.page.toast.logsCleared"))}catch(U){q.error(t("settings.remoteInstances.page.toast.clearLogsFailed"),{description:U instanceof Error?U.message:String(U)})}},[j,t]),fm=m.useCallback(()=>{if(!j)return;if(!Ms&&j.remoteOpenchamber.mode==="external"&&!j.remoteOpenchamber.preferredPort){q.error(t("settings.remoteInstances.page.validation.externalPortRequired")),$s(!0);return}if(!Ms&&j.remoteOpenchamber.mode==="managed"&&j.remoteOpenchamber.bindHost==="0.0.0.0"&&!j.auth.openchamberPassword?.value?.trim()){q.error(t("settings.remoteInstances.page.validation.remoteLanNeedsPassword")),$s(!0),window.setTimeout(()=>Yi.current?.focus(),0);return}ee(!0),(Ms?w(j.id):pn()).catch(ke=>{const tt=Ms?dn?"settings.remoteInstances.page.toast.disconnectFailed":"settings.remoteInstances.page.toast.cancelConnectionFailed":"settings.remoteInstances.page.toast.connectFailed";q.error(t(tt),{description:ke instanceof Error?ke.message:String(ke)})}).finally(()=>{ee(!1)})},[Ms,pn,w,j,dn,t]),hm=m.useCallback(()=>{if(!j||vn)return;le(!0),(qs?w(j.id).then(()=>pn()):S(j.id)).catch(ke=>{q.error(t("settings.remoteInstances.page.toast.retryFailed"),{description:ke instanceof Error?ke.message:String(ke)})}).finally(()=>{le(!1)})},[pn,w,j,vn,qs,S,t]),bm=t(vn?"settings.remoteInstances.page.actions.connecting":qs?un?"settings.remoteInstances.page.actions.reconnectNow":"settings.remoteInstances.page.actions.reconnecting":"settings.remoteInstances.sidebar.actions.retry"),xm=!ae&&!G&&(Ss==="error"||Ss==="idle"||!Ss||qs&&un)&&!vn,vm=t(dn?"settings.remoteInstances.sidebar.actions.disconnect":Ms?"settings.remoteInstances.page.actions.cancel":"settings.remoteInstances.sidebar.actions.connect");if(!j)return s.jsxs(qt,{title:t("settings.page.remoteInstances.title"),children:[a?s.jsxs($e,{title:t("settings.remoteInstances.clientAuth.title"),info:t("settings.remoteInstances.clientAuth.description"),divider:!1,settingsItem:"remote-instances.client-auth",contentClassName:"space-y-3",children:[s.jsx(a1,{clientAuth:a}),s.jsx("div",{children:s.jsxs(H,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{ea()},children:[s.jsx(te,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.clientAuth.actions.addDevice")]})}),s.jsxs("div",{className:"space-y-2.5",children:[hs>0?s.jsx("div",{className:"flex justify-end",children:s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{aa()},children:t("settings.remoteInstances.clientAuth.actions.clearRevoked")})}):null,X&&ye.length===0&&Oe.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.state.loading")}):ye.length===0&&Oe.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.state.empty")}):s.jsxs(s.Fragment,{children:[Oe.map(U=>s.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(go,{className:"bg-[var(--status-warning)]",waiting:!0}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:U.label||t("settings.remoteInstances.clientAuth.field.labelPlaceholder")}),U.usesRelay?s.jsx("span",{className:"typography-micro text-muted-foreground oc-tile-inset px-1 rounded shrink-0 leading-none pb-px",children:t("settings.remoteInstances.clientAuth.state.viaRelay")}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground truncate",children:t("settings.remoteInstances.clientAuth.state.pending")})]}),s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Xn(U.id)},children:t("settings.common.actions.cancel")})]},`pending-${U.id}`)),ye.map(U=>{const ke=U.clientKind==="desktop-local",tt=U.lastUsedAt?Date.parse(U.lastUsedAt):Number.NaN,xt=!U.revokedAt&&(ke||Number.isFinite(tt)&&Date.now()-tt<9e4),Ht=U.revokedAt?t("settings.remoteInstances.clientAuth.state.revoked"):xt?U.lastTransport==="relay"&&!ke?t("settings.remoteInstances.clientAuth.state.connectedRelay"):t("settings.remoteInstances.clientAuth.state.connectedDirect"):Number.isFinite(tt)?t("settings.remoteInstances.clientAuth.lastUsed",{date:Um(tt,e,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}):t("settings.remoteInstances.clientAuth.neverUsed");return s.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[s.jsx("div",{className:"min-w-0",children:s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[s.jsx("span",{className:ze("size-1.5 shrink-0 rounded-full",U.revokedAt?"bg-muted-foreground/20":xt?"bg-[var(--status-success)]":"bg-muted-foreground/30")}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:U.label}),yc(U.devicePlatform)?s.jsx("span",{className:"typography-micro text-muted-foreground oc-tile-inset px-1 rounded shrink-0 leading-none pb-px",children:yc(U.devicePlatform)}):null,ke?s.jsx("span",{className:"typography-micro text-muted-foreground oc-tile-inset px-1 rounded flex-shrink-0 leading-none pb-px",children:t("settings.remoteInstances.clientAuth.state.thisDevice")}):null,s.jsx("span",{className:ze("typography-micro truncate",xt&&!U.revokedAt?"text-[var(--status-success)]":"text-muted-foreground"),children:Ht})]})}),s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{na(U)},disabled:!!U.revokedAt,children:t("settings.remoteInstances.clientAuth.actions.revoke")})]},U.id)})]})]}),yt?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:yt}):null]}):null,n?s.jsxs($e,{title:t("settings.remoteInstances.direct.title"),info:t("settings.remoteInstances.direct.description"),settingsItem:"remote-instances.direct-hosts",contentClassName:"space-y-4",headerAction:s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(H,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{xe(null),Ye(!0)},disabled:ne,children:t("settings.remoteInstances.direct.import.action")}),s.jsxs(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{xe(null),Le(!0)},disabled:ne,children:[s.jsx(te,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.direct.actions.add")]})]}),children:[s.jsx("div",{className:"space-y-2.5",children:ve?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.direct.state.loading")}):J.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.direct.state.empty")}):J.map(U=>{const ke=fe[U.id],tt=ke?ke.status==="ok"?"desktopHostSwitcher.status.connected":ke.status==="auth"?"desktopHostSwitcher.status.authRequired":ke.status==="update-recommended"?"desktopHostSwitcher.status.updateRecommended":ke.status==="incompatible"?"desktopHostSwitcher.status.incompatible":ke.status==="wrong-service"?"desktopHostSwitcher.status.wrongService":ke.status==="relay-limit"?"desktopHostSwitcher.status.relayLimit":"desktopHostSwitcher.status.unreachable":"desktopHostSwitcher.status.checking",xt=ke?.status==="ok";return s.jsx("div",{className:"py-1.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(go,{className:ze(ke?xt?"bg-[var(--status-success)]":"bg-[var(--status-error)]":"bg-muted-foreground/30"),waiting:!ke}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:bi(U.label)}),pe===U.id?s.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:t("desktopHostSwitcher.header.default")}):null,s.jsxs("span",{className:ze("typography-micro shrink-0",xt?"text-[var(--status-success)]":"text-muted-foreground"),children:[t(tt),xt&&typeof ke?.latencyMs=="number"?t("desktopHostSwitcher.status.ping",{ms:Math.max(0,Math.round(ke.latencyMs))}):""]})]}),s.jsx("p",{className:ze("typography-micro text-muted-foreground truncate",U.apiUrl&&"font-mono"),children:U.relay&&!U.apiUrl?t("mobile.connect.relay.badge"):bi(U.apiUrl||U.url)})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{mi(U.id)},disabled:ne||pe===U.id,"aria-label":t("desktopHostSwitcher.actions.setAsDefaultAria"),children:pe===U.id?s.jsx(te,{name:"star-fill",className:"h-3.5 w-3.5"}):s.jsx(te,{name:"star",className:"h-3.5 w-3.5"})}),U.relay&&!U.apiUrl?null:s.jsxs(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>ui(U),disabled:ne,children:[s.jsx(te,{name:"pencil",className:"h-3.5 w-3.5"}),t("desktopHostSwitcher.actions.edit")]}),s.jsxs(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Jn(U.id)},disabled:ne,children:[s.jsx(te,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.common.actions.delete")]})]})]})},U.id)})}),ie&&!Ue&&!Se&&!ut?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:ie}):null]}):null,n?s.jsx(Tt,{open:Se,onOpenChange:Le,children:s.jsxs(Et,{className:"sm:max-w-lg",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:t("settings.remoteInstances.direct.actions.add")}),s.jsx(Ft,{children:t("settings.remoteInstances.direct.addDialog.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:U=>{U.preventDefault(),Gn()},children:[s.jsx(qe,{className:"h-8",value:Ne,onChange:U=>Ie(U.target.value),placeholder:t("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:ne}),s.jsx(qe,{className:"h-8",value:Ce,onChange:U=>Me(U.target.value),placeholder:t("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:ne,autoFocus:!0}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(qe,{className:"h-8",value:he,onChange:U=>Pe(U.target.value),placeholder:t("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:ne}),s.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:t("settings.remoteInstances.direct.note")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx($a,{children:t("settings.remoteInstances.direct.headers.title")}),s.jsx(ts,{children:t("settings.remoteInstances.direct.headers.description")})]}),Re.map(U=>s.jsxs("div",{className:"flex w-full gap-2",children:[s.jsx(qe,{className:"h-8 font-mono text-xs",value:U.name,onChange:ke=>ce(tt=>tt.map(xt=>xt.id===U.id?{...xt,name:ke.target.value}:xt)),placeholder:t("settings.remoteInstances.direct.headers.field.namePlaceholder"),disabled:ne}),s.jsx(qe,{className:"h-8 font-mono text-xs",value:U.value,onChange:ke=>ce(tt=>tt.map(xt=>xt.id===U.id?{...xt,value:ke.target.value}:xt)),placeholder:t("settings.remoteInstances.direct.headers.field.valuePlaceholder"),type:"password",disabled:ne}),s.jsx("button",{type:"button",onClick:()=>ce(ke=>ke.filter(tt=>tt.id!==U.id)),className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-[var(--status-error-background)] hover:text-[var(--status-error)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":t("settings.remoteInstances.direct.headers.removeAria"),disabled:ne,children:s.jsx(te,{name:"close",className:"h-4 w-4"})})]},U.id)),s.jsxs(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>ce(U=>[...U,Hr()]),disabled:ne,children:[s.jsx(te,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.direct.headers.actions.add")]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Le(!1),disabled:ne,children:t("settings.common.actions.cancel")}),s.jsx(H,{type:"submit",size:"xs",className:"!font-normal",disabled:ne||!Ce.trim(),children:t("settings.remoteInstances.direct.actions.add")})]}),ie?s.jsx("p",{role:"alert",className:"typography-meta text-[var(--status-error)]",children:ie}):null]})]})}):null,n?s.jsx(Tt,{open:!!ut,onOpenChange:U=>{U||vt(null)},children:s.jsxs(Et,{className:"sm:max-w-lg",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:t("desktopHostSwitcher.actions.edit")}),s.jsx(Ft,{children:t("settings.remoteInstances.direct.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:U=>{U.preventDefault(),Qn()},children:[s.jsx(qe,{className:"h-8",value:We,onChange:U=>Ze(U.target.value),placeholder:t("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:ne}),s.jsx(qe,{className:"h-8",value:Xe,onChange:U=>it(U.target.value),placeholder:t("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:ne,autoFocus:!0}),s.jsx(qe,{className:"h-8",value:dt,onChange:U=>Be(U.target.value),placeholder:t("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:ne}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx($a,{children:t("settings.remoteInstances.direct.headers.title")}),s.jsx(ts,{children:t("settings.remoteInstances.direct.headers.description")})]}),ot.map(U=>s.jsxs("div",{className:"flex w-full gap-2",children:[s.jsx(qe,{className:"h-8 font-mono text-xs",value:U.name,onChange:ke=>et(tt=>tt.map(xt=>xt.id===U.id?{...xt,name:ke.target.value}:xt)),placeholder:t("settings.remoteInstances.direct.headers.field.namePlaceholder"),disabled:ne}),s.jsx(qe,{className:"h-8 font-mono text-xs",value:U.value,onChange:ke=>et(tt=>tt.map(xt=>xt.id===U.id?{...xt,value:ke.target.value}:xt)),placeholder:t("settings.remoteInstances.direct.headers.field.valuePlaceholder"),type:"password",disabled:ne}),s.jsx("button",{type:"button",onClick:()=>et(ke=>ke.filter(tt=>tt.id!==U.id)),className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-[var(--status-error-background)] hover:text-[var(--status-error)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":t("settings.remoteInstances.direct.headers.removeAria"),disabled:ne,children:s.jsx(te,{name:"close",className:"h-4 w-4"})})]},U.id)),s.jsxs(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>et(U=>[...U,Hr()]),disabled:ne,children:[s.jsx(te,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.direct.headers.actions.add")]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>vt(null),disabled:ne,children:t("settings.common.actions.cancel")}),s.jsx(H,{type:"submit",size:"xs",className:"!font-normal",disabled:ne,children:t("settings.common.actions.saveChanges")})]}),ie?s.jsx("p",{role:"alert",className:"typography-meta text-[var(--status-error)]",children:ie}):null]})]})}):null,n?s.jsx(Tt,{open:Ue,onOpenChange:U=>{lt||Ye(U)},children:s.jsxs(Et,{className:"sm:max-w-lg",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:t("settings.remoteInstances.direct.import.action")}),s.jsx(Ft,{children:t("settings.remoteInstances.direct.import.description")})]}),s.jsxs("form",{className:"space-y-3","aria-busy":lt,onSubmit:async U=>{if(U.preventDefault(),!(lt||ne)){at(!0);try{await Ua()}catch{xe(t("mobile.connect.error.unreachable"))}finally{at(!1)}}},children:[s.jsx(qe,{className:"h-8",value:je,onChange:U=>{de(U.target.value),xe(null)},placeholder:t("settings.remoteInstances.direct.import.placeholder"),disabled:ne||lt,"aria-describedby":ie?"direct-import-error":void 0,autoFocus:!0}),ie?s.jsx("p",{id:"direct-import-error",role:"alert",className:"typography-meta text-[var(--status-error)]",children:ie}):null,s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ye(!1),disabled:ne||lt,children:t("settings.common.actions.cancel")}),s.jsx(H,{type:"submit",size:"xs",className:"!font-normal",disabled:ne||lt||!je.trim(),children:t("settings.remoteInstances.direct.import.action")})]})]})]})}):null,s.jsx(Tt,{open:Ge,onOpenChange:ue,children:s.jsxs(Et,{className:Fe==="result"?"sm:max-w-lg":"sm:max-w-md",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:t(Fe==="result"?"settings.remoteInstances.clientAuth.qrDialogTitle":"settings.remoteInstances.clientAuth.actions.addDevice")}),s.jsx(Ft,{children:t(Fe==="result"?"settings.remoteInstances.clientAuth.qrScanHint":"settings.remoteInstances.clientAuth.addDevice.subtitle")})]}),Fe==="configure"?s.jsxs("form",{className:"space-y-4",onSubmit:U=>{U.preventDefault(),ta()},children:[s.jsx(qe,{className:"h-8",value:nt,onChange:U=>ht(U.target.value),placeholder:t("settings.remoteInstances.clientAuth.field.labelPlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:"typography-ui-label text-foreground",children:t("settings.remoteInstances.clientAuth.addDevice.transportLabel")}),s.jsx("div",{role:"radiogroup","aria-label":t("settings.remoteInstances.clientAuth.addDevice.transportLabel"),className:"space-y-1.5",children:[{key:"relay",label:t("settings.remoteInstances.clientAuth.addDevice.transport.relay"),hint:t("settings.remoteInstances.clientAuth.addDevice.transport.relayHint"),available:!!Gt?.relayAvailable},{key:"lan",label:t("settings.remoteInstances.clientAuth.addDevice.transport.lan"),hint:ps,available:!!Gt?.lanUrl},{key:"local",label:t("settings.remoteInstances.clientAuth.addDevice.transport.local"),hint:t("settings.remoteInstances.clientAuth.addDevice.transport.localHint"),available:!!Gt?.localUrl}].map(U=>{const ke=zt===U.key;return s.jsxs("div",{className:ze("flex items-start gap-2 py-0.5",U.available?"cursor-pointer":"opacity-45"),onClick:()=>{U.available&&es(U.key)},role:"presentation",children:[s.jsx(il,{checked:ke,disabled:!U.available,onChange:()=>es(U.key),ariaLabel:U.label,className:"mt-0.5"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:ze("typography-ui-label font-normal",ke?"text-foreground":"text-foreground/70"),children:U.label}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:U.hint})]})]},U.key)})}),zt==="lan"?s.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 pt-1",children:[s.jsx(si,{checked:ss,onChange:fs,ariaLabel:t("settings.remoteInstances.clientAuth.addDevice.fallback.relay")}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.addDevice.fallback.relay")})]}):null,zt==="relay"&&Gt?.lanUrl?s.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 pt-1",children:[s.jsx(si,{checked:ss,onChange:fs,ariaLabel:t("settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal")}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal")})]}):null]}),yt?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:yt}):null,s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ue(!1),disabled:At,children:t("settings.common.actions.cancel")}),s.jsx(H,{type:"submit",size:"xs",className:"!font-normal",disabled:At||!Gt,children:t("settings.remoteInstances.clientAuth.addDevice.create")})]})]}):s.jsxs("div",{className:"space-y-3",children:[_?s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:_,alt:t("settings.remoteInstances.clientAuth.qrAlt"),className:"w-full max-w-[420px] rounded-md bg-white p-4"})}):null,He?s.jsxs("div",{className:"oc-tile-inset flex items-center gap-2 rounded-md p-2",children:[s.jsx("code",{className:"min-w-0 flex-1 truncate typography-code text-muted-foreground",children:He}),s.jsxs(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:sa,children:[s.jsx(te,{name:Ae?"check":"file-copy",className:ze("h-3.5 w-3.5",Ae&&"text-[var(--status-success)]")}),t(Ae?"settings.remoteInstances.clientAuth.actions.copied":"settings.common.actions.copyAll")]})]}):null,s.jsx("div",{className:"flex justify-end",children:s.jsx(H,{type:"button",size:"xs",className:"!font-normal",onClick:()=>ue(!1),children:t("settings.remoteInstances.clientAuth.addDevice.done")})})]})]})}),n?s.jsx($e,{title:t("settings.remoteInstances.sidebar.title"),description:t("settings.remoteInstances.sidebar.total",{count:i.length}),headerAction:s.jsxs(H,{type:"button",size:"xs",className:"!font-normal",onClick:Zn,children:[s.jsx(te,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.sidebar.actions.addSshInstance")]}),contentClassName:"space-y-2.5",children:c?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.state.loadingInstances")}):i.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:r.length===1?t("settings.remoteInstances.page.empty.noInstancesWithOneImport"):r.length>1?t("settings.remoteInstances.page.empty.noInstancesWithImports",{count:r.length}):t("settings.remoteInstances.page.empty.noInstances")}):i.map(U=>{const ke=o[U.id],tt=U.nickname?.trim()||U.sshParsed?.destination||U.id,xt=ke?.phase,Ht=xt==="ready",Ds=kc(xt),ca=Ds==="error"?ke?.detail:void 0;return s.jsxs("div",{className:"space-y-1.5 py-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(go,{className:Nc(xt),waiting:Oi(xt)}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:tt})]}),s.jsxs("p",{className:"typography-micro text-muted-foreground truncate",children:[t(wc(Ds)),Ds==="connecting"?` · ${t(jc(xt))}`:"",Ht&&ke?.localUrl?` · ${ke.localUrl}`:""]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Ht?s.jsxs(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{jn(U.id)},children:[s.jsx(te,{name:"external-link",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.open")]}):null,s.jsxs(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{(Ht?w(U.id):x(U.id)).catch(tn=>q.error(t(Ht?"settings.remoteInstances.sidebar.toast.disconnectFailed":"settings.remoteInstances.sidebar.toast.connectFailed"),{description:tn instanceof Error?tn.message:String(tn)}))},children:[Ht?s.jsx(te,{name:"stop",className:"h-3.5 w-3.5"}):s.jsx(te,{name:"plug-2",className:"h-3.5 w-3.5"}),t(Ht?"settings.remoteInstances.sidebar.actions.disconnect":"settings.remoteInstances.sidebar.actions.connect")]}),s.jsxs(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>A(U.id),children:[s.jsx(te,{name:"pencil",className:"h-3.5 w-3.5"}),t("desktopHostSwitcher.actions.edit")]}),s.jsxs(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{window.confirm(t("settings.remoteInstances.page.confirm.removeInstance"))&&b(U.id).catch(tn=>q.error(t("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:tn instanceof Error?tn.message:String(tn)}))},children:[s.jsx(te,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.common.actions.delete")]})]})]}),ca?s.jsx("p",{className:"typography-micro text-[var(--status-error)] break-words",children:ca}):null]},U.id)})}):null,n?s.jsx(Tt,{open:ks,onOpenChange:ws,children:s.jsxs(Et,{className:"sm:max-w-lg",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:t("settings.remoteInstances.sidebar.actions.addSshInstance")}),s.jsx(Ft,{children:t("settings.remoteInstances.page.addDialog.description")})]}),s.jsx(Xt,{value:Xs,onChange:Dt,"aria-label":t("settings.remoteInstances.page.addDialog.sourceLabel"),options:[{value:"saved",label:t("settings.remoteInstances.page.addDialog.tab.saved")},{value:"manual",label:t("settings.remoteInstances.page.addDialog.tab.manual")}]}),Xs==="saved"?s.jsxs("div",{className:"space-y-2",children:[s.jsx(qe,{className:"h-8",value:hn,onChange:U=>An(U.target.value),placeholder:t("settings.remoteInstances.page.addDialog.searchPlaceholder"),autoFocus:!0}),u?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.import.loading")}):r.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.addDialog.emptySaved")}):zs.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.addDialog.searchEmpty")}):s.jsx("div",{className:"max-h-[45vh] overflow-auto",children:zs.map(U=>s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] py-2.5 last:border-b-0",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"typography-ui-label font-medium text-foreground truncate",children:[U.host,U.pattern?` ${t("settings.remoteInstances.page.import.patternSuffix")}`:""]}),s.jsx("div",{className:"typography-meta text-muted-foreground truncate",children:U.sshCommand})]}),s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Jt(U.host,U.pattern)},children:t("settings.remoteInstances.page.addDialog.use")})]},`${U.source}:${U.host}`))})]}):s.jsxs("form",{className:"space-y-3",onSubmit:U=>{U.preventDefault(),Yn()},children:[s.jsx(qe,{className:"h-8",value:bn,onChange:U=>En(U.target.value),placeholder:t("settings.remoteInstances.page.field.nicknamePlaceholder"),disabled:d}),s.jsx(qe,{className:"h-8",value:cn,onChange:U=>Tn(U.target.value),placeholder:t("settings.remoteInstances.page.field.sshCommandPlaceholder"),disabled:d,autoFocus:!0}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>ws(!1),disabled:d,children:t("settings.common.actions.cancel")}),s.jsx(H,{type:"submit",size:"xs",className:"!font-normal",disabled:d||!cn.trim(),children:t("settings.common.actions.create")})]})]})]})}):null,s.jsx(Tt,{open:!!$,onOpenChange:U=>{U||gt()},children:s.jsxs(Et,{className:"sm:max-w-md",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:t("settings.remoteInstances.page.patternDialog.title")}),s.jsx(Ft,{children:$?t("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:$}):t("settings.remoteInstances.page.patternDialog.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:U=>{U.preventDefault(),Rn()},children:[s.jsx(qe,{value:Q,onChange:U=>V(U.target.value),placeholder:t("settings.remoteInstances.page.patternDialog.destinationPlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:gt,disabled:L,children:t("settings.common.actions.cancel")}),s.jsx(H,{type:"submit",size:"xs",className:"!font-normal",disabled:L,children:t("settings.remoteInstances.page.actions.create")})]})]})]})})]});const pi=j.remoteOpenchamber.mode==="managed",eo=pi&&j.remoteOpenchamber.bindHost==="0.0.0.0",er=eo&&!j.auth.openchamberPassword?.value?.trim(),ym=j.nickname?.trim()||j.sshParsed?.destination||j.id;return s.jsx(Tt,{open:!!j,onOpenChange:U=>{U||A(null)},children:s.jsxs(Et,{className:"sm:max-w-4xl max-h-[90vh] overflow-auto",children:[s.jsxs("div",{className:"mb-6 px-1",children:[s.jsx("h1",{className:`${Bm} truncate`,children:ym}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(go,{className:Nc(Ss),waiting:Oi(Ss)}),s.jsx("span",{className:"text-foreground",children:t(wc(mn))}),mn==="connecting"?s.jsx("span",{children:t(jc(Ss))}):null,xs?.localUrl?s.jsx("span",{className:"font-mono text-foreground/80",children:xs.localUrl}):null,un?s.jsx("span",{children:t("settings.remoteInstances.page.status.reconnectStale")}):null]})]}),s.jsxs($e,{title:t("settings.remoteInstances.page.section.actions"),info:t("settings.remoteInstances.page.section.actionsDescription"),divider:!1,contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(H,{type:"button",variant:Ms?"outline":"default",size:"xs",className:"!font-normal",onClick:fm,disabled:ae||G,children:[Ms?s.jsx(te,{name:"stop",className:"h-3.5 w-3.5"}):s.jsx(te,{name:"plug-2",className:"h-3.5 w-3.5"}),vm]}),s.jsxs(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal text-foreground/80 hover:bg-transparent hover:text-foreground",onClick:hm,disabled:!xm,children:[ra?s.jsx(va,{className:"h-3.5 w-3.5"}):s.jsx(te,{name:"refresh",className:"h-3.5 w-3.5"}),bm]}),s.jsxs(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal text-foreground/80 hover:bg-transparent hover:text-foreground",onClick:()=>{mm()},children:[s.jsx(te,{name:"terminal-window",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.logs")]}),s.jsxs(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal text-status-error/80 hover:bg-transparent hover:text-status-error",onClick:()=>{window.confirm(t("settings.remoteInstances.page.confirm.removeInstance"))&&b(j.id).then(()=>{A(null),q.success(t("settings.remoteInstances.page.toast.instanceRemoved"))}).catch(ke=>{q.error(t("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:ke instanceof Error?ke.message:String(ke)})})},children:[s.jsx(te,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.sidebar.actions.remove")]})]}),mn==="error"&&xs?.detail?s.jsxs("div",{className:"space-y-2 rounded-md bg-[var(--status-error-background)] p-3",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)] break-words",children:xs.detail}),yn?s.jsx("p",{className:"typography-micro text-muted-foreground",children:t(yn)}):null,en&&!yn?s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{um(en)},children:t(en==="uiPassword"?"settings.remoteInstances.page.error.action.setUiPassword":en==="localPort"?"settings.remoteInstances.page.error.action.pickRandomPort":"settings.remoteInstances.page.error.action.setRemotePort")}):null]}):null,xs?.localUrl?s.jsxs("div",{className:"flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx("span",{children:t("settings.remoteInstances.page.status.currentLocalUrl")}),s.jsx("span",{className:"font-mono text-foreground/90",children:xs.localUrl})]}):null]}),s.jsxs($e,{title:t("settings.remoteInstances.page.section.instance"),info:t("settings.remoteInstances.page.section.instanceDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:t("settings.remoteInstances.page.field.sshCommand")}),s.jsx(qe,{className:"h-7 md:max-w-xl",value:j.sshCommand,onChange:U=>ns(ke=>({...ke,sshCommand:U.target.value})),placeholder:t("settings.remoteInstances.page.field.sshCommandPlaceholder")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:t("settings.remoteInstances.page.field.nickname")}),s.jsx(qe,{className:"h-7 md:max-w-sm",value:j.nickname||"",onChange:U=>ns(ke=>({...ke,nickname:U.target.value})),placeholder:t("settings.remoteInstances.page.field.nicknamePlaceholder")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(sn,{label:t("settings.remoteInstances.page.field.mode"),hint:t("settings.remoteInstances.page.field.modeHint")})}),s.jsxs(Pt,{value:j.remoteOpenchamber.mode,onValueChange:U=>ns(ke=>({...ke,remoteOpenchamber:{...ke.remoteOpenchamber,mode:U==="external"?"external":"managed"}})),children:[s.jsx(Ct,{className:"w-fit min-w-[140px]",children:s.jsx(Kt,{placeholder:t("settings.remoteInstances.page.field.modePlaceholder")})}),s.jsxs(It,{children:[s.jsx(bt,{value:"managed",children:t("settings.remoteInstances.page.field.modeManaged")}),s.jsx(bt,{value:"external",children:t("settings.remoteInstances.page.field.modeExternal")})]})]})]})]}),s.jsxs(ha,{open:Mn,onOpenChange:$s,children:[s.jsxs(ba,{className:"mt-6 w-auto justify-start gap-1.5",children:[s.jsx("span",{className:Wn,children:t("settings.remoteInstances.page.section.advanced")}),s.jsx(te,{name:Mn?"arrow-up-s":"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),s.jsxs(xa,{children:[s.jsx("p",{className:"px-2 pb-2 typography-micro text-muted-foreground",children:t("settings.remoteInstances.page.section.advancedHint")}),s.jsxs("div",{className:"flex flex-col gap-1.5 px-2 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:t("settings.remoteInstances.page.field.connectionTimeoutSeconds")}),s.jsx(ds,{containerClassName:"w-fit",min:5,max:240,step:1,className:ze(us,"tabular-nums"),value:j.connectionTimeoutSec,onValueChange:U=>{ns(ke=>({...ke,connectionTimeoutSec:Number.isFinite(U)?U:ke.connectionTimeoutSec}))}})]}),s.jsxs($e,{title:t("settings.remoteInstances.page.section.remoteServer"),info:t("settings.remoteInstances.page.section.remoteServerDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",ref:Il,children:s.jsx(sn,{label:t("settings.remoteInstances.page.field.preferredRemotePort"),hint:t("settings.remoteInstances.page.field.preferredRemotePortHint")})}),s.jsx(ds,{containerClassName:"w-fit",min:1,max:65535,step:1,className:ze(us,"tabular-nums"),value:j.remoteOpenchamber.preferredPort,onValueChange:U=>{ns(ke=>({...ke,remoteOpenchamber:{...ke.remoteOpenchamber,preferredPort:Number.isFinite(U)&&U>0?U:void 0}}))},onClear:()=>{ns(U=>({...U,remoteOpenchamber:{...U.remoteOpenchamber,preferredPort:void 0}}))},emptyLabel:t("settings.remoteInstances.page.field.auto")})]}),pi?s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(sn,{label:t("settings.remoteInstances.page.field.installMethod"),hint:t("settings.remoteInstances.page.field.installMethodHint")})}),s.jsxs(Pt,{value:j.remoteOpenchamber.installMethod,onValueChange:U=>ns(ke=>({...ke,remoteOpenchamber:{...ke.remoteOpenchamber,installMethod:U==="npm"||U==="bun"?U:"auto"}})),children:[s.jsx(Ct,{className:"w-fit min-w-[140px]",children:s.jsx(Kt,{placeholder:t("settings.remoteInstances.page.field.selectInstallMethodPlaceholder")})}),s.jsxs(It,{children:[s.jsx(bt,{value:"auto",children:t("settings.remoteInstances.page.field.installMethodAuto")}),s.jsx(bt,{value:"bun",children:"bun"}),s.jsx(bt,{value:"npm",children:"npm"})]})]})]}):null,pi?s.jsxs("div",{className:"py-1.5",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(sn,{label:t("settings.remoteInstances.page.field.remoteLanAccess"),hint:t("settings.remoteInstances.page.field.remoteLanAccessHint")})}),s.jsx(La,{checked:eo,onCheckedChange:U=>ns(ke=>({...ke,remoteOpenchamber:{...ke.remoteOpenchamber,bindHost:U?"0.0.0.0":"127.0.0.1"}})),"aria-label":t("settings.remoteInstances.page.field.remoteLanAccess")})]}),eo?s.jsx("p",{className:"mt-2 typography-micro text-[var(--status-warning)] md:ps-[16rem]",children:t("settings.remoteInstances.page.field.remoteLanAccessWarning")}):null]}):null,pi?s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(sn,{label:t("settings.remoteInstances.page.field.keepServerRunning"),hint:t("settings.remoteInstances.page.field.keepServerRunningHint")})}),s.jsx("div",{className:"flex w-full items-center gap-2 md:max-w-xs",children:s.jsx(La,{checked:j.remoteOpenchamber.keepRunning,onCheckedChange:U=>ns(ke=>({...ke,remoteOpenchamber:{...ke.remoteOpenchamber,keepRunning:U}}))})})]}):null]}),s.jsxs($e,{title:t("settings.remoteInstances.page.section.mainTunnel"),info:t("settings.remoteInstances.page.section.mainTunnelDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(sn,{label:t("settings.remoteInstances.page.field.bindHost"),hint:t("settings.remoteInstances.page.field.bindHostHint")})}),s.jsxs(Pt,{value:j.localForward.bindHost,onValueChange:U=>{U==="0.0.0.0"&&!window.confirm(t("settings.remoteInstances.page.confirm.bindAllInterfaces"))||ns(ke=>({...ke,localForward:{...ke.localForward,bindHost:U==="localhost"||U==="0.0.0.0"?U:"127.0.0.1"}}))},children:[s.jsx(Ct,{className:"w-fit min-w-[240px]",children:s.jsx(Kt,{placeholder:t("settings.remoteInstances.page.field.selectBindHostPlaceholder")})}),s.jsxs(It,{children:[s.jsx(bt,{value:"127.0.0.1",children:t("settings.remoteInstances.page.field.bindHostOption.loopback")}),s.jsx(bt,{value:"localhost",children:t("settings.remoteInstances.page.field.bindHostOption.localhost")}),s.jsx(bt,{value:"0.0.0.0",children:t("settings.remoteInstances.page.field.bindHostOption.lan")})]})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(sn,{label:t("settings.remoteInstances.page.field.preferredLocalPort"),hint:t("settings.remoteInstances.page.field.preferredLocalPortHint")})}),s.jsxs("div",{className:"flex w-full items-center gap-2 md:max-w-sm",children:[s.jsx(ds,{containerClassName:"w-fit",min:1,max:65535,step:1,className:ze(us,"tabular-nums"),value:j.localForward.preferredLocalPort,onValueChange:U=>{ns(ke=>({...ke,localForward:{...ke.localForward,preferredLocalPort:Number.isFinite(U)&&U>0?U:void 0}}))},onClear:()=>{ns(U=>({...U,localForward:{...U.localForward,preferredLocalPort:void 0}}))},emptyLabel:t("settings.remoteInstances.page.field.auto")}),s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal h-7 w-7 px-0",title:t("settings.remoteInstances.page.actions.pickRandomPort"),onClick:()=>ns(U=>({...U,localForward:{...U.localForward,preferredLocalPort:wo()}})),children:s.jsx(te,{name:"shuffle",className:"h-3.5 w-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1 pt-1",children:[s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("settings.remoteInstances.page.tunnelPreview.caption")}),s.jsx("p",{className:"typography-micro font-mono text-foreground/80 break-all",children:`${j.localForward.bindHost}:${j.localForward.preferredLocalPort||"auto"} → ${j.sshParsed?.destination||j.nickname||"remote"}:${j.remoteOpenchamber.preferredPort||"auto"}`})]})]}),s.jsxs($e,{title:t("settings.remoteInstances.page.section.authentication"),info:t("settings.remoteInstances.page.section.authenticationDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(sn,{label:t("settings.remoteInstances.page.field.sshPasswordOptional"),hint:t("settings.remoteInstances.page.field.sshPasswordHint")})}),s.jsx(qe,{className:"h-7 md:max-w-sm",type:"password",value:j.auth.sshPassword?.value||"",onChange:U=>ns(ke=>({...ke,auth:{...ke.auth,sshPassword:{enabled:U.target.value.trim().length>0,value:U.target.value,store:ke.auth.sshPassword?.store||"never"}}})),placeholder:t("settings.remoteInstances.page.field.sshPasswordPlaceholder")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(sn,{label:t(eo?"settings.remoteInstances.page.field.uiPasswordRequired":"settings.remoteInstances.page.field.uiPasswordOptional"),hint:t(pi?"settings.remoteInstances.page.field.uiPasswordHintManaged":"settings.remoteInstances.page.field.uiPasswordHintExternal")})}),s.jsx(qe,{className:ze("h-7 md:max-w-sm",er&&"border-[var(--status-error)]"),type:"password",ref:Yi,"aria-invalid":er,value:j.auth.openchamberPassword?.value||"",onChange:U=>ns(ke=>({...ke,auth:{...ke.auth,openchamberPassword:{enabled:U.target.value.trim().length>0,value:U.target.value,store:ke.auth.openchamberPassword?.store||"never"}}})),placeholder:t("settings.remoteInstances.page.field.uiPasswordPlaceholder")})]}),er?s.jsx("p",{className:"typography-micro text-[var(--status-error)] md:ps-[16rem]",children:t("settings.remoteInstances.page.field.uiPasswordMissingForLan")}):null]}),s.jsxs($e,{title:t("settings.remoteInstances.page.section.portForwards"),info:t("settings.remoteInstances.page.section.portForwardsDescription"),contentClassName:"space-y-2",children:[j.portForwards.length===0?s.jsx("p",{className:"typography-micro text-muted-foreground/80",children:t("settings.remoteInstances.page.empty.noExtraForwards")}):null,j.portForwards.map((U,ke)=>{const tt=Ut=>{ns(rs=>({...rs,portForwards:rs.portForwards.map((gi,no)=>no===ke?Ut(gi):gi)}))},xt=U.type==="remote"?"Local target":"Local listen",Ht=U.type==="remote"?"Local host and port on your machine that receives traffic from remote -R listener.":"Local host and port where this forward listens on your machine.",Ds=U.type==="remote"?"Remote listen":"Remote target",ca=U.type==="remote"?"Remote host and port where SSH creates the -R listener.":"Remote host and port that receives traffic from local -L listener.",Ns=Cc(U.localHost||"localhost",U.localPort),tn=Cc(U.remoteHost||"localhost",U.remotePort),Ca=U.type==="local"&&typeof U.localPort=="number"&&U.localPort>0,da=Ca?`http://${f1(U.localHost)}:${U.localPort}`:"",to=!!W[U.id],so=U.type==="local"?t("settings.remoteInstances.page.forwardType.local"):U.type==="remote"?t("settings.remoteInstances.page.forwardType.remote"):t("settings.remoteInstances.page.forwardType.dynamic");return s.jsxs(ha,{open:to,onOpenChange:Ut=>{Y(rs=>({...rs,[U.id]:Ut}))},className:`${ke>0?"border-t border-[var(--surface-subtle)]":""} py-2`,children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:s.jsxs(ba,{className:"flex items-center gap-2 group",children:[s.jsx(te,{name:"arrow-down-s",className:`h-4 w-4 text-muted-foreground transition-transform ${to?"rotate-180":""}`}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:u1(U)}),s.jsx("span",{className:"typography-micro text-muted-foreground/70 shrink-0",children:so})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(La,{checked:U.enabled,onCheckedChange:Ut=>tt(rs=>({...rs,enabled:Ut})),"aria-label":t("settings.remoteInstances.page.actions.enableForwardAria")}),s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>ns(Ut=>({...Ut,portForwards:Ut.portForwards.filter(rs=>rs.id!==U.id)})),children:s.jsx(te,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]}),s.jsx(xa,{className:"pt-2",children:s.jsxs("div",{className:"space-y-0 pb-2",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(sn,{label:t("settings.remoteInstances.page.field.forwardType"),hint:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.remoteInstances.page.field.forwardTypeHint")}),s.jsx("p",{children:t(g1(U.type))})]})})}),s.jsxs(Pt,{value:U.type,onValueChange:Ut=>tt(rs=>({...rs,type:Ut==="dynamic"||Ut==="remote"?Ut:"local"})),children:[s.jsx(Ct,{className:"w-fit min-w-[140px]",children:s.jsx(Kt,{placeholder:t("settings.remoteInstances.page.field.typePlaceholder")})}),s.jsxs(It,{children:[s.jsx(bt,{value:"local",children:t("settings.remoteInstances.page.forwardType.local")}),s.jsx(bt,{value:"remote",children:t("settings.remoteInstances.page.forwardType.remote")}),s.jsx(bt,{value:"dynamic",children:t("settings.remoteInstances.page.forwardType.dynamic")})]})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(sn,{label:xt,hint:Ht})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(qe,{className:"h-7 w-32",value:U.localHost||"127.0.0.1",onChange:Ut=>tt(rs=>({...rs,localHost:Ut.target.value})),placeholder:t("settings.remoteInstances.page.field.localHostPlaceholder")}),s.jsx("span",{className:"text-muted-foreground",children:":"}),s.jsx(ds,{containerClassName:"w-fit",min:1,max:65535,step:1,className:ze(us,"tabular-nums"),value:U.localPort,onValueChange:Ut=>{tt(rs=>({...rs,localPort:Number.isFinite(Ut)&&Ut>0?Ut:void 0}))},onClear:()=>{tt(Ut=>({...Ut,localPort:void 0}))},emptyLabel:t("settings.remoteInstances.page.field.auto")})]})]}),U.type!=="dynamic"?s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(sn,{label:Ds,hint:ca})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(qe,{className:"h-7 w-32",value:U.remoteHost||"",onChange:Ut=>tt(rs=>({...rs,remoteHost:Ut.target.value})),placeholder:t("settings.remoteInstances.page.field.remoteHostPlaceholder")}),s.jsx("span",{className:"text-muted-foreground",children:":"}),s.jsx(ds,{containerClassName:"w-fit",min:1,max:65535,step:1,className:ze(us,"tabular-nums"),value:U.remotePort,onValueChange:Ut=>{tt(rs=>({...rs,remotePort:Number.isFinite(Ut)&&Ut>0?Ut:void 0}))},onClear:()=>{tt(Ut=>({...Ut,remotePort:void 0}))},emptyLabel:t("settings.remoteInstances.page.field.auto")})]})]}):null,s.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2 rounded-md bg-[var(--surface-subtle)] p-2",children:[s.jsx("div",{className:"flex flex-wrap items-center gap-1 typography-micro text-muted-foreground/80",children:U.type==="dynamic"?s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"computer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:Ns}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.localSocks5")})]}):U.type==="remote"?s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"server",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:tn}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.remote")}),s.jsx(te,{name:"arrow-right",className:"h-3.5 w-3.5"}),s.jsx(te,{name:"computer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:Ns}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.local")})]}):s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"computer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:Ns}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.local")}),s.jsx(te,{name:"arrow-right",className:"h-3.5 w-3.5"}),s.jsx(te,{name:"server",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:tn}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.remote")})]})}),Ca?s.jsxs(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ks(da).then(Ut=>{Ut||q.error(t("settings.remoteInstances.page.toast.openLocalEndpointFailed"))})},children:[s.jsx(te,{name:"external-link",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.openLocal")]}):null]})]})})]},U.id)}),s.jsxs(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal mt-1",onClick:()=>{const U=m1();ns(ke=>({...ke,portForwards:[...ke.portForwards,U]})),Y(ke=>({...ke,[U.id]:!0}))},children:[s.jsx(te,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.addForward")]})]})]})]}),s.jsx("div",{className:"mt-8 border-t border-[var(--interactive-border)] pt-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(H,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{Ba()},disabled:!la||d,children:t("settings.common.actions.saveChanges")}),xs?.localUrl?s.jsxs(s.Fragment,{children:[s.jsxs(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ai(xs.localUrl||"").then(U=>{U.ok&&q.success(t("settings.remoteInstances.page.toast.localUrlCopied"))})},children:[s.jsx(te,{name:"file-copy",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.copyLocalUrl")]}),s.jsxs(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{j&&jn(j.id)},children:[s.jsx(te,{name:"external-link",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.open")]})]}):null,l?s.jsx("div",{className:"ms-auto typography-meta text-[var(--status-error)]",children:l}):null]})}),k,s.jsx(Tt,{open:E,onOpenChange:F,children:s.jsxs(Et,{className:"sm:max-w-2xl",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:t("settings.remoteInstances.page.logsDialog.title")}),s.jsx(Ft,{children:j?.nickname?.trim()||j?.sshParsed?.destination||j?.id||t("settings.remoteInstances.page.logsDialog.selectedInstanceFallback")})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:pm,disabled:O||!Xi.trim(),children:[s.jsx(te,{name:"file-copy",className:"h-3.5 w-3.5"}),t("settings.common.actions.copyAll")]}),s.jsxs(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{gm()},disabled:O,children:[s.jsx(te,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.common.actions.clear")]})]}),O?s.jsx("div",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.logsDialog.loading")}):D?s.jsx("div",{className:"typography-meta text-[var(--status-error)]",children:D}):s.jsx("pre",{className:"max-h-[55vh] overflow-auto oc-tile-inset rounded-md p-3 typography-micro text-foreground whitespace-pre-wrap break-words",children:T.length>0?T.join(`
29
29
  `):t("settings.remoteInstances.page.logsDialog.empty")})]})}),s.jsx(Tt,{open:!!$,onOpenChange:U=>{U||gt()},children:s.jsxs(Et,{className:"sm:max-w-md",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:t("settings.remoteInstances.page.patternDialog.title")}),s.jsx(Ft,{children:$?t("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:$}):t("settings.remoteInstances.page.patternDialog.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:U=>{U.preventDefault(),Rn()},children:[s.jsx(qe,{value:Q,onChange:U=>V(U.target.value),placeholder:t("settings.remoteInstances.page.patternDialog.destinationPlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:gt,disabled:L,children:t("settings.common.actions.cancel")}),s.jsx(H,{type:"submit",size:"xs",className:"!font-normal",disabled:L,children:t("settings.common.actions.create")})]})]})]})})]})})},Au=as({providers:Ys(wt())}),k1=as({error:wt().min(1)}),w1=async()=>{const t=await $t("/api/provider/disabled");if(t.status===404)return null;if(!t.ok)throw new Error(`Could not read disabled providers (${t.status})`);return Au.parse(await t.json()).providers},S1=async(t,e)=>{const a=await $t(`/api/provider/${encodeURIComponent(t)}/disabled`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:e})}),n=await a.json().catch(()=>null);if(!a.ok){const i=k1.safeParse(n);throw new Error(i.success?i.data.error:`Could not update the provider (${a.status})`)}return Au.parse(n).providers},N1=(t,e,a)=>t&&!e&&!a,Ac="grid grid-cols-1 gap-0.5 @xl:grid-cols-2 @3xl:grid-cols-3",Tu="flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-start typography-ui-label text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",Tc=t=>{const e=De.c(11),{provider:a,onSelect:n}=t;let i;e[0]!==n||e[1]!==a.id?(i=()=>n(a.id),e[0]=n,e[1]=a.id,e[2]=i):i=e[2];let o;e[3]!==a.id?(o=s.jsx(ln,{providerId:a.id,className:"size-4 shrink-0"}),e[3]=a.id,e[4]=o):o=e[4];let r;e[5]!==a.name?(r=s.jsx("span",{className:"truncate",children:a.name}),e[5]=a.name,e[6]=r):r=e[6];let c;return e[7]!==i||e[8]!==o||e[9]!==r?(c=s.jsxs("button",{type:"button",className:Tu,onClick:i,children:[o,r]}),e[7]=i,e[8]=o,e[9]=r,e[10]=c):c=e[10],c},C1=t=>{const e=De.c(56),{providers:a,loadFailed:n,onSelect:i,onSelectCustom:o}=t,{t:r}=Ee(),[c,u]=m.useState(""),[d,l]=m.useState(!1);let f;e[0]!==a?(f=a??[],e[0]=a,e[1]=f):f=e[1];let p;e[2]!==f?(p=jf(f),e[2]=f,e[3]=p):p=e[3];const{popular:g,others:h}=p;let y,b,x;if(e[4]!==n||e[5]!==i||e[6]!==o||e[7]!==a||e[8]!==c||e[9]!==r){x=Symbol.for("react.early_return_sentinel");e:{if(y=r("settings.providers.page.custom.title"),a===null){let E;e[13]!==n||e[14]!==r?(E=r(n?"settings.providers.page.state.unableToLoadProviderList":"settings.providers.page.state.loading"),e[13]=n,e[14]=r,e[15]=E):E=e[15];let F;e[16]!==E?(F=s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:E}),e[16]=E,e[17]=F):F=e[17],x=F;break e}let j;e[18]!==r?(j=r("settings.providers.connect.searchPlaceholder"),e[18]=r,e[19]=j):j=e[19];let C;if(e[20]!==c||e[21]!==j?(C=s.jsx(Qo,{value:c,onChange:u,placeholder:j}),e[20]=c,e[21]=j,e[22]=C):C=e[22],b=C,c.trim().length>0){const E=wa(a,c,I1),F=Fi([y,"other","custom","openai-compatible"],c),O=E.length===0&&!F?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:r("settings.providers.page.connect.noProvidersFound")}):s.jsxs("div",{className:Ac,children:[E.map(D=>s.jsx(Tc,{provider:D,onSelect:i},D.id)),F?s.jsxs("button",{type:"button",className:Tu,onClick:o,children:[s.jsx(te,{name:"add",className:"size-4 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"truncate",children:y})]}):null]});let K;e[23]!==b||e[24]!==O?(K=s.jsxs(s.Fragment,{children:[b,O]}),e[23]=b,e[24]=O,e[25]=K):K=e[25],x=K;break e}}e[4]=n,e[5]=i,e[6]=o,e[7]=a,e[8]=c,e[9]=r,e[10]=y,e[11]=b,e[12]=x}else y=e[10],b=e[11],x=e[12];if(x!==Symbol.for("react.early_return_sentinel"))return x;let w;e[26]!==r?(w=r("settings.providers.connect.popular"),e[26]=r,e[27]=w):w=e[27];let S;if(e[28]!==i||e[29]!==g||e[30]!==r){let j;e[32]!==i||e[33]!==r?(j=C=>s.jsx(qn,{icon:s.jsx(ln,{providerId:C.id,className:"size-5"}),title:C.name,badges:C.recommended?s.jsx(js,{tone:"neutral",children:r("settings.providers.connect.recommended")}):null,description:r(C.noteKey),onOpen:()=>i(C.id)},C.id),e[32]=i,e[33]=r,e[34]=j):j=e[34],S=g.map(j),e[28]=i,e[29]=g,e[30]=r,e[31]=S}else S=e[31];let v;e[35]!==r?(v=r("settings.providers.connect.customHint"),e[35]=r,e[36]=v):v=e[36];let A;e[37]!==y||e[38]!==o||e[39]!==v?(A=s.jsx(Gi,{label:y,hint:v,onClick:o}),e[37]=y,e[38]=o,e[39]=v,e[40]=A):A=e[40];let I;e[41]!==S||e[42]!==A?(I=s.jsxs("div",{className:li,children:[S,A]}),e[41]=S,e[42]=A,e[43]=I):I=e[43];let N;e[44]!==w||e[45]!==I?(N=s.jsx($e,{title:w,divider:!1,settingsItem:"providers.connect",children:I}),e[44]=w,e[45]=I,e[46]=N):N=e[46];let k;e[47]!==i||e[48]!==h||e[49]!==d||e[50]!==r?(k=h.length>0?s.jsx($e,{title:r("settings.providers.connect.all"),children:d?s.jsx("div",{className:Ac,children:h.map(j=>s.jsx(Tc,{provider:j,onSelect:i},j.id))}):s.jsx(H,{variant:"outline",size:"sm",className:"!font-normal",onClick:()=>l(!0),children:r("settings.providers.connect.showAll",{count:h.length})})}):null,e[47]=i,e[48]=h,e[49]=d,e[50]=r,e[51]=k):k=e[51];let P;return e[52]!==b||e[53]!==k||e[54]!==N?(P=s.jsxs(s.Fragment,{children:[b,N,k]}),e[52]=b,e[53]=k,e[54]=N,e[55]=P):P=e[55],P};function I1(t){return[t.name,t.id]}const P1=wt(),qr=t=>P1.safeParse(t?.settings?.apiKey).data??null,A1=wt().min(1),Wr=t=>t!==void 0&&(t.id==="google-vertex"||t.package.startsWith("@opencode/ai/providers/google-vertex"))&&A1.safeParse(t.settings?.project).success,Sn=(t,e)=>t.find(a=>a.id===e),Ii=t=>t==="opencode-go"?"opencode":t,So=(t,e)=>{const a=Sn(t,e)?.connections,n=Ii(e);if(n===e)return a;const i=Sn(t,n)?.connections;if(!(!a&&!i))return[...a??[],...i??[]]},Gr=t=>(t?.methods??[]).filter(e=>e.type==="oauth"||e.type==="external"),Jr=t=>(t?.methods??[]).find(e=>e.type==="key"),Ec=t=>t===void 0||Jr(t)!==void 0,Mc=t=>(t?.connections??[]).filter(e=>e.type==="credential"),Dc=t=>(t.connections?.length??0)>0||t.machineCredentials?!0:typeof t.optionsApiKey=="string"&&t.optionsApiKey.trim().length>0,yl=t=>t.status?.status==="needs_auth",T1=t=>{if(t.integrations===null)return null;const e=So(t.integrations,t.providerId);if((e??[]).some(yl))return{kind:"reauthNeeded"};const a=(e??[]).filter(n=>n.type==="credential").length;return a>1?{kind:"accounts",count:a}:a===1||(t.optionsApiKey?.trim().length??0)>0?{kind:"connected"}:t.machineCredentials||(e??[]).some(n=>n.type==="env")?{kind:"environment"}:e===void 0?null:{kind:"signInNeeded"}},E1=t=>t.modelCount>0&&(!t.integrationsLoaded||t.hasCredentials||!!t.isEditableCustomProvider),M1=t=>!t.hasCredentials&&!t.userDismissed&&!t.isEditableCustomProvider,Yo=t=>{const e=De.c(12),{t:a}=Ee();if(t==="zen-promo"){let n;return e[0]!==a?(n=a("settings.classification.source.zenPromo.name"),e[0]=a,e[1]=n):n=e[1],n}if(t==="zen-key"){let n;return e[2]!==a?(n=a("settings.classification.source.zenKey.name"),e[2]=a,e[3]=n):n=e[3],n}if(t==="openrouter"){let n;return e[4]!==a?(n=a("settings.classification.source.openrouter.name"),e[4]=a,e[5]=n):n=e[5],n}if(t==="vercel"){let n;return e[6]!==a?(n=a("settings.classification.source.vercel.name"),e[6]=a,e[7]=n):n=e[7],n}if(t==="typesafe"){let n;return e[8]!==a?(n=a("settings.classification.source.typesafe.name"),e[8]=a,e[9]=n):n=e[9],n}if(t==="custom"){let n;return e[10]!==a?(n=a("settings.classification.source.custom.name"),e[10]=a,e[11]=n):n=e[11],n}return null},Fo=()=>{const t=re.getState();t.setSettingsProvidersClassificationRequested(!0),t.requestSettingsJump("providers","providers.classification")},Vn=t=>{const e=De.c(3),{onClick:a,children:n}=t;let i;return e[0]!==n||e[1]!==a?(i=s.jsx("button",{type:"button",onClick:a,className:"cursor-pointer text-[var(--primary-text)] underline-offset-4 hover:underline focus-visible:underline focus-visible:outline-none",children:n}),e[0]=n,e[1]=a,e[2]=i):i=e[2],i},Zo=()=>{const t=De.c(16),{t:e}=Ee(),a=Bt(D1),n=Bt(R1),i=Bt(O1),o=Yo(i),r=Pn();if(!a)return null;if(r&&!n){let f;t[0]!==e?(f=e("settings.jevAccess.enterprise"),t[0]=e,t[1]=f):f=t[1];let p;return t[2]!==f?(p=s.jsx("p",{className:_t,children:f}),t[2]=f,t[3]=p):p=t[3],p}let c;t[4]!==n||t[5]!==o||t[6]!==e?(c=n&&o?e("settings.jevAccess.via",{provider:o}):e("settings.jevAccess.missing"),t[4]=n,t[5]=o,t[6]=e,t[7]=c):c=t[7];let u;t[8]!==n||t[9]!==e?(u=e(n?"settings.jevAccess.manage":"settings.jevAccess.setUp"),t[8]=n,t[9]=e,t[10]=u):u=t[10];let d;t[11]!==u?(d=s.jsx(Vn,{onClick:Fo,children:u}),t[11]=u,t[12]=d):d=t[12];let l;return t[13]!==c||t[14]!==d?(l=s.jsxs("p",{className:_t,children:[c," ",d]}),t[13]=c,t[14]=d,t[15]=l):l=t[15],l};function D1(t){return t.available}function R1(t){return t.jevAvailable}function O1(t){return t.classifier?.effective??null}const F1="https://opencode.ai/v2/docs/policies/",L1=t=>{const e=De.c(3),[a,n]=m.useState(null);let i,o;return e[0]!==t?(i=()=>{let r=!1;return n(null),Qs.configDeniesAnyProvider(t).then(c=>{r||n(c)}).catch(c=>{console.warn("[providers] could not read OpenCode provider policies:",c instanceof Error?c.message:String(c)),r||n(null)}),()=>{r=!0}},o=[t],e[0]=t,e[1]=i,e[2]=o):(i=e[1],o=e[2]),m.useEffect(i,o),a},K1=t=>{const e=De.c(44),{directory:a,integrations:n}=t,{t:i}=Ee(),o=L1(a),r=Ki(B1),c=Ki(V1),u=n===null?null:(Sn(n,"opencode")?.connections?.length??0)>0,d=o!==!1||u===null?null:u?"console":"open",l=d==="open";let f;e[0]!==i?(f=i("settings.providers.enterprisePolicyLink"),e[0]=i,e[1]=f):f=e[1];let p;e[2]!==f?(p=s.jsx(Vn,{onClick:H1,children:f}),e[2]=f,e[3]=p):p=e[3];const g=p,h=l?"bg-[var(--status-warning)]/10":"bg-[var(--status-info-background)]/60";let y;e[4]!==h?(y=ze("mb-4 flex items-start gap-2 rounded-lg p-3",h),e[4]=h,e[5]=y):y=e[5];const b=l?"error-warning":"information",x=l?"text-[var(--status-warning)]":"text-[var(--status-info)]";let w;e[6]!==x?(w=ze("mt-0.5 size-4 shrink-0",x),e[6]=x,e[7]=w):w=e[7];let S;e[8]!==b||e[9]!==w?(S=s.jsx(te,{name:b,className:w}),e[8]=b,e[9]=w,e[10]=S):S=e[10];let v;e[11]!==i?(v=i("settings.providers.enterpriseTitle"),e[11]=i,e[12]=v):v=e[12];let A;e[13]!==v?(A=s.jsx("p",{className:_d,children:v}),e[13]=v,e[14]=A):A=e[14];let I;e[15]!==r||e[16]!==i?(I=r?s.jsx("p",{className:"typography-meta text-foreground",children:i("settings.providers.enterpriseManagedBy",{organization:r})}):null,e[15]=r,e[16]=i,e[17]=I):I=e[17];let N;e[18]!==c||e[19]!==i?(N=c?s.jsx("p",{className:"typography-meta text-foreground",children:i("settings.providers.enterprisePolicyUnreadable")}):null,e[18]=c,e[19]=i,e[20]=N):N=e[20];let k;e[21]!==i?(k=i("settings.providers.enterpriseMode"),e[21]=i,e[22]=k):k=e[22];let P;e[23]!==k?(P=s.jsx("p",{className:"typography-meta text-muted-foreground",children:k}),e[23]=k,e[24]=P):P=e[24];let j;e[25]!==d||e[26]!==g||e[27]!==i?(j=d==="open"?s.jsxs("p",{className:"typography-meta text-foreground",children:[i("settings.providers.enterprisePolicyMissing")," ",g]}):null,e[25]=d,e[26]=g,e[27]=i,e[28]=j):j=e[28];let C;e[29]!==d||e[30]!==g||e[31]!==i?(C=d==="console"?s.jsxs("p",{className:"typography-meta text-muted-foreground",children:[i("settings.providers.enterprisePolicyConsole")," ",g]}):null,e[29]=d,e[30]=g,e[31]=i,e[32]=C):C=e[32];let E;e[33]!==A||e[34]!==I||e[35]!==N||e[36]!==P||e[37]!==j||e[38]!==C?(E=s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[A,I,N,P,j,C]}),e[33]=A,e[34]=I,e[35]=N,e[36]=P,e[37]=j,e[38]=C,e[39]=E):E=e[39];let F;return e[40]!==E||e[41]!==y||e[42]!==S?(F=s.jsxs("div",{className:y,children:[S,E]}),e[40]=E,e[41]=y,e[42]=S,e[43]=F):F=e[43],F},_1=t=>{const e=De.c(19),{onOpen:a}=t,{t:n}=Ee(),i=Bt(q1),o=Bt(W1),r=Bt(G1);if(!i)return null;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(ln,{providerId:"typesafe",className:"size-5"}),e[0]=c):c=e[0];let u;e[1]!==n?(u=n("settings.classification.page.title"),e[1]=n,e[2]=u):u=e[2];const d=o?"success":r?"neutral":"warning";let l;e[3]!==o||e[4]!==r||e[5]!==n?(l=n(o?"settings.classification.card.ready":r?"settings.classification.card.off":"settings.classification.card.notSetUp"),e[3]=o,e[4]=r,e[5]=n,e[6]=l):l=e[6];let f;e[7]!==d||e[8]!==l?(f=s.jsx(js,{tone:d,children:l}),e[7]=d,e[8]=l,e[9]=f):f=e[9];let p;e[10]!==n?(p=n("settings.classification.card.usedFor"),e[10]=n,e[11]=p):p=e[11];let g;e[12]!==p?(g=s.jsx("span",{className:"min-w-0 truncate",children:p}),e[12]=p,e[13]=g):g=e[13];let h;return e[14]!==a||e[15]!==u||e[16]!==f||e[17]!==g?(h=s.jsx(qn,{icon:c,title:u,subtitle:"jev",badges:f,footer:g,onOpen:a}),e[14]=a,e[15]=u,e[16]=f,e[17]=g,e[18]=h):h=e[18],h},$1=(t,e)=>{const[a,n]=m.useState(()=>new Set);return m.useEffect(()=>{let i=!1;const o=e?`?directory=${encodeURIComponent(e)}`:"";return Promise.all(t.map(async r=>{try{const c=await $t(`/api/provider/${encodeURIComponent(r.id)}/source${o}`,{method:"GET",headers:{Accept:"application/json"}});if(!c.ok)return null;const u=await c.json().catch(()=>null);return(u?.sources??u?.data?.sources)?.project?.exists===!0?r.id:null}catch{return null}})).then(r=>{i||n(new Set(r.filter(c=>c!==null)))}),()=>{i=!0}},[e,t]),a},z1=t=>{const e=De.c(14),{status:a}=t,{t:n}=Ee();let i;e:switch(a.kind){case"reauthNeeded":{let c;e[0]!==n?(c=n("settings.providers.card.status.reauthNeeded"),e[0]=n,e[1]=c):c=e[1],i=c;break e}case"accounts":{let c;e[2]!==a.count||e[3]!==n?(c=n("settings.providers.card.status.accounts",{count:a.count}),e[2]=a.count,e[3]=n,e[4]=c):c=e[4],i=c;break e}case"connected":{let c;e[5]!==n?(c=n("settings.providers.card.status.connected"),e[5]=n,e[6]=c):c=e[6],i=c;break e}case"environment":{let c;e[7]!==n?(c=n("settings.providers.card.status.environment"),e[7]=n,e[8]=c):c=e[8],i=c;break e}case"signInNeeded":{let c;e[9]!==n?(c=n("settings.providers.card.status.signInNeeded"),e[9]=n,e[10]=c):c=e[10],i=c}}const o=a.kind==="signInNeeded"||a.kind==="reauthNeeded"?"warning":a.kind==="environment"?"neutral":"success";let r;return e[11]!==i||e[12]!==o?(r=s.jsx(js,{tone:o,children:i}),e[11]=i,e[12]=o,e[13]=r):r=e[13],r},U1=t=>{const e=De.c(49),{providers:a,integrations:n,directory:i,onSelect:o,onConnect:r,onOpenClassification:c,disabledProviders:u,onEnableProvider:d}=t,{t:l}=Ee(),[f,p]=m.useState(""),g=$1(a,i);let h;e[0]!==a?(h=[...a].sort(J1),e[0]=a,e[1]=h):h=e[1];const b=wa(h,f,Q1);let x;e[2]!==f?(x=f.trim(),e[2]=f,e[3]=x):x=e[3];const w=x.length>0,S=Pn(),v=qt;let A;e[4]!==l?(A=l("settings.page.providers.title"),e[4]=l,e[5]=A):A=e[5];let I;e[6]!==l?(I=l("settings.providers.grid.description"),e[6]=l,e[7]=I):I=e[7];let N;e[8]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(Qi,{className:"w-full min-w-0 @xl:w-56"}),e[8]=N):N=e[8];const k="[&>section:first-of-type]:pt-8";let P;e[9]!==i||e[10]!==n||e[11]!==S?(P=S?s.jsx(K1,{directory:i,integrations:n}):null,e[9]=i,e[10]=n,e[11]=S,e[12]=P):P=e[12];let j;e[13]!==a.length||e[14]!==f||e[15]!==l?(j=a.length>0?s.jsx(Qo,{value:f,onChange:p,placeholder:l("settings.providers.grid.searchPlaceholder")}):null,e[13]=a.length,e[14]=f,e[15]=l,e[16]=j):j=e[16];const C=a.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:l("settings.providers.grid.empty")}):b.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:l("settings.providers.grid.noMatches",{query:f.trim()})}):null,E=li;let F;e[17]!==w||e[18]!==S||e[19]!==r||e[20]!==l?(F=w||S?null:s.jsx(Gi,{label:l("settings.providers.grid.connect"),hint:l("settings.providers.grid.connectHint"),onClick:r}),e[17]=w,e[18]=S,e[19]=r,e[20]=l,e[21]=F):F=e[21];let O;e[22]!==w||e[23]!==c?(O=w?null:s.jsx(_1,{onOpen:c}),e[22]=w,e[23]=c,e[24]=O):O=e[24];let K;e[25]!==n||e[26]!==o||e[27]!==g||e[28]!==l?(K=$=>{const z=T1({integrations:n,providerId:$.id,optionsApiKey:qr($),machineCredentials:Wr($)});return s.jsx(qn,{icon:s.jsx(ln,{providerId:$.id,className:"size-5"}),title:$.name||$.id,badges:z?s.jsx(z1,{status:z}):null,footer:s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"inline-flex items-center gap-1","aria-label":l("settings.providers.card.models",{count:$.models.length}),children:[s.jsx(te,{name:"stack",className:"size-3.5 opacity-70","aria-hidden":!0}),s.jsx("span",{className:"tabular-nums",children:$.models.length})]}),g.has($.id)?s.jsx($i,{children:l("settings.providers.card.source.project")}):null]}),onOpen:()=>o($.id)},$.id)},e[25]=n,e[26]=o,e[27]=g,e[28]=l,e[29]=K):K=e[29];const D=b.map(K);let M;e[30]!==E||e[31]!==F||e[32]!==O||e[33]!==D?(M=s.jsxs("div",{className:E,children:[F,O,D]}),e[30]=E,e[31]=F,e[32]=O,e[33]=D,e[34]=M):M=e[34];let T;e[35]!==u||e[36]!==d||e[37]!==l?(T=u&&u.length>0&&d?s.jsx($e,{title:l("settings.providers.disabled.title"),info:l("settings.providers.disabled.info"),children:s.jsx("div",{className:"space-y-1",children:u.map($=>s.jsxs("div",{className:"flex items-center gap-2 py-1",children:[s.jsx(ln,{providerId:$,className:"size-4 shrink-0 opacity-60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-muted-foreground",children:$}),s.jsx(H,{size:"xs",variant:"outline",className:"!font-normal",onClick:()=>d($),children:l("settings.providers.disabled.enable")})]},$))})}):null,e[35]=u,e[36]=d,e[37]=l,e[38]=T):T=e[38];let R;return e[39]!==v||e[40]!==M||e[41]!==T||e[42]!==A||e[43]!==I||e[44]!==N||e[45]!==P||e[46]!==j||e[47]!==C?(R=s.jsxs(v,{title:A,description:I,headerEnd:N,className:k,children:[P,j,C,M,T]}),e[39]=v,e[40]=M,e[41]=T,e[42]=A,e[43]=I,e[44]=N,e[45]=P,e[46]=j,e[47]=C,e[48]=R):R=e[48],R};function B1(t){return t.organization}function V1(t){return t.policyError!==null}function H1(){Ks(F1)}function q1(t){return t.available}function W1(t){return t.jevAvailable}function G1(t){return t.classifier?.selected==="off"}function J1(t,e){return(t.name||t.id).localeCompare(e.name||e.id,void 0,{sensitivity:"base"})}function Q1(t){return[t.name||t.id,t.id]}const Eu=t=>{const e=De.c(38),{disabled:a,draft:n}=t,i=a===void 0?!1:a,{t:o}=Ee();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={kind:"idle"},e[0]=r):r=e[0];const[c,u]=m.useState(r),d=c.kind==="done"?c.result:null,l=Yo(d?.source??null)??"";let f;e[1]!==n?(f=async()=>{const k=n?n():void 0;if(k!==null){u({kind:"running"});try{u({kind:"done",result:await Vm(k)})}catch(P){const j=P;u({kind:"failed",error:j instanceof Error?j.message:String(j)})}}},e[1]=n,e[2]=f):f=e[2];const p=f;let g;e[3]!==l||e[4]!==d||e[5]!==c.error||e[6]!==c.kind||e[7]!==o?(g=()=>{if(c.kind==="failed")return{text:o("settings.classification.test.failed",{error:c.error}),ok:!1};if(!d)return null;if(d.ok)return{text:o("settings.classification.test.ok",{provider:l,model:d.model,ms:d.ms}),ok:!0};if(d.reason==="unavailable")return{text:o("settings.classification.test.unavailable"),ok:!1};if(d.reason==="timeout")return{text:o("settings.classification.test.timeout",{provider:l}),ok:!1};if(d.reason==="unparsable")return{text:o("settings.classification.test.unparsable",{provider:l}),ok:!1};if(d.reason==="network")return{text:o("settings.classification.test.network",{provider:l,error:d.message??""}),ok:!1};const k=d.status??0;return k===401||k===403?{text:o("settings.classification.test.keyRejected",{provider:l,status:k}),ok:!1}:k===404?{text:o("settings.classification.test.notFound",{provider:l}),ok:!1}:{text:o("settings.classification.test.http",{provider:l,status:k}),ok:!1}},e[3]=l,e[4]=d,e[5]=c.error,e[6]=c.kind,e[7]=o,e[8]=g):g=e[8];const h=g;let y,b,x,w,S,v;if(e[9]!==h||e[10]!==i||e[11]!==p||e[12]!==c.kind||e[13]!==o){y=h(),S="flex min-w-0 flex-col gap-1.5";let k;e[20]!==p?(k=()=>{p()},e[20]=p,e[21]=k):k=e[21];const P=i||c.kind==="running";let j;e[22]!==c.kind||e[23]!==o?(j=c.kind==="running"?o("settings.classification.test.running"):o("settings.classification.test.button"),e[22]=c.kind,e[23]=o,e[24]=j):j=e[24],e[25]!==k||e[26]!==P||e[27]!==j?(v=s.jsx(H,{size:"sm",variant:"outline",className:"self-start",onClick:k,disabled:P,children:j}),e[25]=k,e[26]=P,e[27]=j,e[28]=v):v=e[28],b="status",x="polite",w=ze(_t,y&&!y.ok&&"text-[var(--status-error)]"),e[9]=h,e[10]=i,e[11]=p,e[12]=c.kind,e[13]=o,e[14]=y,e[15]=b,e[16]=x,e[17]=w,e[18]=S,e[19]=v}else y=e[14],b=e[15],x=e[16],w=e[17],S=e[18],v=e[19];const A=y?.text??"";let I;e[29]!==A||e[30]!==b||e[31]!==x||e[32]!==w?(I=s.jsx("p",{role:b,"aria-live":x,className:w,children:A}),e[29]=A,e[30]=b,e[31]=x,e[32]=w,e[33]=I):I=e[33];let N;return e[34]!==I||e[35]!==S||e[36]!==v?(N=s.jsxs("div",{className:S,children:[v,I]}),e[34]=I,e[35]=S,e[36]=v,e[37]=N):N=e[37],N},gr="flex w-full min-w-0 items-center gap-2",fr="h-8 rounded-md px-3 min-w-0 flex-1",Y1=()=>{const{t}=Ee(),e=Bt(S=>S.customEndpoint),a=Bt(S=>S.setCustomEndpoint),n=Bt(S=>S.clearCustomEndpoint),[i,o]=m.useState(e?.url??""),[r,c]=m.useState(e?.model??""),[u,d]=m.useState(""),[l,f]=m.useState(!1),[p,g]=m.useState(null);m.useEffect(()=>{o(e?.url??""),c(e?.model??"")},[e?.url,e?.model]);const h=async S=>{f(!0),g(null);try{await S(),d("")}catch(v){g(v instanceof Error?v.message:String(v))}finally{f(!1)}},y=i.trim().length>0&&r.trim().length>0,b=()=>{if(!y)return;const S={url:i.trim(),model:r.trim()},v=u.trim();v&&(S.key=v),h(()=>a(S))},x=()=>{if(!y)return null;const S=u.trim();return S?{url:i.trim(),model:r.trim(),key:S}:{url:i.trim(),model:r.trim()}},w=S=>{S.key==="Enter"&&b()};return e?.pinned?s.jsx($e,{title:t("settings.classification.custom.title"),info:t("settings.classification.custom.info"),children:s.jsx("p",{className:Ln,children:t("settings.classification.custom.pinned",{url:e.url,model:e.model})})}):s.jsx($e,{title:t("settings.classification.custom.title"),info:t("settings.classification.custom.info"),children:s.jsxs("div",{className:Ts,children:[s.jsx(st,{label:t("settings.classification.custom.url.label"),info:t("settings.classification.custom.url.info"),children:s.jsx("div",{className:gr,children:s.jsx(qe,{type:"url",autoComplete:"off",spellCheck:!1,value:i,onChange:S=>o(S.target.value),onKeyDown:w,placeholder:"https://example.com/v1/systemone","aria-label":t("settings.classification.custom.url.label"),className:fr,disabled:l})})}),s.jsx(st,{label:t("settings.classification.custom.model.label"),children:s.jsx("div",{className:gr,children:s.jsx(qe,{autoComplete:"off",spellCheck:!1,value:r,onChange:S=>c(S.target.value),onKeyDown:w,placeholder:"jev-latest","aria-label":t("settings.classification.custom.model.label"),className:fr,disabled:l})})}),s.jsx(st,{label:t("settings.classification.custom.key.label"),info:t("settings.classification.custom.key.info"),children:s.jsx("div",{className:gr,children:s.jsx(qe,{type:"password",autoComplete:"off",value:u,onChange:S=>d(S.target.value),onKeyDown:w,placeholder:e?.keyPresent?t("settings.classification.custom.key.replacePlaceholder"):t("settings.classification.custom.key.placeholder"),"aria-label":t("settings.classification.custom.key.label"),className:fr,disabled:l})})}),s.jsxs(st,{label:null,children:[s.jsx(H,{size:"sm",variant:"outline",onClick:b,disabled:l||!y,children:t("settings.classification.custom.save")}),e?s.jsx(H,{size:"sm",variant:"ghost",onClick:()=>{h(n)},disabled:l,children:t("settings.classification.custom.remove")}):null]}),p?s.jsx("p",{className:Ln,children:p}):null,s.jsx(st,{label:null,children:s.jsx(Eu,{disabled:l||!y,draft:x})})]})})},Z1="https://docs.openchamber.dev/classification-providers/",hr=t=>{const e=De.c(6),{text:a,linkLabel:n,onOpen:i}=t;let o;e[0]!==n||e[1]!==i?(o=s.jsx("span",{onClick:ey,onKeyDown:ty,children:s.jsx(Vn,{onClick:i,children:n})}),e[0]=n,e[1]=i,e[2]=o):o=e[2];let r;return e[3]!==o||e[4]!==a?(r=s.jsxs(s.Fragment,{children:[a," ",o]}),e[3]=o,e[4]=a,e[5]=r):r=e[5],r},X1=({titleLeading:t,onOpenProvider:e})=>{const{t:a}=Ee(),n=Bt(K=>K.available),i=Bt(K=>K.loaded),o=Bt(K=>K.loadError),r=Bt(K=>K.classifier),c=Bt(K=>K.tokenPresent),u=Bt(K=>K.customEndpoint),d=Bt(K=>K.enterpriseMode),l=Bt(K=>K.load),f=Bt(K=>K.setClassifierSource),p=Bt(K=>K.setToken),g=Bt(K=>K.clearToken),h=Yo(r?.effective??null),[y,b]=m.useState(""),[x,w]=m.useState(!1),[S,v]=m.useState(null);m.useEffect(()=>{l()},[l]);const A=K=>r?.sources.find(D=>D.id===K)?.usable===!0,I=async K=>{Mt("saving");try{await f(K),Mt("saved")}catch{Mt("error")}},N=async()=>{const K=y.trim();if(K){w(!0),v(null);try{await p(K),b("")}catch(D){v(D instanceof Error?D.message:String(D))}finally{w(!1)}}},k=async()=>{w(!0),v(null);try{await g()}catch(K){v(K instanceof Error?K.message:String(K))}finally{w(!1)}},P=d?u?.pinned?a("settings.classification.status.enterprisePinned"):a("settings.classification.status.enterprise"):!r||r.selected==="off"?null:r.effective===null?a("settings.classification.status.none"):r.effective!==r.selected&&h?a("settings.classification.status.fallback",{provider:h}):null,j=A("zen-promo"),C=A("zen-key"),E=A("openrouter"),F=A("vercel"),O=A("custom");return s.jsxs(qt,{title:a("settings.classification.page.title"),titleLeading:t,description:s.jsxs("p",{className:Ln,children:[a("settings.classification.page.description")," ",s.jsx(Vn,{onClick:()=>{Ks(Z1)},children:a("settings.classification.page.docsLink")})]}),showSaveStatus:!0,children:[o?s.jsx("p",{className:Ln,children:a("settings.routing.loadError",{error:o})}):null,i?!n||!r?s.jsx("p",{className:Ln,children:a("settings.classification.unavailable")}):s.jsxs(s.Fragment,{children:[s.jsx($e,{title:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(ln,{providerId:"typesafe",className:"size-4 shrink-0"}),a("settings.classification.jev.title")]}),info:a("settings.classification.jev.info"),divider:!1,settingsItem:"providers.classification",children:s.jsxs("div",{className:Ts,children:[P?s.jsx("p",{className:_t,children:P}):null,s.jsxs(Vo,{"aria-label":a("settings.classification.jev.title"),children:[s.jsx(wn,{selected:r.selected==="off",onSelect:()=>{I("off")},label:a("settings.classification.source.off.name"),description:a("settings.classification.source.off.description")}),d?null:s.jsxs(s.Fragment,{children:[j||r.selected==="zen-promo"?s.jsx(wn,{selected:r.selected==="zen-promo",onSelect:()=>{I("zen-promo")},disabled:!j,label:a("settings.classification.source.zenPromo.name"),description:a(j?"settings.classification.source.zenPromo.description":"settings.classification.source.zenPromo.ended")}):null,s.jsx(wn,{selected:r.selected==="zen-key",onSelect:()=>{I("zen-key")},disabled:!C,label:a("settings.classification.source.zenKey.name"),description:C?a("settings.classification.source.zenKey.description"):s.jsx(hr,{text:a("settings.classification.source.zenKey.missing"),linkLabel:a("settings.classification.source.openProvider",{provider:"OpenCode Zen"}),onOpen:()=>e("opencode")})}),s.jsx(wn,{selected:r.selected==="openrouter",onSelect:()=>{I("openrouter")},disabled:!E,label:a("settings.classification.source.openrouter.name"),description:E?a("settings.classification.source.openrouter.description"):s.jsx(hr,{text:a("settings.classification.source.openrouter.missing"),linkLabel:a("settings.classification.source.openProvider",{provider:"OpenRouter"}),onOpen:()=>e("openrouter")})}),s.jsx(wn,{selected:r.selected==="vercel",onSelect:()=>{I("vercel")},disabled:!F,label:a("settings.classification.source.vercel.name"),description:F?a("settings.classification.source.vercel.description"):s.jsx(hr,{text:a("settings.classification.source.vercel.missing"),linkLabel:a("settings.classification.source.openProvider",{provider:"Vercel AI Gateway"}),onOpen:()=>e("vercel")})}),s.jsx(wn,{selected:r.selected==="typesafe",onSelect:()=>{I("typesafe")},disabled:!c,label:a("settings.classification.source.typesafe.name"),description:a(c?"settings.classification.source.typesafe.description":"settings.classification.source.typesafe.missing")})]}),!d||u?.pinned?s.jsx(wn,{selected:r.selected==="custom",onSelect:()=>{I("custom")},disabled:!O,label:a("settings.classification.source.custom.name"),description:u&&O?a("settings.classification.source.custom.description",{url:u.url}):a("settings.classification.source.custom.missing")}):null]}),d?null:s.jsx(st,{label:a("settings.routing.token.label"),info:a("settings.routing.token.info"),children:s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[s.jsx(qe,{type:"password",autoComplete:"off",value:y,onChange:K=>b(K.target.value),onKeyDown:K=>{K.key==="Enter"&&N()},placeholder:a(c?"settings.routing.token.replacePlaceholder":"settings.routing.token.placeholder"),"aria-label":a("settings.routing.token.label"),className:"h-8 rounded-md px-3 min-w-0 flex-1",disabled:x}),s.jsx(H,{size:"sm",variant:"outline",onClick:()=>{N()},disabled:x||y.trim().length===0,children:a("settings.routing.token.save")}),c?s.jsx(H,{size:"sm",variant:"ghost",onClick:()=>{k()},disabled:x,children:a("settings.routing.token.remove")}):null]})}),S?s.jsx("p",{className:Ln,children:S}):null,s.jsx(st,{label:null,children:s.jsx(Eu,{disabled:r.effective===null})})]})}),!d||u?.pinned?s.jsx(Y1,{}):null]}):null]})};function ey(t){return t.stopPropagation()}function ty(t){return t.stopPropagation()}const Rc=t=>{const e=De.c(2),{icon:a}=t;let n;return e[0]!==a?(n=s.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:s.jsx(te,{name:a,className:"size-4"})}),e[0]=a,e[1]=n):n=e[1],n},Oc=t=>{const e=De.c(3),{connection:a,fallback:n}=t;let i;return e[0]!==a||e[1]!==n?(i=yl(a)&&a.status?s.jsx("div",{className:"typography-micro text-[var(--status-warning)] break-words",children:a.status.message}):s.jsx("div",{className:"typography-micro text-muted-foreground",children:n}),e[0]=a,e[1]=n,e[2]=i):i=e[2],i},Fc=t=>{const e=De.c(11),{connection:a,account:n}=t,{t:i}=Ee(),o=yl(a)?a.status?.url:void 0;if(!o)return null;let r;e[0]!==o?(r=()=>{Ks(o)},e[0]=o,e[1]=r):r=e[1];let c;e[2]!==n||e[3]!==i?(c=i("settings.providers.accounts.signInAria",{account:n}),e[2]=n,e[3]=i,e[4]=c):c=e[4];let u;e[5]!==i?(u=i("settings.providers.accounts.signIn"),e[5]=i,e[6]=u):u=e[6];let d;return e[7]!==r||e[8]!==c||e[9]!==u?(d=s.jsx(H,{variant:"outline",size:"xs",onClick:r,"aria-label":c,children:u}),e[7]=r,e[8]=c,e[9]=u,e[10]=d):d=e[10],d},sy=t=>{const e=De.c(32),{initial:a,onSave:n,onCancel:i}=t,{t:o}=Ee(),[r,c]=m.useState(a);let u;e[0]!==r?(u=r.trim(),e[0]=r,e[1]=u):u=e[1];const d=u;let l;e[2]!==a||e[3]!==i||e[4]!==n||e[5]!==d?(l=()=>{if(d.length===0||d===a){i();return}n(d)},e[2]=a,e[3]=i,e[4]=n,e[5]=d,e[6]=l):l=e[6];const f=l;let p;e[7]!==f?(p=I=>{I.preventDefault(),f()},e[7]=f,e[8]=p):p=e[8];let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=I=>c(I.target.value),e[9]=g):g=e[9];let h;e[10]!==i?(h=I=>{I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),i())},e[10]=i,e[11]=h):h=e[11];let y;e[12]!==o?(y=o("settings.providers.accounts.nameAria"),e[12]=o,e[13]=y):y=e[13];let b;e[14]!==h||e[15]!==y||e[16]!==r?(b=s.jsx(qe,{autoFocus:!0,value:r,onChange:g,onKeyDown:h,"aria-label":y,className:"h-8 max-w-[18rem]"}),e[14]=h,e[15]=y,e[16]=r,e[17]=b):b=e[17];let x;e[18]!==o?(x=o("settings.providers.accounts.save"),e[18]=o,e[19]=x):x=e[19];let w;e[20]!==x?(w=s.jsx(H,{type:"submit",size:"xs",children:x}),e[20]=x,e[21]=w):w=e[21];let S;e[22]!==o?(S=o("settings.providers.page.actions.cancel"),e[22]=o,e[23]=S):S=e[23];let v;e[24]!==i||e[25]!==S?(v=s.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:i,children:S}),e[24]=i,e[25]=S,e[26]=v):v=e[26];let A;return e[27]!==v||e[28]!==p||e[29]!==b||e[30]!==w?(A=s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-2",onSubmit:p,children:[b,w,v]}),e[27]=v,e[28]=p,e[29]=b,e[30]=w,e[31]=A):A=e[31],A},ny=t=>{const e=De.c(32),{connections:a,activeId:n,unusedIds:i,busyId:o,onActivate:r,onRename:c,onRemove:u}=t,{t:d}=Ee(),[l,f]=m.useState(null);let p;if(e[0]!==a||e[1]!==i){let S;e[3]!==i?(S=v=>v.type==="credential"&&!i.has(v.id),e[3]=i,e[4]=S):S=e[4],p=a.filter(S),e[0]=a,e[1]=i,e[2]=p}else p=e[2];const h=p.length>1;let y;e[5]!==a?(y=a.filter(ay),e[5]=a,e[6]=y):y=e[6];const b=y.length>1;let x;if(e[7]!==n||e[8]!==o||e[9]!==h||e[10]!==a||e[11]!==r||e[12]!==u||e[13]!==c||e[14]!==l||e[15]!==b||e[16]!==d||e[17]!==i){let S;e[19]!==n||e[20]!==o||e[21]!==h||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==l||e[26]!==b||e[27]!==d||e[28]!==i?(S=v=>{if(v.type==="env")return s.jsxs("div",{className:"flex min-w-0 items-center gap-3 py-2.5",children:[s.jsx(Rc,{icon:"terminal-box"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate font-mono typography-ui-label text-foreground",children:v.name}),s.jsx(Oc,{connection:v,fallback:d("settings.providers.accounts.environment")})]}),s.jsx(Fc,{connection:v,account:v.name})]},`env:${v.name}`);const A=v.id===n,I=i.has(v.id),N=o!==null,k=v.method==="oauth"?d(I?"settings.providers.accounts.method.oauthUnused":"settings.providers.accounts.method.oauth"):v.method==="external"?d(I?"settings.providers.accounts.method.externalUnused":"settings.providers.accounts.method.external"):d(I?"settings.providers.accounts.method.keyUnused":"settings.providers.accounts.method.key"),P=v.method==="oauth"?"user-3":v.method==="external"?"terminal-box":"key";return s.jsxs("div",{className:ze("flex min-w-0 items-center gap-3 py-2.5",I&&"opacity-60"),children:[s.jsx(Rc,{icon:P}),l===v.id?s.jsx(sy,{initial:v.label,onCancel:()=>f(null),onSave:j=>{f(null),c(v,j)}}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:v.label}),b&&A?s.jsx("span",{className:"shrink-0 rounded-full bg-[var(--interactive-selection)] px-2 py-px text-[10px] font-medium text-[var(--interactive-selection-foreground)]",children:d("settings.providers.accounts.active")}):null]}),s.jsx(Oc,{connection:v,fallback:k})]}),s.jsx(Fc,{connection:v,account:v.label}),h&&!A&&!I?s.jsxs(H,{variant:"outline",size:"xs",disabled:N,onClick:()=>r(v),"aria-label":d("settings.providers.accounts.useAria",{account:v.label}),children:[o===v.id?s.jsx(te,{name:"loader-4",className:"size-3.5 animate-spin"}):null,d("settings.providers.accounts.use")]}):null,s.jsxs(ka,{children:[s.jsx(ja,{asChild:!0,children:s.jsx(H,{variant:"ghost",size:"icon",disabled:N,className:ze(Yt,"shrink-0"),"aria-label":d("settings.providers.accounts.menuAria",{account:v.label}),children:s.jsx(te,{name:"more-2",className:"size-4"})})}),s.jsxs(ya,{align:"end",children:[s.jsxs(fa,{onSelect:()=>f(v.id),children:[s.jsx(te,{name:"pencil",className:"size-4"}),d("settings.providers.accounts.rename")]}),s.jsxs(fa,{variant:"destructive",onSelect:()=>u(v),children:[s.jsx(te,{name:"delete-bin",className:"size-4"}),d("settings.providers.accounts.remove")]})]})]})]})]},v.id)},e[19]=n,e[20]=o,e[21]=h,e[22]=r,e[23]=u,e[24]=c,e[25]=l,e[26]=b,e[27]=d,e[28]=i,e[29]=S):S=e[29],x=a.map(S),e[7]=n,e[8]=o,e[9]=h,e[10]=a,e[11]=r,e[12]=u,e[13]=c,e[14]=l,e[15]=b,e[16]=d,e[17]=i,e[18]=x}else x=e[18];let w;return e[30]!==x?(w=s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:x}),e[30]=x,e[31]=w):w=e[31],w};function ay(t){return t.type==="credential"}const jl={"openai-chat":"aisdk:@ai-sdk/openai-compatible","openai-responses":"aisdk:@ai-sdk/openai","anthropic-messages":"aisdk:@ai-sdk/anthropic"},br="__custom_provider__",iy=/^[a-z0-9][a-z0-9-_]*$/,Mu=/^https?:\/\//,oy=/^\{env:([^}]+)\}$/,Lo=t=>{if(!t)return;if(typeof t.package=="string"&&t.package)return t.package;const e=t.api?.npm;return typeof e=="string"&&e?`aisdk:${e}`:void 0},Du=t=>t.settings&&typeof t.settings=="object"?t.settings:t.options&&typeof t.options=="object"?t.options:{};let ry=0;const Ko=()=>`row-${ry++}`,Xo=()=>({row:Ko(),id:"",name:"",contextWindow:"",maxOutputTokens:"",inputCapabilities:["text"],outputCapabilities:["text"],tools:!0,capabilitiesKnown:!1,variants:""}),Lc=as({context:Mo().optional(),output:Mo().optional()}),Kc=as({tools:Ji(),input:Ys(wt()),output:Ys(wt())}),ly=as({id:wt(),name:wt(),limit:Lc.optional(),capabilities:Kc.optional(),metadata:as({providerID:wt(),modelID:wt(),name:wt().optional(),limit:Lc.optional(),capabilities:Kc.optional()}).optional()}),cy=as({models:Ys(ly)}),dy=as({error:wt()}),uy=t=>{const e=t.metadata,a=t.limit?.context??e?.limit?.context,n=t.limit?.output??e?.limit?.output,i=t.capabilities??e?.capabilities,o=!!(t.limit||t.capabilities);return{...Xo(),id:t.id,name:t.name!==t.id?t.name:e?.name??t.id,contextWindow:a?String(a):"",maxOutputTokens:n?String(n):"",inputCapabilities:i?.input??["text"],outputCapabilities:i?.output??["text"],tools:i?.tools??!0,capabilitiesKnown:!!i,...o?{metadataSource:"provider-api"}:e?{metadataSource:"models.dev"}:{}}};function my(t,e){switch(t){case"openai-chat":return{settings:{reasoningEffort:e}};case"openai-responses":return{settings:{reasoningEffort:e,reasoningSummary:"auto",include:["reasoning.encrypted_content"]}};case"anthropic-messages":return{settings:{thinking:{type:"adaptive",display:"summarized"},effort:e}}}}function py(t){const e=t.split(/[,\s]+/).map(a=>a.trim()).filter(Boolean);return e.filter((a,n)=>e.indexOf(a)===n)}function gy(t){return Object.fromEntries((t??[]).map(({id:e,...a})=>[e,a]))}const kl=()=>({row:Ko(),key:"",value:""}),fy=()=>({providerID:"",name:"",icon:null,protocol:"openai-chat",baseURL:"",apiKey:"",models:[Xo()],headers:[kl()]}),Ru={"@opencode/ai/providers/openai-compatible":"openai-chat","@opencode/ai/providers/openai":"openai-responses","@opencode/ai/providers/anthropic":"anthropic-messages"};function hy(t){const e=t?Ru[t]:void 0;if(e)return e;switch(t){case"aisdk:@ai-sdk/openai":case"@ai-sdk/openai":return"openai-responses";case"aisdk:@ai-sdk/anthropic":case"@ai-sdk/anthropic":return"anthropic-messages";default:return"openai-chat"}}function by(t){const e=t.trim();if(!e)return{};const n=e.match(oy)?.[1]?.trim();return n?{env:n}:{key:e}}function xy(t){const e=Du(t),a=typeof e.baseURL=="string"?e.baseURL.trim():"";if(a&&Mu.test(a))return!0;const n=new Set([...Object.values(jl),...Object.keys(Ru)]);return n.has(Lo(t)??"")?!0:(Array.isArray(t.models)?t.models:t.models&&typeof t.models=="object"?Object.values(t.models):[]).some(o=>!o||typeof o!="object"?!1:n.has(Lo(o)??""))}function _c(t,e){return e?!!(e.user?.exists||e.project?.exists||e.custom?.exists)&&xy(t):!1}function $c(t){return t?.custom?.exists?"custom":t?.project?.exists?"project":"user"}function zc(t){const e=Du(t),a=typeof e.baseURL=="string"?e.baseURL:"",n=t.headers&&typeof t.headers=="object"?t.headers:e.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers)?e.headers:{},i=Object.entries(n).filter(d=>typeof d[0]=="string"&&typeof d[1]=="string").map(([d,l])=>({row:Ko(),key:d,value:l})),o=Array.isArray(t.models)?t.models:t.models&&typeof t.models=="object"?Object.entries(t.models).map(([d,l])=>{const f=l&&typeof l=="object"?l:{};return{id:d,modelID:typeof f.modelID=="string"?f.modelID:d,name:typeof f.name=="string"?f.name:d,package:typeof f.package=="string"?f.package:void 0,variants:Ou.safeParse(f.variants).data,limit:Fu.safeParse(f.limit).data,capabilities:Lu.safeParse(f.capabilities).data}}):[],r=o.length>0?o.map(d=>{const l=typeof d?.modelID=="string"&&d.modelID?d.modelID:typeof d?.id=="string"?d.id:"",f=gy(d?.variants);return{row:Ko(),id:l,name:typeof d?.name=="string"?d.name:l,contextWindow:d.limit?.context?String(d.limit.context):"",maxOutputTokens:d.limit?.output?String(d.limit.output):"",inputCapabilities:d.capabilities?.input??["text"],outputCapabilities:d.capabilities?.output??["text"],tools:d.capabilities?.tools??!0,capabilitiesKnown:!!d.capabilities,variants:Object.keys(f).join(", "),savedVariants:f}}):[Xo()],c=Array.isArray(t.env)?t.env.find(d=>typeof d=="string"&&d.trim().length>0)?.trim():void 0,u=o.map(d=>Lo(d)).find(d=>!!d);return{providerID:t.id,name:typeof t.name=="string"&&t.name.trim()?t.name:t.id,icon:null,protocol:hy(Lo(t)??u),baseURL:a,apiKey:c?`{env:${c}}`:"",models:r,headers:i.length>0?i:[kl()]}}const Ou=Ys(as({id:wt(),settings:Bn(wt(),Lr()).optional(),headers:Bn(wt(),wt()).optional(),body:Bn(wt(),Lr()).optional()})),Fu=as({context:Mo().optional(),output:Mo().optional()}),Lu=as({tools:Ji().optional(),input:Ys(wt()).optional(),output:Ys(wt()).optional()}),vy=as({name:wt().optional(),package:wt().optional(),env:Ys(wt()).optional(),settings:Bn(wt(),Lr()).optional(),headers:Bn(wt(),wt()).optional(),models:Bn(wt(),as({modelID:wt().optional(),name:wt().optional(),package:wt().optional(),variants:Ou.optional(),limit:Fu.optional(),capabilities:Lu.optional()})).optional()});function yy(t,e,a=null){const n=Array.isArray(t.models)?t.models.map(r=>({...r,variants:void 0})):t.models,i=zc({...t,models:n});if(!e)return{...i,icon:a,models:i.models.map(r=>({...r,savedVariants:void 0}))};const o=zc({...e,id:t.id});return{providerID:t.id,name:e.name?.trim()?o.name:i.name,icon:a,protocol:e.package?o.protocol:i.protocol,baseURL:o.baseURL||i.baseURL,apiKey:o.apiKey,models:e.models&&Object.keys(e.models).length>0?o.models:i.models.map(r=>({...r,savedVariants:void 0})),headers:o.headers}}function jy(t){const e=t.form.providerID.trim(),a=t.form.name.trim(),n=t.form.baseURL.trim(),{env:i,key:o}=by(t.form.apiKey),r=t.disabledProviders??[],c=t.editingProviderID?.trim(),u=e?iy.test(e)?void 0:t.t("settings.providers.page.custom.error.providerID.format"):t.t("settings.providers.page.custom.error.providerID.required"),d=a?void 0:t.t("settings.providers.page.custom.error.name.required"),l=n?Mu.test(n)?void 0:t.t("settings.providers.page.custom.error.baseURL.format"):t.t("settings.providers.page.custom.error.baseURL.required"),p=!!(i||o||c&&t.allowExistingAuth&&c===e)?void 0:t.t("settings.providers.page.custom.error.apiKey.required"),g=r.includes(e),y=u||!!(c&&c===e)?void 0:t.existingProviderIDs.has(e)&&!g?t.t("settings.providers.page.custom.error.providerID.exists"):void 0,b=new Set,x=t.form.models.map(j=>{const C=j.id.trim(),E=C?b.has(C)?t.t("settings.providers.page.custom.error.duplicate"):void b.add(C):t.t("settings.providers.page.custom.error.required"),F=j.name.trim()?void 0:t.t("settings.providers.page.custom.error.required"),O=j.contextWindow.trim()&&!fo(j.contextWindow)?t.t("settings.providers.page.custom.error.positiveInteger"):void 0,K=j.maxOutputTokens.trim()&&!fo(j.maxOutputTokens)?t.t("settings.providers.page.custom.error.positiveInteger"):void 0;return{id:E,name:F,contextWindow:O,maxOutputTokens:K}}),w=x.every(j=>!j.id&&!j.name&&!j.contextWindow&&!j.maxOutputTokens),S=Object.fromEntries(t.form.models.map(j=>{const C=j.id.trim(),E={modelID:C,name:j.name.trim()},F=fo(j.contextWindow),O=fo(j.maxOutputTokens);(F||O)&&(E.limit={...F?{context:F}:{},...O?{output:O}:{}}),j.capabilitiesKnown&&(E.capabilities={tools:j.tools,input:j.inputCapabilities,output:j.outputCapabilities});const K=py(j.variants);return(K.length>0||j.savedVariants!==void 0)&&(E.variants=K.map(D=>({id:D,...j.savedVariants?.[D]??my(t.form.protocol,D)}))),[C,E]})),v=new Set,A=t.form.headers.map(j=>{const C=j.key.trim(),E=j.value.trim();if(!C&&!E)return{};const F=C?v.has(C.toLowerCase())?t.t("settings.providers.page.custom.error.duplicate"):void v.add(C.toLowerCase()):t.t("settings.providers.page.custom.error.required"),O=E?void 0:t.t("settings.providers.page.custom.error.required");return{key:F,value:O}}),I=A.every(j=>!j.key&&!j.value),N=Object.fromEntries(t.form.headers.map(j=>({key:j.key.trim(),value:j.value.trim()})).filter(j=>j.key&&j.value).map(j=>[j.key,j.value])),k={providerID:u??y,name:d,baseURL:l,apiKey:p};return!u&&!y&&!d&&!l&&!p&&w&&I?{err:k,models:x,headers:A,result:{providerID:e,name:a,icon:t.form.icon,apiKey:o,...!i&&!o?{keepsStoredCredential:!0}:{},config:ky({protocol:t.form.protocol,name:a,env:i,baseURL:n,headers:N,models:S})}}:{err:k,models:x,headers:A}}function fo(t){const e=t.trim();if(!/^\d+$/.test(e))return;const a=Number(e);return Number.isSafeInteger(a)&&a>0?a:void 0}function ky(t){const e={package:jl[t.protocol],name:t.name,settings:{baseURL:t.baseURL},models:t.models};return t.env&&(e.env=[t.env]),Object.keys(t.headers).length>0&&(e.headers=t.headers),e}function wy(t){return t.apiKey?{integrationID:t.providerID,key:t.apiKey}:null}function Sy(t,e){return{providerID:t.providerID,config:t.config,scope:e?.scope??"user",hasCredential:!!(t.apiKey||t.keepsStoredCredential)}}const Ny=[250,500,1e3,2e3];async function Cy(t,e=a=>new Promise(n=>setTimeout(n,a))){for(let a=0;;a+=1)try{await t();return}catch(n){const i=Ny[a];if(!(n instanceof Error&&/not found/i.test(n.message))||i===void 0)throw n;await e(i)}}const Iy=8,Py=t=>{const e=De.c(78),{models:a,existingIds:n,onAdd:i,onCancel:o}=t,{t:r}=Ee(),[c,u]=m.useState("");let d;e[0]!==n||e[1]!==a?(d=()=>new Set(a.filter(V=>!n.has(V.id)).map(Ay)),e[0]=n,e[1]=a,e[2]=d):d=e[2];const[l,f]=m.useState(d);let p,g,h,y,b,x,w,S,v,A;if(e[3]!==n||e[4]!==a||e[5]!==c||e[6]!==l||e[7]!==r){const V=c.trim().toLocaleLowerCase();A=V?a.filter(W=>[W.id,W.name,W.metadata?.name].some(Y=>Y?.toLocaleLowerCase().includes(V))):a;let L;e[18]!==n?(L=W=>!n.has(W.id),e[18]=n,e[19]=L):L=e[19],g=A.filter(L),p=g.length>0&&g.every(W=>l.has(W.id)),v=()=>f(W=>{const Y=new Set(W);for(const ae of g)p?Y.delete(ae.id):Y.add(ae.id);return Y}),S="space-y-2",w="flex items-end justify-between gap-2",b="min-w-0";let B;e[20]!==r?(B=r("settings.providers.page.custom.discovery.review"),e[20]=r,e[21]=B):B=e[21],e[22]!==B?(x=s.jsx("p",{className:Vt,children:B}),e[22]=B,e[23]=x):x=e[23],h=_t,y=r("settings.providers.page.custom.discovery.counts",{matching:A.length,total:a.length,selected:l.size}),e[3]=n,e[4]=a,e[5]=c,e[6]=l,e[7]=r,e[8]=p,e[9]=g,e[10]=h,e[11]=y,e[12]=b,e[13]=x,e[14]=w,e[15]=S,e[16]=v,e[17]=A}else p=e[8],g=e[9],h=e[10],y=e[11],b=e[12],x=e[13],w=e[14],S=e[15],v=e[16],A=e[17];let I;e[24]!==h||e[25]!==y?(I=s.jsx("p",{className:h,children:y}),e[24]=h,e[25]=y,e[26]=I):I=e[26];let N;e[27]!==b||e[28]!==x||e[29]!==I?(N=s.jsxs("div",{className:b,children:[x,I]}),e[27]=b,e[28]=x,e[29]=I,e[30]=N):N=e[30];const k=g.length===0;let P;e[31]!==p||e[32]!==r?(P=r(p?"settings.providers.page.custom.discovery.deselectAll":"settings.providers.page.custom.discovery.selectAll"),e[31]=p,e[32]=r,e[33]=P):P=e[33];let j;e[34]!==k||e[35]!==P||e[36]!==v?(j=s.jsx(H,{type:"button",variant:"ghost",size:"xs",disabled:k,onClick:v,children:P}),e[34]=k,e[35]=P,e[36]=v,e[37]=j):j=e[37];let C;e[38]!==j||e[39]!==w||e[40]!==N?(C=s.jsxs("div",{className:w,children:[N,j]}),e[38]=j,e[39]=w,e[40]=N,e[41]=C):C=e[41];let E;e[42]!==a.length||e[43]!==c||e[44]!==r?(E=a.length>Iy?s.jsxs("div",{className:"relative",children:[s.jsx(te,{name:"search",className:"pointer-events-none absolute inset-s-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":!0}),s.jsx(qe,{value:c,onChange:V=>u(V.target.value),onKeyDown:V=>{V.key==="Escape"&&c&&(V.preventDefault(),V.stopPropagation(),u(""))},placeholder:r("settings.agents.modelSelector.searchPlaceholder"),"aria-label":r("settings.agents.modelSelector.searchPlaceholder"),className:"h-8 rounded-md ps-8"})]}):null,e[42]=a.length,e[43]=c,e[44]=r,e[45]=E):E=e[45];let F;e[46]!==n||e[47]!==l||e[48]!==r||e[49]!==A?(F=A.length>0?A.map(V=>{const L=n.has(V.id),B=V.limit?.context??V.metadata?.limit?.context,W=V.limit?.output??V.metadata?.limit?.output,Y=[B?r("settings.providers.page.custom.discovery.contextValue",{value:Io(B)}):null,W?r("settings.providers.page.custom.discovery.outputValue",{value:Io(W)}):null].filter(Boolean).join(" · ");return s.jsx(ct,{checked:L||l.has(V.id),disabled:L,onChange:ae=>f(ee=>{const G=new Set(ee);return ae?G.add(V.id):G.delete(V.id),G}),label:s.jsx("span",{className:"block truncate font-mono text-xs",children:V.id}),description:L?r("settings.providers.page.custom.discovery.alreadyAdded"):Y||void 0,ariaLabel:V.id,className:"py-1.5"},V.id)}):s.jsx("p",{className:"px-2 py-6 text-center typography-meta text-muted-foreground",children:r("settings.agents.modelSelector.state.noModelsFound")}),e[46]=n,e[47]=l,e[48]=r,e[49]=A,e[50]=F):F=e[50];let O;e[51]!==F?(O=s.jsx(Os,{outerClassName:"oc-tile-inset max-h-[min(18rem,45dvh)] rounded-md",className:"px-2 py-1",disableHorizontal:!0,preventOverscroll:!0,useScrollShadow:!0,children:F}),e[51]=F,e[52]=O):O=e[52];const K=l.size===0;let D;e[53]!==a||e[54]!==i||e[55]!==l?(D=()=>i(a.filter(V=>l.has(V.id))),e[53]=a,e[54]=i,e[55]=l,e[56]=D):D=e[56];let M;e[57]!==l.size||e[58]!==r?(M=r("settings.providers.page.custom.discovery.importSelected",{count:l.size}),e[57]=l.size,e[58]=r,e[59]=M):M=e[59];let T;e[60]!==K||e[61]!==D||e[62]!==M?(T=s.jsx(H,{type:"button",size:"xs",className:"!font-normal",disabled:K,onClick:D,children:M}),e[60]=K,e[61]=D,e[62]=M,e[63]=T):T=e[63];let R;e[64]!==r?(R=r("settings.providers.page.custom.discovery.cancel"),e[64]=r,e[65]=R):R=e[65];let $;e[66]!==o||e[67]!==R?($=s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:o,children:R}),e[66]=o,e[67]=R,e[68]=$):$=e[68];let z;e[69]!==T||e[70]!==$?(z=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[T,$]}),e[69]=T,e[70]=$,e[71]=z):z=e[71];let Q;return e[72]!==C||e[73]!==E||e[74]!==O||e[75]!==z||e[76]!==S?(Q=s.jsxs("div",{className:S,children:[C,E,O,z]}),e[72]=C,e[73]=E,e[74]=O,e[75]=z,e[76]=S,e[77]=Q):Q=e[77],Q};function Ay(t){return t.id}const Ty=["text","image","audio","video","pdf"],Uc=t=>{const e=Number(t.trim());return Number.isSafeInteger(e)&&e>0?e:null},Ey=t=>{const e=De.c(70),{model:a,errors:n,expanded:i,onToggle:o,onChange:r,onToggleCapability:c,onToolsChange:u,onRemove:d}=t,{t:l}=Ee(),f=m.useId();let p;e[0]!==a.id?(p=a.id.trim(),e[0]=a.id,e[1]=p):p=e[1];const g=p;let h;e[2]!==a.name?(h=a.name.trim(),e[2]=a.name,e[3]=h):h=e[3];const y=h;let b;e[4]!==g||e[5]!==y||e[6]!==l?(b=y||g||l("settings.providers.page.custom.models.untitled"),e[4]=g,e[5]=y,e[6]=l,e[7]=b):b=e[7];const x=b;let w,S,v;if(e[8]!==a.contextWindow||e[9]!==a.inputCapabilities||e[10]!==a.maxOutputTokens||e[11]!==l){const L=Uc(a.contextWindow),B=Uc(a.maxOutputTokens),W=a.inputCapabilities.filter(My);w=L?l("settings.providers.page.custom.discovery.contextValue",{value:Io(L)}):null,S=B?l("settings.providers.page.custom.discovery.outputValue",{value:Io(B)}):null,v=W.length>0?W.join(", "):null,e[8]=a.contextWindow,e[9]=a.inputCapabilities,e[10]=a.maxOutputTokens,e[11]=l,e[12]=w,e[13]=S,e[14]=v}else w=e[12],S=e[13],v=e[14];let A;e[15]!==a.tools||e[16]!==l?(A=a.tools?null:l("settings.providers.page.custom.models.toolsOff"),e[15]=a.tools,e[16]=l,e[17]=A):A=e[17];let I;e[18]!==w||e[19]!==S||e[20]!==v||e[21]!==A?(I=[w,S,v,A].filter(Boolean),e[18]=w,e[19]=S,e[20]=v,e[21]=A,e[22]=I):I=e[22];const N=I.join(" · "),k=Dy,P=i&&"rotate-90 rtl:-rotate-90";let j;e[23]!==P?(j=ze("size-4 shrink-0 text-muted-foreground transition-transform",P),e[23]=P,e[24]=j):j=e[24];let C;e[25]!==j?(C=s.jsx(te,{name:"arrow-right-s",className:j,"aria-hidden":!0}),e[25]=j,e[26]=C):C=e[26];const E=!y&&!g&&"text-muted-foreground";let F;e[27]!==E?(F=ze("truncate",Vt,E),e[27]=E,e[28]=F):F=e[28];let O;e[29]!==F||e[30]!==x?(O=s.jsx("span",{className:F,children:x}),e[29]=F,e[30]=x,e[31]=O):O=e[31];let K;e[32]!==g||e[33]!==y?(K=y&&g&&y!==g?s.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",children:g}):null,e[32]=g,e[33]=y,e[34]=K):K=e[34];let D;e[35]!==O||e[36]!==K?(D=s.jsxs("span",{className:"flex min-w-0 items-baseline gap-2",children:[O,K]}),e[35]=O,e[36]=K,e[37]=D):D=e[37];let M;e[38]!==N?(M=N?s.jsx("span",{className:ze("truncate",_t),children:N}):null,e[38]=N,e[39]=M):M=e[39];let T;e[40]!==D||e[41]!==M?(T=s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[D,M]}),e[40]=D,e[41]=M,e[42]=T):T=e[42];let R;e[43]!==f||e[44]!==i||e[45]!==o||e[46]!==C||e[47]!==T?(R=s.jsxs("button",{type:"button",onClick:o,"aria-expanded":i,"aria-controls":f,className:"flex min-w-0 flex-1 items-center gap-2 rounded-md px-1 py-1.5 text-start hover:bg-[var(--interactive-hover)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[var(--interactive-focus-ring)]",children:[C,T]}),e[43]=f,e[44]=i,e[45]=o,e[46]=C,e[47]=T,e[48]=R):R=e[48];let $;e[49]!==d||e[50]!==l?($=d?s.jsx(H,{type:"button",variant:"ghost",size:"icon",className:Yt,onClick:d,"aria-label":l("settings.providers.page.custom.models.remove"),children:s.jsx(te,{name:"delete-bin",className:"size-4"})}):null,e[49]=d,e[50]=l,e[51]=$):$=e[51];let z;e[52]!==R||e[53]!==$?(z=s.jsxs("div",{className:"flex items-center gap-1 py-1",children:[R,$]}),e[52]=R,e[53]=$,e[54]=z):z=e[54];let Q;e[55]!==f||e[56]!==n?.contextWindow||e[57]!==n?.id||e[58]!==n?.maxOutputTokens||e[59]!==n?.name||e[60]!==i||e[61]!==a||e[62]!==r||e[63]!==c||e[64]!==u||e[65]!==l?(Q=i?s.jsxs("div",{id:f,className:"space-y-3 pb-4 ps-7 pe-1 pt-1",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-2 @xl:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:Vt,children:l("settings.providers.page.custom.models.idLabel")}),s.jsx(qe,{value:a.id,onChange:L=>r("id",L.target.value),placeholder:l("settings.providers.page.custom.models.idPlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-invalid":!!n?.id,"aria-label":l("settings.providers.page.custom.models.idLabel")}),k(n?.id)]}),s.jsxs("div",{children:[s.jsx("label",{className:Vt,children:l("settings.providers.page.custom.models.nameLabel")}),s.jsx(qe,{value:a.name,onChange:L=>r("name",L.target.value),placeholder:l("settings.providers.page.custom.models.namePlaceholder"),className:"mt-1 h-8 rounded-md px-3","aria-invalid":!!n?.name,"aria-label":l("settings.providers.page.custom.models.nameLabel")}),k(n?.name)]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-2 @xl:grid-cols-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:Vt,children:l("settings.providers.page.custom.models.contextWindow")}),s.jsx(qe,{inputMode:"numeric",value:a.contextWindow,onChange:L=>r("contextWindow",L.target.value),placeholder:"128000",className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-invalid":!!n?.contextWindow,"aria-label":l("settings.providers.page.custom.models.contextWindow")}),k(n?.contextWindow)]}),s.jsxs("div",{children:[s.jsx("label",{className:Vt,children:l("settings.providers.page.custom.models.maxOutputTokens")}),s.jsx(qe,{inputMode:"numeric",value:a.maxOutputTokens,onChange:L=>r("maxOutputTokens",L.target.value),placeholder:"16384",className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-invalid":!!n?.maxOutputTokens,"aria-label":l("settings.providers.page.custom.models.maxOutputTokens")}),k(n?.maxOutputTokens)]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("label",{className:Vt,children:l("settings.providers.page.custom.models.variantsLabel")}),s.jsx(ts,{children:l("settings.providers.page.custom.models.variantsInfo")})]}),s.jsx(qe,{value:a.variants,onChange:L=>r("variants",L.target.value),placeholder:l("settings.providers.page.custom.models.variantsPlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":l("settings.providers.page.custom.models.variantsLabel")})]}),["inputCapabilities","outputCapabilities"].map(L=>s.jsxs("div",{className:"space-y-1",children:[s.jsx("span",{className:Vt,children:l(L==="inputCapabilities"?"settings.providers.page.custom.models.inputCapabilities":"settings.providers.page.custom.models.outputCapabilities")}),s.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:Ty.map(B=>s.jsx(ct,{checked:a[L].includes(B),onChange:()=>c(L,B),label:B,ariaLabel:B},B))})]},L)),s.jsx(ct,{checked:a.tools,onChange:u,label:l("settings.providers.page.custom.models.tools"),ariaLabel:l("settings.providers.page.custom.models.tools")}),a.metadataSource==="models.dev"||a.metadataSource==="provider-api"?s.jsx("p",{className:_t,children:a.metadataSource==="models.dev"?l("settings.providers.page.custom.discovery.source.models.dev"):l("settings.providers.page.custom.discovery.source.provider-api")}):null]}):null,e[55]=f,e[56]=n?.contextWindow,e[57]=n?.id,e[58]=n?.maxOutputTokens,e[59]=n?.name,e[60]=i,e[61]=a,e[62]=r,e[63]=c,e[64]=u,e[65]=l,e[66]=Q):Q=e[66];let V;return e[67]!==z||e[68]!==Q?(V=s.jsxs("div",{className:"border-b border-border/50 last:border-b-0",children:[z,Q]}),e[67]=z,e[68]=Q,e[69]=V):V=e[69],V};function My(t){return t!=="text"}function Dy(t){return t?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:t}):null}const Bc=({existingProviderIDs:t,disabledProviders:e=[],busy:a=!1,mode:n="create",initialValues:i,allowExistingAuth:o=!1,authFailureHint:r=null,onSubmit:c,onCancel:u,onDisconnect:d})=>{const{t:l}=Ee(),f=n==="edit",[p,g]=m.useState(()=>i??fy()),[h,y]=m.useState({}),[b,x]=m.useState([]),[w,S]=m.useState([]),[v,A]=m.useState(!1),[I,N]=m.useState(null),[k,P]=m.useState(null),[j,C]=m.useState(()=>new Set(i?[]:p.models.map(V=>V.row))),E=m.useRef(null),F=p.providerID.trim()||"custom",{hasLogo:O}=Hm(F);m.useEffect(()=>{i&&(f&&E.current===i.providerID||(E.current=f?i.providerID:null,g(i),y({}),x([]),S([]),C(new Set),P(null)))},[i,f]);const K=(V,L)=>{g(B=>({...B,[V]:L})),y(B=>({...B,[V]:void 0}))},D=(V,L,B)=>{g(W=>({...W,models:W.models.map((Y,ae)=>ae===V?{...Y,[L]:B,metadataSource:"manual"}:Y)})),x(W=>{const Y=[...W];return Y[V]={...Y[V]??{},[L]:void 0},Y})},M=(V,L,B)=>{g(W=>({...W,headers:W.headers.map((Y,ae)=>ae===V?{...Y,[L]:B}:Y)})),S(W=>{const Y=[...W];return Y[V]={...Y[V]??{},[L]:void 0},Y})},T=async()=>{A(!0),N(null);try{const V=Object.fromEntries(p.headers.map(Y=>[Y.key.trim(),Y.value.trim()]).filter(([Y,ae])=>Y&&ae)),L=await $t("/api/provider/discover-models",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({providerID:f?p.providerID:void 0,baseURL:p.baseURL,apiKey:p.apiKey,headers:V,enrich:!0,metadataProviderID:p.providerID})}),B=await L.json().catch(()=>null),W=cy.safeParse(B);if(!L.ok||!W.success)throw new Error(dy.safeParse(B).data?.error||l("settings.providers.page.custom.discovery.failed"));P(W.data.models)}catch(V){N(V instanceof Error?V.message:l("settings.providers.page.custom.discovery.failed"))}finally{A(!1)}},R=V=>{g(L=>{const B=new Set(L.models.map(ae=>ae.id.trim()).filter(Boolean)),W=V.filter(ae=>!B.has(ae.id)).map(uy),Y=L.models.filter(ae=>ae.id.trim()||ae.name.trim());return{...L,models:[...Y,...W]}}),x([]),P(null)},$=V=>C(L=>{const B=new Set(L);return B.has(V)?B.delete(V):B.add(V),B}),z=(V,L,B)=>{g(W=>({...W,models:W.models.map((Y,ae)=>{if(ae!==V)return Y;const ee=Y[L],G=ee.includes(B)?ee.filter(le=>le!==B):[...ee,B];return{...Y,[L]:G,capabilitiesKnown:!0,metadataSource:"manual"}})}))},Q=async V=>{if(V.preventDefault(),a)return;const L=jy({form:p,t:((W,Y)=>l(W,Y)),existingProviderIDs:t,disabledProviders:e,editingProviderID:f?p.providerID:void 0,allowExistingAuth:f&&o});y(L.err),x(L.models),S(L.headers);const B=p.models.filter((W,Y)=>Object.values(L.models[Y]??{}).some(Boolean)).map(W=>W.row);B.length>0&&C(W=>new Set([...W,...B])),L.result&&await c(L.result)};return s.jsxs("form",{onSubmit:Q,className:"space-y-0",children:[s.jsxs($e,{title:l(f?"settings.providers.page.custom.editTitle":"settings.providers.page.custom.title"),divider:!1,settingsItem:"providers.custom",contentClassName:Ts,children:[s.jsx("p",{className:_t,children:l("settings.providers.page.custom.description")}),r?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",role:"status",children:r}):null,s.jsxs(St,{label:l("settings.providers.page.custom.field.providerID.label"),info:l("settings.providers.page.custom.field.providerID.info"),children:[s.jsx(qe,{value:p.providerID,onChange:V=>K("providerID",V.target.value),placeholder:l("settings.providers.page.custom.field.providerID.placeholder"),className:"h-8 rounded-md px-3 font-mono text-xs",autoFocus:!f,disabled:f||a,"aria-invalid":!!h.providerID,"aria-label":l("settings.providers.page.custom.field.providerID.label")}),h.providerID?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:h.providerID}):null]}),s.jsx(St,{label:l("settings.providers.page.custom.field.protocol.label"),info:l("settings.providers.page.custom.field.protocol.info"),children:s.jsxs(Pt,{value:p.protocol,onValueChange:V=>{V in jl&&g(L=>({...L,protocol:V,models:L.models.map(B=>B.savedVariants?{...B,savedVariants:{}}:B)}))},disabled:a,children:[s.jsx(Ct,{"aria-label":l("settings.providers.page.custom.field.protocol.label"),className:"w-full",children:s.jsx(Kt,{})}),s.jsxs(It,{children:[s.jsx(bt,{value:"openai-chat",children:l("settings.providers.page.custom.field.protocol.openaiChat")}),s.jsx(bt,{value:"openai-responses",children:l("settings.providers.page.custom.field.protocol.openaiResponses")}),s.jsx(bt,{value:"anthropic-messages",children:l("settings.providers.page.custom.field.protocol.anthropicMessages")})]})]})}),s.jsxs(St,{label:l("settings.providers.page.custom.field.name.label"),info:l("settings.providers.page.custom.field.name.info"),children:[s.jsx(qe,{value:p.name,onChange:V=>K("name",V.target.value),placeholder:l("settings.providers.page.custom.field.name.placeholder"),className:"h-8 rounded-md px-3","aria-invalid":!!h.name,"aria-label":l("settings.providers.page.custom.field.name.label")}),h.name?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:h.name}):null]}),s.jsx(St,{label:l("settings.providers.page.custom.field.icon.label"),info:l("settings.providers.page.custom.field.icon.info"),children:s.jsxs("div",{className:"flex flex-wrap gap-1.5",role:"group","aria-label":l("settings.providers.page.custom.field.icon.label"),children:[s.jsx(H,{type:"button",variant:p.icon===null?"chip":"ghost",size:"icon",className:ze(Yt,p.icon===null&&"text-foreground"),"aria-label":l("settings.providers.page.custom.field.icon.option.default"),title:l("settings.providers.page.custom.field.icon.option.default"),"aria-pressed":p.icon===null,onClick:()=>g(V=>({...V,icon:null})),children:O?s.jsx(ln,{providerId:F,className:"size-4",ignoreCustomIcon:!0}):s.jsx(te,{name:"checkbox-blank-circle",className:"size-4 text-muted-foreground"})}),Ig.map(V=>s.jsx(H,{type:"button",variant:p.icon===V.id?"chip":"ghost",size:"icon",className:ze(Yt,p.icon===V.id&&"text-foreground"),"aria-label":l(`settings.providers.page.custom.field.icon.option.${V.id}`),title:l(`settings.providers.page.custom.field.icon.option.${V.id}`),"aria-pressed":p.icon===V.id,onClick:()=>g(L=>({...L,icon:V.id})),children:s.jsx(te,{name:V.icon,className:"size-4"})},V.id))]})}),s.jsxs(St,{label:l("settings.providers.page.custom.field.baseURL.label"),info:l("settings.providers.page.custom.field.baseURL.info"),children:[s.jsx(qe,{value:p.baseURL,onChange:V=>K("baseURL",V.target.value),placeholder:l("settings.providers.page.custom.field.baseURL.placeholder"),className:"h-8 rounded-md px-3 font-mono text-xs","aria-invalid":!!h.baseURL,"aria-label":l("settings.providers.page.custom.field.baseURL.label")}),h.baseURL?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:h.baseURL}):null]}),s.jsxs(St,{label:l("settings.providers.page.custom.field.apiKey.label"),info:l(f&&o?"settings.providers.page.custom.field.apiKey.editInfo":"settings.providers.page.custom.field.apiKey.info"),children:[s.jsx(qe,{type:"password",value:p.apiKey,onChange:V=>K("apiKey",V.target.value),placeholder:l(f&&o?"settings.providers.page.custom.field.apiKey.editPlaceholder":"settings.providers.page.custom.field.apiKey.placeholder"),className:"h-8 rounded-md px-3 font-mono text-xs","aria-invalid":!!h.apiKey,"aria-label":l("settings.providers.page.custom.field.apiKey.label")}),h.apiKey?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:h.apiKey}):null]})]}),s.jsxs($e,{title:l("settings.providers.page.custom.models.title"),contentClassName:Ts,children:[s.jsxs("div",{className:`${rn} space-y-2`,children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{T()},disabled:a||v||!p.baseURL.trim(),children:[s.jsx(te,{name:"search",className:"size-3.5"}),l(v?"settings.providers.page.custom.discovery.fetching":"settings.providers.page.custom.discovery.fetch")]}),s.jsx(ts,{children:l("settings.providers.page.custom.discovery.info")})]}),I?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",role:"alert",children:I}):null,k?s.jsx(Py,{models:k,existingIds:new Set(p.models.map(V=>V.id.trim()).filter(Boolean)),onAdd:R,onCancel:()=>P(null)}):null]}),s.jsx("div",{className:rn,children:p.models.map((V,L)=>s.jsx(Ey,{model:V,errors:b[L],expanded:j.has(V.row),onToggle:()=>$(V.row),onChange:(B,W)=>D(L,B,W),onToggleCapability:(B,W)=>z(L,B,W),onToolsChange:B=>g(W=>({...W,models:W.models.map((Y,ae)=>ae===L?{...Y,tools:B,capabilitiesKnown:!0,metadataSource:"manual"}:Y)})),onRemove:p.models.length>1?()=>{g(B=>({...B,models:B.models.filter((W,Y)=>Y!==L)})),x(B=>B.filter((W,Y)=>Y!==L))}:void 0},V.row))}),s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const V=Xo();g(L=>({...L,models:[...L.models,V]})),x(L=>[...L,{}]),C(L=>new Set([...L,V.row]))},children:l("settings.providers.page.custom.models.add")})]}),s.jsxs($e,{title:l("settings.providers.page.custom.headers.title"),contentClassName:Ts,children:[s.jsx("p",{className:_t,children:l("settings.providers.page.custom.headers.description")}),p.headers.map((V,L)=>s.jsx("div",{className:`${rn} space-y-2`,children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:Vt,children:l("settings.providers.page.custom.headers.keyLabel")}),s.jsx(qe,{value:V.key,onChange:B=>M(L,"key",B.target.value),placeholder:l("settings.providers.page.custom.headers.keyPlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":l("settings.providers.page.custom.headers.keyLabel")}),w[L]?.key?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:w[L]?.key}):null]}),s.jsxs("div",{children:[s.jsx("label",{className:Vt,children:l("settings.providers.page.custom.headers.valueLabel")}),s.jsx(qe,{value:V.value,onChange:B=>M(L,"value",B.target.value),placeholder:l("settings.providers.page.custom.headers.valuePlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":l("settings.providers.page.custom.headers.valueLabel")}),w[L]?.value?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:w[L]?.value}):null]})]}),s.jsx(H,{type:"button",variant:"ghost",size:"icon",className:Yt,disabled:p.headers.length<=1,onClick:()=>{p.headers.length<=1||(g(B=>({...B,headers:B.headers.filter((W,Y)=>Y!==L)})),S(B=>B.filter((W,Y)=>Y!==L)))},"aria-label":l("settings.providers.page.custom.headers.remove"),children:s.jsx(te,{name:"delete-bin",className:"size-4"})})]})},V.row)),s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{g(V=>({...V,headers:[...V.headers,kl()]})),S(V=>[...V,{}])},children:l("settings.providers.page.custom.headers.add")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-4",children:[u?s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:u,disabled:a,children:l("settings.providers.page.custom.actions.back")}):null,d?s.jsx(H,{type:"button",variant:"destructive",size:"xs",className:"!font-normal",onClick:()=>{d()},disabled:a,children:l("settings.providers.page.actions.disconnect")}):null,s.jsx(H,{type:"submit",size:"xs",className:"!font-normal",disabled:a,children:l(a?"settings.providers.page.actions.saving":f?"settings.providers.page.custom.actions.update":"settings.providers.page.custom.actions.save")})]})]})},Vc=({integrationId:t,keyMethod:e,connectKey:a,onSaved:n})=>{const{t:i}=Ee(),o=m.useMemo(()=>(e?.form??[]).filter(Kf),[e]),[r,c]=m.useState(""),[u,d]=m.useState({}),l=m.useMemo(()=>({..._f(o),...u}),[o,u]),[f,p]=m.useState(null),[g,h]=m.useState(!1),y=async()=>{const b=r.trim();if(!b){q.error(i("settings.providers.page.toast.apiKeyRequired"));return}const x=zf(o,l);if(x){p(i("settings.providers.page.auth.oauth.promptRequired",{field:Uf(x)}));return}p(null);const w={integrationID:t,key:b},S=Bf(o,l);Object.keys(S).length>0&&(w.answer=S),h(!0);try{await a(w),q.success(i("settings.providers.page.toast.apiKeySaved")),c(""),n()}catch(v){console.error("Failed to save API key:",v),q.error(i("settings.providers.page.toast.apiKeySaveFailed"))}finally{h(!1)}};return s.jsxs("div",{className:"py-1.5 space-y-3",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"typography-ui-label text-foreground flex items-center gap-1.5",children:[i("settings.providers.page.auth.apiKeyLabel"),s.jsx(ts,{children:i("settings.providers.page.auth.apiKeyTooltip")})]}),s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center gap-2 mt-1.5",children:[s.jsx(qe,{type:"password",value:r,onChange:b=>c(b.target.value),placeholder:i("settings.providers.page.auth.apiKeyPlaceholder"),className:"flex-1 font-mono text-xs"}),s.jsx(H,{size:"xs",className:"!font-normal shrink-0",onClick:()=>{y()},disabled:g,children:i(g?"settings.providers.page.actions.saving":"settings.providers.page.actions.saveKey")})]})]}),o.length>0?s.jsx($f,{fields:o,values:l,onChange:(b,x)=>d(w=>({...w,[b]:x}))}):null,f?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:f}):null]})},Hc=t=>{if(typeof t!="number"||Number.isNaN(t))return null;if(t===0)return"0";const e=qm(t);return e.endsWith(".0")?e.slice(0,-2):e},qc=async t=>{await Qs.getSdkClient().integration.connect.key(t)},On="__add_provider__",qa="__classification__",Ry=()=>{const{t}=Ee(),{isMobile:e}=Zs(),a=Hs(),n=ft(_=>$d(_,a)),i=re(_=>_.settingsProvidersConnectRequested),o=re(_=>_.setSettingsProvidersConnectRequested),r=re(_=>_.settingsProvidersClassificationRequested),c=re(_=>_.setSettingsProvidersClassificationRequested),u=re(_=>_.settingsProvidersOpenRequested),d=re(_=>_.setSettingsProvidersOpenRequested),[l,f]=m.useState(()=>i?On:r?qa:u??"");m.useEffect(()=>{i&&(f(On),o(!1))},[i,o]),m.useEffect(()=>{r&&(f(qa),c(!1))},[r,c]),m.useEffect(()=>{u&&(f(u),d(null))},[u,d]);const p=ft(_=>_.getModelMetadata),g=re(_=>_.hiddenModels),h=re(_=>_.customProviderIcons),y=re(_=>_.setCustomProviderIcon),b=re(_=>_.toggleHiddenModel),x=re(_=>_.hideAllModels),w=re(_=>_.showAllModels),S=ft(_=>_.loadProviders);m.useEffect(()=>{S({directory:a,source:"settings:providers"})},[S,a]);const[v,A]=m.useState(()=>ru()),[I,N]=m.useState(!1),k=v?.integrations??null,[P,j]=m.useState(null);m.useEffect(()=>{let _=!0;return w1().then(ge=>{_&&j(ge)}).catch(ge=>{console.warn("[providers] could not read disabled providers:",ge)}),()=>{_=!1}},[]);const C=m.useCallback(async(_,ge)=>{try{j(await S1(_,ge)),ge&&f(""),q.success(ge?t("settings.providers.disabled.toast.disabled",{provider:_}):t("settings.providers.disabled.toast.enabled",{provider:_})),S({directory:a,source:"settings:providers",fresh:!0})}catch(Ae){q.error(Ae instanceof Error?Ae.message:String(Ae))}},[S,f,a,t]),E=v===null&&!I,[F,O]=m.useState(null),[K,D]=m.useState(null),[M,T]=m.useState(""),[R,$]=m.useState(""),[z,Q]=m.useState({}),[V,L]=m.useState({}),[B,W]=m.useState(0),[Y,ae]=m.useState(0),[ee,G]=m.useState(!1),le=Pn(),[J,me]=m.useState(null),[fe,oe]=m.useState(null),[pe,se]=m.useState(null),[ve,be]=m.useState(null),[ne,we]=m.useState(null),[Ne,Ie]=m.useState(null),Ce=l===On,Me=Ce&&R===br,he=!!(fe&&l&&fe===l&&!Ce);m.useEffect(()=>{let _=!0;return(async()=>{try{const Ae=await lu();if(!_)return;A(Ae),N(!1)}catch(Ae){if(!_)return;console.error("Failed to load provider integrations:",Ae),N(!0),q.error(t("settings.providers.page.toast.authMethodsLoadFailed"))}})(),()=>{_=!1}},[Y,t]);const Pe=m.useMemo(()=>new Set(n.map(_=>_.id)),[n]),Re=m.useMemo(()=>v?kf(v,Pe):null,[v,Pe]);m.useEffect(()=>{l!==On||!Re||Re.length===0||R&&R!==br&&!Re.some(_=>_.id===R)&&$("")},[l,R,Re]),m.useEffect(()=>{if(l===On){G(!0),me(null),oe(null),se(null),be(null),we(null);return}G(!1),me(null),fe&&fe!==l&&(oe(null),se(null),be(null),we(null))},[l,fe]),m.useEffect(()=>{if(!l||l===On||l===qa)return;const _=z[l];if(!_||k===null)return;const ge=n.find(Ge=>Ge.id===l),Ae=Dc({connections:So(k,l),optionsApiKey:qr(ge),machineCredentials:Wr(ge)}),Te=!!(ge&&_c(ge,_));M1({hasCredentials:Ae,userDismissed:J===l,isEditableCustomProvider:Te})&&G(!0)},[l,z,n,k,J]),m.useEffect(()=>{if(!l||l===On||l===qa)return;let _=!1;return(async()=>{try{const Ae=a?`?directory=${encodeURIComponent(a)}`:"",Te=await $t(`/api/provider/${encodeURIComponent(l)}/source${Ae}`,{method:"GET",headers:{Accept:"application/json"}}),Ge=await Te.json().catch(()=>null);if(!Te.ok)throw new Error(Ge?.error||t("settings.providers.page.toast.providerSourcesLoadFailed"));const ue=Ge?.sources??Ge?.data?.sources;!_&&ue&&(Q(Fe=>({...Fe,[l]:ue})),L(Fe=>({...Fe,[l]:vy.safeParse(Ge?.config??Ge?.data?.config).data??null})))}catch(Ae){_||console.error("Failed to load provider sources:",Ae)}})(),()=>{_=!0}},[l,B,a,t]);const ce=m.useCallback(()=>{W(_=>_+1)},[]),je=m.useCallback(()=>{ae(_=>_+1)},[]),de=m.useCallback(_=>{A(ge=>ge&&{...ge,integrations:ge.integrations.map(Ae=>Ae.id===_&&Ae.connections.length===0?{...Ae,connections:[{type:"credential",id:`pending:${_}`,label:_,method:"key"}]}:Ae)}),me(null),G(!1),$(""),f(_),ce(),je()},[je,ce,f]),ie=n.find(_=>_.id===l),xe=l?z[l]:void 0,Se=async _=>{const ge=`custom:${_.providerID}`;O(ge),Ie(_.providerID),we(null);try{const Ae=wy(_),Te=Sy(_,{scope:fe?ve??$c(z[fe]):"user"}),Ge=await $t(`/api/provider${a?`?directory=${encodeURIComponent(a)}`:""}`,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(Te)}),ue=await Ge.json().catch(()=>null);if(!Ge.ok)throw new Error(ue?.error||t("settings.providers.page.toast.customProviderSaveFailed"));if(Ae)try{await Cy(()=>Qs.getSdkClient().integration.connect.key(Ae))}catch(pt){throw we(t("settings.providers.page.custom.authFailure.keyAfterConfig")),pt}const Fe={...re.getState().customProviderIcons};_.icon?Fe[_.providerID]=_.icon:delete Fe[_.providerID],await jt({customProviderIcons:Fe}),y(_.providerID,_.icon),q.success(t("settings.providers.page.toast.customProviderSaved",{provider:_.name})),$(""),oe(null),se(null),be(null),we(null),Ie(null),de(_.providerID)}catch(Ae){console.error("Failed to save custom provider:",Ae),q.error(Ae instanceof Error&&Ae.message?Ae.message:t("settings.providers.page.toast.customProviderSaveFailed"))}finally{O(null)}},Le=_=>{G(!1),de(_)},Ue=async _=>{const ge=`disconnect:${_}`;O(ge);try{const Ae=Mc(Sn(k??[],_)),Te=Qs.getSdkClient();for(const Ge of Ae)await Te.credential.remove({credentialID:Ge.id});q.success(t("settings.providers.page.toast.providerDisconnected")),me(null),ce(),je()}catch(Ae){console.error("Failed to disconnect provider:",Ae),q.error(t("settings.providers.page.toast.providerDisconnectFailed"))}finally{O(null)}},Ye=async _=>{_&&(await Ue(_),oe(null),se(null),be(null),we(null),Ie(null),$(""))},lt=async(_,ge,Ae)=>{D(_.id);try{await ge(),Ae.success&&q.success(Ae.success)}catch(Te){console.error("Provider account action failed:",Te),q.error(Ae.failure)}finally{D(null),je()}},at=_=>lt(_,async()=>{await Qs.getSdkClient().credential.activate({credentialID:_.id})},{success:t("settings.providers.accounts.toast.switched",{account:_.label}),failure:t("settings.providers.accounts.toast.switchFailed")}),ut=(_,ge)=>lt(_,async()=>{await Qs.getSdkClient().credential.update({credentialID:_.id,label:ge})},{failure:t("settings.providers.accounts.toast.renameFailed")}),vt=_=>lt(_,async()=>{await Qs.getSdkClient().credential.remove({credentialID:_.id}),ce()},{success:t("settings.providers.accounts.toast.removed"),failure:t("settings.providers.accounts.toast.removeFailed")}),We=()=>{$(""),f("")},Ze=s.jsx(ii,{label:t("settings.providers.page.back"),onClick:We}),Xe=_=>{if(n.some(ge=>ge.id===_)){f(_);return}$(_),f(On)};if(l===qa)return s.jsx(X1,{titleLeading:Ze,onOpenProvider:Xe});if(Ce&&!le&&!R)return s.jsx(qt,{title:t("settings.providers.page.connect.title"),titleLeading:Ze,showSaveStatus:!1,children:s.jsx(C1,{providers:Re,loadFailed:I,onSelect:$,onSelectCustom:()=>$(br)})});if(Ce&&!le){const _=s.jsx(ii,{label:t("settings.providers.page.back"),onClick:()=>$("")}),ge=Re?.find(Ae=>Ae.id===R)?.name??R;return s.jsx(qt,{title:Me?t("settings.providers.page.connect.title"):ge,titleLeading:Me?_:s.jsxs("span",{className:"flex items-center gap-2",children:[_,s.jsx(ln,{providerId:R,className:"h-5 w-5 shrink-0"})]}),showSaveStatus:!1,children:Me?s.jsx(Bc,{mode:"create",existingProviderIDs:Pe,busy:F?.startsWith("custom:")??!1,authFailureHint:ne,onCancel:()=>{$(""),we(null),Ie(null)},onDisconnect:ne&&Ne?()=>{Ye(Ne)}:void 0,onSubmit:Se}):s.jsx($e,{title:t("settings.providers.page.auth.title"),divider:!1,settingsItem:"providers.auth",contentClassName:"space-y-4",children:E?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.providers.page.auth.loadingMethods")}):s.jsx(s.Fragment,{children:(()=>{const Ae=Sn(k??[],R),Te=Gr(Sn(k??[],Ii(R))),Ge=Ec(Ae);return s.jsxs(s.Fragment,{children:[Ge?s.jsx(Vc,{integrationId:R,keyMethod:Jr(Ae),connectKey:qc,onSaved:()=>de(R)},R):null,Te.length>0?s.jsx(_r,{integrationId:Ii(R),methods:Te,onConnected:()=>Le(R),className:ze(Ge&&"border-t border-[var(--surface-subtle)] pt-2")},R):null]})})()})})})}if(!ie)return s.jsx(U1,{providers:n,integrations:k,directory:a,onSelect:f,onConnect:()=>f(On),onOpenClassification:()=>f(qa),disabledProviders:P,onEnableProvider:_=>{C(_,!1)}});const it=Array.isArray(ie.models)?ie.models:[],dt=Sn(k??[],ie.id),Be=Gr(Sn(k??[],Ii(ie.id))),ot=Ec(dt),et=k!==null,ye=!!xe,Z=ye&&_c(ie,xe),Oe=Dc({connections:So(k??[],ie.id),optionsApiKey:qr(ie),machineCredentials:Wr(ie)}),Ve=N1(et,Oe,Z),X=E1({modelCount:it.length,integrationsLoaded:et,hasCredentials:Oe,isEditableCustomProvider:Z}),_e=So(k??[],ie.id)??[],nt=ie.integrationID??ie.id,ht=Mc(Sn(k??[],nt)),yt=ht[0]?.id??null,kt=new Set(_e.flatMap(_=>_.type==="credential"&&!ht.some(ge=>ge.id===_.id)?[_.id]:[])),He=[xe?.user.exists?t("settings.providers.page.connectionDetails.source.userConfig"):null,xe?.project.exists?t("settings.providers.page.connectionDetails.source.projectConfig"):null,xe?.custom?.exists?t("settings.providers.page.connectionDetails.source.customConfig"):null].filter(_=>_!==null),Je=s.jsxs("span",{className:"flex items-center gap-2",children:[Ze,s.jsx(ln,{providerId:ie.id,className:"h-5 w-5 shrink-0"})]}),mt=s.jsxs("span",{className:"typography-settings-description text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:ie.id}),He.length>0?s.jsxs(s.Fragment,{children:[" · ",t("settings.providers.page.configuredIn",{sources:He.join(", ")})]}):null]}),Qe=wa(it,M,_=>[typeof _?.name=="string"?_.name:"",typeof _?.id=="string"?_.id:""]);return he&&Z&&pe?s.jsx(qt,{title:ie.name||ie.id,titleLeading:Je,description:mt,showSaveStatus:!1,children:s.jsx(Bc,{mode:"edit",existingProviderIDs:Pe,initialValues:pe,allowExistingAuth:Oe||!ye,busy:F?.startsWith("custom:")??!1,authFailureHint:ne,onCancel:()=>{oe(null),se(null),be(null),we(null),Ie(null)},onDisconnect:()=>{Ye(ie.id)},onSubmit:Se})}):s.jsxs(qt,{title:ie.name||ie.id,titleLeading:Je,description:mt,showSaveStatus:!1,children:[s.jsxs($e,{title:t("settings.providers.accounts.title"),info:t("settings.providers.accounts.info"),divider:!1,headerAction:s.jsxs("div",{className:"flex items-center gap-1",children:[Z&&!le?s.jsx(H,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{we(null),se(yy(ie,V[ie.id]??null,h[ie.id])),be($c(xe)),oe(ie.id)},children:t("settings.providers.page.actions.edit")}):null,P!==null?s.jsx(H,{variant:"outline",size:"xs",className:"!font-normal",title:t("settings.providers.disabled.disableHint"),onClick:()=>{C(ie.id,!0)},children:t("settings.providers.disabled.disable")}):null,le?null:s.jsx(H,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const _=!ee;G(_),me(_?null:ie.id)},children:ee?t("settings.providers.page.actions.cancel"):s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"add",className:"size-3.5"}),_e.length>0?t("settings.providers.accounts.add"):t("settings.providers.page.actions.connect")]})})]}),settingsItem:"providers.auth",contentClassName:"space-y-4",children:[_e.length>0?s.jsx(ny,{connections:_e,activeId:yt,unusedIds:kt,busyId:K,onActivate:_=>{at(_)},onRename:(_,ge)=>{ut(_,ge)},onRemove:_=>{vt(_)}}):!ee&&Ve?s.jsxs("div",{className:"flex items-center gap-1.5 py-1.5",children:[s.jsx(te,{name:"alert",className:"w-4 h-4 text-[var(--status-warning)] shrink-0"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.providers.page.auth.incomplete")}),ot?s.jsx(ts,{children:t("settings.providers.page.auth.incompleteHint")}):null]}):null,le?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.providers.enterpriseMode")}):null,!ee||le?null:E?s.jsx("div",{className:"py-1.5 typography-meta text-muted-foreground",children:t("settings.providers.page.auth.loadingMethods")}):s.jsxs("div",{className:ze("space-y-4",_e.length>0&&"oc-tile rounded-xl p-4"),children:[ot?s.jsx(Vc,{integrationId:ie.id,keyMethod:Jr(dt),connectKey:qc,onSaved:()=>de(ie.id)},ie.id):null,Be.length>0&&s.jsx(_r,{integrationId:Ii(ie.id),methods:Be,onConnected:()=>Le(ie.id),className:ze(ot&&"border-t border-[var(--surface-subtle)] pt-2")},ie.id)]})]}),X?s.jsxs($e,{title:t("settings.providers.page.models.title"),titleAccessory:s.jsxs("span",{className:"typography-micro text-muted-foreground font-normal",children:["(",it.length,")"]}),headerAction:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(H,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const _=it.map(ge=>typeof ge?.id=="string"?ge.id:"").filter(ge=>ge.length>0);x(ie.id,_)},children:t("settings.providers.page.actions.hideAll")}),s.jsx(H,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>w(ie.id),children:t("settings.providers.page.actions.showAll")})]}),settingsItem:"providers.models",children:[s.jsxs("div",{className:"relative mb-2",children:[s.jsx(te,{name:"search",className:"absolute inset-s-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),s.jsx(qe,{value:M,onChange:_=>T(_.target.value),placeholder:t("settings.providers.page.models.filterPlaceholder"),className:"h-7 ps-8 w-full"})]}),Qe.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground py-4 text-center",children:t("settings.providers.page.models.noModelsMatchFilter")}):s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:Qe.map(_=>{const ge=typeof _?.id=="string"?_.id:"",Ae=typeof _?.name=="string"?_.name:ge,Te=ge?p(ie.id,ge):void 0,Ge=g.some(Nt=>Nt.providerID===ie.id&&Nt.modelID===ge),ue=Hc(Te?.limit?.context),Fe=Hc(Te?.limit?.output),pt=[ue?`${ue} ${t("settings.providers.page.models.tokenBadge.context")}`:null,Fe?`${Fe} ${t("settings.providers.page.models.tokenBadge.output")}`:null].filter(Boolean).join(" · "),At=[];return Te?.tool_call&&At.push({key:"tools",icon:"tools",label:t("settings.providers.page.models.capability.toolCalling")}),Te?.reasoning&&At.push({key:"reasoning",icon:"brain-ai-3",label:t("settings.providers.page.models.capability.reasoning")}),Te?.attachment&&At.push({key:"image",icon:"file-image",label:t("settings.providers.page.models.capability.imageInput")}),s.jsx("div",{className:"py-1.5",children:s.jsxs("div",{className:ze("flex items-center gap-3",Ge&&"opacity-50"),children:[s.jsx("span",{className:"typography-meta font-medium text-foreground truncate flex-1 min-w-0",children:Ae}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e?pt||At.length>0?s.jsx(ts,{className:"h-6 w-6",children:s.jsxs("div",{className:"space-y-1.5",children:[pt?s.jsx("div",{className:"font-medium",children:pt}):null,At.map(({key:Nt,icon:zt,label:es})=>s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(te,{name:zt,className:"h-3.5 w-3.5"}),es]},Nt))]})}):null:s.jsxs(s.Fragment,{children:[pt?s.jsx("span",{className:"typography-micro text-muted-foreground flex-shrink-0 oc-tile-inset px-1.5 py-0.5 rounded",children:pt}):null,At.length>0&&s.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:At.map(({key:Nt,icon:zt,label:es})=>s.jsx("span",{className:"flex h-5 w-5 rounded items-center justify-center text-muted-foreground oc-tile-inset",title:es,"aria-label":es,children:s.jsx(te,{name:zt,className:"h-3 w-3"})},Nt))})]}),s.jsx("button",{type:"button",onClick:()=>b(ie.id,ge),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50",title:t(Ge?"settings.providers.page.models.actions.showModelInSelectors":"settings.providers.page.models.actions.hideModelFromSelectors"),"aria-label":t(Ge?"settings.providers.page.models.actions.showModel":"settings.providers.page.models.actions.hideModel"),children:Ge?s.jsx(te,{name:"eye-off",className:"h-3.5 w-3.5"}):s.jsx(te,{name:"eye",className:"h-3.5 w-3.5"})})]})]})},ge)})})]}):null]})},Oy=t=>{const e=t?.windows??{},a=Object.values(e).map(n=>n.usedPercent).filter(n=>typeof n=="number");return a.length===0?null:Math.max(...a)},Fy=t=>{const e=De.c(75),{onItemSelect:a}=t,{t:n}=Ee(),i=ls(Ly),o=ls(Ky),r=ls(_y),c=ls($y),u=ls(zy),d=ls(Uy),l=ls(By),f=ls(Vy);let p,g;e[0]!==f?(p=()=>{f()},g=[f],e[0]=f,e[1]=p,e[2]=g):(p=e[1],g=e[2]),m.useEffect(p,g);const h=Hy;let y;e[3]!==l?(y=ee=>{ee!=="usage"&&ee!=="remaining"||(l(ee),h({usageDisplayMode:ee}))},e[3]=l,e[4]=y):y=e[4];const b=y;let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=ze("flex h-full flex-col","bg-background"),e[5]=x):x=e[5];let w;e[6]!==n?(w=n("settings.usage.sidebar.title"),e[6]=n,e[7]=w):w=e[7];let S;e[8]!==w?(S=s.jsx("h2",{className:`${Wn} mb-3`,children:w}),e[8]=w,e[9]=S):S=e[9];let v;e[10]!==n?(v=n("settings.usage.sidebar.total",{count:Po.length}),e[10]=n,e[11]=v):v=e[11];let A;e[12]!==v?(A=s.jsx("span",{className:"typography-meta text-muted-foreground",children:v}),e[12]=v,e[13]=A):A=e[13];let I;e[14]!==c?(I=()=>c(),e[14]=c,e[15]=I):I=e[15];let N;e[16]!==n?(N=n("settings.usage.sidebar.actions.refreshAria"),e[16]=n,e[17]=N):N=e[17];let k;e[18]!==n?(k=n("settings.usage.sidebar.actions.refreshTitle"),e[18]=n,e[19]=k):k=e[19];const P=u&&"animate-spin";let j;e[20]!==P?(j=ze("h-3.5 w-3.5",P),e[20]=P,e[21]=j):j=e[21];let C;e[22]!==j?(C=s.jsx(te,{name:"refresh",className:j}),e[22]=j,e[23]=C):C=e[23];let E;e[24]!==u||e[25]!==N||e[26]!==k||e[27]!==C||e[28]!==I?(E=s.jsx("div",{className:"flex items-center gap-2",children:s.jsx(H,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 text-muted-foreground",onClick:I,"aria-label":N,title:k,disabled:u,children:C})}),e[24]=u,e[25]=N,e[26]=k,e[27]=C,e[28]=I,e[29]=E):E=e[29];let F;e[30]!==E||e[31]!==A?(F=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[A,E]}),e[30]=E,e[31]=A,e[32]=F):F=e[32];let O;e[33]!==n?(O=n("settings.usage.sidebar.field.display"),e[33]=n,e[34]=O):O=e[34];let K;e[35]!==O?(K=s.jsx("span",{className:"typography-micro text-muted-foreground",children:O}),e[35]=O,e[36]=K):K=e[36];let D;e[37]!==n?(D=n("settings.usage.sidebar.field.displayModePlaceholder"),e[37]=n,e[38]=D):D=e[38];let M;e[39]!==D?(M=s.jsx(Ct,{className:"w-fit",children:s.jsx(Kt,{placeholder:D})}),e[39]=D,e[40]=M):M=e[40];let T;e[41]!==n?(T=n("settings.usage.sidebar.field.displayModeUsage"),e[41]=n,e[42]=T):T=e[42];let R;e[43]!==T?(R=s.jsx(bt,{value:"usage",children:T}),e[43]=T,e[44]=R):R=e[44];let $;e[45]!==n?($=n("settings.usage.sidebar.field.displayModeRemaining"),e[45]=n,e[46]=$):$=e[46];let z;e[47]!==$?(z=s.jsx(bt,{value:"remaining",children:$}),e[47]=$,e[48]=z):z=e[48];let Q;e[49]!==R||e[50]!==z?(Q=s.jsxs(It,{children:[R,z]}),e[49]=R,e[50]=z,e[51]=Q):Q=e[51];let V;e[52]!==b||e[53]!==M||e[54]!==Q||e[55]!==d?(V=s.jsxs(Pt,{value:d,onValueChange:b,children:[M,Q]}),e[52]=b,e[53]=M,e[54]=Q,e[55]=d,e[56]=V):V=e[56];let L;e[57]!==K||e[58]!==V?(L=s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[K,V]}),e[57]=K,e[58]=V,e[59]=L):L=e[59];let B;e[60]!==F||e[61]!==L||e[62]!==S?(B=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[S,F,L]}),e[60]=F,e[61]=L,e[62]=S,e[63]=B):B=e[63];let W;e[64]!==a||e[65]!==i||e[66]!==o||e[67]!==r||e[68]!==n?(W=Po.map(ee=>{const G=i.find(pe=>pe.providerId===ee.id),le=Oy(G?.usage),J=zd(le),me=ee.id===o,fe=G?.configured,oe=fe?J==="critical"?{backgroundColor:"var(--status-error)"}:J==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"}:{backgroundColor:"var(--surface-muted-foreground)",opacity:.4};return s.jsx("div",{className:ze("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200",me?"bg-interactive-selection":"hover:bg-interactive-hover"),children:s.jsxs("button",{type:"button",onClick:()=>{r(ee.id),a?.()},className:"flex min-w-0 flex-1 items-center gap-2 rounded-sm text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[s.jsx("span",{className:"h-2.5 w-2.5 rounded-full flex-shrink-0",style:oe}),s.jsx(ln,{providerId:ee.id,className:"h-4 w-4 flex-shrink-0"}),s.jsx("span",{className:"typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground",children:ee.name}),fe===!1&&s.jsx("span",{className:"typography-micro text-muted-foreground/60 flex-shrink-0",children:n("settings.usage.sidebar.status.notSet")})]})},ee.id)}),e[64]=a,e[65]=i,e[66]=o,e[67]=r,e[68]=n,e[69]=W):W=e[69];let Y;e[70]!==W?(Y=s.jsx(Os,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:W}),e[70]=W,e[71]=Y):Y=e[71];let ae;return e[72]!==B||e[73]!==Y?(ae=s.jsxs("div",{className:x,children:[B,Y]}),e[72]=B,e[73]=Y,e[74]=ae):ae=e[74],ae};function Ly(t){return t.results}function Ky(t){return t.selectedProviderId}function _y(t){return t.setSelectedProvider}function $y(t){return t.fetchAllQuotas}function zy(t){return t.isLoading}function Uy(t){return t.displayMode}function By(t){return t.setDisplayMode}function Vy(t){return t.loadSettings}async function Hy(t){try{await jt(t)}catch(e){console.warn("Failed to save usage settings:",e)}}const qy=t=>{const e=De.c(17),{percent:a,tonePercent:n,className:i}=t;let o;e[0]!==a?(o=Wm(a)??0,e[0]=a,e[1]=o):o=e[1];const r=o,c=n??a;let u;e[2]!==c?(u=zd(c),e[2]=c,e[3]=u):u=e[3];const d=u;let l;e[4]!==d?(l=d==="critical"?{backgroundColor:"var(--status-error)"}:d==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"},e[4]=d,e[5]=l):l=e[5];const f=l;let p;e[6]!==i?(p=ze("relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden",i),e[6]=i,e[7]=p):p=e[7];const g=`${r}%`;let h;e[8]!==f||e[9]!==g?(h={...f,width:g},e[8]=f,e[9]=g,e[10]=h):h=e[10];let y;e[11]!==r||e[12]!==h?(y=s.jsx("div",{className:"h-full transition-all duration-300",style:h,role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100}),e[11]=r,e[12]=h,e[13]=y):y=e[13];let b;return e[14]!==p||e[15]!==y?(b=s.jsx("div",{className:p,children:y}),e[14]=p,e[15]=y,e[16]=b):b=e[16],b},xr=t=>{const e=De.c(49),{title:a,window:n,subtitle:i,showToggle:o,toggleEnabled:r,onToggle:c,providerId:u}=t,d=o===void 0?!1:o,l=r===void 0?!1:r,{t:f}=Ee(),p=ls(Wy),g=re(Gy),h=p==="remaining"?n.remainingPercent:n.usedPercent,y=h!==null;let b;e[0]!==p||e[1]!==f?(b=f(p==="remaining"?"settings.usage.card.bar.remaining":"settings.usage.card.bar.used"),e[0]=p,e[1]=f,e[2]=b):b=e[2];const x=b;let w;e[3]!==h||e[4]!==n.valueLabel?(w=Gm(n.valueLabel,h),e[3]=h,e[4]=n.valueLabel,e[5]=w):w=e[5];const S=w;let v;if(e[6]!==f||e[7]!==g||e[8]!==n.resetAfterFormatted||e[9]!==n.resetAt||e[10]!==n.resetAtFormatted){const $=Jm(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,g);v=$?f("settings.usage.card.resetsAt",{time:$}):"",e[6]=f,e[7]=g,e[8]=n.resetAfterFormatted,e[9]=n.resetAt,e[10]=n.resetAtFormatted,e[11]=v}else v=e[11];const A=v;let I;e[12]!==a?(I=Qm(a),e[12]=a,e[13]=I):I=e[13];const N=I;let k;e[14]!==c||e[15]!==d||e[16]!==f||e[17]!==l?(k=d&&s.jsx(si,{checked:l,onChange:$=>c?.($),ariaLabel:f("settings.usage.card.showInHeaderAria")}),e[14]=c,e[15]=d,e[16]=f,e[17]=l,e[18]=k):k=e[18];let P;e[19]!==N?(P=s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:N}),e[19]=N,e[20]=P):P=e[20];let j;e[21]!==i?(j=i&&s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:i}),e[21]=i,e[22]=j):j=e[22];let C;e[23]!==P||e[24]!==j?(C=s.jsxs("div",{className:"min-w-0 flex flex-col",children:[P,j]}),e[23]=P,e[24]=j,e[25]=C):C=e[25];let E;e[26]!==C||e[27]!==k?(E=s.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[k,C]}),e[26]=C,e[27]=k,e[28]=E):E=e[28];let F;e[29]!==u||e[30]!==n?(F=u&&s.jsx(Ym,{window:n,providerId:u}),e[29]=u,e[30]=n,e[31]=F):F=e[31];const O=S==="-"?"":S;let K;e[32]!==O?(K=s.jsx("div",{className:"typography-ui-label text-foreground tabular-nums",children:O}),e[32]=O,e[33]=K):K=e[33];let D;e[34]!==F||e[35]!==K?(D=s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[F,K]}),e[34]=F,e[35]=K,e[36]=D):D=e[36];let M;e[37]!==E||e[38]!==D?(M=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[E,D]}),e[37]=E,e[38]=D,e[39]=M):M=e[39];let T;e[40]!==x||e[41]!==h||e[42]!==y||e[43]!==A||e[44]!==n.usedPercent?(T=y?s.jsxs("div",{className:"mt-2.5",children:[s.jsx(qy,{percent:h,tonePercent:n.usedPercent,className:"h-1.5"}),s.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:A}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:x})]})]}):A?s.jsx("div",{className:"mt-1 typography-micro text-muted-foreground",children:A}):null,e[40]=x,e[41]=h,e[42]=y,e[43]=A,e[44]=n.usedPercent,e[45]=T):T=e[45];let R;return e[46]!==M||e[47]!==T?(R=s.jsxs("div",{className:"py-3",children:[M,T]}),e[46]=M,e[47]=T,e[48]=R):R=e[48],R};function Wy(t){return t.displayMode}function Gy(t){return t.timeFormatPreference}const Jy=`ssh exe.dev "ssh-key generate-api-key --label=openchamber --exp=30d --cmds='billing credits usage'"`,Qy=({providerId:t,providerName:e})=>{const{t:a}=Ee(),[n,i]=m.useState(null),[o,r]=m.useState({}),[c,u]=m.useState(!1),d=`/api/quota/credentials/${t}`;m.useEffect(()=>{$t(d).then(async p=>{if(!p.ok)throw new Error;const g=await p.json();i(g),r({})}).catch(()=>i({configured:!1}))},[d]);const l=async(p,g,h)=>{u(!0);try{const y=await $t(p,{method:g,headers:h?{"Content-Type":"application/json"}:void 0,body:h?JSON.stringify(h):void 0}),b=await y.json().catch(()=>null);if(!y.ok)throw new Error(b?.error);b?.configured!==void 0&&i(b),r({}),q.success(a("settings.providers.page.quotaCredentials.saved",{provider:e}))}catch(y){q.error(y instanceof Error&&y.message?y.message:a("settings.providers.page.openCodeGo.saveFailed"))}finally{u(!1)}},f=(p,g,h)=>s.jsxs("label",{className:"block typography-ui-label text-foreground",children:[g,s.jsx(qe,{className:"mt-1 h-7 font-mono text-xs",type:"password",autoComplete:"off",value:o[p]??"",onChange:y=>r(b=>({...b,[p]:y.target.value})),placeholder:n?.secretMasked??h})]});return s.jsxs("div",{"data-settings-item":`usage.${t}-credentials`,className:"mb-8",children:[s.jsx("div",{className:"mb-1 px-1",children:s.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:e})}),s.jsxs("section",{className:"space-y-3 px-2 pb-2 pt-0",children:[t==="exe-dev"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:a("settings.providers.page.quotaCredentials.exeDevTokenInstructions")}),s.jsx("code",{className:"typography-code block whitespace-pre-wrap break-all rounded bg-muted/50 px-2 py-1.5 text-xs text-foreground",children:Jy})]}),t==="zenmux"&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:a("settings.providers.page.quotaCredentials.zenmuxInstructions")}),t==="exe-dev"&&f("usageToken",a("settings.providers.page.quotaCredentials.usageToken"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),t==="zenmux"&&f("platformApiKey",a("settings.providers.page.quotaCredentials.platformApiKey"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),t==="cursor"&&f("accessToken",a("settings.providers.page.quotaCredentials.accessToken"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),t==="cursor"&&f("refreshToken",a("settings.providers.page.quotaCredentials.refreshToken"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(H,{size:"xs",disabled:c,onClick:()=>l(d,"PUT",o),children:n?.configured?a("settings.providers.page.openCodeGo.replace"):a("settings.providers.page.openCodeGo.save")}),n?.configured&&s.jsx(H,{variant:"outline",size:"xs",disabled:c,onClick:()=>l(`${d}/validate`,"POST"),children:a("settings.providers.page.openCodeGo.validate")}),t==="cursor"&&s.jsx(H,{variant:"outline",size:"xs",disabled:c,onClick:()=>l(`${d}/import`,"POST"),children:a("settings.providers.page.actions.connect")}),n?.configured&&s.jsx(H,{variant:"destructive",size:"xs",disabled:c,onClick:()=>l(d,"DELETE"),children:a("settings.providers.page.openCodeGo.delete")})]})]})]})},Yy="claude-code",Zy="claude auth login",Ku=t=>({state:"ready",integration:Sn(t,Yy)}),Xy=t=>{const e=De.c(15),{onSignedIn:a}=t,{t:n}=Ee(),[i,o]=m.useState(e2);let r,c;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{let f=!1;return(async()=>{try{const p=await lu();f||o(Ku(p.integrations))}catch(p){console.error("Failed to load the Claude Code sign-in:",p),f||o(t2)}})(),()=>{f=!0}},c=[],e[0]=r,e[1]=c):(r=e[0],c=e[1]),m.useEffect(r,c),i.state==="loading")return null;let u;e[2]!==i.integration?(u=Gr(i.integration),e[2]=i.integration,e[3]=u):u=e[3];const d=u;if(!i.integration||d.length===0){let f;e[4]!==n?(f=n("settings.usage.page.state.claudeSignInCommand"),e[4]=n,e[5]=f):f=e[5];let p;e[6]!==f?(p=s.jsx("p",{className:"typography-meta text-[var(--status-warning)]/80",children:f}),e[6]=f,e[7]=p):p=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx("code",{className:"typography-code block whitespace-pre-wrap break-all rounded bg-muted/50 px-2 py-1.5 text-xs text-foreground",children:Zy}),e[8]=g):g=e[8];let h;return e[9]!==p?(h=s.jsxs("div",{className:"mt-1 space-y-1.5",children:[p,g]}),e[9]=p,e[10]=h):h=e[10],h}let l;return e[11]!==i.integration.id||e[12]!==d||e[13]!==a?(l=s.jsx(_r,{integrationId:i.integration.id,methods:d,onConnected:a,className:"mt-3"},i.integration.id),e[11]=i.integration.id,e[12]=d,e[13]=a,e[14]=l):l=e[14],l};function e2(){const t=ru();return t?Ku(t.integrations):{state:"loading"}}function t2(t){return t.state==="loading"?{state:"ready",integration:void 0}:t}const Wc=(t,e)=>{if(!t)return"-";try{return Ud(t,e,{fallback:"-"})}catch{return"-"}},s2=()=>{const{t}=Ee(),e=re(R=>R.timeFormatPreference),a=ls(R=>R.results),n=ls(R=>R.selectedProviderId),i=ls(R=>R.setSelectedProvider),o=ls(R=>R.loadSettings),r=ls(R=>R.fetchAllQuotas),c=ls(R=>R.fetchProviderQuota),u=ls(R=>R.isLoading),d=Hi(u),l=ls(R=>R.lastUpdated),f=ls(R=>R.refreshErrors),p=ls(R=>R.dropdownProviderIds),g=ls(R=>R.setDropdownProviderIds),h=ls(R=>R.selectedModels),y=ls(R=>R.toggleModelSelected),b=ls(R=>R.applyDefaultSelections);Zm(),m.useEffect(()=>{o(),r()},[o,r]),m.useEffect(()=>{if(n||a.length===0)return;const R=a.find($=>$.configured)?.providerId;i(R??Po[0]?.id??null)},[a,n,i]);const x=a.find(R=>R.providerId===n)??null,S=Po.find(R=>R.id===n)?.name??n??t("settings.usage.sidebar.title"),v=x?.usage,A=n?f[n]:void 0,I=A?v?t("header.services.usageRefreshFailedStale",{error:A}):A:x?.configured&&!x.ok?x.error:null,N=n?p.includes(n):!1,k=n==="exe-dev"||n==="cursor"||n==="zenmux"?n:null,P=k!==null,j=m.useCallback(R=>{if(!n)return;const $=R?Array.from(new Set([...p,n])):p.filter(z=>z!==n);g($),jt({usageDropdownProviders:$})},[p,n,g]),C=m.useMemo(()=>v?.models?Object.entries(v.models).map(([R,$])=>({name:R,windows:$})).filter(R=>Object.keys(R.windows.windows).length>0):[],[v?.models]);m.useEffect(()=>{n&&C.length>0&&b(n,C.map(R=>R.name))},[n,C,b]);const E=m.useMemo(()=>!n||C.length===0?new Map:Xm(C,R=>R.name,n),[C,n]),F=m.useMemo(()=>{if(!n)return[];const R=tp(n);return ep(R)},[n]),[O,K]=m.useState(()=>({})),D=m.useCallback(R=>{K($=>({...$,[R]:!$[R]}))},[]),M=m.useCallback(R=>{if(!n)return;y(n,R);const $=h[n]??[],Q=$.includes(R)?$.filter(L=>L!==R):[...$,R],V={...h,[n]:Q};jt({usageSelectedModels:V})},[n,h,y]),T=n?h[n]??[]:[];return n?s.jsxs(qt,{title:t("settings.usage.page.header.providerUsage",{provider:S}),titleLeading:s.jsx(ln,{providerId:n,className:"h-5 w-5 shrink-0"}),description:u?s.jsx("span",{className:ze("typography-settings-description text-muted-foreground",d),children:t("settings.usage.page.header.refreshing")}):x?.planLabel?t("settings.usage.page.header.lastUpdatedWithPlan",{plan:x.planLabel,time:Wc(l,e)}):t("settings.usage.page.header.lastUpdated",{time:Wc(l,e)}),showSaveStatus:!0,children:[s.jsx($e,{divider:!1,settingsItem:"usage.work-status-panel",children:s.jsx(ct,{checked:N,onChange:j,label:t("settings.usage.page.options.showInWorkStatus"),ariaLabel:t("settings.usage.page.options.showInWorkStatusAria"),info:t("settings.usage.page.options.showInWorkStatusTooltip")})}),!x&&s.jsx("p",{className:"typography-ui-label text-foreground pb-8",children:t("settings.usage.page.state.noData")}),I&&s.jsxs("div",{className:"mb-8 rounded-lg bg-[var(--status-error-background)] px-4 py-3",children:[s.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-error)]",children:t("settings.usage.page.state.refreshFailedTitle")}),s.jsx("p",{className:"typography-meta text-[var(--status-error)]/80 mt-1",children:I})]}),x&&!x.configured&&!P&&s.jsx("div",{className:"mb-8 rounded-lg bg-[var(--status-warning-background)] px-4 py-3",children:n==="claude"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-warning)]",children:t("settings.usage.page.state.claudeSignedOutTitle")}),s.jsx(Xy,{onSignedIn:()=>{c("claude")}})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-warning)]",children:t("settings.usage.page.state.providerNotConfiguredTitle")}),s.jsx("p",{className:"typography-meta text-[var(--status-warning)]/80 mt-1",children:t("settings.usage.page.state.providerNotConfiguredDescription")})]})}),k&&s.jsx(Qy,{providerId:k,providerName:S}),v?.windows&&Object.keys(v.windows).length>0&&s.jsx($e,{settingsItem:"usage.model-quotas",children:s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:Object.entries(v.windows).map(([R,$])=>s.jsx(xr,{title:R,window:$,providerId:n},R))})}),C.length>0&&s.jsxs($e,{title:t("settings.usage.page.section.modelQuotas"),contentClassName:"space-y-3",children:[F.map(R=>{const $=E.get(R.id)??[];if($.length===0)return null;const z=O[R.id]??!1;return s.jsx("section",{className:"p-2",children:s.jsxs(ha,{open:!z,onOpenChange:()=>D(R.id),children:[s.jsxs(ba,{className:"flex w-full items-center justify-between py-0.5 group",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-start",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:R.label}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",$.length,")"]})]}),z?s.jsx(te,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):s.jsx(te,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),s.jsx(xa,{children:s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:$.map(Q=>{const V=Object.entries(Q.windows.windows);if(V.length===0)return null;const[L,B]=V[0],W=T.includes(Q.name);return s.jsx(xr,{title:L,subtitle:Dl(Q.name),window:B,showToggle:!0,toggleEnabled:W,onToggle:()=>M(Q.name)},Q.name)})})})]})},R.id)}),(()=>{const R=E.get(null)??[];if(R.length===0)return null;const $=O.other??!1;return s.jsx("section",{className:"p-2",children:s.jsxs(ha,{open:!$,onOpenChange:()=>D("other"),children:[s.jsxs(ba,{className:"flex w-full items-center justify-between py-0.5 group",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-start",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:t("settings.usage.page.section.otherModels")}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",R.length,")"]})]}),$?s.jsx(te,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):s.jsx(te,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),s.jsx(xa,{children:s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:R.map(z=>{const Q=Object.entries(z.windows.windows);if(Q.length===0)return null;const[V,L]=Q[0],B=T.includes(z.name);return s.jsx(xr,{title:V,subtitle:Dl(z.name),window:L,showToggle:!0,toggleEnabled:B,onToggle:()=>M(z.name)},z.name)})})})]})})})()]}),x?.configured&&v&&Object.keys(v.windows??{}).length===0&&C.length===0&&s.jsxs("div",{className:"pb-8",children:[s.jsx("p",{className:"typography-ui-label text-foreground",children:t("settings.usage.page.state.noQuotaWindowsTitle")}),s.jsx("p",{className:"typography-meta text-muted-foreground mt-1",children:t("settings.usage.page.state.noQuotaWindowsDescription")})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label",children:t("settings.usage.page.empty.selectProvider")})})},n2="git.commit.generate",Qr=Jo(t=>({selectedPromptId:n2,setSelectedPromptId:e=>{t(a=>a.selectedPromptId===e?a:{selectedPromptId:e})}})),a2=t=>{const e=De.c(23),{onItemSelect:a}=t,{t:n}=Ee(),i=Qr(i2),o=Qr(o2);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={groupKey:"settings.magicPrompts.sidebar.group.git",items:[{id:"git.commit.generate",titleKey:"settings.magicPrompts.sidebar.item.gitCommitGenerate"},{id:"git.pr.generate",titleKey:"settings.magicPrompts.sidebar.item.gitPrGenerate"},{id:"git.conflict.resolve",titleKey:"settings.magicPrompts.sidebar.item.gitConflictResolve"},{id:"git.integrate.cherrypick.resolve",titleKey:"settings.magicPrompts.sidebar.item.gitCherrypickConflictResolve"}]},e[0]=r):r=e[0];let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c={groupKey:"settings.magicPrompts.sidebar.group.planning",items:[{id:"plan.todo",titleKey:"settings.magicPrompts.sidebar.item.planTodo"},{id:"plan.improve",titleKey:"settings.magicPrompts.sidebar.item.planImprove"},{id:"plan.implement",titleKey:"settings.magicPrompts.sidebar.item.planImplement"}]},e[1]=c):c=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u={groupKey:"settings.magicPrompts.sidebar.group.session",items:[{id:"session.explore",titleKey:"settings.magicPrompts.sidebar.item.sessionExplore"},{id:"session.summary",titleKey:"settings.magicPrompts.sidebar.item.sessionSummary"},{id:"session.review",titleKey:"settings.magicPrompts.sidebar.item.sessionWorkspaceReview"},{id:"session.plan",titleKey:"settings.magicPrompts.sidebar.item.sessionFeaturePlan"},{id:"session.craftGoal",titleKey:"settings.magicPrompts.sidebar.item.sessionCraftGoal"},{id:"session.catchup",titleKey:"settings.magicPrompts.sidebar.item.sessionCatchUp"},{id:"session.debug",titleKey:"settings.magicPrompts.sidebar.item.sessionDebug"},{id:"session.weigh",titleKey:"settings.magicPrompts.sidebar.item.sessionWeigh"},{id:"session.fusion",titleKey:"settings.magicPrompts.sidebar.item.sessionFusion"}]},e[2]=u):u=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=[r,c,u,{groupKey:"settings.magicPrompts.sidebar.group.memory",items:[{id:"memory.tidy",titleKey:"settings.magicPrompts.sidebar.item.memoryTidy"}]}],e[3]=d):d=e[3];const l=d;let f;e[4]!==n?(f=n("settings.magicPrompts.sidebar.title"),e[4]=n,e[5]=f):f=e[5];let p;e[6]!==f?(p=s.jsx("h2",{className:Wn,children:f}),e[6]=f,e[7]=p):p=e[7];let g;e[8]!==n?(g=n("settings.magicPrompts.sidebar.description"),e[8]=n,e[9]=g):g=e[9];let h;e[10]!==g?(h=s.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:g}),e[10]=g,e[11]=h):h=e[11];let y;e[12]!==p||e[13]!==h?(y=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[p,h]}),e[12]=p,e[13]=h,e[14]=y):y=e[14];let b;e[15]!==a||e[16]!==i||e[17]!==o||e[18]!==n?(b=s.jsx(Os,{outerClassName:"flex-1 min-h-0",className:"space-y-3 px-3 py-2 overflow-x-hidden",children:l.map(w=>s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro px-1 text-muted-foreground",children:n(w.groupKey)}),w.items.map(S=>{const v=i===S.id;return s.jsx("button",{type:"button",onClick:()=>{o(S.id),a?.()},className:ze("flex w-full items-center rounded-md px-2 py-1.5 text-start transition-colors",v?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:s.jsx("span",{className:"typography-ui-label truncate font-normal",children:n(S.titleKey)})},S.id)})]},w.groupKey))}),e[15]=a,e[16]=i,e[17]=o,e[18]=n,e[19]=b):b=e[19];let x;return e[20]!==b||e[21]!==y?(x=s.jsxs("div",{className:"flex h-full flex-col bg-background",children:[y,b]}),e[20]=b,e[21]=y,e[22]=x):x=e[22],x};function i2(t){return t.selectedPromptId}function o2(t){return t.setSelectedPromptId}const Gc={"git.commit.generate":{titleKey:"settings.magicPrompts.page.group.gitCommitGenerate.title",descriptionKey:"settings.magicPrompts.page.group.gitCommitGenerate.description",blocks:[{id:"git.commit.generate.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.commit.generate.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"git.pr.generate":{titleKey:"settings.magicPrompts.page.group.gitPrGenerate.title",descriptionKey:"settings.magicPrompts.page.group.gitPrGenerate.description",blocks:[{id:"git.pr.generate.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.pr.generate.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"git.conflict.resolve":{titleKey:"settings.magicPrompts.page.group.gitConflictResolve.title",descriptionKey:"settings.magicPrompts.page.group.gitConflictResolve.description",blocks:[{id:"git.conflict.resolve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.conflict.resolve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"git.integrate.cherrypick.resolve":{titleKey:"settings.magicPrompts.page.group.gitCherrypickConflictResolve.title",descriptionKey:"settings.magicPrompts.page.group.gitCherrypickConflictResolve.description",blocks:[{id:"git.integrate.cherrypick.resolve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"git.integrate.cherrypick.resolve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.improve":{titleKey:"settings.magicPrompts.page.group.planImprove.title",descriptionKey:"settings.magicPrompts.page.group.planImprove.description",blocks:[{id:"plan.improve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.improve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.todo":{titleKey:"settings.magicPrompts.page.group.planTodo.title",descriptionKey:"settings.magicPrompts.page.group.planTodo.description",blocks:[{id:"plan.todo.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.todo.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.implement":{titleKey:"settings.magicPrompts.page.group.planImplement.title",descriptionKey:"settings.magicPrompts.page.group.planImplement.description",blocks:[{id:"plan.implement.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.implement.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.summary":{titleKey:"settings.magicPrompts.page.group.sessionSummary.title",descriptionKey:"settings.magicPrompts.page.group.sessionSummary.description",blocks:[{id:"session.summary.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.summary.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.review":{titleKey:"settings.magicPrompts.page.group.sessionWorkspaceReview.title",descriptionKey:"settings.magicPrompts.page.group.sessionWorkspaceReview.description",blocks:[{id:"session.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.review.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.plan":{titleKey:"settings.magicPrompts.page.group.sessionFeaturePlan.title",descriptionKey:"settings.magicPrompts.page.group.sessionFeaturePlan.description",blocks:[{id:"session.plan.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.plan.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.craftGoal":{titleKey:"settings.magicPrompts.page.group.sessionCraftGoal.title",descriptionKey:"settings.magicPrompts.page.group.sessionCraftGoal.description",blocks:[{id:"session.craftGoal.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.craftGoal.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.catchup":{titleKey:"settings.magicPrompts.page.group.sessionCatchUp.title",descriptionKey:"settings.magicPrompts.page.group.sessionCatchUp.description",blocks:[{id:"session.catchup.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.catchup.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.debug":{titleKey:"settings.magicPrompts.page.group.sessionDebug.title",descriptionKey:"settings.magicPrompts.page.group.sessionDebug.description",blocks:[{id:"session.debug.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.debug.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.weigh":{titleKey:"settings.magicPrompts.page.group.sessionWeigh.title",descriptionKey:"settings.magicPrompts.page.group.sessionWeigh.description",blocks:[{id:"session.weigh.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.weigh.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.explore":{titleKey:"settings.magicPrompts.page.group.sessionExplore.title",descriptionKey:"settings.magicPrompts.page.group.sessionExplore.description",blocks:[{id:"session.explore.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.explore.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"session.fusion":{titleKey:"settings.magicPrompts.page.group.sessionFusion.title",descriptionKey:"settings.magicPrompts.page.group.sessionFusion.description",blocks:[{id:"session.fusion.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.fusion.instructions",titleKey:"settings.magicPrompts.page.block.instructions"},{id:"session.fusion.codeInstructions",titleKey:"settings.magicPrompts.page.block.codeFusionInstructions"}]},"memory.tidy":{titleKey:"settings.magicPrompts.page.group.memoryTidy.title",descriptionKey:"settings.magicPrompts.page.group.memoryTidy.description",blocks:[{id:"memory.tidy.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"memory.tidy.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]}},Jc=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),vr=t=>t.endsWith(".visible"),r2=()=>{const{t}=Ee(),e=m.useCallback(N=>t(N),[t]),a=Qr(N=>N.selectedPromptId),[n,i]=m.useState(!0),o=Hi(n),[r,c]=m.useState({}),[u,d]=m.useState({}),[l,f]=m.useState({}),[p,g]=m.useState({}),[h,y]=m.useState(!1);m.useEffect(()=>{let N=!0;return(async()=>{i(!0);try{const P=await ip();if(!N)return;c(P)}catch(P){console.warn("Failed to load magic prompts:",P),q.error(t("settings.magicPrompts.page.toast.loadFailed"))}finally{N&&i(!1)}})(),()=>{N=!1}},[t]);const b=Gc[a]??Gc["git.commit.generate"],x=m.useCallback(N=>Jc(r,N)?r[N]:sr(N),[r]),w=m.useCallback(N=>u[N]??x(N),[u,x]),S=m.useCallback((N,k)=>{d(P=>P[N]===k?P:{...P,[N]:k})},[]),v=m.useCallback(async N=>{const k=w(N);if(vr(N)&&k.trim().length===0){q.error(t("settings.magicPrompts.page.toast.visiblePromptRequired"));return}f(P=>({...P,[N]:!0}));try{const P=k===sr(N)?await Rl(N):await sp(N,k);c(P.overrides),q.success(t("settings.magicPrompts.page.toast.saved"))}catch(P){const j=P instanceof Error?P.message:String(P);q.error(t("settings.magicPrompts.page.toast.saveFailed"),{description:j})}finally{f(P=>({...P,[N]:!1}))}},[w,t]),A=m.useCallback(async N=>{g(k=>({...k,[N]:!0}));try{const k=await Rl(N);c(k.overrides),d(P=>({...P,[N]:sr(N)})),q.success(t("settings.magicPrompts.page.toast.resetSuccess"))}catch(k){const P=k instanceof Error?k.message:String(k);q.error(t("settings.magicPrompts.page.toast.resetFailed"),{description:P})}finally{g(k=>({...k,[N]:!1}))}},[t]),I=m.useCallback(async()=>{y(!0);try{const N=await np();c(N.overrides),d({}),q.success(t("settings.magicPrompts.page.toast.resetAllSuccess"))}catch(N){const k=N instanceof Error?N.message:String(N);q.error(t("settings.magicPrompts.page.toast.resetAllFailed"),{description:k})}finally{y(!1)}},[t]);return n?s.jsxs("div",{className:"py-6 px-6 flex items-center gap-2 text-muted-foreground",children:[s.jsx("span",{className:ze("inline-block h-1.5 w-1.5 rounded-full bg-current",o),"aria-label":t("settings.magicPrompts.page.loading.aria")}),s.jsx("span",{className:"typography-ui",children:t("settings.magicPrompts.page.loading.text")})]}):s.jsx(qt,{title:e(b.titleKey),titleAccessory:s.jsx(ts,{contentClassName:"max-w-xs",children:e(b.descriptionKey)}),headerEnd:s.jsx(H,{"data-settings-item":"magic-prompts.reset-overrides",variant:"outline",size:"sm",onClick:()=>{I()},disabled:h||Object.keys(r).length===0,children:t(h?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetAllOverrides")}),showSaveStatus:!1,children:b.blocks.map((N,k)=>{const P=ap(N.id),j=x(N.id),C=w(N.id),E=Jc(r,N.id),F=C!==j,O=vr(N.id)&&C.trim().length===0,K=l[N.id]===!0,D=p[N.id]===!0;return s.jsxs($e,{title:e(N.titleKey),info:P.description,description:P.placeholders&&P.placeholders.length>0?`${t("settings.magicPrompts.page.placeholdersLabel")} ${P.placeholders.map(M=>`{{${M.key}}}`).join(", ")}`:void 0,divider:k>0,settingsItem:vr(N.id)?"magic-prompts.visible-prompt":"magic-prompts.instructions",contentClassName:"space-y-3",children:[s.jsx(Cs,{value:C,onChange:M=>S(N.id,M.target.value),className:"min-h-[220px] font-mono text-sm"}),O&&s.jsx("div",{className:"typography-micro text-[var(--status-error)]",children:t("settings.magicPrompts.page.validation.visiblePromptRequired")}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:t(F?"settings.magicPrompts.page.status.unsavedChanges":E?"settings.magicPrompts.page.status.usingSavedOverride":"settings.magicPrompts.page.status.usingBuiltinDefault")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(H,{variant:"outline",size:"sm",onClick:()=>{A(N.id)},disabled:!E||K||D,children:t(D?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetToDefault")}),s.jsx(H,{size:"sm",onClick:()=>{v(N.id)},disabled:!F||K||D||O,children:t(K?"settings.common.actions.saving":"settings.magicPrompts.page.actions.save")})]})]})]},N.id)})})},l2=t=>{const e=De.c(89),{onItemSelect:a}=t,{t:n}=Ee(),[i,o]=m.useState(null),[r,c]=m.useState(null),[u,d]=m.useState(null),{selectedSnippetName:l,snippets:f,setSelectedSnippet:p,setSnippetDraft:g,deleteSnippet:h,loadSnippets:y}=Ao(_s(c2));let b,x;e[0]!==y?(b=()=>{y()},x=[y],e[0]=y,e[1]=b,e[2]=x):(b=e[1],x=e[2]),m.useEffect(b,x);let w;e[3]!==a||e[4]!==p||e[5]!==g||e[6]!==f?(w=async()=>{const se=new Set(f.map(d2));let ve="new-snippet",be=1;for(;se.has(ve);)ve=`new-snippet-${be++}`;g({name:ve,scope:"global"}),p(ve),a?.()},e[3]=a,e[4]=p,e[5]=g,e[6]=f,e[7]=w):w=e[7];const S=w;let v;e[8]!==i||e[9]!==h||e[10]!==n?(v=async()=>{if(!i)return;await h(i.name)?(q.success(n("settings.snippets.sidebar.toast.deleted")),o(null)):q.error(n("settings.snippets.sidebar.toast.deleteFailed"))},e[8]=i,e[9]=h,e[10]=n,e[11]=v):v=e[11];const A=v;let I;e[12]!==f?(I=[...f].sort(u2),e[12]=f,e[13]=I):I=e[13];const N=I;let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=ze("flex h-full flex-col","bg-background"),e[14]=k):k=e[14];let P;e[15]!==n?(P=n("settings.snippets.sidebar.title"),e[15]=n,e[16]=P):P=e[16];let j;e[17]!==P?(j=s.jsx("h2",{className:`${Wn} mb-3`,children:P}),e[17]=P,e[18]=j):j=e[18];let C;e[19]!==f.length||e[20]!==n?(C=n("settings.snippets.sidebar.total",{count:f.length}),e[19]=f.length,e[20]=n,e[21]=C):C=e[21];let E;e[22]!==C?(E=s.jsx("span",{className:"typography-meta text-muted-foreground",children:C}),e[22]=C,e[23]=E):E=e[23];let F;e[24]!==n?(F=n("settings.snippets.sidebar.actions.create"),e[24]=n,e[25]=F):F=e[25];let O;e[26]===Symbol.for("react.memo_cache_sentinel")?(O=s.jsx(te,{name:"add",className:"h-3.5 w-3.5"}),e[26]=O):O=e[26];let K;e[27]!==S||e[28]!==F?(K=s.jsx(H,{size:"sm","data-settings-item":"snippets.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:S,"aria-label":F,children:O}),e[27]=S,e[28]=F,e[29]=K):K=e[29];let D;e[30]!==E||e[31]!==K?(D=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[E,K]}),e[30]=E,e[31]=K,e[32]=D):D=e[32];let M;e[33]!==D||e[34]!==j?(M=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[j,D]}),e[33]=D,e[34]=j,e[35]=M):M=e[35];let T;if(e[36]!==a||e[37]!==r||e[38]!==u||e[39]!==l||e[40]!==p||e[41]!==N||e[42]!==n){let se;e[44]!==a||e[45]!==r||e[46]!==u||e[47]!==l||e[48]!==p||e[49]!==n?(se=ve=>s.jsxs(Vi,{open:u===ve.name,onOpenChange:be=>d(be?ve.name:null),children:[s.jsxs(Bi,{render:s.jsx("div",{className:ze("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",l===ve.name?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:be=>{be.preventDefault(),d(ve.name)}}),children:[s.jsxs("button",{onClick:()=>{p(ve.name),a?.()},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",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["#",ve.name]}),s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50",children:n(`snippets.source.${ve.source}`)})]}),s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:ve.description||ve.content.replace(/\s+/g," ").substring(0,80)})]}),s.jsxs(ka,{open:r===ve.name,onOpenChange:be=>{be&&d(null),c(be?ve.name:null)},children:[s.jsx(ja,{asChild:!0,children:s.jsx(H,{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","aria-label":n("settings.snippets.sidebar.actions.more",{name:ve.name}),children:s.jsx(te,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(ya,{align:"end",className:"w-fit min-w-20",children:s.jsxs(fa,{onClick:be=>{be.stopPropagation(),o(ve)},className:"text-destructive focus:text-destructive",children:[s.jsx(te,{name:"delete-bin",className:"h-4 w-4 me-px"}),n("settings.common.actions.delete")]})})]})]}),s.jsx(zi,{className:"w-fit min-w-20",children:s.jsxs(Ui,{onClick:be=>{be.stopPropagation(),o(ve)},className:"text-destructive focus:text-destructive",children:[s.jsx(te,{name:"delete-bin",className:"h-4 w-4 me-px"}),n("settings.common.actions.delete")]})})]},`${ve.source}:${ve.filePath}`),e[44]=a,e[45]=r,e[46]=u,e[47]=l,e[48]=p,e[49]=n,e[50]=se):se=e[50],T=N.map(se),e[36]=a,e[37]=r,e[38]=u,e[39]=l,e[40]=p,e[41]=N,e[42]=n,e[43]=T}else T=e[43];let R;e[51]!==T?(R=s.jsx(Os,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2",children:T}),e[51]=T,e[52]=R):R=e[52];const $=i!==null;let z;e[53]===Symbol.for("react.memo_cache_sentinel")?(z=se=>{se||o(null)},e[53]=z):z=e[53];let Q;e[54]!==n?(Q=n("settings.snippets.sidebar.dialog.deleteTitle"),e[54]=n,e[55]=Q):Q=e[55];let V;e[56]!==Q?(V=s.jsx(Ot,{children:Q}),e[56]=Q,e[57]=V):V=e[57];const L=i?.name??"";let B;e[58]!==n||e[59]!==L?(B=n("settings.snippets.sidebar.dialog.deleteDescription",{name:L}),e[58]=n,e[59]=L,e[60]=B):B=e[60];let W;e[61]!==B?(W=s.jsx(Ft,{children:B}),e[61]=B,e[62]=W):W=e[62];let Y;e[63]!==V||e[64]!==W?(Y=s.jsxs(Rt,{children:[V,W]}),e[63]=V,e[64]=W,e[65]=Y):Y=e[65];let ae;e[66]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>o(null),e[66]=ae):ae=e[66];let ee;e[67]!==n?(ee=n("settings.common.actions.cancel"),e[67]=n,e[68]=ee):ee=e[68];let G;e[69]!==ee?(G=s.jsx(H,{size:"sm",variant:"ghost",onClick:ae,children:ee}),e[69]=ee,e[70]=G):G=e[70];let le;e[71]!==n?(le=n("settings.common.actions.delete"),e[71]=n,e[72]=le):le=e[72];let J;e[73]!==A||e[74]!==le?(J=s.jsx(H,{size:"sm",onClick:A,children:le}),e[73]=A,e[74]=le,e[75]=J):J=e[75];let me;e[76]!==G||e[77]!==J?(me=s.jsxs(Wt,{children:[G,J]}),e[76]=G,e[77]=J,e[78]=me):me=e[78];let fe;e[79]!==Y||e[80]!==me?(fe=s.jsxs(Et,{className:"max-w-md",children:[Y,me]}),e[79]=Y,e[80]=me,e[81]=fe):fe=e[81];let oe;e[82]!==$||e[83]!==fe?(oe=s.jsx(Tt,{open:$,onOpenChange:z,children:fe}),e[82]=$,e[83]=fe,e[84]=oe):oe=e[84];let pe;return e[85]!==M||e[86]!==R||e[87]!==oe?(pe=s.jsxs("div",{className:k,children:[M,R,oe]}),e[85]=M,e[86]=R,e[87]=oe,e[88]=pe):pe=e[88],pe};function c2(t){return{selectedSnippetName:t.selectedSnippetName,snippets:t.snippets,setSelectedSnippet:t.setSelectedSnippet,setSnippetDraft:t.setSnippetDraft,deleteSnippet:t.deleteSnippet,loadSnippets:t.loadSnippets}}function d2(t){return t.name}function u2(t,e){return t.name.localeCompare(e.name)}const m2=()=>{const{t}=Ee(),{selectedSnippetName:e,snippets:a,snippetDraft:n,setSnippetDraft:i,updateSnippet:o,createSnippet:r}=Ao(_s(k=>({selectedSnippetName:k.selectedSnippetName,snippets:k.snippets,snippetDraft:k.snippetDraft,setSnippetDraft:k.setSnippetDraft,updateSnippet:k.updateSnippet,createSnippet:k.createSnippet}))),c=m.useMemo(()=>e?a.find(k=>k.name===e||k.aliases.includes(e))??null:null,[e,a]),u=!!(n&&n.name===e&&!c),[d,l]=m.useState(""),[f,p]=m.useState("global"),[g,h]=m.useState(""),[y,b]=m.useState(""),[x,w]=m.useState(""),[S,v]=m.useState(!1),A=m.useRef(null);m.useEffect(()=>{if(u&&n){const k={draftName:n.name||"",draftScope:n.scope||"global",description:n.description||"",aliases:(n.aliases||[]).join(", "),content:n.content||""};l(k.draftName),p(k.draftScope),h(k.description),b(k.aliases),w(k.content),A.current=k}else if(c){const k={draftName:"",draftScope:"global",description:c.description??"",aliases:c.aliases.join(", "),content:c.content};h(k.description),b(k.aliases),w(k.content),A.current=k}},[c,u,e,n]);const I=m.useMemo(()=>{const k=A.current;return k?u&&d!==k.draftName||u&&f!==k.draftScope?!0:g!==k.description||y!==k.aliases||x!==k.content:!1},[y,x,g,d,f,u]),N=async()=>{const k=u?d.trim().replace(/\s+/g,"-"):e?.trim();if(!k){q.error(t("settings.snippets.page.toast.nameRequired"));return}if(!x.trim()){q.error(t("settings.snippets.page.toast.contentRequired"));return}const P=y.split(",").map(j=>j.trim()).filter(Boolean);v(!0);try{if(!(u?await r(k,x,{aliases:P,description:g,scope:f}):await o(k,{content:x,aliases:P,description:g}))){q.error(t("settings.snippets.page.toast.saveFailed"));return}q.success(t("settings.snippets.page.toast.saved")),u&&i(null)}finally{v(!1)}};return e?s.jsxs(qt,{title:u?t("settings.snippets.page.title.new"):`#${e}`,description:c?c.filePath:void 0,showSaveStatus:!1,children:[s.jsxs($e,{divider:!1,contentClassName:"space-y-0",children:[u?s.jsxs(st,{label:"#",children:[s.jsx(qe,{value:d,onChange:k=>l(k.target.value),placeholder:t("settings.snippets.page.field.namePlaceholder"),className:"h-7 w-44 px-2"}),s.jsxs(Pt,{value:f,onValueChange:k=>p(k),children:[s.jsx(Ct,{className:"w-fit min-w-[100px]",children:s.jsx(Kt,{})}),s.jsxs(It,{align:"end",children:[s.jsx(bt,{value:"global",children:t("settings.common.scope.global")}),s.jsx(bt,{value:"project",children:t("settings.common.scope.project")})]})]})]}):null,s.jsx(St,{label:t("settings.common.field.description"),children:s.jsx(qe,{value:g,onChange:k=>h(k.target.value),placeholder:t("settings.snippets.page.field.descriptionPlaceholder"),className:"h-7 w-full max-w-sm px-2"})}),s.jsx(St,{label:t("settings.snippets.page.field.aliases"),children:s.jsx(qe,{value:y,onChange:k=>b(k.target.value),placeholder:t("settings.snippets.page.field.aliasesPlaceholder"),className:"h-7 w-full max-w-sm px-2"})})]}),s.jsxs($e,{settingsItem:"snippets.content",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.snippets.page.field.content")}),s.jsx(ts,{children:t("settings.snippets.page.hint")})]}),s.jsx(Cs,{value:x,onChange:k=>w(k.target.value),placeholder:t("settings.snippets.page.field.contentPlaceholder"),rows:12,className:"mt-1.5 w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent"}),s.jsx("div",{className:"pt-3",children:s.jsx(H,{onClick:N,disabled:S||!I,size:"xs",className:"!font-normal",children:t(S?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx(te,{name:"file-text",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-ui-label",children:t("settings.snippets.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.snippets.page.empty.description")})]})})},_u=()=>{const{t}=Ee(),e=ft(f=>f.settingsGitmojiEnabled),a=ft(f=>f.setSettingsGitmojiEnabled),n=Pg(),i=re(f=>f.gitChangesViewMode),o=re(f=>f.setGitChangesViewMode),[r,c]=m.useState(!0),u=m.useMemo(()=>[{id:"flat",label:t("settings.openchamber.git.option.flatList")},{id:"tree",label:t("settings.openchamber.git.option.treeView")}],[t]);m.useEffect(()=>{(async()=>{try{const p=await fn();p&&(p.gitmojiEnabled!==void 0&&a(p.gitmojiEnabled),p.gitChangesViewMode!==void 0&&o(p.gitChangesViewMode))}catch(p){console.warn("Failed to load git settings:",p)}finally{c(!1)}})()},[o,a]);const d=m.useCallback(async f=>{a(f);try{await jt({gitmojiEnabled:f})}catch(p){console.warn("Failed to save gitmoji setting:",p)}},[a]),l=m.useCallback(f=>{f!==i&&(o(f),jt({gitChangesViewMode:f}))},[i,o]);return r?null:s.jsx($e,{title:t("settings.openchamber.git.title"),children:s.jsxs("div",{className:bs,children:[s.jsx(ni,{settingsItem:"git.changes-view",title:t("settings.openchamber.git.changesViewTitle"),children:s.jsx(Vo,{"aria-label":t("settings.openchamber.git.changesViewAria"),children:u.map(f=>s.jsx(wn,{selected:i===f.id,onSelect:()=>{l(f.id)},label:f.label,ariaLabel:t("settings.openchamber.git.optionAria",{option:f.label})},f.id))})}),s.jsx(ct,{settingsItem:"git.gitmoji",checked:e,onChange:f=>{d(f)},label:t("settings.openchamber.git.enableGitmoji"),ariaLabel:t("settings.openchamber.git.enableGitmojiAria")}),s.jsx(ct,{settingsItem:"git.gitignored-files",checked:n,onChange:Ag,label:t("settings.openchamber.git.showGitignored"),ariaLabel:t("settings.openchamber.git.showGitignoredAria")})]})})},p2={neutral:"",error:"text-[var(--status-error)]",warning:"text-[var(--status-warning)]",success:"text-[var(--status-success)]"},yr=()=>({status:"idle",credentials:[],candidates:[],truncated:!1,discoveryAttempted:!1});function g2({selection:t,disabled:e=!1}){const{t:a}=Ee(),{git:n}=oi(),[i,o]=m.useState(yr),[r,c]=m.useState(!1),[u,d]=m.useState(""),l=m.useRef(0),f=t?.onChange;m.useLayoutEffect(()=>{const N=()=>{l.current+=1,o(yr()),c(!1),d("")};N();const k=ml(()=>{N(),f?.("")});return()=>{l.current+=1,k()}},[n,f]);const p=async N=>{if(!n.managedSshCredentials||e||i.status==="loading")return;const k=++l.current,P=Zt();o(j=>({...j,status:"loading",rejection:void 0,imported:!1}));try{const j=await n.managedSshCredentials(N);if(k!==l.current||P!==Zt())return;if(j.status==="unsupported"){c(!0),o(yr());return}if(c(!1),j.status==="available"){t?.value&&!j.credentials.some(E=>E.credentialId===t.value&&E.capability.status==="ready")&&t.onChange(""),d(""),o({status:"ready",credentials:j.credentials,candidates:[],truncated:!1,discoveryAttempted:!1});return}if(j.status==="discovered"){d(""),o(E=>({...E,status:"ready",candidates:j.candidates,truncated:j.truncated,discoveryAttempted:!0}));return}if(j.status==="rejected"){d(""),o(E=>({...E,status:"ready",rejection:j.reason}));return}d(""),t?.onChange(j.selectedCredential.credentialId);const C=N.operation==="import"?N.candidateId:"";o(E=>({...E,status:"ready",credentials:j.credentials,candidates:E.candidates.filter(F=>!("candidateId"in F)||F.candidateId!==C),truncated:!1,discoveryAttempted:!1,imported:!0}))}catch{k===l.current&&P===Zt()&&o(j=>({...j,status:"error",imported:!1}))}},g=m.useRef(p);g.current=p,m.useEffect(()=>{g.current({operation:"inventory"})},[n]);const h=N=>N.capability.status==="ready"?"":N.capability.reason==="unreadable"?a("settings.sourceControl.ssh.unreadable"):N.capability.reason==="fingerprint-mismatch"?a("settings.sourceControl.ssh.changed"):a("settings.sourceControl.ssh.unverifiable"),y=N=>N.capability.status==="ready"?"":N.capability.reason==="unreadable"?a("settings.sourceControl.ssh.unreadable"):N.capability.reason==="insecure-permissions"?a("settings.sourceControl.ssh.insecurePermissions"):a("settings.sourceControl.ssh.unverifiable"),b=()=>i.rejection?i.rejection==="candidate-expired"?a("settings.sourceControl.ssh.candidateExpired"):i.rejection==="candidate-changed"?a("settings.sourceControl.ssh.candidateChanged"):i.rejection==="fingerprint-mismatch"?a("settings.sourceControl.ssh.confirmationMismatch"):i.rejection==="inventory-full"?a("settings.sourceControl.ssh.inventoryFull"):a("settings.sourceControl.ssh.candidateUnavailable"):"",x=N=>[N.label,N.fingerprint,h(N)].filter(Boolean).join(" · "),w=i.credentials.find(N=>N.credentialId===t.value)??null,S=b(),v=e||i.status==="loading"||!n.managedSshCredentials,A=(N,k)=>({text:N,tone:k}),I=S?A(S,"error"):i.status==="error"?A(a("settings.sourceControl.ssh.operationFailed"),"error"):i.status==="loading"?A(a("settings.sourceControl.transport.loading"),"neutral"):r||!n.managedSshCredentials?A(a("settings.sourceControl.ssh.hostSetup"),"neutral"):i.truncated?A(a("settings.sourceControl.ssh.discoveryTruncated"),"warning"):i.imported?A(a("settings.sourceControl.ssh.imported"),"success"):i.status==="ready"&&i.discoveryAttempted&&!i.candidates.length?A(a("settings.sourceControl.ssh.discoveredEmpty"),"neutral"):i.status==="ready"&&!i.credentials.length?A(a("settings.sourceControl.ssh.empty"),"neutral"):null;return s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsxs(Pt,{value:t.value,onValueChange:t.onChange,disabled:e||i.status!=="ready",children:[s.jsx(Ct,{className:"min-w-0 max-w-full","aria-label":a("settings.sourceControl.ssh.title"),children:s.jsx(Kt,{placeholder:a("settings.sourceControl.ssh.title"),children:w?x(w):void 0})}),s.jsx(It,{children:i.credentials.map(N=>s.jsx(bt,{value:N.credentialId,disabled:N.capability.status!=="ready",children:x(N)},N.credentialId))})]}),i.status==="idle"||i.status==="error"?s.jsx(H,{size:"sm",variant:"outline",disabled:v,onClick:()=>{p({operation:"inventory"})},children:a("settings.sourceControl.ssh.load")}):null,s.jsx(H,{size:"sm",variant:"outline",disabled:v,onClick:()=>{p({operation:"discover"})},children:a("settings.sourceControl.ssh.discover")})]}),i.candidates.length?s.jsx("div",{className:"space-y-4",children:i.candidates.map((N,k)=>"candidateId"in N?s.jsxs("div",{className:"space-y-2 border-t border-border/60 pt-3",children:[s.jsx("p",{className:"typography-settings-field-label text-foreground",children:N.label}),s.jsx("p",{className:ze(_t,"break-all"),children:N.fingerprint}),s.jsx(ct,{checked:u===N.candidateId,onChange:P=>d(P?N.candidateId:""),disabled:e||i.status==="loading",className:"min-w-0 break-all",label:a("settings.sourceControl.ssh.confirmFingerprint",{fingerprint:N.fingerprint}),ariaLabel:a("settings.sourceControl.ssh.confirmFingerprint",{fingerprint:N.fingerprint})}),s.jsx(H,{size:"sm",variant:"default",disabled:e||i.status==="loading"||u!==N.candidateId,onClick:()=>{p({operation:"import",candidateId:N.candidateId,expectedFingerprint:N.fingerprint,confirmed:!0})},children:a("settings.sourceControl.ssh.import")})]},N.candidateId):s.jsx("p",{className:_t,children:[N.label,y(N)].filter(Boolean).join(" · ")},`${N.label}-${k}`))}):null,s.jsx("p",{role:I?.tone==="error"?"alert":"status",title:I?.text,className:ze(_t,"min-h-[1lh] truncate",I&&p2[I.tone]),children:I?.text})]})}const ho="__none__",Qc=t=>JSON.stringify([t.provider,t.instance,t.accountId]),Yc=[{method:"system",icon:"computer",labelKey:"settings.gitIdentities.editor.auth.system",hintKey:"settings.gitIdentities.editor.auth.systemHint"},{method:"account",icon:"user-3",labelKey:"settings.gitIdentities.editor.auth.account",hintKey:"settings.gitIdentities.editor.auth.accountHint"},{method:"ssh",icon:"lock",labelKey:"settings.gitIdentities.editor.auth.ssh",hintKey:"settings.gitIdentities.editor.auth.sshHint"},{method:"anonymous",icon:"global",labelKey:"settings.gitIdentities.editor.auth.anonymous",hintKey:"settings.gitIdentities.editor.auth.anonymousHint"}],Zc=[{key:"keyword",labelKey:"settings.gitIdentities.editor.color.green",cssVar:"var(--syntax-keyword)"},{key:"error",labelKey:"settings.gitIdentities.editor.color.red",cssVar:"var(--status-error)"},{key:"string",labelKey:"settings.gitIdentities.editor.color.cyan",cssVar:"var(--syntax-string)"},{key:"function",labelKey:"settings.gitIdentities.editor.color.orange",cssVar:"var(--syntax-function)"},{key:"type",labelKey:"settings.gitIdentities.editor.color.yellow",cssVar:"var(--syntax-type)"}],Xc=[{key:"branch",Icon:"git-branch",labelKey:"settings.gitIdentities.editor.icon.branch"},{key:"briefcase",Icon:"briefcase",labelKey:"settings.gitIdentities.editor.icon.work"},{key:"house",Icon:"home",labelKey:"settings.gitIdentities.editor.icon.personal"},{key:"graduation",Icon:"graduation-cap",labelKey:"settings.gitIdentities.editor.icon.school"},{key:"code",Icon:"code",labelKey:"settings.gitIdentities.editor.icon.code"},{key:"github",Icon:"github",label:"GitHub"},{key:"gitlab",Icon:"gitlab",label:"GitLab"}],Wa=t=>{const e=De.c(12),{label:a,info:n,children:i}=t;let o;e[0]!==a?(o=s.jsx("span",{className:Vt,children:a}),e[0]=a,e[1]=o):o=e[1];let r;e[2]!==n?(r=n!=null?s.jsx(ts,{contentClassName:"max-w-xs",children:n}):null,e[2]=n,e[3]=r):r=e[3];let c;e[4]!==o||e[5]!==r?(c=s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 @md:h-8 @md:w-32",children:[o,r]}),e[4]=o,e[5]=r,e[6]=c):c=e[6];let u;e[7]!==i?(u=s.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:i}),e[7]=i,e[8]=u):u=e[8];let d;return e[9]!==c||e[10]!==u?(d=s.jsxs("div",{className:"flex flex-col gap-1.5 @md:flex-row @md:items-start @md:gap-4",children:[c,u]}),e[9]=c,e[10]=u,e[11]=d):d=e[11],d},f2=({open:t,onOpenChange:e,profileId:a})=>{const{t:n}=Ee(),i=Ra(se=>se.getProfileById),o=Ra(se=>se.createProfile),r=Ra(se=>se.updateProfile),c=Ra(se=>se.deleteProfile),u=m.useMemo(()=>a&&a!=="new"?i(a):null,[a,i]),d=a==="new",l=a==="global",[f,p]=m.useState(""),[g,h]=m.useState(""),[y,b]=m.useState(""),[x,w]=m.useState(!1),[S,v]=m.useState(""),[A,I]=m.useState("keyword"),[N,k]=m.useState("branch"),[P,j]=m.useState(ho),[C,E]=m.useState("system"),[F,O]=m.useState(""),[K,D]=m.useState(!1),[M,T]=m.useState(!1),[R,$]=m.useState(!1),{sourceControl:z}=oi(),Q=Fs(se=>se.identities),V=Fs(se=>se.entries),L=Fs(se=>se.refreshAll);m.useEffect(()=>{t&&!l&&L(z)},[t,l,L,z]);const B=m.useMemo(()=>Q.flatMap(se=>{const ve=V[Ho(se)];return!ve?.hasChecked||ve.status?.status!=="connected"?[]:op(se,ve.status.accounts,be=>n(Bd(be.source)))}),[V,Q,n]),W=B.find(se=>se.key===P)??null,Y=u?.account&&P===Qc(u.account)?u.account:null,ae=W?.reference??Y,ee=C;m.useEffect(()=>{if(t){if(d)p(""),h(""),b(""),w(!1),v(""),I("keyword"),k("branch"),j(ho),E("system"),O("");else if(u)p(u.name),h(u.userName),b(u.userEmail),w(u.signCommits===!0),v(u.signingKey||""),I(u.color||"keyword"),k(u.icon||"branch"),j(u.account?Qc(u.account):ho),E(u.transport??"system"),O(u.sshCredentialId??"");else if(l){const se=i("global");se&&(p(se.name),h(se.userName),b(se.userEmail),w(!1),v(""),I(se.color||"keyword"),k(se.icon||"branch"))}}},[t,a,u,d,l,i]);const G=async()=>{if(!g.trim()||!y.trim()){q.error(n("settings.gitIdentities.editor.toast.userNameEmailRequired"));return}if(x&&!S.trim()){q.error(n("settings.gitIdentities.editor.toast.signingKeyRequired"));return}if(ee==="account"&&!ae){q.error(n("settings.gitIdentities.editor.toast.accountRequired"));return}if(ee==="ssh"&&!F.trim()){q.error(n("settings.gitIdentities.editor.toast.sshKeyRequired"));return}D(!0);try{const se={name:f.trim()||g.trim(),userName:g.trim(),userEmail:y.trim(),account:ae,transport:ee,signCommits:x,signingKey:S.trim()||null,color:A,icon:N};ee==="ssh"&&(se.sshCredentialId=F.trim());let ve;if(d)ve=await o(se);else if(a)ve=await r(a,se);else return;ve?(q.success(n(d?"settings.gitIdentities.editor.toast.profileCreated":"settings.gitIdentities.editor.toast.profileUpdated")),e(!1)):q.error(n(d?"settings.gitIdentities.editor.toast.createProfileFailed":"settings.gitIdentities.editor.toast.updateProfileFailed"))}catch(se){console.error("Error saving profile:",se),q.error(n("settings.gitIdentities.editor.toast.saveUnexpectedError"))}finally{D(!1)}},le=async()=>{if(!(!a||d)){$(!0);try{await c(a)?(q.success(n("settings.gitIdentities.editor.toast.profileDeleted")),T(!1),e(!1)):q.error(n("settings.gitIdentities.editor.toast.deleteProfileFailed"))}catch(se){console.error("Error deleting profile:",se),q.error(n("settings.gitIdentities.editor.toast.deleteUnexpectedError"))}finally{$(!1)}}},J=Zc.find(se=>se.key===A)?.cssVar??"var(--syntax-keyword)",me=Xc.find(se=>se.key===N)?.Icon??"git-branch",fe=se=>"labelKey"in se?n(se.labelKey):se.label,oe=n(Yc.find(se=>se.method===C)?.hintKey??"settings.gitIdentities.editor.auth.systemHint"),pe=d?n("settings.gitIdentities.editor.title.newIdentity"):l?n("settings.gitIdentities.editor.title.globalIdentity"):u?.name||n("settings.gitIdentities.editor.title.editIdentity");return s.jsxs(s.Fragment,{children:[s.jsx(Tt,{open:t,onOpenChange:e,children:s.jsxs(Et,{className:"max-w-xl max-h-[85vh] overflow-y-auto",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:pe}),l&&s.jsx(Ft,{children:n("settings.gitIdentities.editor.description.globalReadOnly")})]}),s.jsxs("div",{className:"@container flex flex-col gap-6",children:[!l&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ka,{children:[s.jsx(ja,{asChild:!0,children:s.jsx(H,{type:"button",variant:"outline",size:"icon",className:"shrink-0","aria-label":n("settings.gitIdentities.editor.appearance.aria"),title:n("settings.gitIdentities.editor.appearance.aria"),children:s.jsx(te,{name:me,className:"size-4",style:{color:J}})})}),s.jsx(ya,{align:"start",className:"w-64 p-3",children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:Vt,children:n("settings.gitIdentities.editor.field.color")}),s.jsx("div",{className:"flex items-center gap-2.5",children:Zc.map(se=>s.jsx("button",{type:"button",onClick:()=>I(se.key),"aria-pressed":A===se.key,"aria-label":n(se.labelKey),title:n(se.labelKey),className:ze("size-6 shrink-0 rounded-full transition-shadow",A===se.key&&"ring-2 ring-foreground ring-offset-2 ring-offset-background"),style:{backgroundColor:se.cssVar}},se.key))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:Vt,children:n("settings.gitIdentities.editor.field.icon")}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:Xc.map(se=>{const ve=N===se.key;return s.jsx("button",{type:"button",onClick:()=>k(se.key),"aria-pressed":ve,"aria-label":fe(se),title:fe(se),className:ze("inline-flex size-8 items-center justify-center rounded-md",ve?"bg-interactive-selection":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:s.jsx(te,{name:se.Icon,className:"size-4",style:ve?{color:J}:void 0})},se.key)})})]})]})})]}),s.jsx(qe,{value:f,onChange:se=>p(se.target.value),placeholder:n("settings.gitIdentities.editor.field.profileNamePlaceholder"),"aria-label":n("settings.gitIdentities.editor.field.profileName"),className:"min-w-0 flex-1"})]}),s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx(Wa,{label:n("settings.gitIdentities.editor.field.userName"),info:n("settings.gitIdentities.editor.field.userNameTooltip"),children:s.jsx(qe,{value:g,onChange:se=>h(se.target.value),placeholder:n("settings.gitIdentities.editor.field.userNamePlaceholder"),"aria-label":n("settings.gitIdentities.editor.field.userName"),required:!l,readOnly:l,disabled:l,className:"min-w-0 flex-1"})}),s.jsx(Wa,{label:n("settings.gitIdentities.editor.field.emailAddress"),info:n("settings.gitIdentities.editor.field.emailAddressTooltip"),children:s.jsx(qe,{type:"email",value:y,onChange:se=>b(se.target.value),placeholder:n("settings.gitIdentities.editor.field.emailAddressPlaceholder"),"aria-label":n("settings.gitIdentities.editor.field.emailAddress"),required:!l,readOnly:l,disabled:l,className:"min-w-0 flex-1"})}),!l&&s.jsxs(Wa,{label:n("settings.gitIdentities.editor.section.commitSigning"),children:[s.jsx(si,{checked:x,onChange:w,ariaLabel:n("settings.gitIdentities.editor.field.signCommits")}),s.jsx(qe,{value:S,onChange:se=>v(se.target.value),placeholder:n("settings.gitIdentities.editor.field.signingKeyPlaceholder"),"aria-label":n("settings.gitIdentities.editor.field.signingKey"),disabled:!x,className:"min-w-0 flex-1 font-mono text-xs"})]})]}),!l&&s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx(Wa,{label:n("settings.gitIdentities.editor.field.account"),children:s.jsxs(Pt,{value:P,onValueChange:j,children:[s.jsx(Ct,{className:"min-w-0 max-w-full","aria-label":n("settings.gitIdentities.editor.field.account"),children:s.jsx(Kt,{children:W?.label??Y?.instance??n("settings.gitIdentities.editor.field.accountNone")})}),s.jsxs(It,{children:[B.map(se=>s.jsx(bt,{value:se.key,children:se.label},se.key)),s.jsx(bt,{value:ho,children:n("settings.gitIdentities.editor.field.accountNone")})]})]})}),s.jsx(Wa,{label:n("settings.gitIdentities.editor.auth.label"),info:oe,children:s.jsx(Xt,{value:C,"aria-label":n("settings.gitIdentities.editor.auth.label"),onChange:se=>{E(se),se!=="ssh"&&O("")},options:Yc.map(se=>({value:se.method,label:s.jsxs(s.Fragment,{children:[s.jsx(te,{name:se.icon,className:"size-3.5"}),n(se.labelKey)]}),tooltip:n(se.hintKey)}))})}),s.jsx(Wa,{label:n("settings.gitIdentities.editor.field.sshKey"),info:n("settings.sourceControl.ssh.hostSetup"),children:ee==="ssh"?s.jsx(g2,{selection:{value:F,onChange:O}}):s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[s.jsxs(Pt,{value:"",disabled:!0,children:[s.jsx(Ct,{className:"min-w-0 max-w-full","aria-label":n("settings.gitIdentities.editor.field.sshKey"),children:s.jsx(Kt,{placeholder:n("settings.sourceControl.ssh.title")})}),s.jsx(It,{})]}),s.jsx("p",{"aria-hidden":"true",className:`${_t} min-h-[1lh]`})]})})]})]}),s.jsxs(Wt,{className:"sm:justify-between",children:[!l&&!d?s.jsx(H,{type:"button",variant:"ghost",size:"sm",className:"text-[var(--status-error)]",onClick:()=>T(!0),children:n("settings.common.actions.delete")}):s.jsx("span",{}),s.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row",children:[s.jsx(H,{type:"button",variant:"outline",size:"sm",onClick:()=>e(!1),children:n(l?"settings.gitIdentities.editor.actions.close":"settings.common.actions.cancel")}),!l&&s.jsx(H,{type:"button",size:"sm",onClick:G,disabled:K,children:n(K?"settings.common.actions.saving":d?"settings.gitIdentities.editor.actions.create":"settings.gitIdentities.editor.actions.save")})]})]})]})}),s.jsx(Tt,{open:M,onOpenChange:se=>{R||T(se)},children:s.jsxs(Et,{className:"max-w-md",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:n("settings.gitIdentities.page.deleteDialog.title")}),s.jsx(Ft,{children:n("settings.gitIdentities.page.deleteDialog.description",{name:u?.name||f})})]}),s.jsxs(Wt,{children:[s.jsx(H,{size:"sm",variant:"ghost",onClick:()=>T(!1),disabled:R,children:n("settings.common.actions.cancel")}),s.jsx(H,{size:"sm",variant:"destructive",onClick:()=>{le()},disabled:R,children:n("settings.common.actions.delete")})]})]})})]})},h2={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",github:"github",gitlab:"gitlab"},b2={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)"},x2=()=>{const t=De.c(103),{t:e}=Ee(),{sourceControl:a}=oi(),n=Fs(v2),{profiles:i,globalIdentity:o,defaultGitIdentityId:r,deleteProfile:c,loadProfiles:u,loadGlobalIdentity:d,loadDefaultGitIdentityId:l,setDefaultGitIdentityId:f}=Ra(_s(y2));let p,g;t[0]!==i||t[1]!==n||t[2]!==a?(p=()=>{n(a,i.map(j2))},g=[n,a,i],t[0]=i,t[1]=n,t[2]=a,t[3]=p,t[4]=g):(p=t[3],g=t[4]),m.useEffect(p,g);const[h,y]=m.useState(!1),[b,x]=m.useState(null),[w,S]=m.useState(null),[v,A]=m.useState(!1);let I,N;t[5]!==l||t[6]!==d||t[7]!==u?(I=()=>{u(),d(),l()},N=[u,d,l],t[5]=l,t[6]=d,t[7]=u,t[8]=I,t[9]=N):(I=t[8],N=t[9]),m.useEffect(I,N);let k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k=he=>{x(he),y(!0)},t[10]=k):k=t[10];const P=k;let j;t[11]!==r||t[12]!==f||t[13]!==e?(j=async he=>{const Pe=r===he?null:he;if(!await f(Pe)){q.error(e("settings.gitIdentities.page.toast.updateDefaultFailed"));return}q.success(e(Pe?"settings.gitIdentities.page.toast.defaultUpdated":"settings.gitIdentities.page.toast.defaultUnset"))},t[11]=r,t[12]=f,t[13]=e,t[14]=j):j=t[14];const C=j;let E;t[15]!==w||t[16]!==c||t[17]!==e?(E=async()=>{if(!w)return;A(!0),await c(w.id)?(q.success(e("settings.gitIdentities.page.toast.profileDeleted",{name:w.name})),S(null)):q.error(e("settings.gitIdentities.page.toast.deleteProfileFailed")),A(!1)},t[15]=w,t[16]=c,t[17]=e,t[18]=E):E=t[18];const F=E;let O;t[19]!==e?(O=e("settings.page.git.title"),t[19]=e,t[20]=O):O=t[20];let K;t[21]!==e?(K=e("settings.gitIdentities.page.section.title"),t[21]=e,t[22]=K):K=t[22];let D,M;t[23]===Symbol.for("react.memo_cache_sentinel")?(M=()=>P("new"),D=s.jsx(te,{name:"add",className:"w-3.5 h-3.5 me-1"}),t[23]=D,t[24]=M):(D=t[23],M=t[24]);let T;t[25]!==e?(T=e("settings.common.badge.new"),t[25]=e,t[26]=T):T=t[26];let R;t[27]!==T?(R=s.jsxs(H,{size:"sm",variant:"outline",onClick:M,children:[D," ",T]}),t[27]=T,t[28]=R):R=t[28];let $;t[29]!==r||t[30]!==o||t[31]!==C||t[32]!==i.length?($=o&&s.jsx(ed,{profile:o,isDefault:r==="global",onEdit:()=>P("global"),onToggleDefault:()=>C("global"),isReadOnly:!0,hasBorder:i.length>0}),t[29]=r,t[30]=o,t[31]=C,t[32]=i.length,t[33]=$):$=t[33];let z;if(t[34]!==r||t[35]!==C||t[36]!==i){let he;t[38]!==r||t[39]!==C||t[40]!==i.length?(he=(Pe,Re)=>s.jsx(ed,{profile:Pe,isDefault:r===Pe.id,onEdit:()=>P(Pe.id),onToggleDefault:()=>C(Pe.id),onDelete:()=>S(Pe),hasBorder:Re<i.length-1},Pe.id),t[38]=r,t[39]=C,t[40]=i.length,t[41]=he):he=t[41],z=i.map(he),t[34]=r,t[35]=C,t[36]=i,t[37]=z}else z=t[37];let Q;t[42]!==o||t[43]!==i.length||t[44]!==e?(Q=!o&&i.length===0&&s.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground",children:[s.jsx(te,{name:"shield-keyhole",className:"mx-auto mb-2 h-8 w-8 opacity-40"}),s.jsx("p",{className:"typography-ui-label",children:e("settings.gitIdentities.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.gitIdentities.page.empty.description")})]}),t[42]=o,t[43]=i.length,t[44]=e,t[45]=Q):Q=t[45];let V;t[46]!==$||t[47]!==z||t[48]!==Q?(V=s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[$,z,Q]}),t[46]=$,t[47]=z,t[48]=Q,t[49]=V):V=t[49];let L;t[50]!==R||t[51]!==V||t[52]!==K?(L=s.jsx($e,{title:K,headerAction:R,settingsItem:"git.identities",children:V}),t[50]=R,t[51]=V,t[52]=K,t[53]=L):L=t[53];let B;t[54]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx(_u,{}),t[54]=B):B=t[54];let W;t[55]!==L||t[56]!==O?(W=s.jsxs(qt,{title:O,showSaveStatus:!0,className:"px-4 @xl:px-6 @3xl:px-12",children:[L,B]}),t[55]=L,t[56]=O,t[57]=W):W=t[57];let Y;t[58]!==h||t[59]!==b?(Y=s.jsx(f2,{open:h,onOpenChange:y,profileId:b}),t[58]=h,t[59]=b,t[60]=Y):Y=t[60];const ae=w!==null;let ee;t[61]!==v?(ee=he=>{!he&&!v&&S(null)},t[61]=v,t[62]=ee):ee=t[62];let G;t[63]!==e?(G=e("settings.gitIdentities.page.deleteDialog.title"),t[63]=e,t[64]=G):G=t[64];let le;t[65]!==G?(le=s.jsx(Ot,{children:G}),t[65]=G,t[66]=le):le=t[66];const J=w?.name??"";let me;t[67]!==e||t[68]!==J?(me=e("settings.gitIdentities.page.deleteDialog.description",{name:J}),t[67]=e,t[68]=J,t[69]=me):me=t[69];let fe;t[70]!==me?(fe=s.jsx(Ft,{children:me}),t[70]=me,t[71]=fe):fe=t[71];let oe;t[72]!==le||t[73]!==fe?(oe=s.jsxs(Rt,{children:[le,fe]}),t[72]=le,t[73]=fe,t[74]=oe):oe=t[74];let pe;t[75]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>S(null),t[75]=pe):pe=t[75];let se;t[76]!==e?(se=e("settings.common.actions.cancel"),t[76]=e,t[77]=se):se=t[77];let ve;t[78]!==v||t[79]!==se?(ve=s.jsx(H,{size:"sm",variant:"ghost",onClick:pe,disabled:v,children:se}),t[78]=v,t[79]=se,t[80]=ve):ve=t[80];let be;t[81]!==F?(be=()=>{F()},t[81]=F,t[82]=be):be=t[82];let ne;t[83]!==e?(ne=e("settings.common.actions.delete"),t[83]=e,t[84]=ne):ne=t[84];let we;t[85]!==v||t[86]!==be||t[87]!==ne?(we=s.jsx(H,{size:"sm",variant:"destructive",onClick:be,disabled:v,children:ne}),t[85]=v,t[86]=be,t[87]=ne,t[88]=we):we=t[88];let Ne;t[89]!==ve||t[90]!==we?(Ne=s.jsxs(Wt,{children:[ve,we]}),t[89]=ve,t[90]=we,t[91]=Ne):Ne=t[91];let Ie;t[92]!==oe||t[93]!==Ne?(Ie=s.jsxs(Et,{className:"max-w-md",children:[oe,Ne]}),t[92]=oe,t[93]=Ne,t[94]=Ie):Ie=t[94];let Ce;t[95]!==ae||t[96]!==ee||t[97]!==Ie?(Ce=s.jsx(Tt,{open:ae,onOpenChange:ee,children:Ie}),t[95]=ae,t[96]=ee,t[97]=Ie,t[98]=Ce):Ce=t[98];let Me;return t[99]!==W||t[100]!==Y||t[101]!==Ce?(Me=s.jsxs(s.Fragment,{children:[W,Y,Ce]}),t[99]=W,t[100]=Y,t[101]=Ce,t[102]=Me):Me=t[102],Me},ed=t=>{const e=De.c(84),{profile:a,isDefault:n,onEdit:i,onToggleDefault:o,onDelete:r,isReadOnly:c,hasBorder:u}=t,{t:d}=Ee(),l=rp(),f=Fs(k2),[p,g]=m.useState(!1),h=h2[a.icon||"branch"]||"git-branch";let y;e[0]!==f?(y=z=>dp(z,f[Ho(z)]?.status?.accounts??null)==="cli-not-in-use"?"settings.gitIdentities.page.cliAccountInactive":"settings.gitIdentities.page.accountGone",e[0]=f,e[1]=y):y=e[1];const b=y;let x,w,S,v,A,I,N,k,P,j,C,E;if(e[2]!==b||e[3]!==l||e[4]!==p||e[5]!==u||e[6]!==h||e[7]!==n||e[8]!==c||e[9]!==r||e[10]!==i||e[11]!==o||e[12]!==a||e[13]!==d){const z=Tg(a)?a.account&&!lp(a,l)?b(a.account):null:"settings.gitIdentities.page.incomplete",Q=z!==null,V=b2[a.color||""];let L;e[26]!==i?(L=fe=>{fe.currentTarget===fe.target&&(fe.key!=="Enter"&&fe.key!==" "||(fe.preventDefault(),i()))},e[26]=i,e[27]=L):L=e[27];const B=L;let W;e[28]!==n||e[29]!==c||e[30]!==r||e[31]!==o||e[32]!==d?(W=fe=>s.jsxs(s.Fragment,{children:[s.jsx(fe,{onClick:oe=>{oe.stopPropagation(),o()},children:d(n?"settings.gitIdentities.page.actions.unsetDefault":"settings.gitIdentities.page.actions.setAsDefault")}),!c&&r&&s.jsxs(fe,{onClick:oe=>{oe.stopPropagation(),r()},className:"text-destructive focus:text-destructive",children:[s.jsx(te,{name:"delete-bin",className:"h-4 w-4 me-px"}),d("settings.common.actions.delete")]})]}),e[28]=n,e[29]=c,e[30]=r,e[31]=o,e[32]=d,e[33]=W):W=e[33],S=W,w=Vi,E=p,v=g,x=Bi;const Y=u&&"border-b border-[var(--surface-subtle)]";let ae;e[34]!==Y?(ae=ze("group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer",Y),e[34]=Y,e[35]=ae):ae=e[35];let ee;e[36]===Symbol.for("react.memo_cache_sentinel")?(ee=fe=>{fe.preventDefault(),g(!0)},e[36]=ee):ee=e[36],e[37]!==B||e[38]!==i||e[39]!==ae?(C=s.jsx("div",{className:ae,onClick:i,role:"button",tabIndex:0,onKeyDown:B,onContextMenu:ee}),e[37]=B,e[38]=i,e[39]=ae,e[40]=C):C=e[40],P="flex items-center gap-3 min-w-0";let G;e[41]!==V?(G={color:V},e[41]=V,e[42]=G):G=e[42],e[43]!==h||e[44]!==G?(j=s.jsx(te,{name:h,className:"w-4 h-4 shrink-0",style:G}),e[43]=h,e[44]=G,e[45]=j):j=e[45],N="min-w-0";let le;e[46]!==a||e[47]!==d?(le=cp(a,d),e[46]=a,e[47]=d,e[48]=le):le=e[48];let J;e[49]!==le?(J=s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:le}),e[49]=le,e[50]=J):J=e[50];let me;e[51]!==n||e[52]!==d?(me=n&&s.jsx("span",{className:"typography-micro text-primary bg-primary/12 px-1 rounded flex-shrink-0 leading-none pb-px border border-primary/25",children:d("settings.gitIdentities.page.badge.default")}),e[51]=n,e[52]=d,e[53]=me):me=e[53],e[54]!==J||e[55]!==me?(k=s.jsxs("div",{className:"flex items-center gap-1.5",children:[J,me]}),e[54]=J,e[55]=me,e[56]=k):k=e[56],A="typography-micro text-muted-foreground/60 truncate leading-tight",I=!c&&z?s.jsx("span",{className:Q?"text-[var(--status-warning)]":void 0,children:d(z)}):a.userEmail,e[2]=b,e[3]=l,e[4]=p,e[5]=u,e[6]=h,e[7]=n,e[8]=c,e[9]=r,e[10]=i,e[11]=o,e[12]=a,e[13]=d,e[14]=x,e[15]=w,e[16]=S,e[17]=v,e[18]=A,e[19]=I,e[20]=N,e[21]=k,e[22]=P,e[23]=j,e[24]=C,e[25]=E}else x=e[14],w=e[15],S=e[16],v=e[17],A=e[18],I=e[19],N=e[20],k=e[21],P=e[22],j=e[23],C=e[24],E=e[25];let F;e[57]!==A||e[58]!==I?(F=s.jsx("div",{className:A,children:I}),e[57]=A,e[58]=I,e[59]=F):F=e[59];let O;e[60]!==F||e[61]!==N||e[62]!==k?(O=s.jsxs("div",{className:N,children:[k,F]}),e[60]=F,e[61]=N,e[62]=k,e[63]=O):O=e[63];let K;e[64]!==O||e[65]!==P||e[66]!==j?(K=s.jsxs("div",{className:P,children:[j,O]}),e[64]=O,e[65]=P,e[66]=j,e[67]=K):K=e[67];let D;e[68]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(ja,{asChild:!0,children:s.jsx(H,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",onClick:w2,children:s.jsx(te,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[68]=D):D=e[68];let M;e[69]!==S?(M=s.jsxs(ka,{children:[D,s.jsx(ya,{align:"end",className:"w-fit min-w-28",children:S(fa)})]}),e[69]=S,e[70]=M):M=e[70];let T;e[71]!==x||e[72]!==K||e[73]!==M||e[74]!==C?(T=s.jsxs(x,{render:C,children:[K,M]}),e[71]=x,e[72]=K,e[73]=M,e[74]=C,e[75]=T):T=e[75];let R;e[76]!==S?(R=s.jsx(zi,{className:"w-fit min-w-28",children:S(Ui)}),e[76]=S,e[77]=R):R=e[77];let $;return e[78]!==w||e[79]!==v||e[80]!==T||e[81]!==R||e[82]!==E?($=s.jsxs(w,{open:E,onOpenChange:v,children:[T,R]}),e[78]=w,e[79]=v,e[80]=T,e[81]=R,e[82]=E,e[83]=$):$=e[83],$};function v2(t){return t.refreshIdentityAccounts}function y2(t){return{profiles:t.profiles,globalIdentity:t.globalIdentity,defaultGitIdentityId:t.defaultGitIdentityId,deleteProfile:t.deleteProfile,loadProfiles:t.loadProfiles,loadGlobalIdentity:t.loadGlobalIdentity,loadDefaultGitIdentityId:t.loadDefaultGitIdentityId,setDefaultGitIdentityId:t.setDefaultGitIdentityId}}function j2(t){return t.account}function k2(t){return t.entries}function w2(t){return t.stopPropagation()}const S2={success:"bg-[var(--status-success)]/15 text-[var(--status-success)]",warning:"bg-[var(--status-warning)]/15 text-[var(--status-warning)]",neutral:"oc-tile-inset text-muted-foreground"},di=t=>{const e=De.c(34),{settingsItem:a,logo:n,name:i,description:o,badges:r,status:c,statusTone:u,open:d,onOpenChange:l,children:f}=t;let p;e[0]!==n?(p=s.jsx("div",{className:"oc-tile-inset flex size-10 shrink-0 items-center justify-center rounded-[10px]",children:n}),e[0]=n,e[1]=p):p=e[1];let g;e[2]!==i?(g=s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:i}),e[2]=i,e[3]=g):g=e[3];let h;e[4]!==o?(h=s.jsx("p",{className:"mt-0.5 truncate text-xs leading-snug text-muted-foreground",children:o}),e[4]=o,e[5]=h):h=e[5];let y;e[6]!==g||e[7]!==h?(y=s.jsxs("div",{className:"min-w-0 flex-1",children:[g,h]}),e[6]=g,e[7]=h,e[8]=y):y=e[8];const b=S2[u];let x;e[9]!==b?(x=ze("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",b),e[9]=b,e[10]=x):x=e[10];let w;e[11]!==c||e[12]!==x?(w=s.jsx("span",{"aria-live":"polite",className:x,children:c}),e[11]=c,e[12]=x,e[13]=w):w=e[13];const S=d&&"rotate-180";let v;e[14]!==S?(v=ze("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",S),e[14]=S,e[15]=v):v=e[15];let A;e[16]!==v?(A=s.jsx(te,{name:"arrow-down-s",className:v}),e[16]=v,e[17]=A):A=e[17];let I;e[18]!==r||e[19]!==p||e[20]!==A||e[21]!==y||e[22]!==w?(I=s.jsxs(ba,{className:"oc-tile-hover flex w-full min-w-0 items-center gap-3 px-4 py-3 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[p,y,r,w,A]}),e[18]=r,e[19]=p,e[20]=A,e[21]=y,e[22]=w,e[23]=I):I=e[23];let N;e[24]!==f?(N=s.jsx(xa,{className:"px-4 pb-4 pt-3",children:f}),e[24]=f,e[25]=N):N=e[25];let k;e[26]!==a||e[27]!==I||e[28]!==N?(k=s.jsxs("div",{"data-settings-item":a,className:"oc-tile overflow-hidden rounded-xl",children:[I,N]}),e[26]=a,e[27]=I,e[28]=N,e[29]=k):k=e[29];let P;return e[30]!==l||e[31]!==d||e[32]!==k?(P=s.jsx(ha,{open:d,onOpenChange:l,children:k}),e[30]=l,e[31]=d,e[32]=k,e[33]=P):P=e[33],P},$u=({guest:t})=>{const{t:e}=Ee(),a=t.integration,n=nr(ae=>ae.byId[t.id]),i=nr(ae=>ae.setStatus),o=m.useMemo(()=>Vd(t.id,t.icon,Xd().authenticatedAsset),[t.id,t.icon]),r=nr(ae=>ae.refresh),[c,u]=m.useState(!1),[d,l]=m.useState(!1),[f,p]=m.useState(!1),[g,h]=m.useState(""),[y,b]=m.useState(""),[x,w]=m.useState(""),[S,v]=m.useState(""),[A,I]=m.useState({}),[N,k]=m.useState(!1),P=m.useRef(null),[j]=m.useState(Zt),C=m.useRef(!0),E=()=>C.current&&Zt()===j,F=m.useCallback(()=>{P.current!=null&&(window.clearInterval(P.current),P.current=null),p(!1)},[]);if(m.useEffect(()=>(C.current=!0,r(t.id),()=>{C.current=!1,F()}),[t.id,r,F]),m.useEffect(()=>{n&&I(n.settings)},[n]),!a)return null;const O=a.auth,K=O==="token"&&a.token?.scheme==="basic",D=!!n?.connection.connected,M=n?.connection.account.trim()||"",T=f?e("settings.integrations.guests.status.waiting"):D?M||e("settings.integrations.guests.status.connected"):e("settings.integrations.guests.status.notConnected"),R=f?"warning":D?"success":"neutral",$=f||c,z=a.name,Q=async()=>{if(!E())return!1;const ae=g.trim();if(!ae)return n?.hasClient?!0:(q.error(e("settings.integrations.guests.toast.clientRequired")),!1);Mt("saving");const ee=await xp(t.id,ae,y.trim()||void 0);return E()?ee?(i(t.id,ee),b(""),Mt("saved"),!0):(Mt("error"),q.error(e("settings.integrations.guests.toast.saveFailed",{name:z})),!1):!1},V=async(ae=A)=>{if(!E())return!1;const ee=n?.settings??{};if((a.settings??[]).every(me=>(ae[me.id]??"").trim()===(ee[me.id]??"")))return!0;Mt("saving");const J=await up(t.id,ae);return E()?J?(i(t.id,J),Mt("saved"),!0):(Mt("error"),q.error(e("settings.integrations.guests.toast.saveFailed",{name:z})),!1):!1},L=async()=>{if(!E())return!1;const ae=x.trim();if(!ae)return D?!0:(q.error(e("settings.integrations.guests.toast.tokenRequired")),!1);const ee=S.trim();if(K&&!ee)return q.error(e("settings.integrations.guests.toast.usernameRequired")),!1;Mt("saving");const G=await bp(t.id,ae,K?ee:void 0);return E()?G?(i(t.id,G),w(""),v(""),Mt("saved"),!0):(Mt("error"),q.error(e("settings.integrations.guests.toast.tokenInvalid")),!1):!1},B=async()=>{if(!E())return;F(),l(!0);const ae=n?.connection??{connected:!1,account:""};try{if(O==="token"){if(await L()){if((a.settings??[]).length>0&&!await V()||!E())return;q.success(e("settings.integrations.guests.toast.connected",{name:z}))}return}if(O==="oauth"&&!n?.hasClient&&!await Q())return;const ee=await pp(t.id);if(!E())return;if(!ee){q.error(e("settings.integrations.guests.toast.startFailed",{name:z}));return}p(!0),u(!0),Ks(ee);const G=Date.now()+gp;P.current=window.setInterval(()=>{(async()=>{if(!E()){F();return}if(Date.now()>G){F(),q.error(e("settings.integrations.guests.toast.authorizationFailed",{name:z}));return}const le=await r(t.id);E()&&le&&fp(ae,le.connection)&&(F(),q.success(e("settings.integrations.guests.toast.connected",{name:z})),is()&&eu())})()},hp)}catch(ee){if(!E())return;console.error("Failed to start guest connect:",ee),q.error(e("settings.integrations.guests.toast.startFailed",{name:z})),F()}finally{E()&&l(!1)}},W=async()=>{if(E()){l(!0);try{F();const ae=await mp(t.id);if(!E())return;if(!ae){q.error(e("settings.integrations.guests.toast.disconnectFailed",{name:z}));return}i(t.id,ae),q.success(e("settings.integrations.guests.toast.disconnected",{name:z}))}catch(ae){if(!E())return;console.error("Failed to disconnect guest:",ae),q.error(e("settings.integrations.guests.toast.disconnectFailed",{name:z}))}finally{E()&&l(!1)}}},Y=async()=>{const ae=n?.redirectUri??"";!ae||!(await Ai(ae)).ok||(k(!0),window.setTimeout(()=>k(!1),1500))};return s.jsx(di,{logo:s.jsx(rl,{icon:ll(t.icon),iconSrc:o,className:"size-5 text-foreground"}),name:z,description:a.description,status:T,statusTone:R,open:$,onOpenChange:ae=>{if(f){u(!0);return}u(ae)},children:s.jsxs("div",{className:"space-y-3",children:[O==="oauth"?s.jsxs(s.Fragment,{children:[s.jsx(St,{label:e("settings.integrations.guests.field.clientId"),controlClassName:"w-full max-w-none",children:s.jsx(qe,{value:g,onChange:ae=>h(ae.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:d})}),s.jsx(St,{label:e("settings.integrations.guests.field.clientSecret"),controlClassName:"w-full max-w-none",children:s.jsx(qe,{type:"password",value:y,onChange:ae=>b(ae.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:d})})]}):null,K?s.jsx(St,{label:a.token?.usernameLabel??e("settings.integrations.guests.field.username"),controlClassName:"w-full max-w-none",children:s.jsx(qe,{value:S,onChange:ae=>v(ae.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:d})}):null,O==="token"?s.jsx(St,{label:e("settings.integrations.guests.field.token"),info:e("settings.integrations.guests.field.token.info"),controlClassName:"w-full max-w-none",children:s.jsx(qe,{type:"password",value:x,onChange:ae=>w(ae.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:d})}):null,(a.settings??[]).map(ae=>s.jsx(St,{label:ae.label,controlClassName:"w-full max-w-none",children:s.jsx(qe,{value:A[ae.id]??"",onChange:ee=>{I(G=>({...G,[ae.id]:ee.target.value}))},onBlur:()=>{V()},autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:d})},ae.id)),O==="oauth"?s.jsxs(St,{label:e("settings.integrations.guests.field.redirectUri"),info:e("settings.integrations.guests.field.redirectUri.info"),controlClassName:"w-full max-w-none",children:[s.jsx(qe,{value:n?.redirectUri??"",readOnly:!0,className:"h-8 min-w-0 flex-1 rounded-md px-3"}),s.jsx(H,{type:"button",size:"sm",variant:"outline",disabled:!n?.redirectUri,onClick:()=>{Y()},children:e(N?"settings.integrations.guests.actions.copied":"settings.integrations.guests.actions.copyRedirect")})]}):null,s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:D?s.jsx(H,{type:"button",size:"sm",variant:"destructive",disabled:d,onClick:()=>{W()},children:e("settings.integrations.guests.actions.disconnect")}):s.jsxs(H,{type:"button",size:"sm",disabled:d||f,onClick:()=>{B()},children:[d?s.jsx(te,{name:"loader-4",className:"size-3.5 animate-spin"}):null,e("settings.integrations.guests.actions.connect")]})})]})})},N2=t=>{const e=De.c(27),{divider:a}=t,n=a===void 0?!0:a,{t:i}=Ee(),o=Ps(C2),r=Ps(I2);let c;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0],m.useEffect(P2,c),os()||tu())return null;let u,d,l,f,p,g,h,y;if(e[1]!==n||e[2]!==o||e[3]!==r||e[4]!==i){y=Symbol.for("react.early_return_sentinel");e:{const x=o.filter(A2);if(x.length===0){y=null;break e}u=$e,e[13]!==i?(d=i("settings.integrations.guests.title"),e[13]=i,e[14]=d):d=e[14],e[15]!==i?(l=i("settings.integrations.guests.info"),e[15]=i,e[16]=l):l=e[16],f=n,p="integrations.guests",g="space-y-3";let w;e[17]!==r?(w=S=>s.jsx($u,{guest:S},`${r}:${S.id}`),e[17]=r,e[18]=w):w=e[18],h=x.map(w)}e[1]=n,e[2]=o,e[3]=r,e[4]=i,e[5]=u,e[6]=d,e[7]=l,e[8]=f,e[9]=p,e[10]=g,e[11]=h,e[12]=y}else u=e[5],d=e[6],l=e[7],f=e[8],p=e[9],g=e[10],h=e[11],y=e[12];if(y!==Symbol.for("react.early_return_sentinel"))return y;let b;return e[19]!==u||e[20]!==d||e[21]!==l||e[22]!==f||e[23]!==p||e[24]!==g||e[25]!==h?(b=s.jsx(u,{title:d,info:l,divider:f,settingsItem:p,contentClassName:g,children:h}),e[19]=u,e[20]=d,e[21]=l,e[22]=f,e[23]=p,e[24]=g,e[25]=h,e[26]=b):b=e[26],b};function C2(t){return t.guests}function I2(t){return t.runtimeKey}function P2(){nn()}function A2(t){return t.source!=="bundled"&&t.integration&&cl(t)}const T2=t=>{const e=new Map;for(const a of t){const n=JSON.stringify([a.user.provider,a.user.instance,a.user.id]),i=e.get(n);i?i.accounts.push(a):e.set(n,{key:n,accounts:[a]})}return Array.from(e.values())},E2=t=>/[0-9a-f]{8}(?=-[0-9a-f]{4}-)/i.exec(t)?.[0]??null,zu=t=>{const e=De.c(15),{accounts:a,avatarAlt:n,sourceLabel:i,statusLabel:o,currentLabel:r,renderActions:c}=t;let u;if(e[0]!==a||e[1]!==n||e[2]!==r||e[3]!==c||e[4]!==i||e[5]!==o){let l;e[7]!==n||e[8]!==r||e[9]!==c||e[10]!==i||e[11]!==o?(l=f=>{const p=f.accounts[0].user;return s.jsxs("div",{className:"py-3 first:pt-0 last:pb-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[p.avatarUrl?s.jsx("img",{src:p.avatarUrl,alt:n(p.username),className:"size-9 shrink-0 oc-tile-inset rounded-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center oc-tile-inset rounded-full",children:s.jsx(te,{name:p.provider==="github"?"github-fill":p.provider==="gitlab"?"gitlab":"git-branch",className:"size-4 text-muted-foreground"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate typography-ui-label text-foreground",children:p.name?.trim()||p.username}),s.jsx("div",{className:"truncate font-mono typography-micro text-muted-foreground",children:p.username})]})]}),s.jsx("div",{className:"ms-12 mt-2 divide-y divide-[var(--surface-subtle)]",children:f.accounts.map(g=>{const h=i(g),y=o(g),b=f.accounts.some(x=>x!==g&&i(x)===h)?E2(g.id):null;return s.jsxs("div",{className:"flex flex-col gap-2 py-2 first:pt-0 last:pb-0 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx("span",{children:h}),y?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",children:"·"}),s.jsx("span",{className:"text-[var(--status-warning)]",children:y})]}):null,b?s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",children:"·"}),s.jsx("span",{className:"font-mono",children:b})]}):null,f.accounts.length>1&&g.current?s.jsx("span",{className:"oc-tile-inset rounded-full px-1.5",children:r}):null]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:c(g)})]},g.id)})})]},f.key)},e[7]=n,e[8]=r,e[9]=c,e[10]=i,e[11]=o,e[12]=l):l=e[12],u=T2(a).map(l),e[0]=a,e[1]=n,e[2]=r,e[3]=c,e[4]=i,e[5]=o,e[6]=u}else u=e[6];let d;return e[13]!==u?(d=s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:u}),e[13]=u,e[14]=d):d=e[14],d},Uu=t=>{const e=De.c(38),{code:a,description:n,openLabel:i,onOpen:o,onCancel:r,disabled:c}=t,u=c===void 0?!1:c,{t:d}=Ee();let l;e[0]!==d?(l=d("settings.github.page.flow.title"),e[0]=d,e[1]=l):l=e[1];let f;e[2]!==l?(f=s.jsx($a,{children:l}),e[2]=l,e[3]=f):f=e[3];let p;e[4]!==n?(p=s.jsx("p",{className:"typography-meta text-muted-foreground",children:n}),e[4]=n,e[5]=p):p=e[5];let g;e[6]!==f||e[7]!==p?(g=s.jsxs("div",{className:"space-y-1",children:[f,p]}),e[6]=f,e[7]=p,e[8]=g):g=e[8];let h;e[9]!==a?(h=s.jsx("code",{className:"rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-3 py-1.5 font-mono text-xl tracking-widest text-foreground",children:a}),e[9]=a,e[10]=h):h=e[10];let y;e[11]!==o||e[12]!==i?(y=s.jsx(H,{size:"sm",onClick:o,children:i}),e[11]=o,e[12]=i,e[13]=y):y=e[13];let b;e[14]!==h||e[15]!==y?(b=s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[h,y]}),e[14]=h,e[15]=y,e[16]=b):b=e[16];let x;e[17]!==d?(x=d("settings.github.page.flow.waiting"),e[17]=d,e[18]=x):x=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(Hd,{}),e[19]=w):w=e[19];let S;e[20]!==d?(S=d("settings.github.page.flow.autoRefresh"),e[20]=d,e[21]=S):S=e[21];let v;e[22]!==S||e[23]!==x?(v=s.jsxs("span",{className:"typography-micro text-muted-foreground",children:[x,w," ",S]}),e[22]=S,e[23]=x,e[24]=v):v=e[24];let A;e[25]!==d?(A=d("settings.common.actions.cancel"),e[25]=d,e[26]=A):A=e[26];let I;e[27]!==u||e[28]!==r||e[29]!==A?(I=s.jsx(H,{size:"sm",variant:"ghost",disabled:u,onClick:r,children:A}),e[27]=u,e[28]=r,e[29]=A,e[30]=I):I=e[30];let N;e[31]!==v||e[32]!==I?(N=s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[v,I]}),e[31]=v,e[32]=I,e[33]=N):N=e[33];let k;return e[34]!==N||e[35]!==g||e[36]!==b?(k=s.jsxs("div",{className:"oc-tile-inset space-y-3 rounded-md p-3",children:[g,b,N]}),e[34]=N,e[35]=g,e[36]=b,e[37]=k):k=e[37],k},M2=()=>{const{t}=Ee(),e=_a()?.sourceControl,a=Ho(Ws),n=Fs(M=>M.entries[a]),i=n?.status??null,o=n?.isLoading??!1,r=n?.hasChecked??!1,c=Fs(M=>M.refreshStatus),u=Fs(M=>M.refreshInstances),d=Fs(M=>M.setStatus),l=m.useCallback(async M=>{await Ks(M)},[]),[f,p]=m.useState(!1),[g,h]=m.useState(null),[y,b]=m.useState(null),[x,w]=m.useState(0),S=m.useRef(null),v=m.useRef(""),A=m.useRef(0),I=m.useCallback(()=>{const M=Zt(),T=A.current;return()=>T===A.current&&M===Zt()},[]),N=m.useCallback(()=>{S.current!=null&&(window.clearTimeout(S.current),S.current=null),b(null)},[]),k=m.useCallback(()=>{v.current="",h(null),N()},[N]);m.useEffect(()=>{const M=ml(()=>{A.current+=1,p(!1),k()});return()=>{A.current+=1,M()}},[k]),m.useEffect(()=>((async()=>{try{!r&&e&&await c(e,Ws)}catch(M){console.warn("Failed to load GitHub auth status:",M)}})(),()=>{N()}),[r,c,e,N]);const P=m.useCallback(async()=>{const M=I();p(!0);try{if(!e)return;const T=await e.authStart(Ws);if(!M())return;v.current=Zt(),h(T),w(0),b(Math.max(1,T.interval)*1e3);const R=T.verificationUriComplete||T.verificationUri;l(R)}catch(T){M()&&(console.error("Failed to start GitHub connect:",T),q.error(t("settings.github.page.toast.startConnectFailed")))}finally{M()&&p(!1)}},[I,l,e,t]);m.useEffect(()=>{if(!g?.flowId||!y||S.current!=null)return;const M=async()=>{const T=I();if(v.current!==Zt()){k();return}try{if(!e)throw new Error("Source control runtime API unavailable");const R=await e.authComplete(Ws,g.flowId);if(!T()||v.current!==Zt())return;if(R.status==="connected"){if(k(),await c(e,Ws,{force:!0}),!T()||(await u(e,{force:!0}),!T()))return;q.success(t("settings.github.page.toast.connected"));return}R.status==="pending"&&R.slowDown&&b($=>$?$+5e3:5e3),R.status==="pending"&&w($=>$+1),R.status==="error"&&(q.error(R.message||t("settings.github.page.toast.authorizationFailed")),k())}catch(R){T()&&v.current===Zt()&&(console.warn("GitHub polling failed:",R),w($=>$+1))}};return S.current=window.setTimeout(()=>{M()},y),()=>{S.current!=null&&(window.clearTimeout(S.current),S.current=null)}},[I,g,x,y,u,c,e,k,t]);const j=m.useCallback(async M=>{const T=I();p(!0);try{if(!e||(await e.authSetCliDisabled(Ws,M),!T())||(await c(e,Ws,{force:!0}),!T()))return;q.success(t(M?"settings.github.page.toast.ghCliDisabled":"settings.github.page.toast.ghCliEnabled"))}catch(R){T()&&(console.error("Failed to update gh CLI setting:",R),q.error(t("settings.github.page.toast.ghCliUpdateFailed")))}finally{T()&&p(!1)}},[I,c,e,t]),C=m.useCallback(async M=>{const T=I();p(!0);try{if(!e)return;const R=await e.authActivate(Ws,M);T()&&d(Ws,R)}catch(R){T()&&(console.error("Failed to switch GitHub account:",R),q.error(t("settings.github.page.toast.switchFailed")))}finally{T()&&p(!1)}},[I,d,e,t]),E=m.useCallback(async M=>{const T=I();p(!0);try{if(k(),!e||(await e.authDisconnect(Ws,M),!T())||(await c(e,Ws,{force:!0}),!T())||(await u(e,{force:!0}),!T()))return;q.success(t("settings.github.page.toast.disconnected"))}catch(R){T()&&(console.error("Failed to remove GitHub account:",R),q.error(t("settings.github.page.toast.disconnectFailed")))}finally{T()&&p(!1)}},[I,u,c,e,k,t]);if(o&&!r)return s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.sourceControl.status.checking")});const F=i?.accounts??[],O=i?.cli??null,K=i?.status==="unreachable"||i?.status==="temporarily-unavailable"?i.message||t("sessionAuth.error.networkRetry"):null,D=!!(O?.available&&!O.active&&(!O.user||O.disabled));return s.jsxs("div",{className:"space-y-3","data-settings-item":"git.github-account",children:[K&&s.jsx(st,{label:t("sessionAuth.error.networkTitle"),description:K,children:s.jsx(H,{size:"sm",variant:"outline",disabled:f||o||!e,onClick:()=>{e&&c(e,Ws,{force:!0})},children:t("sessionAuth.error.retry")})}),F.length===0?!K&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.github.page.status.notConnected")}):s.jsx(zu,{accounts:F,avatarAlt:M=>t("settings.github.page.avatarAlt.withLogin",{login:M}),currentLabel:t("settings.sourceControl.accounts.inUse"),sourceLabel:M=>M.source==="cli"?t("settings.github.page.accountSource.cli"):t("settings.github.page.accountSource.oauth"),statusLabel:M=>M.status==="valid"?null:t("settings.sourceControl.accounts.needsAuthentication"),renderActions:M=>s.jsxs(s.Fragment,{children:[M.status==="invalid"?s.jsx(H,{size:"sm",variant:"outline",onClick:P,disabled:f,children:t("settings.sourceControl.actions.reauthenticate")}):null,M.source==="cli"&&!M.current?s.jsx(H,{size:"sm",variant:"outline",onClick:()=>{C(M.id)},disabled:f,children:t("settings.sourceControl.actions.use")}):null,s.jsx(H,{size:"sm",variant:"ghost",onClick:()=>M.source==="cli"?j(!0):E(M.id),disabled:f,children:M.source==="cli"?t("settings.github.page.ghCli.actions.disable"):t("settings.sourceControl.actions.remove")})]})}),g?s.jsx(Uu,{code:g.userCode,description:t("settings.github.page.flow.description"),openLabel:t("settings.github.page.actions.openGithub"),onOpen:()=>{l(g.verificationUriComplete||g.verificationUri)},onCancel:k,disabled:f}):s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.jsx(H,{"data-settings-item":"git.github-connect",size:"sm",variant:F.length>0?"outline":"default",onClick:P,disabled:f,children:F.length>0?t("settings.github.page.actions.addAccount"):t("settings.github.page.actions.connect")})}),D&&O?s.jsx(st,{label:t("settings.github.page.ghCli.title"),description:O.disabled?t("settings.github.page.ghCli.disabledDescription"):t("settings.github.page.ghCli.availableDescription"),className:"border-t border-[var(--surface-subtle)] pt-3",children:s.jsx(H,{size:"sm",variant:"outline",onClick:()=>j(!O.disabled),disabled:f,children:O.disabled?t("settings.github.page.ghCli.actions.enable"):t("settings.github.page.ghCli.actions.disable")})}):null]})},D2=()=>{const t=De.c(18),{t:e}=Ee(),a=qd(Ws),n=a?.status??null,i=a?.isLoading??!1,o=a?.hasChecked??!1,[r,c]=m.useState(!1),u=n?.connected===!0;let d;if(t[0]!==u||t[1]!==o||t[2]!==i||t[3]!==n||t[4]!==e){const x=n?.accounts??[],w=(x.find(R2)??x[0])?.user.username.trim()??(n?.status==="connected"?n.user.username.trim():"");d=i&&!o?e("common.loading"):u?x.length>1?e("settings.sourceControl.accounts.connectedCount",{count:x.length}):w||e("settings.github.page.status.active"):e("settings.integrations.github.status.notConnected"),t[0]=u,t[1]=o,t[2]=i,t[3]=n,t[4]=e,t[5]=d}else d=t[5];const l=d;let f;t[6]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(te,{name:"github-fill",className:"size-5 text-foreground"}),t[6]=f):f=t[6];let p;t[7]!==e?(p=e("settings.integrations.github.title"),t[7]=e,t[8]=p):p=t[8];let g;t[9]!==e?(g=e("settings.integrations.github.description"),t[9]=e,t[10]=g):g=t[10];const h=u?"success":"neutral";let y;t[11]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(M2,{embedded:!0}),t[11]=y):y=t[11];let b;return t[12]!==r||t[13]!==l||t[14]!==p||t[15]!==g||t[16]!==h?(b=s.jsx(di,{settingsItem:"integrations.github",logo:f,name:p,description:g,status:l,statusTone:h,open:r,onOpenChange:c,children:y}),t[12]=r,t[13]=l,t[14]=p,t[15]=g,t[16]=h,t[17]=b):b=t[17],b};function R2(t){return t.current}const O2={provider:"gitlab",instance:"https://gitlab.com"},F2=t=>{try{const e=new URL(t.includes("://")?t:`https://${t}`),a=["localhost","127.0.0.1","::1","[::1]"].includes(e.hostname.toLowerCase()),n=!!(e.username||e.password||e.search||e.hash||e.pathname&&e.pathname!=="/"),i=e.protocol==="https:"||e.protocol==="http:"&&a;return n||!i?null:{provider:"gitlab",instance:e.origin}}catch{return null}},L2=({identity:t,sourceControl:e,onSaved:a})=>{const{t:n}=Ee(),i=Fs(G=>G.refreshInstances),o=Fs(G=>G.refreshStatus),r=Fs(G=>G.setStatus),c=qd(t),[u,d]=m.useState(null),[l,f]=m.useState(!1),[p,g]=m.useState(0),[h,y]=m.useState(null),[b,x]=m.useState(0),[w,S]=m.useState(0),[v,A]=m.useState(""),[I,N]=m.useState(!1),[k,P]=m.useState(!1),[j,C]=m.useState(!1),[E,F]=m.useState(!1),O=m.useRef(""),K=m.useRef(0),D=m.useCallback(()=>{const G=Zt(),le=K.current;return()=>le===K.current&&G===Zt()},[]),M=c?.status??null,T=M?.accounts??[],R=M&&"cli"in M?M.cli:void 0,$=m.useCallback(()=>{O.current="",y(null),x(0)},[]);m.useEffect(()=>{const G=ml(()=>{K.current+=1,$()});return()=>{K.current+=1,G()}},[$]),m.useEffect(()=>$(),[t.instance,t.provider,$]),m.useEffect(()=>{let G=!1;const le=D();return f(!1),Promise.all([e.capabilities(t),o(e,t)]).then(([J])=>{!G&&le()&&d(J)}).catch(()=>{!G&&le()&&f(!0)}),()=>{G=!0}},[p,D,t,o,e]),m.useEffect(()=>{if(!h||b<=0)return;const G=async()=>{const J=D();if(O.current!==Zt()){$();return}try{const me=await e.authComplete(t,h.flowId);if(!J()||O.current!==Zt())return;if(me.status==="connected"){if($(),N(!1),await o(e,t,{force:!0}),!J()||(await i(e,{force:!0}),!J()))return;a?.(),C(!1);return}if(me.status==="pending"){x((me.slowDown?b+5e3:b)||5e3),S(fe=>fe+1);return}$(),C(!0)}catch{J()&&O.current===Zt()&&S(me=>me+1)}},le=window.setTimeout(()=>{G()},b);return()=>window.clearTimeout(le)},[D,h,t,a,w,b,i,o,e,$]);const z=async()=>{const G=D();P(!0),C(!1),F(!1);try{const le=await e.authStart(t);if(!G())return;O.current=Zt(),y(le),S(0),x(Math.max(1,le.interval)*1e3),await Ks(le.verificationUriComplete||le.verificationUri)}catch{G()&&C(!0)}finally{G()&&P(!1)}},Q=async()=>{if(!v.trim())return;const G=D();P(!0),C(!1),F(!1);try{const le=await e.authSetToken(t,v.trim());if(!G()||(r(t,le),A(""),N(!1),await o(e,t,{force:!0}),!G())||(await i(e,{force:!0}),!G()))return;a?.()}catch(le){if(!G())return;le instanceof Error&&"code"in le&&le.code==="INVALID_TOKEN"?F(!0):C(!0)}finally{G()&&P(!1)}},V=async G=>{const le=D();P(!0),C(!1),F(!1);try{if(await e.authDisconnect(t,G),!le()||(await o(e,t,{force:!0}),!le()))return;await i(e,{force:!0})}catch{le()&&C(!0)}finally{le()&&P(!1)}},L=async G=>{const le=D();P(!0),C(!1),F(!1);try{const J=await e.authActivate(t,G);le()&&r(t,J)}catch{le()&&C(!0)}finally{le()&&P(!1)}},B=async()=>{if(!R)return;const G=D();P(!0),C(!1),F(!1);try{if(await e.authSetCliDisabled(t,!R.disabled),!G())return;await o(e,t,{force:!0})}catch{G()&&C(!0)}finally{G()&&P(!1)}},W=()=>{N(!1),y(null),x(0),S(0),A(""),C(!1),F(!1)},Y=T.length>0,ae=!Y||I;let ee;return c?.isLoading?ee=n("settings.sourceControl.status.checking"):E?ee=n("settings.gitlab.status.tokenRejected"):j||l||M?.status==="unreachable"?ee=n("settings.gitlab.status.operationFailed"):T.length>0?ee=null:ee=n("settings.gitlab.status.notConnected"),s.jsxs("div",{className:"space-y-3 py-4 first:pt-0 last:pb-0",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label truncate font-medium text-foreground",title:t.instance,children:t.instance.replace(/^https?:\/\//,"")}),ee?s.jsx("div",{className:"typography-meta mt-0.5 text-muted-foreground",children:ee}):null]}),l||M?.status==="unreachable"?s.jsx(H,{size:"sm",variant:"outline",disabled:k||c?.isLoading,onClick:()=>g(G=>G+1),children:n("sessionAuth.error.retry")}):null]}),T.length>0?s.jsx("div",{children:s.jsx(zu,{accounts:T,avatarAlt:G=>G,currentLabel:n("settings.sourceControl.accounts.inUse"),sourceLabel:G=>n(G.source==="cli"?"settings.gitlab.cli.label":Bd(G.source)),statusLabel:G=>G.status==="valid"?null:n("settings.sourceControl.accounts.needsAuthentication"),renderActions:G=>s.jsxs(s.Fragment,{children:[G.status==="invalid"&&G.source!=="cli"?s.jsx(H,{size:"sm",variant:"outline",onClick:()=>N(!0),disabled:k,children:n("settings.sourceControl.actions.reauthenticate")}):null,G.source==="cli"&&!G.current?s.jsx(H,{size:"sm",variant:"outline",onClick:()=>{L(G.id)},disabled:k,children:n("settings.sourceControl.actions.use")}):null,s.jsx(H,{size:"sm",variant:"ghost",onClick:()=>G.source==="cli"?B():V(G.id),disabled:k,children:G.source==="cli"?n("settings.gitlab.actions.disableCli"):n("settings.sourceControl.actions.remove")})]})})}):null,Y&&!I&&s.jsx("div",{children:s.jsx(H,{size:"sm",variant:"outline",onClick:()=>N(!0),disabled:k,children:n("settings.github.page.actions.addAccount")})}),ae&&s.jsxs("div",{className:Ts,children:[u?.authenticationMethods.device.available&&!h&&s.jsx(st,{label:n("settings.gitlab.device.label"),children:s.jsx(H,{size:"sm",onClick:z,disabled:k,children:n("settings.gitlab.actions.connect")})}),h&&s.jsx(Uu,{code:h.userCode,description:n("settings.gitlab.device.waiting"),openLabel:n("settings.gitlab.actions.openGitLab"),onOpen:()=>{Ks(h.verificationUriComplete||h.verificationUri)},onCancel:W}),u?.authenticationMethods.pat.available&&s.jsx(st,{label:n("settings.gitlab.token.label"),info:n("settings.gitlab.token.info"),children:s.jsxs("div",{className:`${rn} flex flex-col gap-2 @xl:flex-row @xl:items-center`,children:[s.jsx(qe,{className:"h-8 w-full min-w-0 rounded-md",type:"password",value:v,onChange:G=>A(G.target.value),"aria-label":n("settings.gitlab.token.label")}),s.jsx(H,{className:"w-full @xl:w-auto",size:"sm",onClick:Q,disabled:k||!v.trim(),children:n("settings.common.actions.saveChanges")})]})}),I&&!h&&s.jsx("div",{className:"flex justify-end",children:s.jsx(H,{size:"sm",variant:"ghost",onClick:W,disabled:k,children:n("settings.common.actions.cancel")})})]}),(Y||R?.disabled)&&R&&(R.available||R.disabled)&&(R.disabled||!T.some(G=>G.source==="cli"))&&s.jsx("div",{children:s.jsx(st,{label:n("settings.gitlab.cli.label"),info:n("settings.gitlab.cli.info"),children:s.jsx(H,{size:"sm",variant:"outline",onClick:B,disabled:k,children:R.disabled?n("settings.gitlab.actions.enableCli"):n("settings.gitlab.actions.disableCli")})})})]})},K2=()=>{const t=De.c(19),{t:e}=Ee(),a=_a()?.sourceControl,n=Fs(_2),i=Fs($2),o=Fs(z2),[r,c]=m.useState(!1),[u,d]=m.useState(null),[l,f]=m.useState(""),[p,g]=m.useState(!1),[h,y]=m.useState(!1);let b;t[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>d(null),t[0]=b):b=t[0];const x=b,w=n.filter(U2),S=[...w];u&&!w.some(R=>R.instance===u.instance)&&S.push(u),S.length===0&&S.push(O2);let v,A;t[1]!==o?(v=()=>{a&&o(a)},A=[o,a],t[1]=o,t[2]=v,t[3]=A):(v=t[2],A=t[3]),m.useEffect(v,A);let I;t[4]!==l?(I=()=>{const R=F2(l);if(!R){y(!0);return}d(R),f(""),g(!1),y(!1)},t[4]=l,t[5]=I):I=t[5];const N=I;if(!a)return null;let k;t[6]!==i?(k=R=>i[Ho(R)],t[6]=i,t[7]=k):k=t[7];const P=w.map(k),j=P.flatMap(B2).filter(V2),C=j.find(H2)??j[0]??null,E=C!==null,O=P.some(q2)&&!E?e("common.loading"):E?j.length>1?e("settings.sourceControl.accounts.connectedCount",{count:j.length}):C.user.username.trim()||e("settings.gitlab.status.connected"):e("settings.gitlab.status.notConnected");let K;t[8]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(te,{name:"gitlab",className:"size-5 text-foreground"}),t[8]=K):K=t[8];let D;t[9]!==e?(D=e("settings.gitlab.title"),t[9]=e,t[10]=D):D=t[10];let M;t[11]!==e?(M=e("settings.gitlab.info"),t[11]=e,t[12]=M):M=t[12];let T;return t[13]!==N||t[14]!==h||t[15]!==l||t[16]!==p||t[17]!==e?(T=p?s.jsx("div",{children:s.jsx(st,{label:e("settings.gitlab.instance.customLabel"),info:e("settings.gitlab.instance.customInfo"),description:h?e("settings.gitlab.status.operationFailed"):void 0,children:s.jsxs("div",{className:`${rn} flex flex-col gap-2 @xl:flex-row @xl:items-center`,children:[s.jsx(qe,{className:"h-8 w-full min-w-0 rounded-md",value:l,onChange:R=>f(R.target.value),placeholder:"https://gitlab.example.com","aria-label":e("settings.gitlab.instance.customLabel")}),s.jsx(H,{className:"w-full @xl:w-auto",size:"sm",onClick:N,children:e("settings.gitlab.actions.useInstance")}),s.jsx(H,{className:"w-full @xl:w-auto",size:"sm",variant:"ghost",onClick:()=>{f(""),g(!1),y(!1)},children:e("settings.common.actions.cancel")})]})})}):s.jsx(H,{size:"sm",variant:"outline",onClick:()=>g(!0),children:e("settings.gitlab.actions.addInstance")}),t[13]=N,t[14]=h,t[15]=l,t[16]=p,t[17]=e,t[18]=T):T=t[18],s.jsx(di,{settingsItem:"git.gitlab-account",logo:K,name:D,description:M,status:O,statusTone:E?"success":"neutral",open:r,onOpenChange:c,children:s.jsxs("div",{className:"space-y-3","data-settings-item":"git.gitlab-connect",children:[s.jsx("div",{className:"divide-y divide-[var(--interactive-border)]",children:S.map(R=>s.jsx(L2,{identity:R,sourceControl:a,onSaved:u?.instance===R.instance?x:void 0},`${Zt()}:${R.instance}`))}),T]})})};function _2(t){return t.identities}function $2(t){return t.entries}function z2(t){return t.refreshInstances}function U2(t){return t.provider==="gitlab"}function B2(t){return t?.status?.status==="connected"?t.status.accounts:[]}function V2(t){return t.status==="valid"}function H2(t){return t.current}function q2(t){return t?.isLoading&&!t.hasChecked}const bo="__none__",xo="__inherit__";function W2({linear:t,connected:e,organizationId:a}){const{t:n}=Ee(),i=zo(on(b=>b.projects)),[o,r]=m.useState(null),[c,u]=m.useState(!1),[d,l]=m.useState(!1),f=m.useCallback(async()=>{if(!e){r(null),u(!1);return}try{const b=await t.mappingGet();if(b.connected===!1){r(null),u(!1);return}r(b),u(!1)}catch(b){console.error("Failed to load Linear mapping:",b),u(!0)}},[e,t]);m.useEffect(()=>{f()},[f,a]);const p=m.useCallback(async b=>{const x={};for(const w of b.teams??[])w.projectPath&&(x[w.id]=w.projectPath);l(!0),Mt("saving");try{const w=await t.mappingSet({defaultProjectPath:b.defaultProjectPath??null,teamProjectPaths:x});if(w.connected===!1){r(null),Mt("error");return}r(w),u(!1),Mt("saved")}catch(w){console.error("Failed to save Linear mapping:",w),Mt("error")}finally{l(!1)}},[t]);if(!e)return null;if(c&&!o)return s.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.integrations.linear.mapping.loadFailed")});if(!o)return null;const g=b=>i.find(w=>w.path===b)?.label?.trim()||b,h=b=>!b||b===bo?n("settings.integrations.linear.mapping.defaultProject.placeholder"):g(b),y=b=>!b||b===xo?n("settings.integrations.linear.mapping.teams.useDefault"):g(b);return s.jsxs("div",{className:Ts,children:[i.length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.integrations.linear.mapping.emptyProjects")}):null,s.jsx(st,{label:n("settings.integrations.linear.mapping.defaultProject"),info:n("settings.integrations.linear.mapping.defaultProject.info"),settingsItem:"integrations.linear.mapping",children:s.jsxs(Pt,{value:o.defaultProjectPath||bo,disabled:d||i.length===0,onValueChange:b=>{p({...o,defaultProjectPath:b===bo?null:b})},children:[s.jsx(Ct,{className:Es,"aria-label":n("settings.integrations.linear.mapping.defaultProject.aria"),children:s.jsx(Kt,{placeholder:n("settings.integrations.linear.mapping.defaultProject.placeholder"),children:h})}),s.jsxs(It,{children:[s.jsx(bt,{value:bo,children:n("settings.integrations.linear.mapping.defaultProject.placeholder")}),o.defaultProjectPath&&!i.some(b=>b.path===o.defaultProjectPath)?s.jsx(bt,{value:o.defaultProjectPath,children:o.defaultProjectPath}):null,i.map(b=>s.jsx(bt,{value:b.path,children:g(b.path)},b.id))]})]})}),s.jsx(ni,{title:n("settings.integrations.linear.mapping.teams"),info:n("settings.integrations.linear.mapping.teams.info"),children:(o.teams??[]).length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.integrations.linear.mapping.emptyTeams")}):s.jsx("div",{className:Ts,children:(o.teams??[]).map(b=>s.jsx(st,{label:`${b.key} · ${b.name}`,children:s.jsxs(Pt,{value:b.projectPath||xo,disabled:d||i.length===0,onValueChange:x=>{p({...o,teams:(o.teams??[]).map(w=>w.id===b.id?{...w,projectPath:x===xo?null:x}:w)})},children:[s.jsx(Ct,{className:Es,"aria-label":n("settings.integrations.linear.mapping.teams.aria",{team:b.key}),children:s.jsx(Kt,{placeholder:n("settings.integrations.linear.mapping.teams.useDefault"),children:y})}),s.jsxs(It,{children:[s.jsx(bt,{value:xo,children:n("settings.integrations.linear.mapping.teams.useDefault")}),b.projectPath&&!i.some(x=>x.path===b.projectPath)?s.jsx(bt,{value:b.projectPath,children:b.projectPath}):null,i.map(x=>s.jsx(bt,{value:x.path,children:g(x.path)},x.id))]})]})},b.id))})})]})}function G2({linear:t,connected:e}){const{t:a}=Ee(),[n,i]=m.useState(null),[o,r]=m.useState(!1),[c,u]=m.useState(!1);m.useEffect(()=>{if(!e){i(null),r(!1);return}let l=!1;return t.preferencesGet().then(f=>{l||(i(f.sessionComments),r(!1))}).catch(()=>{l||r(!0)}),()=>{l=!0}},[e,t]);const d=m.useCallback(async l=>{const f=n;i(l),u(!0);try{const p=await t.preferencesSet({sessionComments:l});i(p.sessionComments),Mt("saved")}catch{i(f),Mt("error")}finally{u(!1)}},[n,t]);return e?o?s.jsx("p",{className:"text-xs text-muted-foreground",children:a("settings.integrations.linear.sessionComments.loadFailed")}):s.jsx("div",{className:Ts,children:s.jsx(st,{label:a("settings.integrations.linear.sessionComments.label"),info:a("settings.integrations.linear.sessionComments.info"),settingsItem:"integrations.linear.session-comments",children:s.jsx(La,{checked:n===!0,disabled:n===null||c,onCheckedChange:l=>{d(l)},"aria-label":a("settings.integrations.linear.sessionComments.aria")})})}):null}const J2=3*6e4,Q2=1500;function td(t){const e=t?.workspaces??[],a=e.find(n=>n.current);return{connected:!!t?.connected,ids:e.map(n=>n.id).slice().sort().join(","),currentId:a?.id||t?.organization?.id||"",currentAuthorizedAt:a?.authorizedAt??0}}function Y2(t,e){return e.connected?t.connected?e.ids!==t.ids||e.currentId!==t.currentId||e.currentAuthorizedAt!==t.currentAuthorizedAt:!0:!1}const Z2=()=>{const{t}=Ee(),e=_a()?.linear,a=Va(j=>j.status),n=Va(j=>j.isLoading),i=Va(j=>j.hasChecked),o=Va(j=>j.refreshStatus),r=Va(j=>j.setStatus),[c,u]=m.useState(!1),[d,l]=m.useState(!1),[f,p]=m.useState(!1),g=m.useRef(null),h=m.useCallback(()=>{g.current!=null&&(window.clearInterval(g.current),g.current=null),l(!1)},[]);m.useEffect(()=>{if(e)return i||o(e),()=>{h()}},[i,o,e,h]);const y=m.useCallback(async()=>{if(!e)return;h(),u(!0);const j=td(Va.getState().status);try{const C=await e.authStart(is()?"desktop":"web");l(!0),p(!0),Ks(C.authorizationUrl);const E=Date.now()+J2;g.current=window.setInterval(()=>{(async()=>{if(Date.now()>E){h(),q.error(t("settings.integrations.linear.toast.authorizationFailed"));return}const F=await o(e,{force:!0});Y2(j,td(F))&&(h(),q.success(t("settings.integrations.linear.toast.connected")),eu())})()},Q2)}catch(C){console.error("Failed to start Linear connect:",C),q.error(t("settings.integrations.linear.toast.startConnectFailed")),h()}finally{u(!1)}},[o,e,h,t]),b=m.useCallback(async j=>{if(!(!e||!j)){u(!0);try{const C=await e.authActivate(j);r(C),q.success(t("settings.integrations.linear.toast.workspaceSwitched"))}catch(C){console.error("Failed to switch Linear workspace:",C),q.error(t("settings.integrations.linear.toast.workspaceSwitchFailed"))}finally{u(!1)}}},[e,r,t]),x=m.useCallback(async()=>{if(e){u(!0);try{h(),await e.authDisconnect(),q.success(t("settings.integrations.linear.toast.disconnected")),await o(e,{force:!0})}catch(j){console.error("Failed to disconnect Linear:",j),q.error(t("settings.integrations.linear.toast.disconnectFailed"))}finally{u(!1)}}},[o,e,h,t]);if(!e)return null;const w=!!a?.connected,S=a?.user,v=a?.organization,I=(a?.workspaces??[]).filter(j=>!j.current),N=S?.displayName?.trim()||S?.name?.trim()||t("settings.integrations.linear.label.unknownUser"),k=d?t("settings.integrations.linear.status.waiting"):n&&!i?t("common.loading"):w?v?.name?.trim()||t("settings.integrations.linear.status.connected"):t("settings.integrations.linear.status.notConnected"),P=d||f;return s.jsx(di,{settingsItem:"integrations.linear",logo:s.jsx(te,{name:"linear",className:"size-5 text-foreground"}),name:t("settings.integrations.linear.title"),description:t("settings.integrations.linear.description"),status:k,statusTone:d?"warning":w?"success":"neutral",open:P,onOpenChange:j=>{if(d){p(!0);return}p(j)},children:s.jsxs("div",{className:"space-y-3",children:[w?s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[S?.avatarUrl?s.jsx("img",{src:S.avatarUrl,alt:t("settings.integrations.linear.avatarAlt.withName",{name:N}),className:"size-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]",children:s.jsx(te,{name:"linear",className:"size-4 text-muted-foreground"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:N}),s.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[v?.name,S?.email].filter(Boolean).join(" · ")})]})]}):d?s.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.integrations.linear.flow.description")}):null,w?s.jsxs(s.Fragment,{children:[s.jsx(W2,{linear:e,connected:w,organizationId:v?.id??null}),s.jsx(G2,{linear:e,connected:w}),I.length>0?s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("settings.integrations.linear.label.otherWorkspaces")}),s.jsx("div",{className:"space-y-1",children:I.map(j=>{const C=j.user,E=j.name?.trim()||t("settings.integrations.linear.status.connected");return s.jsxs("div",{className:"flex items-center justify-between gap-3 oc-tile-inset rounded-md px-3 py-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:E}),C?.email?s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:C.email}):null]}),s.jsx(H,{type:"button",size:"sm",variant:"ghost",onClick:()=>{b(j.id)},disabled:c,children:t("settings.integrations.linear.actions.switchTo")})]},j.id)})})]}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(H,{type:"button",size:"sm",variant:"outline",onClick:()=>{y()},disabled:c||d,"data-settings-item":"integrations.linear.add-workspace",children:t("settings.integrations.linear.actions.addWorkspace")}),s.jsx(H,{type:"button",size:"sm",variant:"destructive",onClick:()=>{x()},disabled:c,children:t("settings.integrations.linear.actions.disconnect")})]})]}):d?s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("span",{className:"typography-micro text-muted-foreground",children:[t("settings.integrations.linear.flow.waiting"),s.jsx(Hd,{})]}),s.jsx(H,{type:"button",size:"sm",variant:"ghost",disabled:c,onClick:h,children:t("settings.common.actions.cancel")})]}):s.jsxs(H,{type:"button",size:"sm",variant:"default",onClick:()=>{y()},disabled:c||n&&!i,children:[c?s.jsx(te,{name:"loader-4",className:"size-3.5 animate-spin"}):null,t("settings.integrations.linear.actions.connect")]})]})})},jr=[{id:"opencode-claude",packageName:"@openchamber/opencode-claude",providerId:"claude-code",nameKey:"settings.integrations.thirdParty.opencodeClaude.name",descriptionKey:"settings.integrations.thirdParty.opencodeClaude.description",homepage:"https://github.com/openchamber/opencode-claude"}],X2=(t,e)=>t===e||t.startsWith(`${e}@`);function kr(t,e,a){const n=t.filter(u=>X2(u.spec,e)),i=n.filter(u=>u.scope==="user"),o=n.filter(u=>u.scope==="project"),r=i.length===1?i[0]:null,c=a[r?.spec??e]??a[e]??null;return{userEntry:r,userEntryIsAmbiguous:i.length>1,projectEntries:o,registry:c}}function Yr(t,e){return e?.kind!=="npm-ok"||e.name!==t||!e.latestVersion?null:`${t}@${e.latestVersion}`}function sd(t,e){if(t.userEntryIsAmbiguous)return"manage";if(!t.userEntry)return"install";const a=Yr(e,t.registry);return a&&a!==t.userEntry.spec?"update":"setup"}function ej(t,e={}){const a=t.registry?.kind==="npm-ok"?t.registry.latestVersion:null;return t.userEntryIsAmbiguous?{status:"ambiguous",latestVersion:a}:e.restartRequired?{status:"restart-required",latestVersion:a}:e.providerUnavailable?{status:"provider-unavailable",latestVersion:a}:e.registryUnavailable?{status:"registry-unavailable",latestVersion:a}:t.userEntry?t.registry?.kind==="npm-ok"&&t.registry.currentVersion===t.registry.latestVersion?{status:"installed-version",latestVersion:a}:t.registry?.kind==="npm-ok"&&t.registry.currentVersion===null?{status:"unpinned",latestVersion:a}:t.registry?.kind==="npm-ok"&&a?{status:"update-available",latestVersion:a}:{status:"installed",latestVersion:a}:{status:"not-installed",latestVersion:a}}const tj=t=>t.requiresManualRestart===!0||t.reloadFailed===!0,sj=({divider:t=!0})=>{const{t:e}=Ee(),a=Hs(),n=m.useCallback(()=>{re.getState().requestSettingsJump("plugins")},[]),i=m.useCallback(async D=>{if(await ft.getState().loadProviders({directory:a,source:"settings:third-party-provider-setup"}),!$d(ft.getState(),a).some(R=>R.id===D))return!1;const T=re.getState();return T.setSettingsProvidersOpenRequested(D),T.requestSettingsJump("providers"),!0},[a]),{entries:o,registryInfo:r,loadPlugins:c,loadRegistryInfo:u,createEntry:d,updateEntry:l,deleteEntry:f}=Lt(_s(D=>({entries:D.entries,registryInfo:D.registryInfo,loadPlugins:D.loadPlugins,loadRegistryInfo:D.loadRegistryInfo,createEntry:D.createEntry,updateEntry:D.updateEntry,deleteEntry:D.deleteEntry}))),[p,g]=m.useState(!1),[h,y]=m.useState(null),[b,x]=m.useState(()=>new Set),[w,S]=m.useState(()=>new Set),[v,A]=m.useState(null),[I,N]=m.useState(()=>new Set),k=m.useCallback(async()=>{if(!await c({force:!0})){g(!0);return}const M=Lt.getState().entries,T=new Set(jr.map($=>$.packageName));for(const $ of M)jr.some(z=>$.spec===z.packageName||$.spec.startsWith(`${z.packageName}@`))&&T.add($.spec);const R=await u({specs:[...T],force:!0});g(!R)},[c,u]);m.useEffect(()=>{k()},[k]);const P=m.useCallback((D,M)=>{x(T=>{const R=new Set(T);return M?R.add(D):R.delete(D),R})},[]),j=m.useCallback((D,M)=>{S(T=>{const R=new Set(T);return M?R.add(D):R.delete(D),R})},[]),C=m.useCallback(async(D,M,T)=>{y({pluginId:D.id,action:M});try{const R=await T();if(!R.ok){q.error(e("settings.integrations.thirdParty.toast.actionFailed"));return}j(D.id,!1);const $=tj(R);P(D.id,$);const z=$?{description:e("settings.integrations.thirdParty.toast.restartRequired")}:void 0;M==="install"?q.success(e("settings.integrations.thirdParty.toast.installed",{name:e(D.nameKey)}),z):M==="update"?q.success(e("settings.integrations.thirdParty.toast.updated",{name:e(D.nameKey)}),z):q.success(e("settings.integrations.thirdParty.toast.removed",{name:e(D.nameKey)}),z),await k()}finally{y(null)}},[k,j,P,e]),E=m.useCallback(async D=>{const M=kr(o,D.packageName,r),T=sd(M,D.packageName);if(T==="manage"){n();return}if(T==="setup"){y({pluginId:D.id,action:T});try{const $=await i(D.providerId);j(D.id,!$),$?P(D.id,!1):q.error(e("settings.integrations.thirdParty.toast.providerUnavailable"))}finally{y(null)}return}const R=Yr(D.packageName,M.registry);if(!R){g(!0);return}if(T==="install"){await C(D,"install",()=>d({spec:R,scope:"user"}));return}M.userEntry&&await C(D,"update",()=>l(M.userEntry.id,{spec:R}))},[d,o,n,i,r,C,j,P,e,l]),F=m.useCallback(async()=>{const D=v;if(!D)return;const M=kr(o,D.packageName,r);if(!M.userEntry||M.userEntryIsAmbiguous){A(null),n();return}A(null),await C(D,"remove",()=>f(M.userEntry.id))},[f,o,n,r,v,C]),O=m.useCallback((D,M)=>{N(T=>{const R=new Set(T);return M?R.add(D):R.delete(D),R})},[]),K=D=>{const M=kr(o,D.packageName,r),T=sd(M,D.packageName),R=Yr(D.packageName,M.registry),$=h?.pluginId===D.id,z=b.has(D.id),Q=w.has(D.id),V=p||M.registry?.kind==="npm-network",L=$||z&&T!=="setup"||(T==="install"||T==="update")&&(V||!R),B=ej(M,{registryUnavailable:V,restartRequired:z,providerUnavailable:Q});let W;switch(B.status){case"installed-version":W=B.latestVersion?e("settings.integrations.thirdParty.status.installedVersion",{version:B.latestVersion}):e("settings.integrations.thirdParty.status.installed");break;case"update-available":W=B.latestVersion?e("settings.integrations.thirdParty.status.updateAvailable",{version:B.latestVersion}):e("settings.integrations.thirdParty.status.unpinned");break;case"not-installed":W=e("settings.integrations.thirdParty.status.notInstalled");break;case"installed":W=e("settings.integrations.thirdParty.status.installed");break;case"unpinned":W=e("settings.integrations.thirdParty.status.unpinned");break;case"ambiguous":W=e("settings.integrations.thirdParty.status.ambiguous");break;case"restart-required":W=e("settings.integrations.thirdParty.status.restartRequired");break;case"registry-unavailable":W=e("settings.integrations.thirdParty.status.registryUnavailable");break;case"provider-unavailable":W=e("settings.integrations.thirdParty.status.providerUnavailable");break}const Y=B.status==="installed-version"?"success":B.status==="update-available"||B.status==="ambiguous"||B.status==="restart-required"||B.status==="registry-unavailable"||B.status==="provider-unavailable"?"warning":"neutral",ae={install:e("settings.integrations.thirdParty.actions.install"),update:e("settings.integrations.thirdParty.actions.update"),setup:e("settings.integrations.thirdParty.actions.setup"),manage:e("settings.integrations.thirdParty.actions.managePlugins")}[T],ee=I.has(D.id);return s.jsx(di,{settingsItem:`integrations.third-party.${D.id}`,logo:s.jsx(ln,{providerId:D.providerId,alt:"",className:"size-5"}),name:e(D.nameKey),description:e(D.descriptionKey),status:W,statusTone:Y,open:ee,onOpenChange:G=>O(D.id,G),children:s.jsxs("div",{className:"space-y-3",children:[M.projectEntries.length>0?s.jsx("p",{className:"text-xs text-muted-foreground",children:e("settings.integrations.thirdParty.status.projectInstalled")}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(H,{type:"button",size:"sm",variant:T==="manage"?"outline":"default",onClick:()=>{E(D)},disabled:L,children:[$?s.jsx(te,{name:"loader-4",className:"size-3.5 animate-spin"}):T==="setup"?s.jsx(te,{name:"plug-2",className:"size-3.5"}):null,ae]}),s.jsxs(H,{type:"button",size:"sm",variant:"secondary",onClick:()=>{Ks(D.homepage)},children:[s.jsx(te,{name:"external-link",className:"size-3.5"}),e("settings.integrations.thirdParty.actions.docs")]}),M.userEntry&&!M.userEntryIsAmbiguous?s.jsxs(H,{type:"button",size:"sm",variant:"destructive",onClick:()=>A(D),disabled:$,children:[s.jsx(te,{name:"delete-bin",className:"size-3.5"}),e("settings.integrations.thirdParty.actions.remove")]}):null]})]})},D.id)};return s.jsxs(s.Fragment,{children:[s.jsx($e,{title:e("settings.integrations.thirdParty.title"),info:e("settings.integrations.thirdParty.info"),divider:t,settingsItem:"integrations.third-party",contentClassName:"space-y-3",children:jr.map(K)}),s.jsx(Tt,{open:v!==null,onOpenChange:D=>!D&&A(null),children:s.jsxs(Et,{className:"max-w-md",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:e("settings.integrations.thirdParty.dialog.remove.title")}),s.jsx(Ft,{children:e("settings.integrations.thirdParty.dialog.remove.description",{name:v?e(v.nameKey):""})})]}),s.jsxs(Wt,{children:[s.jsx(H,{type:"button",size:"sm",variant:"ghost",onClick:()=>A(null),children:e("settings.common.actions.cancel")}),s.jsx(H,{type:"button",size:"sm",variant:"destructive",onClick:()=>{F()},children:e("settings.integrations.thirdParty.actions.remove")})]})]})})]})},Zr=t=>t==="invalid-path"?"settings.extensions.toast.invalidPath":t==="invalid-url"?"settings.extensions.toast.invalidUrl":t==="not-found"?"settings.extensions.toast.notFound":t==="invalid-manifest"?"settings.extensions.toast.invalidManifest":t==="reserved-id"?"settings.extensions.toast.reservedId":t==="id-taken"?"settings.extensions.toast.idTaken":t==="already-installed"?"settings.extensions.toast.alreadyInstalled":t==="missing-build"?"settings.extensions.toast.missingBuild":t==="host-too-old"?"settings.extensions.toast.hostTooOld":t==="clone-failed"?"settings.extensions.toast.cloneFailed":t==="clone-auth-failed"?"settings.extensions.toast.cloneNeedsSignIn":t==="extract-failed"?"settings.extensions.toast.extractFailed":t==="too-large"?"settings.extensions.toast.zipTooLarge":t==="enterprise-mode"?"settings.extensions.toast.enterpriseMode":t==="unreadable"?"settings.extensions.toast.installedUnreadable":"settings.extensions.toast.failed",Bu=t=>t==="not-git"?"settings.extensions.toast.notGit":t==="enterprise-mode"?"settings.extensions.toast.enterpriseUpdate":t==="clone-failed"?"settings.extensions.toast.cloneFailed":t==="clone-auth-failed"?"settings.extensions.toast.cloneNeedsSignIn":t==="invalid-manifest"?"settings.extensions.toast.invalidManifest":t==="missing-build"?"settings.extensions.toast.missingBuild":t==="swap-failed"?"settings.extensions.toast.swapFailed":t==="not-found"?"settings.extensions.toast.notFound":"settings.extensions.toast.updateFailed",nj=as({updates:Bn(wt().min(1),vp)}),aj=as({error:cu(["not-git","clone-failed","clone-auth-failed","invalid-manifest","missing-build","host-too-old","swap-failed","not-found","enterprise-mode"]),required:wt().trim().min(1).max(64).optional()}),nd=async t=>{try{const e=await $t("/api/guests/updates/check",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({force:t})});if(!e.ok)return{ok:!1};const a=nj.safeParse(JSON.parse(await e.text()));return a.success?{ok:!0,updates:a.data.updates}:{ok:!1}}catch{return{ok:!1}}},ij=async t=>{try{const e=aj.safeParse(JSON.parse(await t.text()));return e.success?e.data.required?{code:e.data.error,required:e.data.required}:{code:e.data.error}:{code:"failed"}}catch{return{code:"failed"}}},Vu=async t=>{try{const e=await $t(`/api/guests/${t}/update`,{method:"POST",headers:{Accept:"application/json"}});if(!e.ok){const n=await ij(e);return n.required?{ok:!1,code:n.code,required:n.required}:{ok:!1,code:n.code}}const a=yp(await e.text());return a?{ok:!0,guest:a}:{ok:!1,code:"failed"}}catch{return{ok:!1,code:"failed"}}},oj={guestId:"excalidraw",gitUrl:"https://github.com/openchamber/openchamber-excalidraw",homepage:"https://github.com/openchamber/openchamber-excalidraw",nameKey:"settings.integrations.extensionCatalog.excalidraw.name",descriptionKey:"settings.integrations.extensionCatalog.excalidraw.description",logo:{kind:"file-type",fileName:"drawing.excalidraw"}},rj={guestId:"resource-monitor",gitUrl:"https://github.com/openchamber/openchamber-resource-monitor",homepage:"https://github.com/openchamber/openchamber-resource-monitor",nameKey:"settings.integrations.extensionCatalog.resourceMonitor.name",descriptionKey:"settings.integrations.extensionCatalog.resourceMonitor.description",logo:{kind:"icon",name:"pulse"}},lj=[oj,rj],cj=(t,e)=>{const a=t.find(n=>n.id===e.guestId);return a?a.enterpriseBlocked?.length?{kind:"blocked",guest:a}:ai(a)?{kind:"needs-approval",guest:a}:a.enabled===!1?{kind:"paused",guest:a}:a.update?{kind:"update-available",guest:a,version:a.update.version}:{kind:"installed",guest:a}:{kind:"not-installed"}},dj=({divider:t=!0})=>{const{t:e}=Ee(),a=Ps(w=>w.guests),n=Ps(w=>w.status),[i,o]=m.useState(null),[r,c]=m.useState(()=>new Set),[u,d]=m.useState(null);m.useEffect(()=>{nn()},[]);const l=m.useCallback(()=>{re.getState().requestSettingsJump("extensions")},[]),f=m.useCallback(async(w,S,v)=>{const A=Zt();o({guestId:w.guestId,action:S});try{await v(),Zt()===A&&await nn()}finally{o(null)}},[]),p=w=>f(w,"install",async()=>{const S=await mu(w.gitUrl);if(!S.ok){q.error(S.code==="host-too-old"&&S.required?e("settings.extensions.toast.hostTooOld",{version:S.required}):e(Zr(S.code)));return}q.success(e("settings.integrations.thirdParty.toast.installed",{name:e(w.nameKey)})),ai(S.guest)&&l()}),g=w=>f(w,"update",async()=>{const S=await Vu(w.guestId);if(!S.ok){q.error(S.code==="host-too-old"&&S.required?e("settings.extensions.toast.hostTooOld",{version:S.required}):e(Bu(S.code)));return}Ei(w.guestId),q.success(e("settings.integrations.thirdParty.toast.updated",{name:e(w.nameKey)})),ai(S.guest)&&l()}),h=w=>f(w,"enable",async()=>{if(!await pu(w.guestId,!0)){q.error(e("settings.integrations.extensionCatalog.toast.enableFailed",{name:e(w.nameKey)}));return}q.success(e("settings.integrations.extensionCatalog.toast.enabled",{name:e(w.nameKey)}))}),y=async()=>{const w=u;w&&(d(null),await f(w,"remove",async()=>{if(!(await uu(w.guestId)).ok){q.error(e("settings.integrations.thirdParty.toast.actionFailed"));return}Ei(w.guestId),q.success(e("settings.integrations.thirdParty.toast.removed",{name:e(w.nameKey)}))}))},b=w=>{switch(w.kind){case"not-installed":return{status:e("settings.integrations.thirdParty.status.notInstalled"),tone:"neutral"};case"blocked":return{status:e("settings.extensions.status.enterpriseBlocked"),tone:"warning"};case"needs-approval":return{status:e("settings.integrations.extensionCatalog.status.needsApproval"),tone:"warning"};case"paused":return{status:e("settings.integrations.extensionCatalog.status.paused"),tone:"neutral"};case"update-available":return{status:e("settings.integrations.thirdParty.status.updateAvailable",{version:w.version}),tone:"warning"};case"installed":return{status:w.guest.version?e("settings.integrations.thirdParty.status.installedVersion",{version:w.guest.version}):e("settings.integrations.thirdParty.status.installed"),tone:"success"}}},x=w=>{const S=cj(a,w),v=n==="idle"||n==="loading",{status:A,tone:I}=v?{status:e("common.loading"),tone:"neutral"}:b(S),N=i?.guestId===w.guestId||v,k=r.has(w.guestId),P=s.jsx(te,{name:"loader-4",className:"size-3.5 animate-spin"}),j=S.kind==="not-installed"?{label:e("settings.integrations.thirdParty.actions.install"),onClick:()=>{p(w)},variant:"default"}:S.kind==="update-available"?{label:e("settings.integrations.thirdParty.actions.update"),onClick:()=>{g(w)},variant:"default"}:S.kind==="paused"?{label:e("settings.integrations.extensionCatalog.actions.enable"),onClick:()=>{h(w)},variant:"default"}:S.kind==="needs-approval"||S.kind==="blocked"?{label:e("settings.integrations.extensionCatalog.actions.manage"),onClick:l,variant:"outline"}:null;return s.jsx(di,{settingsItem:`integrations.extensions.${w.guestId}`,logo:w.logo.kind==="file-type"?s.jsx(jp,{filePath:w.logo.fileName,className:"size-5"}):s.jsx(te,{name:w.logo.name,className:"size-5 text-foreground"}),name:e(w.nameKey),description:e(w.descriptionKey),status:A,statusTone:I,open:k,onOpenChange:C=>c(E=>{const F=new Set(E);return C?F.add(w.guestId):F.delete(w.guestId),F}),children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[j?s.jsxs(H,{type:"button",size:"sm",variant:j.variant,onClick:j.onClick,disabled:N,children:[N?P:null,j.label]}):null,s.jsxs(H,{type:"button",size:"sm",variant:"secondary",onClick:()=>{Ks(w.homepage)},children:[s.jsx(te,{name:"external-link",className:"size-3.5"}),e("settings.integrations.thirdParty.actions.docs")]}),S.kind!=="not-installed"?s.jsxs(H,{type:"button",size:"sm",variant:"destructive",onClick:()=>d(w),disabled:N,children:[s.jsx(te,{name:"delete-bin",className:"size-3.5"}),e("settings.integrations.thirdParty.actions.remove")]}):null]})},w.guestId)};return n==="unsupported"?null:s.jsxs(s.Fragment,{children:[s.jsx($e,{title:e("settings.integrations.extensionCatalog.title"),info:e("settings.integrations.extensionCatalog.info"),divider:t,settingsItem:"integrations.extensions",contentClassName:"space-y-3",children:lj.map(x)}),s.jsx(Tt,{open:u!==null,onOpenChange:w=>!w&&d(null),children:s.jsxs(Et,{className:"max-w-md",children:[s.jsxs(Rt,{children:[s.jsx(Ot,{children:e("settings.integrations.extensionCatalog.dialog.remove.title")}),s.jsx(Ft,{children:e("settings.integrations.extensionCatalog.dialog.remove.description",{name:u?e(u.nameKey):""})})]}),s.jsxs(Wt,{children:[s.jsx(H,{type:"button",size:"sm",variant:"ghost",onClick:()=>d(null),children:e("settings.common.actions.cancel")}),s.jsx(H,{type:"button",size:"sm",variant:"destructive",onClick:()=>{y()},children:e("settings.integrations.thirdParty.actions.remove")})]})]})})]})},uj=()=>{const t=De.c(19),{t:e}=Ee();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=os(),t[0]=a):a=t[0];const n=!a;let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=os(),t[1]=i):i=t[1];const o=!i,r=!!_a()?.linear,c=Ps(mj),u=Ps(pj),d=!os()&&!tu()?c.filter(gj):[],l=n||o||r||d.length>0,f=!Pn(),p=qt;let g;t[2]!==e?(g=e("settings.page.integrations.title"),t[2]=e,t[3]=g):g=t[3];let h;t[4]!==e?(h=e("settings.page.integrations.description"),t[4]=e,t[5]=h):h=t[5];const y=!0,b=l?s.jsxs($e,{title:e("settings.integrations.firstParty.title"),info:e("settings.integrations.firstParty.info"),divider:!1,settingsItem:"integrations.first-party",contentClassName:"space-y-3",children:[n?s.jsx(D2,{}):null,o?s.jsx(K2,{}):null,r?s.jsx(Z2,{}):null,d.map(I=>s.jsx($u,{guest:I},`${u}:${I.id}`))]}):null;let x;t[6]!==l||t[7]!==f?(x=f?s.jsx(sj,{divider:l}):null,t[6]=l,t[7]=f,t[8]=x):x=t[8];const w=l||f;let S;t[9]!==w?(S=s.jsx(dj,{divider:w}),t[9]=w,t[10]=S):S=t[10];let v;t[11]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(N2,{}),t[11]=v):v=t[11];let A;return t[12]!==p||t[13]!==g||t[14]!==h||t[15]!==b||t[16]!==x||t[17]!==S?(A=s.jsxs(p,{title:g,description:h,showSaveStatus:y,children:[b,x,S,v]}),t[12]=p,t[13]=g,t[14]=h,t[15]=b,t[16]=x,t[17]=S,t[18]=A):A=t[18],A};function mj(t){return t.guests}function pj(t){return t.runtimeKey}function gj(t){return t.source==="bundled"&&t.integration&&cl(t)}const ji="__default__",fj=500,hj=(t,e)=>{const a=n=>JSON.stringify({...n,categories:n.categories.map(i=>({...i,name:i.name.trim(),description:i.description.trim()}))});return a(t)===a(e)},bj=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,64),Hu=(t,e)=>{const a=De.c(7),n=ft(yj);let i;e:{if(!t||!e){let r;a[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],a[0]=r):r=a[0],i=r;break e}let o;if(a[1]!==e||a[2]!==t||a[3]!==n){let r;a[5]!==t?(r=d=>d.id===t,a[5]=t,a[6]=r):r=a[6];const u=n.find(r)?.models.find(d=>d.id===e);o=Dd(u),a[1]=e,a[2]=t,a[3]=n,a[4]=o}else o=a[4];i=o}return i},qu=(t,e)=>t&&(e.length===0||e.includes(t))?t:null,Wu=t=>{const e=De.c(49),{providerID:a,modelID:n,value:i,onChange:o,ariaLabel:r,className:c}=t,{t:u}=Ee(),d=Hu(a,n);let l,f,p,g,h,y,b,x,w,S;if(e[0]!==r||e[1]!==c||e[2]!==o||e[3]!==u||e[4]!==i||e[5]!==d){const C=qu(i,d)??ji;let E;e[16]!==u?(E=F=>F===ji?u("settings.routing.thinking.default"):F.charAt(0).toUpperCase()+F.slice(1),e[16]=u,e[17]=E):E=e[17],g=E,p=Pt,x=C,e[18]!==o?(w=F=>o(F===ji?null:F),e[18]=o,e[19]=w):w=e[19],S=d.length===0,f=Ct,e[20]!==c?(y=ze(Es,c),e[20]=c,e[21]=y):y=e[21],b=r,l=Kt,h=g(C),e[0]=r,e[1]=c,e[2]=o,e[3]=u,e[4]=i,e[5]=d,e[6]=l,e[7]=f,e[8]=p,e[9]=g,e[10]=h,e[11]=y,e[12]=b,e[13]=x,e[14]=w,e[15]=S}else l=e[6],f=e[7],p=e[8],g=e[9],h=e[10],y=e[11],b=e[12],x=e[13],w=e[14],S=e[15];let v;e[22]!==l||e[23]!==h?(v=s.jsx(l,{children:h}),e[22]=l,e[23]=h,e[24]=v):v=e[24];let A;e[25]!==f||e[26]!==y||e[27]!==b||e[28]!==v?(A=s.jsx(f,{className:y,"aria-label":b,children:v}),e[25]=f,e[26]=y,e[27]=b,e[28]=v,e[29]=A):A=e[29];let I;e[30]!==g?(I=g(ji),e[30]=g,e[31]=I):I=e[31];let N;e[32]!==I?(N=s.jsx(bt,{value:ji,children:I}),e[32]=I,e[33]=N):N=e[33];let k;if(e[34]!==g||e[35]!==d){let C;e[37]!==g?(C=E=>s.jsx(bt,{value:E,children:g(E)},E),e[37]=g,e[38]=C):C=e[38],k=d.map(C),e[34]=g,e[35]=d,e[36]=k}else k=e[36];let P;e[39]!==N||e[40]!==k?(P=s.jsxs(It,{children:[N,k]}),e[39]=N,e[40]=k,e[41]=P):P=e[41];let j;return e[42]!==p||e[43]!==P||e[44]!==x||e[45]!==w||e[46]!==S||e[47]!==A?(j=s.jsxs(p,{value:x,onValueChange:w,disabled:S,children:[A,P]}),e[42]=p,e[43]=P,e[44]=x,e[45]=w,e[46]=S,e[47]=A,e[48]=j):j=e[48],j},xj=t=>{const e=De.c(52),{category:a,expanded:n,onToggle:i,onChange:o,onReset:r,onRemove:c}=t,{t:u}=Ee(),d=Hu(a.model?.providerID,a.model?.modelID);let l;e[0]!==a.variant||e[1]!==d?(l=qu(a.variant,d),e[0]=a.variant,e[1]=d,e[2]=l):l=e[2];const f=l;let p;e[3]!==a.model||e[4]!==f||e[5]!==u?(p=a.model?`${a.model.modelID}${f?` / ${f}`:""}`:u("settings.routing.model.useFallback"),e[3]=a.model,e[4]=f,e[5]=u,e[6]=p):p=e[6];const g=p;let h;e[7]!==a.agent||e[8]!==g?(h=[g,a.agent].filter(Boolean),e[7]=a.agent,e[8]=g,e[9]=h):h=e[9];const y=h.join(" · "),b=!a.enabled&&"opacity-60";let x;e[10]!==b?(x=ze("py-1",b),e[10]=b,e[11]=x):x=e[11];const w=n?"arrow-down-s":"arrow-right-s";let S;e[12]!==w?(S=s.jsx(te,{name:w,className:"size-4 flex-shrink-0 text-muted-foreground"}),e[12]=w,e[13]=S):S=e[13];const v=a.name||a.id;let A;e[14]!==v?(A=s.jsx("span",{className:"typography-ui-label font-medium text-foreground truncate",children:v}),e[14]=v,e[15]=A):A=e[15];let I;e[16]!==y?(I=s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:y}),e[16]=y,e[17]=I):I=e[17];let N;e[18]!==n||e[19]!==i||e[20]!==I||e[21]!==S||e[22]!==A?(N=s.jsxs("button",{type:"button",onClick:i,"aria-expanded":n,className:"flex min-w-0 flex-1 items-center gap-2 rounded-md px-1 py-1.5 text-start hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[S,A,I]}),e[18]=n,e[19]=i,e[20]=I,e[21]=S,e[22]=A,e[23]=N):N=e[23];const k=a.enabled;let P;e[24]!==o?(P=K=>o({enabled:K}),e[24]=o,e[25]=P):P=e[25];let j;e[26]!==a.name||e[27]!==u?(j=u("settings.routing.category.enabledAria",{name:a.name}),e[26]=a.name,e[27]=u,e[28]=j):j=e[28];let C;e[29]!==a.enabled||e[30]!==P||e[31]!==j?(C=s.jsx(La,{checked:k,onCheckedChange:P,"aria-label":j}),e[29]=a.enabled,e[30]=P,e[31]=j,e[32]=C):C=e[32];let E;e[33]!==N||e[34]!==C?(E=s.jsxs("div",{className:"flex items-center gap-2",children:[N,C]}),e[33]=N,e[34]=C,e[35]=E):E=e[35];let F;e[36]!==a.agent||e[37]!==a.description||e[38]!==a.model?.modelID||e[39]!==a.model?.providerID||e[40]!==a.name||e[41]!==a.variant||e[42]!==n||e[43]!==o||e[44]!==c||e[45]!==r||e[46]!==u?(F=n?s.jsxs("div",{className:"space-y-4 px-1 pb-4 pt-2",children:[s.jsxs(ma,{children:[s.jsx(St,{label:u("settings.routing.category.name"),controlClassName:"max-w-none",children:s.jsx(qe,{value:a.name,onChange:K=>o({name:K.target.value}),"aria-label":u("settings.routing.category.name"),className:"h-8 w-full rounded-md px-3",maxLength:60})}),s.jsx(St,{label:u("settings.routing.category.agent"),info:u("settings.routing.category.agentInfo"),controlClassName:"max-w-none",children:s.jsx(al,{agentName:a.agent??"",onChange:K=>o({agent:K||null}),filter:jj,className:ze(an,"w-full")})}),s.jsx(St,{label:u("settings.routing.category.model"),info:u("settings.routing.category.modelInfo"),controlClassName:"max-w-none",children:s.jsx(Fa,{providerId:a.model?.providerID??"",modelId:a.model?.modelID??"",onChange:(K,D)=>o({model:{providerID:K,modelID:D},variant:null}),className:ze(an,"w-full"),placeholder:u("settings.routing.model.useFallback")})}),s.jsx(St,{label:u("settings.routing.category.thinking"),controlClassName:"max-w-none",children:s.jsx(Wu,{providerID:a.model?.providerID,modelID:a.model?.modelID,value:a.variant,onChange:K=>o({variant:K}),ariaLabel:u("settings.routing.category.thinking"),className:"w-full"})})]}),s.jsx(St,{label:u("settings.routing.category.description"),info:u("settings.routing.category.descriptionInfo"),controlClassName:"max-w-none",children:s.jsx(Cs,{value:a.description,onChange:K=>o({description:K.target.value}),"aria-label":u("settings.routing.category.description"),rows:5,maxLength:2e3,className:"w-full"})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r?s.jsx(H,{size:"sm",variant:"outline",onClick:r,children:u("settings.routing.category.reset")}):null,s.jsx(H,{size:"sm",variant:"ghost",onClick:c,children:u("settings.routing.category.remove")})]})]}):null,e[36]=a.agent,e[37]=a.description,e[38]=a.model?.modelID,e[39]=a.model?.providerID,e[40]=a.name,e[41]=a.variant,e[42]=n,e[43]=o,e[44]=c,e[45]=r,e[46]=u,e[47]=F):F=e[47];let O;return e[48]!==E||e[49]!==F||e[50]!==x?(O=s.jsxs("div",{className:x,children:[E,F]}),e[48]=E,e[49]=F,e[50]=x,e[51]=O):O=e[51],O},vj=()=>{const{t}=Ee(),e=Bt(D=>D.available),a=Bt(D=>D.autoReady),n=Bt(D=>D.config),i=Bt(D=>D.builtins),o=Bt(D=>D.loaded),r=Bt(D=>D.loadError),c=Bt(D=>D.load),u=Bt(D=>D.saveConfig),[d,l]=m.useState(n),[f,p]=m.useState(""),[g,h]=m.useState(null),y=m.useRef(null),b=m.useRef(null),x=m.useRef(Promise.resolve()),w=m.useRef(0);m.useEffect(()=>{c()},[c]),m.useEffect(()=>{y.current||w.current>0||l(D=>D&&n&&hj(n,D)?D:n)},[n]);const S=m.useCallback(()=>{const D=y.current;if(!D||(y.current=null,D.runtimeKey!==Zt()))return x.current;w.current+=1,Mt("saving");const M=x.current.then(async()=>{try{if(D.runtimeKey!==Zt()){Mt("saved");return}await u(D.config),Mt("saved")}catch{Mt("error")}finally{w.current-=1}});return x.current=M,M},[u]);m.useEffect(()=>()=>{b.current&&clearTimeout(b.current),S()},[S]);const v=ft(D=>D.settingsDefaultModel),A=ft(D=>D.settingsDefaultVariant),I=m.useRef(!1);m.useEffect(()=>{if(I.current||!o||!n||n.fallback)return;const D=Un(v);!D||su(D.providerId,D.modelId)||(I.current=!0,N(M=>M.fallback?M:{...M,fallback:{model:{providerID:D.providerId,modelID:D.modelId},variant:A??null}}))},[o,n,v,A]);const N=m.useCallback(D=>{l(M=>{if(!M)return M;const T=D(M);return y.current={config:T,runtimeKey:Zt()},b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{b.current=null,S()},fj),T})},[S]),k=m.useCallback((D,M)=>{N(T=>({...T,categories:T.categories.map(R=>R.id===D?{...R,...M}:R)}))},[N]),P=()=>{const D=f.trim();if(!D||!d)return;const M=bj(D)||`category-${Date.now()}`;let T=M,R=2;for(;d.categories.some($=>$.id===T);)T=`${M}-${R++}`;N($=>({...$,categories:[...$.categories,{id:T,builtin:!1,enabled:!0,name:D,description:"",model:null,variant:null,agent:null}]})),p(""),h(T)},j=D=>{const M=i.find(T=>T.id===D);M&&k(D,{name:M.name,description:M.description,model:null,variant:null,agent:null,enabled:!0})},C=D=>{const M=i.find(T=>T.id===D);M&&N(T=>({...T,categories:[...T.categories,{id:D,builtin:!0,enabled:!0,name:M.name,description:M.description,model:null,variant:null,agent:null}]}))},E=D=>{N(M=>({...M,categories:M.categories.filter(T=>T.id!==D)}))},F=d?.categories.filter(D=>D.enabled).length??0,O=i.filter(D=>!d?.categories.some(M=>M.id===D.id)),K=d?.enabled?d.fallback?F<2?t("settings.routing.status.tooFewCategories"):t(a?"settings.routing.status.ready":"settings.routing.status.notReady"):t("settings.routing.status.noFallback"):t("settings.routing.status.disabled");return s.jsxs(qt,{title:t("settings.page.routing.title"),description:t("settings.page.routing.description"),showSaveStatus:!0,children:[r?s.jsx("p",{className:Ln,children:t("settings.routing.loadError",{error:r})}):null,!o||!d?null:e?s.jsxs(s.Fragment,{children:[s.jsx($e,{title:t("settings.routing.auto.title"),divider:!1,children:s.jsxs("div",{className:Ts,children:[s.jsx(Zo,{}),s.jsxs("div",{className:bs,children:[s.jsx(ct,{settingsItem:"routing.enabled",checked:d.enabled,onChange:D=>N(M=>({...M,enabled:D})),label:t("settings.routing.auto.enable"),ariaLabel:t("settings.routing.auto.enable"),info:t("settings.routing.auto.enableInfo")}),d.preserveCache===void 0?null:s.jsx(ct,{settingsItem:"routing.preserve-cache",checked:d.preserveCache,onChange:D=>N(M=>({...M,preserveCache:D})),label:t("settings.routing.auto.preserveCache"),ariaLabel:t("settings.routing.auto.preserveCache"),info:t("settings.routing.auto.preserveCacheInfo")})]}),s.jsx("p",{className:_t,children:K}),s.jsx(st,{settingsItem:"routing.fallback-model",label:t("settings.routing.auto.fallbackModel"),info:t("settings.routing.auto.fallbackModelInfo"),children:s.jsx(Fa,{providerId:d.fallback?.model.providerID??"",modelId:d.fallback?.model.modelID??"",onChange:(D,M)=>N(T=>({...T,fallback:{model:{providerID:D,modelID:M},variant:null}})),className:an,placeholder:t("settings.routing.model.placeholder")})}),s.jsx(st,{settingsItem:"routing.fallback-thinking",label:t("settings.routing.auto.fallbackThinking"),info:t("settings.routing.auto.fallbackThinkingInfo"),children:s.jsx(Wu,{providerID:d.fallback?.model.providerID,modelID:d.fallback?.model.modelID,value:d.fallback?.variant??null,onChange:D=>N(M=>M.fallback?{...M,fallback:{...M.fallback,variant:D}}:M),ariaLabel:t("settings.routing.auto.fallbackThinking")})})]})}),s.jsx($e,{title:t("settings.routing.categories.title"),children:s.jsxs("div",{className:Ts,children:[s.jsx("p",{className:_t,children:t("settings.routing.categories.description")}),s.jsx("div",{className:"divide-y divide-border/40 border-y border-border/40",children:d.categories.map(D=>s.jsx(xj,{category:D,expanded:g===D.id,onToggle:()=>h(M=>M===D.id?null:D.id),onChange:M=>k(D.id,M),onReset:D.builtin?()=>j(D.id):null,onRemove:()=>E(D.id)},D.id))}),O.length>0?s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:O.map(D=>s.jsx(H,{size:"sm",variant:"outline",onClick:()=>C(D.id),children:t("settings.routing.category.restore",{name:D.name})},D.id))}):null,s.jsx(st,{label:t("settings.routing.categories.addLabel"),settingsItem:"routing.add-category",children:s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[s.jsx(qe,{value:f,onChange:D=>p(D.target.value),onKeyDown:D=>{D.key==="Enter"&&P()},placeholder:t("settings.routing.categories.addPlaceholder"),"aria-label":t("settings.routing.categories.addLabel"),className:"h-8 rounded-md px-3 min-w-0 flex-1",maxLength:60}),s.jsx(H,{size:"sm",variant:"outline",onClick:P,disabled:f.trim().length===0,children:t("settings.routing.categories.add")})]})})]})})]}):s.jsx("p",{className:Ln,children:t("settings.routing.unavailable")})]})};function yj(t){return t.providers}function jj(t){return Co(t.mode)}const kj={prompt:{icon:"chat-1",titleKey:"settings.extensions.capability.prompt",detailKey:"settings.extensions.capability.prompt.detail"},sessions:{icon:"git-branch",titleKey:"settings.extensions.capability.sessions",detailKey:"settings.extensions.capability.sessions.detail"},files:{icon:"file-text",titleKey:"settings.extensions.capability.files",detailKey:"settings.extensions.capability.files.detail"},model:{icon:"sparkling",titleKey:"settings.extensions.capability.model",detailKey:"settings.extensions.capability.model.detail"},shells:{icon:"terminal-box",titleKey:"settings.extensions.capability.shells",detailKey:"settings.extensions.capability.shells.detail"},conversation:{icon:"chat-history",titleKey:"settings.extensions.capability.conversation",detailKey:"settings.extensions.capability.conversation.detail"},filesystem:{icon:"hard-drive-2",titleKey:"settings.extensions.capability.filesystem",detailKey:"settings.extensions.capability.filesystem.detail"},service:{icon:"terminal",titleKey:"settings.extensions.capability.service",detailKey:"settings.extensions.capability.service.detail"},network:{icon:"plug",titleKey:"settings.extensions.capability.network",detailKey:"settings.extensions.capability.network.detail"},origins:{icon:"global",titleKey:"settings.extensions.capability.origins",detailKey:"settings.extensions.capability.origins.detail"}},wj=t=>{const e=De.c(77),{guest:a,busy:n,onApprove:i,onDecline:o,onDismiss:r}=t,{t:c}=Ee();let u;e[0]!==a?.capabilities.requested?(u=a?.capabilities.requested??[],e[0]=a?.capabilities.requested,e[1]=u):u=e[1];const d=u;let l;e[2]!==a?.filesystem?(l=a?.filesystem??[],e[2]=a?.filesystem,e[3]=l):l=e[3];const f=l;let p;e[4]!==a?.origins?(p=a?.origins??[],e[4]=a?.origins,e[5]=p):p=e[5];const g=p;let h;e[6]!==a?.service?.permissions?.exec?(h=a?.service?.permissions?.exec??[],e[6]=a?.service?.permissions?.exec,e[7]=h):h=e[7];const y=h;let b;e[8]!==a?.service?.permissions?.sockets?(b=a?.service?.permissions?.sockets??[],e[8]=a?.service?.permissions?.sockets,e[9]=b):b=e[9];const x=b,w=a?.service;let S;e[10]!==w?(S=Wd(w,"browser"),e[10]=w,e[11]=S):S=e[11];const v=S,A=a?.integration?.apiOrigin??null,I=a!==null;let N;e[12]!==n||e[13]!==r?(N=Y=>{!Y&&!n&&r()},e[12]=n,e[13]=r,e[14]=N):N=e[14];const k=a?.name??"";let P;e[15]!==c||e[16]!==k?(P=c("settings.extensions.dialog.approveTitle",{name:k}),e[15]=c,e[16]=k,e[17]=P):P=e[17];let j;e[18]!==P?(j=s.jsx(Ot,{children:P}),e[18]=P,e[19]=j):j=e[19];const C=a?.name??"",E=a?.version?`v${a.version}`:"";let F;e[20]!==c||e[21]!==C||e[22]!==E?(F=c("settings.extensions.dialog.approveDescription",{name:C,version:E}),e[20]=c,e[21]=C,e[22]=E,e[23]=F):F=e[23];let O;e[24]!==F?(O=s.jsx(Ft,{children:F}),e[24]=F,e[25]=O):O=e[25];let K;e[26]!==j||e[27]!==O?(K=s.jsxs(Rt,{children:[j,O]}),e[26]=j,e[27]=O,e[28]=K):K=e[28];let D;if(e[29]!==A||e[30]!==f||e[31]!==g||e[32]!==v||e[33]!==d||e[34]!==y||e[35]!==x||e[36]!==c){let Y;e[38]!==A||e[39]!==f||e[40]!==g||e[41]!==v||e[42]!==y||e[43]!==x||e[44]!==c?(Y=ae=>{const ee=kj[ae];return s.jsxs("li",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--surface-muted)]",children:s.jsx(te,{name:ee.icon,className:"size-4 text-foreground"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground",children:c(ee.titleKey)}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:c(ee.detailKey)}),ae==="filesystem"&&f.length>0?s.jsx("ul",{className:"mt-1 space-y-0.5",children:f.map(Sj)}):null,ae==="origins"&&g.length>0?s.jsx("ul",{className:"mt-1 space-y-0.5",children:g.map(Nj)}):null,ae==="network"&&A?s.jsxs("p",{className:"typography-meta mt-1 text-foreground",children:[c("settings.extensions.capability.service.sockets")," ",s.jsx("span",{className:"break-all font-mono",children:A})]}):null,ae==="service"&&y.length>0?s.jsxs("p",{className:"typography-meta mt-1 text-foreground",children:[c("settings.extensions.capability.service.runs")," ",s.jsx("span",{className:"break-all font-mono",children:y.join(", ")})]}):null,ae==="service"&&x.length>0?s.jsxs("p",{className:"typography-meta mt-0.5 text-foreground",children:[c("settings.extensions.capability.service.sockets")," ",s.jsx("span",{className:"break-all font-mono",children:x.join(", ")})]}):null,ae==="service"&&v?s.jsx("p",{className:"typography-meta mt-0.5 text-foreground",children:c("settings.extensions.capability.service.providesBrowser")}):null]})]},ae)},e[38]=A,e[39]=f,e[40]=g,e[41]=v,e[42]=y,e[43]=x,e[44]=c,e[45]=Y):Y=e[45],D=d.map(Y),e[29]=A,e[30]=f,e[31]=g,e[32]=v,e[33]=d,e[34]=y,e[35]=x,e[36]=c,e[37]=D}else D=e[37];let M;e[46]!==D?(M=s.jsx("ul",{className:"space-y-3",children:D}),e[46]=D,e[47]=M):M=e[47];let T;e[48]!==a||e[49]!==o?(T=()=>a&&o(a),e[48]=a,e[49]=o,e[50]=T):T=e[50];let R;e[51]!==c?(R=c("settings.extensions.dialog.decline"),e[51]=c,e[52]=R):R=e[52];let $;e[53]!==n||e[54]!==T||e[55]!==R?($=s.jsx(H,{size:"sm",variant:"ghost",disabled:n,onClick:T,children:R}),e[53]=n,e[54]=T,e[55]=R,e[56]=$):$=e[56];let z;e[57]!==a||e[58]!==i?(z=()=>a&&i(a),e[57]=a,e[58]=i,e[59]=z):z=e[59];let Q;e[60]!==c?(Q=c("settings.extensions.dialog.approve"),e[60]=c,e[61]=Q):Q=e[61];let V;e[62]!==n||e[63]!==z||e[64]!==Q?(V=s.jsx(H,{size:"sm",disabled:n,onClick:z,children:Q}),e[62]=n,e[63]=z,e[64]=Q,e[65]=V):V=e[65];let L;e[66]!==$||e[67]!==V?(L=s.jsxs(Wt,{children:[$,V]}),e[66]=$,e[67]=V,e[68]=L):L=e[68];let B;e[69]!==K||e[70]!==M||e[71]!==L?(B=s.jsxs(Et,{className:"max-w-md",children:[K,M,L]}),e[69]=K,e[70]=M,e[71]=L,e[72]=B):B=e[72];let W;return e[73]!==B||e[74]!==I||e[75]!==N?(W=s.jsx(Tt,{open:I,onOpenChange:N,children:B}),e[73]=B,e[74]=I,e[75]=N,e[76]=W):W=e[76],W};function Sj(t){return s.jsx("li",{className:"typography-meta break-all font-mono text-foreground",children:t},t)}function Nj(t){return s.jsx("li",{className:"typography-meta break-all font-mono text-foreground",children:t},t)}const Cj=t=>{if(t.source!=="git"||!t.origin?.url)return null;const e=t.origin.url.trim(),a=/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?([A-Za-z0-9][A-Za-z0-9.-]*\.[A-Za-z0-9.-]+):([^\s]+)$/.exec(e);try{const n=new URL(a?`ssh://${a[1]}/${a[2]}`:e);if(n.protocol!=="https:"&&n.protocol!=="ssh:")return null;const i=n.protocol==="ssh:"?new URL(`https://${n.hostname}${n.pathname}`):n;return i.username="",i.password="",i.search="",i.hash="",i.pathname=i.pathname.replace(/\/+$/,"").replace(/\.git$/i,""),i.pathname==="/"?null:i.href}catch{return null}},wr=(t,e)=>{const a=`${t.method} ${t.path}`;return t.kind==="network"?`${a}: ${e("settings.extensions.request.noResponse")}`:t.kind==="invalid-response"?`${a}: ${e("settings.extensions.request.invalidResponse",{status:t.status})}`:`${a}: HTTP ${t.status}`},ad=t=>t.name.toLowerCase().endsWith(".zip"),Gu=t=>t==="path"?"settings.extensions.source.path":t==="zip"?"settings.extensions.source.zip":t==="git"?"settings.extensions.source.git":"settings.extensions.source.bundled",Ij=t=>{const e=(t.service?.socketBindings??[]).map(i=>i.resolved?`${i.id}=${i.resolved}`:`${i.id}?`),a=(t.service?.permissions?.sockets??[]).filter(i=>!(t.service?.socketBindings??[]).some(o=>o.id===i));return[...e,...a,...t.service?.permissions?.exec??[]].join(", ")},Pj=t=>{const e=De.c(27),{guest:a,binding:n,busy:i,onSaved:o}=t,{t:r}=Ee(),[c,u]=m.useState(n.override??n.resolved??""),[d,l]=m.useState(!1),[f,p]=m.useState(!n.resolved);let g;e[0]!==n.override||e[1]!==n.resolved?(g=()=>{u(n.override??n.resolved??""),n.resolved||p(!0)},e[0]=n.override,e[1]=n.resolved,e[2]=g):g=e[2];let h;e[3]!==n.id||e[4]!==n.override||e[5]!==n.resolved?(h=[n.id,n.override,n.resolved],e[3]=n.id,e[4]=n.override,e[5]=n.resolved,e[6]=h):h=e[6],m.useEffect(g,h);let y;e[7]!==n.id||e[8]!==a.id||e[9]!==a.name||e[10]!==o||e[11]!==r?(y=async v=>{l(!0);const A=await kp(a.id,n.id,v);if(l(!1),!A){q.error(r("settings.extensions.toast.socketSaveFailed"));return}q.success(r("settings.extensions.toast.socketSaved",{name:a.name})),p(!1),await o()},e[7]=n.id,e[8]=a.id,e[9]=a.name,e[10]=o,e[11]=r,e[12]=y):y=e[12];const b=y;let x;e[13]!==n.override||e[14]!==n.resolved?(x=()=>{u(n.override??n.resolved??""),n.resolved&&p(!1)},e[13]=n.override,e[14]=n.resolved,e[15]=x):x=e[15];const w=x;let S;return e[16]!==n.id||e[17]!==n.override||e[18]!==n.resolved||e[19]!==i||e[20]!==w||e[21]!==f||e[22]!==b||e[23]!==d||e[24]!==r||e[25]!==c?(S=s.jsx("div",{className:"space-y-1",children:f?s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(qe,{value:c,onChange:v=>u(v.target.value),placeholder:r("settings.extensions.service.socket.path",{id:n.id}),"aria-label":r("settings.extensions.service.socket.path.aria",{id:n.id}),className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:i||d,autoFocus:!0}),s.jsx(H,{type:"button",variant:"ghost",size:"xs",disabled:i||d,"aria-label":r("settings.extensions.service.socket.save.aria",{id:n.id}),onClick:()=>{b(c.trim()||null)},children:r("settings.extensions.service.socket.save")}),n.override?s.jsx(H,{type:"button",variant:"ghost",size:"xs",disabled:i||d,"aria-label":r("settings.extensions.service.socket.clear.aria",{id:n.id}),onClick:()=>{b(null)},children:r("settings.extensions.service.socket.clear")}):null,n.resolved?s.jsx(H,{type:"button",variant:"ghost",size:"xs",disabled:i||d,"aria-label":r("settings.extensions.service.socket.cancel.aria",{id:n.id}),onClick:w,children:r("settings.extensions.service.socket.cancel")}):null]}):s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx("div",{className:"typography-meta min-w-0 flex-1 truncate text-muted-foreground",children:n.resolved?r("settings.extensions.service.socket.resolved",{path:n.resolved}):r("settings.extensions.service.socket.unresolved")}),s.jsx(H,{type:"button",variant:"ghost",size:"icon",className:Yt,disabled:i||d,"aria-label":r("settings.extensions.service.socket.edit.aria",{id:n.id}),onClick:()=>p(!0),children:s.jsx(te,{name:"pencil",className:"h-3.5 w-3.5"})})]})}),e[16]=n.id,e[17]=n.override,e[18]=n.resolved,e[19]=i,e[20]=w,e[21]=f,e[22]=b,e[23]=d,e[24]=r,e[25]=c,e[26]=S):S=e[26],S},Ju=t=>{const e=t.enabled!==!1,a=(t.enterpriseBlocked?.length??0)>0,n=!a&&ai(t),i=t.source==="bundled",o=a?"settings.extensions.status.enterpriseBlocked":n?"settings.extensions.status.needsApproval":e?"settings.extensions.status.enabled":"settings.extensions.status.disabled",r=a||n?"warning":e?"success":"neutral";return{enabled:e,enterpriseBlocked:a,needsApproval:n,builtIn:i,canRemove:!!(t.source&&t.source!=="bundled"),sourceUrl:Cj(t),update:t.source==="git"?t.update:void 0,statusKey:o,statusTone:r}},Qu=t=>{const e=De.c(3);let a;return e[0]!==t.icon||e[1]!==t.id?(a=Vd(t.id,t.icon,Xd().authenticatedAsset),e[0]=t.icon,e[1]=t.id,e[2]=a):a=e[2],a},Aj=t=>{const e=De.c(36),{guest:a,busy:n,onOpen:i,onReview:o,onRemove:r,onSetEnabled:c,onUpdate:u}=t,{t:d}=Ee(),l=Ju(a),f=Qu(a),p=n?[]:[...l.update?[{label:d("settings.extensions.update.action"),icon:"arrow-up-s",onSelect:()=>{u(a)}}]:[],...l.needsApproval?[{label:d("settings.extensions.review"),icon:"shield-check",onSelect:()=>o(a)}]:[],...l.enterpriseBlocked?[]:[{label:l.enabled?d("settings.extensions.actions.disable"):d("settings.extensions.actions.enable"),icon:l.enabled?"pause":"play",onSelect:()=>{c(a.id,a.name,!l.enabled)}}],...l.sourceUrl?[{label:d("settings.extensions.actions.openSource"),icon:"external-link",onSelect:()=>{Ks(l.sourceUrl??"")}}]:[],...l.canRemove?[{label:d("settings.extensions.remove"),icon:"delete-bin",destructive:!0,onSelect:()=>{r(a.id,a.name)}}]:[]],g=qn;let h;e[0]!==a.icon?(h=ll(a.icon),e[0]=a.icon,e[1]=h):h=e[1];let y;e[2]!==f||e[3]!==h?(y=s.jsx(rl,{icon:h,iconSrc:f,className:"size-5 text-foreground"}),e[2]=f,e[3]=h,e[4]=y):y=e[4];const b=a.name,x=l.update?s.jsx(js,{tone:"info",children:d("settings.extensions.update.badge",{version:l.update.version})}):null,w=js,S=l.statusTone,v=d(l.statusKey);let A;e[5]!==w||e[6]!==l.statusTone||e[7]!==v?(A=s.jsx(w,{tone:S,children:v}),e[5]=w,e[6]=l.statusTone,e[7]=v,e[8]=A):A=e[8];let I;e[9]!==x||e[10]!==A?(I=s.jsxs(s.Fragment,{children:[x,A]}),e[9]=x,e[10]=A,e[11]=I):I=e[11];let N;e[12]!==a||e[13]!==d?(N=Tj(a,d),e[12]=a,e[13]=d,e[14]=N):N=e[14];let k;e[15]!==N?(k=s.jsx("span",{className:"truncate",children:N}),e[15]=N,e[16]=k):k=e[16];let P;e[17]!==l.builtIn||e[18]!==d?(P=l.builtIn?s.jsx($i,{children:d("settings.extensions.source.bundled")}):null,e[17]=l.builtIn,e[18]=d,e[19]=P):P=e[19];let j;e[20]!==k||e[21]!==P?(j=s.jsxs(s.Fragment,{children:[k,P]}),e[20]=k,e[21]=P,e[22]=j):j=e[22];const C=!l.enabled;let E;e[23]!==a.name||e[24]!==d?(E=d("settings.extensions.grid.actionsAria",{name:a.name}),e[23]=a.name,e[24]=d,e[25]=E):E=e[25];let F;return e[26]!==g||e[27]!==p||e[28]!==a.name||e[29]!==i||e[30]!==j||e[31]!==C||e[32]!==E||e[33]!==y||e[34]!==I?(F=s.jsx(g,{icon:y,title:b,badges:I,footer:j,muted:C,onOpen:i,actionsLabel:E,actions:p}),e[26]=g,e[27]=p,e[28]=a.name,e[29]=i,e[30]=j,e[31]=C,e[32]=E,e[33]=y,e[34]=I,e[35]=F):F=e[35],F},Tj=(t,e)=>[t.source==="bundled"?null:e(Gu(t.source)),t.version?`v${t.version}`:null,t.entry?null:e("settings.extensions.source.noPanel")].filter(Boolean).join(" · "),Ej=t=>{const e=De.c(54),{guest:a,busy:n,onBack:i,onReview:o,onRemove:r,onSetEnabled:c,onUpdate:u}=t,{t:d}=Ee(),l=Ju(a),f=Qu(a),p=Ij(a),g=a.path||a.id,h=!!p||!!a.service,y=a.name;let b;e[0]!==d?(b=d("settings.extensions.detail.back"),e[0]=d,e[1]=b):b=e[1];let x;e[2]!==i||e[3]!==b?(x=s.jsx(ii,{label:b,onClick:i}),e[2]=i,e[3]=b,e[4]=x):x=e[4];let w;e[5]!==a.icon?(w=ll(a.icon),e[5]=a.icon,e[6]=w):w=e[6];let S;e[7]!==f||e[8]!==w?(S=s.jsx(rl,{icon:w,iconSrc:f,className:"size-5 shrink-0 text-foreground"}),e[7]=f,e[8]=w,e[9]=S):S=e[9];let v;e[10]!==x||e[11]!==S?(v=s.jsxs(s.Fragment,{children:[x,S]}),e[10]=x,e[11]=S,e[12]=v):v=e[12];const A=l.enterpriseBlocked?null:s.jsx(H,{type:"button",size:"sm",variant:l.enabled?"outline":"default",disabled:n,"aria-label":l.enabled?d("settings.extensions.actions.disable.aria",{name:a.name}):d("settings.extensions.actions.enable.aria",{name:a.name}),onClick:()=>{c(a.id,a.name,!l.enabled)},children:l.enabled?d("settings.extensions.actions.disable"):d("settings.extensions.actions.enable")}),I=l.canRemove?s.jsxs(H,{type:"button",size:"sm",variant:"ghost",className:"text-[var(--status-error)] hover:text-[var(--status-error)]",disabled:n,"aria-label":d("settings.extensions.remove.aria",{name:a.name}),onClick:()=>{r(a.id,a.name).then(i)},children:[s.jsx(te,{name:"delete-bin",className:"size-3.5"}),d("settings.extensions.remove")]}):null;let N;e[13]!==A||e[14]!==I?(N=s.jsxs("div",{className:"flex items-center gap-2",children:[A,I]}),e[13]=A,e[14]=I,e[15]=N):N=e[15];let k;e[16]!==d?(k=d("settings.extensions.detail.section.details"),e[16]=d,e[17]=k):k=e[17];const P=l.enterpriseBlocked||l.needsApproval||!!l.update;let j;e[18]!==d?(j=d("settings.extensions.detail.field.source"),e[18]=d,e[19]=j):j=e[19];let C;e[20]!==a.source||e[21]!==d?(C=d(Gu(a.source)),e[20]=a.source,e[21]=d,e[22]=C):C=e[22];let E;e[23]!==C?(E=s.jsx("span",{className:"typography-ui-label text-foreground",children:C}),e[23]=C,e[24]=E):E=e[24];let F;e[25]!==l||e[26]!==d?(F=l.sourceUrl?s.jsxs(H,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Ks(l.sourceUrl??"")},children:[s.jsx(te,{name:"external-link",className:"size-3.5"}),d("settings.extensions.actions.openSource")]}):null,e[25]=l,e[26]=d,e[27]=F):F=e[27];let O;e[28]!==j||e[29]!==E||e[30]!==F?(O=s.jsxs(st,{label:j,children:[E,F]}),e[28]=j,e[29]=E,e[30]=F,e[31]=O):O=e[31];let K;e[32]!==a.version||e[33]!==d?(K=a.version?s.jsx(st,{label:d("settings.extensions.detail.field.version"),children:s.jsx("span",{className:"typography-ui-label tabular-nums text-foreground",children:`v${a.version}`})}):null,e[32]=a.version,e[33]=d,e[34]=K):K=e[34];let D;e[35]!==d?(D=d("settings.extensions.detail.field.location"),e[35]=d,e[36]=D):D=e[36];let M;e[37]!==g?(M=s.jsx("span",{className:"typography-meta min-w-0 truncate font-mono text-muted-foreground",title:g,children:g}),e[37]=g,e[38]=M):M=e[38];let T;e[39]!==D||e[40]!==M?(T=s.jsx(st,{label:D,alignEnd:!1,controlClassName:"min-w-0 @xl:flex-1",children:M}),e[39]=D,e[40]=M,e[41]=T):T=e[41];let R;e[42]!==O||e[43]!==K||e[44]!==T?(R=s.jsxs("div",{children:[O,K,T]}),e[42]=O,e[43]=K,e[44]=T,e[45]=R):R=e[45];let $;e[46]!==l||e[47]!==d?($=l.builtIn?s.jsx("p",{className:_t,children:d("settings.extensions.builtIn.info")}):null,e[46]=l,e[47]=d,e[48]=$):$=e[48];let z;return e[49]!==k||e[50]!==P||e[51]!==R||e[52]!==$?(z=s.jsxs($e,{title:k,divider:P,contentClassName:"space-y-3",children:[R,$]}),e[49]=k,e[50]=P,e[51]=R,e[52]=$,e[53]=z):z=e[53],s.jsxs(qt,{title:y,titleLeading:v,titleAccessory:s.jsx(js,{tone:l.statusTone,children:d(l.statusKey)}),headerEnd:N,children:[l.enterpriseBlocked||l.needsApproval||l.update?s.jsxs($e,{divider:!1,contentClassName:"space-y-2",children:[l.enterpriseBlocked?s.jsx("div",{className:"rounded-lg bg-[var(--status-warning)]/10 p-3 typography-meta text-[var(--status-warning)]",children:d("settings.extensions.enterpriseBlocked")}):null,l.needsApproval?s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg bg-[var(--status-warning)]/10 p-3",children:[s.jsx("span",{className:"typography-meta text-[var(--status-warning)]",children:d("settings.extensions.status.needsApproval")}),s.jsx(H,{type:"button",size:"sm",disabled:n,"aria-label":d("settings.extensions.review.aria",{name:a.name}),onClick:()=>o(a),children:d("settings.extensions.review")})]}):null,l.update?s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg bg-[var(--status-info)]/10 p-3",children:[s.jsx("span",{className:"typography-meta text-[var(--status-info)]",children:d("settings.extensions.update.badge",{version:l.update.version})}),s.jsx(H,{type:"button",size:"sm",disabled:n,"aria-label":d("settings.extensions.update.action.aria",{name:a.name,version:l.update.version}),onClick:()=>{u(a)},children:d("settings.extensions.update.action")})]}):null]}):null,z,h?s.jsxs($e,{title:d("settings.extensions.detail.section.permissions"),contentClassName:"space-y-3",children:[p?s.jsx("p",{className:"typography-meta text-foreground",children:d("settings.extensions.service.permissions",{list:p})}):null,a.service?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:d("settings.extensions.service.warning")}):null,l.enabled?(a.service?.socketBindings??[]).map(Q=>s.jsx(Pj,{guest:a,binding:Q,busy:n,onSaved:nn},Q.id)):null]}):null]})},Mj=t=>{const e=De.c(33),{guest:a,busy:n,onRemove:i}=t,{t:o}=Ee();let r,c,u,d,l,f;if(e[0]!==n||e[1]!==a.builtIn||e[2]!==a.id||e[3]!==a.name||e[4]!==i||e[5]!==o){const h=a.name??a.id??o("settings.extensions.unreadable.unnamed"),y=a.builtIn?null:a.id;r=qn,e[12]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(te,{name:"error-warning",className:"size-5 text-[var(--status-error)]"}),e[12]=d):d=e[12],l=h;let b;e[13]!==o?(b=o("settings.extensions.status.unreadable"),e[13]=o,e[14]=b):b=e[14],e[15]!==b?(f=s.jsx(js,{tone:"error",children:b}),e[15]=b,e[16]=f):f=e[16];let x;e[17]!==o?(x=o("settings.extensions.unreadable.hint"),e[17]=o,e[18]=x):x=e[18];let w;e[19]!==o?(w=o("settings.extensions.unreadable.hint"),e[19]=o,e[20]=w):w=e[20],e[21]!==x||e[22]!==w?(c=s.jsx("span",{className:"min-w-0 flex-1 truncate",title:x,children:w}),e[21]=x,e[22]=w,e[23]=c):c=e[23],u=y?s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 !font-normal",disabled:n,"aria-label":o("settings.extensions.remove.aria",{name:h}),onClick:()=>{i(y,h)},children:o("settings.extensions.remove")}):null,e[0]=n,e[1]=a.builtIn,e[2]=a.id,e[3]=a.name,e[4]=i,e[5]=o,e[6]=r,e[7]=c,e[8]=u,e[9]=d,e[10]=l,e[11]=f}else r=e[6],c=e[7],u=e[8],d=e[9],l=e[10],f=e[11];let p;e[24]!==c||e[25]!==u?(p=s.jsxs(s.Fragment,{children:[c,u]}),e[24]=c,e[25]=u,e[26]=p):p=e[26];let g;return e[27]!==r||e[28]!==d||e[29]!==l||e[30]!==f||e[31]!==p?(g=s.jsx(r,{icon:d,title:l,badges:f,footer:p}),e[27]=r,e[28]=d,e[29]=l,e[30]=f,e[31]=p,e[32]=g):g=e[32],g},Dj=()=>{const t=De.c(294),{t:e}=Ee(),a=Ps(Rj),n=Ps(Oj),i=Ps(Fj),o=Ps(Lj),r=Ps(Kj),[c,u]=m.useState(null),[d,l]=m.useState(!1),[f,p]=m.useState("global"),g=i==="unsupported",[h,y]=m.useState(""),b=Pn(),[x,w]=m.useState(!1),[S,v]=m.useState(!1),A=m.useRef(!1),[I,N]=m.useState(null),[k,P]=m.useState(null),[j,C]=m.useState(!1),[E,F]=m.useState(!1),[O,K]=m.useState(null),D=m.useRef(0),M=m.useRef(null);let T;t[0]===Symbol.for("react.memo_cache_sentinel")?(T=Eg(),t[0]=T):T=t[0];const R=T;let $;t[1]===Symbol.for("react.memo_cache_sentinel")?($=[],t[1]=$):$=t[1],m.useEffect(_j,$);let z,Q;t[2]!==r||t[3]!==g?(z=()=>{let rt=!1;if(u(null),l(!1),p("global"),N(null),P(null),A.current=!1,!g)return Promise.all([wp(),Sp()]).then(gt=>{const[Jt,zs]=gt;rt||u({runtimeKey:r,profiles:Jt,global:zs})}).catch(()=>{rt||l(!0)}),()=>{rt=!0}},Q=[r,g],t[2]=r,t[3]=g,t[4]=z,t[5]=Q):(z=t[4],Q=t[5]),m.useEffect(z,Q);const V=c?.runtimeKey===r?c:null;let L;t[6]!==e?(L=e("settings.gitIdentities.editor.title.globalIdentity"),t[6]=e,t[7]=L):L=t[7];const B=V?.global?.userName??"",W=V?.global?.userEmail??"";let Y;t[8]!==L||t[9]!==B||t[10]!==W?(Y={id:"global",name:L,userName:B,userEmail:W,icon:"fingerprint",color:"info"},t[8]=L,t[9]=B,t[10]=W,t[11]=Y):Y=t[11];let ae;t[12]!==V?.profiles||t[13]!==Y?(ae=[Y,...V?.profiles.filter($j)??[]],t[12]=V?.profiles,t[13]=Y,t[14]=ae):ae=t[14];const ee=ae;let G;t[15]!==ee||t[16]!==f?(G=ee.find(rt=>rt.id===f)??ee[0],t[15]=ee,t[16]=f,t[17]=G):G=t[17];const le=G;let J,me;t[18]!==i?(J=()=>{if(i!=="ready"||A.current)return;A.current=!0;const rt=Ps.getState().runtimeKey;nd(!1).then(gt=>{gt.ok&&Ps.getState().applyUpdates(gt.updates,rt)})},me=[i],t[18]=i,t[19]=J,t[20]=me):(J=t[19],me=t[20]),m.useEffect(J,me);let fe;t[21]!==e?(fe=async()=>{v(!0);const rt=Ps.getState().runtimeKey,gt=await nd(!0);if(v(!1),!gt.ok){q.error(e("settings.extensions.toast.checkFailed"));return}Ps.getState().applyUpdates(gt.updates,rt),Object.keys(gt.updates).length===0&&q.success(e("settings.extensions.toast.upToDate"))},t[21]=e,t[22]=fe):fe=t[22];const oe=fe;let pe;t[23]!==e?(pe=async rt=>{w(!0);const gt=await Vu(rt.id);if(w(!1),!gt.ok){q.error(gt.code==="host-too-old"&&gt.required?e("settings.extensions.toast.hostTooOld",{version:gt.required}):e(Bu(gt.code)));return}Ei(rt.id),q.success(e("settings.extensions.toast.updated",{name:gt.guest.name,version:gt.guest.version??""})),await nn(),ai(gt.guest)&&P(gt.guest)},t[23]=e,t[24]=pe):pe=t[24];const se=pe;let ve;if(t[25]!==a||t[26]!==e||t[27]!==n){const rt=async(gt,Jt,zs)=>{const jn=zs===void 0?{}:zs;if(!gt.ok&&gt.code==="unreadable")return y(""),N(null),q.error(e(Zr(gt.code))),await nn(),!1;if(!gt.ok){if(jn.allowConflictDialog!==!1&&(gt.code==="id-taken"||gt.code==="already-installed")){const Rn=gt.id?a.find(pn=>pn.id===gt.id)??n.find(pn=>pn.id===gt.id):void 0;return N({source:Jt,name:Rn?.name??gt.id??(Jt.kind==="file"?Jt.file.name:Jt.input)}),!1}return gt.code==="host-too-old"?q.error(gt.required?e("settings.extensions.toast.hostTooOld",{version:gt.required}):e("settings.extensions.toast.failed"),{description:gt.diagnostic?wr(gt.diagnostic,e):void 0}):q.error(e(Zr(gt.code)),{description:gt.diagnostic?wr(gt.diagnostic,e):void 0}),!1}return y(""),N(null),F(!1),q.success(gt.replaced?e("settings.extensions.toast.reinstalled",{name:gt.guest.name}):e("settings.extensions.toast.added",{name:gt.guest.name})),await nn(),ai(gt.guest)&&P(gt.guest),!0};ve=async(gt,Jt)=>{const zs=Jt===void 0?{}:Jt,jn=Zt();gt.kind==="input"&&y(gt.input),w(!0);const Rn=gt.kind==="file"?await Vf(gt.file,zs):await mu(gt.input,{...zs,gitIdentityId:gt.gitIdentityId});w(!1),Zt()===jn&&await rt(Rn,gt,{allowConflictDialog:!zs.replace})},t[25]=a,t[26]=e,t[27]=n,t[28]=ve}else ve=t[28];const be=ve;let ne;t[29]!==h||t[30]!==be||t[31]!==le||t[32]!==e?(ne=async()=>{const rt=h.trim();if(!rt){q.error(e("settings.extensions.toast.invalidPath"));return}await be({kind:"input",input:rt,gitIdentityId:le.id})},t[29]=h,t[30]=be,t[31]=le,t[32]=e,t[33]=ne):ne=t[33];const we=ne;let Ne;t[34]!==be?(Ne=async()=>{if(!R)return;const rt=await Mg("");rt.success&&rt.path&&await be({kind:"input",input:rt.path})},t[34]=be,t[35]=Ne):Ne=t[35];const Ie=Ne;let Ce;t[36]!==be?(Ce=async()=>{if(!R){M.current?.click();return}const rt=await pl({filters:[{name:"ZIP Archive",extensions:["zip"]}]});rt.success&&rt.path&&await be({kind:"input",input:rt.path})},t[36]=be,t[37]=Ce):Ce=t[37];const Me=Ce;let he;t[38]!==be||t[39]!==e?(he=async rt=>{const gt=rt.target.files?.[0]??null;if(rt.target.value="",!!gt){if(!ad(gt)){q.error(e("settings.extensions.toast.invalidPath"));return}await be({kind:"file",file:gt})}},t[38]=be,t[39]=e,t[40]=he):he=t[40];const Pe=he;let Re;t[41]!==x?(Re=rt=>{x||(rt.preventDefault(),D.current=D.current+1,C(!0))},t[41]=x,t[42]=Re):Re=t[42];const ce=Re;let je;t[43]!==x?(je=rt=>{x||(rt.preventDefault(),rt.dataTransfer.dropEffect="copy")},t[43]=x,t[44]=je):je=t[44];const de=je;let ie;t[45]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>{D.current=Math.max(0,D.current-1),D.current===0&&C(!1)},t[45]=ie):ie=t[45];const xe=ie;let Se;t[46]!==x||t[47]!==be||t[48]!==e?(Se=async rt=>{if(rt.preventDefault(),D.current=0,C(!1),x)return;const gt=rt.dataTransfer.items[0],Jt=gt?.getAsFile()??null,jn=(gt?.webkitGetAsEntry()??null)?.isDirectory===!0,Rn=Jt!==null&&!jn&&ad(Jt),pn=Jt&&R?Dg(Jt):null;if(pn&&(jn||Rn)){await be({kind:"input",input:pn});return}if(jn){q.error(e(R?"settings.extensions.toast.invalidPath":"settings.extensions.toast.folderNeedsZip"));return}if(!Jt||!Rn){q.error(e("settings.extensions.toast.invalidPath"));return}await be({kind:"file",file:Jt})},t[46]=x,t[47]=be,t[48]=e,t[49]=Se):Se=t[49];const Le=Se;let Ue;t[50]!==I||t[51]!==be?(Ue=async()=>{I&&await be(I.source,{replace:!0})},t[50]=I,t[51]=be,t[52]=Ue):Ue=t[52];const Ye=Ue;let lt;t[53]!==e?(lt=async(rt,gt)=>{w(!0);const Jt=await uu(rt);if(w(!1),!Jt.ok){q.error(e("settings.extensions.toast.removeFailed"));return}Ei(rt),q.success(e("settings.extensions.toast.removed",{name:gt})),await nn()},t[53]=e,t[54]=lt):lt=t[54];const at=lt;let ut;t[55]!==e?(ut=async rt=>{w(!0);const gt=await Hf(rt.id,rt.capabilities.requested);if(w(!1),!gt){q.error(e("settings.extensions.toast.approveFailed"));return}P(null),q.success(e("settings.extensions.toast.approved",{name:rt.name})),await nn()},t[55]=e,t[56]=ut):ut=t[56];const vt=ut;let We;t[57]!==at?(We=async rt=>{P(null),await at(rt.id,rt.name)},t[57]=at,t[58]=We):We=t[58];const Ze=We;let Xe;t[59]!==e?(Xe=async(rt,gt,Jt)=>{w(!0);const zs=await pu(rt,Jt);if(w(!1),!zs){q.error(e("settings.extensions.toast.enabledFailed"));return}Jt||Ei(rt),q.success(Jt?e("settings.extensions.toast.enabled",{name:gt}):e("settings.extensions.toast.disabled",{name:gt})),await nn()},t[59]=e,t[60]=Xe):Xe=t[60];const it=Xe;let dt;t[61]!==Le?(dt=rt=>{Le(rt)},t[61]=Le,t[62]=dt):dt=t[62];let Be;t[63]!==ce||t[64]!==de||t[65]!==dt?(Be={onDragEnter:ce,onDragOver:de,onDragLeave:xe,onDrop:dt},t[63]=ce,t[64]=de,t[65]=dt,t[66]=Be):Be=t[66];const ot=Be;let et;t[67]!==x||t[68]!==at||t[69]!==it||t[70]!==se?(et={busy:x,onReview:P,onRemove:at,onSetEnabled:it,onUpdate:se},t[67]=x,t[68]=at,t[69]=it,t[70]=se,t[71]=et):et=t[71];const ye=et;let Z;t[72]!==a||t[73]!==O?(Z=O?a.find(rt=>rt.id===O)??null:null,t[72]=a,t[73]=O,t[74]=Z):Z=t[74];const Oe=Z;let Ve;t[75]!==x?(Ve=rt=>{x||F(rt)},t[75]=x,t[76]=Ve):Ve=t[76];let X;t[77]!==e?(X=e("settings.extensions.grid.addTitle"),t[77]=e,t[78]=X):X=t[78];let _e;t[79]!==X?(_e=s.jsx(Ot,{children:X}),t[79]=X,t[80]=_e):_e=t[80];let nt;t[81]!==b||t[82]!==e?(nt=b?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block",children:e("settings.extensions.add.enterpriseRule")}),s.jsx("span",{className:"mt-2 block",children:e("settings.extensions.add.info")})]}):e("settings.extensions.add.info"),t[81]=b,t[82]=e,t[83]=nt):nt=t[83];let ht;t[84]!==nt?(ht=s.jsx(Ft,{children:nt}),t[84]=nt,t[85]=ht):ht=t[85];let yt;t[86]!==_e||t[87]!==ht?(yt=s.jsxs(Rt,{children:[_e,ht]}),t[86]=_e,t[87]=ht,t[88]=yt):yt=t[88];const kt=j&&"border-primary bg-primary/5";let He;t[89]!==kt?(He=ze("relative space-y-2 rounded-lg border border-dashed border-[color-mix(in_srgb,var(--foreground)_14%,transparent)] p-3 transition-colors",kt),t[89]=kt,t[90]=He):He=t[90];let Je;t[91]!==j||t[92]!==e?(Je=j?s.jsx("span",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-lg bg-background/80 typography-ui-label text-primary",children:e("settings.extensions.add.drop.active")}):null,t[91]=j,t[92]=e,t[93]=Je):Je=t[93];let mt;t[94]===Symbol.for("react.memo_cache_sentinel")?(mt=rt=>y(rt.target.value),t[94]=mt):mt=t[94];let Qe;t[95]!==we?(Qe=rt=>{rt.key==="Enter"&&(rt.preventDefault(),we())},t[95]=we,t[96]=Qe):Qe=t[96];let _;t[97]!==e?(_=e("settings.extensions.add.placeholder"),t[97]=e,t[98]=_):_=t[98];let ge;t[99]!==e?(ge=e("settings.extensions.add.label"),t[99]=e,t[100]=ge):ge=t[100];let Ae;t[101]===Symbol.for("react.memo_cache_sentinel")?(Ae=ze("h-8 min-w-0 flex-1 rounded-md ps-3",R?"pe-14":"pe-8"),t[101]=Ae):Ae=t[101];let Te;t[102]!==x||t[103]!==h||t[104]!==Qe||t[105]!==_||t[106]!==ge?(Te=s.jsx(qe,{value:h,onChange:mt,onKeyDown:Qe,placeholder:_,"aria-label":ge,className:Ae,disabled:x}),t[102]=x,t[103]=h,t[104]=Qe,t[105]=_,t[106]=ge,t[107]=Te):Te=t[107];let Ge;t[108]!==Pe?(Ge=s.jsx("input",{ref:M,type:"file",accept:".zip,application/zip",className:"sr-only",tabIndex:-1,"aria-hidden":"true",onChange:rt=>{Pe(rt)}}),t[108]=Pe,t[109]=Ge):Ge=t[109];let ue;t[110]!==Ie||t[111]!==x||t[112]!==e?(ue=R?s.jsx(H,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",title:e("settings.extensions.add.browseFolder"),"aria-label":e("settings.extensions.add.browseFolder.aria"),disabled:x,onClick:()=>{Ie()},children:s.jsx(te,{name:"folder",className:"h-4 w-4"})}):null,t[110]=Ie,t[111]=x,t[112]=e,t[113]=ue):ue=t[113];let Fe;t[114]!==e?(Fe=e("settings.extensions.add.browseZip"),t[114]=e,t[115]=Fe):Fe=t[115];let pt;t[116]!==e?(pt=e("settings.extensions.add.browseZip.aria"),t[116]=e,t[117]=pt):pt=t[117];let At;t[118]!==Me?(At=()=>{Me()},t[118]=Me,t[119]=At):At=t[119];let Nt;t[120]===Symbol.for("react.memo_cache_sentinel")?(Nt=s.jsx(te,{name:"archive",className:"h-4 w-4"}),t[120]=Nt):Nt=t[120];let zt;t[121]!==x||t[122]!==Fe||t[123]!==pt||t[124]!==At?(zt=s.jsx(H,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",title:Fe,"aria-label":pt,disabled:x,onClick:At,children:Nt}),t[121]=x,t[122]=Fe,t[123]=pt,t[124]=At,t[125]=zt):zt=t[125];let es;t[126]!==ue||t[127]!==zt?(es=s.jsxs("div",{className:"absolute inset-e-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[ue,zt]}),t[126]=ue,t[127]=zt,t[128]=es):es=t[128];let ss;t[129]!==Te||t[130]!==Ge||t[131]!==es?(ss=s.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center",children:[Te,Ge,es]}),t[129]=Te,t[130]=Ge,t[131]=es,t[132]=ss):ss=t[132];let fs;t[133]===Symbol.for("react.memo_cache_sentinel")?(fs=rt=>p(rt.id),t[133]=fs):fs=t[133];const Gt=x||!c&&!d;let ms;t[134]!==ee||t[135]!==le||t[136]!==Gt?(ms=s.jsx("div",{className:"shrink-0",children:s.jsx(wf,{activeProfile:le,identities:ee,onSelect:fs,isApplying:Gt,iconOnly:!0})}),t[134]=ee,t[135]=le,t[136]=Gt,t[137]=ms):ms=t[137];let cs;t[138]!==ss||t[139]!==ms?(cs=s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[ss,ms]}),t[138]=ss,t[139]=ms,t[140]=cs):cs=t[140];let ps;t[141]!==e?(ps=e(R?"settings.extensions.add.drop":"settings.extensions.add.drop.zipOnly"),t[141]=e,t[142]=ps):ps=t[142];let hs;t[143]!==ps?(hs=s.jsx("p",{className:"typography-micro text-muted-foreground",children:ps}),t[143]=ps,t[144]=hs):hs=t[144];let ks;t[145]!==d||t[146]!==e?(ks=d?s.jsx("p",{className:"typography-meta text-destructive",children:e("settings.extensions.identity.loadFailed")}):null,t[145]=d,t[146]=e,t[147]=ks):ks=t[147];let ws;t[148]!==ot||t[149]!==He||t[150]!==Je||t[151]!==cs||t[152]!==hs||t[153]!==ks?(ws=s.jsxs("div",{className:He,...ot,children:[Je,cs,hs,ks]}),t[148]=ot,t[149]=He,t[150]=Je,t[151]=cs,t[152]=hs,t[153]=ks,t[154]=ws):ws=t[154];let Xs;t[155]===Symbol.for("react.memo_cache_sentinel")?(Xs=()=>F(!1),t[155]=Xs):Xs=t[155];let Dt;t[156]!==e?(Dt=e("settings.common.actions.cancel"),t[156]=e,t[157]=Dt):Dt=t[157];let hn;t[158]!==x||t[159]!==Dt?(hn=s.jsx(H,{size:"sm",variant:"ghost",disabled:x,onClick:Xs,children:Dt}),t[158]=x,t[159]=Dt,t[160]=hn):hn=t[160];let An;t[161]!==e?(An=e("settings.extensions.add.aria"),t[161]=e,t[162]=An):An=t[162];let cn;t[163]!==we?(cn=()=>{we()},t[163]=we,t[164]=cn):cn=t[164];let Tn;t[165]!==x?(Tn=x?s.jsx(te,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(te,{name:"add",className:"h-4 w-4"}),t[165]=x,t[166]=Tn):Tn=t[166];let bn;t[167]!==e?(bn=e("settings.extensions.add.action"),t[167]=e,t[168]=bn):bn=t[168];let En;t[169]!==x||t[170]!==An||t[171]!==cn||t[172]!==Tn||t[173]!==bn?(En=s.jsxs(H,{size:"sm",disabled:x,"aria-label":An,onClick:cn,children:[Tn,bn]}),t[169]=x,t[170]=An,t[171]=cn,t[172]=Tn,t[173]=bn,t[174]=En):En=t[174];let Mn;t[175]!==hn||t[176]!==En?(Mn=s.jsxs(Wt,{children:[hn,En]}),t[175]=hn,t[176]=En,t[177]=Mn):Mn=t[177];let $s;t[178]!==yt||t[179]!==ws||t[180]!==Mn?($s=s.jsxs(Et,{className:"max-w-xl",children:[yt,ws,Mn]}),t[178]=yt,t[179]=ws,t[180]=Mn,t[181]=$s):$s=t[181];let Dn;t[182]!==E||t[183]!==Ve||t[184]!==$s?(Dn=s.jsx(Tt,{open:E,onOpenChange:Ve,children:$s}),t[182]=E,t[183]=Ve,t[184]=$s,t[185]=Dn):Dn=t[185];let vs;t[186]!==vt?(vs=rt=>{vt(rt)},t[186]=vt,t[187]=vs):vs=t[187];let Gn;t[188]!==Ze?(Gn=rt=>{Ze(rt)},t[188]=Ze,t[189]=Gn):Gn=t[189];let Ua;t[190]===Symbol.for("react.memo_cache_sentinel")?(Ua=()=>P(null),t[190]=Ua):Ua=t[190];let Jn;t[191]!==k||t[192]!==x||t[193]!==vs||t[194]!==Gn?(Jn=s.jsx(wj,{guest:k,busy:x,onApprove:vs,onDecline:Gn,onDismiss:Ua}),t[191]=k,t[192]=x,t[193]=vs,t[194]=Gn,t[195]=Jn):Jn=t[195];const ui=I!==null;let Qn;t[196]!==x?(Qn=rt=>{!rt&&!x&&N(null)},t[196]=x,t[197]=Qn):Qn=t[197];let Yn;t[198]!==e?(Yn=e("settings.extensions.dialog.reinstallTitle"),t[198]=e,t[199]=Yn):Yn=t[199];let Zn;t[200]!==Yn?(Zn=s.jsx(Ot,{children:Yn}),t[200]=Yn,t[201]=Zn):Zn=t[201];const mi=I?.name??"";let ys;t[202]!==e||t[203]!==mi?(ys=e("settings.extensions.dialog.reinstallDescription",{name:mi}),t[202]=e,t[203]=mi,t[204]=ys):ys=t[204];let xn;t[205]!==ys?(xn=s.jsx(Ft,{children:ys}),t[205]=ys,t[206]=xn):xn=t[206];let Xn;t[207]!==Zn||t[208]!==xn?(Xn=s.jsxs(Rt,{children:[Zn,xn]}),t[207]=Zn,t[208]=xn,t[209]=Xn):Xn=t[209];let Sa;t[210]===Symbol.for("react.memo_cache_sentinel")?(Sa=()=>N(null),t[210]=Sa):Sa=t[210];let ea;t[211]!==e?(ea=e("settings.common.actions.cancel"),t[211]=e,t[212]=ea):ea=t[212];let ta;t[213]!==x||t[214]!==ea?(ta=s.jsx(H,{size:"sm",variant:"ghost",disabled:x,onClick:Sa,children:ea}),t[213]=x,t[214]=ea,t[215]=ta):ta=t[215];let sa;t[216]!==Ye?(sa=()=>{Ye()},t[216]=Ye,t[217]=sa):sa=t[217];let na;t[218]!==e?(na=e("settings.extensions.dialog.reinstall"),t[218]=e,t[219]=na):na=t[219];let aa;t[220]!==x||t[221]!==sa||t[222]!==na?(aa=s.jsx(H,{size:"sm",disabled:x,onClick:sa,children:na}),t[220]=x,t[221]=sa,t[222]=na,t[223]=aa):aa=t[223];let xs;t[224]!==ta||t[225]!==aa?(xs=s.jsxs(Wt,{children:[ta,aa]}),t[224]=ta,t[225]=aa,t[226]=xs):xs=t[226];let Ss;t[227]!==Xn||t[228]!==xs?(Ss=s.jsxs(Et,{className:"max-w-md",children:[Xn,xs]}),t[227]=Xn,t[228]=xs,t[229]=Ss):Ss=t[229];let dn;t[230]!==ui||t[231]!==Qn||t[232]!==Ss?(dn=s.jsx(Tt,{open:ui,onOpenChange:Qn,children:Ss}),t[230]=ui,t[231]=Qn,t[232]=Ss,t[233]=dn):dn=t[233];let qs;t[234]!==Dn||t[235]!==Jn||t[236]!==dn?(qs=s.jsxs(s.Fragment,{children:[Dn,Jn,dn]}),t[234]=Dn,t[235]=Jn,t[236]=dn,t[237]=qs):qs=t[237];const ia=qs;if(Oe){let rt;t[238]===Symbol.for("react.memo_cache_sentinel")?(rt=()=>K(null),t[238]=rt):rt=t[238];let gt;t[239]!==ye||t[240]!==Oe?(gt=s.jsx(Ej,{guest:Oe,onBack:rt,...ye}),t[239]=ye,t[240]=Oe,t[241]=gt):gt=t[241];let Jt;return t[242]!==ia||t[243]!==gt?(Jt=s.jsxs(s.Fragment,{children:[gt,ia]}),t[242]=ia,t[243]=gt,t[244]=Jt):Jt=t[244],Jt}const vn=a.length>0||n.length>0;let Na;t[245]!==e?(Na=e("settings.page.extensions.title"),t[245]=e,t[246]=Na):Na=t[246];let Ms;t[247]!==e?(Ms=e("settings.page.extensions.description"),t[247]=e,t[248]=Ms):Ms=t[248];let oa;t[249]!==x||t[250]!==oe||t[251]!==S||t[252]!==i||t[253]!==e||t[254]!==g?(oa=g?null:s.jsx(H,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0 text-muted-foreground","data-settings-item":"extensions.updates.check",disabled:x||S||i!=="ready","aria-label":e("settings.extensions.updates.check.aria"),title:e("settings.extensions.updates.check"),onClick:()=>{oe()},children:s.jsx(te,{name:"refresh",className:ze("size-4",S&&"animate-spin")})}),t[249]=x,t[250]=oe,t[251]=S,t[252]=i,t[253]=e,t[254]=g,t[255]=oa):oa=t[255];let un;t[256]!==ot||t[257]!==g?(un=g?{}:ot,t[256]=ot,t[257]=g,t[258]=un):un=t[258];let ra;t[259]!==E||t[260]!==j||t[261]!==e?(ra=j&&!E?s.jsx("span",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl border border-dashed border-primary bg-background/80 typography-ui-label text-primary",children:e("settings.extensions.add.drop.active")}):null,t[259]=E,t[260]=j,t[261]=e,t[262]=ra):ra=t[262];let mn;t[263]!==o||t[264]!==i||t[265]!==e?(mn=i==="error"||o?s.jsxs("p",{className:"mb-4 typography-meta whitespace-pre-line text-destructive",children:[e("settings.extensions.toast.loadFailed"),o?`
30
- ${wr(o,e)}`:""]}):null,t[263]=o,t[264]=i,t[265]=e,t[266]=mn):mn=t[266];let en;t[267]!==x||t[268]!==a||t[269]!==ye||t[270]!==at||t[271]!==e||t[272]!==n||t[273]!==g?(en=g?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.extensions.unsupported")}):s.jsxs("div",{className:li,children:[s.jsx(Gi,{label:e("settings.extensions.grid.addTitle"),hint:e("settings.extensions.grid.addHint"),onClick:()=>F(!0),settingsItem:"extensions.add"}),a.map(rt=>s.jsx(Aj,{guest:rt,onOpen:()=>K(rt.id),...ye},rt.id)),n.map((rt,gt)=>s.jsx(Mj,{guest:rt,busy:x,onRemove:at},rt.id??`unreadable-${gt}`))]}),t[267]=x,t[268]=a,t[269]=ye,t[270]=at,t[271]=e,t[272]=n,t[273]=g,t[274]=en):en=t[274];let yn;t[275]!==vn||t[276]!==i||t[277]!==e||t[278]!==g?(yn=i==="ready"&&!vn&&!g?s.jsx("p",{className:"pt-4 typography-meta text-muted-foreground",children:e("settings.extensions.empty")}):null,t[275]=vn,t[276]=i,t[277]=e,t[278]=g,t[279]=yn):yn=t[279];let la;t[280]!==un||t[281]!==ra||t[282]!==mn||t[283]!==en||t[284]!==yn?(la=s.jsxs("div",{className:"relative",...un,children:[ra,mn,en,yn]}),t[280]=un,t[281]=ra,t[282]=mn,t[283]=en,t[284]=yn,t[285]=la):la=t[285];let ns;t[286]!==la||t[287]!==Na||t[288]!==Ms||t[289]!==oa?(ns=s.jsx(qt,{title:Na,description:Ms,headerEnd:oa,children:la}),t[286]=la,t[287]=Na,t[288]=Ms,t[289]=oa,t[290]=ns):ns=t[290];let Ba;return t[291]!==ia||t[292]!==ns?(Ba=s.jsxs(s.Fragment,{children:[ns,ia]}),t[291]=ia,t[292]=ns,t[293]=Ba):Ba=t[293],Ba};function Rj(t){return t.guests}function Oj(t){return t.unreadable}function Fj(t){return t.status}function Lj(t){return t.failure}function Kj(t){return t.runtimeKey}function _j(){nn()}function $j(t){return t.id!=="global"}const zj={dark:.16,light:.06};function Uj(t,e,a=!1){if(a)return;const{surface:n,primary:i,status:o,interactive:r,markdown:c,chat:u,tools:d,syntax:l}=t.colors,f=t.metadata.variant==="dark",p=n.background,g=Vs(p,p),h=(C,E)=>jo(C,E,p)??1,y=(C,E,F)=>{if(F(C))return C;let O=0,K=1,D=E;for(let M=0;M<16;M++){const T=(O+K)/2,R=As(E,C,T,p);F(R)?(K=T,D=R):O=T}return D},b=C=>h(C,"#000000"),x=Math.min(4.6,h(g,p)),w=(C,E)=>{const F=E?"#ffffff":"#000000",K=(E?b(C)>b(p):b(C)<b(p))?As(C,p,1,p):p,D=y(K,p,T=>h(T,p)<=1.1),M=h(F,p)<1.04?F:y(D,F,T=>h(T,p)>=1.04);return y(M,p,T=>h(g,T)>=x)};n.muted=w(n.muted,!1),n.elevated=w(n.elevated,f),n.subtle=As(g,p,.025,p);const S=[p,n.muted,n.elevated],v=C=>Math.min(...S.map(E=>h(C,E))),A=C=>y(C,g,E=>v(E)>=4.6),I=(C,E,F=4.6)=>y(y(C,p,O=>h(O,p)<=E),g,O=>v(O)>=F);n.foreground=I(n.foreground,f?13.6:9,7),n.mutedForeground=I(n.mutedForeground,Math.min(6,h(n.foreground,p)*.7)),n.elevatedForeground=I(n.elevatedForeground,f?13.6:9,7);const N=[e["button.background"],e["textLink.foreground"],e["activityBarBadge.background"],e["list.highlightForeground"],e.focusBorder];i.base=A(N.find(C=>C!==void 0&&v(C)>=3)??i.base),i.foreground=Vs(i.base,p),i.hover=As(g,i.base,.08,p),i.active=As(g,i.base,.16,p),i.muted=Ta(i.base,.5),v(r.focusRing)<1.1&&(r.focus=i.base,r.focusRing=i.base,r.borderFocus=i.base),r.selection=y(r.selection,As(i.base,p,.18,p),C=>v(C)>=1.1);const k=f?{border:[1.217,1.245,1.117],hover:[2.304,2.356,2.115],tools:[1.199,1.207,1.156],divider:[1.41,1.442,1.294]}:{border:[1.268,1.203,1.162],hover:[1.64,1.557,1.503],tools:[1.231,1.195,1.171],divider:[1.427,1.355,1.308]},P=(C,[E,F,O])=>{const K=Math.max(E,F,O),D=z=>z+(K-z)*.2,M=z=>h(z,p)<=D(E)&&h(z,n.muted)<=D(F)&&h(z,n.elevated)<=D(O);if(M(C))return C;let T=0,R=1,$=Ta(C,0);for(let z=0;z<16;z++){const Q=(T+R)/2,V=Ta(C,Q);M(V)?(T=Q,$=V):R=Q}return $};r.border=P(r.border,k.border),r.borderHover=P(r.borderHover,k.hover),r.hover=P(r.hover,[1.18,1.18,1.18]),r.active=P(r.active,[1.25,1.25,1.25]),r.selection=P(r.selection,[1.6,1.7,1.45]),r.selectionForeground=Kn(n.foreground,r.selection,p);const j=(C,E,F,O)=>{const K=Np(C,p);return A(K!==null&&K>=F&&K<=O?C:E)};o.error=j(o.error,f?"#e07777":"#b43b45",0,35),o.warning=j(o.warning,f?"#d6b467":"#916b17",35,100),o.success=j(o.success,f?"#80b888":"#357b47",105,170),o.info=j(o.info,f?"#83afe0":"#366eaa",185,275);for(const C of["error","warning","success","info"])o[`${C}Foreground`]=Vs(o[C],p),o[`${C}Background`]=Ta(o[C],f?.16:.12),o[`${C}Border`]=Ta(o[C],f?.45:.35);if(t.colors.pr={open:o.success,closed:o.error,draft:n.mutedForeground,blocked:j(e["terminal.ansiYellow"]??"",f?"#d99464":"#a65b25",40,65),merged:j(e["terminal.ansiMagenta"]??"",f?"#b79bd9":"#8255b0",285,325)},u){let C=y(p,g,E=>h(E,p)>=1.12);h(g,C)<x&&(C=y(p,g==="#ffffff"?"#000000":"#ffffff",E=>h(E,p)>=1.12)),u.userMessageBackground=y(Ol(i.base,C,zj[f?"dark":"light"],p),C,E=>h(E,p)>=1.1&&h(g,E)>=x),S.push(u.userMessageBackground),n.foreground=y(n.foreground,g,E=>v(E)>=7),n.mutedForeground=A(n.mutedForeground),u.userMessage=Kn(n.foreground,u.userMessageBackground,p),u.assistantMessage=n.foreground,u.timestamp=n.mutedForeground,u.typing=n.mutedForeground,u.avatarForeground=e["chat.avatarForeground"]??n.foreground,u.slashCommandBackground=e["chat.slashCommandBackground"]??i.base,u.slashCommandForeground=e["chat.slashCommandForeground"]??Vs(u.slashCommandBackground,p),u.inputWorkingBorderColor1=e["chat.inputWorkingBorderColor1"]??i.base,u.inputWorkingBorderColor2=e["chat.inputWorkingBorderColor2"]??i.hover,u.inputWorkingBorderColor3=e["chat.inputWorkingBorderColor3"]??i.muted,u.divider=P(u.divider??r.border,k.divider)}t.colors.pr&&(t.colors.pr.draft=n.mutedForeground),d&&(d.border=P(d.border??r.border,k.tools),d.title=n.foreground,d.description=n.mutedForeground,d.icon=n.mutedForeground),c&&(c.bold=As(g,n.foreground,.12,p),c.italic=n.foreground,c.blockquote=n.mutedForeground,c.blockquoteBorder=P(c.blockquoteBorder??r.border,k.divider),c.hr=P(c.hr??r.border,k.divider),c.link=A(e["textLink.foreground"]??i.base),c.linkHover=A(e["textLink.activeForeground"]??i.hover),c.listMarker=Ta(i.base,.6),c.inlineCodeBackground=n.subtle,c.inlineCode=Kn(A(e["textPreformat.foreground"]??i.base),n.subtle,p)),l.base.background=y(Ol(p,l.base.background,1,p),p,C=>h(C,p)<=1.1),l.base.foreground=Kn(n.foreground,l.base.background,p)}const Bs=Ta,Bj=t=>{const e={...t,colors:{...t.colors}},a=e.kind==="dark"||e.kind==="high-contrast",n=Cp(a),i=e.colors,o=i["chat.list.background"]??i["editor.background"]??n.colors.surface.background,r=i["interactive-session.foreground"]??i.foreground??i["editor.foreground"]??Vs(o,o);i.foreground??=r,i["sideBar.background"]??=i["panel.background"]??As(r,o,.03,o),!i["editorWidget.background"]&&!i["dropdown.background"]&&!i["input.background"]&&(i["editorWidget.background"]=As(r,o,.04,o),i["editorWidget.foreground"]=Kn(r,i["editorWidget.background"],o)),i.descriptionForeground??=Kn(As(r,o,.6,o),o),i["widget.border"]??=i["input.border"]??i["panel.border"]??As(r,o,.15,o),i["toolbar.hoverBackground"]??=i["list.hoverBackground"]??As(r,o,.08,o),i["toolbar.activeBackground"]??=As(r,o,.12,o),!i["list.activeSelectionBackground"]&&!i["menu.selectionBackground"]&&!i["editor.selectionBackground"]&&(i["list.activeSelectionBackground"]=As(r,o,.16,o),i["list.activeSelectionForeground"]=Kn(r,i["list.activeSelectionBackground"],o)),i["button.background"]||(i["button.background"]=i["textLink.foreground"]??i.focusBorder??r,i["button.foreground"]=Vs(i["button.background"],o)),i.focusBorder??=i["button.background"],i["editorCursor.foreground"]??=i["editor.foreground"]??r;const c=(Ce,Me)=>e.colors[Ce]??Me,u=Ce=>Ce!=="transparent"&&(jo(Ce,"#000000")!==1||jo(Ce,"#ffffff")!==1),d=(Ce,Me)=>{const he=c(Ce,Me);return u(he)?he:Me},l=c("chat.list.background",c("editor.background",n.colors.surface.background)),f=c("interactive-session.foreground",c("foreground",c("editor.foreground",n.colors.surface.foreground))),g=[["editorWidget.background","editorWidget.foreground"],["dropdown.background","dropdown.foreground"],["input.background","input.foreground"]].find(([Ce])=>e.colors[Ce]),h=g?c(g[0],n.colors.surface.elevated):n.colors.surface.elevated,y=Kn(f,h,l),b=g?c(g[1],y):y,x=c("sideBar.background",c("panel.background",n.colors.surface.muted)),w=c("descriptionForeground",c("input.placeholderForeground",n.colors.surface.mutedForeground)),S=c("textBlockQuote.background",x),v=n.colors.surface.overlay,A=c("button.background",c("textLink.foreground",n.colors.primary.base)),I=c("button.hoverBackground",A),N=e.colors["button.background"]?c("button.foreground",Vs(A,l)):Vs(A,l),k=Bs(A,.5),j=[e.kind==="high-contrast"||e.highContrast?c("contrastBorder",""):"",c("widget.border",""),c("input.border",""),c("panel.border",""),c("sideBar.border",""),c("editorWidget.border",""),c("contrastBorder","")].find(Ce=>Ce&&u(Ce))||Bs(f,a?.25:.2),C=c("toolbar.hoverBackground",c("list.hoverBackground",n.colors.interactive.hover)),E=c("toolbar.activeBackground",C),O=[["list.activeSelectionBackground","list.activeSelectionForeground"],["menu.selectionBackground","menu.selectionForeground"],["editor.selectionBackground","editor.selectionForeground"]].filter(([Ce])=>e.colors[Ce]),K=O.find(([Ce])=>[l,x,h].every(Me=>{const he=jo(c(Ce,""),Me,l);return he===null||he>1.01}))??O[0],D=K?c(K[0],n.colors.interactive.selection):n.colors.interactive.selection,M=K?c(K[1],f):f,T=c("focusBorder",c("inputOption.activeBorder",A)),R=T,$=c("editorCursor.foreground",n.colors.interactive.cursor),z=c("editorError.foreground",c("testing.iconFailed",n.colors.status.error)),Q=d("editorError.background",Bs(z,a?.16:.12)),V=c("problemsWarningIcon.foreground",c("notificationsWarningIcon.foreground",c("editorWarning.foreground",n.colors.status.warning))),L=d("editorWarning.background",Bs(V,a?.16:.12)),B=c("testing.iconPassed",c("gitDecoration.addedResourceForeground",n.colors.status.success)),W=Bs(B,a?.16:.12),Y=c("problemsInfoIcon.foreground",c("editorInfo.foreground",n.colors.status.info)),ae=d("editorInfo.background",Bs(Y,a?.16:.12)),ee=c("editorLineNumber.foreground",w),G=c("textPreformat.foreground",c("terminal.ansiGreen",n.colors.syntax.base.string)),le=c("terminal.ansiBlue",A),J=c("terminal.ansiYellow",n.colors.syntax.base.number),me=c("terminal.ansiCyan",n.colors.syntax.base.function),fe=c("terminal.ansiMagenta",f),oe=c("terminal.ansiYellow",n.colors.syntax.base.type),pe=c("chat.requestBorder",j),se=c("diffEditor.insertedLineBackground",c("diffEditor.insertedTextBackground",W)),ve=c("diffEditor.removedLineBackground",c("diffEditor.removedTextBackground",Q)),be=c("chat.linesAddedForeground",c("gitDecoration.addedResourceForeground",B)),ne=c("chat.linesRemovedForeground",c("gitDecoration.deletedResourceForeground",z)),we=c("gitDecoration.modifiedResourceForeground",Y),Ne=c("chat.requestBubbleBackground",c("chat.requestBackground",h)),Ie={...n,metadata:{...n.metadata,id:"vscode-auto",name:"VS Code Theme",description:"Mirrors your current VS Code color theme",author:"VS Code",version:"1.0.0",variant:a?"dark":"light",tags:["vscode","auto"]},colors:{...n.colors,primary:{base:A,hover:I,active:I,foreground:N,muted:k},surface:{background:l,foreground:f,muted:x,mutedForeground:w,elevated:h,elevatedForeground:b,overlay:v,subtle:S},interactive:{border:j,borderHover:c("toolbar.hoverOutline",j),borderFocus:T,selection:D,selectionForeground:M,focus:T,focusRing:R,cursor:$,hover:C,active:E},status:{error:z,errorForeground:Vs(z,l),errorBackground:Q,errorBorder:Bs(z,a?.45:.35),warning:V,warningForeground:Vs(V,l),warningBackground:L,warningBorder:Bs(V,a?.45:.35),success:B,successForeground:Vs(B,l),successBackground:W,successBorder:Bs(B,a?.45:.35),info:Y,infoForeground:Vs(Y,l),infoBackground:ae,infoBorder:Bs(Y,a?.45:.35)},pr:n.colors.pr?{...n.colors.pr,open:B,closed:z,draft:w}:void 0,syntax:{tokens:{},highlights:{diffAdded:be,diffAddedBackground:se,diffRemoved:ne,diffRemovedBackground:ve,diffModified:we,diffModifiedBackground:Bs(we,a?.16:.12),lineNumber:c("editorLineNumber.foreground",w),lineNumberActive:c("editorLineNumber.activeForeground",f)},base:{background:c("editor.background",l),foreground:c("editor.foreground",f),comment:ee,keyword:le,string:G,number:J,function:me,variable:fe,type:oe,operator:A}},tools:{border:pe,icon:c("icon.foreground",w),title:f,description:Bs(w,.8),edit:{added:be,addedBackground:se,removed:ne,removedBackground:ve,modified:we,modifiedBackground:Bs(we,a?.16:.12),lineNumber:ee}},chat:{background:l,userMessage:f,userMessageBackground:Ne,assistantMessage:f,assistantMessageBackground:l,timestamp:w,divider:j,typing:c("chat.thinkingShimmer",w),avatarBackground:c("chat.avatarBackground",l),avatarForeground:c("chat.avatarForeground",f),slashCommandBackground:c("chat.slashCommandBackground",A),slashCommandForeground:c("chat.slashCommandForeground",N),inputWorkingBorderColor1:c("chat.inputWorkingBorderColor1",A),inputWorkingBorderColor2:c("chat.inputWorkingBorderColor2",I),inputWorkingBorderColor3:c("chat.inputWorkingBorderColor3",k)},markdown:{link:c("textLink.foreground",A),linkHover:c("textLink.activeForeground",I),inlineCode:c("textPreformat.foreground",G),inlineCodeBackground:c("textPreformat.background",c("editor.background",l)),blockquote:f,blockquoteBackground:c("textBlockQuote.background","transparent"),blockquoteBorder:c("textBlockQuote.border",j),listMarker:Bs(A,.6)}}};return Uj(Ie,t.colors,e.kind==="high-contrast"||e.highContrast===!0),Ie},_o=wt().regex(/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i),wl=as({foreground:_o.optional()}),Yu=as({scope:Kr([wt(),Ys(wt())]).optional(),settings:wl}),Vj=as({name:wt().trim().min(1).max(160).optional(),author:wt().max(160).optional(),description:wt().max(1024).optional(),type:cu(["light","dark","hc","hc-black","hc-light"]).optional(),include:wt().optional(),colors:Bn(wt(),_o.nullable()).default({}),tokenColors:Kr([Ys(Yu),wt()]).optional(),semanticHighlighting:Ji().optional(),semanticTokenColors:Bn(wt(),Kr([_o,wl])).optional()});function Hj(t){return t.flatMap(e=>(Array.isArray(e.scope)?e.scope:[e.scope??""]).flatMap(n=>n.split(",").map(i=>({scope:i.trim(),color:e.settings.foreground}))))}function qj(t,e){for(const a of e){let n,i=-1;for(const o of t)!o.color||!o.scope||(a===o.scope||a.startsWith(`${o.scope}.`))&&o.scope.length>=i&&(n=o.color,i=o.scope.length);if(n)return n}}function Wj(t,e){for(const a of e.length?[...e,"*"]:e){const n=t[a];if(n===void 0)continue;const i=_o.safeParse(n);if(i.success)return i.data;const o=wl.safeParse(n);if(o.success&&o.data.foreground)return o.data.foreground}}function Gj(t){return/^[a-z0-9]+(?:[-_][a-z0-9]+)+$/.test(t)?t.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):t}function Zu(t,e){if(new TextEncoder().encode(t).byteLength>Gd)throw new Da("size");let a;try{a=Vj.parse(JSON.parse(Zf(t.replace(/^\uFEFF/,""),{trailingCommas:!0})))}catch{throw new Da("invalid")}const n=Ys(Yu).safeParse(a.tokenColors??[]);if(a.include||!n.success)throw new Da("include");const i={};for(const[N,k]of Object.entries(a.colors))k!==null&&(i[N]=k);const o=i["editor.background"];if(!o)throw new Da("background");const r=a.type?["dark","hc","hc-black"].includes(a.type):Vs(o,"#ffffff")==="#ffffff",c=r?"dark":"light",u=As(o,r?"#000000":"#ffffff",1),d=Hj(n.data),l=n.data.filter(N=>!N.scope&&N.settings.foreground).at(-1)?.settings.foreground,f=i["editor.foreground"]??l??i.foreground??Vs(u,u);i["editor.background"]=u,i["editor.foreground"]=f;const p=a.type?.startsWith("hc")??!1;p&&i.contrastBorder&&(i["widget.border"]=i.contrastBorder);const h=Bj({kind:r&&p?"high-contrast":c,colors:i,highContrast:p}),y=a.semanticHighlighting===!1?{}:a.semanticTokenColors??{},b=(N,k,P)=>Wj(y,N)??qj(d,k)??P,x=h.colors.syntax.base.foreground,w={background:h.colors.syntax.base.background,foreground:h.colors.syntax.base.foreground,comment:b(["comment"],["comment","comment.line","comment.block"],Kn(As(f,u,.6,u),u)),keyword:b(["keyword"],["keyword","storage","keyword.control","storage.type"],x),string:b(["string"],["string","string.quoted","string.template"],x),number:b(["number"],["constant.numeric"],x),function:b(["function"],["entity.name.function","support.function"],x),variable:b(["variable"],["variable.other.readwrite","variable"],x),type:b(["type"],["entity.name.type","support.type","support.class"],x),operator:b(["operator"],["keyword.operator"],x)},S=b(["class"],["entity.name.type.class","entity.name.class"],w.type),v=b(["property"],["variable.other.property","support.type.property-name"],w.variable),A={base:w,tokens:{className:S,interface:b(["interface"],["entity.name.type.interface"],w.type),enum:b(["enum"],["entity.name.type.enum"],S),method:b(["method"],["entity.name.function.method"],w.function),variableProperty:v,parameter:b(["parameter"],["variable.parameter"],w.variable),constant:b(["variable.readonly","*.readonly","enumMember"],["variable.other.constant","constant.other"],w.number),boolean:b([],["constant.language.boolean","constant.language"],w.number),punctuation:b([],["punctuation","punctuation.separator"],w.operator),stringEscape:b([],["constant.character.escape"],w.string),commentDoc:b([],["comment.block.documentation","comment.documentation"],w.comment),keywordImport:b([],["keyword.control.import","keyword.import"],w.keyword),tag:b([],["entity.name.tag"],w.keyword),tagAttribute:b([],["entity.other.attribute-name"],v)},highlights:h.colors.syntax.highlights},I=Gj(a.name??(e.replace(/\.(jsonc?|code-theme)$/i,"").replace(/[-_]color[-_]theme$/i,"").trim().slice(0,160)||"VS Code"));return Ip({metadata:{id:`vscode-import-${c}`,name:I,variant:c,author:a.author,description:a.description??"",version:"1.0.0",tags:["imported","vscode"]},colors:{...h.colors,syntax:A}})}const Jj=as({namespace:wt(),name:wt(),version:wt(),label:wt(),icon:wt().url().refine(t=>{const e=new URL(t);return e.protocol==="https:"&&["open-vsx.org","openvsx.eclipsecontent.org"].includes(e.hostname)}).nullable()});async function Qj(t,e){const a=await $t("/api/config/themes/catalog/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t}),signal:e});if(!a.ok)throw new Error("catalog");return as({items:Ys(Jj).max(24)}).parse(await a.json()).items}async function Yj(t,e){const a=await $t("/api/config/themes/catalog/package",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:e});if(!a.ok)throw new Error("catalog");const{items:n}=as({items:Ys(as({path:wt(),name:wt(),text:wt(),error:Ji()})).max(40)}).parse(await a.json());return n.map((i,o)=>{const r=`${o}:${i.path}`;try{if(i.error)throw new Error("invalid");const c=Zu(i.text,i.path);return c.metadata.name=i.name,c.metadata.author=t.namespace,{status:"ready",key:r,name:i.name,definition:c,theme:Pp(c)}}catch{return{status:"invalid",key:r,name:i.name}}})}function Zj(t){const e=De.c(3),{extension:a}=t,[n,i]=m.useState(!1);let o;return e[0]!==a.icon||e[1]!==n?(o=a.icon&&!n?s.jsx("img",{src:a.icon,alt:"",referrerPolicy:"no-referrer",loading:"lazy",className:"size-9 shrink-0 rounded object-contain",onError:()=>i(!0)}):s.jsx(te,{name:"palette",className:"size-9 shrink-0 text-muted-foreground"}),e[0]=a.icon,e[1]=n,e[2]=o):o=e[2],o}function Xj(t){const e=De.c(93),{pickFile:a,fileBusy:n,onClose:i}=t,{t:o}=Ee(),r=re(sk),{isMobile:c}=Zs(),u=r||c,{importTheme:d}=za(),[l,f]=m.useState("");let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={step:"search",status:"idle",results:[]},e[0]=p):p=e[0];const[g,h]=m.useState(p);let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=new Set,e[1]=y):y=e[1];const[b,x]=m.useState(y);let w;e[2]===Symbol.for("react.memo_cache_sentinel")?(w=new Set,e[2]=w):w=e[2];const[S,v]=m.useState(w),[A,I]=m.useState(!1),[N,k]=m.useState(null),P=m.useRef(null);let j,C;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const W=new AbortController;P.current=W;const Y=Go(()=>W.abort());return()=>{Y(),W.abort()}},C=[],e[3]=j,e[4]=C):(j=e[3],C=e[4]),m.useEffect(j,C);let E,F;e[5]!==l||e[6]!==g.step?(E=()=>{if(g.step!=="search")return;const W=new AbortController,Y=l.trim(),ae=setTimeout(async()=>{if(!Y){h({step:"search",status:"idle",results:[]});return}h({step:"search",status:"loading",results:[]});try{const ee=await Qj(Y,W.signal);W.signal.aborted||h({step:"search",status:"ready",results:ee})}catch{W.signal.aborted||h({step:"search",status:"error",results:[]})}},350);return()=>{clearTimeout(ae),W.abort()}},F=[l,g.step],e[5]=l,e[6]=g.step,e[7]=E,e[8]=F):(E=e[7],F=e[8]),m.useEffect(E,F);let O,K;if(e[9]!==n||e[10]!==d||e[11]!==u||e[12]!==a||e[13]!==l||e[14]!==N||e[15]!==S||e[16]!==A||e[17]!==b||e[18]!==g.extension||e[19]!==g.results||e[20]!==g.status||e[21]!==g.step||e[22]!==g.variants||e[23]!==o){const W=async se=>{const ve=P.current?.signal;if(ve){h({step:"package",status:"loading",extension:se}),v(new Set),k(null),x(new Set);try{const be=await Yj(se,ve);ve.aborted||h({step:"variants",extension:se,variants:be})}catch{ve.aborted||h({step:"package",status:"error",extension:se})}}};let Y;e[26]!==d||e[27]!==S||e[28]!==A||e[29]!==b||e[30]!==g.step||e[31]!==g.variants||e[32]!==o?(Y=async()=>{if(g.step!=="variants"||A)return;const se=P.current?.signal;if(!se)return;I(!0),k(null);let ve=!1;for(const be of g.variants){if(se.aborted)break;if(!(be.status!=="ready"||!b.has(be.key)||S.has(be.key)))try{if(await d(be.definition,{activate:!1}),se.aborted)break;v(ne=>new Set(ne).add(be.key)),x(ne=>{const we=new Set(ne);return we.delete(be.key),we})}catch{ve=!0}}se.aborted||(I(!1),k(ve?"partial":null),ve?Ya.error(o("settings.themeImport.partialError")):Ya.success(o("settings.themeImport.complete")))},e[26]=d,e[27]=S,e[28]=A,e[29]=b,e[30]=g.step,e[31]=g.variants,e[32]=o,e[33]=Y):Y=e[33];const ae=Y;let ee,G;e[34]!==S||e[35]!==b||e[36]!==g.step||e[37]!==g.variants?(ee=g.step==="variants"?g.variants.filter(se=>se.status==="ready"&&!S.has(se.key)):[],G=ee.length>0&&ee.every(se=>b.has(se.key)),e[34]=S,e[35]=b,e[36]=g.step,e[37]=g.variants,e[38]=ee,e[39]=G):(ee=e[38],G=e[39]);const le=G;let J;e[40]!==n||e[41]!==ae||e[42]!==A||e[43]!==b||e[44]!==g.step||e[45]!==o?(J=g.step==="variants"&&s.jsx(H,{disabled:!b.size||A||n,onClick:()=>{ae()},children:o(A?"settings.themeImport.busy":"settings.themeImport.importSelected")}),e[40]=n,e[41]=ae,e[42]=A,e[43]=b,e[44]=g.step,e[45]=o,e[46]=J):J=e[46];const me=A||n;let fe;e[47]!==o?(fe=o("settings.themeImport.chooseFile"),e[47]=o,e[48]=fe):fe=e[48];let oe;e[49]!==a||e[50]!==me||e[51]!==fe?(oe=s.jsx(H,{variant:"outline",className:"self-start",disabled:me,onClick:a,children:fe}),e[49]=a,e[50]=me,e[51]=fe,e[52]=oe):oe=e[52];let pe;e[53]!==J||e[54]!==oe?(pe=s.jsxs(s.Fragment,{children:[J,oe]}),e[53]=J,e[54]=oe,e[55]=pe):pe=e[55],O=pe,K=s.jsx(s.Fragment,{children:g.step==="search"?s.jsxs(s.Fragment,{children:[s.jsx(qe,{autoFocus:!0,"aria-label":o("settings.themeImport.search"),placeholder:o("settings.themeImport.search"),value:l,maxLength:160,onChange:se=>f(se.target.value)}),s.jsxs("div",{className:u?"space-y-1":"max-h-[45dvh] overflow-y-auto space-y-1","aria-live":"polite",children:[g.status==="loading"&&s.jsx("p",{className:"text-muted-foreground",children:o("common.loading")}),g.status==="error"&&s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:o("settings.themeImport.catalogError")}),g.status==="ready"&&!g.results.length&&s.jsx("p",{className:"text-muted-foreground",children:o("settings.themeImport.empty")}),g.results.map(se=>s.jsxs(H,{variant:"ghost",className:"h-auto w-full justify-start py-2 text-start",onClick:()=>{W(se)},children:[s.jsx(Zj,{extension:se}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate",children:se.label}),s.jsx("span",{className:"block truncate typography-meta text-muted-foreground",children:se.namespace})]})]},`${se.namespace}.${se.name}`))]})]}):s.jsxs(s.Fragment,{children:[s.jsxs(H,{variant:"ghost",size:"sm",className:"justify-start",disabled:A||g.step==="package"&&g.status==="loading",onClick:()=>h({step:"search",status:"idle",results:[]}),children:[s.jsx(te,{name:"arrow-left",className:"size-4"}),o("settings.themeImport.back")]}),s.jsx("p",{className:"typography-ui-label",children:g.extension.label}),N==="partial"&&s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:o("settings.themeImport.partialError")}),g.step==="package"?g.status==="loading"?s.jsx("p",{role:"status",children:o("common.loading")}):s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:o("settings.themeImport.catalogError")}):s.jsxs(s.Fragment,{children:[g.variants.length>1&&s.jsx(H,{variant:"ghost",size:"sm",className:"self-start",disabled:A||n||!ee.length,onClick:()=>x(le?new Set:new Set(ee.map(tk))),children:o(le?"settings.themeImport.deselectAll":"settings.themeImport.selectAll")}),s.jsx("div",{className:u?"space-y-2":"max-h-[45dvh] overflow-y-auto space-y-2",children:g.variants.map(se=>s.jsxs("div",{className:"flex items-center gap-3",children:[se.status==="ready"&&s.jsxs("div",{"aria-hidden":"true",className:"flex w-20 shrink-0 items-center gap-2 rounded px-2 py-3",style:{backgroundColor:se.theme.colors.surface.background,color:se.theme.colors.surface.foreground},children:[s.jsx("span",{children:"Aa"}),s.jsx("span",{className:"space-y-1",children:[se.theme.colors.syntax.base.keyword,se.theme.colors.syntax.base.string,se.theme.colors.syntax.base.function].map(ek)})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[S.has(se.key)?s.jsxs("div",{className:"flex items-center gap-2 py-1",children:[s.jsx(te,{name:"check",className:"size-4 shrink-0 text-[var(--status-success-text)]"}),s.jsx("span",{className:"typography-ui-label",children:se.name})]}):s.jsx(ct,{checked:b.has(se.key),disabled:se.status!=="ready"||A||n,label:se.name,onChange:ve=>x(be=>{const ne=new Set(be);return ve?ne.add(se.key):ne.delete(se.key),ne})}),s.jsx("p",{className:S.has(se.key)?"typography-meta font-medium text-[var(--status-success-text)]":"typography-meta text-muted-foreground",children:se.status!=="ready"?o("settings.themeImport.error.invalid"):S.has(se.key)?o("settings.themeImport.installed"):o(se.theme.metadata.variant==="dark"?"settings.openchamber.visual.option.themeMode.dark":"settings.openchamber.visual.option.themeMode.light")})]})]},se.key))})]})]})}),e[9]=n,e[10]=d,e[11]=u,e[12]=a,e[13]=l,e[14]=N,e[15]=S,e[16]=A,e[17]=b,e[18]=g.extension,e[19]=g.results,e[20]=g.status,e[21]=g.step,e[22]=g.variants,e[23]=o,e[24]=O,e[25]=K}else O=e[24],K=e[25];const D=K;if(u){let W;e[56]!==o?(W=o("settings.themeImport.catalogTitle"),e[56]=o,e[57]=W):W=e[57];let Y;e[58]!==O?(Y=s.jsx("div",{className:"flex flex-col gap-2",children:O}),e[58]=O,e[59]=Y):Y=e[59];let ae;e[60]!==o?(ae=o("settings.themeImport.catalogHint"),e[60]=o,e[61]=ae):ae=e[61];let ee;e[62]!==ae?(ee=s.jsx("p",{className:"typography-meta text-muted-foreground",children:ae}),e[62]=ae,e[63]=ee):ee=e[63];let G;e[64]!==D||e[65]!==ee?(G=s.jsxs("div",{className:"flex flex-col gap-4 px-1",children:[ee,D]}),e[64]=D,e[65]=ee,e[66]=G):G=e[66];let le;return e[67]!==i||e[68]!==Y||e[69]!==G||e[70]!==W?(le=s.jsx(dl,{open:!0,title:W,onClose:i,footer:Y,children:G}),e[67]=i,e[68]=Y,e[69]=G,e[70]=W,e[71]=le):le=e[71],le}let M;e[72]!==i?(M=W=>{W||i()},e[72]=i,e[73]=M):M=e[73];let T;e[74]===Symbol.for("react.memo_cache_sentinel")?(T={forceRender:!0},e[74]=T):T=e[74];let R;e[75]!==o?(R=o("settings.themeImport.catalogTitle"),e[75]=o,e[76]=R):R=e[76];let $;e[77]!==R?($=s.jsx(Ot,{children:R}),e[77]=R,e[78]=$):$=e[78];let z;e[79]!==o?(z=o("settings.themeImport.catalogHint"),e[79]=o,e[80]=z):z=e[80];let Q;e[81]!==z?(Q=s.jsx(Ft,{children:z}),e[81]=z,e[82]=Q):Q=e[82];let V;e[83]!==$||e[84]!==Q?(V=s.jsxs(Rt,{children:[$,Q]}),e[83]=$,e[84]=Q,e[85]=V):V=e[85];let L;e[86]!==O||e[87]!==D||e[88]!==V?(L=s.jsxs(Et,{className:"max-w-lg",backdropProps:T,children:[V,D,O]}),e[86]=O,e[87]=D,e[88]=V,e[89]=L):L=e[89];let B;return e[90]!==L||e[91]!==M?(B=s.jsx(Tt,{open:!0,onOpenChange:M,children:L}),e[90]=L,e[91]=M,e[92]=B):B=e[92],B}function ek(t,e){return s.jsx("span",{className:"block h-1 w-5 rounded",style:{backgroundColor:t}},e)}function tk(t){return t.key}function sk(t){return t.isMobile}function nk(){const{t}=Ee(),{importTheme:e,customThemesLoading:a}=za(),n=oi(),[i,o]=m.useState(!1),r=m.useCallback(()=>o(!1),[]),c=m.useRef(null),u=m.useRef(0),d=m.useRef(null),[l,f]=m.useState(!1);m.useEffect(()=>Go(()=>{u.current+=1,o(!1)}),[]);const p=async(y,b)=>{f(!0);try{if(y.size>Gd)throw new Da("size");const x=await y.text();if(b.key!==Zt()||b.generation!==u.current)throw new Da("connection");const w=await e(Zu(x,y.name));Ya.success(t("settings.themeImport.success",{name:w.metadata.name})),o(!1)}catch(x){const w=x instanceof Da?x.code:"invalid";Ya.error(t(`settings.themeImport.error.${w}`))}finally{f(!1)}},g=async()=>{if(l)return;const y={key:Zt(),generation:u.current};if(d.current=y,!n.themeFiles){c.current?.click();return}f(!0);try{const b=await n.themeFiles.pick();if(b?.status==="picked"){if(b.file){const x=b.file;await p({name:x.name,size:x.size,text:async()=>x.text},y)}return}c.current?.click()}catch{Ya.error(t("settings.themeImport.error.invalid"))}finally{f(!1)}},h=async y=>{const b=y.target.files?.[0];y.target.value="",b&&!l&&d.current&&await p(b,d.current)};return s.jsxs("div",{className:"flex items-center gap-2","data-settings-item":"appearance.import-theme",children:[s.jsxs(H,{variant:"outline",size:"sm",disabled:l||a,onClick:()=>o(!0),children:[s.jsx(te,{name:l?"loader":"add",className:l?"size-3.5 animate-spin":"size-3.5"}),t(l?"settings.themeImport.busy":"settings.themeImport.action")]}),s.jsx(ts,{children:t("settings.themeImport.catalogHint")}),s.jsx("input",{ref:c,type:"file",accept:".json,.jsonc",className:"hidden","aria-label":t("settings.themeImport.action"),onChange:h}),i&&s.jsx(Xj,{pickFile:()=>{g()},fileBusy:l,onClose:r})]})}const id=(t,e,a)=>{const n=t?.querySelector("[cmdk-list]"),i=t?.querySelector(`[cmdk-item][data-value="${CSS.escape(e)}"]`);if(!n||!i)return;const o=n.getBoundingClientRect(),r=n.offsetHeight>0?o.height/n.offsetHeight:1;if(r<=0)return;const c=i.getBoundingClientRect(),u=(c.top-o.top)/r+n.scrollTop,d=c.height/r;a?.onlyIfHidden&&u>=n.scrollTop&&u+d<=n.scrollTop+n.clientHeight||(n.scrollTop=Math.max(0,u-(n.clientHeight-d)/2))};function od({options:t,value:e,onValueChange:a,placeholder:n,ariaLabel:i}){const{t:o}=Ee(),{deleteImportedTheme:r,customThemeIds:c}=za(),{isMobile:u}=Zs(),[d,l]=m.useState(!1),[f,p]=m.useState(""),[g,h]=m.useState(void 0),[y,b]=m.useState(null),x=m.useRef(null),w=m.useRef(null),S=Ap(d,w),[v,A]=m.useState(null),[I,N]=m.useState(null),k=m.useCallback(M=>{const T=M instanceof HTMLElement?M:null,R=T?.closest('[data-slot="dialog-content"], [role="dialog"]');A(R instanceof HTMLElement?R:null),N(T?.closest("main")??null)},[]);m.useEffect(()=>{if(d)return Tp.suspend()},[d]);const P=m.useRef(e);P.current=e;const j=m.useCallback(M=>{M&&id(M,P.current)},[]),C=t.find(M=>M.id===e),E=m.useMemo(()=>d?wa(t,f,M=>[M.label]):t,[d,t,f]),F=M=>{a(M),l(!1)},O=async M=>{if(!y){b(M.id);try{await r(M.id),x.current?.focus()}catch{Ya.error(o("settings.themeImport.deleteError"))}finally{b(null)}}},K=M=>{if(!c.includes(M.id))return null;const T=y===M.id;return s.jsx(H,{variant:"ghost",size:"icon",className:"size-6 shrink-0",disabled:T,"aria-label":o("settings.themeImport.delete",{name:M.label}),onPointerDown:R=>R.stopPropagation(),onClick:R=>{R.stopPropagation(),O(M)},children:s.jsx(te,{name:T?"loader":"delete-bin",className:T?"size-4 animate-spin":"size-4"})})},D=s.jsx("div",{role:"status",className:"px-3 py-6 text-center typography-ui-label text-muted-foreground",children:o("settings.openchamber.visual.field.noThemesFound")});return u?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button","aria-label":i,"aria-haspopup":"dialog",className:ze(an,!C&&"text-muted-foreground"),onClick:()=>{p(""),l(!0)},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:C?.label??n}),s.jsx(te,{name:"arrow-down-s",className:"size-4 opacity-50"})]}),s.jsx(dl,{open:d,title:i,onClose:()=>l(!1),children:s.jsxs("div",{className:"flex flex-col gap-2 px-3 pb-4 pt-1",children:[s.jsx(qe,{value:f,onChange:M=>p(M.target.value),placeholder:o("settings.openchamber.visual.field.searchThemes"),"aria-label":o("settings.openchamber.visual.field.searchThemes"),className:"h-9"}),s.jsx("div",{className:"flex flex-col",role:"listbox","aria-label":i,children:E.length===0?D:E.map(M=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{type:"button",role:"option","aria-selected":M.id===e,className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-lg px-2 py-2.5 text-start typography-ui-label hover:bg-[var(--interactive-hover)]",onClick:()=>F(M.id),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:M.label}),M.id===e?s.jsx(te,{name:"check",className:"size-4 shrink-0 text-muted-foreground"}):null]}),K(M)]},M.id))})]})})]}):s.jsxs(Xf,{open:d,onOpenChange:M=>{p(""),h(M?e:void 0),l(M)},onOpenChangeComplete:M=>{if(!M){w.current?.focus();return}x.current?.focus(),id(x.current?.closest('[data-slot="command"]'),e,{onlyIfHidden:!0})},children:[s.jsxs(eh,{ref:w,"aria-label":i,"aria-haspopup":"dialog",className:ze(an,!C&&"text-muted-foreground"),onPointerDownCapture:M=>k(M.currentTarget),onFocusCapture:M=>k(M.currentTarget),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:C?.label??n}),s.jsx(te,{name:"arrow-down-s",className:"size-4 opacity-50"})]}),s.jsx(th,{container:v??void 0,children:s.jsx(sh,{side:S,align:"start",sideOffset:4,collisionAvoidance:{side:"none"},collisionBoundary:I??void 0,className:"z-[120]",children:s.jsx(nh,{role:"dialog","aria-label":i,className:ze(Kp,"flex w-[var(--anchor-width)] min-w-[16rem] max-w-[calc(100vw-2rem)] flex-col p-0"),initialFocus:!1,finalFocus:!1,children:s.jsxs(Ep,{ref:j,className:ze("min-h-0 flex-1",S==="top"&&Lp),shouldFilter:!1,value:g,onValueChange:h,children:[s.jsx(Mp,{ref:x,"aria-label":o("settings.openchamber.visual.field.searchThemes"),placeholder:o("settings.openchamber.visual.field.searchThemes"),value:f,onValueChange:p,onKeyDown:M=>{if(Dp(M)){M.stopPropagation();return}Rp(M,T=>{M.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:T,bubbles:!0,cancelable:!0}))})}}),s.jsx(Op,{label:i,className:"max-h-[20rem] p-1",children:E.length===0?D:E.map(M=>s.jsxs(Fp,{value:M.id,onSelect:F,"aria-current":M.id===e?!0:void 0,className:"max-w-full typography-ui-label",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:M.label}),M.id===e?s.jsx(te,{name:"check",className:"size-4 shrink-0 text-muted-foreground"}):null,K(M)]},M.id))})]})})})})]})}const ak=[{value:"system",labelKey:"settings.openchamber.visual.option.themeMode.system",descriptionKey:"settings.openchamber.visual.option.themeMode.system.description"},{value:"light",labelKey:"settings.openchamber.visual.option.themeMode.light",descriptionKey:"settings.openchamber.visual.option.themeMode.light.description"},{value:"dark",labelKey:"settings.openchamber.visual.option.themeMode.dark",descriptionKey:"settings.openchamber.visual.option.themeMode.dark.description"}],ki="OpenChamber - AI Coding Assistant",rd=[{id:"system",labelKey:"settings.openchamber.visual.option.pwaOrientation.system.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.system.description"},{id:"portrait",labelKey:"settings.openchamber.visual.option.pwaOrientation.portrait.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.portrait.description"},{id:"landscape",labelKey:"settings.openchamber.visual.option.pwaOrientation.landscape.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.landscape.description"}],ld=[{id:"native",labelKey:"settings.openchamber.visual.option.mobileKeyboardMode.native.label",descriptionKey:"settings.openchamber.visual.option.mobileKeyboardMode.native.description"},{id:"resize-content",labelKey:"settings.openchamber.visual.option.mobileKeyboardMode.resizeContent.label",descriptionKey:"settings.openchamber.visual.option.mobileKeyboardMode.resizeContent.description"}],Sr=t=>t==="portrait"||t==="landscape"?t:"system",cd=[{id:"auto",labelKey:"settings.openchamber.visual.option.timeFormat.auto.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.auto.description"},{id:"24h",labelKey:"settings.openchamber.visual.option.timeFormat.24h.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.24h.description"},{id:"12h",labelKey:"settings.openchamber.visual.option.timeFormat.12h.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.12h.description"}],dd=[{id:"auto",labelKey:"settings.openchamber.visual.option.weekStart.auto.label",descriptionKey:"settings.openchamber.visual.option.weekStart.auto.description"},{id:"monday",labelKey:"settings.openchamber.visual.option.weekStart.monday.label"},{id:"sunday",labelKey:"settings.openchamber.visual.option.weekStart.sunday.label"}],ik=[{id:"left",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsLeft"},{id:"right",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsRight"}],ok=[{id:"classic",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsClassic"},{id:"traffic-lights",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsTrafficLights"}],rk=({visibleSettings:t})=>{const{locale:e,locales:a,setLocale:n,label:i,t:o}=Ee(),r=m.useCallback(X=>o(X),[o]),{isMobile:c}=Zs(),{browserTab:u}=Sf(),d=To(X=>X.animatedActivityIndicators),l=To(X=>X.setAnimatedActivityIndicators),f=re(X=>X.fontSize),p=re(X=>X.setFontSize),g=re(X=>X.terminalFontSize),h=re(X=>X.setTerminalFontSize),y=re(X=>X.editorFontSize),b=re(X=>X.setEditorFontSize),{uiFont:x,monoFont:w}=_p(),S=re(X=>X.setUiFont),v=re(X=>X.setMonoFont),A=re(X=>X.customUiFont),I=re(X=>X.customMonoFont),N=re(X=>X.setCustomUiFont),k=re(X=>X.setCustomMonoFont),P=Pn(),j=re(X=>X.padding),C=re(X=>X.setPadding),E=re(X=>X.inputBarOffset),F=re(X=>X.setInputBarOffset),O=re(X=>X.mobileKeyboardMode),K=re(X=>X.setMobileKeyboardMode),D=re(X=>X.timeFormatPreference),M=re(X=>X.setTimeFormatPreference),T=re(X=>X.weekStartPreference),R=re(X=>X.setWeekStartPreference),{themeMode:$,setThemeMode:z,availableThemes:Q,customThemesLoading:V,reloadCustomThemes:L,lightThemeId:B,darkThemeId:W,setLightThemePreference:Y,setDarkThemePreference:ae}=za(),[ee,G]=m.useState(!1),le=m.useMemo(()=>is()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",[]),J=re(X=>X.dockBadgeEnabled),me=re(X=>X.setDockBadgeEnabled),fe=re(X=>X.alwaysShowScrollbars===!0),oe=re(X=>X.setAlwaysShowScrollbars),pe=Rg(),se=re(X=>X.desktopWindowControlsPosition),ve=re(X=>X.setDesktopWindowControlsPosition),be=re(X=>X.desktopWindowControlsStyle),ne=re(X=>X.setDesktopWindowControlsStyle),we=m.useCallback(X=>{const _e=a.find(nt=>nt===X);_e&&(n(_e),jt({locale:_e}))},[a,n]),Ne=m.useCallback(X=>{ve(X),jt({desktopWindowControlsPosition:X})},[ve]),Ie=m.useCallback(X=>{ne(X),jt({desktopWindowControlsStyle:X})},[ne]),Ce=m.useCallback(X=>{M(X),jt({timeFormatPreference:X})},[M]),Me=m.useCallback(X=>{R(X),jt({weekStartPreference:X})},[R]),he=m.useMemo(()=>Q.filter(X=>X.metadata.variant==="light").sort((X,_e)=>X.metadata.name.localeCompare(_e.metadata.name)),[Q]),Pe=m.useMemo(()=>Q.filter(X=>X.metadata.variant==="dark").sort((X,_e)=>X.metadata.name.localeCompare(_e.metadata.name)),[Q]),Re=m.useMemo(()=>he.find(X=>X.metadata.id===B)??he[0],[he,B]),ce=m.useMemo(()=>Pe.find(X=>X.metadata.id===W)??Pe[0],[Pe,W]),je=m.useCallback((X,_e)=>{const nt=_e==="dark"?" Dark":" Light";return X.endsWith(nt)?X.slice(0,-nt.length):X},[]),de=m.useMemo(()=>he.map(X=>({id:X.metadata.id,label:je(X.metadata.name,"light")})),[he,je]),ie=m.useMemo(()=>Pe.map(X=>({id:X.metadata.id,label:je(X.metadata.name,"dark")})),[Pe,je]),xe=X=>t?t.includes(X):!0,Se=os(),Le=xe("theme")&&!Se,Ue=xe("windowControlsPosition")&&pe,Ye=xe("theme")||xe("timeFormat")||xe("weekStart"),lt=Se?Ye:xe("theme")||Ue||xe("pwaInstallName")||xe("pwaOrientation")||xe("timeFormat")||xe("weekStart"),at=xe("fontSize")||xe("terminalFontSize")||xe("editorFontSize")||xe("spacing")||xe("scrollbars")&&!Le||xe("inputBarOffset")&&c,ut=xe("pwaInstallName")&&Di()&&u&&!is()&&!Se,vt=xe("pwaOrientation")&&Di()&&!is()&&!Se,We=xe("mobileKeyboardMode")&&Di()&&!is()&&!Se&&Og(),[Ze,Xe]=m.useState(""),[it,dt]=m.useState("system"),Be=m.useMemo(()=>{const X=cd.find(_e=>_e.id===D);return r(X?.labelKey??"settings.openchamber.visual.option.timeFormat.auto.label")},[D,r]),ot=m.useMemo(()=>{const X=dd.find(_e=>_e.id===T);return r(X?.labelKey??"settings.openchamber.visual.option.weekStart.auto.label")},[T,r]),et=m.useMemo(()=>{const X=rd.find(_e=>_e.id===it);return X?r(X.labelKey):void 0},[it,r]),ye=m.useMemo(()=>{const X=ld.find(_e=>_e.id===O);return X?r(X.labelKey):void 0},[O,r]),Z=m.useCallback(async X=>{if(typeof window>"u")return;const _e=window,ht=X.trim().replace(/\s+/g," ").slice(0,64);if(await jt({pwaAppName:ht}),typeof _e.__OPENCHAMBER_SET_PWA_INSTALL_NAME__=="function"){const yt=_e.__OPENCHAMBER_SET_PWA_INSTALL_NAME__(ht);Xe(yt);return}Xe(ht||ki),_e.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]),Oe=m.useCallback(async X=>{if(typeof window>"u")return;const _e=window,nt=Sr(X);if(await jt({pwaOrientation:nt}),typeof _e.__OPENCHAMBER_SET_PWA_ORIENTATION__=="function"){const ht=_e.__OPENCHAMBER_SET_PWA_ORIENTATION__(nt);dt(ht);return}dt(nt),_e.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]);m.useEffect(()=>{if(typeof window>"u"||!ut&&!vt&&!We)return;let X=!1;return(async()=>{try{const nt=await fn();if(!nt){X||Xe(ki);return}const yt=(nt.pwaAppName??"").trim().replace(/\s+/g," ").slice(0,64),kt=Sr(nt.pwaOrientation),He=Jl(nt.mobileKeyboardMode);X||(ut&&Xe(yt||ki),vt&&dt(kt),We&&K(He))}catch{X||(ut&&Xe(ki),vt&&dt("system"),We&&K("native"))}})(),()=>{X=!0}},[K,We,ut,vt]);const Ve=xe("scrollbars")?s.jsx(ct,{checked:fe,onChange:oe,label:o("settings.openchamber.visual.field.alwaysShowScrollbars"),info:o("settings.openchamber.visual.field.alwaysShowScrollbarsHint"),settingsItem:"appearance.scrollbars"}):null;return s.jsxs("div",{className:"space-y-0",children:[lt&&s.jsxs("div",{className:"space-y-0",children:[Le&&s.jsxs($e,{title:o("settings.openchamber.visual.section.colorModeAndTheme"),divider:!1,children:[s.jsxs(ma,{children:[s.jsx("div",{className:Ts,children:s.jsx(Vo,{"aria-label":o("settings.openchamber.visual.section.colorMode"),children:ak.map(X=>s.jsx(wn,{selected:$===X.value,onSelect:()=>z(X.value),label:r(X.labelKey),ariaLabel:r(X.labelKey)},X.value))})}),s.jsxs("div",{className:Ts,children:[s.jsx(St,{label:o("settings.openchamber.visual.field.lightTheme"),settingsItem:"appearance.light-theme",children:s.jsx(od,{options:de,value:Re?.metadata.id??"",onValueChange:Y,placeholder:o("settings.openchamber.visual.field.selectThemePlaceholder"),ariaLabel:o("settings.openchamber.visual.field.selectLightThemeAria")})}),s.jsx(St,{label:o("settings.openchamber.visual.field.darkTheme"),settingsItem:"appearance.dark-theme",children:s.jsx(od,{options:ie,value:ce?.metadata.id??"",onValueChange:ae,placeholder:o("settings.openchamber.visual.field.selectThemePlaceholder"),ariaLabel:o("settings.openchamber.visual.field.selectDarkThemeAria")})}),s.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[s.jsxs("button",{type:"button",disabled:V||ee,onClick:()=>{const X=Date.now();G(!0),L().finally(()=>{const _e=Date.now()-X;if(_e<500){window.setTimeout(()=>{G(!1)},500-_e);return}G(!1)})},className:"typography-settings-link inline-flex items-center gap-1.5 disabled:cursor-not-allowed disabled:opacity-50 disabled:no-underline",children:[s.jsx(te,{name:"restart",className:ze("h-3.5 w-3.5",ee&&"animate-spin")}),o(ee?"settings.openchamber.visual.actions.reloadingThemes":"settings.openchamber.visual.actions.reloadThemes")]}),s.jsx(ts,{children:o("settings.openchamber.visual.field.themeImportInfoTooltip")})]}),s.jsx(nk,{})]})]}),le&&s.jsx(_i,{settingsItem:"appearance.dock-badge",children:s.jsx(ct,{checked:J,onChange:me,label:o("settings.openchamber.visual.field.dockBadge"),info:o("settings.openchamber.visual.field.dockBadgeHint"),ariaLabel:o("settings.openchamber.visual.field.dockBadge")})}),Ve&&s.jsx(_i,{children:Ve})]}),Ue&&s.jsx($e,{title:o("settings.openchamber.desktopNetwork.field.windowControls"),info:o("settings.openchamber.desktopNetwork.field.windowControlsPositionDescription"),divider:Le,children:s.jsxs(ma,{children:[s.jsx(St,{label:o("settings.openchamber.desktopNetwork.field.windowControlsPosition"),settingsItem:"sessions.desktop-window-controls-position",children:s.jsx(Xt,{value:se,options:ik.map(X=>({value:X.id,label:r(X.labelKey)})),onChange:Ne,"aria-label":o("settings.openchamber.desktopNetwork.field.windowControlsPositionAria")})}),s.jsx(St,{label:o("settings.openchamber.desktopNetwork.field.windowControlsStyle"),settingsItem:"sessions.desktop-window-controls-style",children:s.jsx(Xt,{value:be,options:ok.map(X=>({value:X.id,label:r(X.labelKey)})),onChange:Ie,"aria-label":o("settings.openchamber.desktopNetwork.field.windowControlsStyleAria")})})]})}),Ye&&s.jsx($e,{title:o("settings.openchamber.visual.section.localization"),children:s.jsxs(ma,{children:[s.jsx(St,{label:o("settings.appearance.language.label"),info:o("settings.appearance.language.description"),settingsItem:"appearance.language",children:s.jsxs(Pt,{value:e,onValueChange:we,children:[s.jsx(Ct,{"aria-label":o("settings.appearance.language.select"),className:fi,children:s.jsx(Kt,{children:i(e)})}),s.jsx(It,{children:a.map(X=>s.jsx(bt,{value:X,children:i(X)},X))})]})}),(xe("timeFormat")||xe("weekStart"))&&s.jsxs("div",{className:Ts,children:[xe("timeFormat")&&s.jsx(St,{label:o("settings.openchamber.visual.field.timeFormat"),settingsItem:"appearance.time-format",children:s.jsxs(Pt,{value:D,onValueChange:X=>Ce(X),children:[s.jsx(Ct,{"aria-label":o("settings.openchamber.visual.field.selectTimeFormatAria"),className:fi,children:s.jsx(Kt,{children:Be})}),s.jsx(It,{children:cd.map(X=>s.jsx(bt,{value:X.id,children:r(X.labelKey)},X.id))})]})}),xe("weekStart")&&s.jsx(St,{label:o("settings.openchamber.visual.field.weekStartsOn"),settingsItem:"appearance.week-start",children:s.jsxs(Pt,{value:T,onValueChange:X=>Me(X),children:[s.jsx(Ct,{"aria-label":o("settings.openchamber.visual.field.selectWeekStartAria"),className:fi,children:s.jsx(Kt,{children:ot})}),s.jsx(It,{children:dd.map(X=>s.jsx(bt,{value:X.id,children:r(X.labelKey)},X.id))})]})})]})]})}),(ut||vt||We)&&s.jsxs($e,{title:o("settings.openchamber.visual.section.appInstall"),contentClassName:Ts,children:[ut&&s.jsxs(st,{label:o("settings.openchamber.visual.field.installAppName"),info:o("settings.openchamber.visual.field.installAppNameHint"),settingsItem:"appearance.pwa-install-name",alignEnd:!1,controlClassName:rn,children:[s.jsx(qe,{value:Ze,onChange:X=>{Xe(X.target.value)},onBlur:()=>{Z(Ze)},onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),Z(Ze))},className:"min-w-0 flex-1",maxLength:64,"aria-label":o("settings.openchamber.visual.field.pwaInstallAppNameAria")}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{Xe(ki),Z("")},className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetInstallAppNameAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]}),vt&&s.jsxs(st,{label:o("settings.openchamber.visual.field.installOrientation"),description:o("settings.openchamber.visual.field.installOrientationHint"),settingsItem:"appearance.pwa-orientation",alignEnd:!1,controlClassName:rn,children:[s.jsxs(Pt,{value:it,onValueChange:X=>{const _e=Sr(X);dt(_e),Oe(_e)},children:[s.jsx(Ct,{"aria-label":o("settings.openchamber.visual.field.pwaInstallOrientationAria"),className:Fl,children:s.jsx(Kt,{placeholder:o("settings.openchamber.visual.field.selectOrientationPlaceholder"),children:et})}),s.jsx(It,{children:rd.map(X=>s.jsx(bt,{value:X.id,children:r(X.labelKey)},X.id))})]}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{dt("system"),Oe("system")},disabled:it==="system",className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetInstallOrientationAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]}),We&&s.jsxs(st,{label:o("settings.openchamber.visual.field.mobileKeyboardMode"),info:o("settings.openchamber.visual.field.mobileKeyboardModeHint"),settingsItem:"appearance.mobile-keyboard-mode",alignEnd:!1,controlClassName:rn,children:[s.jsxs(Pt,{value:O,onValueChange:X=>{const _e=Jl(X);K(_e),jt({mobileKeyboardMode:_e})},children:[s.jsx(Ct,{"aria-label":o("settings.openchamber.visual.field.mobileKeyboardModeAria"),className:Fl,children:s.jsx(Kt,{placeholder:o("settings.openchamber.visual.field.selectMobileKeyboardModePlaceholder"),children:ye})}),s.jsx(It,{children:ld.map(X=>s.jsx(bt,{value:X.id,children:r(X.labelKey)},X.id))})]}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{K("native"),jt({mobileKeyboardMode:"native"})},disabled:O==="native",className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetMobileKeyboardModeAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})]})]}),at&&s.jsxs($e,{title:o("settings.openchamber.visual.section.densityAndType"),contentClassName:Ts,children:[xe("fontSize")&&!c||xe("terminalFontSize")?s.jsxs(ma,{children:[xe("fontSize")&&!c&&s.jsxs(St,{label:o("settings.openchamber.visual.field.interfaceFont"),settingsItem:"appearance.interface-font-size",controlClassName:"w-full flex-wrap",children:[s.jsxs(Pt,{value:x,onValueChange:X=>S(X),children:[s.jsx(Ct,{"aria-label":o("settings.openchamber.visual.field.selectInterfaceFontAria"),className:fi,children:s.jsx(Kt,{children:x===Ha?o("settings.openchamber.visual.field.customFont"):Hl.find(X=>X.id===x)?.label})}),s.jsxs(It,{children:[Hl.map(X=>s.jsx(bt,{value:X.id,disabled:P&&!!X.source,children:s.jsx("span",{style:{fontFamily:X.stack},children:X.label})},X.id)),s.jsx(bt,{value:Ha,children:o("settings.openchamber.visual.field.customFont")})]})]}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>S(ql),disabled:x===ql,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetInterfaceFontAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})}),x===Ha?s.jsx(qe,{value:A,onChange:X=>N(X.target.value),placeholder:o("settings.openchamber.visual.field.customFontPlaceholder"),"aria-label":o("settings.openchamber.visual.field.customFontAria"),spellCheck:!1,autoComplete:"off",className:"h-8 basis-full rounded-md px-3"}):null]}),xe("terminalFontSize")&&s.jsxs(St,{label:o("settings.openchamber.visual.field.codeFont"),controlClassName:"w-full flex-wrap",children:[s.jsxs(Pt,{value:w,onValueChange:X=>v(X),children:[s.jsx(Ct,{"aria-label":o("settings.openchamber.visual.field.selectCodeFontAria"),className:fi,children:s.jsx(Kt,{children:w===Ha?o("settings.openchamber.visual.field.customFont"):Wl.find(X=>X.id===w)?.label})}),s.jsxs(It,{children:[Wl.map(X=>s.jsx(bt,{value:X.id,disabled:P&&!!X.source,children:s.jsx("span",{style:{fontFamily:X.stack},children:X.label})},X.id)),s.jsx(bt,{value:Ha,children:o("settings.openchamber.visual.field.customFont")})]})]}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>v(Gl),disabled:w===Gl,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetCodeFontAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})}),w===Ha?s.jsx(qe,{value:I,onChange:X=>k(X.target.value),placeholder:o("settings.openchamber.visual.field.customFontPlaceholder"),"aria-label":o("settings.openchamber.visual.field.customFontAria"),spellCheck:!1,autoComplete:"off",className:"h-8 basis-full rounded-md px-3"}):null]})]}):null,P&&(xe("fontSize")&&!c||xe("terminalFontSize"))?s.jsx("p",{className:_t,children:o("settings.openchamber.visual.field.webFontsEnterprise")}):null,xe("fontSize")&&!c||xe("terminalFontSize")||xe("editorFontSize")?s.jsxs(ma,{children:[xe("fontSize")&&!c&&s.jsx(St,{label:o("settings.openchamber.visual.field.interfaceFontSize"),controlClassName:"w-full",children:s.jsxs("div",{className:Fn,children:[s.jsx(ds,{value:f,onValueChange:p,min:50,max:200,step:5,className:us,"aria-label":o("settings.openchamber.visual.field.fontSizePercentageAria")}),s.jsx("span",{className:ga,children:"%"}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>p(100),disabled:f===100,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetFontSizeAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})}),xe("terminalFontSize")&&s.jsx(St,{label:o("settings.openchamber.visual.field.terminalFontSize"),settingsItem:"appearance.terminal-font-size",controlClassName:"w-full",children:s.jsxs("div",{className:Fn,children:[s.jsx(ds,{value:g,onValueChange:h,min:9,max:52,step:1,className:us}),s.jsx("span",{className:ga,children:"px"}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>h(13),disabled:g===13,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetTerminalFontSizeAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})}),xe("editorFontSize")&&s.jsx(St,{label:o("settings.openchamber.visual.field.editorFontSize"),settingsItem:"appearance.editor-font-size",controlClassName:"w-full",children:s.jsxs("div",{className:Fn,children:[s.jsx(ds,{value:y,onValueChange:b,min:9,max:32,step:1,className:us}),s.jsx("span",{className:ga,children:"px"}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>b(13),disabled:y===13,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetEditorFontSizeAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})})]}):null,xe("spacing")||xe("inputBarOffset")&&c?s.jsxs(ma,{children:[xe("spacing")&&s.jsx(St,{label:o("settings.openchamber.visual.field.spacingDensity"),settingsItem:"appearance.spacing-density",controlClassName:"w-full",children:s.jsxs("div",{className:Fn,children:[s.jsx(ds,{value:j,onValueChange:C,min:50,max:200,step:5,className:us}),s.jsx("span",{className:ga,children:"%"}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>C(100),disabled:j===100,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetSpacingAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})}),xe("inputBarOffset")&&c&&s.jsx(St,{label:o("settings.openchamber.visual.field.inputBarOffset"),info:o("settings.openchamber.visual.field.inputBarOffsetTooltip"),settingsItem:"appearance.input-bar-offset",controlClassName:"w-full",children:s.jsxs("div",{className:Fn,children:[s.jsx(ds,{value:E,onValueChange:F,min:0,max:100,step:5,className:us}),s.jsx("span",{className:ga,children:"px"}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>F(0),disabled:E===0,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetInputBarOffsetAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})})]}):null,!Le&&Ve]}),xe("animatedActivityIndicators")&&s.jsx($e,{title:o("settings.openchamber.visual.section.sessionActivity"),settingsItem:"appearance.session-activity",contentClassName:bs,children:s.jsx(ct,{checked:d,onChange:l,label:o("settings.openchamber.visual.field.animatedActivityIndicators"),ariaLabel:o("settings.openchamber.visual.field.animatedActivityIndicatorsAria"),info:o("settings.openchamber.visual.field.animatedActivityIndicatorsInfo"),settingsItem:"appearance.animated-activity-indicators"})})]})},lk=1,ck=365,ud=30,dk=[{value:"archive",labelKey:"settings.openchamber.sessionRetention.action.archive"},{value:"delete",labelKey:"settings.openchamber.sessionRetention.action.delete"}],uk=()=>{const t=De.c(122),{t:e}=Ee(),a=re(mk),n=re(pk),i=re(gk),o=re(fk),r=re(hk),c=re(bk),u=re(xk);let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d={autoRun:!1},t[0]=d):d=t[0];const{candidates:l,isRunning:f,runCleanup:p,action:g,status:h}=$p(d),y=l.length;let b;t[1]!==p||t[2]!==e?(b=async()=>{const Pe=await p({force:!0}).catch(()=>(q.error(e("sessions.sidebar.group.empty.loadFailed")),null));if(!(!Pe||Pe.skippedReason&&Pe.skippedReason!=="no-candidates")){if(Pe.completedIds.length===0&&Pe.failedIds.length===0){q.message(Pe.action==="archive"?e("settings.openchamber.sessionRetention.toast.noneEligibleArchive"):e("settings.openchamber.sessionRetention.toast.noneEligibleDelete"));return}Pe.completedIds.length>0&&q.success(Pe.action==="archive"?e("settings.openchamber.sessionRetention.toast.archivedCount",{count:Pe.completedIds.length}):e("settings.openchamber.sessionRetention.toast.deletedCount",{count:Pe.completedIds.length})),Pe.failedIds.length>0&&q.error(Pe.action==="archive"?e("settings.openchamber.sessionRetention.toast.failedArchiveCount",{count:Pe.failedIds.length}):e("settings.openchamber.sessionRetention.toast.failedDeleteCount",{count:Pe.failedIds.length}))}},t[1]=p,t[2]=e,t[3]=b):b=t[3];const x=b;let w;t[4]!==g||t[5]!==y||t[6]!==h||t[7]!==e?(w=h==="error"?e("sessions.sidebar.group.empty.loadFailed"):h!=="ready"?e("sessions.sidebar.group.empty.loadingSessions"):g==="archive"?e("settings.openchamber.sessionRetention.manualCleanup.eligibleArchiveNow",{count:y}):e("settings.openchamber.sessionRetention.manualCleanup.eligibleDeleteNow",{count:y}),t[4]=g,t[5]=y,t[6]=h,t[7]=e,t[8]=w):w=t[8];const S=w;let v;t[9]!==e?(v=e("settings.openchamber.sessionRetention.title"),t[9]=e,t[10]=v):v=t[10];const A=i?"settings.openchamber.sessionRetention.archivedTooltip":"settings.openchamber.sessionRetention.tooltip";let I;t[11]!==e||t[12]!==A?(I=e(A),t[11]=e,t[12]=A,t[13]=I):I=t[13];let N;t[14]!==e?(N=e("settings.openchamber.sessionRetention.field.enableAutoCleanup"),t[14]=e,t[15]=N):N=t[15];let k;t[16]!==e?(k=e("settings.openchamber.sessionRetention.field.enableAutoCleanupAria"),t[16]=e,t[17]=k):k=t[17];let P;t[18]!==a||t[19]!==o||t[20]!==N||t[21]!==k?(P=s.jsx(ct,{settingsItem:"sessions.auto-cleanup",checked:a,onChange:o,label:N,ariaLabel:k}),t[18]=a,t[19]=o,t[20]=N,t[21]=k,t[22]=P):P=t[22];let j;t[23]!==e?(j=e("settings.layout.sessions.retention.target"),t[23]=e,t[24]=j):j=t[24];let C;t[25]!==e?(C=e("settings.openchamber.sessionRetention.field.onlyArchivedDescription"),t[25]=e,t[26]=C):C=t[26];const E=i?"archived":"unarchived";let F;t[27]!==u?(F=Pe=>u(Pe==="archived"),t[27]=u,t[28]=F):F=t[28];let O;t[29]!==e?(O=e("settings.layout.sessions.retention.target"),t[29]=e,t[30]=O):O=t[30];let K;t[31]!==e?(K=e("settings.layout.sessions.retention.target.unarchived"),t[31]=e,t[32]=K):K=t[32];let D;t[33]!==f||t[34]!==K?(D={value:"unarchived",label:K,disabled:f},t[33]=f,t[34]=K,t[35]=D):D=t[35];let M;t[36]!==e?(M=e("settings.layout.sessions.retention.target.archived"),t[36]=e,t[37]=M):M=t[37];let T;t[38]!==f||t[39]!==M?(T={value:"archived",label:M,disabled:f},t[38]=f,t[39]=M,t[40]=T):T=t[40];let R;t[41]!==D||t[42]!==T?(R=[D,T],t[41]=D,t[42]=T,t[43]=R):R=t[43];let $;t[44]!==E||t[45]!==F||t[46]!==O||t[47]!==R?($=s.jsx(Xt,{value:E,onChange:F,"aria-label":O,options:R}),t[44]=E,t[45]=F,t[46]=O,t[47]=R,t[48]=$):$=t[48];let z;t[49]!==C||t[50]!==$||t[51]!==j?(z=s.jsx(st,{settingsItem:"sessions.retention-only-archived",label:j,info:C,children:$}),t[49]=C,t[50]=$,t[51]=j,t[52]=z):z=t[52];let Q;t[53]!==e?(Q=e("settings.openchamber.sessionRetention.field.retentionPeriod"),t[53]=e,t[54]=Q):Q=t[54];let V;t[55]!==e?(V=e("settings.openchamber.sessionRetention.field.retentionPeriodAria"),t[55]=e,t[56]=V):V=t[56];let L;t[57]===Symbol.for("react.memo_cache_sentinel")?(L=ze(us,"tabular-nums"),t[57]=L):L=t[57];let B;t[58]!==n||t[59]!==r||t[60]!==V?(B=s.jsx(ds,{value:n,onValueChange:r,min:lk,max:ck,step:1,"aria-label":V,className:L}),t[58]=n,t[59]=r,t[60]=V,t[61]=B):B=t[61];let W;t[62]!==e?(W=e("settings.openchamber.sessionRetention.field.days"),t[62]=e,t[63]=W):W=t[63];let Y;t[64]!==W?(Y=s.jsx("span",{className:ga,children:W}),t[64]=W,t[65]=Y):Y=t[65];let ae;t[66]!==r?(ae=()=>r(ud),t[66]=r,t[67]=ae):ae=t[67];const ee=n===ud;let G;t[68]!==e?(G=e("settings.openchamber.sessionRetention.actions.resetRetentionAria"),t[68]=e,t[69]=G):G=t[69];let le;t[70]!==e?(le=e("settings.common.actions.reset"),t[70]=e,t[71]=le):le=t[71];let J;t[72]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"}),t[72]=J):J=t[72];let me;t[73]!==ae||t[74]!==ee||t[75]!==G||t[76]!==le?(me=s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:ae,disabled:ee,className:Yt,"aria-label":G,title:le,children:J}),t[73]=ae,t[74]=ee,t[75]=G,t[76]=le,t[77]=me):me=t[77];let fe;t[78]!==B||t[79]!==Y||t[80]!==me?(fe=s.jsxs("div",{className:Fn,children:[B,Y,me]}),t[78]=B,t[79]=Y,t[80]=me,t[81]=fe):fe=t[81];let oe;t[82]!==Q||t[83]!==fe?(oe=s.jsx(st,{settingsItem:"sessions.retention-period",label:Q,children:fe}),t[82]=Q,t[83]=fe,t[84]=oe):oe=t[84];let pe;t[85]!==e?(pe=e("settings.openchamber.sessionRetention.field.whenSessionsExpire"),t[85]=e,t[86]=pe):pe=t[86];let se;t[87]!==i||t[88]!==e?(se=dk.map(Pe=>({value:Pe.value,label:e(Pe.labelKey),disabled:i&&Pe.value==="archive"})),t[87]=i,t[88]=e,t[89]=se):se=t[89];let ve;t[90]!==g||t[91]!==c||t[92]!==se?(ve=s.jsx(Xt,{value:g,onChange:c,options:se}),t[90]=g,t[91]=c,t[92]=se,t[93]=ve):ve=t[93];let be;t[94]!==pe||t[95]!==ve?(be=s.jsx(st,{settingsItem:"sessions.retention-action",label:pe,children:ve}),t[94]=pe,t[95]=ve,t[96]=be):be=t[96];let ne;t[97]!==e?(ne=e("settings.openchamber.sessionRetention.manualCleanup.title"),t[97]=e,t[98]=ne):ne=t[98];let we;t[99]!==f||t[100]!==e?(we=e(f?"settings.openchamber.sessionRetention.actions.cleaningUp":"settings.openchamber.sessionRetention.actions.runCleanupNow"),t[99]=f,t[100]=e,t[101]=we):we=t[101];let Ne;t[102]!==x||t[103]!==f||t[104]!==we?(Ne=s.jsx(H,{type:"button",variant:"outline",size:"sm",onClick:x,disabled:f,className:"!font-normal",children:we}),t[102]=x,t[103]=f,t[104]=we,t[105]=Ne):Ne=t[105];let Ie;t[106]!==S?(Ie=s.jsx("span",{className:"typography-meta truncate text-muted-foreground","aria-live":"polite",title:S,children:S}),t[106]=S,t[107]=Ie):Ie=t[107];let Ce;t[108]!==ne||t[109]!==Ne||t[110]!==Ie?(Ce=s.jsxs(st,{label:ne,children:[Ne,Ie]}),t[108]=ne,t[109]=Ne,t[110]=Ie,t[111]=Ce):Ce=t[111];let Me;t[112]!==z||t[113]!==oe||t[114]!==be||t[115]!==Ce?(Me=s.jsxs("div",{children:[z,oe,be,Ce]}),t[112]=z,t[113]=oe,t[114]=be,t[115]=Ce,t[116]=Me):Me=t[116];let he;return t[117]!==v||t[118]!==Me||t[119]!==I||t[120]!==P?(he=s.jsxs($e,{title:v,info:I,contentClassName:"space-y-2",children:[P,Me]}),t[117]=v,t[118]=Me,t[119]=I,t[120]=P,t[121]=he):he=t[121],he};function mk(t){return t.autoDeleteEnabled}function pk(t){return t.autoDeleteAfterDays}function gk(t){return t.sessionRetentionOnlyArchived}function fk(t){return t.setAutoDeleteEnabled}function hk(t){return t.setAutoDeleteAfterDays}function bk(t){return t.setSessionRetentionAction}function xk(t){return t.setSessionRetentionOnlyArchived}const vk=()=>{const t=De.c(17),{t:e}=Ee(),a=re(yk),n=re(jk);let i;t[0]!==e?(i=e("settings.openchamber.mergedWorktreeCleanup.title"),t[0]=e,t[1]=i):i=t[1];let o;t[2]!==e?(o=e("settings.openchamber.mergedWorktreeCleanup.info"),t[2]=e,t[3]=o):o=t[3];let r;t[4]!==e?(r=e("settings.openchamber.mergedWorktreeCleanup.field.enable"),t[4]=e,t[5]=r):r=t[5];let c;t[6]!==e?(c=e("settings.openchamber.mergedWorktreeCleanup.field.enableDescription"),t[6]=e,t[7]=c):c=t[7];let u;t[8]!==a||t[9]!==n||t[10]!==r||t[11]!==c?(u=s.jsx(ct,{settingsItem:"sessions.merged-worktree-cleanup",checked:a,onChange:n,label:r,description:c}),t[8]=a,t[9]=n,t[10]=r,t[11]=c,t[12]=u):u=t[12];let d;return t[13]!==i||t[14]!==o||t[15]!==u?(d=s.jsx($e,{settingsItem:"sessions.merged-worktree-cleanup-section",title:i,info:o,children:u}),t[13]=i,t[14]=o,t[15]=u,t[16]=d):d=t[16],d};function yk(t){return t.mergedWorktreeCleanupEnabled}function jk(t){return t.setMergedWorktreeCleanupEnabled}const kk=()=>{const t=De.c(22),{t:e}=Ee(),a=re(wk),n=re(Sk),i=To(Nk),o=To(Ck);let r;t[0]!==e?(r=e("settings.layout.sessions.sidebar.title"),t[0]=e,t[1]=r):r=t[1];let c;t[2]!==o||t[3]!==i||t[4]!==e?(c=os()?null:s.jsx(ct,{settingsItem:"sessions.show-chats",checked:i,onChange:g=>{o(g),jt({sidebarShowChatsSection:g})},label:e("settings.openchamber.defaults.field.showChats"),ariaLabel:e("settings.openchamber.defaults.field.showChats")}),t[2]=o,t[3]=i,t[4]=e,t[5]=c):c=t[5];let u;t[6]!==e?(u=e("settings.openchamber.sessionWork.field.enabled"),t[6]=e,t[7]=u):u=t[7];let d;t[8]!==e?(d=e("settings.openchamber.sessionWork.field.enabled"),t[8]=e,t[9]=d):d=t[9];let l;t[10]!==e?(l=e("settings.openchamber.sessionWork.info"),t[10]=e,t[11]=l):l=t[11];let f;t[12]!==a||t[13]!==n||t[14]!==u||t[15]!==d||t[16]!==l?(f=s.jsx(ct,{settingsItem:"sessions.work-enabled",checked:a,onChange:n,label:u,ariaLabel:d,info:l}),t[12]=a,t[13]=n,t[14]=u,t[15]=d,t[16]=l,t[17]=f):f=t[17];let p;return t[18]!==r||t[19]!==c||t[20]!==f?(p=s.jsxs($e,{title:r,settingsItem:"sessions.work",contentClassName:bs,children:[c,f]}),t[18]=r,t[19]=c,t[20]=f,t[21]=p):p=t[21],p};function wk(t){return t.sessionWorkEnabled}function Sk(t){return t.setSessionWorkEnabled}function Nk(t){return t.showChatsSection}function Ck(t){return t.setShowChatsSection}const md=(t,e,a)=>!t||!Number.isFinite(t)?e:new Intl.DateTimeFormat(Bo(),{dateStyle:"medium",timeStyle:"short",hour12:a==="auto"?void 0:a==="12h"}).format(t),Ik=()=>{const{t}=Ee(),e=re(T=>T.timeFormatPreference),[a,n]=m.useState(!1),[i,o]=m.useState(!0),[r,c]=m.useState(!1),[u,d]=m.useState(null),[l,f]=m.useState(!1),[p,g]=m.useState(null),[h,y]=m.useState(""),[b,x]=m.useState(!1),w=m.useRef(!1),S=m.useRef(!1),[v,A]=m.useState([]),[I,N]=m.useState(zp),[k,P]=m.useState(""),j=m.useMemo(()=>Up(),[]),C=m.useCallback(async()=>{o(!0),P("");try{const T=await Bp();A(T)}catch(T){const R=T instanceof Error?T.message:t("settings.openchamber.passkeys.toast.loadFailed");P(R)}finally{o(!1)}},[t]);m.useEffect(()=>{let T=!1;return(async()=>{try{if(!j.supported){T||(n(!1),o(!1));return}T||n(!0)}catch{T||n(!1)}if(!T){const R=await ar();if(N(R),!R.enabled){A([]),o(!1);return}await C()}})(),()=>{T=!0,Ll()}},[C,j.supported]);const E=m.useCallback(async()=>{if(!I.enabled){const T=t("settings.openchamber.passkeys.toast.enableUiPasswordFirst");P(T),q.message(T);return}if(!a){P(j.reason),q.message(j.reason);return}if(r){Ll(),c(!1);return}P(""),c(!0);try{await Vp(),N(await ar()),await C(),q.success(t("settings.openchamber.passkeys.toast.added"))}catch(T){if(Hp(T)){q.message(t("settings.openchamber.passkeys.toast.setupCanceled"));return}const R=T instanceof Error?T.message:t("settings.openchamber.passkeys.toast.addFailed");P(R),q.error(R)}finally{c(!1)}},[r,C,I.enabled,j.reason,a,t]),F=m.useCallback(async T=>{d(T),P("");try{await qp(T),N(await ar()),await C(),q.success(t("settings.openchamber.passkeys.toast.removed"))}catch(R){const $=R instanceof Error?R.message:t("settings.openchamber.passkeys.toast.removeFailed");P($),q.error($)}finally{d(null)}},[C,t]),O=m.useCallback(T=>{w.current=!1,y(T.customLabel??""),g(T.id)},[]),K=m.useCallback(()=>{w.current=!0,y(""),g(null)},[]),D=m.useCallback(async T=>{if(w.current){w.current=!1;return}if(!S.current){if(h.trim()===(T.customLabel??"")){g(R=>R===T.id?null:R);return}S.current=!0,x(!0),P("");try{const R=await Wp(T.id,h);R?A($=>$.map(z=>z.id===T.id?R:z)):await C(),g($=>$===T.id?null:$),q.success(t("settings.openchamber.passkeys.toast.renamed"))}catch(R){const $=R instanceof Error?R.message:t("settings.openchamber.passkeys.toast.renameFailed");P($),q.error($)}finally{S.current=!1,x(!1)}}},[C,h,t]),M=m.useCallback(async()=>{f(!0),P("");try{await Gp(),window.location.reload()}catch(T){const R=T instanceof Error?T.message:t("settings.openchamber.passkeys.toast.clearAuthFailed");P(R),q.error(R),f(!1)}},[t]);return s.jsxs($e,{title:t("settings.openchamber.passkeys.title"),children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(st,{label:t("settings.openchamber.passkeys.field.currentDevice"),children:[s.jsx(H,{type:"button",variant:r?"secondary":"outline",size:"xs",onClick:()=>{E()},disabled:i||l,className:"!font-normal",children:t(r?"settings.openchamber.passkeys.actions.cancelSetup":"settings.openchamber.passkeys.actions.add")}),s.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:()=>{M()},disabled:i||r||l,className:"!font-normal text-muted-foreground hover:text-foreground",children:t(l?"settings.openchamber.passkeys.actions.signingOut":"settings.openchamber.passkeys.actions.signOutEverywhere")})]}),!I.enabled&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.uiPasswordRequired")}),I.enabled&&!a&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:j.reason}),i?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.loading")}):v.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.noneSaved")}):s.jsx("div",{className:"space-y-1 pt-1",children:v.map(T=>{const R=p===T.id;return s.jsxs(st,{label:R?s.jsx(qe,{value:h,placeholder:T.label,inputSize:"compact",autoFocus:!0,maxLength:120,disabled:b,"aria-label":t("settings.openchamber.passkeys.actions.rename"),onChange:$=>y($.target.value),onBlur:()=>{D(T)},onKeyDown:$=>{$.key==="Enter"?($.preventDefault(),$.currentTarget.blur()):$.key==="Escape"&&($.preventDefault(),K())}}):s.jsx("span",{title:T.label,children:T.label}),alignEnd:!1,controlClassName:"justify-between sm:flex-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:T.lastUsedAt?t("settings.openchamber.passkeys.item.lastUsed",{time:md(T.lastUsedAt,t("settings.openchamber.passkeys.time.neverUsed"),e)}):t("settings.openchamber.passkeys.item.added",{time:md(T.createdAt,t("settings.openchamber.passkeys.time.neverUsed"),e)})}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[!R&&s.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:()=>O(T),disabled:b,"aria-label":t("settings.openchamber.passkeys.actions.rename"),title:t("settings.openchamber.passkeys.actions.rename"),className:"!font-normal text-muted-foreground hover:text-foreground",children:s.jsx(te,{name:"pencil",className:"h-3.5 w-3.5"})}),s.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:()=>{F(T.id)},disabled:u===T.id,className:"!font-normal text-muted-foreground hover:text-foreground",children:u===T.id?t("settings.openchamber.passkeys.actions.removing"):t("settings.common.actions.delete")})]})]},T.id)})})]}),k&&s.jsx("div",{className:"mt-1 py-1.5",children:s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:k})})]})},Pk=()=>{const t=De.c(14),{t:e}=Ee(),a=Kl(Ak),n=Kl(Tk);let i;t[0]!==e?(i=e("settings.openchamber.appLinks.title"),t[0]=e,t[1]=i):i=t[1];let o;t[2]!==e?(o=e("settings.openchamber.appLinks.info"),t[2]=e,t[3]=o):o=t[3];let r;t[4]!==n||t[5]!==e||t[6]!==a?(r=a.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.appLinks.empty")}):a.map(d=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-mono text-[13px]",children:`${d}://`}),s.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:()=>n(d),className:"!font-normal text-muted-foreground hover:text-foreground","aria-label":e("settings.openchamber.appLinks.removeAria",{scheme:`${d}://`}),children:e("settings.common.actions.delete")})]},d)),t[4]=n,t[5]=e,t[6]=a,t[7]=r):r=t[7];let c;t[8]!==r?(c=s.jsx("div",{className:"space-y-1","data-settings-item":"general.app-links",children:r}),t[8]=r,t[9]=c):c=t[9];let u;return t[10]!==i||t[11]!==o||t[12]!==c?(u=s.jsx($e,{title:i,description:o,children:c}),t[10]=i,t[11]=o,t[12]=c,t[13]=u):u=t[13],u};function Ak(t){return t.trustedSchemes}function Tk(t){return t.removeTrustedScheme}const Ek=()=>{const{t}=Ee(),[e,a]=m.useState(null),n=m.useRef(0);m.useEffect(()=>{let o=!1;return Qs.getConfig(null).then(r=>{!o&&n.current===0&&a(!!r.warming)},r=>console.warn("[session-warming] failed to read config",r)),()=>{o=!0}},[]);const i=m.useCallback(async o=>{const r=e,c=++n.current;a(o),Mt("saving");try{const u=await $t("/api/config/warming",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({enabled:o})});if(!u.ok)throw new Error(`HTTP ${u.status}`);Mt("saved"),Qs.clearConfigCache()}catch(u){console.warn("[session-warming] failed to save",u),Mt("error"),c===n.current&&a(r)}},[e]);return s.jsx(ct,{settingsItem:"sessions.warming",checked:e??!1,disabled:e===null,onChange:o=>{i(o)},label:t("settings.openchamber.defaults.field.sessionWarming"),info:t("settings.openchamber.defaults.field.sessionWarmingInfo")})},Xu=30,Mk=/^(\d+(?:\.\d+)?)\s*([a-z]+)$/i,Dk=new Map([...["ms","millis","millisecond","milliseconds"].map(t=>[t,1/6e4]),...["s","second","seconds"].map(t=>[t,1/60]),...["m","minute","minutes"].map(t=>[t,1]),...["h","hour","hours"].map(t=>[t,60])]),Rk=t=>{if(!t)return null;if(t===!0||!t.duration)return Xu;const e=Mk.exec(t.duration.trim()),a=e?Dk.get(e[2].toLowerCase()):void 0;return e&&a?Math.round(Number(e[1])*a):null},Ok=()=>{const{t}=Ee(),e=hi(S=>S.status),a=hi(S=>S.enabled),n=hi(S=>S.minutes),i=hi(S=>S.setMode),o=hi(S=>S.setMinutes),[r,c]=m.useState(null),[u,d]=m.useState(null),[l,f]=m.useState(null),p=m.useRef(0);m.useEffect(()=>{let S=!1;return Qs.getConfig(null).then(v=>{!S&&p.current===0&&c({on:!!v.warming,minutes:Rk(v.warming)})},v=>console.warn("[session-warming] failed to read config",v)),()=>{S=!0}},[]);const g=u??(r===null||e==="loading"?null:r.on?"all":a?"session":"off"),h=l??(g==="all"?r?.minutes??null:n),y=m.useCallback(async(S,v)=>{const A=++p.current;Mt("saving");try{await S(),Mt("saved")}catch(I){console.warn("[session-warming] failed to save",I),Mt("error")}finally{v(A===p.current)}},[]),b=S=>{d(S),y(async()=>{await i(S),Qs.clearConfigCache(),c(v=>({on:S==="all",minutes:v?.minutes??Xu}))},v=>{v&&d(null)})},x=S=>{if(g!=="all"&&g!=="session")return;const v=g;f(S),y(async()=>{await o(v,S),v==="all"&&(Qs.clearConfigCache(),c({on:!0,minutes:S}))},A=>{A&&f(null)})},w=g===null||g==="off"||e==="unavailable";return s.jsxs(s.Fragment,{children:[s.jsx(st,{settingsItem:"sessions.warming",label:t("settings.openchamber.defaults.field.sessionWarming"),info:t("settings.openchamber.defaults.sessionWarming.info"),children:s.jsx(Xt,{"aria-label":t("settings.openchamber.defaults.sessionWarming.aria"),value:g??"off",onChange:S=>{g!==null&&S!==g&&b(S)},options:[{value:"off",label:t("settings.openchamber.defaults.sessionWarming.off"),disabled:g===null},{value:"all",label:t("settings.openchamber.defaults.sessionWarming.all"),disabled:g===null},{value:"session",label:t("settings.openchamber.defaults.sessionWarming.session"),disabled:g===null||e==="unavailable"}]})}),s.jsx(st,{settingsItem:"sessions.warming-duration",label:t("settings.openchamber.defaults.sessionWarming.duration"),children:s.jsx(Xt,{"aria-label":t("settings.openchamber.defaults.sessionWarming.durationAria"),value:h===null?"":String(h),onChange:S=>{const v=Number(S);v!==h&&x(v)},options:Jp.map(S=>({value:String(S),label:t(`settings.openchamber.defaults.sessionWarming.duration.${S}`),disabled:w}))})})]})},Fk={ask:{icon:"shield-user",color:void 0},safety:{icon:"shield-star",color:"var(--status-success)"},auto:{icon:"shield-check",color:"var(--status-info)"}},Lk=t=>{const e=De.c(42),{agentName:a}=t,{t:n}=Ee(),i=re(Kk),o=re(_k),r=Bt(ul),c=Yo(Bt($k));let u;e[0]!==i||e[1]!==r?(u=Qp(i,r),e[0]=i,e[1]=r,e[2]=u):u=e[2];const d=u;let l;e[3]!==o?(l=C=>{o(C),jt({permissionDefaultMode:C})},e[3]=o,e[4]=l):l=e[4];const f=l;let p;e[5]!==a?(p=()=>{const C=a??ft.getState().currentAgentName;C&&Cn.getState().setSelectedAgent(C),re.getState().requestSettingsJump("agents","agents.permissions")},e[5]=a,e[6]=p):p=e[6];const g=p;let h;e[7]!==g||e[8]!==c||e[9]!==r||e[10]!==n?(h=C=>C==="safety"&&!r?s.jsxs(s.Fragment,{children:[n("settings.sessions.permissions.explain.safetyUnavailable")," ",s.jsx(Vn,{onClick:Fo,children:n("settings.jevAccess.setUp")})]}):C==="safety"?s.jsxs(s.Fragment,{children:[c?n("settings.sessions.permissions.explain.safetyVia",{provider:c}):n("settings.sessions.permissions.explain.safety")," ",s.jsx(Vn,{onClick:Fo,children:n("settings.jevAccess.manage")})]}):s.jsxs(s.Fragment,{children:[n(C==="auto"?"settings.sessions.permissions.explain.auto":"settings.sessions.permissions.explain.ask")," ",s.jsx(Vn,{onClick:g,children:n("settings.sessions.permissions.agentPermissionsLink")})]}),e[7]=g,e[8]=c,e[9]=r,e[10]=n,e[11]=h):h=e[11];const y=h;let b;e[12]!==y||e[13]!==r?(b=(C,E)=>{const{icon:F,color:O}=Fk[C];return{value:C,label:s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(te,{name:F,className:"size-3.5",style:O?{color:O}:void 0}),E]}),tooltip:y(C),disabled:C==="safety"&&!r}},e[12]=y,e[13]=r,e[14]=b):b=e[14];const x=b;let w;e[15]!==n?(w=n("settings.sessions.permissions.defaultMode"),e[15]=n,e[16]=w):w=e[16];let S;e[17]!==n?(S=n("settings.sessions.permissions.defaultModeInfo"),e[17]=n,e[18]=S):S=e[18];let v;e[19]!==n?(v=n("settings.sessions.permissions.defaultMode"),e[19]=n,e[20]=v):v=e[20];let A;e[21]!==x||e[22]!==n?(A=[x("ask",n("settings.sessions.permissions.mode.ask")),x("safety",n("settings.sessions.permissions.mode.safety")),x("auto",n("settings.sessions.permissions.mode.auto"))],e[21]=x,e[22]=n,e[23]=A):A=e[23];let I;e[24]!==f||e[25]!==d||e[26]!==v||e[27]!==A?(I=s.jsx(Xt,{"aria-label":v,value:d,onChange:f,options:A}),e[24]=f,e[25]=d,e[26]=v,e[27]=A,e[28]=I):I=e[28];let N;e[29]!==I||e[30]!==w||e[31]!==S?(N=s.jsx(st,{settingsItem:"sessions.permission-default",label:w,info:S,children:I}),e[29]=I,e[30]=w,e[31]=S,e[32]=N):N=e[32];let k;e[33]!==y||e[34]!==d?(k=s.jsx("p",{className:_t,children:y(d)}),e[33]=y,e[34]=d,e[35]=k):k=e[35];let P;e[36]!==r?(P=r?null:s.jsx(Zo,{}),e[36]=r,e[37]=P):P=e[37];let j;return e[38]!==N||e[39]!==k||e[40]!==P?(j=s.jsxs("div",{className:"space-y-1",children:[N,k,P]}),e[38]=N,e[39]=k,e[40]=P,e[41]=j):j=e[41],j};function Kk(t){return t.permissionDefaultMode}function _k(t){return t.setPermissionDefaultMode}function $k(t){return t.classifier?.effective??null}const Nr=t=>{const e=Un(t);return e||{providerId:"",modelId:""}},zk=()=>{const{t}=Ee(),e=ft(oe=>oe.setProvider),a=ft(oe=>oe.setModel),n=ft(oe=>oe.setAgent),i=ft(oe=>oe.setCurrentVariant),o=ft(oe=>oe.setCurrentVariantOverride),r=ft(oe=>oe.setSettingsDefaultModel),c=ft(oe=>oe.setSettingsDefaultVariant),u=ft(oe=>oe.setSettingsDefaultAgent),d=ft(oe=>oe.selectionSource==="manual"),l=Yp(oe=>oe.currentSessionId),f=_l(oe=>oe.getSessionModelSelection),p=_l(oe=>oe.getSessionAgentSelection),g=ft(oe=>oe.agentSelectionSource==="manual"),y=!!(ft(oe=>{if(oe.agentSelectionSource!=="manual")return!1;const pe=oe.agents.find(se=>se.name===oe.currentAgentName);return!!(pe?.model?.providerID&&pe.model.id)})||d&&l&&f(l)),b=!!(g&&l&&p(l)),x=m.useMemo(()=>os(),[]),w=re(oe=>oe.showDeletionDialog),S=re(oe=>oe.setShowDeletionDialog),v=ft(oe=>oe.providers),A=ft(oe=>oe.modelsMetadata),[I,N]=m.useState(),[k,P]=m.useState(),[j,C]=m.useState(),[E,F]=m.useState(!0),[O,K]=m.useState(),D=ah()??[],[M,T]=m.useState(),[R,$]=m.useState(!0),z=m.useMemo(()=>Nr(I),[I]);m.useEffect(()=>{(async()=>{try{const pe=await fn();if(pe){const se=pe.defaultModel?.trim()||void 0,ve=pe.defaultVariant?.trim()||void 0,be=pe.defaultAgent?.trim()||void 0;se!==void 0&&N(se),ve!==void 0&&P(ve),be!==void 0&&C(be),pe.smallModelUseDefault!==void 0&&F(pe.smallModelUseDefault);const ne=pe.smallModelOverride?.trim();ne&&K(ne);const we=pe.walkthroughModelOverride?.trim();we&&T(we)}}catch(pe){console.warn("Failed to load defaults settings:",pe)}finally{$(!1)}})()},[]);const Q=m.useCallback(async(oe,pe)=>{const se=oe&&pe?`${oe}/${pe}`:void 0;N(se),P(void 0),c(void 0),r(se),y||(i(void 0),oe&&pe&&(v.find(be=>be.id===oe)||su(oe,pe))&&(e(oe),a(pe)));try{await jt({defaultModel:se??"",defaultVariant:""})}catch(ve){console.warn("Failed to save default model:",ve)}},[y,v,i,a,e,r,c]),V="__default__",L=m.useCallback(oe=>oe===V?t("settings.openchamber.defaults.option.default"):oe.charAt(0).toUpperCase()+oe.slice(1),[t]),B=m.useCallback(async oe=>{const pe=oe===V?void 0:oe||void 0;P(pe),c(pe),y||o(pe??null,pe);try{await jt({defaultVariant:pe??""})}catch(se){console.warn("Failed to save default variant:",se)}},[y,o,c]),W=m.useCallback(async oe=>{const pe=oe||void 0;C(pe),u(pe),oe&&!b&&n(oe);try{await jt({defaultAgent:pe??""})}catch(se){console.warn("Failed to save default agent:",se)}},[b,n,u]),Y=m.useCallback(async oe=>{F(oe);try{await jt({smallModelUseDefault:oe})}catch(pe){console.warn("Failed to save small model preference:",pe)}},[]),ae=m.useCallback(async(oe,pe)=>{const se=oe&&pe?`${oe}/${pe}`:void 0;K(se);try{await jt({smallModelOverride:se??""})}catch(ve){console.warn("Failed to save small model override:",ve)}},[]),ee=m.useCallback(async(oe,pe)=>{const se=oe&&pe?`${oe}/${pe}`:void 0;T(se);try{await jt({walkthroughModelOverride:se??""})}catch(ve){console.warn("Failed to save walkthrough model override:",ve)}},[]),G=m.useCallback((oe,pe)=>A.get(`${oe}/${pe}`)?.structured_output!==!1,[A]),le=m.useMemo(()=>Nr(O),[O]),J=m.useMemo(()=>Nr(M),[M]),me=m.useMemo(()=>{if(!z.providerId||!z.modelId)return[];const pe=v.find(se=>se.id===z.providerId)?.models.find(se=>se.id===z.modelId);return Zp(pe?.variants)},[z.modelId,z.providerId,v]),fe=me.length>0;return R?null:s.jsxs(s.Fragment,{children:[s.jsxs($e,{title:t("settings.openchamber.defaults.title"),description:s.jsxs(s.Fragment,{children:[t("settings.openchamber.defaults.summaryPrefix")," ",s.jsx("span",{className:"text-foreground",children:z.providerId?`${z.providerId}/${z.modelId}${fe?` (${k??t("settings.openchamber.defaults.option.defaultLowercase")})`:""}`:t("settings.openchamber.defaults.summaryOpenCodeDefault")}),j?s.jsxs(s.Fragment,{children:[" / ",s.jsx("span",{className:"text-foreground",children:j})]}):null]}),divider:!1,contentClassName:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(st,{settingsItem:"sessions.default-model",label:t("settings.openchamber.defaults.field.defaultModel"),children:s.jsx(Fa,{providerId:z.providerId,modelId:z.modelId,onChange:Q,className:an,offerAuto:!0})}),s.jsx(st,{settingsItem:"sessions.default-thinking",label:t("settings.openchamber.defaults.field.defaultThinking"),children:s.jsxs(Pt,{value:k??V,onValueChange:B,disabled:!fe,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.openchamber.defaults.field.thinkingPlaceholder"),children:L(k??V)})}),s.jsxs(It,{children:[s.jsx(bt,{value:V,children:t("settings.openchamber.defaults.option.default")}),me.map(oe=>s.jsx(bt,{value:oe,children:L(oe)},oe))]})]})}),s.jsx(st,{settingsItem:"sessions.default-agent",label:t("settings.openchamber.defaults.field.defaultAgent"),children:s.jsx(al,{agentName:j||"",onChange:W,filter:oe=>Co(oe.mode),className:an})}),x?null:s.jsx(Lk,{agentName:j}),x?null:s.jsx(Ok,{})]}),s.jsxs("div",{className:bs,children:[s.jsx(ct,{settingsItem:"sessions.deletion-dialog",checked:w,onChange:S,label:t("settings.openchamber.defaults.field.showDeletionDialog"),ariaLabel:t("settings.openchamber.defaults.field.showDeletionDialogAria")}),x?s.jsx(Ek,{}):null]})]}),s.jsxs($e,{title:t("settings.layout.sessions.helperModels.title"),contentClassName:"space-y-2",children:[s.jsx(ct,{settingsItem:"sessions.small-model",checked:E,onChange:oe=>{Y(oe)},label:t("settings.openchamber.defaults.smallModel.useDefault"),ariaLabel:t("settings.openchamber.defaults.smallModel.useDefaultAria"),info:t("settings.openchamber.defaults.smallModel.description")}),s.jsxs("div",{children:[E?null:s.jsx(st,{label:t("settings.openchamber.defaults.smallModel.title"),children:s.jsx(Fa,{providerId:le.providerId,modelId:le.modelId,onChange:ae,allowedProviderIds:D,className:an})}),s.jsx(st,{settingsItem:"sessions.walkthrough-model",label:t("settings.openchamber.defaults.walkthroughModel.title"),info:t("settings.openchamber.defaults.walkthroughModel.description"),children:s.jsx(Fa,{providerId:J.providerId,modelId:J.modelId,onChange:ee,allowedProviderIds:D,isModelAllowed:G,placeholder:t("settings.openchamber.defaults.walkthroughModel.usesSmallModel"),className:an})})]})]})]})},pd={completion:{titleKey:"settings.notifications.page.template.defaults.completion.title",messageKey:"settings.notifications.page.template.defaults.completion.message"},error:{titleKey:"settings.notifications.page.template.defaults.error.title",messageKey:"settings.notifications.page.template.defaults.error.message"},question:{titleKey:"settings.notifications.page.template.defaults.question.title",messageKey:"settings.notifications.page.template.defaults.question.message"},subtask:{titleKey:"settings.notifications.page.template.defaults.subtask.title",messageKey:"settings.notifications.page.template.defaults.subtask.message"}},Uk={completion:"settings.notifications.page.template.event.completion",subtask:"settings.notifications.page.template.event.subtask",error:"settings.notifications.page.template.event.error",question:"settings.notifications.page.template.event.question"},Bk=()=>{const{t}=Ee(),e=m.useMemo(()=>is(),[]),a=m.useMemo(()=>os(),[]),n=m.useMemo(()=>typeof window>"u"?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",[]),i=!e&&!a&&!n,o=re(L=>L.nativeNotificationsEnabled),r=re(L=>L.setNativeNotificationsEnabled),c=re(L=>L.notificationMode),u=re(L=>L.setNotificationMode),d=re(L=>L.notifyOnSubtasks),l=re(L=>L.setNotifyOnSubtasks),f=re(L=>L.notifyOnCompletion),p=re(L=>L.setNotifyOnCompletion),g=re(L=>L.notifyOnError),h=re(L=>L.setNotifyOnError),y=re(L=>L.notifyOnQuestion),b=re(L=>L.setNotifyOnQuestion),x=re(L=>L.notificationTemplates),w=re(L=>L.setNotificationTemplates),[S,v]=m.useState("default"),[A,I]=m.useState(!1),[N,k]=m.useState(!1),[P,j]=m.useState(!1),C=Hi(P);m.useEffect(()=>{if(!i){I(!1),k(!1);return}typeof Notification<"u"&&v(Notification.permission);const L=typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window;I(L),(async()=>{if(!L){k(!1);return}try{const W=await navigator.serviceWorker.getRegistration();if(!W){k(!1);return}const Y=await W.pushManager.getSubscription();k(!!Y)}catch{k(!1)}})()},[i]);const E=async L=>{if(e){r(L);return}if(!i){r(L);return}if(L&&typeof Notification<"u"&&Notification.permission==="default")try{const B=await Notification.requestPermission();v(B),B==="granted"?r(!0):q.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.description")})}catch(B){console.error("Failed to request notification permission:",B),q.error(t("settings.notifications.page.toast.requestPermissionFailed"))}else r(!!(L&&S==="granted"))},F=e||a||n||i&&typeof Notification<"u"&&Notification.permission==="granted",O=(L,B,W)=>{w(Y=>({...Y,[L]:{...Y[L],[B]:W}}))},K=L=>{const B="=".repeat((4-L.length%4)%4),W=(L+B).replace(/-/g,"+").replace(/_/g,"/"),Y=atob(W),ae=new Uint8Array(Y.length);for(let ee=0;ee<Y.length;ee+=1)ae[ee]=Y.charCodeAt(ee);return ae},D=async(L,B,W)=>{let Y=null;const ae=new Promise((ee,G)=>{Y=setTimeout(()=>{G(new Error(W))},B)});try{return await Promise.race([L,ae])}finally{Y&&clearTimeout(Y)}},M=async L=>{if(L.active)return;const B=L.installing||L.waiting;B&&B.state!=="activated"&&await D(new Promise(W=>{const Y=()=>{B.state==="activated"&&(B.removeEventListener("statechange",Y),W())};B.addEventListener("statechange",Y),Y()}),15e3,"Service worker activation timed out")},T=async()=>{if(typeof navigator.serviceWorker.register!="function")throw new Error("navigator.serviceWorker.register unavailable");const L=[{label:"no-options",opts:null},{label:"scope-root",opts:{scope:"/"}},{label:"type-classic",opts:{type:"classic"}},{label:"type-classic-scope",opts:{type:"classic",scope:"/"}},{label:"updateViaCache-none",opts:{type:"classic",updateViaCache:"none",scope:"/"}}];let B=null;for(const W of L)try{const Y=W.opts?navigator.serviceWorker.register("/sw.js",W.opts):navigator.serviceWorker.register("/sw.js");return await D(Y,1e4,`Service worker registration timed out (${W.label})`)}catch(Y){B=Y}throw B instanceof Error?B:new Error("Service worker registration failed")},R=async()=>{if(!("serviceWorker"in navigator))throw new Error("Service worker not supported");const L=await navigator.serviceWorker.getRegistration();if(L)return L;const B=await T();try{await B.update()}catch{}return await M(B),B},$=L=>{const B=L,W=[`type=${typeof L}`,`toString=${String(L)}`,`name=${String(B?.name??"")}`,`message=${String(B?.message??"")}`];let Y="";try{Y=JSON.stringify(L)}catch{}return{summary:W.filter(Boolean).join(" | "),json:Y,stack:typeof B?.stack=="string"?B.stack:""}},z=async()=>{const L=_a();if(!L?.notifications){q.error(t("settings.notifications.page.toast.notificationsApiUnavailable"));return}try{await L.notifications.notifyAgentCompletion({title:t("settings.notifications.page.testNotification.title"),body:t("settings.notifications.page.testNotification.body"),tag:"openchamber-test"})?q.success(t("settings.notifications.page.toast.testNotificationSent")):q.error(t("settings.notifications.page.toast.testNotificationFailed"))}catch(B){console.error("Test notification failed:",B),q.error(t("settings.notifications.page.toast.testNotificationFailed"))}},Q=async()=>{if(!A){q.error(t("settings.notifications.page.toast.pushUnsupported"));return}const L=_a();if(!L?.push){q.error(t("settings.notifications.page.toast.pushApiUnavailable"));return}j(!0);try{if(typeof Notification<"u"&&Notification.permission==="default"){const J=await Notification.requestPermission();if(v(J),J!=="granted"){q.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}}if(typeof Notification<"u"&&Notification.permission!=="granted"){q.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}const B=await L.push.getVapidPublicKey();if(!B?.publicKey){q.error(t("settings.notifications.page.toast.pushKeyLoadFailed"));return}const W=await R();await M(W);const Y=await W.pushManager.getSubscription();if(!("pushManager"in W)||!W.pushManager)throw new Error("PushManager unavailable (requires installed PWA + iOS 16.4+)");const ee=(Y??await D(W.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:K(B.publicKey)}),15e3,"Push subscription timed out")).toJSON(),G=ee.keys;if(!ee.endpoint||!G?.p256dh||!G.auth)throw new Error("Push subscription missing keys");if(!(await D(L.push.subscribe({endpoint:ee.endpoint,keys:{p256dh:G.p256dh,auth:G.auth},origin:typeof window<"u"?window.location.origin:void 0,platform:Fg()}),15e3,"Push subscribe request timed out"))?.ok){q.error(t("settings.notifications.page.toast.enableBackgroundFailed"));return}k(!0),q.success(t("settings.notifications.page.toast.backgroundEnabled"))}catch(B){console.error("[Push] Enable failed:",B);const W=$(B);q.error(t("settings.notifications.page.toast.enableBackgroundFailed"),{description:W.summary})}finally{j(!1)}},V=async()=>{if(!A){k(!1);return}const L=_a();if(!L?.push){q.error(t("settings.notifications.page.toast.pushApiUnavailable"));return}j(!0);try{const W=await(await R()).pushManager.getSubscription();if(!W){k(!1);return}const Y=W.endpoint;await W.unsubscribe(),await L.push.unsubscribe({endpoint:Y}),k(!1),q.success(t("settings.notifications.page.toast.backgroundDisabled"))}finally{j(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs($e,{settingsItem:"notifications.delivery",title:t("settings.notifications.page.delivery.title"),divider:!1,children:[s.jsxs("div",{className:bs,children:[s.jsx(ct,{checked:o&&F,onChange:L=>{E(L)},label:t("settings.notifications.page.delivery.enableLabel"),info:i?t("settings.notifications.page.delivery.browserPermissionHint"):a?t("settings.notifications.page.delivery.vscodeHint"):void 0,ariaLabel:t("settings.notifications.page.delivery.enableAria")}),o&&F&&!n&&s.jsxs(s.Fragment,{children:[s.jsx(ct,{checked:c==="always",onChange:L=>u(L?"always":"hidden-only"),label:t("settings.notifications.page.delivery.focusedLabel"),ariaLabel:t("settings.notifications.page.delivery.focusedAria")}),s.jsx("div",{className:"py-2",children:s.jsx(H,{type:"button",variant:"outline",size:"sm",onClick:()=>{z()},children:t("settings.notifications.page.delivery.testAction")})})]})]}),i&&s.jsxs("div",{className:"mt-1",children:[S==="denied"&&s.jsx("p",{className:"typography-meta text-[var(--status-error)] mt-1",children:t("settings.notifications.page.delivery.permissionDenied")}),S==="granted"&&!o&&s.jsx("p",{className:"typography-meta text-muted-foreground/70 mt-1",children:t("settings.notifications.page.delivery.permissionGrantedButDisabled")})]})]}),o&&F&&s.jsxs(s.Fragment,{children:[s.jsx($e,{settingsItem:"notifications.events",title:t("settings.notifications.page.events.title"),children:s.jsxs("div",{className:bs,children:[s.jsx(ct,{checked:f,onChange:p,label:t("settings.notifications.page.events.completionLabel"),ariaLabel:t("settings.notifications.page.events.completionAria")}),s.jsx(ct,{checked:d,onChange:l,label:t("settings.notifications.page.events.subtaskLabel"),ariaLabel:t("settings.notifications.page.events.subtaskAria")}),s.jsx(ct,{checked:g,onChange:h,label:t("settings.notifications.page.events.errorLabel"),ariaLabel:t("settings.notifications.page.events.errorAria")}),s.jsx(ct,{checked:y,onChange:b,label:t("settings.notifications.page.events.questionLabel"),ariaLabel:t("settings.notifications.page.events.questionAria")})]})}),!n&&s.jsx($e,{title:t("settings.notifications.page.template.title"),description:s.jsxs(s.Fragment,{children:[t("settings.notifications.page.template.variablesLabel")," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{project_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{worktree}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{branch}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{session_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{agent_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{model_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{last_message}"})]}),children:s.jsx(ma,{className:"gap-2 md:grid-cols-2 md:gap-3 lg:gap-3",children:["completion","subtask","error","question"].map(L=>s.jsxs("section",{className:"p-2",children:[s.jsx($a,{className:"capitalize",children:t(Uk[L])}),s.jsxs("div",{className:"mt-1.5 space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:t("settings.notifications.page.template.field.title")}),s.jsx(qe,{value:x[L].title,onChange:B=>O(L,"title",B.target.value),className:"h-7",placeholder:t(pd[L].titleKey)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:t("settings.notifications.page.template.field.message")}),s.jsx(qe,{value:x[L].message,onChange:B=>O(L,"message",B.target.value),className:"h-7",placeholder:t(pd[L].messageKey)})]})]})]},L))})})]}),i&&s.jsx($e,{settingsItem:"notifications.push",title:t("settings.notifications.page.push.title"),children:s.jsx(ct,{checked:A?N:!1,disabled:!A||P,onChange:L=>{L?Q():V()},label:t("settings.notifications.page.push.enableLabel"),description:A?void 0:t("settings.notifications.page.push.unsupportedHint"),info:A?t("settings.notifications.page.push.supportedHint"):void 0,ariaLabel:t("settings.notifications.page.push.enableAria"),labelAccessory:P?s.jsx("span",{className:ze("inline-block h-1.5 w-1.5 rounded-full bg-current text-muted-foreground",C),"aria-label":t("settings.notifications.page.push.loadingAria")}):null})})]})},Rs=t=>{if(!t)return;t.pause();const{src:e}=t;e.startsWith("blob:")&&URL.revokeObjectURL(e),t.removeAttribute("src"),t.load()},pa="oc-surface-elevated oc-raised oc-field w-full min-w-0 h-8 rounded-md bg-surface-elevated px-3 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none",Vk=[{id:"parakeet-tdt-0.6b-v2-int8",labelKey:"settings.voice.page.stt.model.parakeetV2",badgeKey:"settings.voice.page.stt.badge.bestForEnglish",accuracy:5,speed:5,size:"460 MB"},{id:"parakeet-tdt-0.6b-v3-int8",labelKey:"settings.voice.page.stt.model.parakeetV3",badgeKey:"settings.voice.page.stt.badge.bestForMultilingual",accuracy:5,speed:4,size:"465 MB"},{id:"whisper-base-int8",labelKey:"settings.voice.page.stt.model.whisperBase",badgeKey:null,accuracy:3,speed:3,size:"200 MB"},{id:"whisper-tiny-int8",labelKey:"settings.voice.page.stt.model.whisperTiny",badgeKey:null,accuracy:2,speed:4,size:"115 MB"}],gd=t=>{const e=De.c(8),{value:a,label:n}=t,i=`${n}: ${a}/5`;let o;e[0]!==n?(o=s.jsx("span",{className:"typography-micro text-muted-foreground",children:n}),e[0]=n,e[1]=o):o=e[1];const r=`${a/5*100}%`;let c;e[2]!==r?(c=s.jsx("span",{className:"h-1.5 w-8 flex-shrink-0 overflow-hidden rounded-full bg-[var(--interactive-border)]","aria-hidden":"true",children:s.jsx("span",{className:"block h-full rounded-full bg-[var(--primary-base)]",style:{width:r}})}),e[2]=r,e[3]=c):c=e[3];let u;return e[4]!==i||e[5]!==o||e[6]!==c?(u=s.jsxs("span",{className:"flex items-center gap-1.5",title:i,children:[o,c]}),e[4]=i,e[5]=o,e[6]=c,e[7]=u):u=e[7],u},Hk=({selectedModelId:t,onSelect:e})=>{const{t:a}=Ee(),n=Ke.useCallback(p=>a(p),[a]),[i,o]=Ke.useState(new Map),[r,c]=Ke.useState(null),u=Ke.useCallback(async()=>{try{const p=await $t("/api/dictation/status",{query:{provider:"local"}});if(!p.ok)return;const g=await p.json();Array.isArray(g?.models)&&o(new Map(g.models.map(h=>[h.id,h])))}catch{}},[]);Ke.useEffect(()=>{u()},[u]);const d=Array.from(i.values()).some(p=>p.downloading);Ke.useEffect(()=>{if(!d)return;const p=setInterval(()=>{u()},2e3);return()=>clearInterval(p)},[d,u]);const l=async p=>{c(p);try{await $t(`/api/dictation/models/${encodeURIComponent(p)}/download`,{method:"POST"}),await u()}catch{}finally{c(null)}},f=async p=>{c(p);try{await $t(`/api/dictation/models/${encodeURIComponent(p)}`,{method:"DELETE"}),await u()}catch{}finally{c(null)}};return s.jsx("div",{role:"radiogroup","aria-label":a("settings.voice.page.field.model"),className:"grid w-full grid-cols-1 gap-2 @3xl:grid-cols-2",children:Vk.map(p=>{const g=t===p.id,h=i.get(p.id)??null;return s.jsxs("div",{className:ze("flex items-start gap-2 rounded-lg px-3 py-2.5",g?"bg-interactive-selection text-interactive-selection-foreground":"oc-tile"),children:[s.jsxs("div",{className:"flex min-w-0 flex-1 cursor-pointer items-start gap-2",role:"button",tabIndex:0,onClick:()=>e(p.id),onKeyDown:y=>{(y.key===" "||y.key==="Enter")&&(y.preventDefault(),e(p.id))},children:[s.jsx("div",{className:"pt-0.5",children:s.jsx(il,{checked:g,onChange:()=>e(p.id),ariaLabel:n(p.labelKey)})}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("div",{className:"typography-ui-label truncate text-foreground",title:n(p.labelKey),children:n(p.labelKey)}),p.badgeKey?s.jsx("span",{className:"inline-block rounded-full bg-[var(--status-success)]/15 px-2 py-px text-[10px] font-medium text-[var(--status-success)]",children:n(p.badgeKey)}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsx(gd,{value:p.accuracy,label:a("settings.voice.page.stt.meta.accuracy")}),s.jsx(gd,{value:p.speed,label:a("settings.voice.page.stt.meta.speed")}),s.jsx("span",{className:"typography-micro tabular-nums text-muted-foreground",children:p.size})]}),h?.downloadError?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:h.downloadError}):null]})]}),s.jsx("div",{className:"flex h-6 shrink-0 items-center gap-1",children:h?.installed?s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"checkbox-circle",className:"h-4 w-4 flex-shrink-0 text-[var(--status-success)]","aria-label":a("settings.voice.page.stt.modelInstalled")}),s.jsx(H,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]",disabled:r===p.id,onClick:()=>{f(p.id)},title:a("settings.voice.page.stt.modelDelete"),"aria-label":a("settings.voice.page.stt.modelDelete"),children:s.jsx(te,{name:"delete-bin",className:"h-4 w-4"})})]}):h?.downloading?s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(va,{className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:typeof h.downloadProgress=="number"?`${h.downloadProgress}%`:""})]}):s.jsx(H,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0",disabled:r===p.id,onClick:()=>{l(p.id)},title:a("settings.voice.page.stt.modelDownload"),"aria-label":a("settings.voice.page.stt.modelDownload"),children:s.jsx(te,{name:"download",className:"h-4 w-4"})})})]},p.id)})})},qk=[{id:0,label:"Alloy (af)"},{id:1,label:"Bella (af)"},{id:2,label:"Nicole (af)"},{id:3,label:"Sarah (af)"},{id:4,label:"Sky (af)"},{id:5,label:"Adam (am)"},{id:6,label:"Michael (am)"},{id:7,label:"Emma (bf)"},{id:8,label:"Isabella (bf)"},{id:9,label:"George (bm)"},{id:10,label:"Lewis (bm)"}],Xr="kokoro-en-v0_19",Wk="kokoro-multi-lang-v1_1",Gk=[{id:0,label:"Maple (af)"},{id:1,label:"Sol (af)"},{id:2,label:"Vale (bf)"},{id:3,label:"Xiaoxiao (zf)"},{id:58,label:"Yunxi (zm)"}],wi=(t,e)=>`${t}:${e}`,Jk=()=>{const[t,e]=Ke.useState([]),[a,n]=Ke.useState(null),i=Ke.useCallback(async()=>{try{const c=await $t("/api/dictation/status",{query:{provider:"local"}});if(!c.ok)return;const u=await c.json();Array.isArray(u?.ttsModels)&&e(u.ttsModels)}catch{}},[]);Ke.useEffect(()=>{i()},[i]);const o=t.some(c=>c.downloading);Ke.useEffect(()=>{if(!o)return;const c=setInterval(()=>{i()},2e3);return()=>clearInterval(c)},[o,i]);const r=Ke.useCallback(async(c,u)=>{n(c);try{const d=u==="POST"?`/api/dictation/models/${c}/download`:`/api/dictation/models/${c}`;await $t(d,{method:u}),await i()}catch{}finally{n(null)}},[i]);return{models:t,requestingId:a,request:r,refresh:i}},Qk=t=>{const e=qk.map(a=>({modelId:Xr,speakerId:a.id,label:a.label}));for(const a of t)if(!(a.id===Xr||!a.installed)){if(a.id===Wk){for(const n of Gk)e.push({modelId:a.id,speakerId:n.id,label:`${n.label} · Kokoro zh/en`});continue}e.push({modelId:a.id,speakerId:0,label:a.description??a.id})}return e},fd=t=>{const e=De.c(16),{model:a,requestingId:n,request:i,t:o}=t,r=a.description??a.id;let c;e[0]!==r?(c=s.jsx("span",{className:"typography-ui-label text-foreground",children:r}),e[0]=r,e[1]=c):c=e[1];let u;e[2]!==a.downloadProgress||e[3]!==a.downloading||e[4]!==a.id||e[5]!==a.installed||e[6]!==i||e[7]!==n||e[8]!==o?(u=a.installed?s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"checkbox-circle",className:"h-4 w-4 text-[var(--status-success)]","aria-label":o("settings.voice.page.stt.modelInstalled")}),s.jsx(H,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]",disabled:n!==null,onClick:()=>{i(a.id,"DELETE")},title:o("settings.voice.page.stt.modelDelete"),"aria-label":o("settings.voice.page.stt.modelDelete"),children:s.jsx(te,{name:"delete-bin",className:"h-4 w-4"})})]}):a.downloading?s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(va,{className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:typeof a.downloadProgress=="number"?`${a.downloadProgress}%`:""})]}):s.jsx(H,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0",disabled:n!==null,onClick:()=>{i(a.id,"POST")},title:o("settings.voice.page.stt.modelDownload"),"aria-label":o("settings.voice.page.stt.modelDownload"),children:s.jsx(te,{name:"download",className:"h-4 w-4"})}),e[2]=a.downloadProgress,e[3]=a.downloading,e[4]=a.id,e[5]=a.installed,e[6]=i,e[7]=n,e[8]=o,e[9]=u):u=e[9];let d;e[10]!==a.downloadError?(d=a.downloadError?s.jsx("span",{className:"typography-meta text-[var(--status-error)]",children:a.downloadError}):null,e[10]=a.downloadError,e[11]=d):d=e[11];let l;return e[12]!==c||e[13]!==u||e[14]!==d?(l=s.jsxs("div",{className:"flex items-center gap-2 py-1.5",children:[c,u,d]}),e[12]=c,e[13]=u,e[14]=d,e[15]=l):l=e[15],l},Yk=t=>{const e=De.c(21),{models:a,requestingId:n,request:i}=t,{t:o}=Ee(),[r,c]=Ke.useState(!1),[u,d]=Ke.useState("");if(a.length===0)return null;let l,f,p;if(e[0]!==u||e[1]!==a){f=[],l=[];for(const w of a)w.id===Xr||w.installed||w.downloading||w.downloadError?f.push(w):l.push(w);const x=u.trim().toLowerCase();p=x?l.filter(w=>(w.description??"").toLowerCase().includes(x)||w.id.toLowerCase().includes(x)):l,e[0]=u,e[1]=a,e[2]=l,e[3]=f,e[4]=p}else l=e[2],f=e[3],p=e[4];const g=p;let h;e[5]!==f||e[6]!==i||e[7]!==n||e[8]!==o?(h=f.map(x=>s.jsx(fd,{model:x,requestingId:n,request:i,t:o},x.id)),e[5]=f,e[6]=i,e[7]=n,e[8]=o,e[9]=h):h=e[9];let y;e[10]!==l.length||e[11]!==r||e[12]!==u||e[13]!==g||e[14]!==i||e[15]!==n||e[16]!==o?(y=l.length>0?s.jsxs(ha,{open:r,onOpenChange:c,children:[s.jsxs(ba,{className:"group flex w-full items-center justify-between py-1 hover:bg-transparent",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-start",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:o("settings.voice.page.localTts.availableToDownload")}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",l.length,")"]})]}),s.jsx(te,{name:r?"arrow-down-s":"arrow-right-s",className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]}),s.jsxs(xa,{className:"pt-1",children:[s.jsx("input",{type:"text",value:u,onChange:x=>d(x.target.value),placeholder:o("settings.voice.page.localTts.filterPlaceholder"),"aria-label":o("settings.voice.page.localTts.filterPlaceholder"),className:ze(pa,"mb-1")}),g.length===0?s.jsx("div",{className:"typography-meta py-1.5 text-muted-foreground",children:o("settings.voice.page.localTts.filterNoMatch")}):g.map(x=>s.jsx(fd,{model:x,requestingId:n,request:i,t:o},x.id))]})]}):null,e[10]=l.length,e[11]=r,e[12]=u,e[13]=g,e[14]=i,e[15]=n,e[16]=o,e[17]=y):y=e[17];let b;return e[18]!==h||e[19]!==y?(b=s.jsxs("div",{className:"flex flex-col",children:[h,y]}),e[18]=h,e[19]=y,e[20]=b):b=e[20],b},hd=[{value:"alloy",label:"Alloy"},{value:"ash",label:"Ash"},{value:"ballad",label:"Ballad"},{value:"coral",label:"Coral"},{value:"echo",label:"Echo"},{value:"fable",label:"Fable"},{value:"nova",label:"Nova"},{value:"onyx",label:"Onyx"},{value:"sage",label:"Sage"},{value:"shimmer",label:"Shimmer"},{value:"verse",label:"Verse"},{value:"marin",label:"Marin"},{value:"cedar",label:"Cedar"}],Cr=t=>{const e=De.c(34),{kind:a}=t,{t:n}=Ee();let i;e[0]!==a?(i=N=>N.voiceApiKeys[a],e[0]=a,e[1]=i):i=e[1];const o=ft(i),r=ft(Xk),[c,u]=Ke.useState(""),[d,l]=Ke.useState(!1);let f;e[2]!==a||e[3]!==r||e[4]!==n?(f=async N=>{l(!0);const k=await r(a,N);l(!1),k?u(""):q.error(n("settings.voice.page.toast.apiKeySaveFailed"))},e[2]=a,e[3]=r,e[4]=n,e[5]=f):f=e[5];const p=f;let g;e[6]!==c||e[7]!==p?(g=()=>{const N=c.trim();N&&p(N)},e[6]=c,e[7]=p,e[8]=g):g=e[8];const h=g;let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=ze("relative",rn),e[9]=y):y=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=N=>u(N.target.value),e[10]=b):b=e[10];let x;e[11]!==h?(x=N=>{N.key==="Enter"&&h()},e[11]=h,e[12]=x):x=e[12];let w;e[13]!==o||e[14]!==n?(w=o?n("settings.voice.page.field.apiKeySavedPlaceholder"):"sk-...",e[13]=o,e[14]=n,e[15]=w):w=e[15];let S;e[16]!==n?(S=n("settings.voice.page.field.apiKey"),e[16]=n,e[17]=S):S=e[17];let v;e[18]!==h||e[19]!==c||e[20]!==d||e[21]!==x||e[22]!==w||e[23]!==S?(v=s.jsx("input",{type:"password",value:c,disabled:d,onChange:b,onBlur:h,onKeyDown:x,placeholder:w,className:pa,"aria-label":S}),e[18]=h,e[19]=c,e[20]=d,e[21]=x,e[22]=w,e[23]=S,e[24]=v):v=e[24];let A;e[25]!==c||e[26]!==d||e[27]!==p||e[28]!==o||e[29]!==n?(A=o&&!c&&s.jsx("button",{type:"button",onClick:()=>{p(null)},disabled:d,"aria-label":n("settings.voice.page.field.apiKeyRemove"),className:"absolute inset-e-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(te,{name:"close",className:"w-3.5 h-3.5"})}),e[25]=c,e[26]=d,e[27]=p,e[28]=o,e[29]=n,e[30]=A):A=e[30];let I;return e[31]!==A||e[32]!==v?(I=s.jsxs("div",{className:y,children:[v,A]}),e[31]=A,e[32]=v,e[33]=I):I=e[33],I},Zk=()=>{const{t}=Ee(),{isMobile:e}=Zs(),a=ft(Z=>Z.voiceProvider),n=ft(Z=>Z.setVoiceProvider),i=ft(Z=>Z.speechRate),o=ft(Z=>Z.setSpeechRate),r=ft(Z=>Z.speechPitch),c=ft(Z=>Z.setSpeechPitch),u=ft(Z=>Z.speechVolume),d=ft(Z=>Z.setSpeechVolume),l=ft(Z=>Z.sayVoice),f=ft(Z=>Z.setSayVoice),p=ft(Z=>Z.localTtsVoiceId),g=ft(Z=>Z.localTtsModelId),h=ft(Z=>Z.setLocalTtsModelId),y=Jk(),b=Ke.useMemo(()=>Qk(y.models),[y.models]),x=ft(Z=>Z.ttsFollowTextLanguage),w=ft(Z=>Z.setTtsFollowTextLanguage),S=ft(Z=>Z.setLocalTtsVoiceId),{speak:v,stop:A,isPlaying:I,error:N}=Xp(),k=Ke.useCallback(()=>{if(I){A();return}const Z=b.find(Oe=>Oe.modelId===g&&Oe.speakerId===p)?.label??String(p);v(t("settings.voice.page.preview.voiceLine",{voiceName:Z}),{model:g,speakerId:p,speed:ft.getState().speechRate})},[I,g,p,b,v,A,t]),P=ft(Z=>Z.browserVoice),j=ft(Z=>Z.setBrowserVoice),C=ft(Z=>Z.openaiVoice),E=ft(Z=>Z.setOpenaiVoice),F=ft(Z=>Z.voiceApiKeys.openai),O=ft(Z=>Z.refreshVoiceApiKeys),K=ft(Z=>Z.openaiCompatibleUrl),D=ft(Z=>Z.setOpenaiCompatibleUrl),M=ft(Z=>Z.openaiCompatibleVoice),T=ft(Z=>Z.setOpenaiCompatibleVoice),R=ft(Z=>Z.openaiCompatibleTtsModel),$=ft(Z=>Z.setOpenaiCompatibleTtsModel),z=ft(Z=>Z.showMessageTTSButtons),Q=ft(Z=>Z.ttsInputMode),V=ft(Z=>Z.setTtsInputMode),L=ft(Z=>Z.ttsChunkedMode),B=ft(Z=>Z.setTtsChunkedMode),W=ft(Z=>Z.sttProvider),Y=ft(Z=>Z.setSttProvider),ae=ft(Z=>Z.sttServerUrl),ee=ft(Z=>Z.setSttServerUrl),G=ft(Z=>Z.sttModel),le=ft(Z=>Z.setSttModel),J=ft(Z=>Z.sttLocalModel),me=ft(Z=>Z.setSttLocalModel),fe=ft(Z=>Z.sttLanguage),oe=ft(Z=>Z.setSttLanguage),pe=ft(Z=>Z.setShowMessageTTSButtons),se=ft(Z=>Z.dictationEnabled),ve=ft(Z=>Z.setDictationEnabled),[be,ne]=Ke.useState(!1),[we,Ne]=Ke.useState([]),[Ie,Ce]=Ke.useState(!1),[Me,he]=Ke.useState(null),[Pe,Re]=Ke.useState(!1),[ce,je]=Ke.useState(!1),[de,ie]=Ke.useState(!1),[xe,Se]=Ke.useState(null),[Le,Ue]=Ke.useState(!1),[Ye,lt]=Ke.useState(null),[at,ut]=Ke.useState([]),[vt,We]=Ke.useState(!1);Ke.useEffect(()=>((async()=>{const Oe=await ir.waitForVoices();ut(Oe)})(),"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=()=>{ut(window.speechSynthesis.getVoices())}),()=>{"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);const Ze=Ke.useMemo(()=>at.filter(Z=>Z.lang).sort((Z,Oe)=>{const Ve=Z.lang.startsWith("en"),X=Oe.lang.startsWith("en");if(Ve&&!X)return-1;if(!Ve&&X)return 1;const _e=Z.lang.localeCompare(Oe.lang);return _e!==0?_e:Z.name.localeCompare(Oe.name)}),[at]),Xe=Ke.useCallback(()=>{if(vt){ir.cancelSpeech(),We(!1);return}const Z=at.find(_e=>_e.name===P),Oe=Z?.name??t("settings.voice.page.preview.browserVoiceFallback"),Ve=t("settings.voice.page.preview.voiceLine",{voiceName:Oe});We(!0);const X=new SpeechSynthesisUtterance(Ve);X.rate=i,X.pitch=r,X.volume=u,Z&&(X.voice=Z,X.lang=Z.lang),X.onend=()=>We(!1),X.onerror=()=>We(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(X)},[P,at,i,r,u,vt,t]);Ke.useEffect(()=>()=>{vt&&ir.cancelSpeech()},[vt]),Ke.useEffect(()=>{O({force:!0})},[O]),Ke.useEffect(()=>{if(!z||a!=="openai"&&a!=="openai-compatible"){Re(F);return}(async()=>{try{const Ve=await(await $t("/api/tts/status")).json(),X=Ve.available,_e=F,nt=Ve.enterpriseMode===!0;je(nt),Re(!nt&&(X||_e))}catch{Re(F)}})()},[F,z,a]),Ke.useEffect(()=>{if(!z){ne(!1),Ne([]);return}$t("/api/tts/say/status").then(Z=>Z.json()).then(Z=>{if(ne(Z.available),Z.voices){const Oe=Z.voices.filter((Ve,X,_e)=>_e.findIndex(nt=>nt.name===Ve.name)===X).sort((Ve,X)=>Ve.name.localeCompare(X.name));Ne(Oe)}}).catch(()=>{ne(!1)})},[z]);const it=Ke.useCallback(async()=>{if(Me){Rs(Me),he(null),Ce(!1);return}Ce(!0);let Z=null;try{const Oe=await $t("/api/tts/say/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.voiceLine",{voiceName:l}),voice:l,rate:Math.round(100+(i-.5)*200)})});if(!Oe.ok)throw new Error("Preview failed");const Ve=await Oe.blob(),X=URL.createObjectURL(Ve);Z=new Audio(X),Z.onended=()=>{Rs(Z),he(null),Ce(!1)},Z.onerror=()=>{Rs(Z),he(null),Ce(!1)},he(Z),await Z.play()}catch{Rs(Z),he(null),Ce(!1)}},[l,i,Me,t]);Ke.useEffect(()=>()=>{Rs(Me)},[Me]);const dt=Ke.useCallback(async()=>{if(xe){Rs(xe),Se(null),ie(!1);return}ie(!0);let Z=null;try{const Oe=await $t("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.voiceLine",{voiceName:C}),voice:C,speed:i})});if(!Oe.ok){const _e=await Oe.json().catch(()=>({error:"Unknown error"}));throw new Error(_e.error||`HTTP ${Oe.status}`)}const Ve=await Oe.blob(),X=URL.createObjectURL(Ve);Z=new Audio(X),Z.onended=()=>{Rs(Z),Se(null),ie(!1)},Z.onerror=()=>{Rs(Z),Se(null),ie(!1)},Se(Z),await Z.play()}catch{Rs(Z),Se(null),ie(!1)}},[C,i,xe,t]);Ke.useEffect(()=>()=>{Rs(xe)},[xe]);const Be=Ke.useCallback(async()=>{if(Ye){Rs(Ye),lt(null),Ue(!1);return}if(!K.trim())return;Ue(!0);let Z=null;try{const Oe=await $t("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.customServerLine"),voice:M,model:R||void 0,speed:i,baseURL:K})});if(!Oe.ok){const _e=await Oe.json().catch(()=>({error:"Unknown error"}));throw new Error(_e.error||`HTTP ${Oe.status}`)}const Ve=await Oe.blob(),X=URL.createObjectURL(Ve);Z=new Audio(X),Z.onended=()=>{Rs(Z),lt(null),Ue(!1)},Z.onerror=()=>{Rs(Z),lt(null),Ue(!1)},lt(Z),await Z.play()}catch{Rs(Z),lt(null),Ue(!1)}},[K,M,R,i,Ye,t]);Ke.useEffect(()=>()=>{Rs(Ye)},[Ye]);const ot="w-40 flex-none h-1.5 bg-[var(--interactive-border)] rounded-full appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:border-0 disabled:opacity-50",et="typography-ui-label w-12 shrink-0 text-end tabular-nums text-muted-foreground",ye=Z=>Z?s.jsx(te,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx(te,{name:"play",className:"w-3.5 h-3.5"});return s.jsxs(s.Fragment,{children:[s.jsxs($e,{settingsItem:"voice.playback",title:t("settings.voice.page.section.playbackAndSummary"),divider:!1,contentClassName:"space-y-3",children:[s.jsx(ct,{checked:z,onChange:pe,label:t("settings.voice.page.field.messageReadAloudButton"),ariaLabel:t("settings.voice.page.field.messageReadAloudButtonAria")}),z&&s.jsxs(s.Fragment,{children:[s.jsx(st,{label:t("settings.voice.page.field.provider"),info:s.jsxs("ul",{className:"space-y-1",children:[s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.browser")})," ",t("settings.voice.page.tooltip.browser")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.local")})," ",t("settings.voice.page.tooltip.localTts")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.openai")})," ",t("settings.voice.page.tooltip.openai")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.custom")})," ",t("settings.voice.page.tooltip.custom")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.say")})," ",t("settings.voice.page.tooltip.say")]})]}),children:s.jsx(Xt,{value:a,onChange:n,"aria-label":t("settings.voice.page.field.provider"),options:[{value:"browser",label:t("settings.voice.page.provider.browser")},{value:"local",label:t("settings.voice.page.provider.local")},{value:"openai",label:t("settings.voice.page.provider.openai")},{value:"openai-compatible",label:t("settings.voice.page.provider.custom")},...be?[{value:"say",label:s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"apple",className:"me-0.5 h-3.5 w-3.5"}),t("settings.voice.page.provider.say")]})}]:[]]})}),ce&&(a==="openai"||a==="openai-compatible")&&s.jsx("p",{className:_t,children:t("settings.voice.page.enterpriseMode")}),a==="openai"&&s.jsx(St,{label:s.jsx("span",{className:ze(!Pe&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.apiKey")}),description:t(Pe&&!F?"settings.voice.page.field.apiKeyHintUsingConfig":Pe?"settings.voice.page.field.apiKeyHintProvide":"settings.voice.page.field.apiKeyHintRequired"),children:s.jsx(Cr,{kind:"openai"})}),a==="openai-compatible"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(St,{label:s.jsx("span",{className:ze(!K.trim()&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.serverUrl")}),info:t("settings.voice.page.field.serverUrlHint"),children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("input",{type:"text",value:K,onChange:Z=>D(Z.target.value),placeholder:"http://localhost:8880/v1",className:pa}),K&&s.jsx("button",{type:"button",onClick:()=>D(""),className:"absolute inset-e-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(te,{name:"close",className:"w-3.5 h-3.5"})})]})}),s.jsx(St,{label:t("settings.voice.page.field.apiKey"),description:t("settings.voice.page.field.apiKeyOptional"),children:s.jsx(Cr,{kind:"openaiCompatible"})}),s.jsx(St,{label:t("settings.voice.page.field.model"),children:s.jsx("input",{type:"text",value:R,onChange:Z=>$(Z.target.value),placeholder:"speaches-ai/Kokoro-82M-v1.0-ONNX",className:pa})}),s.jsxs(St,{label:t("settings.voice.page.field.voice"),info:t("settings.voice.page.field.voiceIdentifierHint"),children:[s.jsx("input",{type:"text",value:M,onChange:Z=>T(Z.target.value),placeholder:"af_sky",className:pa}),s.jsx(H,{size:"sm",variant:"ghost",className:Yt,onClick:Be,title:t("settings.voice.page.actions.preview"),"aria-label":t("settings.voice.page.actions.preview"),disabled:!K.trim(),children:ye(Le)})]})]}),a==="local"&&s.jsx(Yk,{...y}),s.jsxs("div",{children:[a==="openai-compatible"?null:s.jsxs(st,{label:t("settings.voice.page.field.voice"),children:[a==="local"&&s.jsxs(s.Fragment,{children:[s.jsxs(Pt,{value:wi(g,p),onValueChange:Z=>{const Oe=b.find(Ve=>wi(Ve.modelId,Ve.speakerId)===Z);Oe&&(h(Oe.modelId),S(Oe.speakerId))},children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder"),children:Z=>b.find(Oe=>wi(Oe.modelId,Oe.speakerId)===Z)?.label??Z})}),s.jsx(It,{children:b.map(Z=>s.jsx(bt,{value:wi(Z.modelId,Z.speakerId),children:Z.label},wi(Z.modelId,Z.speakerId)))})]}),s.jsx(H,{size:"sm",variant:"ghost",className:Yt,onClick:k,title:t("settings.voice.page.actions.preview"),"aria-label":t("settings.voice.page.actions.preview"),children:ye(I)}),N?s.jsx("span",{className:"typography-meta text-[var(--status-error)]",children:N}):null]}),a==="openai"&&Pe&&s.jsxs(s.Fragment,{children:[s.jsxs(Pt,{value:C,onValueChange:E,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder"),children:Z=>hd.find(Oe=>Oe.value===Z)?.label??Z})}),s.jsx(It,{children:hd.map(Z=>s.jsx(bt,{value:Z.value,children:Z.label},Z.value))})]}),s.jsx(H,{size:"sm",variant:"ghost",className:Yt,onClick:dt,title:t("settings.voice.page.actions.preview"),"aria-label":t("settings.voice.page.actions.preview"),children:ye(de)})]}),a==="say"&&be&&we.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs(Pt,{value:l,onValueChange:f,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder")})}),s.jsx(It,{children:we.map(Z=>s.jsx(bt,{value:Z.name,children:Z.name},Z.name))})]}),s.jsx(H,{size:"sm",variant:"ghost",className:Yt,onClick:it,title:t("settings.voice.page.actions.preview"),"aria-label":t("settings.voice.page.actions.preview"),children:ye(Ie)})]}),a==="browser"&&Ze.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs(Pt,{value:P||"$auto",onValueChange:Z=>j(Z==="$auto"?"":Z),children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.voice.page.field.auto"),children:Z=>Z==="$auto"?t("settings.voice.page.field.auto"):Z})}),s.jsxs(It,{children:[s.jsx(bt,{value:"$auto",children:t("settings.voice.page.field.auto")}),Ze.map(Z=>s.jsxs(bt,{value:Z.name,children:[Z.name," (",Z.lang,")"]},Z.name))]})]}),s.jsx(H,{size:"sm",variant:"ghost",className:Yt,onClick:Xe,title:t("settings.voice.page.actions.preview"),"aria-label":t("settings.voice.page.actions.preview"),children:ye(vt)})]})]}),s.jsx(st,{label:t("settings.voice.page.field.speechRate"),children:e?s.jsx(ds,{value:i,onValueChange:o,min:.5,max:2,step:.1,className:ze(us,"tabular-nums")}):s.jsxs("div",{className:"flex h-8 items-center gap-2",children:[s.jsx("input",{type:"range",min:.5,max:2,step:.1,value:i,onChange:Z=>o(Number(Z.target.value)),className:ot,"aria-label":t("settings.voice.page.field.speechRate")}),s.jsx("span",{className:et,children:`${i.toFixed(1)}×`})]})}),s.jsx(st,{label:t("settings.voice.page.field.speechPitch"),children:e?s.jsx(ds,{value:r,onValueChange:c,min:.5,max:2,step:.1,className:ze(us,"tabular-nums")}):s.jsxs("div",{className:"flex h-8 items-center gap-2",children:[s.jsx("input",{type:"range",min:.5,max:2,step:.1,value:r,onChange:Z=>c(Number(Z.target.value)),className:ot,"aria-label":t("settings.voice.page.field.speechPitch")}),s.jsx("span",{className:et,children:r.toFixed(1)})]})}),s.jsx(st,{label:t("settings.voice.page.field.speechVolume"),children:e?s.jsx(ds,{value:Math.round(u*100),onValueChange:Z=>d(Z/100),min:0,max:100,step:10,className:ze(us,"tabular-nums")}):s.jsxs("div",{className:"flex h-8 items-center gap-2",children:[s.jsx("input",{type:"range",min:0,max:1,step:.1,value:u,onChange:Z=>d(Number(Z.target.value)),className:ot,"aria-label":t("settings.voice.page.field.speechVolume")}),s.jsx("span",{className:et,children:`${Math.round(u*100)}%`})]})}),s.jsx(st,{label:t("settings.voice.page.field.ttsInputMode"),children:s.jsx(Xt,{value:Q,onChange:V,"aria-label":t("settings.voice.page.field.ttsInputMode"),options:[{value:"sanitized",label:t("settings.voice.page.field.ttsInputModeSanitized")},{value:"raw",label:t("settings.voice.page.field.ttsInputModeRaw")},{value:"summarized",label:t("settings.voice.page.field.ttsInputModeSummarized")}]})})]}),(a==="local"||a==="say"||a==="openai"||a==="openai-compatible")&&s.jsxs("div",{className:bs,children:[(a==="local"||a==="say")&&s.jsx(ct,{checked:x,onChange:w,label:t("settings.voice.page.field.followTextLanguage"),ariaLabel:t("settings.voice.page.field.followTextLanguageAria"),info:t("settings.voice.page.field.followTextLanguageInfo")}),(a==="openai"||a==="openai-compatible")&&s.jsx(ct,{checked:L,onChange:B,label:t("settings.voice.page.field.ttsChunkedMode"),ariaLabel:t("settings.voice.page.field.ttsChunkedModeAria"),info:t("settings.voice.page.tooltip.ttsChunked")})]})]})]}),s.jsxs($e,{settingsItem:"voice.speech-recognition",title:t("settings.voice.page.section.speechRecognition"),contentClassName:"space-y-3",children:[s.jsx(ct,{checked:se,onChange:ve,label:t("settings.voice.page.field.enableVoiceInput"),ariaLabel:t("settings.voice.page.field.enableVoiceInputAria")}),se&&s.jsxs(s.Fragment,{children:[s.jsx(st,{label:t("settings.voice.page.field.provider"),info:s.jsxs("ul",{className:"space-y-1",children:[s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.local")})," ",t("settings.voice.page.tooltip.sttLocal")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.server")})," ",t("settings.voice.page.tooltip.sttServer")]})]}),children:s.jsx(Xt,{value:W,onChange:Y,"aria-label":t("settings.voice.page.field.provider"),options:[{value:"local",label:t("settings.voice.page.provider.local")},{value:"openai-compatible",label:t("settings.voice.page.provider.server")}]})}),W==="local"&&s.jsx(St,{label:t("settings.voice.page.field.model"),controlClassName:"max-w-none",children:s.jsx(Hk,{selectedModelId:J,onSelect:me})}),W==="openai-compatible"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(St,{label:s.jsx("span",{className:ze(!ae.trim()&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.serverUrl")}),info:t("settings.voice.page.field.sttServerUrlHint"),children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("input",{type:"text",value:ae,onChange:Z=>ee(Z.target.value),placeholder:"http://localhost:8001/v1",className:pa}),ae&&s.jsx("button",{type:"button",onClick:()=>ee(""),className:"absolute inset-e-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(te,{name:"close",className:"w-3.5 h-3.5"})})]})}),s.jsx(St,{label:t("settings.voice.page.field.apiKey"),description:t("settings.voice.page.field.apiKeyOptional"),children:s.jsx(Cr,{kind:"stt"})}),s.jsx(St,{label:t("settings.voice.page.field.model"),children:s.jsx("input",{type:"text",value:G,onChange:Z=>le(Z.target.value),placeholder:"deepdml/faster-whisper-large-v3-turbo-ct2",className:pa})}),s.jsx(St,{label:t("settings.voice.page.field.language"),info:t("settings.voice.page.field.sttLanguageHint"),controlClassName:"max-w-[8rem]",children:s.jsx("input",{type:"text",value:fe,onChange:Z=>oe(Z.target.value),placeholder:"auto",className:pa})})]})]})]})]})};function Xk(t){return t.setVoiceApiKey}const vo=[{value:"1800000",label:"30m",ms:1800*1e3},{value:"180000",label:"3m",ms:180*1e3},{value:"7200000",label:"2h",ms:7200*1e3},{value:"28800000",label:"8h",ms:480*60*1e3},{value:"86400000",label:"24h",ms:1440*60*1e3}],yo=[{value:"3600000",label:"1h",ms:3600*1e3},{value:"28800000",label:"8h",ms:480*60*1e3},{value:"43200000",label:"12h",ms:720*60*1e3},{value:"86400000",label:"24h",ms:1440*60*1e3},{value:"604800000",label:"1w",ms:10080*60*1e3},{value:"2592000000",label:"30d",ms:720*60*60*1e3}],ew="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/get-started/create-remote-tunnel/",tw="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/configuration-file/",Ir=[{value:"quick",labelKey:"settings.openchamber.tunnel.option.mode.quick.label",tooltipKey:"settings.openchamber.tunnel.option.mode.quick.tooltip"},{value:"managed-remote",labelKey:"settings.openchamber.tunnel.option.mode.managedRemote.label",tooltipKey:"settings.openchamber.tunnel.option.mode.managedRemote.tooltip"},{value:"managed-local",labelKey:"settings.openchamber.tunnel.option.mode.managedLocal.label",tooltipKey:"settings.openchamber.tunnel.option.mode.managedLocal.tooltip"}],sw=[".yml",".yaml",".json"],nw="settings.openchamber.tunnel.error.invalidConfigExtension",Si=t=>{const e=t.trim().toLowerCase();return sw.some(a=>e.endsWith(a))},aw=t=>t==="ngrok"?"ngrok":"cloudflared",em=()=>{if(typeof window<"u"&&typeof window.__OPENCHAMBER_PLATFORM__=="string"){const e=window.__OPENCHAMBER_PLATFORM__;if(e==="win32"||e==="darwin"||e==="linux")return e}const t=typeof navigator<"u"?`${navigator.platform||""} ${navigator.userAgent||""}`.toLowerCase():"";return t.includes("win")?"win32":t.includes("mac")?"darwin":"linux"},iw=(t,e=em())=>t==="ngrok"?e==="win32"?"winget install ngrok -s msstore":e==="darwin"?"brew install ngrok":"https://ngrok.com/download":e==="win32"?"winget install --id Cloudflare.cloudflared":e==="darwin"?"brew install cloudflared":"https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/",Pr=(t,e)=>{const a=typeof e?.provider=="string"&&e.provider.trim().length>0?e.provider.trim().toLowerCase():t,n=typeof e?.dependency=="string"&&e.dependency.trim().length>0?e.dependency.trim():aw(a),i=typeof e?.platform=="string"&&e.platform.trim().length>0?e.platform.trim():em(),o=typeof e?.installCommand=="string"&&e.installCommand.trim().length>0?e.installCommand.trim():iw(a,i);return{provider:a,dependency:n,installCommand:o}},tm=t=>t==="cloudflare"?"Cloudflare":t==="ngrok"?"Ngrok":t,bd=t=>{const e=De.c(11),{provider:a}=t;let n;e[0]!==a?(n=tm(a),e[0]=a,e[1]=n):n=e[1];const i=n,c=a==="cloudflare"||a==="ngrok"?"text-[var(--status-warning)]":"text-muted-foreground";let u;e[2]!==c?(u=ze("size-4 shrink-0",c),e[2]=c,e[3]=u):u=e[3];let d;e[4]!==u?(d=s.jsx(te,{name:"cloud",className:u}),e[4]=u,e[5]=d):d=e[5];let l;e[6]!==i?(l=s.jsx("span",{children:i}),e[6]=i,e[7]=l):l=e[7];let f;return e[8]!==d||e[9]!==l?(f=s.jsxs("span",{className:"flex items-center gap-2",children:[d,l]}),e[8]=d,e[9]=l,e[10]=f):f=e[10],f},ua=t=>t==="quick"?"quick":t==="managed-remote"?"managed-remote":t==="managed-local"?"managed-local":"quick",el=(t,e,a)=>t.find(i=>i.ms===e)?.value||a,xd=(t,e,a)=>{const n=el(t,e,a);return t.find(i=>i.value===n)?.label||n},vd=t=>{const e=Math.max(0,t),a=Math.floor(e/1e3),n=Math.floor(a/3600),i=Math.floor(a%3600/60),o=a%60;return n>0?`${n}h ${i}m`:i>0?`${i}m ${o}s`:`${o}s`},ow=(t,e)=>Ud(t,e,{hour:"2-digit",precision:"second"}),No=t=>{const e=t.trim();if(!e)return"";try{return(e.includes("://")?new URL(e):new URL(`https://${e}`)).hostname.trim().toLowerCase()}catch{return e.toLowerCase()}},rw=t=>{if(!Array.isArray(t))return[];const e=new Set,a=new Set,n=[];for(const i of t){if(!i||typeof i!="object")continue;const o=i,r=typeof o.id=="string"?o.id.trim():"",c=typeof o.name=="string"?o.name.trim():"",u=No(typeof o.hostname=="string"?o.hostname:"");!r||!c||!u||e.has(r)||a.has(u)||(e.add(r),a.add(u),n.push({id:r,name:c,hostname:u}))}return n},lw=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,cw=()=>{const{t}=Ee(),e=re(_=>_.timeFormatPreference),a=m.useCallback(_=>t(_),[t]),[n,i]=m.useState("checking"),o=Hi(n==="checking"),[r,c]=m.useState(!1),[u,d]=m.useState(null),[l,f]=m.useState(null),[p,g]=m.useState(null),[h,y]=m.useState(null),[b,x]=m.useState(null),[w,S]=m.useState(!1),[v,A]=m.useState(!1),[I,N]=m.useState(!1),[k,P]=m.useState("cloudflare"),[j,C]=m.useState(()=>Pr("cloudflare")),[E,F]=m.useState([]),[O,K]=m.useState("quick"),[D,M]=m.useState(null),[T,R]=m.useState([]),[$,z]=m.useState({}),[Q,V]=m.useState(""),[L,B]=m.useState({}),[W,Y]=m.useState(new Set),[ae,ee]=m.useState(!1),[G,le]=m.useState(""),[J,me]=m.useState(""),[fe,oe]=m.useState(""),[pe,se]=m.useState(1800*1e3),[ve,be]=m.useState(480*60*1e3),[ne,we]=m.useState([]),Ne=Kd(!!u?.bootstrapExpiresAt||ne.length>0),[Ie,Ce]=m.useState(null),Me=t(nw),he=m.useRef(null),Pe=m.useMemo(()=>D?!Si(D):!1,[D]),Re=m.useMemo(()=>T.find(_=>_.id===Q)||T[0]||null,[T,Q]),ce=m.useMemo(()=>ne.map(_=>{const ge=_.expiresAt<=Ne,Ae=_.status==="active"&&!ge,Te=Ae?vd(_.expiresAt-Ne):_.inactiveReason==="expired"||ge?"expired":"inactive",Ge=Te==="expired"?t("settings.openchamber.tunnel.state.expired"):_.inactiveReason==="tunnel-revoked"?t("settings.openchamber.tunnel.state.revoked"):t("settings.openchamber.tunnel.state.inactive"),ue=ua(_.mode);return{..._,isActive:Ae,mode:ue,remainingTextForSession:Te,inactiveLabel:Ge}}),[Ne,ne,t]),je=u?.bootstrapExpiresAt&&u.bootstrapExpiresAt>Ne?vd(u.bootstrapExpiresAt-Ne):t("settings.openchamber.tunnel.state.expired"),de=m.useMemo(()=>u?.connectUrl?u.bootstrapExpiresAt===null?!0:u.bootstrapExpiresAt>Ne:!1,[Ne,u?.bootstrapExpiresAt,u?.connectUrl]),ie=m.useMemo(()=>!u||n!=="active"&&n!=="stopping"?!1:l===O,[l,n,u,O]),xe=m.useMemo(()=>!u||n!=="active"||!l?!1:l!==O,[l,n,u,O]),Se=m.useMemo(()=>{if(typeof Ie=="number"&&Number.isFinite(Ie)&&Ie>0)return Ie;if(typeof window>"u")return null;const ge=qi()||window.location.href;let Ae=0;try{Ae=Number(new URL(ge).port)}catch{Ae=Number(window.location.port)}return Number.isFinite(Ae)&&Ae>0?Ae:null},[Ie]),Le=m.useMemo(()=>E.find(_=>_.provider===k)??null,[E,k]),Ue=m.useMemo(()=>{const _=new Set(Le?.modes?.map(ge=>ge.key).filter(ge=>ge==="quick"||ge==="managed-remote"||ge==="managed-local"));return _.size===0?Ir:Ir.filter(ge=>_.has(ge.value))},[Le]),Ye=m.useMemo(()=>Ue.some(_=>_.value==="managed-remote"||_.value==="managed-local"),[Ue]),lt=m.useMemo(()=>j.provider===k?j:Pr(k),[j,k]),at=m.useCallback(async _=>{await Ks(_)},[]),ut=m.useCallback((_,ge)=>(C(Pr(ge,_)),_.available===!0),[]),vt=m.useCallback(async(_,ge)=>{try{const Ae=await $t("/api/openchamber/tunnel/check",{query:{provider:_},...ge?{signal:ge}:{}});if(!Ae.ok)return null;const Te=await Ae.json();if(ge?.aborted)return null;const Ge=ut(Te,_);return i(ue=>ue==="checking"||ue==="starting"||ue==="active"||ue==="stopping"?ue:Ge?"idle":"not-available"),Ge}catch{return null}},[ut]),We=m.useCallback(async _=>{try{const[ge,Ae,Te,Ge]=await Promise.all([$t("/api/openchamber/tunnel/check",{signal:_}),$t("/api/openchamber/tunnel/status",{signal:_}),fn(),$t("/api/openchamber/tunnel/providers",{signal:_})]),ue=await ge.json(),Fe=await Ae.json(),pt=Te??{},At=Ge.ok?await Ge.json():{},Nt=Fe.ttlConfig?.bootstrapTtlMs??(pt.tunnelBootstrapTtlMs===void 0?1800*1e3:pt.tunnelBootstrapTtlMs),zt=typeof Fe.ttlConfig?.sessionTtlMs=="number"?Fe.ttlConfig.sessionTtlMs:pt.tunnelSessionTtlMs??480*60*1e3,es=ua(Fe.mode??pt.tunnelMode),ss=pt.tunnelProvider??"cloudflare",fs=pt.managedLocalTunnelConfigPath??null,Gt=ut(ue,ss),ms=rw(Fe?.managedRemoteTunnelPresets),cs=typeof Fe.managedRemoteTunnelHostname=="string"?Fe.managedRemoteTunnelHostname:"",ps=ms.length>0?ms:cs?[{id:`legacy-${No(cs)}`,name:cs,hostname:No(cs)}]:[],hs=ps[0]?.id||"";if(c(Fe.enterpriseMode===!0),se(Nt),be(zt),P(ss),F(Array.isArray(At?.providers)?At.providers:[]),K(es),M(fs),R(ps),V(hs),we(Array.isArray(Fe.activeSessions)?Fe.activeSessions:[]),f(Fe.activeTunnelMode?ua(Fe.activeTunnelMode):Fe.active&&Fe.mode?ua(Fe.mode):null),Y(new Set(Array.isArray(Fe.managedRemoteTunnelTokenPresetIds)?Fe.managedRemoteTunnelTokenPresetIds:[])),Ce(typeof Fe.localPort=="number"?Fe.localPort:null),Fe.active&&Fe.url){d({url:Fe.url,connectUrl:null,bootstrapExpiresAt:typeof Fe.bootstrapExpiresAt=="number"?Fe.bootstrapExpiresAt:null}),i("active");return}i(Gt?"idle":"not-available")}catch{_.aborted||(i("error"),y(t("settings.openchamber.tunnel.toast.checkAvailabilityFailed")))}},[ut,t]);m.useEffect(()=>{const _=new AbortController;return We(_.signal),()=>_.abort()},[We]),m.useEffect(()=>{if(!u?.connectUrl){g(null);return}let _=!1;return gu.toDataURL(u.connectUrl,{width:256,margin:2,color:{dark:"#000000",light:"#ffffff"}}).then(ge=>{_||g(ge)}).catch(()=>{_||g(null)}),()=>{_=!0}},[u?.connectUrl]),m.useEffect(()=>{if(n==="starting"||n==="stopping"||n==="checking")return;let _=!1;const ge=async()=>{try{const Te=await $t("/api/openchamber/tunnel/status");if(!Te.ok||_)return;const Ge=await Te.json();if(_)return;we(Array.isArray(Ge.activeSessions)?Ge.activeSessions:[]),Y(new Set(Array.isArray(Ge.managedRemoteTunnelTokenPresetIds)?Ge.managedRemoteTunnelTokenPresetIds:[])),Ce(typeof Ge.localPort=="number"?Ge.localPort:null)}catch{}},Ae=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||ge()},5e3);return()=>{_=!0,window.clearInterval(Ae)}},[n]);const Ze=m.useCallback(async _=>{N(!0);try{await jt(_),Object.prototype.hasOwnProperty.call(_,"tunnelMode")&&_.tunnelMode&&K(_.tunnelMode),Object.prototype.hasOwnProperty.call(_,"tunnelProvider")&&typeof _.tunnelProvider=="string"&&P(_.tunnelProvider),Object.prototype.hasOwnProperty.call(_,"managedLocalTunnelConfigPath")&&M(_.managedLocalTunnelConfigPath??null),Object.prototype.hasOwnProperty.call(_,"managedRemoteTunnelPresets")&&_.managedRemoteTunnelPresets&&R(_.managedRemoteTunnelPresets)}catch{q.error(t("settings.openchamber.tunnel.toast.saveSettingsFailed"))}finally{N(!1)}},[t]),Xe=m.useCallback(async(_,ge)=>{A(!0);try{await jt({tunnelBootstrapTtlMs:_,tunnelSessionTtlMs:ge})}catch{q.error(t("settings.openchamber.tunnel.toast.saveTtlFailed"))}finally{A(!1)}},[t]),it=m.useCallback(async _=>{const ge=_.token.trim();if(ge)try{const Ae={...L,[_.presetId]:ge};await jt({managedRemoteTunnelPresetTokens:Ae}),Y(Te=>{const Ge=new Set(Te);return Ge.add(_.presetId),Ge})}catch{q.error(t("settings.openchamber.tunnel.toast.saveTokenFailed"))}},[L,t]),dt=m.useCallback(async _=>{x(null),y(null);const ge=E.find(Te=>Te.provider===_),Ae=ge?.modes?.some(Te=>Te.key===O)?O:ua(ge?.modes?.[0]?.key);await Ze({tunnelProvider:_,tunnelMode:Ae}),vt(_)},[E,vt,Ze,O]),Be=m.useCallback(async()=>{const _=await pl({filters:[{name:"Config",extensions:["yml","yaml","json"]}]});if(_.success&&typeof _.path=="string"&&_.path.trim().length>0){const ge=_.path.trim();if(!Si(ge)){q.error(Me);return}M(ge),await Ze({managedLocalTunnelConfigPath:ge});return}he.current?.click()},[Me,Ze]),ot=m.useCallback(_=>{const ge=_.trim();M(ge.length>0?ge:null)},[]),et=m.useCallback(async()=>{if(D&&!Si(D)){q.error(Me);return}await Ze({managedLocalTunnelConfigPath:D})},[Me,D,Ze]),ye=m.useCallback(async()=>{M(null),await Ze({managedLocalTunnelConfigPath:null})},[Ze]),Z=m.useCallback(async _=>{const ge=_.target.files?.[0];if(!ge)return;const Ae=ge.name.trim();if(Ae.length!==0){if(!Si(Ae)){q.error(Me);return}M(Ae),await Ze({managedLocalTunnelConfigPath:Ae}),_.target.value=""}},[Me,Ze]),Oe=m.useCallback(async()=>{if(y(null),x(null),O==="managed-local"&&D&&!Si(D)){y(Me),q.error(Me);return}i("starting");try{let _="",ge="";if(O==="managed-remote"){if(!Re){i("idle"),x(t("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst")),q.error(t("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst"));return}_=Re.hostname,ge=(L[Re.id]||"").trim(),await Ze({tunnelMode:"managed-remote",managedRemoteTunnelPresets:T})}const Ae=await $t("/api/openchamber/tunnel/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:k,mode:O,...O==="managed-remote"&&Re?{managedRemoteTunnelPresetId:Re.id,managedRemoteTunnelPresetName:Re.name}:{},...O==="managed-remote"&&_?{managedRemoteTunnelHostname:_}:{},...O==="managed-remote"&&ge?{managedRemoteTunnelToken:ge}:{},...O==="managed-local"&&D?{configPath:D}:{}})}),Te=await Ae.json();if(!Ae.ok||!Te.ok){if(O==="managed-remote"&&typeof Te.error=="string"&&Te.error.includes("Managed remote tunnel token is required")){i("idle"),x(t("settings.openchamber.tunnel.toast.managedRemoteTokenRequiredBeforeStarting")),q.error(t("settings.openchamber.tunnel.toast.addManagedRemoteTokenBeforeStarting"));return}i("error"),y(Te.error||t("settings.openchamber.tunnel.toast.startFailed")),q.error(Te.error||t("settings.openchamber.tunnel.toast.startFailed"));return}const Ge=typeof Te.url=="string"?Te.url:"";if(!Ge){i("error"),y(t("settings.openchamber.tunnel.toast.startedButNoPublicUrl")),q.error(t("settings.openchamber.tunnel.toast.startedButNoPublicUrl"));return}if(d({url:Ge,connectUrl:typeof Te.connectUrl=="string"?Te.connectUrl:null,bootstrapExpiresAt:typeof Te.bootstrapExpiresAt=="number"?Te.bootstrapExpiresAt:null}),f(Te.activeTunnelMode?ua(Te.activeTunnelMode):Te.mode?ua(Te.mode):O),we(Array.isArray(Te.activeSessions)?Te.activeSessions:[]),Array.isArray(Te.managedRemoteTunnelTokenPresetIds)&&Y(new Set(Te.managedRemoteTunnelTokenPresetIds)),typeof Te.localPort=="number"&&Ce(Te.localPort),typeof Te.mode=="string"&&K(ua(Te.mode)),i("active"),Te.replacedTunnel){const ue=typeof Te.revokedBootstrapCount=="number"?Te.revokedBootstrapCount:0,Fe=typeof Te.invalidatedSessionCount=="number"?Te.invalidatedSessionCount:0;ue===1&&Fe===1?q.warning(t("settings.openchamber.tunnel.toast.replacedTunnelSingleSingle")):ue===1?q.warning(t("settings.openchamber.tunnel.toast.replacedTunnelSingleManySessions",{invalidatedSessionCount:Fe})):Fe===1?q.warning(t("settings.openchamber.tunnel.toast.replacedTunnelManyLinksSingleSession",{revokedBootstrapCount:ue})):q.warning(t("settings.openchamber.tunnel.toast.replacedTunnelManyMany",{revokedBootstrapCount:ue,invalidatedSessionCount:Fe}))}else q.success(t("settings.openchamber.tunnel.toast.linkReady"))}catch{i("error"),y(t("settings.openchamber.tunnel.toast.startFailed")),q.error(t("settings.openchamber.tunnel.toast.startFailed"))}},[Me,T,Ze,Re,L,t,k,O,D]),Ve=m.useCallback(async()=>{i("stopping");try{await $t("/api/openchamber/tunnel/stop",{method:"POST"});const _=await $t("/api/openchamber/tunnel/status");if(_.ok){const ge=await _.json();we(Array.isArray(ge.activeSessions)?ge.activeSessions:[]),Y(new Set(Array.isArray(ge.managedRemoteTunnelTokenPresetIds)?ge.managedRemoteTunnelTokenPresetIds:[])),Ce(typeof ge.localPort=="number"?ge.localPort:null)}d(null),f(null),g(null),i("idle"),q.success(t("settings.openchamber.tunnel.toast.stopped"))}catch{i("error"),y(t("settings.openchamber.tunnel.toast.stopFailed")),q.error(t("settings.openchamber.tunnel.toast.stopFailed"))}},[t]),X=m.useCallback(async()=>{if(u?.connectUrl)try{await navigator.clipboard.writeText(u.connectUrl),S(!0),q.success(t("settings.openchamber.tunnel.toast.connectLinkCopied")),setTimeout(()=>S(!1),2e3)}catch{q.error(t("settings.openchamber.tunnel.toast.copyUrlFailed"))}},[t,u?.connectUrl]),_e=m.useCallback(async _=>{const ge=vo.find(Ae=>Ae.value===_);ge&&(se(ge.ms),await Xe(ge.ms,ve))},[Xe,ve]),nt=m.useCallback(async _=>{const ge=yo.find(Ae=>Ae.value===_);!ge||ge.ms===null||(be(ge.ms),await Xe(pe,ge.ms))},[pe,Xe]),ht=m.useCallback(async _=>{x(null),y(null),n!=="active"&&n!=="stopping"&&n!=="starting"&&i("idle"),await Ze({tunnelMode:_,managedRemoteTunnelPresets:T})},[T,Ze,n]),yt=m.useCallback(async(_,ge)=>{try{await jt({managedRemoteTunnelPresets:ge})}catch{q.error(t("settings.openchamber.tunnel.toast.saveSelectedManagedRemoteFailed"))}},[t]),kt=m.useCallback(_=>{const ge=T.find(Ae=>Ae.id===_);ge&&(V(ge.id),x(null),yt(ge,T))},[T,yt]),He=m.useCallback(async()=>{const _=G.trim(),ge=No(J),Ae=fe.trim();if(!_){q.error(t("settings.openchamber.tunnel.toast.tunnelNameRequired"));return}if(!ge){q.error(t("settings.openchamber.tunnel.toast.managedRemoteHostnameRequired"));return}if(!Ae){q.error(t("settings.openchamber.tunnel.toast.managedRemoteTokenRequired"));return}if(T.some(ue=>ue.hostname===ge)){q.error(t("settings.openchamber.tunnel.toast.hostnameAlreadyExists"));return}const Te={id:lw(),name:_,hostname:ge},Ge=[...T,Te];R(Ge),V(Te.id),z(ue=>({...ue,[Te.id]:!0})),B(ue=>({...ue,[Te.id]:Ae})),x(null),ee(!1),le(""),me(""),oe(""),await Ze({tunnelMode:"managed-remote",managedRemoteTunnelPresets:Ge,managedRemoteTunnelPresetTokens:{...L,[Te.id]:Ae}}),await it({presetId:Te.id,presetName:Te.name,hostname:Te.hostname,token:Ae}),q.success(t("settings.openchamber.tunnel.toast.managedRemoteSaved"))},[T,J,G,fe,it,Ze,L,t]),Je=m.useCallback(async _=>{const ge=T.find(Fe=>Fe.id===_);if(!ge)return;const Ae=T.filter(Fe=>Fe.id!==ge.id),Te=Ae[0]?.id||"",Ge=Q===ge.id?Te:Q,ue=Object.fromEntries(Object.entries(L).filter(([Fe,pt])=>Fe!==ge.id&&pt.trim().length>0));R(Ae),V(Ge),z(Fe=>{const pt={...Fe};return delete pt[ge.id],pt}),B(Fe=>{const pt={...Fe};return delete pt[ge.id],pt}),Y(Fe=>{const pt=new Set(Fe);return pt.delete(ge.id),pt}),x(null),await Ze({managedRemoteTunnelPresets:Ae,managedRemoteTunnelPresetTokens:ue}),q.success(t("settings.openchamber.tunnel.toast.managedRemoteRemoved"))},[T,Ze,Q,L,t]);if(n==="checking")return s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("span",{className:ze("h-1.5 w-1.5 rounded-full bg-current",o),"aria-label":t("settings.openchamber.tunnel.state.loading")})});if(r)return s.jsx($e,{title:t("settings.openchamber.tunnel.title"),divider:!1,children:s.jsx("p",{className:Ln,children:t("settings.openchamber.tunnel.enterpriseMode")})});const mt=I||n==="starting"||n==="stopping",Qe=a(Ir.find(_=>_.value===O)?.labelKey??"settings.openchamber.tunnel.option.mode.quick.label");return s.jsxs(s.Fragment,{children:[s.jsxs($e,{title:t("settings.layout.tunnel.section.setup"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.openchamber.tunnel.description")}),s.jsx("p",{children:t("settings.openchamber.tunnel.note.serverSideEnforced")}),s.jsx("p",{children:t("settings.openchamber.tunnel.note.connectLinksOneTime")})]}),divider:!1,contentClassName:"space-y-4",children:[n==="not-available"&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-[var(--status-warning)]/10 p-3",children:[s.jsx(te,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:_d,children:t("settings.openchamber.tunnel.notAvailable.dependencyNotFound",{dependency:lt.dependency})}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.tunnel.notAvailable.installHint")}),s.jsx("code",{className:"typography-code block rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:lt.installCommand})]})]}),s.jsxs("div",{children:[s.jsx(st,{label:t("settings.openchamber.tunnel.field.provider"),settingsItem:"tunnel.provider",children:s.jsxs(Pt,{value:k,onValueChange:_=>{dt(_)},disabled:mt,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.openchamber.tunnel.field.providerPlaceholder"),children:tm(k)})}),s.jsxs(It,{children:[E.length>0?E.map(_=>s.jsx(bt,{value:_.provider,children:s.jsx(bd,{provider:_.provider})},_.provider)):s.jsx(bt,{value:"cloudflare",children:s.jsx(bd,{provider:"cloudflare"})}),s.jsx(bt,{value:"__more-soon",disabled:!0,children:t("settings.openchamber.tunnel.option.moreProvidersSoon")})]})]})}),s.jsx(st,{label:t("settings.openchamber.tunnel.field.tunnelType"),settingsItem:"tunnel.type",children:s.jsx(Xt,{value:O,"aria-label":t("settings.openchamber.tunnel.field.tunnelType"),onChange:_=>{ht(_)},options:Ue.map(_=>({value:_.value,label:a(_.labelKey),tooltip:a(_.tooltipKey),disabled:mt}))})})]}),O==="quick"&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-[var(--status-warning)]/10 p-3",children:[s.jsx(te,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.option.mode.quick.tooltip")}),Ye&&s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.warning.quickModeReliability")})]})]}),O==="managed-remote"&&s.jsxs("p",{className:_t,children:[t("settings.openchamber.tunnel.note.managedRemoteRequiresDomain")," ",s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 text-[var(--primary-text)] underline-offset-4 hover:underline",onClick:()=>{at(ew)},children:[t("settings.openchamber.tunnel.actions.openManagedRemoteDocs"),s.jsx(te,{name:"external-link",className:"size-3.5"})]})]}),O==="managed-local"&&s.jsxs("p",{className:_t,children:[t("settings.openchamber.tunnel.note.managedLocalUsesConfig")," ",s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 text-[var(--primary-text)] underline-offset-4 hover:underline",onClick:()=>{at(tw)},children:[t("settings.openchamber.tunnel.actions.openManagedLocalDocs"),s.jsx(te,{name:"external-link",className:"size-3.5"})]})]}),O==="managed-remote"&&s.jsxs("div",{"data-settings-item":"tunnel.managed-remote",className:"oc-tile space-y-2 rounded-lg p-3",children:[typeof Se=="number"&&s.jsx("div",{className:"rounded-md bg-[var(--status-info-background)]/60 px-2 py-1.5",children:s.jsxs("p",{className:"typography-meta text-[var(--status-info)]",children:[t("settings.openchamber.tunnel.note.cloudflareConnectorTarget")," ",s.jsxs("code",{children:["http://localhost:",Se]})]})}),s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[s.jsx($a,{children:t("settings.openchamber.tunnel.section.savedManagedRemoteTunnels")}),s.jsxs(H,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>ee(_=>!_),disabled:n==="starting"||n==="stopping"||I,children:[s.jsx(te,{name:"add",className:"h-3.5 w-3.5"}),t("settings.common.actions.create")]})]}),T.length>0?s.jsx("div",{className:"oc-tile-inset overflow-hidden rounded-md",children:T.map((_,ge)=>{const Ae=L[_.id]||"",Te=W.has(_.id),Ge=$[_.id]??!1;return s.jsx("div",{className:ze(ge<T.length-1&&"border-b border-[var(--interactive-border)]"),children:s.jsxs(ha,{open:Ge,onOpenChange:ue=>{z(Fe=>({...Fe,[_.id]:ue})),ue&&kt(_.id)},className:"py-1.5",children:[s.jsxs("div",{className:"flex items-start gap-2 px-3",children:[s.jsxs(ba,{type:"button",className:"group flex-1 justify-start gap-2 rounded-md px-0 py-1 pe-1 text-start hover:bg-[var(--interactive-hover)]",disabled:n==="starting"||n==="stopping"||I,children:[Ge?s.jsx(te,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):s.jsx(te,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label min-w-0 flex-1 truncate text-foreground",children:_.name})]}),s.jsx(H,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-[var(--status-error)]","aria-label":t("settings.openchamber.tunnel.actions.removePresetAria",{name:_.name}),onClick:()=>{Je(_.id)},disabled:n==="starting"||n==="stopping"||I,children:s.jsx(te,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),s.jsx(xa,{className:"pt-1.5",children:s.jsxs("div",{className:"space-y-1 px-3 pb-2",children:[s.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[t("settings.openchamber.tunnel.field.hostnameLabel")," ",s.jsx("code",{children:_.hostname})]}),s.jsx(qe,{type:"password",value:Ae,onChange:ue=>{const Fe=ue.target.value;x(null),B(pt=>({...pt,[_.id]:Fe}))},onBlur:ue=>{const Fe=ue.currentTarget.value.trim();Fe&&it({presetId:_.id,presetName:_.name,hostname:_.hostname,token:Fe})},placeholder:t(Te?"settings.openchamber.tunnel.field.savedTokenAvailablePlaceholder":"settings.openchamber.tunnel.field.pasteTokenPlaceholder"),className:"h-7",disabled:n==="starting"||n==="stopping"}),s.jsx("div",{className:"flex items-center justify-end",children:s.jsx(H,{variant:"ghost",size:"xs",className:"!font-normal",disabled:n==="starting"||n==="stopping"||Ae.trim().length===0,onClick:()=>{it({presetId:_.id,presetName:_.name,hostname:_.hostname,token:Ae})},children:t("settings.openchamber.tunnel.actions.saveToken")})})]})})]})},_.id)})}):s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t("settings.openchamber.tunnel.empty.noManagedRemoteTunnels")}),ae&&s.jsxs("div",{className:"oc-tile-inset space-y-2 rounded-md p-2",children:[s.jsx(qe,{value:G,onChange:_=>le(_.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetNamePlaceholder"),className:"h-7",disabled:I||n==="starting"||n==="stopping"}),s.jsx(qe,{value:J,onChange:_=>me(_.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetHostnamePlaceholder"),className:"h-7",disabled:I||n==="starting"||n==="stopping"}),s.jsx(qe,{type:"password",value:fe,onChange:_=>oe(_.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetTokenPlaceholder"),className:"h-7",disabled:I||n==="starting"||n==="stopping"}),typeof Se=="number"&&s.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[t("settings.openchamber.tunnel.note.cloudflareConnectorTargetUse")," ",s.jsxs("code",{children:["http://localhost:",Se]}),"."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(H,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{He()},disabled:I||n==="starting"||n==="stopping",children:t("settings.common.actions.saveChanges")}),s.jsx(H,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{ee(!1),le(""),me(""),oe("")},disabled:I||n==="starting"||n==="stopping",children:t("settings.common.actions.cancel")})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("settings.openchamber.tunnel.note.tokensSavedPerTunnel")}),s.jsx(ts,{children:t("settings.openchamber.tunnel.tooltip.tokensSavedPath")})]}),!Re&&b&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:b})]}),O==="managed-local"&&s.jsx("div",{"data-settings-item":"tunnel.managed-local-config",className:"oc-tile space-y-2 rounded-lg p-3",children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:Vt,children:t("settings.openchamber.tunnel.field.configurationFile")}),s.jsx("input",{ref:he,type:"file",accept:".yml,.yaml,.json",className:"hidden",onChange:_=>{Z(_)}}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qe,{value:D||"",onChange:_=>{ot(_.target.value)},onBlur:()=>{et()},placeholder:t("settings.openchamber.tunnel.field.configurationFilePlaceholder"),className:"h-7",disabled:n==="starting"||n==="stopping"||I}),s.jsx(H,{variant:"outline",size:"xs",className:"h-7 w-7 p-0","aria-label":t("settings.openchamber.tunnel.actions.browseConfigFileAria"),onClick:()=>{Be()},disabled:n==="starting"||n==="stopping"||I,children:s.jsx(te,{name:"folder",className:"size-3.5"})}),D&&s.jsx(H,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0","aria-label":t("settings.openchamber.tunnel.actions.clearConfigFileAria"),onClick:()=>{ye()},disabled:n==="starting"||n==="stopping"||I,children:s.jsx(te,{name:"close",className:"size-3.5"})})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t(D?"settings.openchamber.tunnel.note.customConfigUsed":"settings.openchamber.tunnel.note.defaultConfigUsed")}),Pe&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Me})]})})]}),s.jsxs($e,{title:t("settings.layout.tunnel.section.connection"),settingsItem:"tunnel.start",contentClassName:"space-y-4",children:[!ie&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:_t,children:t("settings.openchamber.tunnel.note.startModeAndGenerateLink",{mode:Qe})}),O==="managed-remote"&&s.jsx(st,{label:t("settings.openchamber.tunnel.field.managedRemoteTunnelToConnect"),children:s.jsxs(Pt,{value:Q||(T[0]?.id??""),onValueChange:_=>{kt(_)},disabled:mt||T.length<=1,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.openchamber.tunnel.field.selectSavedTunnelPlaceholder"),children:Re?.name})}),s.jsx(It,{fitContent:!0,children:T.map(_=>s.jsx(bt,{value:_.id,children:_.name},_.id))})]})}),xe&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-[var(--status-warning-background)] p-3",children:[s.jsx(te,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.warning.replacesActiveTunnel")})]}),s.jsx(H,{size:"sm",onClick:Oe,disabled:n==="starting"||I||O==="managed-remote"&&!Re||O==="managed-local"&&Pe,children:n==="starting"?s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"loader-4",className:"size-3.5 animate-spin"})," ",t("settings.openchamber.tunnel.actions.startingTunnel")]}):t("settings.openchamber.tunnel.actions.startTunnel")})]}),ie&&u&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--status-success)]"}),s.jsx("p",{className:"typography-ui-label font-medium text-foreground",children:t("settings.openchamber.tunnel.state.tunnelReady")})]}),s.jsx(St,{label:t("settings.openchamber.tunnel.field.publicUrlHint"),controlClassName:"max-w-none",children:s.jsx("code",{className:"typography-code block min-w-0 truncate rounded-md oc-tile-inset px-2 py-1.5 text-xs text-foreground",title:u.url,children:u.url})}),de&&u.connectUrl&&s.jsxs("div",{className:"flex flex-col gap-4 @xl:flex-row @xl:items-start",children:[s.jsxs(St,{label:t("settings.openchamber.tunnel.field.connectLink"),description:`${t("settings.openchamber.tunnel.field.expires")}: ${u.bootstrapExpiresAt?je:t("settings.openchamber.tunnel.state.never")}`,descriptionPlacement:"after",className:"min-w-0 flex-1",controlClassName:"max-w-none",children:[s.jsx("code",{className:"typography-code block min-w-0 flex-1 truncate rounded-md oc-tile-inset px-2 py-1.5 text-xs text-foreground",title:u.connectUrl,children:u.connectUrl}),s.jsxs(H,{size:"sm",variant:"ghost",onClick:X,className:"shrink-0 gap-1.5",children:[w?s.jsx(te,{name:"check",className:"size-3.5 text-[var(--status-success)]"}):s.jsx(te,{name:"file-copy",className:"size-3.5"}),t(w?"settings.openchamber.tunnel.actions.copied":"settings.common.actions.copyAll")]})]}),s.jsxs("div",{className:"flex shrink-0 flex-col items-center gap-2 oc-tile rounded-lg p-3",children:[p?s.jsx("img",{src:p,alt:t("settings.openchamber.tunnel.field.connectQrAlt"),className:"size-40"}):s.jsx("div",{className:"size-40 rounded bg-muted/30"}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("settings.openchamber.tunnel.note.scanQrToConnect")})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(H,{size:"sm",onClick:Oe,disabled:n==="stopping"||I||O==="managed-local"&&Pe,children:[s.jsx(te,{name:"restart",className:"size-3.5"}),t("settings.openchamber.tunnel.actions.newConnectLink")]}),s.jsx(H,{size:"sm",variant:"ghost",onClick:Ve,disabled:n==="stopping"||I,className:"text-[var(--status-error)]",children:n==="stopping"?s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"loader-4",className:"size-3.5 animate-spin"})," ",t("settings.openchamber.tunnel.actions.stopping")]}):t("settings.openchamber.tunnel.actions.stopTunnel")})]})]}),n==="error"&&h&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:h}),s.jsx(H,{size:"sm",variant:"ghost",onClick:Oe,children:t("settings.openchamber.tunnel.actions.retry")})]})]}),s.jsxs($e,{title:t("settings.layout.tunnel.section.lifetime"),settingsItem:"tunnel.ttl",children:[s.jsx(st,{label:t("settings.openchamber.tunnel.field.connectLinkTtl"),children:s.jsxs(Pt,{value:el(vo,pe,"1800000"),onValueChange:_=>{_e(_)},disabled:v||mt,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{className:"truncate",children:xd(vo,pe,"1800000")})}),s.jsx(It,{children:vo.map(_=>s.jsx(bt,{value:_.value,children:_.label},_.value))})]})}),s.jsx(st,{label:t("settings.openchamber.tunnel.field.tunnelSessionTtl"),children:s.jsxs(Pt,{value:el(yo,ve,"28800000"),onValueChange:_=>{nt(_)},disabled:v||mt,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{className:"truncate",children:xd(yo,ve,"28800000")})}),s.jsx(It,{children:yo.map(_=>s.jsx(bt,{value:_.value,children:_.label},_.value))})]})})]}),ce.length>0&&s.jsx($e,{title:t("settings.openchamber.tunnel.section.redeemedAccessLinks"),contentClassName:"space-y-1",children:ce.map(_=>{const ge=_.mode==="quick",Ae=_.mode==="managed-remote",Te=ge?"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-[var(--status-warning)]":Ae?"border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)]":"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",Ge=_.isActive?ge?"text-[var(--status-warning)]":Ae?"text-[var(--status-info)]":"text-[var(--status-success)]":"text-muted-foreground/50",ue=t(ge?"settings.openchamber.tunnel.badge.quick":Ae?"settings.openchamber.tunnel.badge.remote":"settings.openchamber.tunnel.badge.local");return s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 oc-tile rounded-md px-3 py-2",children:[s.jsx(te,{name:"checkbox-blank-circle-fill",className:ze("size-2.5 shrink-0",Ge)}),s.jsx("span",{className:ze("rounded-full px-2 py-0.5 text-[10px] font-medium",Te),children:ue}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.tunnel.session.redeemedAt",{time:ow(_.createdAt,e)})}),s.jsx("span",{className:"typography-meta text-foreground",children:_.isActive?t("settings.openchamber.tunnel.session.expiresIn",{remaining:_.remainingTextForSession}):_.inactiveLabel===t("settings.openchamber.tunnel.state.inactive")?t("settings.openchamber.tunnel.state.inactive"):t("settings.openchamber.tunnel.session.inactiveWithReason",{reason:_.inactiveLabel})})]},_.sessionId)})})]})},dw=()=>{const{t}=Ee(),e=Ki(h=>h.opencodeBinary),[a,n]=Ke.useState(""),[i,o]=Ke.useState(!0),[r,c]=Ke.useState(!1),u=re(h=>h.showOpenCodeUpdateNotifications),d=re(h=>h.setShowOpenCodeUpdateNotifications);Ke.useEffect(()=>{let h=!1;return(async()=>{try{const y=await fn();if(h||!y)return;n(y.opencodeBinary??"")}catch{}finally{h||o(!1)}})(),()=>{h=!0}},[]);const l=Ke.useCallback(async()=>{if(!(typeof window>"u")&&is())try{const h=await pl();h.success&&h.path&&h.path.trim().length>0&&n(h.path.trim())}catch{}},[]),f=Ke.useCallback(async()=>{c(!0);try{const h=a.trim(),y=h.length>=2&&(h.startsWith('"')&&h.endsWith('"')||h.startsWith("'")&&h.endsWith("'"))?h.slice(1,-1).trim():h;await jt({opencodeBinary:y}),await Ed({message:t("settings.openchamber.opencodeCli.actions.restartingOpenCode"),mode:"projects",scopes:["all"]})}catch(h){if(h?.requiresManualRestart){q.warning(t("settings.openchamber.opencodeCli.restart.manualRequired"));return}q.error(t("settings.openchamber.opencodeCli.restart.failed"))}finally{c(!1)}},[t,a]),p=Ke.useCallback(async()=>{c(!0);try{await fu(t)}finally{c(!1)}},[t]),g=Ke.useCallback(h=>{d(h),jt({showOpenCodeUpdateNotifications:h})},[d]);return s.jsx($e,{title:t("settings.openchamber.opencodeCli.title"),children:s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs(st,{settingsItem:"sessions.opencode-binary",label:t("settings.openchamber.opencodeCli.field.binaryPath"),info:s.jsxs(s.Fragment,{children:[t("settings.openchamber.opencodeCli.tipPrefix")," ",s.jsx("span",{className:"font-mono",children:"OPENCODE_BINARY"})," ",t("settings.openchamber.opencodeCli.tipMiddle")," ",s.jsx("span",{className:"font-mono",children:"~/.config/openchamber/settings.json"}),"."]}),description:e?t("settings.openchamber.opencodeCli.field.pinnedByAdministrator"):void 0,alignEnd:!1,controlClassName:"@xl:w-[20rem]",children:[s.jsx(qe,{value:e??a,onChange:h=>n(h.target.value),placeholder:t("settings.openchamber.opencodeCli.field.binaryPathPlaceholder"),disabled:i||r||e!==null,className:"h-8 min-w-0 flex-1 font-mono text-xs"}),s.jsx(H,{type:"button",variant:"outline",size:"xs",onClick:l,disabled:i||r||!is()||e!==null,className:Yt,"aria-label":t("settings.openchamber.opencodeCli.actions.browseAria"),title:t("settings.openchamber.opencodeCli.actions.browse"),children:s.jsx(te,{name:"folder",className:"h-4 w-4"})})]}),s.jsxs(_i,{className:bs,children:[s.jsx(ct,{settingsItem:"sessions.opencode-update-notifications",checked:u,onChange:g,label:t("settings.openchamber.opencodeCli.field.showUpdateNotifications"),ariaLabel:t("settings.openchamber.opencodeCli.field.showUpdateNotificationsAria")}),s.jsxs("div",{className:"flex flex-wrap justify-start gap-2 py-1.5","data-settings-item":"sessions.opencode-restart",children:[s.jsx(H,{type:"button",size:"xs",onClick:f,disabled:i||r||e!==null,className:"shrink-0 !font-normal",children:t(r?"settings.openchamber.opencodeCli.actions.restartingOpenCode":"settings.openchamber.opencodeCli.actions.saveAndReload")}),s.jsx(H,{type:"button",variant:"outline",size:"xs",onClick:p,disabled:i||r,className:"shrink-0 !font-normal",children:t("settings.openchamber.opencodeCli.actions.restart")})]})]})]})})},uw=()=>{const{t}=Ee(),e=Pn(),[a,n]=m.useState({state:"loading"}),[i,o]=m.useState(!1),[r,c]=m.useState(!1);m.useEffect(()=>{let l=!1;return Nf().then(f=>{l||n({state:"ready",names:f.names})}).catch(()=>{l||n({state:"failed"})}),()=>{l=!0}},[]);const u=m.useCallback(async l=>{Mt("saving");try{const f=await Cf(l);return n({state:"ready",names:f.names}),o(!0),Mt("saved"),!0}catch{return Mt("error"),q.error(t("settings.environment.editor.saveFailed")),!1}},[t]),d=m.useCallback(async()=>{c(!0);try{await fu(t),o(!1)}finally{c(!1)}},[t]);return s.jsx($e,{title:t("settings.environment.user.title"),info:t("settings.environment.user.info"),settingsItem:"general.environment-variables",children:s.jsxs("div",{className:"space-y-3",children:[e?s.jsx("p",{className:_t,children:t("settings.environment.user.enterpriseNote")}):null,a.state==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:t("settings.environment.editor.loadFailed")}):s.jsx(If,{names:a.state==="ready"?a.names:[],disabled:a.state!=="ready",onSet:(l,f)=>u({[l]:f}),onRemove:l=>u({[l]:null})}),i&&!e?s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("p",{className:_t,children:t("settings.environment.user.restartNote")}),s.jsx(H,{type:"button",variant:"outline",size:"xs",onClick:()=>{d()},disabled:r,className:"shrink-0 !font-normal",children:t(r?"settings.openchamber.opencodeCli.actions.restartingOpenCode":"settings.openchamber.opencodeCli.actions.restart")})]}):null]})})},mw=3e3,sm=1e3,pw=5,gw=(t,e)=>t.imagePulling?mw:t.imageBytes===0&&e<pw?sm:null,yd=["B","KB","MB","GB","TB"],$o=t=>{let e=t,a=0;for(;e>=1e3&&a<yd.length-1;)e/=1e3,a+=1;return`${new Intl.NumberFormat(Bo(),{maximumFractionDigits:a===0?0:1}).format(e)} ${yd[a]}`},nm=t=>{const e=De.c(11);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={kind:"reading"},e[0]=a):a=e[0];const[n,i]=m.useState(a),[o,r]=m.useState(0);let c;e[1]!==t?(c=()=>{const b=new AbortController;return i({kind:"reading"}),t(b.signal).then(x=>{b.signal.aborted||i({kind:"read",value:x})},x=>{b.signal.aborted||i({kind:"failed",error:x})}),()=>b.abort()},e[1]=t,e[2]=c):c=e[2];let u;e[3]!==t||e[4]!==o?(u=[t,o],e[3]=t,e[4]=o,e[5]=u):u=e[5],m.useEffect(c,u);let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=()=>r(ww),e[6]=d):d=e[6];const l=d;let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=b=>i({kind:"read",value:b}),e[7]=f):f=e[7];const p=f;let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=b=>i({kind:"failed",error:b}),e[8]=g):g=e[8];const h=g;let y;return e[9]!==n?(y=[n,l,p,h],e[9]=n,e[10]=y):y=e[10],y},Pi=t=>{const e=De.c(7),{tone:a,children:n}=t;let i;e[0]!==a?(i=a==="busy"?s.jsx(va,{className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 text-muted-foreground"}):s.jsx(te,{name:a==="ready"?"checkbox-circle":"circle",className:ze("mt-[0.2em] h-3.5 w-3.5 shrink-0",a==="ready"?"text-[var(--status-success)]":"text-muted-foreground")}),e[0]=a,e[1]=i):i=e[1];let o;e[2]!==n?(o=s.jsx("span",{children:n}),e[2]=n,e[3]=o):o=e[3];let r;return e[4]!==i||e[5]!==o?(r=s.jsxs("p",{className:"flex items-start gap-1.5 typography-meta text-foreground",role:"status",children:[i,o]}),e[4]=i,e[5]=o,e[6]=r):r=e[6],r},fw=t=>{const e=De.c(44),{disk:a,onCancel:n,onConfirm:i}=t,{t:o}=Ee(),r=re(Sw),c=a!==null;let u;e[0]!==o?(u=o("settings.openchamber.spaces.places.cleanUp.confirmTitle"),e[0]=o,e[1]=u):u=e[1];const d=u;let l;e[2]!==a||e[3]!==o?(l=a?[o("settings.openchamber.spaces.places.cleanUp.frees",{size:$o(a.freeBytes)}),...a.freesImage?[o("settings.openchamber.spaces.places.cleanUp.imageAgain")]:[]]:[],e[2]=a,e[3]=o,e[4]=l):l=e[4];const f=l;let p;e[5]!==o?(p=o("settings.openchamber.spaces.places.cleanUp.cancel"),e[5]=o,e[6]=p):p=e[6];let g;e[7]!==n||e[8]!==p?(g=s.jsx(H,{variant:"outline",size:"sm",onClick:n,children:p}),e[7]=n,e[8]=p,e[9]=g):g=e[9];let h;e[10]!==o?(h=o("settings.openchamber.spaces.places.cleanUp.confirm"),e[10]=o,e[11]=h):h=e[11];let y;e[12]!==i||e[13]!==h?(y=s.jsx(H,{size:"sm",onClick:i,children:h}),e[12]=i,e[13]=h,e[14]=y):y=e[14];let b;e[15]!==g||e[16]!==y?(b=s.jsxs("div",{className:"flex w-full justify-end gap-2",children:[g,y]}),e[15]=g,e[16]=y,e[17]=b):b=e[17];const x=b;if(r){let P;e[18]!==f?(P=s.jsx("div",{className:"flex flex-col gap-1 px-3 pb-4 pt-1",children:f.map(Nw)}),e[18]=f,e[19]=P):P=e[19];let j;return e[20]!==x||e[21]!==n||e[22]!==c||e[23]!==P||e[24]!==d?(j=s.jsx(dl,{open:c,title:d,onClose:n,footer:x,children:P}),e[20]=x,e[21]=n,e[22]=c,e[23]=P,e[24]=d,e[25]=j):j=e[25],j}let w;e[26]!==n?(w=P=>{P||n()},e[26]=n,e[27]=w):w=e[27];let S;e[28]!==d?(S=s.jsx(Ot,{children:d}),e[28]=d,e[29]=S):S=e[29];let v;e[30]!==f?(v=s.jsx(Ft,{className:"flex flex-col gap-1",children:f.map(Cw)}),e[30]=f,e[31]=v):v=e[31];let A;e[32]!==v||e[33]!==S?(A=s.jsxs(Rt,{children:[S,v]}),e[32]=v,e[33]=S,e[34]=A):A=e[34];let I;e[35]!==x?(I=s.jsx(Wt,{children:x}),e[35]=x,e[36]=I):I=e[36];let N;e[37]!==A||e[38]!==I?(N=s.jsxs(Et,{className:"max-w-md",children:[A,I]}),e[37]=A,e[38]=I,e[39]=N):N=e[39];let k;return e[40]!==c||e[41]!==N||e[42]!==w?(k=s.jsx(Tt,{open:c,onOpenChange:w,children:N}),e[40]=c,e[41]=N,e[42]=w,e[43]=k):k=e[43],k},hw=t=>{const e=De.c(19),{outcome:a}=t,{t:n}=Ee();let i;e[0]!==a.kept?(i=a.kept.some(Iw),e[0]=a.kept,e[1]=i):i=e[1];const o=i;let r;e[2]!==a.kept?(r=a.kept.some(Pw),e[2]=a.kept,e[3]=r):r=e[3];const c=r;let u;e[4]!==a.freedBytes||e[5]!==n?(u=n("settings.openchamber.spaces.places.cleanUp.freed",{size:$o(a.freedBytes)}),e[4]=a.freedBytes,e[5]=n,e[6]=u):u=e[6];let d;e[7]!==u?(d=s.jsx("p",{className:"typography-meta text-muted-foreground",children:u}),e[7]=u,e[8]=d):d=e[8];let l;e[9]!==o||e[10]!==n?(l=o?s.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.spaces.places.cleanUp.keptInUse")}):null,e[9]=o,e[10]=n,e[11]=l):l=e[11];let f;e[12]!==c||e[13]!==n?(f=c?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:n("settings.openchamber.spaces.places.cleanUp.keptFailed")}):null,e[12]=c,e[13]=n,e[14]=f):f=e[14];let p;return e[15]!==d||e[16]!==l||e[17]!==f?(p=s.jsxs("div",{className:"space-y-0.5",role:"status",children:[d,l,f]}),e[15]=d,e[16]=l,e[17]=f,e[18]=p):p=e[18],p},bw=t=>{const e=De.c(68),{placeId:a}=t,{t:n}=Ee();let i;e[0]!==a?(i=z=>Ql(a,z),e[0]=a,e[1]=i):i=e[1];const o=i,[r,,c,u]=nm(o);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d={kind:"idle"},e[2]=d):d=e[2];const[l,f]=m.useState(d);let p;e[3]!==a||e[4]!==c?(p=async()=>{f({kind:"cleaning"});try{const z=await Kg(a);c(z.disk),f({kind:"done",outcome:z})}catch(z){const Q=z;if(!(Q instanceof Error))throw Q;f({kind:"failed",error:Q})}},e[3]=a,e[4]=c,e[5]=p):p=e[5];const g=p;let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h={kind:"idle"},e[6]=h):h=e[6];const[y,b]=m.useState(h),x=m.useRef(0);let w;e[7]!==r.kind||e[8]!==r.value||e[9]!==u||e[10]!==a||e[11]!==c?(w=()=>{if(r.kind!=="read")return;const z=gw(r.value,x.current);if(z===null)return;const Q=new AbortController,V=setTimeout(()=>{Ql(a,Q.signal).then(L=>{Q.signal.aborted||(L.imagePulling?x.current=0:L.imageBytes===0&&z===sm&&(x.current=x.current+1),c(L))},L=>{Q.signal.aborted||u(L)})},z);return()=>{Q.abort(),clearTimeout(V)}},e[7]=r.kind,e[8]=r.value,e[9]=u,e[10]=a,e[11]=c,e[12]=w):w=e[12];let S;e[13]!==r||e[14]!==u||e[15]!==a||e[16]!==c?(S=[r,u,a,c],e[13]=r,e[14]=u,e[15]=a,e[16]=c,e[17]=S):S=e[17],m.useEffect(w,S);let v;e[18]!==a||e[19]!==c?(v=async()=>{b({kind:"starting"}),f(Aw),x.current=0;try{c(await _g(a)),b({kind:"idle"})}catch(z){const Q=z;if(!(Q instanceof Error))throw Q;b({kind:"failed",error:Q})}},e[18]=a,e[19]=c,e[20]=v):v=e[20];const A=v;if(r.kind==="reading"){let z;e[21]!==n?(z=n("settings.openchamber.spaces.places.disk.reading"),e[21]=n,e[22]=z):z=e[22];let Q;return e[23]!==z?(Q=s.jsx(Pi,{tone:"busy",children:z}),e[23]=z,e[24]=Q):Q=e[24],Q}if(r.kind==="failed"){let z;e[25]!==r.error||e[26]!==n?(z=n("settings.openchamber.spaces.places.disk.readFailed",{reason:zn(n,Ka(r.error))}),e[25]=r.error,e[26]=n,e[27]=z):z=e[27];let Q;return e[28]!==z?(Q=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:z}),e[28]=z,e[29]=Q):Q=e[29],Q}let I;e[30]!==r.value.imageFailure||e[31]!==y.error||e[32]!==y.kind?(I=y.kind==="failed"?Ka(y.error):r.value.imageFailure,e[30]=r.value.imageFailure,e[31]=y.error,e[32]=y.kind,e[33]=I):I=e[33];const N=I,k=r.value.imagePulling||y.kind==="starting",P=(r.value.imageBytes??0)+r.value.toolsBytes+r.value.spacesBytes,j=r.value.freeBytes>0&&!r.value.imagePulling;let C;e[34]!==r.value.imageBytes||e[35]!==A||e[36]!==k||e[37]!==n?(C=k?s.jsx(Pi,{tone:"busy",children:n("settings.openchamber.spaces.places.image.downloadingNote")}):r.value.imageBytes===null?s.jsxs("div",{className:"space-y-2",children:[s.jsx(Pi,{tone:"todo",children:n("settings.openchamber.spaces.places.image.missing")}),s.jsxs(H,{size:"sm",variant:"outline",onClick:()=>{A()},children:[s.jsx(te,{name:"download",className:"size-3.5"}),n("settings.openchamber.spaces.places.image.downloadNow")]})]}):s.jsx(Pi,{tone:"ready",children:n("settings.openchamber.spaces.places.image.ready")}),e[34]=r.value.imageBytes,e[35]=A,e[36]=k,e[37]=n,e[38]=C):C=e[38];let E;e[39]!==j||e[40]!==l.kind||e[41]!==r.value.freeBytes||e[42]!==n||e[43]!==P?(E=P>0||l.kind==="cleaning"?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.spaces.places.disk.total",{size:$o(P)})}),l.kind==="cleaning"?s.jsxs("span",{className:"inline-flex items-center gap-1.5 typography-meta text-muted-foreground",role:"status",children:[s.jsx(va,{className:"size-3.5"}),n("settings.openchamber.spaces.places.cleanUp.running")]}):j?s.jsx(H,{size:"xs",variant:"outline",onClick:()=>f({kind:"confirming"}),children:n("settings.openchamber.spaces.places.cleanUp.freeUp",{size:$o(r.value.freeBytes)})}):null]}):null,e[39]=j,e[40]=l.kind,e[41]=r.value.freeBytes,e[42]=n,e[43]=P,e[44]=E):E=e[44];let F;e[45]!==N||e[46]!==n?(F=N?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",role:"alert",children:zn(n,N)}):null,e[45]=N,e[46]=n,e[47]=F):F=e[47];let O;e[48]!==l.kind||e[49]!==l.outcome?(O=l.kind==="done"?s.jsx(hw,{outcome:l.outcome}):null,e[48]=l.kind,e[49]=l.outcome,e[50]=O):O=e[50];let K;e[51]!==l.error||e[52]!==l.kind||e[53]!==n?(K=l.kind==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",role:"alert",children:n("settings.openchamber.spaces.places.cleanUp.failed",{reason:zn(n,Ka(l.error))})}):null,e[51]=l.error,e[52]=l.kind,e[53]=n,e[54]=K):K=e[54];const D=l.kind==="confirming"?r.value:null;let M;e[55]===Symbol.for("react.memo_cache_sentinel")?(M=()=>f({kind:"idle"}),e[55]=M):M=e[55];let T;e[56]!==g?(T=()=>{g()},e[56]=g,e[57]=T):T=e[57];let R;e[58]!==D||e[59]!==T?(R=s.jsx(fw,{disk:D,onCancel:M,onConfirm:T}),e[58]=D,e[59]=T,e[60]=R):R=e[60];let $;return e[61]!==E||e[62]!==F||e[63]!==O||e[64]!==K||e[65]!==R||e[66]!==C?($=s.jsxs("div",{className:"space-y-2",children:[C,E,F,O,K,R]}),e[61]=E,e[62]=F,e[63]=O,e[64]=K,e[65]=R,e[66]=C,e[67]=$):$=e[67],$},xw=new Map([["docker","settings.openchamber.spaces.places.docker"]]),vw=new Set(["docker",Wi]),yw=t=>{const e=De.c(62),{place:a,title:n,field:i,spaces:o,spacesError:r,onRetry:c}=t,u=i===void 0?null:i,{t:d}=Ee(),l=re(Tw),f=!!(a.setup?.remedy||a.setup?.job);if(!a.available){let N;e[0]!==c||e[1]!==a||e[2]!==f||e[3]!==d?(N=f?s.jsx($l,{place:a,onRecheck:c,withCheck:!0}):s.jsxs("p",{className:"flex items-start gap-1.5 typography-meta text-foreground",role:"status",children:[s.jsx(te,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 text-[var(--status-info)]"}),s.jsx("span",{children:zn(d,a,a.machine===null?void 0:{machine:a.machine})})]}),e[0]=c,e[1]=a,e[2]=f,e[3]=d,e[4]=N):N=e[4];let k;e[5]!==o||e[6]!==d?(k=o&&o.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:o.length===1?d("settings.openchamber.spaces.places.lastSeenSingle"):d("settings.openchamber.spaces.places.lastSeenPlural",{count:o.length})}),o.map(Ew)]}):null,e[5]=o,e[6]=d,e[7]=k):k=e[7];let P;e[8]!==c||e[9]!==f||e[10]!==d?(P=f?null:s.jsx(H,{size:"sm",variant:"outline",onClick:c,children:d("settings.openchamber.spaces.places.retry")}),e[8]=c,e[9]=f,e[10]=d,e[11]=P):P=e[11];let j;e[12]!==u||e[13]!==N||e[14]!==k||e[15]!==P?(j=s.jsxs("div",{className:"space-y-2",children:[u,N,k,P]}),e[12]=u,e[13]=N,e[14]=k,e[15]=P,e[16]=j):j=e[16];let C;return e[17]!==j||e[18]!==n?(C=s.jsx(ni,{title:n,children:j}),e[17]=j,e[18]=n,e[19]=C):C=e[19],C}let p,g,h,y,b,x,w,S,v;if(e[20]!==u||e[21]!==l||e[22]!==c||e[23]!==a||e[24]!==o||e[25]!==r||e[26]!==d||e[27]!==n){const N=o?.filter(Mw).length??0,k=o?.filter(Dw).length??0,P=o?.filter(Rw)??[],j=a.setup?.memory?.engine;let C;e[37]!==j||e[38]!==a.version||e[39]!==d?(C=j==="colima"?d("settings.openchamber.spaces.places.dockerRunningColima",{version:a.version}):j==="docker_desktop"?d("settings.openchamber.spaces.places.dockerRunningDesktop",{version:a.version}):d("settings.openchamber.spaces.places.dockerRunning",{version:a.version}),e[37]=j,e[38]=a.version,e[39]=d,e[40]=C):C=e[40];const E=C;p=ni,v=n,g="space-y-2",h=u,e[41]!==E||e[42]!==a.id||e[43]!==a.version?(y=vw.has(a.id)&&a.version?s.jsx(Pi,{tone:"ready",children:E}):null,e[41]=E,e[42]=a.id,e[43]=a.version,e[44]=y):y=e[44],e[45]!==c||e[46]!==a?(b=s.jsx($l,{place:a,onRecheck:c}),e[45]=c,e[46]=a,e[47]=b):b=e[47],e[48]!==a.id?(x=s.jsx(bw,{placeId:a.id}),e[48]=a.id,e[49]=x):x=e[49],w=o&&N+k>0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:d("settings.openchamber.spaces.places.spaceCount",{running:N,stopped:k})}):r?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:d("spaces.page.loadFailed",{reason:zn(d,Ka(r))})}):null,S=P.length>0?s.jsxs("div",{className:"space-y-1 pt-1",children:[s.jsx("p",{className:"typography-ui-label text-foreground",children:d("settings.openchamber.spaces.places.leftBehind")}),P.map(F=>s.jsx(gl,{entry:F,actions:l?"sheet":"menu",showFolder:!0},F.id))]}):null,e[20]=u,e[21]=l,e[22]=c,e[23]=a,e[24]=o,e[25]=r,e[26]=d,e[27]=n,e[28]=p,e[29]=g,e[30]=h,e[31]=y,e[32]=b,e[33]=x,e[34]=w,e[35]=S,e[36]=v}else p=e[28],g=e[29],h=e[30],y=e[31],b=e[32],x=e[33],w=e[34],S=e[35],v=e[36];let A;e[50]!==g||e[51]!==h||e[52]!==y||e[53]!==b||e[54]!==x||e[55]!==w||e[56]!==S?(A=s.jsxs("div",{className:g,children:[h,y,b,x,w,S]}),e[50]=g,e[51]=h,e[52]=y,e[53]=b,e[54]=x,e[55]=w,e[56]=S,e[57]=A):A=e[57];let I;return e[58]!==p||e[59]!==A||e[60]!==v?(I=s.jsx(p,{title:v,children:A}),e[58]=p,e[59]=A,e[60]=v,e[61]=I):I=e[61],I},jw=t=>{const e=De.c(59),{machine:a,onChange:n}=t,{t:i}=Ee(),[o,r]=m.useState(a??"");let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={kind:"idle"},e[0]=c):c=e[0];const[u,d]=m.useState(c),[l,f]=m.useState(!1);let p,g;e[1]!==l||e[2]!==a?(p=()=>{l||r(a??"")},g=[l,a],e[1]=l,e[2]=a,e[3]=p,e[4]=g):(p=e[3],g=e[4]),m.useEffect(p,g);let h;e[5]!==n?(h=async T=>{d({kind:"saving"}),Mt("saving");try{const R=await $g(T.trim());Mt("saved"),d({kind:"idle"}),f(!1),n(R)}catch(R){const $=R;if(Mt("error"),!($ instanceof Error))throw $;d({kind:"failed",error:$})}},e[5]=n,e[6]=h):h=e[6];const y=h,b=u.kind==="saving";let x;e[7]!==o?(x=o.trim(),e[7]=o,e[8]=x):x=e[8];const w=x===(a??"");let S;e[9]!==i?(S=i("settings.openchamber.spaces.places.machine.label"),e[9]=i,e[10]=S):S=e[10];let v;e[11]!==i?(v=i("settings.openchamber.spaces.places.machine.info"),e[11]=i,e[12]=v):v=e[12];let A;e[13]!==u.kind?(A=T=>{r(T.target.value),f(!0),u.kind==="failed"&&d({kind:"idle"})},e[13]=u.kind,e[14]=A):A=e[14];let I;e[15]!==o||e[16]!==y||e[17]!==b||e[18]!==w?(I=T=>{T.key==="Enter"&&!b&&!w&&(T.preventDefault(),y(o))},e[15]=o,e[16]=y,e[17]=b,e[18]=w,e[19]=I):I=e[19];let N;e[20]!==i?(N=i("settings.openchamber.spaces.places.machine.placeholder"),e[20]=i,e[21]=N):N=e[21];let k;e[22]!==i?(k=i("settings.openchamber.spaces.places.machine.label"),e[22]=i,e[23]=k):k=e[23];let P;e[24]!==o||e[25]!==b||e[26]!==N||e[27]!==k||e[28]!==A||e[29]!==I?(P=s.jsx(qe,{value:o,onChange:A,onKeyDown:I,placeholder:N,"aria-label":k,className:"h-8 min-w-[14rem] flex-1 max-w-[24rem] font-mono",autoComplete:"off",spellCheck:!1,disabled:b}),e[24]=o,e[25]=b,e[26]=N,e[27]=k,e[28]=A,e[29]=I,e[30]=P):P=e[30];const j=b||w;let C;e[31]!==o||e[32]!==y?(C=()=>{y(o)},e[31]=o,e[32]=y,e[33]=C):C=e[33];let E;e[34]!==b||e[35]!==i?(E=b?s.jsxs(s.Fragment,{children:[s.jsx(va,{className:"size-3.5"}),i("settings.openchamber.spaces.places.machine.checking")]}):i("settings.openchamber.spaces.places.machine.check"),e[34]=b,e[35]=i,e[36]=E):E=e[36];let F;e[37]!==j||e[38]!==C||e[39]!==E?(F=s.jsx(H,{size:"sm",variant:"outline",className:"shrink-0",disabled:j,onClick:C,children:E}),e[37]=j,e[38]=C,e[39]=E,e[40]=F):F=e[40];let O;e[41]!==a||e[42]!==y||e[43]!==b||e[44]!==i?(O=a!==null?s.jsx(H,{size:"sm",variant:"ghost",className:"shrink-0 !font-normal",disabled:b,onClick:()=>{y("")},children:i("settings.openchamber.spaces.places.machine.remove")}):null,e[41]=a,e[42]=y,e[43]=b,e[44]=i,e[45]=O):O=e[45];let K;e[46]!==P||e[47]!==F||e[48]!==O||e[49]!==S||e[50]!==v?(K=s.jsxs(st,{settingsItem:"general.isolated-spaces-machine",label:S,info:v,alignEnd:!1,controlClassName:"flex-wrap",children:[P,F,O]}),e[46]=P,e[47]=F,e[48]=O,e[49]=S,e[50]=v,e[51]=K):K=e[51];let D;e[52]!==u.error||e[53]!==u.kind||e[54]!==i?(D=u.kind==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",role:"alert",children:zn(i,Ka(u.error))}):null,e[52]=u.error,e[53]=u.kind,e[54]=i,e[55]=D):D=e[55];let M;return e[56]!==K||e[57]!==D?(M=s.jsxs("div",{className:"space-y-1",children:[K,D]}),e[56]=K,e[57]=D,e[58]=M):M=e[58],M},kw=()=>{const t=De.c(47),{t:e}=Ee(),a=re(Ow),[n,i,o]=nm(Lg),{journey:r,error:c}=nu();let u,d,l,f;if(t[0]!==a||t[1]!==r||t[2]!==c||t[3]!==n.error||t[4]!==n.kind||t[5]!==n.value||t[6]!==o||t[7]!==i||t[8]!==e){f=Symbol.for("react.early_return_sentinel");e:{const g=r?Array.from(r.values()):null;let h;t[13]!==i?(h=()=>{i(),Dr().catch(Fw)},t[13]=i,t[14]=h):h=t[14];const y=h;let b;t[15]!==n.kind||t[16]!==n.value||t[17]!==o?(b=j=>{if(n.kind!=="read")return;const C=n.value.filter(Lw);o(j?[...C,j]:C),Dr().catch(Kw)},t[15]=n.kind,t[16]=n.value,t[17]=o,t[18]=b):b=t[18];const x=b;if(n.kind==="reading"){let j;t[19]!==e?(j=e("settings.openchamber.spaces.places.reading"),t[19]=e,t[20]=j):j=t[20];let C;t[21]!==j?(C=s.jsx("p",{className:"typography-meta text-muted-foreground",children:j}),t[21]=j,t[22]=C):C=t[22],f=C;break e}if(n.kind==="failed"){let j;t[23]!==n.error||t[24]!==e?(j=e("settings.openchamber.spaces.places.readFailed",{reason:zn(e,Ka(n.error))}),t[23]=n.error,t[24]=e,t[25]=j):j=t[25];let C;t[26]!==j?(C=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:j}),t[26]=j,t[27]=C):C=t[27];let E;t[28]!==e?(E=e("settings.openchamber.spaces.places.retry"),t[28]=e,t[29]=E):E=t[29];let F;t[30]!==y||t[31]!==E?(F=s.jsx(H,{size:"sm",variant:"outline",onClick:y,children:E}),t[30]=y,t[31]=E,t[32]=F):F=t[32];let O;t[33]!==C||t[34]!==F?(O=s.jsxs("div",{className:"space-y-2",children:[C,F]}),t[33]=C,t[34]=F,t[35]=O):O=t[35],f=O;break e}let w;t[36]!==n.value?(w=n.value.find(_w)??null,t[36]=n.value,t[37]=w):w=t[37];const S=w,v=S?.machine??null;let A;t[38]!==x||t[39]!==v?(A=s.jsx(jw,{machine:v,onChange:x}),t[38]=x,t[39]=v,t[40]=A):A=t[40];const I=A,N=S?[]:g?.filter($w)??[];let k;t[41]!==e?(k=j=>{const C=xw.get(j.id);return j.machine??(C?e(C):j.id)},t[41]=e,t[42]=k):k=t[42];const P=k;u="space-y-6",d=n.value.map(j=>s.jsx(yw,{place:j,title:P(j),field:j.id===Wi?I:void 0,spaces:g?.filter(C=>C.placeId===j.id)??null,spacesError:c,onRetry:y},j.id)),l=S?null:s.jsx(ni,{title:e("settings.openchamber.spaces.places.machine.title"),children:s.jsxs("div",{className:"space-y-2",children:[I,N.length>0?s.jsx("div",{className:"space-y-1 pt-1",children:N.map(j=>s.jsx(gl,{entry:j,actions:a?"sheet":"menu",showFolder:!0},j.id))}):null]})})}t[0]=a,t[1]=r,t[2]=c,t[3]=n.error,t[4]=n.kind,t[5]=n.value,t[6]=o,t[7]=i,t[8]=e,t[9]=u,t[10]=d,t[11]=l,t[12]=f}else u=t[9],d=t[10],l=t[11],f=t[12];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;return t[43]!==u||t[44]!==d||t[45]!==l?(p=s.jsxs("div",{className:u,children:[d,l]}),t[43]=u,t[44]=d,t[45]=l,t[46]=p):p=t[46],p};function ww(t){return t+1}function Sw(t){return t.isMobile}function Nw(t){return s.jsx("p",{className:"typography-meta text-muted-foreground",children:t},t)}function Cw(t){return s.jsx("span",{children:t},t)}function Iw(t){return t.reason==="in_use"}function Pw(t){return t.reason==="failed"}function Aw(t){return t.kind==="done"||t.kind==="failed"?{kind:"idle"}:t}function Tw(t){return t.isMobile}function Ew(t){return s.jsxs("div",{className:"flex items-center gap-2 opacity-60",children:[s.jsx(te,{name:"box-3",className:"h-4 w-4 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label truncate text-foreground",children:t.name})]},t.id)}function Mw(t){return t.state==="running"}function Dw(t){return t.state==="exited"}function Rw(t){return t.state==="missing"}function Ow(t){return t.isMobile}function Fw(){}function Lw(t){return t.id!==Wi}function Kw(){}function _w(t){return t.id===Wi}function $w(t){return t.placeId===Wi}const jd=4,zw=()=>{const t=De.c(30),{t:e}=Ee(),[a,n]=m.useState(null),[i,o]=m.useState(!1),r=m.useRef(0);let c,u;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{const S=new AbortController;return qg(S.signal).then(n,()=>{S.signal.aborted||o(!0)}),()=>S.abort()},u=[],t[0]=c,t[1]=u):(c=t[0],u=t[1]),m.useEffect(c,u);let d;t[2]!==a?(d=async S=>{const v=a,A=r.current+1;r.current=A,n(S),Mt("saving");try{const I=await Wg(S);A===r.current&&n(I),Mt("saved")}catch(I){const N=I;if(!(N instanceof Error))throw N;A===r.current&&n(v),Mt("error")}},t[2]=a,t[3]=d):d=t[3];const l=d;if(i){let S;t[4]!==e?(S=e("settings.openchamber.spaces.idleStop.loadFailed"),t[4]=e,t[5]=S):S=t[5];let v;return t[6]!==S?(v=s.jsx("p",{className:"ps-6 typography-ui-label text-[var(--status-error)]",children:S}),t[6]=S,t[7]=v):v=t[7],v}if(!a)return null;const f=a.enabled;let p;t[8]!==l||t[9]!==a?(p=S=>{l({...a,enabled:S})},t[8]=l,t[9]=a,t[10]=p):p=t[10];let g;t[11]!==e?(g=e("settings.openchamber.spaces.idleStop.enabled"),t[11]=e,t[12]=g):g=t[12];let h;t[13]!==e?(h=e("settings.openchamber.spaces.idleStop.enabledAria"),t[13]=e,t[14]=h):h=t[14];let y;t[15]!==e?(y=e("settings.openchamber.spaces.idleStop.enabledInfo"),t[15]=e,t[16]=y):y=t[16];let b;t[17]!==a.enabled||t[18]!==p||t[19]!==g||t[20]!==h||t[21]!==y?(b=s.jsx(ct,{settingsItem:"general.isolated-spaces-idle-stop",checked:f,onChange:p,label:g,ariaLabel:h,info:y}),t[17]=a.enabled,t[18]=p,t[19]=g,t[20]=h,t[21]=y,t[22]=b):b=t[22];let x;t[23]!==l||t[24]!==a||t[25]!==e?(x=a.enabled?s.jsx(_i,{className:"space-y-0",children:s.jsxs(st,{label:e("settings.openchamber.spaces.idleStop.after"),children:[s.jsx(ds,{value:a.hours,onValueChange:S=>{l({...a,hours:S})},min:Vg,max:Bg,step:1,deferExternalValueWhileFocused:!0,"aria-label":e("settings.openchamber.spaces.idleStop.afterAria"),className:ze(us,"tabular-nums")}),s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:e("settings.openchamber.spaces.idleStop.hours")}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{l({...a,hours:jd})},disabled:a.hours===jd,className:Yt,"aria-label":e("settings.openchamber.spaces.idleStop.resetAria"),title:e("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})}):null,t[23]=l,t[24]=a,t[25]=e,t[26]=x):x=t[26];let w;return t[27]!==b||t[28]!==x?(w=s.jsxs(s.Fragment,{children:[b,x]}),t[27]=b,t[28]=x,t[29]=w):w=t[29],w},Uw=()=>{const t=De.c(19),{t:e}=Ee(),a=re(Vw),{journey:n}=nu();let i,o,r,c,u;if(t[0]!==a||t[1]!==n||t[2]!==e){u=Symbol.for("react.early_return_sentinel");e:{const f=n?Hg(n).filter(Hw):[];if(f.length===0){u=null;break e}i=$e,t[8]!==e?(c=e("settings.openchamber.spaces.withoutProject.title"),t[8]=e,t[9]=c):c=t[9],o="space-y-1";let p;t[10]!==a?(p=g=>s.jsx(gl,{entry:g,actions:a?"sheet":"menu",showFolder:!0},g.id),t[10]=a,t[11]=p):p=t[11],r=f.map(p)}t[0]=a,t[1]=n,t[2]=e,t[3]=i,t[4]=o,t[5]=r,t[6]=c,t[7]=u}else i=t[3],o=t[4],r=t[5],c=t[6],u=t[7];if(u!==Symbol.for("react.early_return_sentinel"))return u;let d;t[12]!==o||t[13]!==r?(d=s.jsx("div",{className:o,children:r}),t[12]=o,t[13]=r,t[14]=d):d=t[14];let l;return t[15]!==i||t[16]!==c||t[17]!==d?(l=s.jsx(i,{title:c,children:d}),t[15]=i,t[16]=c,t[17]=d,t[18]=l):l=t[18],l},Bw=()=>{const{t}=Ee(),e=re(h=>h.isolatedSpacesEnabled),a=re(h=>h.setIsolatedSpacesEnabled),[n,i]=m.useState(!1),[o,r]=m.useState(null),[c,u]=m.useState(null),[d,l]=m.useState(null);m.useEffect(()=>{const h=new AbortController;return Yl(h.signal).then(y=>a(y.enabled),()=>{}),()=>h.abort()},[a]);const f=async h=>{i(!0),l(null),r(null),Mt("saving");try{const y=await zg(h);a(y.enabled),u(y.stillRunning.length>0?y:null),Mt("saved"),y.enabled?Dr().catch(()=>{}):(Ug.getState().forgetForSwitchOff(),eg(),tg())}catch(y){if(Mt("error"),!(y instanceof Error))throw y;l(t("settings.openchamber.spaces.switchFailed",{reason:zn(t,Ka(y))}))}finally{i(!1)}},p=async h=>{if(u(null),h){await f(!0);return}i(!0);const y=await Yl().catch(()=>null);if(i(!1),!y||y.enabled&&y.spaces===null){r({kind:"unknown"});return}const b=y.enabled&&y.spaces?y.spaces.filter(x=>x.state==="running").length:0;b>0?r({kind:"stops",count:b}):await f(!1)},g=o?.kind==="unknown"?t("settings.openchamber.spaces.turnOff.unknown"):o?.count===1?t("settings.openchamber.spaces.turnOff.stopsSingle"):t("settings.openchamber.spaces.turnOff.stopsPlural",{count:o?.count??0});return s.jsxs(s.Fragment,{children:[s.jsx($e,{divider:!1,children:s.jsxs("div",{className:bs,children:[s.jsx(ct,{settingsItem:"general.isolated-spaces",checked:e,disabled:n||o!==null,onChange:h=>{p(h)},label:t("settings.openchamber.spaces.field.enabled"),ariaLabel:t("settings.openchamber.spaces.field.enabledAria"),info:t("settings.openchamber.spaces.field.enabledInfo")}),o?s.jsxs("div",{className:"space-y-2 ps-6",role:"alert",children:[s.jsx("p",{className:"typography-ui-label text-[var(--status-warning)]",children:g}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(H,{size:"sm",variant:"outline",disabled:n,onClick:()=>r(null),children:t("settings.openchamber.spaces.turnOff.cancel")}),s.jsx(H,{size:"sm",disabled:n,onClick:()=>{f(!1)},children:t("settings.openchamber.spaces.turnOff.confirm")})]})]}):null,c?.stillRunning.map(h=>s.jsx("p",{className:"ps-6 typography-ui-label text-[var(--status-warning)]",children:t("settings.openchamber.spaces.turnOff.stillRunning",{name:h.name,reason:zn(t,h)})},h.id)),d?s.jsx("p",{className:"ps-6 typography-ui-label text-[var(--status-error)]",children:d}):null,e?s.jsx(zw,{}):null]})}),e?s.jsx($e,{title:t("settings.openchamber.spaces.places.title"),children:s.jsx(kw,{})}):null,e?s.jsx(Uw,{}):null]})};function Vw(t){return t.isMobile}function Hw(t){return t.state!=="missing"}const Ar="builtin",qw=t=>t.filter(e=>cl(e)&&Wd(e.service,"browser")),Ww="ps-[3.75rem]",Aa=t=>{const e=De.c(23),{icon:a,title:n,summary:i,info:o,ariaLabel:r,checked:c,onChange:u,settingsItem:d}=t;let l;e[0]!==a?(l=s.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center oc-tile-inset rounded-lg text-foreground",children:s.jsx(te,{name:a,className:"size-4"})}),e[0]=a,e[1]=l):l=e[1];let f;e[2]!==n?(f=s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:n}),e[2]=n,e[3]=f):f=e[3];let p;e[4]!==o?(p=s.jsx(ts,{children:o}),e[4]=o,e[5]=p):p=e[5];let g;e[6]!==f||e[7]!==p?(g=s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[f,p]}),e[6]=f,e[7]=p,e[8]=g):g=e[8];let h;e[9]!==i?(h=s.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),e[9]=i,e[10]=h):h=e[10];let y;e[11]!==g||e[12]!==h?(y=s.jsxs("div",{className:"min-w-0 flex-1",children:[g,h]}),e[11]=g,e[12]=h,e[13]=y):y=e[13];let b;e[14]!==r||e[15]!==c||e[16]!==u?(b=s.jsx(La,{checked:c,onCheckedChange:u,"aria-label":r}),e[14]=r,e[15]=c,e[16]=u,e[17]=b):b=e[17];let x;return e[18]!==d||e[19]!==l||e[20]!==y||e[21]!==b?(x=s.jsxs("div",{"data-settings-item":d,className:"flex items-center gap-3 px-4 py-3",children:[l,y,b]}),e[18]=d,e[19]=l,e[20]=y,e[21]=b,e[22]=x):x=e[22],x},Gw=()=>{const t=De.c(184),{t:e}=Ee(),a=re(Jw),n=re(Qw),i=re(Yw),o=re(Zw),r=re(Xw),c=re(e3),u=re(t3),d=re(s3),l=Ps(n3),f=re(a3),p=re(i3),g=re(o3),h=re(r3),y=re(l3),b=re(c3),x=re(d3),w=re(u3),S=re(m3),v=re(p3),A=re(g3);let I;t[0]!==n?(I=Qe=>{n(Qe),jt({agentControlToolEnabled:Qe})},t[0]=n,t[1]=I):I=t[1];const N=I;let k;t[2]!==o?(k=Qe=>{o(Qe),jt({agentScheduleToolEnabled:Qe})},t[2]=o,t[3]=k):k=t[3];const P=k;let j;t[4]!==c?(j=Qe=>{c(Qe),jt({agentWebToolEnabled:Qe})},t[4]=c,t[5]=j):j=t[5];const C=j;let E;t[6]!==x?(E=Qe=>{x(Qe),jt({agentNotifyToolEnabled:Qe})},t[6]=x,t[7]=E):E=t[7];const F=E;let O;t[8]!==S?(O=Qe=>{S(Qe),jt({agentRenderToolEnabled:Qe})},t[8]=S,t[9]=O):O=t[9];const K=O;let D;t[10]!==y?(D=Qe=>{y(Qe),jt({agentKnowledgeToolEnabled:Qe})},t[10]=y,t[11]=D):D=t[11];const M=D;let T;t[12]!==A?(T=Qe=>{A(Qe),jt({agentToolsCodeMode:Qe})},t[12]=A,t[13]=T):T=t[13];const R=T;let $;t[14]===Symbol.for("react.memo_cache_sentinel")?($=[],t[14]=$):$=t[14],Ke.useEffect(f3,$);let z;t[15]!==l?(z=qw(l),t[15]=l,t[16]=z):z=t[16];const Q=z;let V;t[17]!==u||t[18]!==Q?(V=Q.some(Qe=>Qe.id===u)?u:Ar,t[17]=u,t[18]=Q,t[19]=V):V=t[19];const L=V;let B;t[20]!==d?(B=Qe=>{d(Qe),jt({browserProvider:Qe})},t[20]=d,t[21]=B):B=t[21];const W=B;let Y;t[22]!==g?(Y=Qe=>{g(Qe),jt({agentMemoryToolEnabled:Qe}).finally(()=>{Qe&&sg.getState().refresh()})},t[22]=g,t[23]=Y):Y=t[23];const ae=Y;let ee;t[24]!==e?(ee=e("settings.openchamber.tools.title"),t[24]=e,t[25]=ee):ee=t[25];let G;t[26]!==e?(G=e("settings.openchamber.tools.field.agentControlTool"),t[26]=e,t[27]=G):G=t[27];let le;t[28]!==e?(le=e("settings.openchamber.tools.field.agentControlToolSummary"),t[28]=e,t[29]=le):le=t[29];let J;t[30]!==e?(J=e("settings.openchamber.tools.field.agentControlToolInfo"),t[30]=e,t[31]=J):J=t[31];let me;t[32]!==e?(me=e("settings.openchamber.tools.field.agentControlToolAria"),t[32]=e,t[33]=me):me=t[33];let fe;t[34]!==a||t[35]!==N||t[36]!==G||t[37]!==le||t[38]!==J||t[39]!==me?(fe=s.jsx(Aa,{icon:"node-tree",settingsItem:"sessions.agent-control-tool",checked:a,onChange:N,title:G,summary:le,info:J,ariaLabel:me}),t[34]=a,t[35]=N,t[36]=G,t[37]=le,t[38]=J,t[39]=me,t[40]=fe):fe=t[40];let oe;t[41]!==e?(oe=e("settings.openchamber.tools.field.agentScheduleTool"),t[41]=e,t[42]=oe):oe=t[42];let pe;t[43]!==e?(pe=e("settings.openchamber.tools.field.agentScheduleToolSummary"),t[43]=e,t[44]=pe):pe=t[44];let se;t[45]!==e?(se=e("settings.openchamber.tools.field.agentScheduleToolInfo"),t[45]=e,t[46]=se):se=t[46];let ve;t[47]!==e?(ve=e("settings.openchamber.tools.field.agentScheduleToolAria"),t[47]=e,t[48]=ve):ve=t[48];let be;t[49]!==i||t[50]!==P||t[51]!==oe||t[52]!==pe||t[53]!==se||t[54]!==ve?(be=s.jsx(Aa,{icon:"calendar-schedule",settingsItem:"sessions.agent-schedule-tool",checked:i,onChange:P,title:oe,summary:pe,info:se,ariaLabel:ve}),t[49]=i,t[50]=P,t[51]=oe,t[52]=pe,t[53]=se,t[54]=ve,t[55]=be):be=t[55];let ne;t[56]!==e?(ne=e("settings.openchamber.tools.field.agentWebTool"),t[56]=e,t[57]=ne):ne=t[57];let we;t[58]!==e?(we=e("settings.openchamber.tools.field.agentWebToolSummary"),t[58]=e,t[59]=we):we=t[59];let Ne;t[60]!==e?(Ne=e("settings.openchamber.tools.field.agentWebToolInfo"),t[60]=e,t[61]=Ne):Ne=t[61];let Ie;t[62]!==e?(Ie=e("settings.openchamber.tools.field.agentWebToolAria"),t[62]=e,t[63]=Ie):Ie=t[63];let Ce;t[64]!==r||t[65]!==C||t[66]!==ne||t[67]!==we||t[68]!==Ne||t[69]!==Ie?(Ce=s.jsx(Aa,{icon:"global",settingsItem:"sessions.agent-web-tool",checked:r,onChange:C,title:ne,summary:we,info:Ne,ariaLabel:Ie}),t[64]=r,t[65]=C,t[66]=ne,t[67]=we,t[68]=Ne,t[69]=Ie,t[70]=Ce):Ce=t[70];let Me;t[71]===Symbol.for("react.memo_cache_sentinel")?(Me=ze("flex min-w-0 items-center gap-2 pb-3 pe-4",Ww),t[71]=Me):Me=t[71];let he;t[72]!==e?(he=e("settings.openchamber.tools.browserProvider.label"),t[72]=e,t[73]=he):he=t[73];let Pe;t[74]!==he?(Pe=s.jsx("span",{className:"truncate typography-meta text-muted-foreground",children:he}),t[74]=he,t[75]=Pe):Pe=t[75];let Re;t[76]!==e?(Re=e("settings.openchamber.tools.browserProvider.info"),t[76]=e,t[77]=Re):Re=t[77];let ce;t[78]!==Re?(ce=s.jsx(ts,{children:Re}),t[78]=Re,t[79]=ce):ce=t[79];const je=!r||Q.length===0;let de;t[80]!==e?(de=e("settings.openchamber.tools.browserProvider.aria"),t[80]=e,t[81]=de):de=t[81];let ie;t[82]!==Q||t[83]!==e?(ie=s.jsx(Kt,{children:Qe=>Qe===Ar?e("settings.openchamber.tools.browserProvider.option.builtin"):Q.find(_=>_.id===Qe)?.name??null}),t[82]=Q,t[83]=e,t[84]=ie):ie=t[84];let xe;t[85]!==de||t[86]!==ie?(xe=s.jsx(Ct,{className:"ms-auto w-auto min-w-0 max-w-[14rem]","aria-label":de,children:ie}),t[85]=de,t[86]=ie,t[87]=xe):xe=t[87];let Se;t[88]!==e?(Se=e("settings.openchamber.tools.browserProvider.option.builtin"),t[88]=e,t[89]=Se):Se=t[89];let Le;t[90]!==Se?(Le=s.jsx(bt,{value:Ar,children:Se}),t[90]=Se,t[91]=Le):Le=t[91];let Ue;t[92]!==Q?(Ue=Q.map(h3),t[92]=Q,t[93]=Ue):Ue=t[93];let Ye;t[94]!==Le||t[95]!==Ue?(Ye=s.jsxs(It,{children:[Le,Ue]}),t[94]=Le,t[95]=Ue,t[96]=Ye):Ye=t[96];let lt;t[97]!==W||t[98]!==L||t[99]!==je||t[100]!==xe||t[101]!==Ye?(lt=s.jsxs(Pt,{value:L,onValueChange:W,disabled:je,children:[xe,Ye]}),t[97]=W,t[98]=L,t[99]=je,t[100]=xe,t[101]=Ye,t[102]=lt):lt=t[102];let at;t[103]!==Pe||t[104]!==ce||t[105]!==lt?(at=s.jsxs("div",{"data-settings-item":"sessions.browser-provider",className:Me,children:[Pe,ce,lt]}),t[103]=Pe,t[104]=ce,t[105]=lt,t[106]=at):at=t[106];let ut;t[107]!==Ce||t[108]!==at?(ut=s.jsxs("div",{children:[Ce,at]}),t[107]=Ce,t[108]=at,t[109]=ut):ut=t[109];let vt;t[110]!==e?(vt=e("settings.openchamber.tools.field.agentNotifyTool"),t[110]=e,t[111]=vt):vt=t[111];let We;t[112]!==e?(We=e("settings.openchamber.tools.field.agentNotifyToolSummary"),t[112]=e,t[113]=We):We=t[113];let Ze;t[114]!==e?(Ze=e("settings.openchamber.tools.field.agentNotifyToolInfo"),t[114]=e,t[115]=Ze):Ze=t[115];let Xe;t[116]!==e?(Xe=e("settings.openchamber.tools.field.agentNotifyToolAria"),t[116]=e,t[117]=Xe):Xe=t[117];let it;t[118]!==b||t[119]!==F||t[120]!==vt||t[121]!==We||t[122]!==Ze||t[123]!==Xe?(it=s.jsx(Aa,{icon:"notification-3",settingsItem:"sessions.agent-notify-tool",checked:b,onChange:F,title:vt,summary:We,info:Ze,ariaLabel:Xe}),t[118]=b,t[119]=F,t[120]=vt,t[121]=We,t[122]=Ze,t[123]=Xe,t[124]=it):it=t[124];let dt;t[125]!==e?(dt=e("settings.openchamber.tools.field.agentRenderTool"),t[125]=e,t[126]=dt):dt=t[126];let Be;t[127]!==e?(Be=e("settings.openchamber.tools.field.agentRenderToolSummary"),t[127]=e,t[128]=Be):Be=t[128];let ot;t[129]!==e?(ot=e("settings.openchamber.tools.field.agentRenderToolInfo"),t[129]=e,t[130]=ot):ot=t[130];let et;t[131]!==e?(et=e("settings.openchamber.tools.field.agentRenderToolAria"),t[131]=e,t[132]=et):et=t[132];let ye;t[133]!==w||t[134]!==K||t[135]!==dt||t[136]!==Be||t[137]!==ot||t[138]!==et?(ye=s.jsx(Aa,{icon:"bar-chart-box",settingsItem:"sessions.agent-render-tool",checked:w,onChange:K,title:dt,summary:Be,info:ot,ariaLabel:et}),t[133]=w,t[134]=K,t[135]=dt,t[136]=Be,t[137]=ot,t[138]=et,t[139]=ye):ye=t[139];let Z;t[140]!==e?(Z=e("settings.openchamber.tools.field.agentKnowledgeTool"),t[140]=e,t[141]=Z):Z=t[141];let Oe;t[142]!==e?(Oe=e("settings.openchamber.tools.field.agentKnowledgeToolSummary"),t[142]=e,t[143]=Oe):Oe=t[143];let Ve;t[144]!==e?(Ve=e("settings.openchamber.tools.field.agentKnowledgeToolInfo"),t[144]=e,t[145]=Ve):Ve=t[145];let X;t[146]!==e?(X=e("settings.openchamber.tools.field.agentKnowledgeToolAria"),t[146]=e,t[147]=X):X=t[147];let _e;t[148]!==h||t[149]!==M||t[150]!==Z||t[151]!==Oe||t[152]!==Ve||t[153]!==X?(_e=s.jsx(Aa,{icon:"sticky-note",settingsItem:"sessions.agent-knowledge-tool",checked:h,onChange:M,title:Z,summary:Oe,info:Ve,ariaLabel:X}),t[148]=h,t[149]=M,t[150]=Z,t[151]=Oe,t[152]=Ve,t[153]=X,t[154]=_e):_e=t[154];let nt;t[155]!==p||t[156]!==f||t[157]!==ae||t[158]!==e?(nt=p?s.jsx(Aa,{icon:"brain",settingsItem:"sessions.agent-memory-tool",checked:f,onChange:ae,title:e("settings.openchamber.tools.field.agentMemoryTool"),summary:e("settings.openchamber.tools.field.agentMemoryToolSummary"),info:e("settings.openchamber.tools.field.agentMemoryToolInfo"),ariaLabel:e("settings.openchamber.tools.field.agentMemoryToolAria")}):null,t[155]=p,t[156]=f,t[157]=ae,t[158]=e,t[159]=nt):nt=t[159];let ht;t[160]!==fe||t[161]!==be||t[162]!==ut||t[163]!==it||t[164]!==ye||t[165]!==_e||t[166]!==nt?(ht=s.jsxs("div",{className:"max-w-[44rem] oc-tile divide-y divide-[var(--interactive-border)] rounded-xl",children:[fe,be,ut,it,ye,_e,nt]}),t[160]=fe,t[161]=be,t[162]=ut,t[163]=it,t[164]=ye,t[165]=_e,t[166]=nt,t[167]=ht):ht=t[167];let yt;t[168]!==e?(yt=e("settings.openchamber.tools.field.agentToolsCodeMode"),t[168]=e,t[169]=yt):yt=t[169];let kt;t[170]!==e?(kt=e("settings.openchamber.tools.field.agentToolsCodeModeAria"),t[170]=e,t[171]=kt):kt=t[171];let He;t[172]!==e?(He=e("settings.openchamber.tools.field.agentToolsCodeModeInfo"),t[172]=e,t[173]=He):He=t[173];let Je;t[174]!==v||t[175]!==R||t[176]!==yt||t[177]!==kt||t[178]!==He?(Je=s.jsx(ct,{className:"mt-4",settingsItem:"sessions.agent-tools-code-mode",checked:v,onChange:R,label:yt,ariaLabel:kt,info:He}),t[174]=v,t[175]=R,t[176]=yt,t[177]=kt,t[178]=He,t[179]=Je):Je=t[179];let mt;return t[180]!==ee||t[181]!==ht||t[182]!==Je?(mt=s.jsxs($e,{title:ee,children:[ht,Je]}),t[180]=ee,t[181]=ht,t[182]=Je,t[183]=mt):mt=t[183],mt};function Jw(t){return t.agentControlToolEnabled}function Qw(t){return t.setAgentControlToolEnabled}function Yw(t){return t.agentScheduleToolEnabled}function Zw(t){return t.setAgentScheduleToolEnabled}function Xw(t){return t.agentWebToolEnabled}function e3(t){return t.setAgentWebToolEnabled}function t3(t){return t.browserProvider}function s3(t){return t.setBrowserProvider}function n3(t){return t.guests}function a3(t){return t.agentMemoryToolEnabled}function i3(t){return t.agentMemoryFeatureAvailable}function o3(t){return t.setAgentMemoryToolEnabled}function r3(t){return t.agentKnowledgeToolEnabled}function l3(t){return t.setAgentKnowledgeToolEnabled}function c3(t){return t.agentNotifyToolEnabled}function d3(t){return t.setAgentNotifyToolEnabled}function u3(t){return t.agentRenderToolEnabled}function m3(t){return t.setAgentRenderToolEnabled}function p3(t){return t.agentToolsCodeMode}function g3(t){return t.setAgentToolsCodeMode}function f3(){nn()}function h3(t){return s.jsx(bt,{value:t.id,children:t.name},t.id)}const ei=Jo(t=>({patches:{},blocked:{},setDraft:(e,a,n)=>t(i=>({patches:{...i.patches,[e]:a??void 0},blocked:{...i.blocked,[e]:n}}))})),b3=()=>{const{patches:t}=ei.getState(),e={...t.app,...t.network};return Object.keys(e).length>0?e:null},am=async()=>{const t=b3();return t?(await jt(t)).ok:!1},x3=()=>{const{t}=Ee(),e=is()&&ri(),[a,n]=Ke.useState(!1),[i,o]=Ke.useState(!1),[r,c]=Ke.useState(!1),[u,d]=Ke.useState(""),[l,f]=Ke.useState(!1),[p,g]=Ke.useState(!1),[h,y]=Ke.useState(null),[b,x]=Ke.useState(!0),[w,S]=Ke.useState(!1),[v,A]=Ke.useState(null),[I,N]=Ke.useState(null);Ke.useEffect(()=>{if(!e){x(!1);return}let V=!1;return(async()=>{try{const L=await fn();if(!L)throw new Error(t("settings.openchamber.desktopNetwork.error.loadFailed"));if(V)return;const B=L.desktopLanAccessEnabled===!0;n(B),o(B),c(L.hasDesktopUiPassword===!0),d(""),f(!1),g(L.desktopLanAccessActive===!0),y(L.desktopLanAccessBlockedReason??null),A(null)}catch(L){V||A(L instanceof Error?L.message:t("settings.openchamber.desktopNetwork.error.loadFailed"))}finally{V||x(!1)}})(),()=>{V=!0}},[e,t]),Ke.useEffect(()=>{if(!e||!i){N(null);return}let V=!1;return(async()=>{const L=await Zd();V||N(L)})(),()=>{V=!0}},[i,e]);const k=u.trim(),P=k.length>0||l,j=i!==a||P,C=Ke.useMemo(()=>{if(typeof window>"u")return null;const L=qi()||window.location.href;let B=0;try{B=Number(new URL(L).port)}catch{B=Number(window.location.port)}return Number.isFinite(B)&&B>0?B:null},[]),E=i&&p&&I&&C?`http://${I}:${C}`:null,F=k.length>0||r&&!l,O=i&&!F,K=a&&!p&&h==="missing-password",D=Ki(V=>V.networkAccessBlocked)||h==="enterprise-mode",M=ei(V=>V.setDraft),T=ei(V=>!!(V.patches.app||V.patches.network)),R=b||w||!T||O;Ke.useEffect(()=>{M("network",j&&!O?{...i!==a?{desktopLanAccessEnabled:i}:{},...k?{desktopUiPassword:k}:l?{desktopUiPassword:""}:{}}:null,O)},[i,j,O,k,l,a,M]),Ke.useEffect(()=>()=>M("network",null,!1),[M]);const $=Ke.useCallback(V=>{d(V),V.trim()&&f(!1)},[]),z=Ke.useCallback(()=>{d(""),f(!0),o(!1)},[]),Q=Ke.useCallback(async()=>{S(!0),A(null);try{if(!await am())throw new Error(t("settings.openchamber.desktopNetwork.error.saveFailed"));if(n(i),k?c(!0):l&&c(!1),d(""),f(!1),!await au())throw new Error(t("settings.openchamber.desktopNetwork.error.savedRestartFailed"))}catch(V){A(V instanceof Error?V.message:t("settings.openchamber.desktopNetwork.error.saveFailed")),S(!1)}},[i,k,l,t]);return e?s.jsxs($e,{title:t("settings.layout.general.network.title"),contentClassName:"space-y-4",children:[s.jsxs(St,{settingsItem:"sessions.desktop-ui-password",label:s.jsx("label",{htmlFor:"desktop-ui-password",children:t("settings.openchamber.desktopPassword.field.password")}),info:t("settings.openchamber.desktopPassword.field.passwordDescription"),children:[s.jsx(qe,{id:"desktop-ui-password",type:"password",className:"h-8 min-w-0 flex-1",value:u,onChange:V=>$(V.target.value),placeholder:t(r&&!l?"settings.openchamber.desktopPassword.field.passwordSetPlaceholder":"settings.openchamber.desktopPassword.field.passwordPlaceholder"),disabled:b||w,required:i&&!F,"aria-invalid":O}),r&&!l?s.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:z,disabled:b||w,className:"shrink-0 !font-normal",children:t("settings.openchamber.desktopPassword.actions.removePassword")}):null]}),s.jsx(ct,{settingsItem:"sessions.desktop-lan-access",checked:i&&!D,onChange:o,disabled:b||w||D,label:t("settings.openchamber.desktopNetwork.field.allowLanAccess"),info:t("settings.openchamber.desktopNetwork.field.allowLanAccessDescription"),description:D?s.jsx("span",{className:"block",children:t("settings.openchamber.desktopNetwork.field.enterpriseBlocked")}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block text-[var(--status-warning)]/85",children:t("settings.openchamber.desktopNetwork.field.warning")}),O||K?s.jsx("span",{className:"block text-[var(--status-warning)]/85",children:t("settings.openchamber.desktopNetwork.field.passwordRequiredWarning")}):null]}),ariaLabel:t("settings.openchamber.desktopNetwork.field.allowLanAccessAria")}),E&&!D?s.jsxs("p",{className:"typography-meta text-muted-foreground",children:[t(j&&!a?"settings.openchamber.desktopNetwork.hint.openAfterRestart":"settings.openchamber.desktopNetwork.hint.openNow"),s.jsx("span",{className:"font-mono text-foreground",children:E})]}):null,v?s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:v}):null,s.jsx(H,{type:"button",size:"xs",onClick:Q,disabled:R,className:"!font-normal",children:t(w?"settings.common.actions.saving":"settings.openchamber.desktopNetwork.actions.saveAndRestart")})]}):null},im=new Set(["shift","control","alt","meta"]),om=3,v3=3e3,rm={maxKeys:om,macModifiers:rg()};function Sl(t,{macModifiers:e}){const a=[];return e?(t.metaKey&&a.push("mod"),t.ctrlKey&&a.push("ctrl")):(t.ctrlKey&&a.push("mod"),t.metaKey&&a.push("super")),t.shiftKey&&a.push("shift"),t.altKey&&a.push("alt"),a}function Nl(t,e=!1){const a=new Set;return t.altKey&&a.add("alt"),t.ctrlKey&&a.add("control"),t.metaKey&&a.add("meta"),t.shiftKey&&a.add("shift"),e&&a.add(t.key.toLowerCase()),a.size}function y3(t){return t.action.customizable}function kd(t,e){if(Nl(t)>e.maxKeys)return null;const a=Sl(t,e);return a.length>0?qo(a.join("+")):null}function j3(t,e){if(im.has(t.key.toLowerCase())||Nl(t,!0)>e.maxKeys)return null;const a=ig(og(t));return a?qo([...Sl(t,e),a].join("+")):null}function k3(t,e){const a=t.key.toLowerCase();if(!im.has(a)||Nl(t,!0)>e.maxKeys)return null;const n=Sl({metaKey:t.metaKey||a==="meta",ctrlKey:t.ctrlKey||a==="control",shiftKey:t.shiftKey||a==="shift",altKey:t.altKey||a==="alt"},e);return n.length>0?qo(n.join("+")):null}function wd(t){return t.chords.length>0?{...t,livePreview:null,settled:!0}:t}function w3(t,e,a,n=2,i={}){const o={...rm,...i};if(e.repeat||e.isComposing)return t;if(a==="keyup")return{...t,livePreview:kd(e,o)};if(e.key==="Backspace")return{chords:t.chords.slice(0,-1),livePreview:null,settled:!1};const r=j3(e,o);if(r){if(t.settled){const u=[r];return{chords:u,livePreview:null,settled:u.length>=n}}const c=t.chords.length<n?[...t.chords,r]:t.chords;return{chords:c,livePreview:null,settled:c.length>=n}}return{...t,livePreview:kd(e,o)}}const Cl=t=>{const e=De.c(122),{action:a,overrides:n,onSave:i,onOpenChange:o,maxChords:r,maxKeys:c}=t,u=r===void 0?2:r,d=c===void 0?om:c,{t:l}=Ee();let f;e[0]!==l?(f=ve=>l(ve.settingsLabelKey),e[0]=l,e[1]=f):f=e[1];const p=f;let g;e[2]!==p?(g=ve=>ve.action.customizable?p(ve.action):Hn(ve.action.defaultBinding),e[2]=p,e[3]=g):g=e[3];const h=g;let y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y={chords:[],livePreview:null,settled:!1},e[4]=y):y=e[4];const[b,x]=m.useState(y),w=m.useRef(null);let S,v;e[5]!==a?(S=()=>{a&&(x({chords:[],livePreview:null,settled:!1}),w.current?.focus())},v=[a],e[5]=a,e[6]=S,e[7]=v):(S=e[6],v=e[7]),m.useEffect(S,v);const A=b.chords.length===1&&!b.settled;let I,N;e[8]!==A?(I=()=>{if(!A)return;const ve=window.setTimeout(()=>x(wd),v3);return()=>window.clearTimeout(ve)},N=[A],e[8]=A,e[9]=I,e[10]=N):(I=e[9],N=e[10]),m.useEffect(I,N);let k;e[11]!==b.chords?(k=qo(b.chords.join(" ")),e[11]=b.chords,e[12]=k):k=e[12];const P=k;let j;e[13]!==a||e[14]!==P||e[15]!==n?(j=a&&P?ng(a.id,P,n):[],e[13]=a,e[14]=P,e[15]=n,e[16]=j):j=e[16];const C=j;let E;e[17]!==C?(E=C.find(S3),e[17]=C,e[18]=E):E=e[18];const F=E;let O,K,D,M,T,R,$,z,Q,V,L,B,W,Y,ae;if(e[19]!==a||e[20]!==p||e[21]!==P||e[22]!==h||e[23]!==C||e[24]!==u||e[25]!==d||e[26]!==o||e[27]!==i||e[28]!==F||e[29]!==b||e[30]!==l){const ve=C.filter(y3);T=ve.find(N3);const be=ve.find(C3),ne=C.find(I3);let we;e[46]!==o?(we=()=>o(!1),e[46]=o,e[47]=we):we=e[47],D=we,M=()=>{b.settled||x(wd),!(!a||!P||F||T)&&(i(a.id,P,be?.action.id),D())};let Ne;e[48]!==a||e[49]!==u||e[50]!==d||e[51]!==b?(Ne=(Ue,Ye)=>{Ue.preventDefault(),Ue.stopPropagation();const lt=!!(a&&"prefixStyle"in a&&a.prefixStyle);if(Ye==="keyup"&&lt&&b.chords.length===0){const ut=k3(Ue,{...rm,maxKeys:d});if(ut){x({chords:[ut],livePreview:null,settled:!0});return}}const at=w3(b,{altKey:Ue.altKey,code:Ue.nativeEvent.code,ctrlKey:Ue.ctrlKey,isComposing:Ue.nativeEvent.isComposing,key:Ue.key,metaKey:Ue.metaKey,repeat:Ue.repeat,shiftKey:Ue.shiftKey},Ye,u,{maxKeys:d});x(lt&&at.chords.length>1?b:at)},e[48]=a,e[49]=u,e[50]=d,e[51]=b,e[52]=Ne):Ne=e[52];const Ie=Ne;K=Tt,Y=a!==null,ae=P3,O=Et,R="max-w-md",$=w,z=!1;let Ce;e[53]!==a||e[54]!==p||e[55]!==l?(Ce=a?l("settings.openchamber.keyboardShortcuts.dialog.title",{action:p(a)}):"",e[53]=a,e[54]=p,e[55]=l,e[56]=Ce):Ce=e[56];let Me;e[57]!==Ce?(Me=s.jsx(Ot,{children:Ce}),e[57]=Ce,e[58]=Me):Me=e[58];const he=u===1?"settings.openchamber.keyboardShortcuts.dialog.instructionsSingle":"settings.openchamber.keyboardShortcuts.dialog.instructions";let Pe;e[59]!==l||e[60]!==he?(Pe=l(he),e[59]=l,e[60]=he,e[61]=Pe):Pe=e[61];let Re;e[62]!==Pe?(Re=s.jsx(Ft,{children:Pe}),e[62]=Pe,e[63]=Re):Re=e[63],e[64]!==Me||e[65]!==Re?(Q=s.jsxs(Rt,{children:[Me,Re]}),e[64]=Me,e[65]=Re,e[66]=Q):Q=e[66];let ce,je;e[67]!==Ie?(ce=Ue=>Ie(Ue,"keydown"),je=Ue=>Ie(Ue,"keyup"),e[67]=Ie,e[68]=ce,e[69]=je):(ce=e[68],je=e[69]);let de;e[70]===Symbol.for("react.memo_cache_sentinel")?(de=()=>x(A3),e[70]=de):de=e[70];let ie;e[71]!==b.chords?(ie=b.chords.map(T3),e[71]=b.chords,e[72]=ie):ie=e[72];let xe;e[73]!==b.livePreview?(xe=b.livePreview?s.jsx("kbd",{className:"rounded-md border border-dashed border-border bg-muted px-3 py-2 typography-ui-label text-muted-foreground",children:Hn(b.livePreview)}):null,e[73]=b.livePreview,e[74]=xe):xe=e[74];let Se;e[75]!==b.chords.length||e[76]!==b.livePreview||e[77]!==l?(Se=b.chords.length===0&&!b.livePreview?s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:l("settings.openchamber.keyboardShortcuts.dialog.recording")}):null,e[75]=b.chords.length,e[76]=b.livePreview,e[77]=l,e[78]=Se):Se=e[78];let Le;e[79]!==ie||e[80]!==xe||e[81]!==Se?(Le=s.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[ie,xe,Se]}),e[79]=ie,e[80]=xe,e[81]=Se,e[82]=Le):Le=e[82],e[83]!==ce||e[84]!==je||e[85]!==Le?(V=s.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-lg border border-border bg-[var(--surface-elevated)] px-4 py-5 text-center outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,ref:w,onKeyDown:ce,onKeyUp:je,onBlur:de,children:Le}),e[83]=ce,e[84]=je,e[85]=Le,e[86]=V):V=e[86],L=b.settled&&F?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:l("settings.openchamber.keyboardShortcuts.error.internalConflict")}):b.settled&&T?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:l("settings.openchamber.keyboardShortcuts.error.prefixConflict",{action:p(T.action)})}):null,B=b.settled&&be&&!F&&!T?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:l("settings.openchamber.keyboardShortcuts.error.exactConflict",{action:p(be.action)})}):null,W=b.settled&&ne&&!F&&!T?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:l("settings.openchamber.keyboardShortcuts.warning.contextualPrefix",{action:h(ne)})}):null,e[19]=a,e[20]=p,e[21]=P,e[22]=h,e[23]=C,e[24]=u,e[25]=d,e[26]=o,e[27]=i,e[28]=F,e[29]=b,e[30]=l,e[31]=O,e[32]=K,e[33]=D,e[34]=M,e[35]=T,e[36]=R,e[37]=$,e[38]=z,e[39]=Q,e[40]=V,e[41]=L,e[42]=B,e[43]=W,e[44]=Y,e[45]=ae}else O=e[31],K=e[32],D=e[33],M=e[34],T=e[35],R=e[36],$=e[37],z=e[38],Q=e[39],V=e[40],L=e[41],B=e[42],W=e[43],Y=e[44],ae=e[45];let ee;e[87]!==P||e[88]!==b.settled||e[89]!==l?(ee=b.settled&&P&&ag(P)?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:l("settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut")}):null,e[87]=P,e[88]=b.settled,e[89]=l,e[90]=ee):ee=e[90];let G;e[91]!==l?(G=l("settings.common.actions.cancel"),e[91]=l,e[92]=G):G=e[92];let le;e[93]!==D||e[94]!==G?(le=s.jsx(H,{type:"button",variant:"ghost",size:"sm",onClick:D,children:G}),e[93]=D,e[94]=G,e[95]=le):le=e[95];const J=!P||b.settled&&(!!F||!!T);let me;e[96]!==l?(me=l("settings.openchamber.keyboardShortcuts.actions.confirm"),e[96]=l,e[97]=me):me=e[97];let fe;e[98]!==M||e[99]!==J||e[100]!==me?(fe=s.jsx(H,{type:"button",size:"sm",disabled:J,onClick:M,children:me}),e[98]=M,e[99]=J,e[100]=me,e[101]=fe):fe=e[101];let oe;e[102]!==le||e[103]!==fe?(oe=s.jsxs(Wt,{children:[le,fe]}),e[102]=le,e[103]=fe,e[104]=oe):oe=e[104];let pe;e[105]!==O||e[106]!==R||e[107]!==$||e[108]!==z||e[109]!==Q||e[110]!==V||e[111]!==L||e[112]!==B||e[113]!==W||e[114]!==ee||e[115]!==oe?(pe=s.jsxs(O,{className:R,initialFocus:$,showCloseButton:z,children:[Q,V,L,B,W,ee,oe]}),e[105]=O,e[106]=R,e[107]=$,e[108]=z,e[109]=Q,e[110]=V,e[111]=L,e[112]=B,e[113]=W,e[114]=ee,e[115]=oe,e[116]=pe):pe=e[116];let se;return e[117]!==K||e[118]!==Y||e[119]!==ae||e[120]!==pe?(se=s.jsx(K,{open:Y,onOpenChange:ae,children:pe}),e[117]=K,e[118]=Y,e[119]=ae,e[120]=pe,e[121]=se):se=e[121],se};function S3(t){return!t.action.customizable&&t.kind!=="contextual-prefix"}function N3(t){return t.kind==="prefix"}function C3(t){return t.kind==="exact"}function I3(t){return t.kind==="contextual-prefix"}function P3(t,e){t||e.cancel()}function A3(t){return{...t,livePreview:null}}function T3(t,e){return s.jsx("kbd",{className:"rounded-md border border-border bg-muted px-3 py-2 typography-ui-label text-foreground",children:Hn(t)},`${t}-${e}`)}const Tr=[.3,.35,.4,.45,.5,.6,1],E3=t=>{const e=De.c(41),{quake:a,miniChatCombo:n,onReleaseMiniChatShortcut:i}=t,{t:o}=Ee(),[r,c]=Ke.useState(!1),u=re(M3),d=re(D3);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=Wo().find(R3)??null,e[0]=l):l=e[0];const f=l;let p;e[1]!==n||e[2]!==u?(p=n?{...u,mini_chat_global:n}:u,e[1]=n,e[2]=u,e[3]=p):p=e[3];const g=p;let h=Tr[0];for(const D of Tr)Math.abs(D-a.heightFraction)<Math.abs(h-a.heightFraction)&&(h=D);const y=String(h),{saveShortcut:b}=a;let x;e[4]!==i||e[5]!==b||e[6]!==d||e[7]!==u?(x=(D,M,T)=>{b(M).then(R=>{if(!(!R||!T)){if(T==="mini_chat_global"){i();return}d(T,_n),jt({shortcutOverrides:{...u,[T]:_n}})}})},e[4]=i,e[5]=b,e[6]=d,e[7]=u,e[8]=x):x=e[8];const w=x;if(!a.supported)return null;const S=a.enabled;let v;e[9]!==a?(v=D=>{D!==a.enabled&&a.setEnabled(D)},e[9]=a,e[10]=v):v=e[10];const A=a.isSaving;let I;e[11]!==o?(I=o("settings.openchamber.desktopNetwork.field.quakeMode"),e[11]=o,e[12]=I):I=e[12];let N;e[13]!==o?(N=o("settings.openchamber.desktopNetwork.field.quakeModeDescription"),e[13]=o,e[14]=N):N=e[14];let k;e[15]!==o?(k=o("settings.openchamber.desktopNetwork.field.quakeModeAria"),e[15]=o,e[16]=k):k=e[16];let P;e[17]!==a.enabled||e[18]!==a.isSaving||e[19]!==v||e[20]!==I||e[21]!==N||e[22]!==k?(P=s.jsx(ct,{settingsItem:"sessions.desktop-quake-mode",checked:S,onChange:v,disabled:A,label:I,info:N,ariaLabel:k}),e[17]=a.enabled,e[18]=a.isSaving,e[19]=v,e[20]=I,e[21]=N,e[22]=k,e[23]=P):P=e[23];let j;e[24]!==a||e[25]!==o?(j=a.enabled?s.jsxs(st,{label:o("settings.openchamber.desktopNetwork.field.quakeModeShortcut"),info:o("settings.openchamber.desktopNetwork.field.quakeModeShortcutDescription"),description:a.combo&&!a.active?s.jsx("span",{className:"block text-[var(--status-warning)]",children:o("settings.openchamber.desktopNetwork.field.quakeModeShortcutInactive")}):void 0,children:[s.jsx("kbd",{className:"min-w-32 oc-tile-inset rounded-md px-2 py-1 text-center typography-meta text-foreground",children:a.combo?Hn(a.combo):o("settings.openchamber.keyboardShortcuts.unassigned")}),s.jsx(H,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",disabled:a.isSaving,onClick:()=>c(!0),children:o("settings.openchamber.keyboardShortcuts.actions.edit")}),a.storedCombo?s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",disabled:a.isSaving,onClick:()=>{a.saveShortcut(null)},children:o("settings.common.actions.reset")}):null]}):null,e[24]=a,e[25]=o,e[26]=j):j=e[26];let C;e[27]!==y||e[28]!==a||e[29]!==o?(C=a.enabled?s.jsx(st,{label:o("settings.openchamber.desktopNetwork.field.quakeModeHeight"),info:o("settings.openchamber.desktopNetwork.field.quakeModeHeightDescription"),children:s.jsxs(Pt,{value:y,onValueChange:D=>{const M=Number(D);Number.isFinite(M)&&a.setHeight(M)},disabled:a.isSaving,children:[s.jsx(Ct,{className:Es,"aria-label":o("settings.openchamber.desktopNetwork.field.quakeModeHeightAria"),children:s.jsx(Kt,{})}),s.jsx(It,{children:Tr.map(O3)})]})}):null,e[27]=y,e[28]=a,e[29]=o,e[30]=C):C=e[30];const E=r?f:null;let F;e[31]===Symbol.for("react.memo_cache_sentinel")?(F=D=>{D||c(!1)},e[31]=F):F=e[31];let O;e[32]!==w||e[33]!==g||e[34]!==E?(O=s.jsx(Cl,{action:E,overrides:g,onSave:w,onOpenChange:F,maxChords:1,maxKeys:5}),e[32]=w,e[33]=g,e[34]=E,e[35]=O):O=e[35];let K;return e[36]!==P||e[37]!==j||e[38]!==C||e[39]!==O?(K=s.jsxs(s.Fragment,{children:[P,j,C,O]}),e[36]=P,e[37]=j,e[38]=C,e[39]=O,e[40]=K):K=e[40],K};function M3(t){return t.shortcutOverrides}function D3(t){return t.setShortcutOverride}function R3(t){return t.id==="quake_mode_global"}function O3(t){return s.jsx(bt,{value:String(t),children:`${Math.round(t*100)}%`},t)}const F3=(t,e)=>{const{t:a}=Ee(),[n,i]=Ke.useState(null),[o,r]=Ke.useState(!1);Ke.useEffect(()=>{if(!t){i(null);return}let g=!1;return(async()=>{const h=await iu();g||i(h)})(),()=>{g=!0}},[t]);const c=n?.supported===!0,u=Ke.useCallback(async g=>{if(!c||o)return null;r(!0),e(null);try{const h=await g();if(!h?.supported)throw new Error(a("settings.openchamber.desktopNetwork.error.quakeModeSaveFailed"));return i(h),h}catch(h){return e(h instanceof Error?h.message:a("settings.openchamber.desktopNetwork.error.quakeModeSaveFailed")),null}finally{r(!1)}},[o,e,c,a]),d=Ke.useCallback(g=>{u(()=>Gg(g))},[u]),l=Ke.useCallback(async g=>{const h=await u(()=>Rr(g));return h?h.error==="unsupported-combo"?(e(a("settings.openchamber.desktopNetwork.error.quakeModeShortcutUnsupported")),!1):!0:!1},[u,e,a]),f=Ke.useCallback(g=>{u(()=>Jg(g))},[u]),p=Ke.useCallback(()=>{Rr(_n).then(g=>{g&&i(g)})},[]);return{supported:c,enabled:n?.enabled===!0,combo:n?.combo??null,storedCombo:n?.storedCombo??null,active:n?.active===!0,heightFraction:n?.heightFraction??1,isSaving:o,setEnabled:d,saveShortcut:l,setHeight:f,release:p}},Sd=t=>{const e=De.c(2),{message:a}=t;let n;return e[0]!==a?(n=a?s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:a}):null,e[0]=a,e[1]=n):n=e[1],n},L3=()=>{const{t}=Ee(),e=is()&&ri(),a=e&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",n=e&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="linux",[i,o]=Ke.useState(!0),[r,c]=Ke.useState(!1),[u,d]=Ke.useState(!1),[l,f]=Ke.useState(!1),[p,g]=Ke.useState(!1),[h,y]=Ke.useState(!1),[b,x]=Ke.useState(!1),[w,S]=Ke.useState(!1),[v,A]=Ke.useState(!0),[I,N]=Ke.useState(!0),[k,P]=Ke.useState(!1),[j,C]=Ke.useState(!1),[E,F]=Ke.useState(!1),[O,K]=Ke.useState(!1),[D,M]=Ke.useState(!1),[T,R]=Ke.useState(!1),[$,z]=Ke.useState(null),[Q,V]=Ke.useState(!1),[L,B]=Ke.useState(!1),[W,Y]=Ke.useState(!1),ae=re(de=>de.shortcutOverrides),ee=re(de=>de.setShortcutOverride),G=Ke.useMemo(()=>Wo().find(de=>de.id==="mini_chat_global")??null,[]),[le,J]=Ke.useState(null),[me,fe]=Ke.useState(null),oe=F3(e,fe),{release:pe}=oe,se=Ke.useMemo(()=>oe.combo?{...ae,quake_mode_global:oe.combo}:ae,[oe.combo,ae]);Ke.useEffect(()=>{if(!e||!a&&!n){o(!1);return}let de=!1;return(async()=>{try{const ie=await fn();if(!ie)throw new Error(t("settings.openchamber.desktopNetwork.error.loadFailed"));if(de)return;const xe=ie.desktopMacMenuBarEnabled!==!1;A(xe),N(xe);const Se=ie.desktopLinuxNativeFrame===!0;P(Se),C(Se),J(null)}catch(ie){de||J(ie instanceof Error?ie.message:t("settings.openchamber.desktopNetwork.error.loadFailed"))}finally{de||o(!1)}})(),()=>{de=!0}},[n,e,a,t]),Ke.useEffect(()=>{if(!e){d(!1);return}let de=!1;return(async()=>{const ie=await Qg();de||(d(ie?.supported===!0),f(ie?.enabled===!0))})(),()=>{de=!0}},[e]),Ke.useEffect(()=>{if(!e){y(!1);return}let de=!1;return(async()=>{const ie=await Yg();de||(y(ie?.supported===!0),x(ie?.enabled===!0))})(),()=>{de=!0}},[e]),Ke.useEffect(()=>{if(!e){F(!1);return}let de=!1;return(async()=>{const ie=await Zg();de||(F(ie?.supported===!0),K(ie?.enabled===!0))})(),()=>{de=!0}},[e]),Ke.useEffect(()=>{if(!e){R(!1);return}let de=!1;return(async()=>{const ie=await ou();de||(R(ie?.supported===!0),z(ie?.combo??null),V(ie?.active===!0))})(),()=>{de=!0}},[e]);const ve=I!==v||j!==k,be=ei(de=>de.setDraft),ne=ei(de=>!!(de.patches.app||de.patches.network)),we=ei(de=>!!de.blocked.network);Ke.useEffect(()=>{be("app",ve?{...I!==v?{desktopMacMenuBarEnabled:I}:{},...j!==k?{desktopLinuxNativeFrame:j}:{}}:null,!1)},[j,I,ve,k,v,be]),Ke.useEffect(()=>()=>be("app",null,!1),[be]);const Ne=Ke.useCallback(async()=>{if(!u||p)return;const de=!l;f(de),g(!0),J(null);try{const ie=await Xg(de);if(!ie?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.launchAtLoginUnsupported"));f(ie.enabled)}catch(ie){f(!de),J(ie instanceof Error?ie.message:t("settings.openchamber.desktopNetwork.error.launchAtLoginSaveFailed"))}finally{g(!1)}},[p,l,u,t]),Ie=Ke.useCallback(async()=>{if(!h||w)return;const de=!b;x(de),S(!0),J(null);try{const ie=await ef(de);if(!ie)throw new Error(t("settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed"));if(!ie.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.minimizeToTrayUnsupported"));x(ie.enabled)}catch(ie){x(!de),J(ie instanceof Error?ie.message:t("settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed"))}finally{S(!1)}},[w,b,h,t]),Ce=Ke.useCallback(async()=>{if(!E||D)return;const de=!O;K(de),M(!0),J(null);try{const ie=await tf(de);if(!ie?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.keepAwakeUnsupported"));K(ie.enabled)}catch(ie){K(!de),J(ie instanceof Error?ie.message:t("settings.openchamber.desktopNetwork.error.keepAwakeSaveFailed"))}finally{M(!1)}},[D,O,E,t]),Me=Ke.useCallback(async de=>{if(!T||L)return!1;B(!0),fe(null);try{const ie=await Or(de);if(!ie?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.miniChatGlobalShortcutSaveFailed"));return z(ie.combo??null),V(ie.active===!0),ie.error==="unsupported-combo"?(fe(t("settings.openchamber.desktopNetwork.error.miniChatGlobalShortcutUnsupported")),!1):!0}catch(ie){return fe(ie instanceof Error?ie.message:t("settings.openchamber.desktopNetwork.error.miniChatGlobalShortcutSaveFailed")),!1}finally{B(!1)}},[L,T,t]),he=Ke.useCallback((de,ie,xe)=>{Me(ie).then(Se=>{if(!(!Se||!xe)){if(xe==="quake_mode_global"){pe();return}ee(xe,_n),jt({shortcutOverrides:{...ae,[xe]:_n}})}})},[Me,pe,ee,ae]),Pe=Ke.useCallback(()=>{Or(null).then(de=>{de&&(z(de.combo??null),V(de.active===!0))})},[]),Re=Ke.useCallback(async()=>{c(!0),J(null);try{if(!await am())throw new Error(t("settings.openchamber.desktopNetwork.error.saveFailed"));if(A(I),P(j),!await au())throw new Error(t("settings.openchamber.desktopNetwork.error.savedRestartFailed"))}catch(de){J(de instanceof Error?de.message:t("settings.openchamber.desktopNetwork.error.saveFailed")),c(!1)}},[j,I,t]);if(!e)return null;const ce=u||a||n||h||E,je=T||oe.supported;return s.jsxs(s.Fragment,{children:[ce?s.jsxs($e,{title:t("settings.layout.general.desktopApp.title"),divider:!1,contentClassName:"space-y-3",children:[s.jsxs("div",{className:bs,children:[u?s.jsx(ct,{settingsItem:"sessions.desktop-launch-at-login",checked:l,onChange:de=>{de!==l&&Ne()},disabled:p,label:t("settings.openchamber.desktopNetwork.field.launchAtLogin"),info:t("settings.openchamber.desktopNetwork.field.launchAtLoginDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.launchAtLoginAria")}):null,h?s.jsx(ct,{settingsItem:"sessions.desktop-minimize-to-tray",checked:b,onChange:de=>{de!==b&&Ie()},disabled:w,label:t("settings.openchamber.desktopNetwork.field.minimizeToTray"),info:t("settings.openchamber.desktopNetwork.field.minimizeToTrayDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.minimizeToTrayAria")}):null,E?s.jsx(ct,{settingsItem:"sessions.desktop-keep-awake",checked:O,onChange:de=>{de!==O&&Ce()},disabled:D,label:t("settings.openchamber.desktopNetwork.field.keepAwake"),info:t("settings.openchamber.desktopNetwork.field.keepAwakeDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.keepAwakeAria")}):null,a?s.jsx(ct,{settingsItem:"sessions.desktop-mac-menu-bar",checked:I,onChange:N,disabled:i||r,label:t("settings.openchamber.desktopNetwork.field.macMenuBar"),info:t("settings.openchamber.desktopNetwork.field.macMenuBarDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.macMenuBarAria")}):null,n?s.jsx(ct,{settingsItem:"sessions.desktop-linux-native-frame",checked:j,onChange:C,disabled:i||r,label:t("settings.openchamber.desktopNetwork.field.linuxNativeFrame"),info:t("settings.openchamber.desktopNetwork.field.linuxNativeFrameDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.linuxNativeFrame")}):null]}),s.jsx(Sd,{message:le}),a||n?s.jsx(H,{type:"button",size:"xs",onClick:Re,disabled:i||r||!ne||we,className:"!font-normal",children:t(r?"settings.common.actions.saving":"settings.openchamber.desktopNetwork.actions.saveAndRestart")}):null]}):null,je?s.jsxs($e,{title:t("settings.layout.general.quickAccess.title"),info:t("settings.layout.general.quickAccess.info"),divider:ce,contentClassName:"space-y-2",children:[T?s.jsxs(st,{settingsItem:"sessions.desktop-mini-chat-global-shortcut",label:t("settings.openchamber.desktopNetwork.field.miniChatGlobalShortcut"),info:t("settings.openchamber.desktopNetwork.field.miniChatGlobalShortcutDescription"),description:$&&!Q?s.jsx("span",{className:"block text-[var(--status-warning)]",children:t("settings.openchamber.desktopNetwork.field.miniChatGlobalShortcutInactive")}):void 0,children:[s.jsx("kbd",{className:"min-w-32 oc-tile-inset rounded-md px-2 py-1 text-center typography-meta text-foreground",children:$?Hn($):t("settings.openchamber.keyboardShortcuts.unassigned")}),s.jsx(H,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",disabled:L,onClick:()=>Y(!0),children:t("settings.openchamber.keyboardShortcuts.actions.edit")}),$?s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",disabled:L,onClick:()=>{Me(null)},children:t("settings.common.actions.reset")}):null]}):null,s.jsx(E3,{quake:oe,miniChatCombo:$,onReleaseMiniChatShortcut:Pe}),s.jsx(Sd,{message:me}),s.jsx(Cl,{action:W?G:null,overrides:se,onSave:he,onOpenChange:de=>{de||Y(!1)},maxChords:1,maxKeys:5})]}):null]})},K3=2e3,_3=3,$3=(t,e)=>t.state==="unsupported"||t.state==="failed"?!0:e?t.state==="on"&&t.index?.backfill.state!=="running":t.state==="off",z3=t=>{const e=t/1e6;return new Intl.NumberFormat(Bo(),{style:"unit",unit:"megabyte",maximumFractionDigits:e<10?1:0}).format(e)},U3=()=>{const t=De.c(70),{t:e}=Ee(),a=re(B3),n=re(V3),i=re(H3),o=re(q3);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={kind:"loading"},t[0]=r):r=t[0];const[c,u]=m.useState(r),[d,l]=m.useState(!1),f=m.useRef(i);let p,g;t[1]!==a||t[2]!==i?(p=()=>{const $=a&&i&&!f.current;f.current=i;const z=new AbortController;let Q,V=$?_3:0;const L=()=>{cg(z.signal).then(B=>{if(z.signal.aborted)return;u({kind:"ready",status:B}),B.index?.backfill.state==="running"&&(V=0);const W=V>0;V=V-1,(!$3(B,a)||W)&&(Q=setTimeout(L,K3))}).catch(()=>{z.signal.aborted||u({kind:"error"})})};return L(),()=>{z.abort(),clearTimeout(Q)}},g=[a,i],t[1]=a,t[2]=i,t[3]=p,t[4]=g):(p=t[3],g=t[4]),m.useEffect(p,g);let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{l(!0),lg().then($=>u({kind:"ready",status:$})).catch(()=>u({kind:"error"})).finally(()=>l(!1))},t[5]=h):h=t[5];const y=h,b=c.kind==="ready"?c.status:null,x=b?.state==="unsupported";let w;if(t[6]!==a||t[7]!==b?.sizeBytes||t[8]!==e||t[9]!==c.kind||t[10]!==c.status){const $=z3(b?.sizeBytes??0);if(c.kind==="loading"){let z;t[12]!==e?(z=e("settings.openchamber.messageSearch.status.loading"),t[12]=e,t[13]=z):z=t[13],w=z}else if(c.kind==="error"){let z;t[14]!==e?(z=e("settings.openchamber.messageSearch.status.error"),t[14]=e,t[15]=z):z=t[15],w=z}else if(c.status.state==="unsupported"){let z;t[16]!==e?(z=e("settings.openchamber.messageSearch.status.unsupported"),t[16]=e,t[17]=z):z=t[17],w=z}else if(!a)w=c.status.sizeBytes>0?e("settings.openchamber.messageSearch.status.offWithFile",{size:$}):e("settings.openchamber.messageSearch.status.off");else if(c.status.state==="failed"){let z;t[18]!==e?(z=e("settings.openchamber.messageSearch.status.failed"),t[18]=e,t[19]=z):z=t[19],w=z}else if(c.status.state==="on"&&c.status.index?.backfill.state==="running")w=e("settings.openchamber.messageSearch.status.indexing",{done:c.status.index.backfill.done,total:c.status.index.backfill.total,size:$});else if(c.status.state==="on"&&c.status.index)w=e("settings.openchamber.messageSearch.status.ready",{sessions:c.status.index.sessions,messages:c.status.index.messages,size:$});else{let z;t[20]!==e?(z=e("settings.openchamber.messageSearch.status.loading"),t[20]=e,t[21]=z):z=t[21],w=z}t[6]=a,t[7]=b?.sizeBytes,t[8]=e,t[9]=c.kind,t[10]=c.status,t[11]=w}else w=t[11];let S;t[22]!==e?(S=e("settings.openchamber.messageSearch.title"),t[22]=e,t[23]=S):S=t[23];let v;t[24]!==e?(v=e("settings.openchamber.messageSearch.field.enabled"),t[24]=e,t[25]=v):v=t[25];let A;t[26]!==e?(A=e("settings.openchamber.messageSearch.field.enabled"),t[26]=e,t[27]=A):A=t[27];let I;t[28]!==e?(I=e("settings.openchamber.messageSearch.field.enabledInfo"),t[28]=e,t[29]=I):I=t[29];let N;t[30]!==a||t[31]!==n||t[32]!==v||t[33]!==A||t[34]!==I||t[35]!==x?(N=s.jsx(ct,{settingsItem:"chat.message-search-enabled",checked:a,onChange:n,disabled:x,label:v,ariaLabel:A,info:I}),t[30]=a,t[31]=n,t[32]=v,t[33]=A,t[34]=I,t[35]=x,t[36]=N):N=t[36];const k=a&&i,P=!a||x;let j;t[37]!==e?(j=e("settings.openchamber.messageSearch.field.reasoning"),t[37]=e,t[38]=j):j=t[38];let C;t[39]!==e?(C=e("settings.openchamber.messageSearch.field.reasoning"),t[39]=e,t[40]=C):C=t[40];let E;t[41]!==e?(E=e("settings.openchamber.messageSearch.field.reasoningInfo"),t[41]=e,t[42]=E):E=t[42];let F;t[43]!==o||t[44]!==P||t[45]!==j||t[46]!==C||t[47]!==E||t[48]!==k?(F=s.jsx(ct,{settingsItem:"chat.message-search-reasoning",checked:k,onChange:o,disabled:P,label:j,ariaLabel:C,info:E}),t[43]=o,t[44]=P,t[45]=j,t[46]=C,t[47]=E,t[48]=k,t[49]=F):F=t[49];let O;t[50]!==e?(O=e("settings.openchamber.messageSearch.field.index"),t[50]=e,t[51]=O):O=t[51];let K;t[52]!==a||t[53]!==b||t[54]!==e||t[55]!==d?(K=a?s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:y,disabled:d||b?.state!=="on"&&b?.state!=="failed",children:e(d?"settings.openchamber.messageSearch.actions.working":"settings.openchamber.messageSearch.actions.rebuild")}):s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:y,disabled:d||!b||b.state==="on"||b.sizeBytes===0,children:e(d?"settings.openchamber.messageSearch.actions.working":"settings.openchamber.messageSearch.actions.delete")}),t[52]=a,t[53]=b,t[54]=e,t[55]=d,t[56]=K):K=t[56];let D;t[57]!==O||t[58]!==K?(D=s.jsx(st,{label:O,children:K}),t[57]=O,t[58]=K,t[59]=D):D=t[59];let M;t[60]!==w?(M=s.jsx("p",{className:_t,"aria-live":"polite",children:w}),t[60]=w,t[61]=M):M=t[61];let T;t[62]!==F||t[63]!==D||t[64]!==M?(T=s.jsxs(_i,{children:[F,D,M]}),t[62]=F,t[63]=D,t[64]=M,t[65]=T):T=t[65];let R;return t[66]!==T||t[67]!==S||t[68]!==N?(R=s.jsxs($e,{title:S,settingsItem:"chat.message-search",children:[N,T]}),t[66]=T,t[67]=S,t[68]=N,t[69]=R):R=t[69],R};function B3(t){return t.messageSearchEnabled}function V3(t){return t.setMessageSearchEnabled}function H3(t){return t.messageSearchReasoningEnabled}function q3(t){return t.setMessageSearchReasoningEnabled}const W3=()=>{re.getState().requestSettingsJump("sessions","sessions.small-model")},G3=t=>{const e=De.c(33),{disabled:a}=t,n=a===void 0?!1:a,{t:i}=Ee(),o=re(Q3),r=re(Y3),c=Bt(ul),u=!Pn(),d=c?o:"small-model";let l;e[0]!==i?(l=i("settings.openchamber.visual.goal.checkerLabel"),e[0]=i,e[1]=l):l=e[1];let f;e[2]!==i?(f=i("settings.openchamber.visual.goal.checkerInfo"),e[2]=i,e[3]=f):f=e[3];let p;e[4]!==i?(p=i("settings.openchamber.visual.goal.checkerLabel"),e[4]=i,e[5]=p):p=e[5];const g=n||!c;let h;e[6]!==g?(h={value:"classifier",label:"Jev",disabled:g},e[6]=g,e[7]=h):h=e[7];let y;e[8]!==i?(y=i("settings.openchamber.visual.goal.checker.smallModel"),e[8]=i,e[9]=y):y=e[9];let b;e[10]!==n||e[11]!==y?(b={value:"small-model",label:y,disabled:n},e[10]=n,e[11]=y,e[12]=b):b=e[12];let x;e[13]!==h||e[14]!==b?(x=[h,b],e[13]=h,e[14]=b,e[15]=x):x=e[15];let w;e[16]!==r||e[17]!==d||e[18]!==p||e[19]!==x?(w=s.jsx(Xt,{"aria-label":p,value:d,onChange:r,options:x}),e[16]=r,e[17]=d,e[18]=p,e[19]=x,e[20]=w):w=e[20];let S;e[21]!==w||e[22]!==l||e[23]!==f?(S=s.jsx(st,{settingsItem:"chat.session-goal-checker",label:l,info:f,children:w}),e[21]=w,e[22]=l,e[23]=f,e[24]=S):S=e[24];let v;e[25]!==u||e[26]!==c||e[27]!==d||e[28]!==i?(v=d==="classifier"?s.jsx(Zo,{}):s.jsxs("p",{className:_t,children:[i(c?"settings.openchamber.visual.goal.checker.viaSmallModel":"settings.openchamber.visual.goal.checker.jevMissing")," ",s.jsx(Vn,{onClick:W3,children:i("settings.openchamber.visual.goal.checker.smallModelLink")}),c||!u?null:s.jsxs(s.Fragment,{children:[" · ",s.jsx(Vn,{onClick:Fo,children:i("settings.jevAccess.setUp")})]})]}),e[25]=u,e[26]=c,e[27]=d,e[28]=i,e[29]=v):v=e[29];let A;return e[30]!==S||e[31]!==v?(A=s.jsxs("div",{className:"space-y-1",children:[S,v]}),e[30]=S,e[31]=v,e[32]=A):A=e[32],A},J3=t=>{const e=De.c(32),{disabled:a}=t,n=a===void 0?!1:a,{t:i}=Ee(),o=re(Z3),r=re(X3);let c;e[0]!==i?(c=i("settings.openchamber.visual.goal.maxTurnsLabel"),e[0]=i,e[1]=c):c=e[1];let u;e[2]!==i?(u=i("settings.openchamber.visual.goal.maxTurnsInfo"),e[2]=i,e[3]=u):u=e[3];let d;e[4]!==r?(d=v=>r(Math.floor(v)),e[4]=r,e[5]=d):d=e[5];let l;e[6]!==i?(l=i("settings.openchamber.visual.goal.maxTurnsLabel"),e[6]=i,e[7]=l):l=e[7];let f;e[8]!==n||e[9]!==o||e[10]!==d||e[11]!==l?(f=s.jsx(ds,{value:o,onValueChange:d,min:1,max:sf,step:1,disabled:n,className:us,"aria-label":l}),e[8]=n,e[9]=o,e[10]=d,e[11]=l,e[12]=f):f=e[12];let p;e[13]!==r?(p=()=>r(Zl),e[13]=r,e[14]=p):p=e[14];const g=n||o===Zl;let h;e[15]!==i?(h=i("settings.openchamber.visual.goal.maxTurnsResetAria"),e[15]=i,e[16]=h):h=e[16];let y;e[17]!==i?(y=i("settings.common.actions.reset"),e[17]=i,e[18]=y):y=e[18];let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"}),e[19]=b):b=e[19];let x;e[20]!==y||e[21]!==p||e[22]!==g||e[23]!==h?(x=s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:p,disabled:g,className:Yt,"aria-label":h,title:y,children:b}),e[20]=y,e[21]=p,e[22]=g,e[23]=h,e[24]=x):x=e[24];let w;e[25]!==x||e[26]!==f?(w=s.jsxs("div",{className:Fn,children:[f,x]}),e[25]=x,e[26]=f,e[27]=w):w=e[27];let S;return e[28]!==w||e[29]!==c||e[30]!==u?(S=s.jsx(st,{settingsItem:"chat.session-goal-max-turns",label:c,info:u,children:w}),e[28]=w,e[29]=c,e[30]=u,e[31]=S):S=e[31],S};function Q3(t){return t.sessionGoalChecker}function Y3(t){return t.setSessionGoalChecker}function Z3(t){return t.sessionGoalMaxAutoTurns}function X3(t){return t.setSessionGoalMaxAutoTurns}const e0=[{id:"collapsed",labelKey:"settings.openchamber.visual.option.activityRenderMode.collapsed.label"},{id:"summary",labelKey:"settings.openchamber.visual.option.activityRenderMode.summary.label"}],t0=[{id:"markdown",labelKey:"settings.openchamber.visual.option.userMessageRendering.markdown.label"},{id:"plain",labelKey:"settings.openchamber.visual.option.userMessageRendering.plain.label"}],s0=[{id:"svg",labelKey:"settings.openchamber.visual.option.mermaidRendering.svg.label"},{id:"ascii",labelKey:"settings.openchamber.visual.option.mermaidRendering.ascii.label"}],n0=[{id:"dynamic",labelKey:"settings.openchamber.visual.option.diffLayout.dynamic.label"},{id:"inline",labelKey:"settings.openchamber.visual.option.diffLayout.inline.label"},{id:"side-by-side",labelKey:"settings.openchamber.visual.option.diffLayout.sideBySide.label"}],a0=[{id:"steer",labelKey:"settings.openchamber.visual.option.followUpBehavior.steer.label"},{id:"queue",labelKey:"settings.openchamber.visual.option.followUpBehavior.queue.label"}],i0=[{id:"global",labelKey:"settings.openchamber.visual.option.inputHistoryScope.global.label"},{id:"session",labelKey:"settings.openchamber.visual.option.inputHistoryScope.session.label"}],o0=[{id:"ask",labelKey:"settings.openchamber.visual.option.largeTextPaste.ask.label"},{id:"attach",labelKey:"settings.openchamber.visual.option.largeTextPaste.attach.label"},{id:"inline",labelKey:"settings.openchamber.visual.option.largeTextPaste.inline.label"},{id:"inline-double-paste",labelKey:"settings.openchamber.visual.option.largeTextPaste.inlineDoublePaste.label"}],Nd="ps-6",Ja=t=>{const e=De.c(5),{t:a}=Ee();let n;if(e[0]!==t||e[1]!==a){let i;e[3]!==a?(i=o=>({value:o.id,label:a(o.labelKey)}),e[3]=a,e[4]=i):i=e[4],n=t.map(i),e[0]=t,e[1]=a,e[2]=n}else n=e[2];return n},r0=()=>{const t=De.c(234),{t:e}=Ee();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=os(),t[0]=a):a=t[0];const n=a,i=re(u0),o=re(m0),r=re(p0),c=re(g0),u=re(f0),d=re(h0),l=re(b0),f=re(x0),p=re(v0),g=re(y0),h=re(j0),y=re(k0),b=re(w0),x=re(S0),w=re(N0),S=re(C0),v=re(I0),A=re(P0),I=re(A0),N=re(T0),k=re(E0),P=re(M0),j=re(D0),C=re(R0),E=re(O0),F=re(F0),O=re(L0),K=re(K0),D=re(_0),M=re($0),T=re(z0),R=re(U0),$=re(B0),z=re(V0),Q=re(H0),V=re(q0),L=Ja(e0),B=Ja(t0),W=Ja(s0),Y=Ja(n0);let ae;t[1]!==o?(ae=Dt=>{o(Dt),jt({activityRenderMode:Dt,chatRenderMode:"live"})},t[1]=o,t[2]=ae):ae=t[2];const ee=ae;let G;t[3]!==e?(G=e("settings.layout.chat.section.activity"),t[3]=e,t[4]=G):G=t[4];let le;t[5]!==e?(le=e("settings.openchamber.visual.section.activityDefault"),t[5]=e,t[6]=le):le=t[6];let J;t[7]!==e?(J=e("settings.openchamber.visual.section.activityDefaultAria"),t[7]=e,t[8]=J):J=t[8];let me;t[9]!==L||t[10]!==i||t[11]!==ee||t[12]!==J?(me=s.jsx(Xt,{value:i,options:L,onChange:ee,"aria-label":J}),t[9]=L,t[10]=i,t[11]=ee,t[12]=J,t[13]=me):me=t[13];let fe;t[14]!==le||t[15]!==me?(fe=s.jsx(st,{label:le,settingsItem:"chat.activity-default",children:me}),t[14]=le,t[15]=me,t[16]=fe):fe=t[16];let oe;t[17]!==e?(oe=e("settings.openchamber.visual.field.showReasoningTraces"),t[17]=e,t[18]=oe):oe=t[18];let pe;t[19]!==e?(pe=e("settings.openchamber.visual.field.showReasoningTracesAria"),t[19]=e,t[20]=pe):pe=t[20];let se;t[21]!==c||t[22]!==r||t[23]!==oe||t[24]!==pe?(se=s.jsx(ct,{checked:r,onChange:c,label:oe,ariaLabel:pe,settingsItem:"chat.reasoning-traces"}),t[21]=c,t[22]=r,t[23]=oe,t[24]=pe,t[25]=se):se=t[25];let ve;t[26]!==u||t[27]!==d||t[28]!==r||t[29]!==e?(ve=r?s.jsx(ct,{checked:u,onChange:d,label:e("settings.openchamber.visual.field.collapsibleThinkingBlocks"),ariaLabel:e("settings.openchamber.visual.field.collapsibleThinkingBlocksAria"),className:Nd}):null,t[26]=u,t[27]=d,t[28]=r,t[29]=e,t[30]=ve):ve=t[30];let be;t[31]!==u||t[32]!==l||t[33]!==f||t[34]!==r||t[35]!==e?(be=r&&u?s.jsx(ct,{checked:l,onChange:f,label:e("settings.openchamber.visual.field.expandReasoningWhileStreaming"),ariaLabel:e("settings.openchamber.visual.field.expandReasoningWhileStreamingAria"),info:e("settings.openchamber.visual.field.expandReasoningWhileStreamingInfo"),className:Nd}):null,t[31]=u,t[32]=l,t[33]=f,t[34]=r,t[35]=e,t[36]=be):be=t[36];let ne;t[37]!==g?(ne=Dt=>{g(Dt),jt({showToolFileIcons:Dt})},t[37]=g,t[38]=ne):ne=t[38];let we;t[39]!==e?(we=e("settings.openchamber.visual.field.showToolFileIcons"),t[39]=e,t[40]=we):we=t[40];let Ne;t[41]!==e?(Ne=e("settings.openchamber.visual.field.showToolFileIconsAria"),t[41]=e,t[42]=Ne):Ne=t[42];let Ie;t[43]!==p||t[44]!==ne||t[45]!==we||t[46]!==Ne?(Ie=s.jsx(ct,{checked:p,onChange:ne,label:we,ariaLabel:Ne,settingsItem:"chat.tool-file-icons"}),t[43]=p,t[44]=ne,t[45]=we,t[46]=Ne,t[47]=Ie):Ie=t[47];let Ce;t[48]!==y?(Ce=Dt=>{y(Dt),jt({showTurnChangedFiles:Dt})},t[48]=y,t[49]=Ce):Ce=t[49];let Me;t[50]!==e?(Me=e("settings.openchamber.visual.field.showTurnChangedFiles"),t[50]=e,t[51]=Me):Me=t[51];let he;t[52]!==e?(he=e("settings.openchamber.visual.field.showTurnChangedFilesAria"),t[52]=e,t[53]=he):he=t[53];let Pe;t[54]!==h||t[55]!==Ce||t[56]!==Me||t[57]!==he?(Pe=s.jsx(ct,{checked:h,onChange:Ce,label:Me,ariaLabel:he,settingsItem:"chat.changed-files"}),t[54]=h,t[55]=Ce,t[56]=Me,t[57]=he,t[58]=Pe):Pe=t[58];let Re;t[59]!==ve||t[60]!==be||t[61]!==Ie||t[62]!==Pe||t[63]!==se?(Re=s.jsxs("div",{className:bs,"data-settings-item":"chat.reasoning",children:[se,ve,be,Ie,Pe]}),t[59]=ve,t[60]=be,t[61]=Ie,t[62]=Pe,t[63]=se,t[64]=Re):Re=t[64];let ce;t[65]!==G||t[66]!==Re||t[67]!==fe?(ce=s.jsxs($e,{title:G,divider:!1,contentClassName:"space-y-3",children:[fe,Re]}),t[65]=G,t[66]=Re,t[67]=fe,t[68]=ce):ce=t[68];let je;t[69]!==e?(je=e("settings.layout.chat.section.reading"),t[69]=e,t[70]=je):je=t[70];let de;t[71]!==S?(de=Dt=>{S(Dt),jt({wideChatLayoutEnabled:Dt})},t[71]=S,t[72]=de):de=t[72];let ie;t[73]!==e?(ie=e("settings.openchamber.visual.field.wideChatLayout"),t[73]=e,t[74]=ie):ie=t[74];let xe;t[75]!==e?(xe=e("settings.openchamber.visual.field.wideChatLayoutAria"),t[75]=e,t[76]=xe):xe=t[76];let Se;t[77]!==de||t[78]!==ie||t[79]!==xe||t[80]!==w?(Se=s.jsx(ct,{checked:w,onChange:de,label:ie,ariaLabel:xe,settingsItem:"chat.wide-layout"}),t[77]=de,t[78]=ie,t[79]=xe,t[80]=w,t[81]=Se):Se=t[81];let Le;t[82]!==e?(Le=e("settings.openchamber.visual.field.streamingAutoFollow"),t[82]=e,t[83]=Le):Le=t[83];let Ue;t[84]!==e?(Ue=e("settings.openchamber.visual.field.streamingAutoFollowAria"),t[84]=e,t[85]=Ue):Ue=t[85];let Ye;t[86]!==e?(Ye=e("settings.openchamber.visual.field.streamingAutoFollowInfo"),t[86]=e,t[87]=Ye):Ye=t[87];let lt;t[88]!==x||t[89]!==b||t[90]!==Le||t[91]!==Ue||t[92]!==Ye?(lt=s.jsx(ct,{checked:b,onChange:x,label:Le,ariaLabel:Ue,info:Ye,settingsItem:"chat.streaming-auto-follow"}),t[88]=x,t[89]=b,t[90]=Le,t[91]=Ue,t[92]=Ye,t[93]=lt):lt=t[93];let at;t[94]!==N?(at=Dt=>{N(Dt),jt({collapsibleUserMessages:Dt})},t[94]=N,t[95]=at):at=t[95];let ut;t[96]!==e?(ut=e("settings.openchamber.visual.field.collapsibleUserMessages"),t[96]=e,t[97]=ut):ut=t[97];let vt;t[98]!==e?(vt=e("settings.openchamber.visual.field.collapsibleUserMessagesAria"),t[98]=e,t[99]=vt):vt=t[99];let We;t[100]!==I||t[101]!==at||t[102]!==ut||t[103]!==vt?(We=s.jsx(ct,{checked:I,onChange:at,label:ut,ariaLabel:vt,settingsItem:"chat.collapsible-user-messages"}),t[100]=I,t[101]=at,t[102]=ut,t[103]=vt,t[104]=We):We=t[104];let Ze;t[105]!==P?(Ze=Dt=>{P(Dt),jt({stickyUserHeader:Dt})},t[105]=P,t[106]=Ze):Ze=t[106];let Xe;t[107]!==e?(Xe=e("settings.openchamber.visual.field.stickyUserHeader"),t[107]=e,t[108]=Xe):Xe=t[108];let it;t[109]!==e?(it=e("settings.openchamber.visual.field.stickyUserHeaderAria"),t[109]=e,t[110]=it):it=t[110];let dt;t[111]!==k||t[112]!==Ze||t[113]!==Xe||t[114]!==it?(dt=s.jsx(ct,{checked:k,onChange:Ze,label:Xe,ariaLabel:it,settingsItem:"chat.sticky-user-header"}),t[111]=k,t[112]=Ze,t[113]=Xe,t[114]=it,t[115]=dt):dt=t[115];let Be;t[116]!==A?(Be=Dt=>{A(Dt),jt({promptNavigatorEnabled:Dt})},t[116]=A,t[117]=Be):Be=t[117];let ot;t[118]!==e?(ot=e("settings.openchamber.visual.field.promptNavigatorEnabled"),t[118]=e,t[119]=ot):ot=t[119];let et;t[120]!==e?(et=e("settings.openchamber.visual.field.promptNavigatorEnabledAria"),t[120]=e,t[121]=et):et=t[121];let ye;t[122]!==v||t[123]!==Be||t[124]!==ot||t[125]!==et?(ye=s.jsx(ct,{checked:v,onChange:Be,label:ot,ariaLabel:et,settingsItem:"chat.prompt-navigator"}),t[122]=v,t[123]=Be,t[124]=ot,t[125]=et,t[126]=ye):ye=t[126];let Z;t[127]!==C?(Z=Dt=>{C(Dt),jt({showSplitAssistantMessageActions:Dt})},t[127]=C,t[128]=Z):Z=t[128];let Oe;t[129]!==e?(Oe=e("settings.openchamber.visual.field.showSplitAssistantMessageActions"),t[129]=e,t[130]=Oe):Oe=t[130];let Ve;t[131]!==e?(Ve=e("settings.openchamber.visual.field.showSplitAssistantMessageActionsAria"),t[131]=e,t[132]=Ve):Ve=t[132];let X;t[133]!==e?(X=e("settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip"),t[133]=e,t[134]=X):X=t[134];let _e;t[135]!==j||t[136]!==Z||t[137]!==Oe||t[138]!==Ve||t[139]!==X?(_e=s.jsx(ct,{checked:j,onChange:Z,label:Oe,ariaLabel:Ve,info:X,settingsItem:"chat.inline-assistant-actions"}),t[135]=j,t[136]=Z,t[137]=Oe,t[138]=Ve,t[139]=X,t[140]=_e):_e=t[140];let nt;t[141]!==je||t[142]!==Se||t[143]!==lt||t[144]!==We||t[145]!==dt||t[146]!==ye||t[147]!==_e?(nt=s.jsxs($e,{title:je,settingsItem:"chat.message-appearance",contentClassName:bs,children:[Se,lt,We,dt,ye,_e]}),t[141]=je,t[142]=Se,t[143]=lt,t[144]=We,t[145]=dt,t[146]=ye,t[147]=_e,t[148]=nt):nt=t[148];let ht;t[149]!==e?(ht=e("settings.layout.chat.section.formatting"),t[149]=e,t[150]=ht):ht=t[150];let yt;t[151]!==e?(yt=e("settings.openchamber.visual.section.userMessageRendering"),t[151]=e,t[152]=yt):yt=t[152];const kt=E==="markdown"?"markdown":"plain";let He;t[153]!==F?(He=Dt=>{F(Dt),jt({userMessageRenderingMode:Dt})},t[153]=F,t[154]=He):He=t[154];let Je;t[155]!==e?(Je=e("settings.openchamber.visual.section.userMessageRenderingAria"),t[155]=e,t[156]=Je):Je=t[156];let mt;t[157]!==kt||t[158]!==He||t[159]!==Je||t[160]!==B?(mt=s.jsx(Xt,{value:kt,options:B,onChange:He,"aria-label":Je}),t[157]=kt,t[158]=He,t[159]=Je,t[160]=B,t[161]=mt):mt=t[161];let Qe;t[162]!==yt||t[163]!==mt?(Qe=s.jsx(st,{label:yt,settingsItem:"chat.user-message-rendering",children:mt}),t[162]=yt,t[163]=mt,t[164]=Qe):Qe=t[164];let _;t[165]!==e?(_=e("settings.openchamber.visual.section.mermaidRendering"),t[165]=e,t[166]=_):_=t[166];let ge;t[167]!==K?(ge=Dt=>{K(Dt),jt({mermaidRenderingMode:Dt})},t[167]=K,t[168]=ge):ge=t[168];let Ae;t[169]!==e?(Ae=e("settings.openchamber.visual.section.mermaidRenderingAria"),t[169]=e,t[170]=Ae):Ae=t[170];let Te;t[171]!==W||t[172]!==O||t[173]!==ge||t[174]!==Ae?(Te=s.jsx(Xt,{value:O,options:W,onChange:ge,"aria-label":Ae}),t[171]=W,t[172]=O,t[173]=ge,t[174]=Ae,t[175]=Te):Te=t[175];let Ge;t[176]!==_||t[177]!==Te?(Ge=s.jsx(st,{label:_,settingsItem:"chat.mermaid-rendering",children:Te}),t[176]=_,t[177]=Te,t[178]=Ge):Ge=t[178];let ue;t[179]!==Y||t[180]!==D||t[181]!==M||t[182]!==e?(ue=n?null:s.jsx(st,{label:e("settings.openchamber.visual.section.diffLayout"),settingsItem:"chat.diff-layout",children:s.jsx(Xt,{value:D,options:Y,onChange:M,"aria-label":e("settings.openchamber.visual.section.diffLayoutAria")})}),t[179]=Y,t[180]=D,t[181]=M,t[182]=e,t[183]=ue):ue=t[183];let Fe;t[184]!==Qe||t[185]!==Ge||t[186]!==ue?(Fe=s.jsxs("div",{children:[Qe,Ge,ue]}),t[184]=Qe,t[185]=Ge,t[186]=ue,t[187]=Fe):Fe=t[187];let pt;t[188]!==e?(pt=e("settings.openchamber.visual.field.codeBlockLineWrap"),t[188]=e,t[189]=pt):pt=t[189];let At;t[190]!==e?(At=e("settings.openchamber.visual.field.codeBlockLineWrapAria"),t[190]=e,t[191]=At):At=t[191];let Nt;t[192]!==T||t[193]!==R||t[194]!==pt||t[195]!==At?(Nt=s.jsx(ct,{checked:T,onChange:R,label:pt,ariaLabel:At,settingsItem:"chat.code-block-line-wrap"}),t[192]=T,t[193]=R,t[194]=pt,t[195]=At,t[196]=Nt):Nt=t[196];let zt;t[197]!==e?(zt=e("settings.openchamber.visual.field.tableCellWrap"),t[197]=e,t[198]=zt):zt=t[198];let es;t[199]!==e?(es=e("settings.openchamber.visual.field.tableCellWrapAria"),t[199]=e,t[200]=es):es=t[200];let ss;t[201]!==e?(ss=e("settings.openchamber.visual.field.tableCellWrapInfo"),t[201]=e,t[202]=ss):ss=t[202];let fs;t[203]!==z||t[204]!==zt||t[205]!==es||t[206]!==ss||t[207]!==$?(fs=s.jsx(ct,{checked:$,onChange:z,label:zt,ariaLabel:es,info:ss,settingsItem:"chat.table-cell-wrap"}),t[203]=z,t[204]=zt,t[205]=es,t[206]=ss,t[207]=$,t[208]=fs):fs=t[208];let Gt;t[209]!==e?(Gt=e("settings.openchamber.visual.field.copyMessagesAsPlainText"),t[209]=e,t[210]=Gt):Gt=t[210];let ms;t[211]!==e?(ms=e("settings.openchamber.visual.field.copyMessagesAsPlainTextAria"),t[211]=e,t[212]=ms):ms=t[212];let cs;t[213]!==e?(cs=e("settings.openchamber.visual.field.copyMessagesAsPlainTextInfo"),t[213]=e,t[214]=cs):cs=t[214];let ps;t[215]!==Q||t[216]!==V||t[217]!==Gt||t[218]!==ms||t[219]!==cs?(ps=s.jsx(ct,{checked:Q,onChange:V,label:Gt,ariaLabel:ms,info:cs,settingsItem:"chat.copy-plain-text"}),t[215]=Q,t[216]=V,t[217]=Gt,t[218]=ms,t[219]=cs,t[220]=ps):ps=t[220];let hs;t[221]!==Nt||t[222]!==fs||t[223]!==ps?(hs=s.jsxs("div",{className:bs,children:[Nt,fs,ps]}),t[221]=Nt,t[222]=fs,t[223]=ps,t[224]=hs):hs=t[224];let ks;t[225]!==ht||t[226]!==Fe||t[227]!==hs?(ks=s.jsxs($e,{title:ht,contentClassName:"space-y-3",children:[Fe,hs]}),t[225]=ht,t[226]=Fe,t[227]=hs,t[228]=ks):ks=t[228];let ws;t[229]===Symbol.for("react.memo_cache_sentinel")?(ws=n?null:s.jsx(U3,{}),t[229]=ws):ws=t[229];let Xs;return t[230]!==ce||t[231]!==nt||t[232]!==ks?(Xs=s.jsxs(s.Fragment,{children:[ce,nt,ks,ws]}),t[230]=ce,t[231]=nt,t[232]=ks,t[233]=Xs):Xs=t[233],Xs},l0=()=>{const t=De.c(140),{t:e}=Ee(),{isMobile:a}=Zs(),n=re(W0),i=re(G0),o=re(J0),r=re(Q0),c=Xl(Y0),u=Xl(Z0),d=re(X0),l=re(eS),f=re(tS),p=re(sS),g=re(nS),h=re(aS),y=re(iS),b=re(oS),x=re(rS),w=re(lS),S=oo(cS),v=oo(dS),A=oo(uS),I=oo(mS),N=Ja(a0),k=Ja(i0),P=o?n:!a;let j;t[0]!==i||t[1]!==r?(j=at=>{i(at),r(!0),jt({enterToSend:at,enterToSendConfigured:!0})},t[0]=i,t[1]=r,t[2]=j):j=t[2];const C=j;let E;t[3]!==I?(E=at=>{const ut=Math.round(at);nf(ut)&&(I(ut),jt({inputHistoryLimit:ut}))},t[3]=I,t[4]=E):E=t[4];const F=E;let O;t[5]!==e?(O=e("settings.layout.chat.section.sending"),t[5]=e,t[6]=O):O=t[6];let K;t[7]!==P||t[8]!==C||t[9]!==a||t[10]!==e?(K=a?null:s.jsx(st,{label:e("settings.openchamber.visual.field.enterToSend"),info:e("settings.openchamber.visual.field.enterToSendHint"),settingsItem:"chat.enter-to-send",children:s.jsx(Xt,{value:P?"enter":"modifier",options:[{value:"enter",label:e("settings.openchamber.visual.option.enterToSend.enter.label")},{value:"modifier",label:e("settings.openchamber.visual.option.enterToSend.modifier.label")}],onChange:at=>C(at==="enter"),"aria-label":e("settings.openchamber.visual.field.enterToSend")})}),t[7]=P,t[8]=C,t[9]=a,t[10]=e,t[11]=K):K=t[11];let D;t[12]!==e?(D=e("settings.openchamber.visual.section.followUpBehavior"),t[12]=e,t[13]=D):D=t[13];let M;t[14]!==e?(M=e("settings.openchamber.visual.section.followUpBehaviorAria"),t[14]=e,t[15]=M):M=t[15];let T;t[16]!==c||t[17]!==N||t[18]!==u||t[19]!==M?(T=s.jsx(Xt,{value:c,options:N,onChange:u,"aria-label":M}),t[16]=c,t[17]=N,t[18]=u,t[19]=M,t[20]=T):T=t[20];let R;t[21]!==D||t[22]!==T?(R=s.jsx(st,{label:D,settingsItem:"chat.follow-up-behavior",children:T}),t[21]=D,t[22]=T,t[23]=R):R=t[23];let $;t[24]!==K||t[25]!==R?($=s.jsxs("div",{children:[K,R]}),t[24]=K,t[25]=R,t[26]=$):$=t[26];let z;t[27]!==e?(z=e("settings.openchamber.visual.field.largeTextPaste"),t[27]=e,t[28]=z):z=t[28];let Q;t[29]!==e?(Q=e("settings.openchamber.visual.field.largeTextPasteHint"),t[29]=e,t[30]=Q):Q=t[30];let V;t[31]!==e?(V=e("settings.openchamber.visual.field.largeTextPasteAria"),t[31]=e,t[32]=V):V=t[32];let L;t[33]!==d||t[34]!==l||t[35]!==e?(L=o0.map(at=>s.jsx(wn,{selected:d===at.id,onSelect:()=>l(at.id),label:e(at.labelKey),ariaLabel:e("settings.openchamber.visual.field.largeTextPasteOptionAria",{option:e(at.labelKey)})},at.id)),t[33]=d,t[34]=l,t[35]=e,t[36]=L):L=t[36];let B;t[37]!==V||t[38]!==L?(B=s.jsx(Vo,{"aria-label":V,children:L}),t[37]=V,t[38]=L,t[39]=B):B=t[39];let W;t[40]!==Q||t[41]!==B||t[42]!==z?(W=s.jsx(ni,{title:z,info:Q,settingsItem:"chat.large-text-paste",children:B}),t[40]=Q,t[41]=B,t[42]=z,t[43]=W):W=t[43];let Y;t[44]!==e?(Y=e("settings.openchamber.visual.field.allowPromptingSubagentSessions"),t[44]=e,t[45]=Y):Y=t[45];let ae;t[46]!==e?(ae=e("settings.openchamber.visual.field.allowPromptingSubagentSessionsAria"),t[46]=e,t[47]=ae):ae=t[47];let ee;t[48]!==f||t[49]!==p||t[50]!==Y||t[51]!==ae?(ee=s.jsx(ct,{checked:f,onChange:p,label:Y,ariaLabel:ae,settingsItem:"chat.subagent-read-only-banner"}),t[48]=f,t[49]=p,t[50]=Y,t[51]=ae,t[52]=ee):ee=t[52];let G;t[53]!==e?(G=e("settings.openchamber.visual.field.saveImagesForTextOnlyModels"),t[53]=e,t[54]=G):G=t[54];let le;t[55]!==e?(le=e("settings.openchamber.visual.field.saveImagesForTextOnlyModels"),t[55]=e,t[56]=le):le=t[56];let J;t[57]!==e?(J=e("settings.openchamber.visual.field.saveImagesForTextOnlyModelsInfo"),t[57]=e,t[58]=J):J=t[58];let me;t[59]!==g||t[60]!==h||t[61]!==G||t[62]!==le||t[63]!==J?(me=s.jsx(ct,{checked:g,onChange:h,label:G,ariaLabel:le,info:J,settingsItem:"chat.save-images-for-text-models"}),t[59]=g,t[60]=h,t[61]=G,t[62]=le,t[63]=J,t[64]=me):me=t[64];let fe;t[65]!==ee||t[66]!==me?(fe=s.jsxs("div",{className:bs,children:[ee,me]}),t[65]=ee,t[66]=me,t[67]=fe):fe=t[67];let oe;t[68]!==W||t[69]!==O||t[70]!==fe||t[71]!==$?(oe=s.jsxs($e,{title:O,divider:!1,settingsItem:"chat.composer",contentClassName:"space-y-5",children:[$,W,fe]}),t[68]=W,t[69]=O,t[70]=fe,t[71]=$,t[72]=oe):oe=t[72];let pe;t[73]!==e?(pe=e("settings.layout.chat.section.draftsAndHistory"),t[73]=e,t[74]=pe):pe=t[74];let se;t[75]!==e?(se=e("settings.openchamber.visual.field.persistDraftMessages"),t[75]=e,t[76]=se):se=t[76];let ve;t[77]!==e?(ve=e("settings.openchamber.visual.field.persistDraftMessagesAria"),t[77]=e,t[78]=ve):ve=t[78];let be;t[79]!==y||t[80]!==b||t[81]!==se||t[82]!==ve?(be=s.jsx(ct,{checked:y,onChange:b,label:se,ariaLabel:ve,settingsItem:"chat.persist-drafts"}),t[79]=y,t[80]=b,t[81]=se,t[82]=ve,t[83]=be):be=t[83];let ne;t[84]!==x||t[85]!==a||t[86]!==w||t[87]!==e?(ne=a?null:s.jsx(ct,{checked:x,onChange:at=>{w(at),jt({inputSpellcheckEnabled:at})},label:e("settings.openchamber.visual.field.enableSpellcheckInTextInputs"),ariaLabel:e("settings.openchamber.visual.field.enableSpellcheckInTextInputsAria"),settingsItem:"chat.spellcheck"}),t[84]=x,t[85]=a,t[86]=w,t[87]=e,t[88]=ne):ne=t[88];let we;t[89]!==be||t[90]!==ne?(we=s.jsxs("div",{className:bs,children:[be,ne]}),t[89]=be,t[90]=ne,t[91]=we):we=t[91];let Ne;t[92]!==e?(Ne=e("settings.openchamber.visual.field.inputHistoryScope"),t[92]=e,t[93]=Ne):Ne=t[93];let Ie;t[94]!==e?(Ie=e("settings.openchamber.visual.field.inputHistoryScopeDescription"),t[94]=e,t[95]=Ie):Ie=t[95];let Ce;t[96]!==A?(Ce=at=>{A(at),jt({inputHistoryScope:at})},t[96]=A,t[97]=Ce):Ce=t[97];let Me;t[98]!==e?(Me=e("settings.openchamber.visual.section.inputHistoryScopeAria"),t[98]=e,t[99]=Me):Me=t[99];let he;t[100]!==k||t[101]!==S||t[102]!==Ce||t[103]!==Me?(he=s.jsx(Xt,{value:S,options:k,onChange:Ce,"aria-label":Me}),t[100]=k,t[101]=S,t[102]=Ce,t[103]=Me,t[104]=he):he=t[104];let Pe;t[105]!==Ne||t[106]!==Ie||t[107]!==he?(Pe=s.jsx(st,{label:Ne,info:Ie,settingsItem:"chat.input-history-scope",children:he}),t[105]=Ne,t[106]=Ie,t[107]=he,t[108]=Pe):Pe=t[108];let Re;t[109]!==e?(Re=e("settings.openchamber.visual.field.inputHistoryLimit"),t[109]=e,t[110]=Re):Re=t[110];let ce;t[111]!==e?(ce=e("settings.openchamber.visual.field.inputHistoryLimitDescription"),t[111]=e,t[112]=ce):ce=t[112];let je;t[113]!==e?(je=e("settings.openchamber.visual.field.inputHistoryLimitAria"),t[113]=e,t[114]=je):je=t[114];let de;t[115]!==F||t[116]!==v||t[117]!==je?(de=s.jsx(ds,{value:v,onValueChange:F,min:of,max:af,step:1,className:us,deferExternalValueWhileFocused:!0,"aria-label":je}),t[115]=F,t[116]=v,t[117]=je,t[118]=de):de=t[118];let ie;t[119]!==e?(ie=e("settings.openchamber.visual.field.inputHistoryLimitUnit"),t[119]=e,t[120]=ie):ie=t[120];let xe;t[121]!==ie?(xe=s.jsx("span",{className:ga,children:ie}),t[121]=ie,t[122]=xe):xe=t[122];let Se;t[123]!==de||t[124]!==xe?(Se=s.jsxs("div",{className:Fn,children:[de,xe]}),t[123]=de,t[124]=xe,t[125]=Se):Se=t[125];let Le;t[126]!==Re||t[127]!==ce||t[128]!==Se?(Le=s.jsx(st,{label:Re,description:ce,settingsItem:"chat.input-history-limit",children:Se}),t[126]=Re,t[127]=ce,t[128]=Se,t[129]=Le):Le=t[129];let Ue;t[130]!==Pe||t[131]!==Le?(Ue=s.jsxs("div",{children:[Pe,Le]}),t[130]=Pe,t[131]=Le,t[132]=Ue):Ue=t[132];let Ye;t[133]!==pe||t[134]!==we||t[135]!==Ue?(Ye=s.jsxs($e,{title:pe,contentClassName:"space-y-3",children:[we,Ue]}),t[133]=pe,t[134]=we,t[135]=Ue,t[136]=Ye):Ye=t[136];let lt;return t[137]!==oe||t[138]!==Ye?(lt=s.jsxs(s.Fragment,{children:[oe,Ye]}),t[137]=oe,t[138]=Ye,t[139]=lt):lt=t[139],lt},c0=()=>{const t=De.c(54),{t:e}=Ee();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=os(),t[0]=a):a=t[0];const n=a,i=re(pS),o=re(gS),r=re(fS),c=re(hS),u=re(bS),d=re(xS),l=re(vS),f=re(yS),p=Bt(ul),g=re(jS),h=re(kS),y=re(wS),b=re(SS),x=re(NS),w=re(CS);let S;t[1]!==e?(S=e("settings.openchamber.visual.section.sessionAssistance"),t[1]=e,t[2]=S):S=t[2];let v;t[3]!==o?(v=T=>{o(T),jt({draftStartersVisible:T})},t[3]=o,t[4]=v):v=t[4];let A;t[5]!==e?(A=e("settings.openchamber.visual.field.draftStartersVisible"),t[5]=e,t[6]=A):A=t[6];let I;t[7]!==e?(I=e("settings.openchamber.visual.field.draftStartersVisibleAria"),t[7]=e,t[8]=I):I=t[8];let N;t[9]!==i||t[10]!==v||t[11]!==A||t[12]!==I?(N=s.jsx(ct,{checked:i,onChange:v,label:A,ariaLabel:I,settingsItem:"chat.draft-starters-visible"}),t[9]=i,t[10]=v,t[11]=A,t[12]=I,t[13]=N):N=t[13];let k;t[14]!==e?(k=e("settings.openchamber.visual.field.sessionRecap"),t[14]=e,t[15]=k):k=t[15];let P;t[16]!==e?(P=e("settings.openchamber.visual.field.sessionRecapAria"),t[16]=e,t[17]=P):P=t[17];let j;t[18]!==r||t[19]!==c||t[20]!==k||t[21]!==P?(j=s.jsx(ct,{checked:r,onChange:c,label:k,ariaLabel:P,settingsItem:"chat.session-recap"}),t[18]=r,t[19]=c,t[20]=k,t[21]=P,t[22]=j):j=t[22];let C;t[23]!==e?(C=e("settings.openchamber.visual.field.sessionSuggestion"),t[23]=e,t[24]=C):C=t[24];let E;t[25]!==e?(E=e("settings.openchamber.visual.field.sessionSuggestionAria"),t[25]=e,t[26]=E):E=t[26];let F;t[27]!==u||t[28]!==d||t[29]!==E||t[30]!==C?(F=s.jsx(ct,{checked:u,onChange:d,label:C,ariaLabel:E,settingsItem:"chat.session-suggestion"}),t[27]=u,t[28]=d,t[29]=E,t[30]=C,t[31]=F):F=t[31];let O;t[32]!==p||t[33]!==l||t[34]!==f||t[35]!==e?(O=n?null:s.jsx(ct,{checked:p&&l,onChange:f,disabled:!p,label:e("settings.openchamber.visual.field.sessionReviewOffer"),ariaLabel:e("settings.openchamber.visual.field.sessionReviewOffer"),info:e("settings.openchamber.visual.field.sessionReviewOfferInfo"),footer:s.jsx(Zo,{}),settingsItem:"chat.session-review-offer"}),t[32]=p,t[33]=l,t[34]=f,t[35]=e,t[36]=O):O=t[36];let K;t[37]!==S||t[38]!==F||t[39]!==O||t[40]!==N||t[41]!==j?(K=s.jsxs($e,{title:S,settingsItem:"chat.session-assistance",divider:!1,contentClassName:bs,children:[N,j,F,O]}),t[37]=S,t[38]=F,t[39]=O,t[40]=N,t[41]=j,t[42]=K):K=t[42];let D;t[43]!==x||t[44]!==y||t[45]!==g||t[46]!==w||t[47]!==b||t[48]!==h||t[49]!==e?(D=n?null:s.jsxs($e,{title:e("settings.openchamber.visual.goal.sectionTitle"),info:e("settings.openchamber.visual.goal.description"),contentClassName:"space-y-3",children:[s.jsx(ct,{checked:g,onChange:h,label:e("settings.openchamber.visual.field.sessionGoal"),ariaLabel:e("settings.openchamber.visual.field.sessionGoalAria"),settingsItem:"chat.session-goal"}),s.jsxs("div",{children:[s.jsx(G3,{disabled:!g}),s.jsx(J3,{disabled:!g}),s.jsx(st,{label:s.jsx(ct,{checked:y,onChange:b,disabled:!g,label:e("settings.openchamber.visual.goal.budgetLabel"),ariaLabel:e("settings.openchamber.visual.goal.budgetAria")}),settingsItem:"chat.session-goal-budget",children:s.jsx(ds,{value:x,onValueChange:T=>{Number.isFinite(T)&&T>0&&w(Math.floor(T))},min:1e3,max:1e8,step:5e4,disabled:!g||!y,className:us,"aria-label":e("settings.openchamber.visual.goal.budgetAria")})})]})]}),t[43]=x,t[44]=y,t[45]=g,t[46]=w,t[47]=b,t[48]=h,t[49]=e,t[50]=D):D=t[50];let M;return t[51]!==K||t[52]!==D?(M=s.jsxs(s.Fragment,{children:[K,D]}),t[51]=K,t[52]=D,t[53]=M):M=t[53],M},d0=()=>{const t=De.c(34),{t:e}=Ee(),a=zr(IS),n=zr(PS);let i;t[0]!==e?(i=e("settings.layout.chat.tab.messages"),t[0]=e,t[1]=i):i=t[1];let o;t[2]!==i?(o={id:"messages",label:i},t[2]=i,t[3]=o):o=t[3];let r;t[4]!==e?(r=e("settings.layout.chat.tab.composer"),t[4]=e,t[5]=r):r=t[5];let c;t[6]!==r?(c={id:"composer",label:r},t[6]=r,t[7]=c):c=t[7];let u;t[8]!==e?(u=e("settings.layout.chat.tab.assistance"),t[8]=e,t[9]=u):u=t[9];let d;t[10]!==u?(d={id:"assistance",label:u},t[10]=u,t[11]=d):d=t[11];let l;t[12]!==o||t[13]!==c||t[14]!==d?(l=[o,c,d],t[12]=o,t[13]=c,t[14]=d,t[15]=l):l=t[15];const f=l;let p;t[16]!==n||t[17]!==f?(p=w=>{const S=f.find(v=>v.id===w);S&&n(S.id)},t[16]=n,t[17]=f,t[18]=p):p=t[18];let g;t[19]!==p||t[20]!==a||t[21]!==f?(g=s.jsx("div",{className:"mb-8",children:s.jsx(Uo,{items:f,activeId:a,onSelect:p,layoutMode:"fit",variant:"active-pill",pillSize:"form",className:"h-8 max-w-[28rem]"})}),t[19]=p,t[20]=a,t[21]=f,t[22]=g):g=t[22];let h;t[23]!==a?(h=a==="messages"?s.jsx(r0,{}):null,t[23]=a,t[24]=h):h=t[24];let y;t[25]!==a?(y=a==="composer"?s.jsx(l0,{}):null,t[25]=a,t[26]=y):y=t[26];let b;t[27]!==a?(b=a==="assistance"?s.jsx(c0,{}):null,t[27]=a,t[28]=b):b=t[28];let x;return t[29]!==y||t[30]!==b||t[31]!==g||t[32]!==h?(x=s.jsxs(s.Fragment,{children:[g,h,y,b]}),t[29]=y,t[30]=b,t[31]=g,t[32]=h,t[33]=x):x=t[33],x};function u0(t){return t.activityRenderMode}function m0(t){return t.setActivityRenderMode}function p0(t){return t.showReasoningTraces}function g0(t){return t.setShowReasoningTraces}function f0(t){return t.collapsibleThinkingBlocks}function h0(t){return t.setCollapsibleThinkingBlocks}function b0(t){return t.expandReasoningWhileStreaming}function x0(t){return t.setExpandReasoningWhileStreaming}function v0(t){return t.showToolFileIcons}function y0(t){return t.setShowToolFileIcons}function j0(t){return t.showTurnChangedFiles}function k0(t){return t.setShowTurnChangedFiles}function w0(t){return t.streamingAutoFollowEnabled}function S0(t){return t.setStreamingAutoFollowEnabled}function N0(t){return t.wideChatLayoutEnabled}function C0(t){return t.setWideChatLayoutEnabled}function I0(t){return t.promptNavigatorEnabled}function P0(t){return t.setPromptNavigatorEnabled}function A0(t){return t.collapsibleUserMessages}function T0(t){return t.setCollapsibleUserMessages}function E0(t){return t.stickyUserHeader}function M0(t){return t.setStickyUserHeader}function D0(t){return t.showSplitAssistantMessageActions}function R0(t){return t.setShowSplitAssistantMessageActions}function O0(t){return t.userMessageRenderingMode}function F0(t){return t.setUserMessageRenderingMode}function L0(t){return t.mermaidRenderingMode}function K0(t){return t.setMermaidRenderingMode}function _0(t){return t.diffLayoutPreference}function $0(t){return t.setDiffLayoutPreference}function z0(t){return t.codeBlockLineWrap}function U0(t){return t.setCodeBlockLineWrap}function B0(t){return t.tableCellWrap}function V0(t){return t.setTableCellWrap}function H0(t){return t.copyMessagesAsPlainText}function q0(t){return t.setCopyMessagesAsPlainText}function W0(t){return t.enterToSend}function G0(t){return t.setEnterToSend}function J0(t){return t.enterToSendConfigured}function Q0(t){return t.setEnterToSendConfigured}function Y0(t){return t.followUpBehavior}function Z0(t){return t.setFollowUpBehavior}function X0(t){return t.largeTextPasteBehavior}function eS(t){return t.setLargeTextPasteBehavior}function tS(t){return t.allowPromptingSubagentSessions}function sS(t){return t.setAllowPromptingSubagentSessions}function nS(t){return t.saveImagesForTextOnlyModels}function aS(t){return t.setSaveImagesForTextOnlyModels}function iS(t){return t.persistChatDraft}function oS(t){return t.setPersistChatDraft}function rS(t){return t.inputSpellcheckEnabled}function lS(t){return t.setInputSpellcheckEnabled}function cS(t){return t.scope}function dS(t){return t.entryLimit}function uS(t){return t.applyScope}function mS(t){return t.applyEntryLimit}function pS(t){return t.draftStartersVisible}function gS(t){return t.setDraftStartersVisible}function fS(t){return t.sessionRecapEnabled}function hS(t){return t.setSessionRecapEnabled}function bS(t){return t.sessionSuggestionEnabled}function xS(t){return t.setSessionSuggestionEnabled}function vS(t){return t.sessionReviewOfferEnabled}function yS(t){return t.setSessionReviewOfferEnabled}function jS(t){return t.sessionGoalEnabled}function kS(t){return t.setSessionGoalEnabled}function wS(t){return t.sessionGoalDefaultBudgetEnabled}function SS(t){return t.setSessionGoalDefaultBudgetEnabled}function NS(t){return t.sessionGoalDefaultBudget}function CS(t){return t.setSessionGoalDefaultBudget}function IS(t){return t.tab}function PS(t){return t.setTab}const AS={changes:"mobile.menu.git",files:"mobile.menu.files",terminal:"mobile.menu.terminal",notes:"contextRail.surface.notes",mcp:"mobile.menu.mcp"},TS=()=>{const t=De.c(22),{t:e}=Ee(),a=re(ES),n=re(MS),i=re(DS),o=re(RS);let r;if(t[0]!==n||t[1]!==a||t[2]!==e){const h=rf(a,n);r=lf(a).map(y=>({id:y,label:e(AS[y]),visible:h.includes(y),locked:h.length===1&&h.includes(y)})),t[0]=n,t[1]=a,t[2]=e,t[3]=r}else r=t[3];const c=r;let u;t[4]!==e?(u=e("settings.layout.general.mobileTabs.title"),t[4]=e,t[5]=u):u=t[5];let d;t[6]!==e?(d=e("settings.layout.general.mobileTabs.info"),t[6]=e,t[7]=d):d=t[7];let l;t[8]!==c||t[9]!==o?(l=(h,y)=>{const b=c.find(x=>x.id===h)?.id;b&&o(b,y)},t[8]=c,t[9]=o,t[10]=l):l=t[10];let f;t[11]!==e?(f=e("settings.layout.general.mobileTabs.dragInstructions"),t[11]=e,t[12]=f):f=t[12];let p;t[13]!==c||t[14]!==i||t[15]!==l||t[16]!==f?(p=s.jsx(Pf,{items:c,onVisibleChange:l,onReorder:i,settingsItemPrefix:"layout.mobile-workspace-tabs.",dragInstructions:f}),t[13]=c,t[14]=i,t[15]=l,t[16]=f,t[17]=p):p=t[17];let g;return t[18]!==u||t[19]!==d||t[20]!==p?(g=s.jsx($e,{title:u,info:d,settingsItem:"layout.mobile-workspace-tabs",children:p}),t[18]=u,t[19]=d,t[20]=p,t[21]=g):g=t[21],g};function ES(t){return t.mobileWorkspaceTabOrder}function MS(t){return t.mobileWorkspaceHiddenTabs}function DS(t){return t.setMobileWorkspaceTabOrder}function RS(t){return t.setMobileWorkspaceTabVisible}const Cd=[{id:"auto",labelKey:"settings.openchamber.visual.option.messageTransport.auto.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.auto.description"},{id:"ws",labelKey:"settings.openchamber.visual.option.messageTransport.ws.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.ws.description"},{id:"sse",labelKey:"settings.openchamber.visual.option.messageTransport.sse.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.sse.description"}],OS=t=>{const e=De.c(84),{divider:a}=t,{t:n}=Ee(),{isMobile:i}=Zs();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=os(),e[0]=o):o=e[0];const r=o,c=re($S),u=re(zS),d=re(US),l=re(BS),f=re(VS),p=re(HS),g=re(qS),h=re(WS),y=re(GS),b=re(JS),x=cf(),w=ft(QS),S=ft(YS);let v;e[1]!==d?(v=Jf(d),e[1]=d,e[2]=v):v=e[2];const A=v.invalidLines;let I;e[3]!==S?(I=me=>{S(me),jt({defaultFileViewerPreview:me}),window.dispatchEvent(new CustomEvent("openchamber:file-viewer-preview-mode-changed",{detail:{enabled:me}}))},e[3]=S,e[4]=I):I=e[4];const N=I,k=!r&&!i;let P;e[5]!==n?(P=n("settings.layout.general.files.title"),e[5]=n,e[6]=P):P=e[6];let j;e[7]!==n?(j=n("settings.openchamber.visual.field.fileEditorKeymap"),e[7]=n,e[8]=j):j=e[8];let C;e[9]!==n?(C=n("settings.openchamber.visual.field.fileEditorKeymap"),e[9]=n,e[10]=C):C=e[10];let E;e[11]!==n?(E=n("settings.openchamber.visual.option.fileEditorKeymap.default"),e[11]=n,e[12]=E):E=e[12];let F;e[13]!==E?(F={value:"default",label:E},e[13]=E,e[14]=F):F=e[14];let O;e[15]!==n?(O=n("settings.openchamber.visual.option.fileEditorKeymap.vim"),e[15]=n,e[16]=O):O=e[16];let K;e[17]!==O?(K={value:"vim",label:O},e[17]=O,e[18]=K):K=e[18];let D;e[19]!==K||e[20]!==F?(D=[F,K],e[19]=K,e[20]=F,e[21]=D):D=e[21];let M;e[22]!==c||e[23]!==u||e[24]!==D||e[25]!==C?(M=s.jsx(Xt,{value:c,onChange:u,"aria-label":C,options:D}),e[22]=c,e[23]=u,e[24]=D,e[25]=C,e[26]=M):M=e[26];let T;e[27]!==M||e[28]!==j?(T=s.jsx(st,{label:j,settingsItem:"appearance.file-editor-keymap",children:M}),e[27]=M,e[28]=j,e[29]=T):T=e[29];let R;e[30]!==c||e[31]!==d||e[32]!==A||e[33]!==l||e[34]!==n?(R=c==="vim"?s.jsx(St,{label:n("settings.openchamber.visual.field.fileEditorVimMappings"),info:n("settings.openchamber.visual.field.fileEditorVimMappingsInfo"),description:A.length>0?n("settings.openchamber.visual.field.fileEditorVimMappingsInvalid",{lines:A.join(", ")}):void 0,descriptionPlacement:"after",settingsItem:"appearance.file-editor-vim-mappings",className:"pt-1 pb-2",children:s.jsx(Cs,{value:d,onChange:me=>l(me.target.value),placeholder:"inoremap jk <Esc>","aria-label":n("settings.openchamber.visual.field.fileEditorVimMappings"),rows:4,spellCheck:!1,className:"w-full font-mono typography-meta"})}):null,e[30]=c,e[31]=d,e[32]=A,e[33]=l,e[34]=n,e[35]=R):R=e[35];let $;e[36]!==f||e[37]!==p||e[38]!==k||e[39]!==n?($=k?s.jsx(st,{label:n("settings.openchamber.visual.field.fileTreeSide"),settingsItem:"appearance.file-tree-side",children:s.jsx(Xt,{value:f,onChange:p,"aria-label":n("settings.openchamber.visual.field.fileTreeSide"),options:[{value:"left",label:n("settings.openchamber.visual.option.fileTreeSide.left")},{value:"right",label:n("settings.openchamber.visual.option.fileTreeSide.right")}]})}):null,e[36]=f,e[37]=p,e[38]=k,e[39]=n,e[40]=$):$=e[40];let z;e[41]!==T||e[42]!==R||e[43]!==$?(z=s.jsxs("div",{children:[T,R,$]}),e[41]=T,e[42]=R,e[43]=$,e[44]=z):z=e[44];let Q;e[45]!==n?(Q=n("settings.openchamber.visual.field.autoSaveEnabled"),e[45]=n,e[46]=Q):Q=e[46];let V;e[47]!==n?(V=n("settings.openchamber.visual.field.autoSaveEnabledAria"),e[47]=n,e[48]=V):V=e[48];let L;e[49]!==n?(L=n("settings.openchamber.visual.field.autoSaveEnabledInfo"),e[49]=n,e[50]=L):L=e[50];let B;e[51]!==g||e[52]!==h||e[53]!==Q||e[54]!==V||e[55]!==L?(B=s.jsx(ct,{checked:g,onChange:h,label:Q,ariaLabel:V,info:L,settingsItem:"appearance.auto-save-enabled"}),e[51]=g,e[52]=h,e[53]=Q,e[54]=V,e[55]=L,e[56]=B):B=e[56];let W;e[57]!==y||e[58]!==b||e[59]!==k||e[60]!==n?(W=k?s.jsx(ct,{checked:y,onChange:b,label:n("settings.openchamber.visual.field.confirmFileTreeMove"),ariaLabel:n("settings.openchamber.visual.field.confirmFileTreeMove"),settingsItem:"appearance.confirm-file-tree-move"}):null,e[57]=y,e[58]=b,e[59]=k,e[60]=n,e[61]=W):W=e[61];let Y;e[62]!==x||e[63]!==n?(Y=r?null:s.jsx(ct,{checked:x,onChange:df,label:n("settings.openchamber.visual.field.showDotfiles"),ariaLabel:n("settings.openchamber.visual.field.showDotfilesAria"),settingsItem:"chat.dotfiles"}),e[62]=x,e[63]=n,e[64]=Y):Y=e[64];let ae;e[65]!==n?(ae=n("settings.openchamber.defaults.field.openFilesPreview"),e[65]=n,e[66]=ae):ae=e[66];let ee;e[67]!==n?(ee=n("settings.openchamber.defaults.field.openFilesPreviewAria"),e[67]=n,e[68]=ee):ee=e[68];let G;e[69]!==w||e[70]!==N||e[71]!==ae||e[72]!==ee?(G=s.jsx(ct,{checked:w,onChange:N,label:ae,ariaLabel:ee,settingsItem:"general.file-viewer-preview"}),e[69]=w,e[70]=N,e[71]=ae,e[72]=ee,e[73]=G):G=e[73];let le;e[74]!==B||e[75]!==W||e[76]!==Y||e[77]!==G?(le=s.jsxs("div",{className:bs,children:[B,W,Y,G]}),e[74]=B,e[75]=W,e[76]=Y,e[77]=G,e[78]=le):le=e[78];let J;return e[79]!==a||e[80]!==z||e[81]!==le||e[82]!==P?(J=s.jsxs($e,{title:P,divider:a,contentClassName:"space-y-4",children:[z,le]}),e[79]=a,e[80]=z,e[81]=le,e[82]=P,e[83]=J):J=e[83],J},FS=()=>{const t=De.c(66),{t:e}=Ee(),{isMobile:a}=Zs(),{terminal:n}=oi(),i=re(ZS),o=re(XS),r=re(eN),c=re(tN),u=re(sN),d=re(nN);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=[],t[0]=l):l=t[0];const[f,p]=m.useState(l),[g,h]=m.useState(0);let y,b;t[1]===Symbol.for("react.memo_cache_sentinel")?(y=()=>Go(()=>{p([]),h(aN)}),b=[],t[1]=y,t[2]=b):(y=t[1],b=t[2]),m.useEffect(y,b);let x;t[3]!==n?(x=()=>{let W=!1;if(n.listShells)return n.listShells().then(Y=>{W||p(Y)}).catch(()=>{W||p([])}),()=>{W=!0}},t[3]=n,t[4]=x):x=t[4];let w;t[5]!==n||t[6]!==g?(w=[n,g],t[5]=n,t[6]=g,t[7]=w):w=t[7],m.useEffect(x,w);let S;if(t[8]!==f||t[9]!==i){e:{const W=f.filter(iN);if(i==="auto"||W.some(ae=>ae.id===i)){S=W;break e}let Y;t[11]!==i?(Y={id:i,name:i,supportsLogin:!1},t[11]=i,t[12]=Y):Y=t[12],S=[Y,...W]}t[8]=f,t[9]=i,t[10]=S}else S=t[10];const v=S;let A;t[13]!==f||t[14]!==i?(A=f.find(W=>W.id===i)?.supportsLogin,t[13]=f,t[14]=i,t[15]=A):A=t[15];const I=A===!0;let N;t[16]!==r||t[17]!==i?(N=r.includes(i),t[16]=r,t[17]=i,t[18]=N):N=t[18];const k=N;let P;t[19]!==c||t[20]!==r||t[21]!==i?(P=W=>{c(W?[...r.filter(Y=>Y!==i),i]:r.filter(Y=>Y!==i))},t[19]=c,t[20]=r,t[21]=i,t[22]=P):P=t[22];const j=P;let C;t[23]!==e?(C=e("settings.layout.general.terminal.title"),t[23]=e,t[24]=C):C=t[24];let E;t[25]!==e?(E=e("settings.openchamber.visual.field.terminalShell"),t[25]=e,t[26]=E):E=t[26];let F;t[27]!==e?(F=e("settings.openchamber.visual.field.terminalShellHint"),t[27]=e,t[28]=F):F=t[28];let O;t[29]!==o?(O=W=>{pf(W)&&o(W)},t[29]=o,t[30]=O):O=t[30];let K;t[31]!==e?(K=e("settings.openchamber.visual.field.terminalShellAria"),t[31]=e,t[32]=K):K=t[32];let D;t[33]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(Kt,{}),t[33]=D):D=t[33];let M;t[34]!==K?(M=s.jsx(Ct,{"aria-label":K,className:Es,children:D}),t[34]=K,t[35]=M):M=t[35];let T;t[36]!==e?(T=e("settings.openchamber.visual.option.terminalShell.auto"),t[36]=e,t[37]=T):T=t[37];let R;t[38]!==T?(R=s.jsx(bt,{value:"auto",children:T}),t[38]=T,t[39]=R):R=t[39];let $;t[40]!==v?($=v.map(oN),t[40]=v,t[41]=$):$=t[41];let z;t[42]!==R||t[43]!==$?(z=s.jsxs(It,{children:[R,$]}),t[42]=R,t[43]=$,t[44]=z):z=t[44];let Q;t[45]!==O||t[46]!==M||t[47]!==z||t[48]!==i?(Q=s.jsxs(Pt,{value:i,onValueChange:O,children:[M,z]}),t[45]=O,t[46]=M,t[47]=z,t[48]=i,t[49]=Q):Q=t[49];let V;t[50]!==E||t[51]!==F||t[52]!==Q?(V=s.jsx(st,{label:E,info:F,settingsItem:"appearance.terminal-shell",children:Q}),t[50]=E,t[51]=F,t[52]=Q,t[53]=V):V=t[53];let L;t[54]!==a||t[55]!==d||t[56]!==j||t[57]!==u||t[58]!==e||t[59]!==k||t[60]!==I?(L=I||!a?s.jsxs("div",{className:bs,children:[I?s.jsx(ct,{checked:k,onChange:j,label:e("settings.openchamber.visual.field.terminalLoginShell"),ariaLabel:e("settings.openchamber.visual.field.terminalLoginShell"),settingsItem:"appearance.terminal-login-shell"}):null,a?null:s.jsx(ct,{checked:u,onChange:d,label:e("settings.openchamber.visual.field.terminalQuickKeys"),ariaLabel:e("settings.openchamber.visual.field.terminalQuickKeysAria"),settingsItem:"appearance.terminal-quick-keys",info:e("settings.openchamber.visual.field.terminalQuickKeysTooltip",{control:Hn("ctrl"),alt:Hn("alt")})})]}):null,t[54]=a,t[55]=d,t[56]=j,t[57]=u,t[58]=e,t[59]=k,t[60]=I,t[61]=L):L=t[61];let B;return t[62]!==V||t[63]!==L||t[64]!==C?(B=s.jsxs($e,{title:C,contentClassName:"space-y-3",children:[V,L]}),t[62]=V,t[63]=L,t[64]=C,t[65]=B):B=t[65],B},LS=()=>{const t=De.c(41),{t:e}=Ee(),{isMobile:a}=Zs(),n=re(rN),i=re(lN),o=re(cN),r=re(dN),c=re(uN),u=re(mN),d=re(pN),l=re(gN),f=re(fN),p=re(hN);let g;t[0]!==e?(g=e("settings.layout.general.panels.title"),t[0]=e,t[1]=g):g=t[1];let h;t[2]!==a||t[3]!==n||t[4]!==i||t[5]!==e?(h=a?null:s.jsx(ct,{checked:n,onChange:i,label:e("settings.openchamber.visual.field.sessionTabs"),ariaLabel:e("settings.openchamber.visual.field.sessionTabsAria"),info:e("settings.openchamber.visual.field.sessionTabsInfo"),settingsItem:"appearance.session-tabs"}),t[2]=a,t[3]=n,t[4]=i,t[5]=e,t[6]=h):h=t[6];let y;t[7]!==a||t[8]!==o||t[9]!==r||t[10]!==e?(y=a?null:s.jsx(ct,{checked:o,onChange:r,label:e("settings.openchamber.visual.field.layoutAnimations"),ariaLabel:e("settings.openchamber.visual.field.layoutAnimationsAria"),info:e("settings.openchamber.visual.field.layoutAnimationsInfo"),settingsItem:"appearance.layout-animations"}),t[7]=a,t[8]=o,t[9]=r,t[10]=e,t[11]=y):y=t[11];let b;t[12]!==a||t[13]!==c||t[14]!==u||t[15]!==e?(b=is()&&!a?s.jsx(ct,{checked:c,onChange:u,label:e("settings.openchamber.visual.field.openLinksInBrowserPanel"),ariaLabel:e("settings.openchamber.visual.field.openLinksInBrowserPanel"),info:e("settings.openchamber.visual.field.openLinksInBrowserPanelInfo"),settingsItem:"appearance.open-links-in-browser-panel"}):null,t[12]=a,t[13]=c,t[14]=u,t[15]=e,t[16]=b):b=t[16];let x;t[17]!==e?(x=e("settings.openchamber.visual.field.openTrackerLinksOnBoard"),t[17]=e,t[18]=x):x=t[18];let w;t[19]!==e?(w=e("settings.openchamber.visual.field.openTrackerLinksOnBoard"),t[19]=e,t[20]=w):w=t[20];let S;t[21]!==e?(S=e("settings.openchamber.visual.field.openTrackerLinksOnBoardInfo"),t[21]=e,t[22]=S):S=t[22];let v;t[23]!==f||t[24]!==p||t[25]!==x||t[26]!==w||t[27]!==S?(v=s.jsx(ct,{checked:f,onChange:p,label:x,ariaLabel:w,info:S,settingsItem:"appearance.open-tracker-links-on-board"}),t[23]=f,t[24]=p,t[25]=x,t[26]=w,t[27]=S,t[28]=v):v=t[28];let A;t[29]!==a||t[30]!==d||t[31]!==l||t[32]!==e?(A=is()&&!a?s.jsx(st,{label:e("settings.openchamber.visual.field.liveBrowserTabs"),info:e("settings.openchamber.visual.field.liveBrowserTabsInfo"),settingsItem:"appearance.live-browser-tabs",children:s.jsxs("div",{className:Fn,children:[s.jsx(ds,{value:d,onValueChange:l,min:mf,max:uf,step:1,className:us,deferExternalValueWhileFocused:!0,"aria-label":e("settings.openchamber.visual.field.liveBrowserTabs")}),s.jsx("span",{className:ga,children:e("settings.openchamber.visual.field.liveBrowserTabsUnit")})]})}):null,t[29]=a,t[30]=d,t[31]=l,t[32]=e,t[33]=A):A=t[33];let I;return t[34]!==g||t[35]!==h||t[36]!==y||t[37]!==b||t[38]!==v||t[39]!==A?(I=s.jsxs($e,{title:g,contentClassName:bs,children:[h,y,b,v,A]}),t[34]=g,t[35]=h,t[36]=y,t[37]=b,t[38]=v,t[39]=A,t[40]=I):I=t[40],I},KS=t=>{const e=De.c(10),{firstSection:a}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=os(),e[0]=n):n=e[0];const i=n,{isMobile:o}=Zs(),r=!a;let c;e[1]!==r?(c=s.jsx(OS,{divider:r}),e[1]=r,e[2]=c):c=e[2];let u,d;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=i?null:s.jsx(FS,{}),d=i?null:s.jsx(LS,{}),e[3]=u,e[4]=d):(u=e[3],d=e[4]);let l;e[5]!==o?(l=o?s.jsx(TS,{}):null,e[5]=o,e[6]=l):l=e[6];let f;return e[7]!==c||e[8]!==l?(f=s.jsxs(s.Fragment,{children:[c,u,d,l]}),e[7]=c,e[8]=l,e[9]=f):f=e[9],f},_S=()=>{const t=De.c(55),{t:e}=Ee(),a=ft(bN),n=ft(xN),i=re(vN),o=re(yN);let r,c,u,d,l,f,p;if(t[0]!==a||t[1]!==n||t[2]!==o||t[3]!==e){let A;t[11]!==a?(A=E=>E.id===a,t[11]=a,t[12]=A):A=t[12];const I=Cd.find(A);let N;t[13]!==n?(N=E=>{n(E),jt({messageStreamTransport:E})},t[13]=n,t[14]=N):N=t[14];const k=N;let P;t[15]!==o?(P=E=>{o(E),jt({reportUsage:E})},t[15]=o,t[16]=P):P=t[16],c=P,r=$e,t[17]!==e?(u=e("settings.openchamber.visual.section.messageStreamTransport"),t[17]=e,t[18]=u):u=t[18],d="chat.message-transport",l="space-y-2";let j;t[19]!==e?(j=Cd.map(E=>({value:E.id,label:e(E.labelKey)})),t[19]=e,t[20]=j):j=t[20];let C;t[21]!==e?(C=e("settings.openchamber.visual.section.messageStreamTransport"),t[21]=e,t[22]=C):C=t[22],t[23]!==k||t[24]!==a||t[25]!==j||t[26]!==C?(f=s.jsx(Xt,{value:a,options:j,onChange:k,"aria-label":C}),t[23]=k,t[24]=a,t[25]=j,t[26]=C,t[27]=f):f=t[27],p=I?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e(I.descriptionKey)}):null,t[0]=a,t[1]=n,t[2]=o,t[3]=e,t[4]=r,t[5]=c,t[6]=u,t[7]=d,t[8]=l,t[9]=f,t[10]=p}else r=t[4],c=t[5],u=t[6],d=t[7],l=t[8],f=t[9],p=t[10];let g;t[28]!==r||t[29]!==u||t[30]!==d||t[31]!==l||t[32]!==f||t[33]!==p?(g=s.jsxs(r,{title:u,settingsItem:d,contentClassName:l,children:[f,p]}),t[28]=r,t[29]=u,t[30]=d,t[31]=l,t[32]=f,t[33]=p,t[34]=g):g=t[34];let h;t[35]!==e?(h=e("settings.openchamber.visual.section.privacy"),t[35]=e,t[36]=h):h=t[36];let y;t[37]!==e?(y=e("settings.openchamber.visual.field.sendAnonymousUsageReports"),t[37]=e,t[38]=y):y=t[38];let b;t[39]!==e?(b=e("settings.openchamber.visual.field.sendAnonymousUsageReportsHint"),t[39]=e,t[40]=b):b=t[40];let x;t[41]!==e?(x=e("settings.openchamber.visual.field.sendAnonymousUsageReportsAria"),t[41]=e,t[42]=x):x=t[42];let w;t[43]!==c||t[44]!==i||t[45]!==y||t[46]!==b||t[47]!==x?(w=s.jsx(ct,{checked:i,onChange:c,label:y,info:b,ariaLabel:x,settingsItem:"appearance.usage-reports"}),t[43]=c,t[44]=i,t[45]=y,t[46]=b,t[47]=x,t[48]=w):w=t[48];let S;t[49]!==w||t[50]!==h?(S=s.jsx($e,{title:h,children:w}),t[49]=w,t[50]=h,t[51]=S):S=t[51];let v;return t[52]!==S||t[53]!==g?(v=s.jsxs(s.Fragment,{children:[g,S]}),t[52]=S,t[53]=g,t[54]=v):v=t[54],v};function $S(t){return t.fileEditorKeymap}function zS(t){return t.setFileEditorKeymap}function US(t){return t.fileEditorVimMappings}function BS(t){return t.setFileEditorVimMappings}function VS(t){return t.fileTreeSide}function HS(t){return t.setFileTreeSide}function qS(t){return t.autoSaveEnabled}function WS(t){return t.setAutoSaveEnabled}function GS(t){return t.confirmFileTreeMove}function JS(t){return t.setConfirmFileTreeMove}function QS(t){return t.settingsDefaultFileViewerPreview}function YS(t){return t.setSettingsDefaultFileViewerPreview}function ZS(t){return t.terminalShell}function XS(t){return t.setTerminalShell}function eN(t){return t.terminalLoginShells}function tN(t){return t.setTerminalLoginShells}function sN(t){return t.showTerminalQuickKeysOnDesktop}function nN(t){return t.setShowTerminalQuickKeysOnDesktop}function aN(t){return t+1}function iN(t){return t.id!=="auto"}function oN(t){return s.jsx(bt,{value:t.id,children:t.name},t.id)}function rN(t){return t.sessionTabsEnabled}function lN(t){return t.setSessionTabsEnabled}function cN(t){return t.layoutAnimations}function dN(t){return t.setLayoutAnimations}function uN(t){return t.openLinksInBrowserPanel}function mN(t){return t.setOpenLinksInBrowserPanel}function pN(t){return t.liveBrowserTabLimit}function gN(t){return t.setLiveBrowserTabLimit}function fN(t){return t.openTrackerLinksOnBoard}function hN(t){return t.setOpenTrackerLinksOnBoard}function bN(t){return t.settingsMessageStreamTransport}function xN(t){return t.setSettingsMessageStreamTransport}function vN(t){return t.reportUsage}function yN(t){return t.setReportUsage}const lm=t=>`shortcuts.action.${t}`,jN=[{id:"chat.activity-default",page:"chat",titleKey:"settings.openchamber.visual.section.activityDefault",keywords:["activity","collapsed","expanded","live","tools","history"]},{id:"appearance.language",page:"appearance",titleKey:"settings.appearance.language.label",descriptionKey:"settings.appearance.language.description",keywords:["locale","translation","ui language"]},{id:"appearance.time-format",page:"appearance",titleKey:"settings.openchamber.visual.field.timeFormat",keywords:["clock","12h","24h"]},{id:"appearance.week-start",page:"appearance",titleKey:"settings.openchamber.visual.field.weekStartsOn",keywords:["calendar","monday","sunday"]},{id:"appearance.light-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.lightTheme",keywords:["theme","color","light mode"],isAvailable:t=>!t.isVSCode},{id:"appearance.dark-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.darkTheme",keywords:["theme","color","dark mode"],isAvailable:t=>!t.isVSCode},{id:"appearance.import-theme",page:"appearance",titleKey:"settings.themeImport.action",descriptionKey:"settings.themeImport.catalogHint",keywords:["theme","import","vscode","open vsx","openvsx","json","jsonc","syntax","palette"],isAvailable:t=>!t.isVSCode},{id:"appearance.dock-badge",page:"appearance",titleKey:"settings.openchamber.visual.field.dockBadge",descriptionKey:"settings.openchamber.visual.field.dockBadgeHint",keywords:["dock","badge","unread","unseen","counter","count","notification","macos"],isAvailable:t=>t.isMac},{id:"appearance.scrollbars",page:"appearance",titleKey:"settings.openchamber.visual.field.alwaysShowScrollbars",descriptionKey:"settings.openchamber.visual.field.alwaysShowScrollbarsHint",keywords:["scrollbar","scrollbars","scroll","mouse","wheel","accessibility","always visible"]},{id:"appearance.pwa-install-name",page:"appearance",titleKey:"settings.openchamber.visual.field.installAppName",descriptionKey:"settings.openchamber.visual.field.installAppNameHint",keywords:["pwa","installed app"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.pwa-orientation",page:"appearance",titleKey:"settings.openchamber.visual.field.installOrientation",descriptionKey:"settings.openchamber.visual.field.installOrientationHint",keywords:["pwa","portrait","landscape"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.mobile-keyboard-mode",page:"appearance",titleKey:"settings.openchamber.visual.field.mobileKeyboardMode",descriptionKey:"settings.openchamber.visual.field.mobileKeyboardModeHint",keywords:["mobile","keyboard","resize"],isAvailable:t=>t.isMobile&&t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.animated-activity-indicators",page:"appearance",titleKey:"settings.openchamber.visual.field.animatedActivityIndicators",descriptionKey:"settings.openchamber.visual.field.animatedActivityIndicatorsInfo",keywords:["spinner","animation","session","activity","motion","running","indicator"]},{id:"appearance.interface-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.interfaceFontSize",keywords:["font","text size","ui scale"],isAvailable:t=>!t.isMobile},{id:"appearance.terminal-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.terminalFontSize",keywords:["terminal","font","text size"]},{id:"appearance.terminal-shell",page:"general",titleKey:"settings.openchamber.visual.field.terminalShell",descriptionKey:"settings.openchamber.visual.field.terminalShellHint",keywords:["terminal","shell","bash","zsh","fish","pwsh","powershell"],isAvailable:t=>!t.isVSCode},{id:"appearance.editor-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.editorFontSize",keywords:["editor","font","text size","code"]},{id:"appearance.spacing-density",page:"appearance",titleKey:"settings.openchamber.visual.field.spacingDensity",keywords:["density","compact","comfortable","spacing"]},{id:"appearance.input-bar-offset",page:"appearance",titleKey:"settings.openchamber.visual.field.inputBarOffset",descriptionKey:"settings.openchamber.visual.field.inputBarOffsetTooltip",keywords:["input","home bar","offset"],isAvailable:t=>t.isMobile},{id:"appearance.auto-save-enabled",page:"general",titleKey:"settings.openchamber.visual.field.autoSaveEnabled",descriptionKey:"settings.openchamber.visual.field.autoSaveEnabledInfo",keywords:["editor","autosave","auto-save","files","save"]},{id:"appearance.confirm-file-tree-move",page:"general",titleKey:"settings.openchamber.visual.field.confirmFileTreeMove",keywords:["files","tree","move","drag","drop","confirm"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.file-tree-side",page:"general",titleKey:"settings.openchamber.visual.field.fileTreeSide",keywords:["files","tree","explorer","left","right","side","editor"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.layout-animations",page:"general",titleKey:"settings.openchamber.visual.field.layoutAnimations",descriptionKey:"settings.openchamber.visual.field.layoutAnimationsInfo",keywords:["animation","motion","sidebar","panel","slide","instant"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.open-links-in-browser-panel",page:"general",titleKey:"settings.openchamber.visual.field.openLinksInBrowserPanel",descriptionKey:"settings.openchamber.visual.field.openLinksInBrowserPanelInfo",keywords:["links","url","browser","open","preview","external"],isAvailable:t=>t.isDesktop&&!t.isMobile&&!t.isVSCode},{id:"appearance.live-browser-tabs",page:"general",titleKey:"settings.openchamber.visual.field.liveBrowserTabs",descriptionKey:"settings.openchamber.visual.field.liveBrowserTabsInfo",keywords:["browser","tabs","memory","reload","background","loaded"],isAvailable:t=>t.isDesktop&&!t.isMobile&&!t.isVSCode},{id:"layout.mobile-workspace-tabs",page:"general",titleKey:"settings.layout.general.mobileTabs.title",descriptionKey:"settings.layout.general.mobileTabs.info",keywords:["tabs","workspace","panel","order","hide","git","files","terminal","mcp","mobile"],isAvailable:t=>t.isMobile},{id:"appearance.open-tracker-links-on-board",page:"general",titleKey:"settings.openchamber.visual.field.openTrackerLinksOnBoard",descriptionKey:"settings.openchamber.visual.field.openTrackerLinksOnBoardInfo",keywords:["links","github","gitlab","linear","issue","pull request","merge request","board"],isAvailable:t=>!t.isVSCode},{id:"appearance.file-editor-keymap",page:"general",titleKey:"settings.openchamber.visual.field.fileEditorKeymap",keywords:["editor","vim","keymap"]},{id:"appearance.session-tabs",page:"general",titleKey:"settings.openchamber.visual.field.sessionTabsGroup",descriptionKey:"settings.openchamber.visual.field.sessionTabsInfo",keywords:["session","tabs","header","working set"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.terminal-quick-keys",page:"general",titleKey:"settings.openchamber.visual.field.terminalQuickKeys",descriptionKey:"settings.openchamber.visual.field.terminalQuickKeysTooltip",keywords:["terminal","keyboard","esc","ctrl","arrows"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.usage-reports",page:"general",titleKey:"settings.openchamber.visual.field.sendAnonymousUsageReports",descriptionKey:"settings.openchamber.visual.field.sendAnonymousUsageReportsHint",keywords:["telemetry","analytics"]},{id:"general.app-links",page:"general",titleKey:"settings.openchamber.appLinks.title",descriptionKey:"settings.openchamber.appLinks.info",keywords:["security","app link","deep link","scheme","protocol","obsidian","notion"]},{id:"chat.message-transport",page:"general",titleKey:"settings.openchamber.visual.section.messageStreamTransport",keywords:["streaming","sse","websocket"]},{id:"chat.session-recap",page:"chat",titleKey:"settings.openchamber.visual.field.sessionRecap",keywords:["recap","assist","small model","summary"]},{id:"chat.session-assistance",page:"chat",titleKey:"settings.openchamber.visual.section.sessionAssistance",keywords:["recap","suggestion","subagent"]},{id:"chat.session-suggestion",page:"chat",titleKey:"settings.openchamber.visual.field.sessionSuggestion",keywords:["suggestion","assist","small model","follow up"]},{id:"chat.session-review-offer",page:"chat",titleKey:"settings.openchamber.visual.field.sessionReviewOffer",descriptionKey:"settings.openchamber.visual.field.sessionReviewOfferInfo",keywords:["review","walkthrough","changes","diff","jev","classification"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal",page:"chat",titleKey:"settings.openchamber.visual.field.sessionGoal",keywords:["goal","objective","auto continue"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal-checker",page:"chat",titleKey:"settings.openchamber.visual.goal.checkerLabel",keywords:["goal","progress","check","jev","classification","small model"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal-max-turns",page:"chat",titleKey:"settings.openchamber.visual.goal.maxTurnsLabel",keywords:["goal","turns","limit","continuations","safety"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal-budget",page:"chat",titleKey:"settings.openchamber.visual.goal.budgetLabel",keywords:["goal","budget","tokens","limit"],isAvailable:t=>!t.isVSCode},{id:"chat.reasoning-traces",page:"chat",titleKey:"settings.openchamber.visual.field.showReasoningTraces",keywords:["thinking","reasoning"]},{id:"chat.reasoning",page:"chat",titleKey:"settings.openchamber.visual.section.reasoning",keywords:["thinking","traces","collapse","expand","streaming"]},{id:"chat.streaming-auto-follow",page:"chat",titleKey:"settings.openchamber.visual.field.streamingAutoFollow",descriptionKey:"settings.openchamber.visual.field.streamingAutoFollowInfo",keywords:["autoscroll","auto-scroll","follow","stick to bottom","streaming"]},{id:"chat.sticky-user-header",page:"chat",titleKey:"settings.openchamber.visual.field.stickyUserHeader",keywords:["sticky","pin","prompt","header","user messages"]},{id:"chat.prompt-navigator",page:"chat",titleKey:"settings.openchamber.visual.field.promptNavigatorEnabled",keywords:["prompt","navigator","navigation","timeline","scroll"]},{id:"chat.collapsible-user-messages",page:"chat",titleKey:"settings.openchamber.visual.field.collapsibleUserMessages",keywords:["collapse","expand","clamp","long messages","user messages"]},{id:"chat.wide-layout",page:"chat",titleKey:"settings.openchamber.visual.field.wideChatLayout",keywords:["layout","wide","messages"]},{id:"chat.message-appearance",page:"chat",titleKey:"settings.layout.chat.section.reading",keywords:["layout","messages","appearance"]},{id:"chat.code-block-line-wrap",page:"chat",titleKey:"settings.openchamber.visual.field.codeBlockLineWrap",keywords:["code","wrap","line wrap","markdown"]},{id:"chat.table-cell-wrap",page:"chat",titleKey:"settings.openchamber.visual.field.tableCellWrap",descriptionKey:"settings.openchamber.visual.field.tableCellWrapInfo",keywords:["table","wrap","cell","columns","markdown"]},{id:"chat.copy-plain-text",page:"chat",titleKey:"settings.openchamber.visual.field.copyMessagesAsPlainText",descriptionKey:"settings.openchamber.visual.field.copyMessagesAsPlainTextInfo",keywords:["copy","clipboard","plain text","markdown","selection"]},{id:"chat.inline-assistant-actions",page:"chat",titleKey:"settings.openchamber.visual.field.showSplitAssistantMessageActions",descriptionKey:"settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip",keywords:["copy","save image","read aloud"]},{id:"chat.draft-starters-visible",page:"chat",titleKey:"settings.openchamber.visual.field.draftStartersVisible",keywords:["starter","starters","new session","welcome","suggestions"]},{id:"chat.subagent-read-only-banner",page:"chat",titleKey:"settings.openchamber.visual.field.allowPromptingSubagentSessions",keywords:["subagent","read only","prompt","banner"]},{id:"chat.save-images-for-text-models",page:"chat",titleKey:"settings.openchamber.visual.field.saveImagesForTextOnlyModels",descriptionKey:"settings.openchamber.visual.field.saveImagesForTextOnlyModelsInfo",keywords:["image","screenshot","paste","vision","text-only","model","path","attachment"]},{id:"chat.tool-file-icons",page:"chat",titleKey:"settings.openchamber.visual.field.showToolFileIcons",keywords:["tools","files","icons"]},{id:"chat.changed-files",page:"chat",titleKey:"settings.openchamber.visual.field.showTurnChangedFiles",keywords:["changed files","turns"]},{id:"chat.dotfiles",page:"general",titleKey:"settings.openchamber.visual.field.showDotfiles",keywords:["hidden files","dotfiles","file tree","files"],isAvailable:t=>!t.isVSCode},{id:"general.file-viewer-preview",page:"general",titleKey:"settings.openchamber.defaults.field.openFilesPreview",keywords:["preview","markdown","files","viewer","rendered"]},{id:"chat.user-message-rendering",page:"chat",titleKey:"settings.openchamber.visual.section.userMessageRendering",keywords:["markdown","plain text","user message","format"]},{id:"chat.mermaid-rendering",page:"chat",titleKey:"settings.openchamber.visual.section.mermaidRendering",keywords:["mermaid","diagram","svg","ascii"]},{id:"chat.diff-layout",page:"chat",titleKey:"settings.openchamber.visual.section.diffLayout",keywords:["diff","inline","side by side","split","changes"],isAvailable:t=>!t.isVSCode},{id:"chat.follow-up-behavior",page:"chat",titleKey:"settings.openchamber.visual.section.followUpBehavior",descriptionKey:"settings.openchamber.visual.field.followUpBehaviorDescription",keywords:["follow up","queue","steer","send immediately"]},{id:"chat.input-history-scope",page:"chat",titleKey:"settings.openchamber.visual.field.inputHistoryScope",descriptionKey:"settings.openchamber.visual.field.inputHistoryScopeDescription",keywords:["input history","composer history","global","session","reuse"]},{id:"chat.input-history-limit",page:"chat",titleKey:"settings.openchamber.visual.field.inputHistoryLimit",descriptionKey:"settings.openchamber.visual.field.inputHistoryLimitDescription",keywords:["history limit","prompt recall","remember prompts","composer history","submitted prompts","trim history"]},{id:"chat.message-search",page:"chat",titleKey:"settings.openchamber.messageSearch.title",keywords:["search","find","index","messages","history","full text"],isAvailable:t=>!t.isVSCode},{id:"chat.message-search-enabled",page:"chat",titleKey:"settings.openchamber.messageSearch.field.enabled",keywords:["search","find","index","messages"],isAvailable:t=>!t.isVSCode},{id:"chat.message-search-reasoning",page:"chat",titleKey:"settings.openchamber.messageSearch.field.reasoning",keywords:["search","reasoning","thinking","index"],isAvailable:t=>!t.isVSCode},{id:"chat.persist-drafts",page:"chat",titleKey:"settings.openchamber.visual.field.persistDraftMessages",keywords:["draft","message"]},{id:"chat.composer",page:"chat",titleKey:"settings.layout.chat.section.sending",keywords:["composer","input","send","paste","follow-up"]},{id:"chat.spellcheck",page:"chat",titleKey:"settings.openchamber.visual.field.enableSpellcheckInTextInputs",keywords:["spelling","input"],isAvailable:t=>!t.isMobile},{id:"chat.large-text-paste",page:"chat",titleKey:"settings.openchamber.visual.field.largeTextPaste",descriptionKey:"settings.openchamber.visual.field.largeTextPasteHint",keywords:["paste","clipboard","attachment","large","text","file","double paste","ctrl v","cmd v"]},{id:"chat.enter-to-send",page:"chat",titleKey:"settings.openchamber.visual.field.enterToSend",descriptionKey:"settings.openchamber.visual.field.enterToSendHint",keywords:["enter","shift enter","ctrl enter","cmd enter","mod enter","send","newline"],isAvailable:t=>!t.isMobile},{id:"sessions.default-model",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultModel",keywords:["model","provider","new sessions"]},{id:"sessions.default-thinking",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultThinking",keywords:["thinking","reasoning","variant"]},{id:"sessions.default-agent",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultAgent",keywords:["agent","new sessions"]},{id:"sessions.deletion-dialog",page:"sessions",titleKey:"settings.openchamber.defaults.field.showDeletionDialog",keywords:["delete","confirmation"]},{id:"sessions.warming",page:"sessions",titleKey:"settings.openchamber.defaults.field.sessionWarming",descriptionKey:"settings.openchamber.defaults.field.sessionWarmingInfo",keywords:["warming","warm","cache","prompt cache","keep-alive","idle","per session","keep warm"]},{id:"sessions.warming-duration",page:"sessions",titleKey:"settings.openchamber.defaults.sessionWarming.duration",keywords:["warming","warm","duration","how long","hour","cache"],isAvailable:t=>!t.isVSCode},{id:"sessions.permission-default",page:"sessions",titleKey:"settings.sessions.permissions.defaultMode",descriptionKey:"settings.sessions.permissions.defaultModeInfo",keywords:["permissions","auto-accept","accept","safety net","ask","shield","approval","new session"],isAvailable:t=>!t.isVSCode},{id:"sessions.show-chats",page:"sessions",titleKey:"settings.openchamber.defaults.field.showChats",keywords:["chats","sidebar","hide","show","section"],isAvailable:t=>!t.isVSCode},{id:"sessions.work",page:"sessions",titleKey:"settings.openchamber.sessionWork.title",descriptionKey:"settings.openchamber.sessionWork.info",keywords:["in work","in progress","track","done","inbox","sidebar","recent","jev"]},{id:"sessions.work-enabled",page:"sessions",titleKey:"settings.openchamber.sessionWork.field.enabled",keywords:["in work","in progress","track","done","sidebar"]},{id:"sessions.small-model",page:"sessions",titleKey:"settings.openchamber.defaults.smallModel.title",descriptionKey:"settings.openchamber.defaults.smallModel.description",keywords:["small model","utility","summary","recap","cheap","override"]},{id:"sessions.walkthrough-model",page:"sessions",titleKey:"settings.openchamber.defaults.walkthroughModel.title",descriptionKey:"settings.openchamber.defaults.walkthroughModel.description",keywords:["walkthrough","diff","review","changes","structured output","model","override"]},{id:"sessions.auto-cleanup",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.enableAutoCleanup",descriptionKey:"settings.openchamber.sessionRetention.tooltip",keywords:["retention","archive","delete"]},{id:"sessions.merged-worktree-cleanup",page:"sessions",titleKey:"settings.openchamber.mergedWorktreeCleanup.field.enable",descriptionKey:"settings.openchamber.mergedWorktreeCleanup.field.enableDescription",keywords:["pr","pull request","merged","worktree","branch","archive","cleanup","remove"]},{id:"sessions.retention-only-archived",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.onlyArchived",descriptionKey:"settings.openchamber.sessionRetention.field.onlyArchivedDescription",keywords:["archive","archived","only","delete","cleanup","retention"]},{id:"sessions.retention-period",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.retentionPeriod",keywords:["days","cleanup","retention"]},{id:"sessions.retention-action",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.whenSessionsExpire",keywords:["archive","delete","expire"]},{id:"sessions.desktop-launch-at-login",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.launchAtLogin",descriptionKey:"settings.openchamber.desktopNetwork.field.launchAtLoginDescription",keywords:["desktop","startup","login","launch","background","autostart"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-window-controls-position",page:"appearance",titleKey:"settings.openchamber.desktopNetwork.field.windowControlsPosition",descriptionKey:"settings.openchamber.desktopNetwork.field.windowControlsPositionDescription",keywords:["desktop","window","controls","minimize","maximize","close","titlebar","linux","windows"],isAvailable:t=>t.isDesktop&&(t.isWindows||!t.isMac)},{id:"sessions.desktop-window-controls-style",page:"appearance",titleKey:"settings.openchamber.desktopNetwork.field.windowControlsStyle",keywords:["desktop","window","controls","style","traffic","lights","classic","macos","titlebar"],isAvailable:t=>t.isDesktop&&(t.isWindows||!t.isMac)},{id:"sessions.desktop-mac-menu-bar",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.macMenuBar",descriptionKey:"settings.openchamber.desktopNetwork.field.macMenuBarDescription",keywords:["desktop","menu bar","tray","status item","macos","background"],isAvailable:t=>t.isDesktopLocalOrigin&&t.isMac},{id:"sessions.desktop-linux-native-frame",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.linuxNativeFrame",descriptionKey:"settings.openchamber.desktopNetwork.field.linuxNativeFrameDescription",keywords:["desktop","linux","title bar","titlebar","window","frame","decorations","gnome","kde"],isAvailable:t=>t.isDesktopLocalOrigin&&t.isLinux},{id:"sessions.desktop-minimize-to-tray",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.minimizeToTray",descriptionKey:"settings.openchamber.desktopNetwork.field.minimizeToTrayDescription",keywords:["desktop","tray","system tray","minimize","close","background","windows","linux"],isAvailable:t=>t.isDesktopLocalOrigin&&(t.isWindows||t.isLinux)},{id:"sessions.desktop-keep-awake",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.keepAwake",descriptionKey:"settings.openchamber.desktopNetwork.field.keepAwakeDescription",keywords:["desktop","sleep","awake","server","mobile","phone"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-mini-chat-global-shortcut",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.miniChatGlobalShortcut",descriptionKey:"settings.openchamber.desktopNetwork.field.miniChatGlobalShortcutDescription",keywords:["desktop","mini chat","shortcut","hotkey","global","keyboard"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-quake-mode",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.quakeMode",descriptionKey:"settings.openchamber.desktopNetwork.field.quakeModeDescription",keywords:["desktop","quake","dropdown","hotkey","shortcut","height","global","background","tray","terminal"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-ui-password",page:"general",titleKey:"settings.openchamber.desktopPassword.field.password",descriptionKey:"settings.openchamber.desktopPassword.field.passwordDescription",keywords:["desktop","password","auth","login"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-lan-access",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.allowLanAccess",descriptionKey:"settings.openchamber.desktopNetwork.field.allowLanAccessDescription",keywords:["desktop","lan","network","phone","tablet"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.opencode-binary",page:"general",titleKey:"settings.openchamber.opencodeCli.field.binaryPath",keywords:["opencode","cli","binary","path"],isAvailable:t=>!t.isVSCode},{id:"sessions.opencode-restart",page:"general",titleKey:"settings.openchamber.opencodeCli.actions.restart",keywords:["opencode","restart","reload","plugin"],isAvailable:t=>!t.isVSCode},{id:"general.environment-variables",page:"general",titleKey:"settings.environment.user.title",descriptionKey:"settings.environment.user.info",keywords:["environment","env","variables","api key","token","secret","opencode","terminal","git"],isAvailable:t=>!t.isVSCode},{id:"sessions.opencode-update-notifications",page:"general",titleKey:"settings.openchamber.opencodeCli.field.showUpdateNotifications",keywords:["opencode","cli","updates"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-control-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentControlTool",descriptionKey:"settings.openchamber.tools.field.agentControlToolInfo",keywords:["agent","tool","orchestration","openchamber","sessions","worktree","control"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-schedule-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentScheduleTool",descriptionKey:"settings.openchamber.tools.field.agentScheduleToolInfo",keywords:["agent","tool","schedule","scheduled","task","cron","recurring","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-web-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentWebTool",descriptionKey:"settings.openchamber.tools.field.agentWebToolInfo",keywords:["agent","tool","web","browser","page","preview","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.browser-provider",page:"general",titleKey:"settings.openchamber.tools.browserProvider.label",descriptionKey:"settings.openchamber.tools.browserProvider.info",keywords:["agent","browser","provider","extension","chrome","server","headless"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-notify-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentNotifyTool",descriptionKey:"settings.openchamber.tools.field.agentNotifyToolInfo",keywords:["agent","tool","notify","notification","alert","ping","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-render-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentRenderTool",descriptionKey:"settings.openchamber.tools.field.agentRenderToolInfo",keywords:["agent","tool","render","page","html","chart","table","diagram","generative","ui","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-knowledge-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentKnowledgeTool",descriptionKey:"settings.openchamber.tools.field.agentKnowledgeToolInfo",keywords:["agent","tool","project","knowledge","notes","todos","plans","openchamber"],isAvailable:t=>!t.isVSCode},{id:"general.isolated-spaces",page:"isolated-spaces",titleKey:"settings.openchamber.spaces.field.enabled",descriptionKey:"settings.openchamber.spaces.field.enabledInfo",keywords:["isolated","space","spaces","container","docker","sandbox","agent"],isAvailable:t=>!t.isVSCode&&Af()},{id:"general.isolated-spaces-idle-stop",page:"isolated-spaces",titleKey:"settings.openchamber.spaces.idleStop.enabled",descriptionKey:"settings.openchamber.spaces.idleStop.enabledInfo",keywords:["idle","stop","space","spaces","container","hours","timeout","sleep"],isAvailable:t=>!t.isVSCode&&re.getState().isolatedSpacesEnabled},{id:"general.isolated-spaces-machine",page:"isolated-spaces",titleKey:"settings.openchamber.spaces.places.machine.label",descriptionKey:"settings.openchamber.spaces.places.machine.info",keywords:["machine","ssh","remote","docker","space","spaces","host","server"],isAvailable:t=>!t.isVSCode&&re.getState().isolatedSpacesEnabled},{id:"sessions.agent-memory-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentMemoryTool",descriptionKey:"settings.openchamber.tools.field.agentMemoryToolInfo",keywords:["agent","tool","memory","remember","recall","preferences","openchamber"],isAvailable:t=>!t.isVSCode&&re.getState().agentMemoryFeatureAvailable},{id:"git.gitlab-account",page:"integrations",titleKey:"settings.gitlab.title",descriptionKey:"settings.gitlab.info",keywords:["gitlab","account","oauth","pat","merge request","issues","glab"],isAvailable:t=>!t.isVSCode},{id:"git.gitlab-connect",page:"integrations",titleKey:"settings.gitlab.actions.connect",keywords:["gitlab","connect","add account","oauth","pat","token","instance"],isAvailable:t=>!t.isVSCode},{id:"routing.token",page:"routing",titleKey:"settings.routing.token.label",descriptionKey:"settings.routing.token.info",keywords:["jev","typesafe","api key","token","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable},{id:"sessions.agent-tools-code-mode",page:"general",titleKey:"settings.openchamber.tools.field.agentToolsCodeMode",descriptionKey:"settings.openchamber.tools.field.agentToolsCodeModeInfo",keywords:["agent","tool","code mode","codemode","execute","openchamber"],isAvailable:t=>!t.isVSCode},{id:"routing.enabled",page:"routing",titleKey:"settings.routing.auto.enable",descriptionKey:"settings.routing.auto.enableInfo",keywords:["auto","routing","model","jev","automatic"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"routing.preserve-cache",page:"routing",titleKey:"settings.routing.auto.preserveCache",descriptionKey:"settings.routing.auto.preserveCacheInfo",keywords:["cache","prompt cache","auto","routing","switch","model","cost"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"routing.fallback-model",page:"routing",titleKey:"settings.routing.auto.fallbackModel",descriptionKey:"settings.routing.auto.fallbackModelInfo",keywords:["fallback","default","model","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"routing.add-category",page:"routing",titleKey:"settings.routing.categories.title",descriptionKey:"settings.routing.categories.description",keywords:["category","categories","task type","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"git.identities",page:"git",titleKey:"settings.gitIdentities.page.section.title",descriptionKey:"settings.gitIdentities.page.empty.description",keywords:["identity","profile","author","email","credentials","account","transport","ssh","ssh key","signing","commit signing","ssh signing","gpg"]},{id:"git.changes-view",page:"git",titleKey:"settings.openchamber.git.changesViewTitle",keywords:["changes","flat list","tree view"]},{id:"git.gitmoji",page:"git",titleKey:"settings.openchamber.git.enableGitmoji",keywords:["commit","emoji"]},{id:"git.gitignored-files",page:"git",titleKey:"settings.openchamber.git.showGitignored",keywords:["ignored","files","gitignore"]},{id:"usage.work-status-panel",page:"usage",titleKey:"settings.usage.page.options.showInWorkStatus",descriptionKey:"settings.usage.page.options.showInWorkStatusTooltip",keywords:["quota","work","status","panel"]},{id:"usage.model-quotas",page:"usage",titleKey:"settings.usage.page.section.modelQuotas",keywords:["models","quota","limits","tokens"]},{id:"projects.name",page:"projects",titleKey:"settings.projects.page.field.projectName",keywords:["label","display name","project metadata"]},{id:"projects.default-agent",page:"projects",titleKey:"settings.projects.page.field.projectAgent",keywords:["agent","default","new chat","project metadata"]},{id:"projects.default-model",page:"projects",titleKey:"settings.projects.page.field.projectModel",keywords:["model","default","new chat","project metadata"]},{id:"projects.default-thinking",page:"projects",titleKey:"settings.projects.page.field.projectThinking",keywords:["thinking","variant","reasoning","effort","model","project metadata"]},{id:"projects.icon",page:"projects",titleKey:"settings.projects.page.field.projectIcon",keywords:["icon","favicon","upload","color","accent color","appearance","project metadata"]},{id:"projects.close",page:"projects",titleKey:"settings.projects.page.actions.closeProject",keywords:["close","remove","delete","forget","project"],isAvailable:t=>!t.isVSCode},{id:"projects.actions",page:"projects",titleKey:"settings.projects.actions.title",descriptionKey:"settings.projects.actions.info",keywords:["run","run button","commands","dev server","scripts","project actions"]},{id:"projects.worktree",page:"projects",titleKey:"settings.projects.page.section.worktree",keywords:["worktree","branch","repository"]},{id:"projects.worktree.setup.wait",page:"projects",titleKey:"settings.openchamber.worktrees.setup.waitForCommands",keywords:["worktree","setup commands","bootstrap","wait"]},{id:"projects.worktree.setup.replace",page:"projects",titleKey:"settings.projects.shared.replaceMode",keywords:["worktree","setup commands","shared","team","only mine"]},{id:"projects.environment",page:"projects",titleKey:"settings.projects.environment.title",descriptionKey:"settings.projects.environment.info",keywords:["environment","env","variables","direnv","devenv","nix","envrc","path","terminal","git hooks"],isAvailable:t=>!t.isVSCode},{id:"projects.shared",page:"projects",titleKey:"settings.projects.team.title",descriptionKey:"settings.projects.team.info",keywords:["shared","team","repository",".openchamber","project.json","trust"]},{id:"projects.shared.plansDir",page:"projects",titleKey:"settings.projects.shared.plansDir",descriptionKey:"settings.projects.shared.plansDirInfo",keywords:["plans","folder","shared","team","docs"]},{id:"remote-instances.client-auth",page:"remote-instances",titleKey:"settings.remoteInstances.clientAuth.title",descriptionKey:"settings.remoteInstances.clientAuth.description",keywords:["pairing link","client token","connect desktop","remote access","relay","devices","connect from anywhere"],isAvailable:t=>!t.isVSCode},{id:"remote-instances.direct-hosts",page:"remote-instances",titleKey:"settings.remoteInstances.direct.title",descriptionKey:"settings.remoteInstances.direct.description",keywords:["server url","connection token","import link","host switcher","additional headers","request headers","cloudflare access","service token"],isAvailable:t=>t.isDesktop},{id:"behavior.system-prompt",page:"behavior",titleKey:"settings.behavior.page.section.systemPrompt",descriptionKey:"settings.behavior.page.warning.title",keywords:["agents.md","global instructions","system prompt"]},{id:"behavior.response-style",page:"behavior",titleKey:"settings.behavior.page.section.responseStyle",descriptionKey:"settings.behavior.page.responseStyle.tooltip",keywords:["tone","concise","detailed","custom instructions"]},{id:"agents.create",page:"agents",titleKey:"settings.agents.page.title.new",keywords:["create","add","new agent"]},{id:"agents.name",page:"agents",titleKey:"settings.agents.page.field.agentName",keywords:["agent","name"]},{id:"agents.mode",page:"agents",titleKey:"settings.agents.page.field.mode",descriptionKey:"settings.agents.page.field.modeTooltip",keywords:["primary","subagent","visibility"]},{id:"agents.color",page:"agents",titleKey:"settings.agents.page.field.color",descriptionKey:"settings.agents.page.field.colorTooltip",keywords:["colour","hex","accent"]},{id:"agents.model",page:"agents",titleKey:"settings.agents.page.field.overrideModel",keywords:["model","provider"]},{id:"agents.variant",page:"agents",titleKey:"settings.agents.page.field.variant",descriptionKey:"settings.agents.page.field.variantTooltip",keywords:["thinking","reasoning","variant","depth"]},{id:"agents.temperature",page:"agents",titleKey:"settings.agents.page.field.temperature",descriptionKey:"settings.agents.page.field.temperatureTooltip",keywords:["randomness","creative"]},{id:"agents.top-p",page:"agents",titleKey:"settings.agents.page.field.topP",descriptionKey:"settings.agents.page.field.topPTooltip",keywords:["sampling","nucleus"]},{id:"agents.system-prompt",page:"agents",titleKey:"settings.agents.page.section.systemPrompt",keywords:["prompt","instructions"]},{id:"agents.steps",page:"agents",titleKey:"settings.agents.page.field.steps",descriptionKey:"settings.agents.page.field.stepsTooltip",keywords:["steps","loop","tool calls"]},{id:"agents.permissions",page:"agents",titleKey:"settings.agents.page.section.toolPermissions",keywords:["tools","permissions","rules","allow","ask","deny"]},{id:"commands.create",page:"commands",titleKey:"settings.commands.page.title.new",keywords:["create","add","new command"]},{id:"commands.name",page:"commands",titleKey:"settings.commands.page.field.commandName",keywords:["slash command","name"]},{id:"commands.agent",page:"commands",titleKey:"settings.commands.page.field.overrideAgent",keywords:["agent","execution"]},{id:"commands.model",page:"commands",titleKey:"settings.agents.page.field.overrideModel",keywords:["model","provider"]},{id:"commands.variant",page:"commands",titleKey:"settings.agents.page.field.variant",keywords:["variant","reasoning","thinking"]},{id:"commands.subagent",page:"commands",titleKey:"settings.commands.page.field.subagent",descriptionKey:"settings.commands.page.field.subagentTooltip",keywords:["subagent","background","child session"]},{id:"commands.template",page:"commands",titleKey:"settings.commands.page.section.template",keywords:["prompt","template","arguments","shell","file"]},{id:"mcp.create",page:"mcp",titleKey:"settings.mcp.sidebar.actions.addServerTitle",keywords:["create","add","server"]},{id:"mcp.server",page:"mcp",titleKey:"settings.mcp.page.server.title",keywords:["server","name","transport"]},{id:"mcp.command",page:"mcp",titleKey:"settings.mcp.page.connection.command",keywords:["stdio","local","command"]},{id:"mcp.environment",page:"mcp",titleKey:"settings.mcp.page.env.title",keywords:["env","variables","api key"]},{id:"mcp.advanced",page:"mcp",titleKey:"settings.mcp.page.advanced.title",keywords:["oauth","headers","timeout","code mode","codemode"]},{id:"plugins.create",page:"plugins",titleKey:"settings.plugins.sidebar.actions.addTitle",keywords:["add","plugin","npm","path","file"]},{id:"plugins.spec",page:"plugins",titleKey:"settings.plugins.page.field.spec",keywords:["npm","package","path"]},{id:"plugins.options",page:"plugins",titleKey:"settings.plugins.page.field.options",keywords:["json","configuration"]},{id:"plugins.content",page:"plugins",titleKey:"settings.plugins.page.field.content",keywords:["file","code"]},{id:"snippets.create",page:"snippets",titleKey:"settings.snippets.sidebar.actions.create",keywords:["add","new snippet"]},{id:"snippets.content",page:"snippets",titleKey:"settings.snippets.page.field.content",keywords:["markdown","prompt","template"]},{id:"providers.connect",page:"providers",titleKey:"settings.providers.page.connect.title",keywords:["add provider","connect provider","credentials"]},{id:"providers.classification",page:"providers",titleKey:"settings.classification.page.title",descriptionKey:"settings.classification.page.description",keywords:["jev","typesafe","zen","api key","token","safety net","auto","routing","classification","promotion","off","disable","privacy","custom endpoint","base url","openai-compatible","system one","self-hosted","proxy"],isAvailable:t=>!t.isVSCode&&t.routingAvailable},{id:"providers.custom",page:"providers",titleKey:"settings.providers.page.custom.title",descriptionKey:"settings.providers.page.custom.description",keywords:["other","custom","openai-compatible","base url","api key"]},{id:"providers.auth",page:"providers",titleKey:"settings.providers.accounts.title",keywords:["api key","oauth","credentials","accounts","switch account","disconnect"]},{id:"providers.models",page:"providers",titleKey:"settings.providers.page.models.title",keywords:["models","hide","show"]},{id:"web-search.provider",page:"web-search",titleKey:"settings.webSearch.section.provider",descriptionKey:"settings.webSearch.section.providerInfo",keywords:["web search","websearch","internet","default provider","disable","off","random"]},{id:"web-search.providers",page:"web-search",titleKey:"settings.webSearch.section.providers",descriptionKey:"settings.webSearch.section.providersInfo",keywords:["api key","exa","tavily","firecrawl","parallel","tinyfish","searxng","brave","kagi","perplexity","linkup","serper","credentials"]},{id:"skills.create",page:"skills.installed",titleKey:"settings.skills.page.title.newSkill",keywords:["create","add","new skill"]},{id:"skills.basic-information",page:"skills.installed",titleKey:"settings.skills.page.section.basicInformation",keywords:["name","location","description","manual","invocation","autoinvoke"]},{id:"skills.instructions",page:"skills.installed",titleKey:"settings.skills.page.section.instructions",keywords:["markdown","skill.md","content"]},{id:"skills.supporting-files",page:"skills.installed",titleKey:"settings.skills.page.section.supportingFiles",keywords:["files","resources"]},{id:"skills.catalog.source",page:"skills.catalog",titleKey:"settings.skills.catalog.page.section.sourceRepository",keywords:["catalog","repository","source","refresh"]},{id:"skills.catalog.search",page:"skills.catalog",titleKey:"settings.skills.catalog.shared.field.searchSkillsPlaceholder",keywords:["find skills","install skills","catalog search"]},{id:"skills.catalog.add-catalog",page:"skills.catalog",titleKey:"settings.skills.catalog.page.actions.addCatalog",keywords:["external repository","add source","catalog"]},{id:"magic-prompts.visible-prompt",page:"magic-prompts",titleKey:"settings.magicPrompts.page.block.visiblePrompt",keywords:["prompt text","user message","template"],isAvailable:t=>!t.isVSCode},{id:"magic-prompts.instructions",page:"magic-prompts",titleKey:"settings.magicPrompts.page.block.instructions",keywords:["hidden prompt","instructions","template"],isAvailable:t=>!t.isVSCode},{id:"magic-prompts.reset-overrides",page:"magic-prompts",titleKey:"settings.magicPrompts.page.actions.resetAllOverrides",keywords:["reset","default prompts","overrides"],isAvailable:t=>!t.isVSCode},{id:"shortcuts.keyboard-shortcuts",page:"shortcuts",titleKey:"settings.openchamber.keyboardShortcuts.title",descriptionKey:"settings.openchamber.keyboardShortcuts.tooltip",keywords:["keyboard","hotkeys","bindings"]},...Wo().filter(t=>t.category!=="desktop").map(t=>({id:lm(t.id),page:"shortcuts",titleKey:t.settingsLabelKey,keywords:["shortcut","hotkey","keyboard","keybinding"]})),{id:"voice.playback",page:"voice",titleKey:"settings.voice.page.section.playbackAndSummary",keywords:["tts","read aloud","voice","provider","speech rate","speech pitch","speech volume","tts input mode","markdown"]},{id:"voice.speech-recognition",page:"voice",titleKey:"settings.voice.page.section.speechRecognition",keywords:["stt","dictation","voice input","transcribe","whisper","parakeet","microphone"]},{id:"tunnel.provider",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.provider",descriptionKey:"settings.openchamber.tunnel.description",keywords:["remote access","cloudflare","ngrok"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.type",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.tunnelType",keywords:["quick","managed remote","managed local"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.ttl",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.connectLinkTtl",descriptionKey:"settings.openchamber.tunnel.field.tunnelSessionTtl",keywords:["expiry","expiration","session ttl","connect link ttl"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.managed-remote",page:"tunnel",titleKey:"settings.openchamber.tunnel.section.savedManagedRemoteTunnels",keywords:["cloudflare","hostname","token","managed remote"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.managed-local-config",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.configurationFile",descriptionKey:"settings.openchamber.tunnel.note.managedLocalUsesConfig",keywords:["cloudflared","config","yaml","json","managed local"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.start",page:"tunnel",titleKey:"settings.openchamber.tunnel.actions.startTunnel",descriptionKey:"settings.openchamber.tunnel.note.connectLinksOneTime",keywords:["connect link","qr code","public url","remote access"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"notifications.delivery",page:"notifications",titleKey:"settings.notifications.page.delivery.title",keywords:["desktop notifications","system notifications"]},{id:"notifications.events",page:"notifications",titleKey:"settings.notifications.page.events.title",keywords:["completion","subtasks","errors","questions"]},{id:"notifications.push",page:"notifications",titleKey:"settings.notifications.page.push.title",keywords:["background","push"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"integrations.first-party",page:"integrations",titleKey:"settings.integrations.firstParty.title",descriptionKey:"settings.integrations.firstParty.info",keywords:["built-in","first-party","native","github","linear"],isAvailable:t=>!t.isVSCode},{id:"integrations.github",page:"integrations",titleKey:"settings.integrations.github.title",descriptionKey:"settings.integrations.github.description",keywords:["github","account","oauth","gh","cli","prs","pull request","issues","connect"],isAvailable:t=>!t.isVSCode},{id:"git.github-connect",page:"integrations",titleKey:"settings.github.page.actions.connect",keywords:["github","connect","add account","oauth","device flow"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear",page:"integrations",titleKey:"settings.integrations.linear.title",descriptionKey:"settings.integrations.linear.description",keywords:["linear","issues","oauth","connect","workspace"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear.add-workspace",page:"integrations",titleKey:"settings.integrations.linear.actions.addWorkspace",descriptionKey:"settings.integrations.linear.description",keywords:["linear","workspace","add","connect","oauth"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear.mapping",page:"integrations",titleKey:"settings.integrations.linear.mapping.defaultProject",descriptionKey:"settings.integrations.linear.mapping.defaultProject.info",keywords:["linear","project","team","map","workspace","directory"],isAvailable:t=>!t.isVSCode},{id:"integrations.third-party",page:"integrations",titleKey:"settings.integrations.thirdParty.title",descriptionKey:"settings.integrations.thirdParty.info",keywords:["plugin","provider","install","update","remove","subscription"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"integrations.third-party.opencode-claude",page:"integrations",titleKey:"settings.integrations.thirdParty.opencodeClaude.name",descriptionKey:"settings.integrations.thirdParty.opencodeClaude.description",keywords:["claude","anthropic","claude code","pro","max","agent sdk","@openchamber/opencode-claude"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"integrations.extensions",page:"integrations",titleKey:"settings.integrations.extensionCatalog.title",descriptionKey:"settings.integrations.extensionCatalog.info",keywords:["extension","install","update","remove","openchamber"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"integrations.extensions.excalidraw",page:"integrations",titleKey:"settings.integrations.extensionCatalog.excalidraw.name",descriptionKey:"settings.integrations.extensionCatalog.excalidraw.description",keywords:["excalidraw","drawing","diagram","canvas","whiteboard","obsidian","sketch"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"integrations.extensions.resource-monitor",page:"integrations",titleKey:"settings.integrations.extensionCatalog.resourceMonitor.name",descriptionKey:"settings.integrations.extensionCatalog.resourceMonitor.description",keywords:["resource","monitor","cpu","memory","ram","process","activity","task manager","dev server","port","performance"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"integrations.guests",page:"integrations",titleKey:"settings.integrations.guests.title",descriptionKey:"settings.integrations.guests.info",keywords:["guest","extension","oauth","clickup","gitlab","panel","connect"],isAvailable:t=>!t.isVSCode},{id:"extensions.add",page:"extensions",titleKey:"settings.extensions.add.label",descriptionKey:"settings.extensions.add.info",keywords:["folder","path","zip","git","url","install","guest","panel"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"extensions.gitIdentity",page:"extensions",titleKey:"settings.extensions.identity.title",descriptionKey:"settings.extensions.add.info",keywords:["ssh","key","identity","git","private","clone","extension"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"extensions.updates.check",page:"extensions",titleKey:"settings.extensions.updates.check",keywords:["update","upgrade","version","git","extension","guest","refresh"],isAvailable:t=>!t.isVSCode&&!t.isMobile}];function Id(t){return t.trim().toLocaleLowerCase()}function kN({query:t,runtimeCtx:e,visiblePageSlugs:a,t:n,getPageTitle:i}){const o=Id(t);if(!o)return[];const r=a?new Set(a):null,c=o.split(/\s+/).filter(Boolean);return jN.flatMap(u=>{if(r&&!r.has(u.page))return[];const d=Ga(u.page);if(!d||d.isAvailable&&!d.isAvailable(e)||u.isAvailable&&!u.isAvailable(e))return[];const l=n(u.titleKey),f=u.descriptionKey?n(u.descriptionKey):null,p=Id([l,f,i(u.page),...u.keywords??[]].filter(Boolean).join(" "));return c.every(g=>p.includes(g))?[{...u,title:l,description:f,pageTitle:i(u.page)}]:[]})}const wN=["session","models","panels","navigation","application"],SN=()=>{const t=De.c(34),{t:e}=Ee(),a=re(NN),n=re(CN),i=re(IN),o=re(PN),[r,c]=m.useState(null),[u,d]=m.useState(null);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{ou().then(T=>d(T?.combo??null)).catch(AN)},t[0]=l):l=t[0];const f=l;let p,g;t[1]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{f()},g=[f],t[1]=p,t[2]=g):(p=t[1],g=t[2]),m.useEffect(p,g);const[h,y]=m.useState(null);let b;t[3]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{iu().then(T=>y(T?.combo??null)).catch(TN)},t[3]=b):b=t[3];const x=b;let w,S;t[4]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{x()},S=[x],t[4]=w,t[5]=S):(w=t[4],S=t[5]),m.useEffect(w,S);let v;t[6]===Symbol.for("react.memo_cache_sentinel")?(v=Wo(),t[6]=v):v=t[6];const A=v,I=EN;let N;t[7]!==n||t[8]!==a?(N=(T,R,$)=>{const z={...a,[T]:R};n(T,R),$==="mini_chat_global"?Or(null).then(Q=>{Q&&d(Q.combo)}):$==="quake_mode_global"?Rr(_n).then(Q=>{Q&&y(Q.combo)}):$&&(z[$]=_n,n($,_n)),I(z)},t[7]=n,t[8]=a,t[9]=N):N=t[9];const k=N;let P;t[10]!==i||t[11]!==a?(P=T=>{const R={...a};delete R[T],i(T),I(R)},t[10]=i,t[11]=a,t[12]=P):P=t[12];const j=P;let C;t[13]!==a||t[14]!==e?(C=T=>{const R="prefixStyle"in T&&T.prefixStyle,$=R?dg(T.id,a):Jd(T.id,a),z=Hn($,e("settings.openchamber.keyboardShortcuts.unassigned"));if(!R||!$||$===_n)return z;const Q=T.id==="switch_session_tab"?e("settings.openchamber.keyboardShortcuts.action.switch_session_tab.suffix"):e("settings.openchamber.keyboardShortcuts.action.switch_context_surface.suffix");return`${z}${Q}`},t[13]=a,t[14]=e,t[15]=C):C=t[15];const E=C;let F;t[16]!==u||t[17]!==h||t[18]!==a?(F={...a},u&&(F.mini_chat_global=u),h&&(F.quake_mode_global=h),t[16]=u,t[17]=h,t[18]=a,t[19]=F):F=t[19];let O;t[20]!==o||t[21]!==j||t[22]!==E||t[23]!==a||t[24]!==e?(O=wN.map((T,R)=>{const $=A.filter(z=>z.category===T);return $.length===0?null:s.jsx($e,{settingsItem:R===0?"shortcuts.keyboard-shortcuts":void 0,title:e(`settings.openchamber.keyboardShortcuts.category.${T}`),divider:R!==0,info:R===0?e("settings.openchamber.keyboardShortcuts.tooltip"):void 0,headerAction:R===0?s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{o(),I({})},children:e("settings.openchamber.keyboardShortcuts.actions.resetAll")}):void 0,children:s.jsx("div",{children:$.map(z=>s.jsxs(st,{label:e(z.settingsLabelKey),settingsItem:lm(z.id),children:[s.jsx("kbd",{className:"min-w-32 oc-tile-inset rounded-md px-2 py-1 text-center typography-meta text-foreground",children:E(z)}),s.jsx(H,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",onClick:()=>{f(),x(),c(z)},children:e("settings.openchamber.keyboardShortcuts.actions.edit")}),z.id in a?s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>j(z.id),children:e("settings.common.actions.reset")}):null]},z.id))})},T)}),t[20]=o,t[21]=j,t[22]=E,t[23]=a,t[24]=e,t[25]=O):O=t[25];let K;t[26]===Symbol.for("react.memo_cache_sentinel")?(K=T=>{T||c(null)},t[26]=K):K=t[26];let D;t[27]!==r||t[28]!==F||t[29]!==k?(D=s.jsx(Cl,{action:r,overrides:F,onSave:k,onOpenChange:K}),t[27]=r,t[28]=F,t[29]=k,t[30]=D):D=t[30];let M;return t[31]!==O||t[32]!==D?(M=s.jsxs(s.Fragment,{children:[O,D]}),t[31]=O,t[32]=D,t[33]=M):M=t[33],M};function NN(t){return t.shortcutOverrides}function CN(t){return t.setShortcutOverride}function IN(t){return t.clearShortcutOverride}function PN(t){return t.resetAllShortcutOverrides}function AN(){}function TN(){}function EN(t){jt({shortcutOverrides:t})}const cm=()=>{const t=De.c(2),[e,a]=m.useState(0);let n,i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>Go(()=>a(BN)),i=[],t[0]=n,t[1]=i):(n=t[0],i=t[1]),m.useEffect(n,i),e},MN=t=>{const e=De.c(68),{section:a}=t,{t:n}=Ee(),i=cm();let o;e[0]!==i||e[1]!==a?(o=()=>{switch(a){case"general":return s.jsx(RN,{});case"visual":return s.jsx(ON,{});case"chat":return s.jsx(FN,{});case"sessions":return s.jsx(LN,{runtimeEndpointEpoch:i});case"shortcuts":return s.jsx(DN,{});case"git":return s.jsx(KN,{});case"notifications":return s.jsx(_N,{});case"voice":return s.jsx($N,{});case"tunnel":return s.jsx(UN,{});case"spaces":return s.jsx(zN,{});default:return null}},e[0]=i,e[1]=a,e[2]=o):o=e[2];const r=o;let c;e[3]!==n?(c=n("settings.page.general.title"),e[3]=n,e[4]=c):c=e[4];let u;e[5]!==n?(u=n("settings.page.appearance.title"),e[5]=n,e[6]=u):u=e[6];let d;e[7]!==n?(d=n("settings.page.chat.title"),e[7]=n,e[8]=d):d=e[8];let l;e[9]!==n?(l=n("settings.page.sessions.title"),e[9]=n,e[10]=l):l=e[10];let f;e[11]!==n?(f=n("settings.page.shortcuts.title"),e[11]=n,e[12]=f):f=e[12];let p;e[13]!==n?(p=n("settings.page.git.title"),e[13]=n,e[14]=p):p=e[14];let g;e[15]!==n?(g=n("settings.page.git.title"),e[15]=n,e[16]=g):g=e[16];let h;e[17]!==n?(h=n("settings.page.notifications.title"),e[17]=n,e[18]=h):h=e[18];let y;e[19]!==n?(y=n("settings.page.voice.title"),e[19]=n,e[20]=y):y=e[20];let b;e[21]!==n?(b=n("settings.page.tunnel.title"),e[21]=n,e[22]=b):b=e[22];let x;e[23]!==n?(x=n("settings.openchamber.spaces.title"),e[23]=n,e[24]=x):x=e[24];let w;e[25]!==y||e[26]!==b||e[27]!==x||e[28]!==c||e[29]!==u||e[30]!==d||e[31]!==l||e[32]!==f||e[33]!==p||e[34]!==g||e[35]!==h?(w={general:c,visual:u,chat:d,sessions:l,shortcuts:f,git:p,github:g,notifications:h,voice:y,tunnel:b,spaces:x},e[25]=y,e[26]=b,e[27]=x,e[28]=c,e[29]=u,e[30]=d,e[31]=l,e[32]=f,e[33]=p,e[34]=g,e[35]=h,e[36]=w):w=e[36];const S=w[a];let v;e[37]!==n?(v=n("settings.page.general.description"),e[37]=n,e[38]=v):v=e[38];let A;e[39]!==n?(A=n("settings.page.appearance.description"),e[39]=n,e[40]=A):A=e[40];let I;e[41]!==n?(I=n("settings.page.chat.description"),e[41]=n,e[42]=I):I=e[42];let N;e[43]!==n?(N=n("settings.page.sessions.description"),e[43]=n,e[44]=N):N=e[44];let k;e[45]!==n?(k=n("settings.page.shortcuts.description"),e[45]=n,e[46]=k):k=e[46];let P;e[47]!==n?(P=n("settings.page.notifications.description"),e[47]=n,e[48]=P):P=e[48];let j;e[49]!==n?(j=n("settings.page.voice.description"),e[49]=n,e[50]=j):j=e[50];let C;e[51]!==n?(C=n("settings.page.tunnel.description"),e[51]=n,e[52]=C):C=e[52];let E;e[53]!==v||e[54]!==A||e[55]!==I||e[56]!==N||e[57]!==k||e[58]!==P||e[59]!==j||e[60]!==C?(E={general:v,visual:A,chat:I,sessions:N,shortcuts:k,git:void 0,github:void 0,notifications:P,voice:j,tunnel:C,spaces:void 0},e[53]=v,e[54]=A,e[55]=I,e[56]=N,e[57]=k,e[58]=P,e[59]=j,e[60]=C,e[61]=E):E=e[61];const F=E[a];let O;e[62]!==r?(O=r(),e[62]=r,e[63]=O):O=e[63];let K;return e[64]!==F||e[65]!==S||e[66]!==O?(K=s.jsx(qt,{title:S,description:F,showSaveStatus:!0,className:"openchamber-page-body",children:O}),e[64]=F,e[65]=S,e[66]=O,e[67]=K):K=e[67],K},DN=()=>{const t=De.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(SN,{}),t[0]=e):e=t[0],e},RN=()=>{const t=De.c(15);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=os(),t[0]=e):e=t[0];const a=e,n=cm();let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=is()&&ri(),t[1]=i):i=t[1];const o=i;let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=Di()&&!is()&&!a&&!Qd(),t[2]=r):r=t[2];const c=r;let u,d,l,f,p,g;t[3]===Symbol.for("react.memo_cache_sentinel")?(u=o&&s.jsx(L3,{}),d=s.jsx(KS,{firstSection:!o}),l=o&&s.jsx(x3,{}),f=c&&s.jsx(Ik,{}),p=s.jsx(Pk,{}),g=!a&&s.jsx(dw,{}),t[3]=u,t[4]=d,t[5]=l,t[6]=f,t[7]=p,t[8]=g):(u=t[3],d=t[4],l=t[5],f=t[6],p=t[7],g=t[8]);let h;t[9]!==n?(h=!a&&s.jsx(uw,{},n),t[9]=n,t[10]=h):h=t[10];let y,b;t[11]===Symbol.for("react.memo_cache_sentinel")?(y=!a&&s.jsx(Gw,{}),b=s.jsx(_S,{}),t[11]=y,t[12]=b):(y=t[11],b=t[12]);let x;return t[13]!==h?(x=s.jsxs(s.Fragment,{children:[u,d,l,f,p,g,h,y,b]}),t[13]=h,t[14]=x):x=t[14],x},ON=()=>{const t=De.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=os(),t[0]=e):e=t[0];const a=e;let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(rk,{visibleSettings:["theme","windowControlsPosition","pwaInstallName","pwaOrientation","mobileKeyboardMode","timeFormat",...a?[]:["weekStart"],"fontSize","terminalFontSize","editorFontSize","spacing","scrollbars","inputBarOffset","animatedActivityIndicators"]}),t[1]=n):n=t[1],n},FN=()=>{const t=De.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(d0,{}),t[0]=e):e=t[0],e},LN=t=>{const e=De.c(7),{runtimeEndpointEpoch:a}=t;let n;e[0]!==a?(n=s.jsx(zk,{},a),e[0]=a,e[1]=n):n=e[1];let i,o,r;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(kk,{}),o=s.jsx(uk,{}),r=!os()&&s.jsx(vk,{}),e[2]=i,e[3]=o,e[4]=r):(i=e[2],o=e[3],r=e[4]);let c;return e[5]!==n?(c=s.jsxs(s.Fragment,{children:[n,i,o,r]}),e[5]=n,e[6]=c):c=e[6],c},KN=()=>{const t=De.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(_u,{}),t[0]=e):e=t[0],e},_N=()=>{const t=De.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Bk,{}),t[0]=e):e=t[0],e},$N=()=>{const t=De.c(1);if(os())return null;let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Zk,{}),t[0]=e):e=t[0],e},zN=()=>{const t=De.c(1);if(os())return null;let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Bw,{}),t[0]=e):e=t[0],e},UN=()=>{const t=De.c(1);if(os())return null;let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(cw,{}),t[0]=e):e=t[0],e};function BN(t){return t+1}const Pd=280,VN=32,dm="__openchamberSettingsDetail",Ad=t=>{const e=kh(t);e&&zr.getState().setTab(e)},HN=30,qN=["general","appearance","chat","notifications","sessions","routing","shortcuts","voice","integrations","extensions","usage","about","projects","remote-instances","tunnel","git","isolated-spaces","providers","web-search","agents","behavior","commands","mcp","plugins","magic-prompts","snippets","skills.installed","skills.catalog"],WN=["general","projects","opencode","content"];function GN(t,e,a,n,i){const o=os(),r=!t&&Di();return{isVSCode:o,isWeb:r,isDesktop:t,isMobile:e,routingAvailable:a,enterpriseMode:n,jevBlockedByEnterprise:i}}function Td(t,e){return t.isAvailable?t.isAvailable(e):!0}function Ni(t,e){const a=new Set(e);let n=t,i=1;for(;a.has(n);)n=`${t}-${i}`,i+=1;return n}function Er(t){const e=t?.[dm];return e?.page==null||e.stage!=="page-content"?null:{page:Fr(e.page),stage:e.stage}}function JN(){return window.history.state??{}}const hC=({onClose:t,forceMobile:e,isWindowed:a,visiblePageSlugs:n,initialMobileStage:i="nav",registerBackHandler:o})=>{const{t:r}=Ee(),c=Zs(),u=e??c.isMobile,d=re(ce=>ce.settingsPage),l=re(ce=>ce.isSettingsDialogOpen),f=re(ce=>ce.setSettingsPage),p=re(ce=>ce.shortcutOverrides.open_settings),g=Fr(d),[h,y]=m.useState(i),b=m.useRef(i==="nav"?g:null);m.useEffect(()=>{!u&&g==="home"&&f("general")},[u,f,g]);const[x,w]=m.useState(""),[S,v]=m.useState(null),[A,I]=m.useState(0),N=m.useRef(null),k=m.useRef(!1),P=m.useRef([]),j=m.useRef(0),C=m.useRef(!1),E=m.useMemo(()=>is(),[]),F=m.useMemo(()=>is()&&ri(),[]),O=m.useMemo(()=>is()&&window.__OPENCHAMBER_PLATFORM__==="darwin",[]),K=m.useMemo(()=>is()&&window.__OPENCHAMBER_PLATFORM__==="win32",[]),D=m.useMemo(()=>is()&&window.__OPENCHAMBER_PLATFORM__==="linux",[]),M=re(ce=>ce.routingFeatureAvailable),T=Pn(),R=ug(),$=m.useMemo(()=>GN(E,u,M,T,R),[E,u,M,T,R]),z=m.useMemo(()=>{const ce=n?new Set(n):null;return Tf.filter(je=>je.slug!=="home").filter(je=>!ce||ce.has(je.slug)).filter(je=>Td(je,$)).filter(je=>!($.isVSCode&&je.slug==="projects")).filter(je=>!(u&&je.slug==="shortcuts"))},[$,u,n]),Q=m.useMemo(()=>{const ce=new Map(qN.map((je,de)=>[je,de]));return z.slice().sort((je,de)=>(ce.get(je.slug)??999)-(ce.get(de.slug)??999))},[z]),V=on(ce=>ce.activeProjectId),L=Hs();m.useEffect(()=>{if(!(!l&&!$.isVSCode&&!a)){if(g==="agents"){Cn.getState().loadAgents(L);return}if(g==="commands"){ti.getState().loadCommands(L);return}if(g==="mcp"){$n.getState().loadMcpConfigs({directory:L});return}if(g==="plugins"){Lt.getState().loadPlugins();return}(g==="skills.installed"||g==="skills.catalog")&&(Js.getState().loadSkills(L),Nn.getState().loadCatalog()),g==="snippets"&&Ao.getState().loadSnippets()}},[V,l,a,$.isVSCode,L,g]);const B=m.useCallback(ce=>{if(f(ce),b.current=ce,!u)return;const je=Ga(ce);if(!je||je.slug==="home"){y("nav");return}y(je.kind==="split"?"page-sidebar":"page-content")},[u,f]),W=m.useMemo(()=>Ga(g),[g]),Y=m.useMemo(()=>({general:"general",appearance:"visual",chat:"chat",shortcuts:"shortcuts",sessions:"sessions",notifications:"notifications",voice:"voice",tunnel:"tunnel","isolated-spaces":"spaces"}),[]),ae=m.useCallback(ce=>{switch(ce){case"general":return r("settings.page.general.title");case"projects":return r("settings.page.projects.title");case"remote-instances":return r("settings.page.remoteInstances.title");case"providers":return r("settings.page.providers.title");case"web-search":return r("settings.page.webSearch.title");case"usage":return r("settings.page.usage.title");case"agents":return r("settings.page.agents.title");case"behavior":return r("settings.page.behavior.title");case"commands":return r("settings.page.commands.title");case"mcp":return r("settings.page.mcp.title");case"plugins":return r("settings.page.plugins.title");case"skills.installed":return r("settings.page.skills.title");case"skills.catalog":return r("settings.page.skillsCatalog.title");case"git":return r("settings.page.git.title");case"integrations":return r("settings.page.integrations.title");case"extensions":return r("settings.page.extensions.title");case"appearance":return r("settings.page.appearance.title");case"chat":return r("settings.page.chat.title");case"shortcuts":return r("settings.page.shortcuts.title");case"sessions":return r("settings.page.sessions.title");case"routing":return r("settings.page.routing.title");case"magic-prompts":return r("settings.page.magicPrompts.title");case"snippets":return r("settings.page.snippets.title");case"notifications":return r("settings.page.notifications.title");case"voice":return r("settings.page.voice.title");case"tunnel":return r("settings.page.tunnel.title");case"isolated-spaces":return r("settings.openchamber.spaces.title");case"about":return r("settings.page.about.title");default:return r("settings.view.home.title")}},[r]),ee=m.useMemo(()=>kN({query:x,runtimeCtx:{...$,isDesktopLocalOrigin:F,isMac:O,isWindows:K,isLinux:D},visiblePageSlugs:n,t:r,getPageTitle:ae}),[ae,F,O,K,D,$,x,r,n]),G=m.useCallback(ce=>{if(ce.id.startsWith("agents.")){const de=Cn.getState(),ie=Ni("new-agent",de.agents.map(xe=>xe.name));return de.setAgentDraft({name:ie,scope:"user"}),de.setSelectedAgent(ie),ce.id==="agents.create"?"agents.name":ce.id}if(ce.id.startsWith("commands.")){const de=ti.getState(),ie=Ni("new-command",de.commands.map(xe=>xe.name));return de.setCommandDraft({name:ie,scope:"user"}),de.setSelectedCommand(ie),ce.id==="commands.create"?"commands.name":ce.id}if(ce.id.startsWith("mcp.")){const de=$n.getState(),ie=Ni("new-mcp-server",de.mcpServers.map(xe=>xe.name));return de.setMcpDraft({name:ie,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),de.setSelectedMcp(ie),ce.id==="mcp.create"?"mcp.server":ce.id}if(ce.id.startsWith("snippets.")){const de=Ao.getState(),ie=Ni("new-snippet",de.snippets.map(xe=>xe.name));return de.setSnippetDraft({name:ie,scope:"global"}),de.setSelectedSnippet(ie),ce.id==="snippets.create"?"snippets.content":ce.id}if(ce.id.startsWith("skills.")){const de=Js.getState(),ie=Ni("new-skill",de.skills.map(xe=>xe.name));return de.setSkillDraft({name:ie,scope:"user",source:"opencode",description:"",instructions:""}),de.setSelectedSkill(ie),ce.id==="skills.create"?"skills.basic-information":ce.id}if(ce.id==="providers.connect"&&re.getState().setSettingsProvidersConnectRequested(!0),ce.id==="providers.classification"&&re.getState().setSettingsProvidersClassificationRequested(!0),ce.id==="plugins.create")return"plugins.spec";if(ce.id==="extensions.gitIdentity")return"extensions.add";const je=yh(ce.id);return je&&$r.getState().setTab(je),Ad(ce.id),ce.id},[]),le=m.useMemo(()=>{const ce=[],je=new Map;for(const de of ee){let ie=je.get(de.page);ie||(ie={page:de.page,pageTitle:de.pageTitle,results:[]},je.set(de.page,ie),ce.push(ie)),ie.results.push(de)}return ce},[ee]);m.useEffect(()=>{I(0),j.current=0,C.current=!1},[x]),m.useEffect(()=>{j.current=A},[A]),m.useEffect(()=>{P.current[A]?.scrollIntoView({block:"nearest"})},[A]),m.useEffect(()=>{A>=ee.length&&I(Math.max(0,ee.length-1)),P.current.length=ee.length},[A,ee.length]);const J=m.useCallback(ce=>{const je=G(ce);v(je),B(ce.page),u&&y("page-content"),ce.id==="plugins.create"&&window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("openchamber:settings-open-plugin-add"))},50)},[u,B,G]),me=m.useCallback(ce=>{if(x.trim()){if(ce.key==="Escape"){ce.preventDefault(),w("");return}if(ee.length!==0){if(ce.key==="ArrowDown"){ce.preventDefault(),C.current=!0,I(je=>(je+1)%ee.length);return}if(ce.key==="ArrowUp"){ce.preventDefault(),C.current=!0,I(je=>(je-1+ee.length)%ee.length);return}if(ce.key==="Enter"){ce.preventDefault();const je=(j.current%ee.length+ee.length)%ee.length,de=ee[je]??ee[0];de&&J(de)}}}},[J,x,ee]),fe=re(ce=>ce.settingsJumpRequest);m.useEffect(()=>{fe&&(re.getState().clearSettingsJumpRequest(),fe.itemId&&Ad(fe.itemId),v(fe.itemId),B(Fr(fe.page)),u&&y("page-content"))},[u,B,fe]),m.useEffect(()=>{const ce=S;if(!ce)return;let je=!1,de=0,ie=0;const xe=()=>{if(je)return;const Se=globalThis.CSS?.escape?globalThis.CSS.escape(ce):ce.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Le=N.current?.querySelector(`[data-settings-item="${Se}"]`);if(!Le){de+=1,de<HN&&(ie=window.requestAnimationFrame(xe));return}v(null),Le.scrollIntoView({block:"center",behavior:"smooth"}),Le.setAttribute("data-settings-search-highlight","true"),window.setTimeout(()=>{Le.removeAttribute("data-settings-search-highlight")},1600)};return ie=window.requestAnimationFrame(xe),()=>{je=!0,window.cancelAnimationFrame(ie)}},[S,g]);const oe=m.useCallback(()=>s.jsx("div",{className:"flex h-full items-center justify-center px-6",children:s.jsxs("div",{className:"max-w-md text-center",children:[s.jsx("div",{className:Wn,children:r("settings.view.unavailable.title")}),s.jsx("p",{className:"typography-ui text-muted-foreground mt-1",children:r("settings.view.unavailable.description")})]})}),[r]),pe=m.useCallback((ce,je)=>{switch(ce){case"projects":return s.jsx(_v,{onItemSelect:je.onItemSelect});case"agents":return s.jsx(Ph,{onItemSelect:je.onItemSelect});case"commands":return s.jsx(kb,{onItemSelect:je.onItemSelect});case"skills.installed":return s.jsx(Jx,{onItemSelect:je.onItemSelect});case"usage":return s.jsx(Fy,{onItemSelect:je.onItemSelect});case"magic-prompts":return s.jsx(a2,{onItemSelect:je.onItemSelect});case"snippets":return s.jsx(l2,{onItemSelect:je.onItemSelect});default:return null}},[]),se=m.useCallback(ce=>{const je=Ga(ce);if(je&&!Td(je,$))return oe();switch(ce){case"projects":return s.jsx(Vv,{});case"remote-instances":return s.jsx(j1,{});case"agents":return s.jsx(Zh,{});case"behavior":return s.jsx(ab,{});case"commands":return s.jsx(Ab,{});case"mcp":return s.jsx(Xb,{});case"plugins":return s.jsx(Ex,{});case"skills.installed":return s.jsx(vc,{view:"installed"});case"skills.catalog":return s.jsx(vc,{view:"catalog"});case"providers":return s.jsx(Ry,{});case"web-search":return s.jsx(ub,{});case"usage":return s.jsx(s2,{});case"about":return s.jsx(qt,{title:r("settings.page.about.title"),showSaveStatus:!1,children:s.jsx(gh,{})});case"magic-prompts":return s.jsx(r2,{});case"snippets":return s.jsx(m2,{});case"git":return s.jsx(x2,{});case"integrations":return s.jsx(uj,{});case"routing":return s.jsx(vj,{});case"extensions":return s.jsx(Dj,{});case"general":case"appearance":case"chat":case"shortcuts":case"sessions":case"notifications":case"voice":case"tunnel":case"isolated-spaces":{const de=Y[ce]??"visual";return s.jsx(MN,{section:de})}default:return null}},[Y,oe,$,r]);m.useEffect(()=>{if(!u||h!=="nav"||g==="home"||b.current===g)return;const ce=Ga(g);!ce||ce.slug==="home"||(b.current=g,y(ce.kind==="split"?"page-sidebar":"page-content"))},[u,h,g]);const ve=u&&h!=="nav",be=u&&h==="page-content"&&W?.kind==="split",ne=r(be?"settings.view.actions.back":ve?"settings.view.actions.backToSettings":"settings.view.actions.closeSettings"),we=Jd("open_settings",p===void 0?void 0:{open_settings:p}),Ne=we?r("settings.view.actions.closeSettingsWithShortcut",{shortcut:Hn(we)}):r("settings.view.actions.closeSettings"),Ie=m.useCallback(ce=>{if($.isVSCode)return;const je=Er(window.history.state);je?.page===ce&&je.stage==="page-content"||window.history.pushState({...JN(),[dm]:{page:ce,stage:"page-content"}},"",window.location.href)},[$.isVSCode]),Ce=m.useCallback(()=>{k.current=!0,y("page-content"),Ie(g)},[Ie,g]);m.useEffect(()=>{if(!u||h!=="page-content"||!k.current)return;k.current=!1;const ce=window.requestAnimationFrame(()=>{N.current?.querySelector("[data-settings-page-heading]")?.focus({preventScroll:!0})});return()=>{window.cancelAnimationFrame(ce)}},[u,h,g]);const Me=m.useCallback(()=>{if(be){if(Er(window.history.state)?.page===g&&!$.isVSCode){window.history.back();return}y("page-sidebar");return}y("nav")},[be,$.isVSCode,g]);m.useEffect(()=>{if(o)return o(()=>!u||h==="nav"?!1:(Me(),!0)),()=>o(null)},[Me,u,h,o]),m.useEffect(()=>{if(!u||$.isVSCode)return;const ce=je=>{if(Ga(g)?.kind!=="split")return;if(Er(je.state)?.page===g){y("page-content");return}y(ie=>ie==="page-content"?"page-sidebar":ie)};return window.addEventListener("popstate",ce),()=>{window.removeEventListener("popstate",ce)}},[u,$.isVSCode,g]);const he=()=>{const ce=x.trim().length>0;return s.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[s.jsx("div",{className:"px-4 pt-3",children:s.jsxs("div",{className:"oc-surface-elevated oc-raised oc-field flex h-10 items-center gap-1.5 rounded-md bg-surface-elevated/70 px-2 text-muted-foreground sm:h-8",children:[s.jsx(te,{name:"search",className:"h-4 w-4 shrink-0"}),s.jsx("input",{value:x,onChange:je=>w(je.target.value),onKeyDown:me,placeholder:r("settings.view.search.placeholder"),"aria-label":r("settings.view.search.aria"),"data-settings-search":"",className:"typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70"}),ce&&s.jsx("button",{type:"button",onClick:()=>w(""),"aria-label":r("settings.view.search.clear"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-interactive-hover hover:text-foreground sm:h-5 sm:w-5",children:s.jsx(te,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsx(Os,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx("div",{className:"flex flex-col gap-0.5 px-4 pt-4 pb-2",children:ce?ee.length>0?(()=>{let je=0;return le.map(de=>s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:"px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70",children:de.pageTitle}),de.results.map(ie=>{const xe=je;je+=1;const Se=xe===A,Le=!!ie.description;return s.jsxs("button",{type:"button",ref:Ue=>{P.current[xe]=Ue},onMouseMove:()=>{C.current=!1,I(xe)},onClick:()=>J(ie),className:ze("flex w-full flex-col rounded-md px-2 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Le?"min-h-11 py-1.5":"py-2",Se?"bg-interactive-selection":"hover:bg-interactive-hover"),children:[s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:ie.title}),Le&&s.jsx("span",{className:"typography-micro text-muted-foreground/70 line-clamp-2",children:ie.description})]},ie.id)})]},de.page))})():s.jsx("div",{className:"px-2 py-6 text-center typography-ui text-muted-foreground",children:r("settings.view.search.noResults")}):(()=>{const je=new Map;for(const ie of Q){const xe=ie.group,Se=je.get(xe);Se?Se.push(ie):je.set(xe,[ie])}return WN.map(ie=>({group:ie,pages:je.get(ie)??[]})).filter(ie=>ie.pages.length>0).map(({group:ie,pages:xe},Se)=>s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:ze("px-3 pb-1 typography-micro font-semibold uppercase tracking-wide text-muted-foreground sm:px-2 sm:pb-0.5",Se===0?"pt-1":"pt-4 sm:pt-3"),children:r(`settings.view.nav.group.${ie}`)}),xe.map(Le=>{const Ue=g===Le.slug&&!(u&&h==="nav"),Ye=Ef(Le.slug);return!Ye&&Le.slug!=="mcp"?null:s.jsx(mg,{children:s.jsx(pg,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>B(Le.slug),"aria-current":Ue?"page":void 0,className:ze("flex h-11 w-full items-center gap-2.5 rounded-md px-3 overflow-hidden sm:h-8 sm:gap-2 sm:px-2",Ue?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:[Le.slug==="mcp"?s.jsx(gg,{className:"h-[18px] w-[18px] shrink-0 sm:h-4 sm:w-4"}):s.jsx(te,{name:Ye,className:"h-[18px] w-[18px] shrink-0 sm:h-4 sm:w-4"}),s.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap overflow-hidden transition-opacity duration-150 opacity-100",children:[s.jsx("span",{className:"typography-ui-label font-normal truncate",children:ae(Le.slug)}),Le.slug==="tunnel"&&s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:r("settings.view.badge.beta")})]})]})})},Le.slug)})]},ie))})()})})]})},Pe=()=>{if(h==="nav")return s.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:s.jsx("div",{className:"flex h-full min-h-0 flex-col",children:s.jsx(Ia,{children:he()})})});if(!W)return s.jsx("div",{className:"flex-1 bg-background"});if(h==="page-sidebar"){if(W.kind!=="split"){const je=se(g);return s.jsx(Os,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Ia,{children:je})})}return s.jsx(Os,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Ia,{children:pe(g,{onItemSelect:Ce})})})}const ce=se(g);return s.jsx(Os,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Ia,{children:ce})})},Re=()=>{if(!W||g==="home")return null;const ce=t?VN:0,je=s.jsx(Mf.Provider,{value:ce,children:s.jsx(Ia,{children:se(g)})});return W.kind==="split"?s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[s.jsx("div",{className:ze("border-e",$.isVSCode?"bg-background":"bg-sidebar"),style:{width:Pd,minWidth:Pd,borderColor:"var(--interactive-border)"},children:s.jsx(Ia,{children:pe(g,{})})}),s.jsx(Os,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,verticalTrackStart:ce,children:je})]}):s.jsx(Os,{outerClassName:"h-full min-h-0",className:"bg-background",disableHorizontal:!0,verticalTrackStart:ce,children:je})};return s.jsxs("div",{ref:N,"data-settings-view":"true",className:ze("relative flex h-full min-h-0 flex-col overflow-hidden bg-background"),children:[u?s.jsxs("div",{className:ze("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",h!=="nav"&&"border-b","bg-background"),style:h!=="nav"?{borderColor:"var(--interactive-border)"}:void 0,children:[ve?s.jsx("button",{type:"button",onClick:Me,"aria-label":ne,className:"inline-flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(te,{name:"arrow-left-s",className:"h-5 w-5"})}):null,s.jsx("div",{className:"min-w-0 flex-1 px-2 typography-ui-label font-medium text-foreground truncate",children:h==="nav"?r("settings.view.home.title"):W?ae(W.slug):r("settings.view.home.title")}),t&&s.jsx("button",{type:"button",onClick:t,"aria-label":r("settings.view.actions.closeSettings"),title:Ne,className:"inline-flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(te,{name:"close",className:"h-5 w-5"})})]}):s.jsxs(s.Fragment,{children:[ve&&s.jsx("div",{className:ze("absolute inset-s-3 z-50",a?"top-2":"top-3"),children:s.jsx("button",{type:"button",onClick:Me,"aria-label":r("settings.view.actions.back"),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(te,{name:"arrow-left-s",className:"h-5 w-5"})})}),t&&s.jsx("div",{className:ze("absolute inset-e-0.5 z-50",a?"top-0.5":"top-1"),children:s.jsx("button",{type:"button",onClick:t,"aria-label":r("settings.view.actions.closeSettings"),title:Ne,className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(te,{name:"close",className:"h-5 w-5"})})})]}),s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:u?Pe():s.jsxs(s.Fragment,{children:[s.jsx("div",{className:ze("relative flex h-full min-h-0 w-36 min-w-36 flex-col overflow-hidden border-e sm:w-64 sm:min-w-64",E?"bg-sidebar":$.isVSCode?"bg-background":"bg-sidebar"),style:{borderColor:"var(--interactive-border)"},children:s.jsx(Ia,{children:he()})}),s.jsx("div",{className:"flex-1 overflow-hidden bg-background",children:Re()})]})})]})};export{gh as A,hC as S};
30
+ ${wr(o,e)}`:""]}):null,t[263]=o,t[264]=i,t[265]=e,t[266]=mn):mn=t[266];let en;t[267]!==x||t[268]!==a||t[269]!==ye||t[270]!==at||t[271]!==e||t[272]!==n||t[273]!==g?(en=g?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.extensions.unsupported")}):s.jsxs("div",{className:li,children:[s.jsx(Gi,{label:e("settings.extensions.grid.addTitle"),hint:e("settings.extensions.grid.addHint"),onClick:()=>F(!0),settingsItem:"extensions.add"}),a.map(rt=>s.jsx(Aj,{guest:rt,onOpen:()=>K(rt.id),...ye},rt.id)),n.map((rt,gt)=>s.jsx(Mj,{guest:rt,busy:x,onRemove:at},rt.id??`unreadable-${gt}`))]}),t[267]=x,t[268]=a,t[269]=ye,t[270]=at,t[271]=e,t[272]=n,t[273]=g,t[274]=en):en=t[274];let yn;t[275]!==vn||t[276]!==i||t[277]!==e||t[278]!==g?(yn=i==="ready"&&!vn&&!g?s.jsx("p",{className:"pt-4 typography-meta text-muted-foreground",children:e("settings.extensions.empty")}):null,t[275]=vn,t[276]=i,t[277]=e,t[278]=g,t[279]=yn):yn=t[279];let la;t[280]!==un||t[281]!==ra||t[282]!==mn||t[283]!==en||t[284]!==yn?(la=s.jsxs("div",{className:"relative",...un,children:[ra,mn,en,yn]}),t[280]=un,t[281]=ra,t[282]=mn,t[283]=en,t[284]=yn,t[285]=la):la=t[285];let ns;t[286]!==la||t[287]!==Na||t[288]!==Ms||t[289]!==oa?(ns=s.jsx(qt,{title:Na,description:Ms,headerEnd:oa,children:la}),t[286]=la,t[287]=Na,t[288]=Ms,t[289]=oa,t[290]=ns):ns=t[290];let Ba;return t[291]!==ia||t[292]!==ns?(Ba=s.jsxs(s.Fragment,{children:[ns,ia]}),t[291]=ia,t[292]=ns,t[293]=Ba):Ba=t[293],Ba};function Rj(t){return t.guests}function Oj(t){return t.unreadable}function Fj(t){return t.status}function Lj(t){return t.failure}function Kj(t){return t.runtimeKey}function _j(){nn()}function $j(t){return t.id!=="global"}const zj={dark:.16,light:.06};function Uj(t,e,a=!1){if(a)return;const{surface:n,primary:i,status:o,interactive:r,markdown:c,chat:u,tools:d,syntax:l}=t.colors,f=t.metadata.variant==="dark",p=n.background,g=Vs(p,p),h=(C,E)=>jo(C,E,p)??1,y=(C,E,F)=>{if(F(C))return C;let O=0,K=1,D=E;for(let M=0;M<16;M++){const T=(O+K)/2,R=As(E,C,T,p);F(R)?(K=T,D=R):O=T}return D},b=C=>h(C,"#000000"),x=Math.min(4.6,h(g,p)),w=(C,E)=>{const F=E?"#ffffff":"#000000",K=(E?b(C)>b(p):b(C)<b(p))?As(C,p,1,p):p,D=y(K,p,T=>h(T,p)<=1.1),M=h(F,p)<1.04?F:y(D,F,T=>h(T,p)>=1.04);return y(M,p,T=>h(g,T)>=x)};n.muted=w(n.muted,!1),n.elevated=w(n.elevated,f),n.subtle=As(g,p,.025,p);const S=[p,n.muted,n.elevated],v=C=>Math.min(...S.map(E=>h(C,E))),A=C=>y(C,g,E=>v(E)>=4.6),I=(C,E,F=4.6)=>y(y(C,p,O=>h(O,p)<=E),g,O=>v(O)>=F);n.foreground=I(n.foreground,f?13.6:9,7),n.mutedForeground=I(n.mutedForeground,Math.min(6,h(n.foreground,p)*.7)),n.elevatedForeground=I(n.elevatedForeground,f?13.6:9,7);const N=[e["button.background"],e["textLink.foreground"],e["activityBarBadge.background"],e["list.highlightForeground"],e.focusBorder];i.base=A(N.find(C=>C!==void 0&&v(C)>=3)??i.base),i.foreground=Vs(i.base,p),i.hover=As(g,i.base,.08,p),i.active=As(g,i.base,.16,p),i.muted=Ta(i.base,.5),v(r.focusRing)<1.1&&(r.focus=i.base,r.focusRing=i.base,r.borderFocus=i.base),r.selection=y(r.selection,As(i.base,p,.18,p),C=>v(C)>=1.1);const k=f?{border:[1.217,1.245,1.117],hover:[2.304,2.356,2.115],tools:[1.199,1.207,1.156],divider:[1.41,1.442,1.294]}:{border:[1.268,1.203,1.162],hover:[1.64,1.557,1.503],tools:[1.231,1.195,1.171],divider:[1.427,1.355,1.308]},P=(C,[E,F,O])=>{const K=Math.max(E,F,O),D=z=>z+(K-z)*.2,M=z=>h(z,p)<=D(E)&&h(z,n.muted)<=D(F)&&h(z,n.elevated)<=D(O);if(M(C))return C;let T=0,R=1,$=Ta(C,0);for(let z=0;z<16;z++){const Q=(T+R)/2,V=Ta(C,Q);M(V)?(T=Q,$=V):R=Q}return $};r.border=P(r.border,k.border),r.borderHover=P(r.borderHover,k.hover),r.hover=P(r.hover,[1.18,1.18,1.18]),r.active=P(r.active,[1.25,1.25,1.25]),r.selection=P(r.selection,[1.6,1.7,1.45]),r.selectionForeground=Kn(n.foreground,r.selection,p);const j=(C,E,F,O)=>{const K=Np(C,p);return A(K!==null&&K>=F&&K<=O?C:E)};o.error=j(o.error,f?"#e07777":"#b43b45",0,35),o.warning=j(o.warning,f?"#d6b467":"#916b17",35,100),o.success=j(o.success,f?"#80b888":"#357b47",105,170),o.info=j(o.info,f?"#83afe0":"#366eaa",185,275);for(const C of["error","warning","success","info"])o[`${C}Foreground`]=Vs(o[C],p),o[`${C}Background`]=Ta(o[C],f?.16:.12),o[`${C}Border`]=Ta(o[C],f?.45:.35);if(t.colors.pr={open:o.success,closed:o.error,draft:n.mutedForeground,blocked:j(e["terminal.ansiYellow"]??"",f?"#d99464":"#a65b25",40,65),merged:j(e["terminal.ansiMagenta"]??"",f?"#b79bd9":"#8255b0",285,325)},u){let C=y(p,g,E=>h(E,p)>=1.12);h(g,C)<x&&(C=y(p,g==="#ffffff"?"#000000":"#ffffff",E=>h(E,p)>=1.12)),u.userMessageBackground=y(Ol(i.base,C,zj[f?"dark":"light"],p),C,E=>h(E,p)>=1.1&&h(g,E)>=x),S.push(u.userMessageBackground),n.foreground=y(n.foreground,g,E=>v(E)>=7),n.mutedForeground=A(n.mutedForeground),u.userMessage=Kn(n.foreground,u.userMessageBackground,p),u.assistantMessage=n.foreground,u.timestamp=n.mutedForeground,u.typing=n.mutedForeground,u.avatarForeground=e["chat.avatarForeground"]??n.foreground,u.slashCommandBackground=e["chat.slashCommandBackground"]??i.base,u.slashCommandForeground=e["chat.slashCommandForeground"]??Vs(u.slashCommandBackground,p),u.inputWorkingBorderColor1=e["chat.inputWorkingBorderColor1"]??i.base,u.inputWorkingBorderColor2=e["chat.inputWorkingBorderColor2"]??i.hover,u.inputWorkingBorderColor3=e["chat.inputWorkingBorderColor3"]??i.muted,u.divider=P(u.divider??r.border,k.divider)}t.colors.pr&&(t.colors.pr.draft=n.mutedForeground),d&&(d.border=P(d.border??r.border,k.tools),d.title=n.foreground,d.description=n.mutedForeground,d.icon=n.mutedForeground),c&&(c.bold=As(g,n.foreground,.12,p),c.italic=n.foreground,c.blockquote=n.mutedForeground,c.blockquoteBorder=P(c.blockquoteBorder??r.border,k.divider),c.hr=P(c.hr??r.border,k.divider),c.link=A(e["textLink.foreground"]??i.base),c.linkHover=A(e["textLink.activeForeground"]??i.hover),c.listMarker=Ta(i.base,.6),c.inlineCodeBackground=n.subtle,c.inlineCode=Kn(A(e["textPreformat.foreground"]??i.base),n.subtle,p)),l.base.background=y(Ol(p,l.base.background,1,p),p,C=>h(C,p)<=1.1),l.base.foreground=Kn(n.foreground,l.base.background,p)}const Bs=Ta,Bj=t=>{const e={...t,colors:{...t.colors}},a=e.kind==="dark"||e.kind==="high-contrast",n=Cp(a),i=e.colors,o=i["chat.list.background"]??i["editor.background"]??n.colors.surface.background,r=i["interactive-session.foreground"]??i.foreground??i["editor.foreground"]??Vs(o,o);i.foreground??=r,i["sideBar.background"]??=i["panel.background"]??As(r,o,.03,o),!i["editorWidget.background"]&&!i["dropdown.background"]&&!i["input.background"]&&(i["editorWidget.background"]=As(r,o,.04,o),i["editorWidget.foreground"]=Kn(r,i["editorWidget.background"],o)),i.descriptionForeground??=Kn(As(r,o,.6,o),o),i["widget.border"]??=i["input.border"]??i["panel.border"]??As(r,o,.15,o),i["toolbar.hoverBackground"]??=i["list.hoverBackground"]??As(r,o,.08,o),i["toolbar.activeBackground"]??=As(r,o,.12,o),!i["list.activeSelectionBackground"]&&!i["menu.selectionBackground"]&&!i["editor.selectionBackground"]&&(i["list.activeSelectionBackground"]=As(r,o,.16,o),i["list.activeSelectionForeground"]=Kn(r,i["list.activeSelectionBackground"],o)),i["button.background"]||(i["button.background"]=i["textLink.foreground"]??i.focusBorder??r,i["button.foreground"]=Vs(i["button.background"],o)),i.focusBorder??=i["button.background"],i["editorCursor.foreground"]??=i["editor.foreground"]??r;const c=(Ce,Me)=>e.colors[Ce]??Me,u=Ce=>Ce!=="transparent"&&(jo(Ce,"#000000")!==1||jo(Ce,"#ffffff")!==1),d=(Ce,Me)=>{const he=c(Ce,Me);return u(he)?he:Me},l=c("chat.list.background",c("editor.background",n.colors.surface.background)),f=c("interactive-session.foreground",c("foreground",c("editor.foreground",n.colors.surface.foreground))),g=[["editorWidget.background","editorWidget.foreground"],["dropdown.background","dropdown.foreground"],["input.background","input.foreground"]].find(([Ce])=>e.colors[Ce]),h=g?c(g[0],n.colors.surface.elevated):n.colors.surface.elevated,y=Kn(f,h,l),b=g?c(g[1],y):y,x=c("sideBar.background",c("panel.background",n.colors.surface.muted)),w=c("descriptionForeground",c("input.placeholderForeground",n.colors.surface.mutedForeground)),S=c("textBlockQuote.background",x),v=n.colors.surface.overlay,A=c("button.background",c("textLink.foreground",n.colors.primary.base)),I=c("button.hoverBackground",A),N=e.colors["button.background"]?c("button.foreground",Vs(A,l)):Vs(A,l),k=Bs(A,.5),j=[e.kind==="high-contrast"||e.highContrast?c("contrastBorder",""):"",c("widget.border",""),c("input.border",""),c("panel.border",""),c("sideBar.border",""),c("editorWidget.border",""),c("contrastBorder","")].find(Ce=>Ce&&u(Ce))||Bs(f,a?.25:.2),C=c("toolbar.hoverBackground",c("list.hoverBackground",n.colors.interactive.hover)),E=c("toolbar.activeBackground",C),O=[["list.activeSelectionBackground","list.activeSelectionForeground"],["menu.selectionBackground","menu.selectionForeground"],["editor.selectionBackground","editor.selectionForeground"]].filter(([Ce])=>e.colors[Ce]),K=O.find(([Ce])=>[l,x,h].every(Me=>{const he=jo(c(Ce,""),Me,l);return he===null||he>1.01}))??O[0],D=K?c(K[0],n.colors.interactive.selection):n.colors.interactive.selection,M=K?c(K[1],f):f,T=c("focusBorder",c("inputOption.activeBorder",A)),R=T,$=c("editorCursor.foreground",n.colors.interactive.cursor),z=c("editorError.foreground",c("testing.iconFailed",n.colors.status.error)),Q=d("editorError.background",Bs(z,a?.16:.12)),V=c("problemsWarningIcon.foreground",c("notificationsWarningIcon.foreground",c("editorWarning.foreground",n.colors.status.warning))),L=d("editorWarning.background",Bs(V,a?.16:.12)),B=c("testing.iconPassed",c("gitDecoration.addedResourceForeground",n.colors.status.success)),W=Bs(B,a?.16:.12),Y=c("problemsInfoIcon.foreground",c("editorInfo.foreground",n.colors.status.info)),ae=d("editorInfo.background",Bs(Y,a?.16:.12)),ee=c("editorLineNumber.foreground",w),G=c("textPreformat.foreground",c("terminal.ansiGreen",n.colors.syntax.base.string)),le=c("terminal.ansiBlue",A),J=c("terminal.ansiYellow",n.colors.syntax.base.number),me=c("terminal.ansiCyan",n.colors.syntax.base.function),fe=c("terminal.ansiMagenta",f),oe=c("terminal.ansiYellow",n.colors.syntax.base.type),pe=c("chat.requestBorder",j),se=c("diffEditor.insertedLineBackground",c("diffEditor.insertedTextBackground",W)),ve=c("diffEditor.removedLineBackground",c("diffEditor.removedTextBackground",Q)),be=c("chat.linesAddedForeground",c("gitDecoration.addedResourceForeground",B)),ne=c("chat.linesRemovedForeground",c("gitDecoration.deletedResourceForeground",z)),we=c("gitDecoration.modifiedResourceForeground",Y),Ne=c("chat.requestBubbleBackground",c("chat.requestBackground",h)),Ie={...n,metadata:{...n.metadata,id:"vscode-auto",name:"VS Code Theme",description:"Mirrors your current VS Code color theme",author:"VS Code",version:"1.0.0",variant:a?"dark":"light",tags:["vscode","auto"]},colors:{...n.colors,primary:{base:A,hover:I,active:I,foreground:N,muted:k},surface:{background:l,foreground:f,muted:x,mutedForeground:w,elevated:h,elevatedForeground:b,overlay:v,subtle:S},interactive:{border:j,borderHover:c("toolbar.hoverOutline",j),borderFocus:T,selection:D,selectionForeground:M,focus:T,focusRing:R,cursor:$,hover:C,active:E},status:{error:z,errorForeground:Vs(z,l),errorBackground:Q,errorBorder:Bs(z,a?.45:.35),warning:V,warningForeground:Vs(V,l),warningBackground:L,warningBorder:Bs(V,a?.45:.35),success:B,successForeground:Vs(B,l),successBackground:W,successBorder:Bs(B,a?.45:.35),info:Y,infoForeground:Vs(Y,l),infoBackground:ae,infoBorder:Bs(Y,a?.45:.35)},pr:n.colors.pr?{...n.colors.pr,open:B,closed:z,draft:w}:void 0,syntax:{tokens:{},highlights:{diffAdded:be,diffAddedBackground:se,diffRemoved:ne,diffRemovedBackground:ve,diffModified:we,diffModifiedBackground:Bs(we,a?.16:.12),lineNumber:c("editorLineNumber.foreground",w),lineNumberActive:c("editorLineNumber.activeForeground",f)},base:{background:c("editor.background",l),foreground:c("editor.foreground",f),comment:ee,keyword:le,string:G,number:J,function:me,variable:fe,type:oe,operator:A}},tools:{border:pe,icon:c("icon.foreground",w),title:f,description:Bs(w,.8),edit:{added:be,addedBackground:se,removed:ne,removedBackground:ve,modified:we,modifiedBackground:Bs(we,a?.16:.12),lineNumber:ee}},chat:{background:l,userMessage:f,userMessageBackground:Ne,assistantMessage:f,assistantMessageBackground:l,timestamp:w,divider:j,typing:c("chat.thinkingShimmer",w),avatarBackground:c("chat.avatarBackground",l),avatarForeground:c("chat.avatarForeground",f),slashCommandBackground:c("chat.slashCommandBackground",A),slashCommandForeground:c("chat.slashCommandForeground",N),inputWorkingBorderColor1:c("chat.inputWorkingBorderColor1",A),inputWorkingBorderColor2:c("chat.inputWorkingBorderColor2",I),inputWorkingBorderColor3:c("chat.inputWorkingBorderColor3",k)},markdown:{link:c("textLink.foreground",A),linkHover:c("textLink.activeForeground",I),inlineCode:c("textPreformat.foreground",G),inlineCodeBackground:c("textPreformat.background",c("editor.background",l)),blockquote:f,blockquoteBackground:c("textBlockQuote.background","transparent"),blockquoteBorder:c("textBlockQuote.border",j),listMarker:Bs(A,.6)}}};return Uj(Ie,t.colors,e.kind==="high-contrast"||e.highContrast===!0),Ie},_o=wt().regex(/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i),wl=as({foreground:_o.optional()}),Yu=as({scope:Kr([wt(),Ys(wt())]).optional(),settings:wl}),Vj=as({name:wt().trim().min(1).max(160).optional(),author:wt().max(160).optional(),description:wt().max(1024).optional(),type:cu(["light","dark","hc","hc-black","hc-light"]).optional(),include:wt().optional(),colors:Bn(wt(),_o.nullable()).default({}),tokenColors:Kr([Ys(Yu),wt()]).optional(),semanticHighlighting:Ji().optional(),semanticTokenColors:Bn(wt(),Kr([_o,wl])).optional()});function Hj(t){return t.flatMap(e=>(Array.isArray(e.scope)?e.scope:[e.scope??""]).flatMap(n=>n.split(",").map(i=>({scope:i.trim(),color:e.settings.foreground}))))}function qj(t,e){for(const a of e){let n,i=-1;for(const o of t)!o.color||!o.scope||(a===o.scope||a.startsWith(`${o.scope}.`))&&o.scope.length>=i&&(n=o.color,i=o.scope.length);if(n)return n}}function Wj(t,e){for(const a of e.length?[...e,"*"]:e){const n=t[a];if(n===void 0)continue;const i=_o.safeParse(n);if(i.success)return i.data;const o=wl.safeParse(n);if(o.success&&o.data.foreground)return o.data.foreground}}function Gj(t){return/^[a-z0-9]+(?:[-_][a-z0-9]+)+$/.test(t)?t.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):t}function Zu(t,e){if(new TextEncoder().encode(t).byteLength>Gd)throw new Da("size");let a;try{a=Vj.parse(JSON.parse(Zf(t.replace(/^\uFEFF/,""),{trailingCommas:!0})))}catch{throw new Da("invalid")}const n=Ys(Yu).safeParse(a.tokenColors??[]);if(a.include||!n.success)throw new Da("include");const i={};for(const[N,k]of Object.entries(a.colors))k!==null&&(i[N]=k);const o=i["editor.background"];if(!o)throw new Da("background");const r=a.type?["dark","hc","hc-black"].includes(a.type):Vs(o,"#ffffff")==="#ffffff",c=r?"dark":"light",u=As(o,r?"#000000":"#ffffff",1),d=Hj(n.data),l=n.data.filter(N=>!N.scope&&N.settings.foreground).at(-1)?.settings.foreground,f=i["editor.foreground"]??l??i.foreground??Vs(u,u);i["editor.background"]=u,i["editor.foreground"]=f;const p=a.type?.startsWith("hc")??!1;p&&i.contrastBorder&&(i["widget.border"]=i.contrastBorder);const h=Bj({kind:r&&p?"high-contrast":c,colors:i,highContrast:p}),y=a.semanticHighlighting===!1?{}:a.semanticTokenColors??{},b=(N,k,P)=>Wj(y,N)??qj(d,k)??P,x=h.colors.syntax.base.foreground,w={background:h.colors.syntax.base.background,foreground:h.colors.syntax.base.foreground,comment:b(["comment"],["comment","comment.line","comment.block"],Kn(As(f,u,.6,u),u)),keyword:b(["keyword"],["keyword","storage","keyword.control","storage.type"],x),string:b(["string"],["string","string.quoted","string.template"],x),number:b(["number"],["constant.numeric"],x),function:b(["function"],["entity.name.function","support.function"],x),variable:b(["variable"],["variable.other.readwrite","variable"],x),type:b(["type"],["entity.name.type","support.type","support.class"],x),operator:b(["operator"],["keyword.operator"],x)},S=b(["class"],["entity.name.type.class","entity.name.class"],w.type),v=b(["property"],["variable.other.property","support.type.property-name"],w.variable),A={base:w,tokens:{className:S,interface:b(["interface"],["entity.name.type.interface"],w.type),enum:b(["enum"],["entity.name.type.enum"],S),method:b(["method"],["entity.name.function.method"],w.function),variableProperty:v,parameter:b(["parameter"],["variable.parameter"],w.variable),constant:b(["variable.readonly","*.readonly","enumMember"],["variable.other.constant","constant.other"],w.number),boolean:b([],["constant.language.boolean","constant.language"],w.number),punctuation:b([],["punctuation","punctuation.separator"],w.operator),stringEscape:b([],["constant.character.escape"],w.string),commentDoc:b([],["comment.block.documentation","comment.documentation"],w.comment),keywordImport:b([],["keyword.control.import","keyword.import"],w.keyword),tag:b([],["entity.name.tag"],w.keyword),tagAttribute:b([],["entity.other.attribute-name"],v)},highlights:h.colors.syntax.highlights},I=Gj(a.name??(e.replace(/\.(jsonc?|code-theme)$/i,"").replace(/[-_]color[-_]theme$/i,"").trim().slice(0,160)||"VS Code"));return Ip({metadata:{id:`vscode-import-${c}`,name:I,variant:c,author:a.author,description:a.description??"",version:"1.0.0",tags:["imported","vscode"]},colors:{...h.colors,syntax:A}})}const Jj=as({namespace:wt(),name:wt(),version:wt(),label:wt(),icon:wt().url().refine(t=>{const e=new URL(t);return e.protocol==="https:"&&["open-vsx.org","openvsx.eclipsecontent.org"].includes(e.hostname)}).nullable()});async function Qj(t,e){const a=await $t("/api/config/themes/catalog/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t}),signal:e});if(!a.ok)throw new Error("catalog");return as({items:Ys(Jj).max(24)}).parse(await a.json()).items}async function Yj(t,e){const a=await $t("/api/config/themes/catalog/package",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:e});if(!a.ok)throw new Error("catalog");const{items:n}=as({items:Ys(as({path:wt(),name:wt(),text:wt(),error:Ji()})).max(40)}).parse(await a.json());return n.map((i,o)=>{const r=`${o}:${i.path}`;try{if(i.error)throw new Error("invalid");const c=Zu(i.text,i.path);return c.metadata.name=i.name,c.metadata.author=t.namespace,{status:"ready",key:r,name:i.name,definition:c,theme:Pp(c)}}catch{return{status:"invalid",key:r,name:i.name}}})}function Zj(t){const e=De.c(3),{extension:a}=t,[n,i]=m.useState(!1);let o;return e[0]!==a.icon||e[1]!==n?(o=a.icon&&!n?s.jsx("img",{src:a.icon,alt:"",referrerPolicy:"no-referrer",loading:"lazy",className:"size-9 shrink-0 rounded object-contain",onError:()=>i(!0)}):s.jsx(te,{name:"palette",className:"size-9 shrink-0 text-muted-foreground"}),e[0]=a.icon,e[1]=n,e[2]=o):o=e[2],o}function Xj(t){const e=De.c(93),{pickFile:a,fileBusy:n,onClose:i}=t,{t:o}=Ee(),r=re(sk),{isMobile:c}=Zs(),u=r||c,{importTheme:d}=za(),[l,f]=m.useState("");let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={step:"search",status:"idle",results:[]},e[0]=p):p=e[0];const[g,h]=m.useState(p);let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y=new Set,e[1]=y):y=e[1];const[b,x]=m.useState(y);let w;e[2]===Symbol.for("react.memo_cache_sentinel")?(w=new Set,e[2]=w):w=e[2];const[S,v]=m.useState(w),[A,I]=m.useState(!1),[N,k]=m.useState(null),P=m.useRef(null);let j,C;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const W=new AbortController;P.current=W;const Y=Go(()=>W.abort());return()=>{Y(),W.abort()}},C=[],e[3]=j,e[4]=C):(j=e[3],C=e[4]),m.useEffect(j,C);let E,F;e[5]!==l||e[6]!==g.step?(E=()=>{if(g.step!=="search")return;const W=new AbortController,Y=l.trim(),ae=setTimeout(async()=>{if(!Y){h({step:"search",status:"idle",results:[]});return}h({step:"search",status:"loading",results:[]});try{const ee=await Qj(Y,W.signal);W.signal.aborted||h({step:"search",status:"ready",results:ee})}catch{W.signal.aborted||h({step:"search",status:"error",results:[]})}},350);return()=>{clearTimeout(ae),W.abort()}},F=[l,g.step],e[5]=l,e[6]=g.step,e[7]=E,e[8]=F):(E=e[7],F=e[8]),m.useEffect(E,F);let O,K;if(e[9]!==n||e[10]!==d||e[11]!==u||e[12]!==a||e[13]!==l||e[14]!==N||e[15]!==S||e[16]!==A||e[17]!==b||e[18]!==g.extension||e[19]!==g.results||e[20]!==g.status||e[21]!==g.step||e[22]!==g.variants||e[23]!==o){const W=async se=>{const ve=P.current?.signal;if(ve){h({step:"package",status:"loading",extension:se}),v(new Set),k(null),x(new Set);try{const be=await Yj(se,ve);ve.aborted||h({step:"variants",extension:se,variants:be})}catch{ve.aborted||h({step:"package",status:"error",extension:se})}}};let Y;e[26]!==d||e[27]!==S||e[28]!==A||e[29]!==b||e[30]!==g.step||e[31]!==g.variants||e[32]!==o?(Y=async()=>{if(g.step!=="variants"||A)return;const se=P.current?.signal;if(!se)return;I(!0),k(null);let ve=!1;for(const be of g.variants){if(se.aborted)break;if(!(be.status!=="ready"||!b.has(be.key)||S.has(be.key)))try{if(await d(be.definition,{activate:!1}),se.aborted)break;v(ne=>new Set(ne).add(be.key)),x(ne=>{const we=new Set(ne);return we.delete(be.key),we})}catch{ve=!0}}se.aborted||(I(!1),k(ve?"partial":null),ve?Ya.error(o("settings.themeImport.partialError")):Ya.success(o("settings.themeImport.complete")))},e[26]=d,e[27]=S,e[28]=A,e[29]=b,e[30]=g.step,e[31]=g.variants,e[32]=o,e[33]=Y):Y=e[33];const ae=Y;let ee,G;e[34]!==S||e[35]!==b||e[36]!==g.step||e[37]!==g.variants?(ee=g.step==="variants"?g.variants.filter(se=>se.status==="ready"&&!S.has(se.key)):[],G=ee.length>0&&ee.every(se=>b.has(se.key)),e[34]=S,e[35]=b,e[36]=g.step,e[37]=g.variants,e[38]=ee,e[39]=G):(ee=e[38],G=e[39]);const le=G;let J;e[40]!==n||e[41]!==ae||e[42]!==A||e[43]!==b||e[44]!==g.step||e[45]!==o?(J=g.step==="variants"&&s.jsx(H,{disabled:!b.size||A||n,onClick:()=>{ae()},children:o(A?"settings.themeImport.busy":"settings.themeImport.importSelected")}),e[40]=n,e[41]=ae,e[42]=A,e[43]=b,e[44]=g.step,e[45]=o,e[46]=J):J=e[46];const me=A||n;let fe;e[47]!==o?(fe=o("settings.themeImport.chooseFile"),e[47]=o,e[48]=fe):fe=e[48];let oe;e[49]!==a||e[50]!==me||e[51]!==fe?(oe=s.jsx(H,{variant:"outline",className:"self-start",disabled:me,onClick:a,children:fe}),e[49]=a,e[50]=me,e[51]=fe,e[52]=oe):oe=e[52];let pe;e[53]!==J||e[54]!==oe?(pe=s.jsxs(s.Fragment,{children:[J,oe]}),e[53]=J,e[54]=oe,e[55]=pe):pe=e[55],O=pe,K=s.jsx(s.Fragment,{children:g.step==="search"?s.jsxs(s.Fragment,{children:[s.jsx(qe,{autoFocus:!0,"aria-label":o("settings.themeImport.search"),placeholder:o("settings.themeImport.search"),value:l,maxLength:160,onChange:se=>f(se.target.value)}),s.jsxs("div",{className:u?"space-y-1":"max-h-[45dvh] overflow-y-auto space-y-1","aria-live":"polite",children:[g.status==="loading"&&s.jsx("p",{className:"text-muted-foreground",children:o("common.loading")}),g.status==="error"&&s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:o("settings.themeImport.catalogError")}),g.status==="ready"&&!g.results.length&&s.jsx("p",{className:"text-muted-foreground",children:o("settings.themeImport.empty")}),g.results.map(se=>s.jsxs(H,{variant:"ghost",className:"h-auto w-full justify-start py-2 text-start",onClick:()=>{W(se)},children:[s.jsx(Zj,{extension:se}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate",children:se.label}),s.jsx("span",{className:"block truncate typography-meta text-muted-foreground",children:se.namespace})]})]},`${se.namespace}.${se.name}`))]})]}):s.jsxs(s.Fragment,{children:[s.jsxs(H,{variant:"ghost",size:"sm",className:"justify-start",disabled:A||g.step==="package"&&g.status==="loading",onClick:()=>h({step:"search",status:"idle",results:[]}),children:[s.jsx(te,{name:"arrow-left",className:"size-4"}),o("settings.themeImport.back")]}),s.jsx("p",{className:"typography-ui-label",children:g.extension.label}),N==="partial"&&s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:o("settings.themeImport.partialError")}),g.step==="package"?g.status==="loading"?s.jsx("p",{role:"status",children:o("common.loading")}):s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:o("settings.themeImport.catalogError")}):s.jsxs(s.Fragment,{children:[g.variants.length>1&&s.jsx(H,{variant:"ghost",size:"sm",className:"self-start",disabled:A||n||!ee.length,onClick:()=>x(le?new Set:new Set(ee.map(tk))),children:o(le?"settings.themeImport.deselectAll":"settings.themeImport.selectAll")}),s.jsx("div",{className:u?"space-y-2":"max-h-[45dvh] overflow-y-auto space-y-2",children:g.variants.map(se=>s.jsxs("div",{className:"flex items-center gap-3",children:[se.status==="ready"&&s.jsxs("div",{"aria-hidden":"true",className:"flex w-20 shrink-0 items-center gap-2 rounded px-2 py-3",style:{backgroundColor:se.theme.colors.surface.background,color:se.theme.colors.surface.foreground},children:[s.jsx("span",{children:"Aa"}),s.jsx("span",{className:"space-y-1",children:[se.theme.colors.syntax.base.keyword,se.theme.colors.syntax.base.string,se.theme.colors.syntax.base.function].map(ek)})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[S.has(se.key)?s.jsxs("div",{className:"flex items-center gap-2 py-1",children:[s.jsx(te,{name:"check",className:"size-4 shrink-0 text-[var(--status-success-text)]"}),s.jsx("span",{className:"typography-ui-label",children:se.name})]}):s.jsx(ct,{checked:b.has(se.key),disabled:se.status!=="ready"||A||n,label:se.name,onChange:ve=>x(be=>{const ne=new Set(be);return ve?ne.add(se.key):ne.delete(se.key),ne})}),s.jsx("p",{className:S.has(se.key)?"typography-meta font-medium text-[var(--status-success-text)]":"typography-meta text-muted-foreground",children:se.status!=="ready"?o("settings.themeImport.error.invalid"):S.has(se.key)?o("settings.themeImport.installed"):o(se.theme.metadata.variant==="dark"?"settings.openchamber.visual.option.themeMode.dark":"settings.openchamber.visual.option.themeMode.light")})]})]},se.key))})]})]})}),e[9]=n,e[10]=d,e[11]=u,e[12]=a,e[13]=l,e[14]=N,e[15]=S,e[16]=A,e[17]=b,e[18]=g.extension,e[19]=g.results,e[20]=g.status,e[21]=g.step,e[22]=g.variants,e[23]=o,e[24]=O,e[25]=K}else O=e[24],K=e[25];const D=K;if(u){let W;e[56]!==o?(W=o("settings.themeImport.catalogTitle"),e[56]=o,e[57]=W):W=e[57];let Y;e[58]!==O?(Y=s.jsx("div",{className:"flex flex-col gap-2",children:O}),e[58]=O,e[59]=Y):Y=e[59];let ae;e[60]!==o?(ae=o("settings.themeImport.catalogHint"),e[60]=o,e[61]=ae):ae=e[61];let ee;e[62]!==ae?(ee=s.jsx("p",{className:"typography-meta text-muted-foreground",children:ae}),e[62]=ae,e[63]=ee):ee=e[63];let G;e[64]!==D||e[65]!==ee?(G=s.jsxs("div",{className:"flex flex-col gap-4 px-1",children:[ee,D]}),e[64]=D,e[65]=ee,e[66]=G):G=e[66];let le;return e[67]!==i||e[68]!==Y||e[69]!==G||e[70]!==W?(le=s.jsx(dl,{open:!0,title:W,onClose:i,footer:Y,children:G}),e[67]=i,e[68]=Y,e[69]=G,e[70]=W,e[71]=le):le=e[71],le}let M;e[72]!==i?(M=W=>{W||i()},e[72]=i,e[73]=M):M=e[73];let T;e[74]===Symbol.for("react.memo_cache_sentinel")?(T={forceRender:!0},e[74]=T):T=e[74];let R;e[75]!==o?(R=o("settings.themeImport.catalogTitle"),e[75]=o,e[76]=R):R=e[76];let $;e[77]!==R?($=s.jsx(Ot,{children:R}),e[77]=R,e[78]=$):$=e[78];let z;e[79]!==o?(z=o("settings.themeImport.catalogHint"),e[79]=o,e[80]=z):z=e[80];let Q;e[81]!==z?(Q=s.jsx(Ft,{children:z}),e[81]=z,e[82]=Q):Q=e[82];let V;e[83]!==$||e[84]!==Q?(V=s.jsxs(Rt,{children:[$,Q]}),e[83]=$,e[84]=Q,e[85]=V):V=e[85];let L;e[86]!==O||e[87]!==D||e[88]!==V?(L=s.jsxs(Et,{className:"max-w-lg",backdropProps:T,children:[V,D,O]}),e[86]=O,e[87]=D,e[88]=V,e[89]=L):L=e[89];let B;return e[90]!==L||e[91]!==M?(B=s.jsx(Tt,{open:!0,onOpenChange:M,children:L}),e[90]=L,e[91]=M,e[92]=B):B=e[92],B}function ek(t,e){return s.jsx("span",{className:"block h-1 w-5 rounded",style:{backgroundColor:t}},e)}function tk(t){return t.key}function sk(t){return t.isMobile}function nk(){const{t}=Ee(),{importTheme:e,customThemesLoading:a}=za(),n=oi(),[i,o]=m.useState(!1),r=m.useCallback(()=>o(!1),[]),c=m.useRef(null),u=m.useRef(0),d=m.useRef(null),[l,f]=m.useState(!1);m.useEffect(()=>Go(()=>{u.current+=1,o(!1)}),[]);const p=async(y,b)=>{f(!0);try{if(y.size>Gd)throw new Da("size");const x=await y.text();if(b.key!==Zt()||b.generation!==u.current)throw new Da("connection");const w=await e(Zu(x,y.name));Ya.success(t("settings.themeImport.success",{name:w.metadata.name})),o(!1)}catch(x){const w=x instanceof Da?x.code:"invalid";Ya.error(t(`settings.themeImport.error.${w}`))}finally{f(!1)}},g=async()=>{if(l)return;const y={key:Zt(),generation:u.current};if(d.current=y,!n.themeFiles){c.current?.click();return}f(!0);try{const b=await n.themeFiles.pick();if(b?.status==="picked"){if(b.file){const x=b.file;await p({name:x.name,size:x.size,text:async()=>x.text},y)}return}c.current?.click()}catch{Ya.error(t("settings.themeImport.error.invalid"))}finally{f(!1)}},h=async y=>{const b=y.target.files?.[0];y.target.value="",b&&!l&&d.current&&await p(b,d.current)};return s.jsxs("div",{className:"flex items-center gap-2","data-settings-item":"appearance.import-theme",children:[s.jsxs(H,{variant:"outline",size:"sm",disabled:l||a,onClick:()=>o(!0),children:[s.jsx(te,{name:l?"loader":"add",className:l?"size-3.5 animate-spin":"size-3.5"}),t(l?"settings.themeImport.busy":"settings.themeImport.action")]}),s.jsx(ts,{children:t("settings.themeImport.catalogHint")}),s.jsx("input",{ref:c,type:"file",accept:".json,.jsonc",className:"hidden","aria-label":t("settings.themeImport.action"),onChange:h}),i&&s.jsx(Xj,{pickFile:()=>{g()},fileBusy:l,onClose:r})]})}const id=(t,e,a)=>{const n=t?.querySelector("[cmdk-list]"),i=t?.querySelector(`[cmdk-item][data-value="${CSS.escape(e)}"]`);if(!n||!i)return;const o=n.getBoundingClientRect(),r=n.offsetHeight>0?o.height/n.offsetHeight:1;if(r<=0)return;const c=i.getBoundingClientRect(),u=(c.top-o.top)/r+n.scrollTop,d=c.height/r;a?.onlyIfHidden&&u>=n.scrollTop&&u+d<=n.scrollTop+n.clientHeight||(n.scrollTop=Math.max(0,u-(n.clientHeight-d)/2))};function od({options:t,value:e,onValueChange:a,placeholder:n,ariaLabel:i}){const{t:o}=Ee(),{deleteImportedTheme:r,customThemeIds:c}=za(),{isMobile:u}=Zs(),[d,l]=m.useState(!1),[f,p]=m.useState(""),[g,h]=m.useState(void 0),[y,b]=m.useState(null),x=m.useRef(null),w=m.useRef(null),S=Ap(d,w),[v,A]=m.useState(null),[I,N]=m.useState(null),k=m.useCallback(M=>{const T=M instanceof HTMLElement?M:null,R=T?.closest('[data-slot="dialog-content"], [role="dialog"]');A(R instanceof HTMLElement?R:null),N(T?.closest("main")??null)},[]);m.useEffect(()=>{if(d)return Tp.suspend()},[d]);const P=m.useRef(e);P.current=e;const j=m.useCallback(M=>{M&&id(M,P.current)},[]),C=t.find(M=>M.id===e),E=m.useMemo(()=>d?wa(t,f,M=>[M.label]):t,[d,t,f]),F=M=>{a(M),l(!1)},O=async M=>{if(!y){b(M.id);try{await r(M.id),x.current?.focus()}catch{Ya.error(o("settings.themeImport.deleteError"))}finally{b(null)}}},K=M=>{if(!c.includes(M.id))return null;const T=y===M.id;return s.jsx(H,{variant:"ghost",size:"icon",className:"size-6 shrink-0",disabled:T,"aria-label":o("settings.themeImport.delete",{name:M.label}),onPointerDown:R=>R.stopPropagation(),onClick:R=>{R.stopPropagation(),O(M)},children:s.jsx(te,{name:T?"loader":"delete-bin",className:T?"size-4 animate-spin":"size-4"})})},D=s.jsx("div",{role:"status",className:"px-3 py-6 text-center typography-ui-label text-muted-foreground",children:o("settings.openchamber.visual.field.noThemesFound")});return u?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button","aria-label":i,"aria-haspopup":"dialog",className:ze(an,!C&&"text-muted-foreground"),onClick:()=>{p(""),l(!0)},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:C?.label??n}),s.jsx(te,{name:"arrow-down-s",className:"size-4 opacity-50"})]}),s.jsx(dl,{open:d,title:i,onClose:()=>l(!1),children:s.jsxs("div",{className:"flex flex-col gap-2 px-3 pb-4 pt-1",children:[s.jsx(qe,{value:f,onChange:M=>p(M.target.value),placeholder:o("settings.openchamber.visual.field.searchThemes"),"aria-label":o("settings.openchamber.visual.field.searchThemes"),className:"h-9"}),s.jsx("div",{className:"flex flex-col",role:"listbox","aria-label":i,children:E.length===0?D:E.map(M=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{type:"button",role:"option","aria-selected":M.id===e,className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-lg px-2 py-2.5 text-start typography-ui-label hover:bg-[var(--interactive-hover)]",onClick:()=>F(M.id),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:M.label}),M.id===e?s.jsx(te,{name:"check",className:"size-4 shrink-0 text-muted-foreground"}):null]}),K(M)]},M.id))})]})})]}):s.jsxs(Xf,{open:d,onOpenChange:M=>{p(""),h(M?e:void 0),l(M)},onOpenChangeComplete:M=>{if(!M){w.current?.focus();return}x.current?.focus(),id(x.current?.closest('[data-slot="command"]'),e,{onlyIfHidden:!0})},children:[s.jsxs(eh,{ref:w,"aria-label":i,"aria-haspopup":"dialog",className:ze(an,!C&&"text-muted-foreground"),onPointerDownCapture:M=>k(M.currentTarget),onFocusCapture:M=>k(M.currentTarget),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:C?.label??n}),s.jsx(te,{name:"arrow-down-s",className:"size-4 opacity-50"})]}),s.jsx(th,{container:v??void 0,children:s.jsx(sh,{side:S,align:"start",sideOffset:4,collisionAvoidance:{side:"none"},collisionBoundary:I??void 0,className:"z-[120]",children:s.jsx(nh,{role:"dialog","aria-label":i,className:ze(Kp,"flex w-[var(--anchor-width)] min-w-[16rem] max-w-[calc(100vw-2rem)] flex-col p-0"),initialFocus:!1,finalFocus:!1,children:s.jsxs(Ep,{ref:j,className:ze("min-h-0 flex-1",S==="top"&&Lp),shouldFilter:!1,value:g,onValueChange:h,children:[s.jsx(Mp,{ref:x,"aria-label":o("settings.openchamber.visual.field.searchThemes"),placeholder:o("settings.openchamber.visual.field.searchThemes"),value:f,onValueChange:p,onKeyDown:M=>{if(Dp(M)){M.stopPropagation();return}Rp(M,T=>{M.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:T,bubbles:!0,cancelable:!0}))})}}),s.jsx(Op,{label:i,className:"max-h-[20rem] p-1",children:E.length===0?D:E.map(M=>s.jsxs(Fp,{value:M.id,onSelect:F,"aria-current":M.id===e?!0:void 0,className:"max-w-full typography-ui-label",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:M.label}),M.id===e?s.jsx(te,{name:"check",className:"size-4 shrink-0 text-muted-foreground"}):null,K(M)]},M.id))})]})})})})]})}const ak=[{value:"system",labelKey:"settings.openchamber.visual.option.themeMode.system",descriptionKey:"settings.openchamber.visual.option.themeMode.system.description"},{value:"light",labelKey:"settings.openchamber.visual.option.themeMode.light",descriptionKey:"settings.openchamber.visual.option.themeMode.light.description"},{value:"dark",labelKey:"settings.openchamber.visual.option.themeMode.dark",descriptionKey:"settings.openchamber.visual.option.themeMode.dark.description"}],ki="OpenChamber - AI Coding Assistant",rd=[{id:"system",labelKey:"settings.openchamber.visual.option.pwaOrientation.system.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.system.description"},{id:"portrait",labelKey:"settings.openchamber.visual.option.pwaOrientation.portrait.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.portrait.description"},{id:"landscape",labelKey:"settings.openchamber.visual.option.pwaOrientation.landscape.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.landscape.description"}],ld=[{id:"native",labelKey:"settings.openchamber.visual.option.mobileKeyboardMode.native.label",descriptionKey:"settings.openchamber.visual.option.mobileKeyboardMode.native.description"},{id:"resize-content",labelKey:"settings.openchamber.visual.option.mobileKeyboardMode.resizeContent.label",descriptionKey:"settings.openchamber.visual.option.mobileKeyboardMode.resizeContent.description"}],Sr=t=>t==="portrait"||t==="landscape"?t:"system",cd=[{id:"auto",labelKey:"settings.openchamber.visual.option.timeFormat.auto.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.auto.description"},{id:"24h",labelKey:"settings.openchamber.visual.option.timeFormat.24h.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.24h.description"},{id:"12h",labelKey:"settings.openchamber.visual.option.timeFormat.12h.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.12h.description"}],dd=[{id:"auto",labelKey:"settings.openchamber.visual.option.weekStart.auto.label",descriptionKey:"settings.openchamber.visual.option.weekStart.auto.description"},{id:"monday",labelKey:"settings.openchamber.visual.option.weekStart.monday.label"},{id:"sunday",labelKey:"settings.openchamber.visual.option.weekStart.sunday.label"}],ik=[{id:"left",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsLeft"},{id:"right",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsRight"}],ok=[{id:"classic",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsClassic"},{id:"traffic-lights",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsTrafficLights"}],rk=({visibleSettings:t})=>{const{locale:e,locales:a,setLocale:n,label:i,t:o}=Ee(),r=m.useCallback(X=>o(X),[o]),{isMobile:c}=Zs(),{browserTab:u}=Sf(),d=To(X=>X.animatedActivityIndicators),l=To(X=>X.setAnimatedActivityIndicators),f=re(X=>X.fontSize),p=re(X=>X.setFontSize),g=re(X=>X.terminalFontSize),h=re(X=>X.setTerminalFontSize),y=re(X=>X.editorFontSize),b=re(X=>X.setEditorFontSize),{uiFont:x,monoFont:w}=_p(),S=re(X=>X.setUiFont),v=re(X=>X.setMonoFont),A=re(X=>X.customUiFont),I=re(X=>X.customMonoFont),N=re(X=>X.setCustomUiFont),k=re(X=>X.setCustomMonoFont),P=Pn(),j=re(X=>X.padding),C=re(X=>X.setPadding),E=re(X=>X.inputBarOffset),F=re(X=>X.setInputBarOffset),O=re(X=>X.mobileKeyboardMode),K=re(X=>X.setMobileKeyboardMode),D=re(X=>X.timeFormatPreference),M=re(X=>X.setTimeFormatPreference),T=re(X=>X.weekStartPreference),R=re(X=>X.setWeekStartPreference),{themeMode:$,setThemeMode:z,availableThemes:Q,customThemesLoading:V,reloadCustomThemes:L,lightThemeId:B,darkThemeId:W,setLightThemePreference:Y,setDarkThemePreference:ae}=za(),[ee,G]=m.useState(!1),le=m.useMemo(()=>is()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",[]),J=re(X=>X.dockBadgeEnabled),me=re(X=>X.setDockBadgeEnabled),fe=re(X=>X.alwaysShowScrollbars===!0),oe=re(X=>X.setAlwaysShowScrollbars),pe=Rg(),se=re(X=>X.desktopWindowControlsPosition),ve=re(X=>X.setDesktopWindowControlsPosition),be=re(X=>X.desktopWindowControlsStyle),ne=re(X=>X.setDesktopWindowControlsStyle),we=m.useCallback(X=>{const _e=a.find(nt=>nt===X);_e&&(n(_e),jt({locale:_e}))},[a,n]),Ne=m.useCallback(X=>{ve(X),jt({desktopWindowControlsPosition:X})},[ve]),Ie=m.useCallback(X=>{ne(X),jt({desktopWindowControlsStyle:X})},[ne]),Ce=m.useCallback(X=>{M(X),jt({timeFormatPreference:X})},[M]),Me=m.useCallback(X=>{R(X),jt({weekStartPreference:X})},[R]),he=m.useMemo(()=>Q.filter(X=>X.metadata.variant==="light").sort((X,_e)=>X.metadata.name.localeCompare(_e.metadata.name)),[Q]),Pe=m.useMemo(()=>Q.filter(X=>X.metadata.variant==="dark").sort((X,_e)=>X.metadata.name.localeCompare(_e.metadata.name)),[Q]),Re=m.useMemo(()=>he.find(X=>X.metadata.id===B)??he[0],[he,B]),ce=m.useMemo(()=>Pe.find(X=>X.metadata.id===W)??Pe[0],[Pe,W]),je=m.useCallback((X,_e)=>{const nt=_e==="dark"?" Dark":" Light";return X.endsWith(nt)?X.slice(0,-nt.length):X},[]),de=m.useMemo(()=>he.map(X=>({id:X.metadata.id,label:je(X.metadata.name,"light")})),[he,je]),ie=m.useMemo(()=>Pe.map(X=>({id:X.metadata.id,label:je(X.metadata.name,"dark")})),[Pe,je]),xe=X=>t?t.includes(X):!0,Se=os(),Le=xe("theme")&&!Se,Ue=xe("windowControlsPosition")&&pe,Ye=xe("theme")||xe("timeFormat")||xe("weekStart"),lt=Se?Ye:xe("theme")||Ue||xe("pwaInstallName")||xe("pwaOrientation")||xe("timeFormat")||xe("weekStart"),at=xe("fontSize")||xe("terminalFontSize")||xe("editorFontSize")||xe("spacing")||xe("scrollbars")&&!Le||xe("inputBarOffset")&&c,ut=xe("pwaInstallName")&&Di()&&u&&!is()&&!Se,vt=xe("pwaOrientation")&&Di()&&!is()&&!Se,We=xe("mobileKeyboardMode")&&Di()&&!is()&&!Se&&Og(),[Ze,Xe]=m.useState(""),[it,dt]=m.useState("system"),Be=m.useMemo(()=>{const X=cd.find(_e=>_e.id===D);return r(X?.labelKey??"settings.openchamber.visual.option.timeFormat.auto.label")},[D,r]),ot=m.useMemo(()=>{const X=dd.find(_e=>_e.id===T);return r(X?.labelKey??"settings.openchamber.visual.option.weekStart.auto.label")},[T,r]),et=m.useMemo(()=>{const X=rd.find(_e=>_e.id===it);return X?r(X.labelKey):void 0},[it,r]),ye=m.useMemo(()=>{const X=ld.find(_e=>_e.id===O);return X?r(X.labelKey):void 0},[O,r]),Z=m.useCallback(async X=>{if(typeof window>"u")return;const _e=window,ht=X.trim().replace(/\s+/g," ").slice(0,64);if(await jt({pwaAppName:ht}),typeof _e.__OPENCHAMBER_SET_PWA_INSTALL_NAME__=="function"){const yt=_e.__OPENCHAMBER_SET_PWA_INSTALL_NAME__(ht);Xe(yt);return}Xe(ht||ki),_e.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]),Oe=m.useCallback(async X=>{if(typeof window>"u")return;const _e=window,nt=Sr(X);if(await jt({pwaOrientation:nt}),typeof _e.__OPENCHAMBER_SET_PWA_ORIENTATION__=="function"){const ht=_e.__OPENCHAMBER_SET_PWA_ORIENTATION__(nt);dt(ht);return}dt(nt),_e.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]);m.useEffect(()=>{if(typeof window>"u"||!ut&&!vt&&!We)return;let X=!1;return(async()=>{try{const nt=await fn();if(!nt){X||Xe(ki);return}const yt=(nt.pwaAppName??"").trim().replace(/\s+/g," ").slice(0,64),kt=Sr(nt.pwaOrientation),He=Jl(nt.mobileKeyboardMode);X||(ut&&Xe(yt||ki),vt&&dt(kt),We&&K(He))}catch{X||(ut&&Xe(ki),vt&&dt("system"),We&&K("native"))}})(),()=>{X=!0}},[K,We,ut,vt]);const Ve=xe("scrollbars")?s.jsx(ct,{checked:fe,onChange:oe,label:o("settings.openchamber.visual.field.alwaysShowScrollbars"),info:o("settings.openchamber.visual.field.alwaysShowScrollbarsHint"),settingsItem:"appearance.scrollbars"}):null;return s.jsxs("div",{className:"space-y-0",children:[lt&&s.jsxs("div",{className:"space-y-0",children:[Le&&s.jsxs($e,{title:o("settings.openchamber.visual.section.colorModeAndTheme"),divider:!1,children:[s.jsxs(ma,{children:[s.jsx("div",{className:Ts,children:s.jsx(Vo,{"aria-label":o("settings.openchamber.visual.section.colorMode"),children:ak.map(X=>s.jsx(wn,{selected:$===X.value,onSelect:()=>z(X.value),label:r(X.labelKey),ariaLabel:r(X.labelKey)},X.value))})}),s.jsxs("div",{className:Ts,children:[s.jsx(St,{label:o("settings.openchamber.visual.field.lightTheme"),settingsItem:"appearance.light-theme",children:s.jsx(od,{options:de,value:Re?.metadata.id??"",onValueChange:Y,placeholder:o("settings.openchamber.visual.field.selectThemePlaceholder"),ariaLabel:o("settings.openchamber.visual.field.selectLightThemeAria")})}),s.jsx(St,{label:o("settings.openchamber.visual.field.darkTheme"),settingsItem:"appearance.dark-theme",children:s.jsx(od,{options:ie,value:ce?.metadata.id??"",onValueChange:ae,placeholder:o("settings.openchamber.visual.field.selectThemePlaceholder"),ariaLabel:o("settings.openchamber.visual.field.selectDarkThemeAria")})}),s.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[s.jsxs("button",{type:"button",disabled:V||ee,onClick:()=>{const X=Date.now();G(!0),L().finally(()=>{const _e=Date.now()-X;if(_e<500){window.setTimeout(()=>{G(!1)},500-_e);return}G(!1)})},className:"typography-settings-link inline-flex items-center gap-1.5 disabled:cursor-not-allowed disabled:opacity-50 disabled:no-underline",children:[s.jsx(te,{name:"restart",className:ze("h-3.5 w-3.5",ee&&"animate-spin")}),o(ee?"settings.openchamber.visual.actions.reloadingThemes":"settings.openchamber.visual.actions.reloadThemes")]}),s.jsx(ts,{children:o("settings.openchamber.visual.field.themeImportInfoTooltip")})]}),s.jsx(nk,{})]})]}),le&&s.jsx(_i,{settingsItem:"appearance.dock-badge",children:s.jsx(ct,{checked:J,onChange:me,label:o("settings.openchamber.visual.field.dockBadge"),info:o("settings.openchamber.visual.field.dockBadgeHint"),ariaLabel:o("settings.openchamber.visual.field.dockBadge")})}),Ve&&s.jsx(_i,{children:Ve})]}),Ue&&s.jsx($e,{title:o("settings.openchamber.desktopNetwork.field.windowControls"),info:o("settings.openchamber.desktopNetwork.field.windowControlsPositionDescription"),divider:Le,children:s.jsxs(ma,{children:[s.jsx(St,{label:o("settings.openchamber.desktopNetwork.field.windowControlsPosition"),settingsItem:"sessions.desktop-window-controls-position",children:s.jsx(Xt,{value:se,options:ik.map(X=>({value:X.id,label:r(X.labelKey)})),onChange:Ne,"aria-label":o("settings.openchamber.desktopNetwork.field.windowControlsPositionAria")})}),s.jsx(St,{label:o("settings.openchamber.desktopNetwork.field.windowControlsStyle"),settingsItem:"sessions.desktop-window-controls-style",children:s.jsx(Xt,{value:be,options:ok.map(X=>({value:X.id,label:r(X.labelKey)})),onChange:Ie,"aria-label":o("settings.openchamber.desktopNetwork.field.windowControlsStyleAria")})})]})}),Ye&&s.jsx($e,{title:o("settings.openchamber.visual.section.localization"),children:s.jsxs(ma,{children:[s.jsx(St,{label:o("settings.appearance.language.label"),info:o("settings.appearance.language.description"),settingsItem:"appearance.language",children:s.jsxs(Pt,{value:e,onValueChange:we,children:[s.jsx(Ct,{"aria-label":o("settings.appearance.language.select"),className:fi,children:s.jsx(Kt,{children:i(e)})}),s.jsx(It,{children:a.map(X=>s.jsx(bt,{value:X,children:i(X)},X))})]})}),(xe("timeFormat")||xe("weekStart"))&&s.jsxs("div",{className:Ts,children:[xe("timeFormat")&&s.jsx(St,{label:o("settings.openchamber.visual.field.timeFormat"),settingsItem:"appearance.time-format",children:s.jsxs(Pt,{value:D,onValueChange:X=>Ce(X),children:[s.jsx(Ct,{"aria-label":o("settings.openchamber.visual.field.selectTimeFormatAria"),className:fi,children:s.jsx(Kt,{children:Be})}),s.jsx(It,{children:cd.map(X=>s.jsx(bt,{value:X.id,children:r(X.labelKey)},X.id))})]})}),xe("weekStart")&&s.jsx(St,{label:o("settings.openchamber.visual.field.weekStartsOn"),settingsItem:"appearance.week-start",children:s.jsxs(Pt,{value:T,onValueChange:X=>Me(X),children:[s.jsx(Ct,{"aria-label":o("settings.openchamber.visual.field.selectWeekStartAria"),className:fi,children:s.jsx(Kt,{children:ot})}),s.jsx(It,{children:dd.map(X=>s.jsx(bt,{value:X.id,children:r(X.labelKey)},X.id))})]})})]})]})}),(ut||vt||We)&&s.jsxs($e,{title:o("settings.openchamber.visual.section.appInstall"),contentClassName:Ts,children:[ut&&s.jsxs(st,{label:o("settings.openchamber.visual.field.installAppName"),info:o("settings.openchamber.visual.field.installAppNameHint"),settingsItem:"appearance.pwa-install-name",alignEnd:!1,controlClassName:rn,children:[s.jsx(qe,{value:Ze,onChange:X=>{Xe(X.target.value)},onBlur:()=>{Z(Ze)},onKeyDown:X=>{X.key==="Enter"&&(X.preventDefault(),Z(Ze))},className:"min-w-0 flex-1",maxLength:64,"aria-label":o("settings.openchamber.visual.field.pwaInstallAppNameAria")}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{Xe(ki),Z("")},className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetInstallAppNameAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]}),vt&&s.jsxs(st,{label:o("settings.openchamber.visual.field.installOrientation"),description:o("settings.openchamber.visual.field.installOrientationHint"),settingsItem:"appearance.pwa-orientation",alignEnd:!1,controlClassName:rn,children:[s.jsxs(Pt,{value:it,onValueChange:X=>{const _e=Sr(X);dt(_e),Oe(_e)},children:[s.jsx(Ct,{"aria-label":o("settings.openchamber.visual.field.pwaInstallOrientationAria"),className:Fl,children:s.jsx(Kt,{placeholder:o("settings.openchamber.visual.field.selectOrientationPlaceholder"),children:et})}),s.jsx(It,{children:rd.map(X=>s.jsx(bt,{value:X.id,children:r(X.labelKey)},X.id))})]}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{dt("system"),Oe("system")},disabled:it==="system",className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetInstallOrientationAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]}),We&&s.jsxs(st,{label:o("settings.openchamber.visual.field.mobileKeyboardMode"),info:o("settings.openchamber.visual.field.mobileKeyboardModeHint"),settingsItem:"appearance.mobile-keyboard-mode",alignEnd:!1,controlClassName:rn,children:[s.jsxs(Pt,{value:O,onValueChange:X=>{const _e=Jl(X);K(_e),jt({mobileKeyboardMode:_e})},children:[s.jsx(Ct,{"aria-label":o("settings.openchamber.visual.field.mobileKeyboardModeAria"),className:Fl,children:s.jsx(Kt,{placeholder:o("settings.openchamber.visual.field.selectMobileKeyboardModePlaceholder"),children:ye})}),s.jsx(It,{children:ld.map(X=>s.jsx(bt,{value:X.id,children:r(X.labelKey)},X.id))})]}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{K("native"),jt({mobileKeyboardMode:"native"})},disabled:O==="native",className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetMobileKeyboardModeAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})]})]}),at&&s.jsxs($e,{title:o("settings.openchamber.visual.section.densityAndType"),contentClassName:Ts,children:[xe("fontSize")&&!c||xe("terminalFontSize")?s.jsxs(ma,{children:[xe("fontSize")&&!c&&s.jsxs(St,{label:o("settings.openchamber.visual.field.interfaceFont"),settingsItem:"appearance.interface-font-size",controlClassName:"w-full flex-wrap",children:[s.jsxs(Pt,{value:x,onValueChange:X=>S(X),children:[s.jsx(Ct,{"aria-label":o("settings.openchamber.visual.field.selectInterfaceFontAria"),className:fi,children:s.jsx(Kt,{children:x===Ha?o("settings.openchamber.visual.field.customFont"):Hl.find(X=>X.id===x)?.label})}),s.jsxs(It,{children:[Hl.map(X=>s.jsx(bt,{value:X.id,disabled:P&&!!X.source,children:s.jsx("span",{style:{fontFamily:X.stack},children:X.label})},X.id)),s.jsx(bt,{value:Ha,children:o("settings.openchamber.visual.field.customFont")})]})]}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>S(ql),disabled:x===ql,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetInterfaceFontAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})}),x===Ha?s.jsx(qe,{value:A,onChange:X=>N(X.target.value),placeholder:o("settings.openchamber.visual.field.customFontPlaceholder"),"aria-label":o("settings.openchamber.visual.field.customFontAria"),spellCheck:!1,autoComplete:"off",className:"h-8 basis-full rounded-md px-3"}):null]}),xe("terminalFontSize")&&s.jsxs(St,{label:o("settings.openchamber.visual.field.codeFont"),controlClassName:"w-full flex-wrap",children:[s.jsxs(Pt,{value:w,onValueChange:X=>v(X),children:[s.jsx(Ct,{"aria-label":o("settings.openchamber.visual.field.selectCodeFontAria"),className:fi,children:s.jsx(Kt,{children:w===Ha?o("settings.openchamber.visual.field.customFont"):Wl.find(X=>X.id===w)?.label})}),s.jsxs(It,{children:[Wl.map(X=>s.jsx(bt,{value:X.id,disabled:P&&!!X.source,children:s.jsx("span",{style:{fontFamily:X.stack},children:X.label})},X.id)),s.jsx(bt,{value:Ha,children:o("settings.openchamber.visual.field.customFont")})]})]}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>v(Gl),disabled:w===Gl,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetCodeFontAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})}),w===Ha?s.jsx(qe,{value:I,onChange:X=>k(X.target.value),placeholder:o("settings.openchamber.visual.field.customFontPlaceholder"),"aria-label":o("settings.openchamber.visual.field.customFontAria"),spellCheck:!1,autoComplete:"off",className:"h-8 basis-full rounded-md px-3"}):null]})]}):null,P&&(xe("fontSize")&&!c||xe("terminalFontSize"))?s.jsx("p",{className:_t,children:o("settings.openchamber.visual.field.webFontsEnterprise")}):null,xe("fontSize")&&!c||xe("terminalFontSize")||xe("editorFontSize")?s.jsxs(ma,{children:[xe("fontSize")&&!c&&s.jsx(St,{label:o("settings.openchamber.visual.field.interfaceFontSize"),controlClassName:"w-full",children:s.jsxs("div",{className:Fn,children:[s.jsx(ds,{value:f,onValueChange:p,min:50,max:200,step:5,className:us,"aria-label":o("settings.openchamber.visual.field.fontSizePercentageAria")}),s.jsx("span",{className:ga,children:"%"}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>p(100),disabled:f===100,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetFontSizeAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})}),xe("terminalFontSize")&&s.jsx(St,{label:o("settings.openchamber.visual.field.terminalFontSize"),settingsItem:"appearance.terminal-font-size",controlClassName:"w-full",children:s.jsxs("div",{className:Fn,children:[s.jsx(ds,{value:g,onValueChange:h,min:9,max:52,step:1,className:us}),s.jsx("span",{className:ga,children:"px"}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>h(13),disabled:g===13,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetTerminalFontSizeAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})}),xe("editorFontSize")&&s.jsx(St,{label:o("settings.openchamber.visual.field.editorFontSize"),settingsItem:"appearance.editor-font-size",controlClassName:"w-full",children:s.jsxs("div",{className:Fn,children:[s.jsx(ds,{value:y,onValueChange:b,min:9,max:32,step:1,className:us}),s.jsx("span",{className:ga,children:"px"}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>b(13),disabled:y===13,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetEditorFontSizeAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})})]}):null,xe("spacing")||xe("inputBarOffset")&&c?s.jsxs(ma,{children:[xe("spacing")&&s.jsx(St,{label:o("settings.openchamber.visual.field.spacingDensity"),settingsItem:"appearance.spacing-density",controlClassName:"w-full",children:s.jsxs("div",{className:Fn,children:[s.jsx(ds,{value:j,onValueChange:C,min:50,max:200,step:5,className:us}),s.jsx("span",{className:ga,children:"%"}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>C(100),disabled:j===100,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetSpacingAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})}),xe("inputBarOffset")&&c&&s.jsx(St,{label:o("settings.openchamber.visual.field.inputBarOffset"),info:o("settings.openchamber.visual.field.inputBarOffsetTooltip"),settingsItem:"appearance.input-bar-offset",controlClassName:"w-full",children:s.jsxs("div",{className:Fn,children:[s.jsx(ds,{value:E,onValueChange:F,min:0,max:100,step:5,className:us}),s.jsx("span",{className:ga,children:"px"}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>F(0),disabled:E===0,className:Yt,"aria-label":o("settings.openchamber.visual.actions.resetInputBarOffsetAria"),title:o("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})})]}):null,!Le&&Ve]}),xe("animatedActivityIndicators")&&s.jsx($e,{title:o("settings.openchamber.visual.section.sessionActivity"),settingsItem:"appearance.session-activity",contentClassName:bs,children:s.jsx(ct,{checked:d,onChange:l,label:o("settings.openchamber.visual.field.animatedActivityIndicators"),ariaLabel:o("settings.openchamber.visual.field.animatedActivityIndicatorsAria"),info:o("settings.openchamber.visual.field.animatedActivityIndicatorsInfo"),settingsItem:"appearance.animated-activity-indicators"})})]})},lk=1,ck=365,ud=30,dk=[{value:"archive",labelKey:"settings.openchamber.sessionRetention.action.archive"},{value:"delete",labelKey:"settings.openchamber.sessionRetention.action.delete"}],uk=()=>{const t=De.c(122),{t:e}=Ee(),a=re(mk),n=re(pk),i=re(gk),o=re(fk),r=re(hk),c=re(bk),u=re(xk);let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d={autoRun:!1},t[0]=d):d=t[0];const{candidates:l,isRunning:f,runCleanup:p,action:g,status:h}=$p(d),y=l.length;let b;t[1]!==p||t[2]!==e?(b=async()=>{const Pe=await p({force:!0}).catch(()=>(q.error(e("sessions.sidebar.group.empty.loadFailed")),null));if(!(!Pe||Pe.skippedReason&&Pe.skippedReason!=="no-candidates")){if(Pe.completedIds.length===0&&Pe.failedIds.length===0){q.message(Pe.action==="archive"?e("settings.openchamber.sessionRetention.toast.noneEligibleArchive"):e("settings.openchamber.sessionRetention.toast.noneEligibleDelete"));return}Pe.completedIds.length>0&&q.success(Pe.action==="archive"?e("settings.openchamber.sessionRetention.toast.archivedCount",{count:Pe.completedIds.length}):e("settings.openchamber.sessionRetention.toast.deletedCount",{count:Pe.completedIds.length})),Pe.failedIds.length>0&&q.error(Pe.action==="archive"?e("settings.openchamber.sessionRetention.toast.failedArchiveCount",{count:Pe.failedIds.length}):e("settings.openchamber.sessionRetention.toast.failedDeleteCount",{count:Pe.failedIds.length}))}},t[1]=p,t[2]=e,t[3]=b):b=t[3];const x=b;let w;t[4]!==g||t[5]!==y||t[6]!==h||t[7]!==e?(w=h==="error"?e("sessions.sidebar.group.empty.loadFailed"):h!=="ready"?e("sessions.sidebar.group.empty.loadingSessions"):g==="archive"?e("settings.openchamber.sessionRetention.manualCleanup.eligibleArchiveNow",{count:y}):e("settings.openchamber.sessionRetention.manualCleanup.eligibleDeleteNow",{count:y}),t[4]=g,t[5]=y,t[6]=h,t[7]=e,t[8]=w):w=t[8];const S=w;let v;t[9]!==e?(v=e("settings.openchamber.sessionRetention.title"),t[9]=e,t[10]=v):v=t[10];const A=i?"settings.openchamber.sessionRetention.archivedTooltip":"settings.openchamber.sessionRetention.tooltip";let I;t[11]!==e||t[12]!==A?(I=e(A),t[11]=e,t[12]=A,t[13]=I):I=t[13];let N;t[14]!==e?(N=e("settings.openchamber.sessionRetention.field.enableAutoCleanup"),t[14]=e,t[15]=N):N=t[15];let k;t[16]!==e?(k=e("settings.openchamber.sessionRetention.field.enableAutoCleanupAria"),t[16]=e,t[17]=k):k=t[17];let P;t[18]!==a||t[19]!==o||t[20]!==N||t[21]!==k?(P=s.jsx(ct,{settingsItem:"sessions.auto-cleanup",checked:a,onChange:o,label:N,ariaLabel:k}),t[18]=a,t[19]=o,t[20]=N,t[21]=k,t[22]=P):P=t[22];let j;t[23]!==e?(j=e("settings.layout.sessions.retention.target"),t[23]=e,t[24]=j):j=t[24];let C;t[25]!==e?(C=e("settings.openchamber.sessionRetention.field.onlyArchivedDescription"),t[25]=e,t[26]=C):C=t[26];const E=i?"archived":"unarchived";let F;t[27]!==u?(F=Pe=>u(Pe==="archived"),t[27]=u,t[28]=F):F=t[28];let O;t[29]!==e?(O=e("settings.layout.sessions.retention.target"),t[29]=e,t[30]=O):O=t[30];let K;t[31]!==e?(K=e("settings.layout.sessions.retention.target.unarchived"),t[31]=e,t[32]=K):K=t[32];let D;t[33]!==f||t[34]!==K?(D={value:"unarchived",label:K,disabled:f},t[33]=f,t[34]=K,t[35]=D):D=t[35];let M;t[36]!==e?(M=e("settings.layout.sessions.retention.target.archived"),t[36]=e,t[37]=M):M=t[37];let T;t[38]!==f||t[39]!==M?(T={value:"archived",label:M,disabled:f},t[38]=f,t[39]=M,t[40]=T):T=t[40];let R;t[41]!==D||t[42]!==T?(R=[D,T],t[41]=D,t[42]=T,t[43]=R):R=t[43];let $;t[44]!==E||t[45]!==F||t[46]!==O||t[47]!==R?($=s.jsx(Xt,{value:E,onChange:F,"aria-label":O,options:R}),t[44]=E,t[45]=F,t[46]=O,t[47]=R,t[48]=$):$=t[48];let z;t[49]!==C||t[50]!==$||t[51]!==j?(z=s.jsx(st,{settingsItem:"sessions.retention-only-archived",label:j,info:C,children:$}),t[49]=C,t[50]=$,t[51]=j,t[52]=z):z=t[52];let Q;t[53]!==e?(Q=e("settings.openchamber.sessionRetention.field.retentionPeriod"),t[53]=e,t[54]=Q):Q=t[54];let V;t[55]!==e?(V=e("settings.openchamber.sessionRetention.field.retentionPeriodAria"),t[55]=e,t[56]=V):V=t[56];let L;t[57]===Symbol.for("react.memo_cache_sentinel")?(L=ze(us,"tabular-nums"),t[57]=L):L=t[57];let B;t[58]!==n||t[59]!==r||t[60]!==V?(B=s.jsx(ds,{value:n,onValueChange:r,min:lk,max:ck,step:1,"aria-label":V,className:L}),t[58]=n,t[59]=r,t[60]=V,t[61]=B):B=t[61];let W;t[62]!==e?(W=e("settings.openchamber.sessionRetention.field.days"),t[62]=e,t[63]=W):W=t[63];let Y;t[64]!==W?(Y=s.jsx("span",{className:ga,children:W}),t[64]=W,t[65]=Y):Y=t[65];let ae;t[66]!==r?(ae=()=>r(ud),t[66]=r,t[67]=ae):ae=t[67];const ee=n===ud;let G;t[68]!==e?(G=e("settings.openchamber.sessionRetention.actions.resetRetentionAria"),t[68]=e,t[69]=G):G=t[69];let le;t[70]!==e?(le=e("settings.common.actions.reset"),t[70]=e,t[71]=le):le=t[71];let J;t[72]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"}),t[72]=J):J=t[72];let me;t[73]!==ae||t[74]!==ee||t[75]!==G||t[76]!==le?(me=s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:ae,disabled:ee,className:Yt,"aria-label":G,title:le,children:J}),t[73]=ae,t[74]=ee,t[75]=G,t[76]=le,t[77]=me):me=t[77];let fe;t[78]!==B||t[79]!==Y||t[80]!==me?(fe=s.jsxs("div",{className:Fn,children:[B,Y,me]}),t[78]=B,t[79]=Y,t[80]=me,t[81]=fe):fe=t[81];let oe;t[82]!==Q||t[83]!==fe?(oe=s.jsx(st,{settingsItem:"sessions.retention-period",label:Q,children:fe}),t[82]=Q,t[83]=fe,t[84]=oe):oe=t[84];let pe;t[85]!==e?(pe=e("settings.openchamber.sessionRetention.field.whenSessionsExpire"),t[85]=e,t[86]=pe):pe=t[86];let se;t[87]!==i||t[88]!==e?(se=dk.map(Pe=>({value:Pe.value,label:e(Pe.labelKey),disabled:i&&Pe.value==="archive"})),t[87]=i,t[88]=e,t[89]=se):se=t[89];let ve;t[90]!==g||t[91]!==c||t[92]!==se?(ve=s.jsx(Xt,{value:g,onChange:c,options:se}),t[90]=g,t[91]=c,t[92]=se,t[93]=ve):ve=t[93];let be;t[94]!==pe||t[95]!==ve?(be=s.jsx(st,{settingsItem:"sessions.retention-action",label:pe,children:ve}),t[94]=pe,t[95]=ve,t[96]=be):be=t[96];let ne;t[97]!==e?(ne=e("settings.openchamber.sessionRetention.manualCleanup.title"),t[97]=e,t[98]=ne):ne=t[98];let we;t[99]!==f||t[100]!==e?(we=e(f?"settings.openchamber.sessionRetention.actions.cleaningUp":"settings.openchamber.sessionRetention.actions.runCleanupNow"),t[99]=f,t[100]=e,t[101]=we):we=t[101];let Ne;t[102]!==x||t[103]!==f||t[104]!==we?(Ne=s.jsx(H,{type:"button",variant:"outline",size:"sm",onClick:x,disabled:f,className:"!font-normal",children:we}),t[102]=x,t[103]=f,t[104]=we,t[105]=Ne):Ne=t[105];let Ie;t[106]!==S?(Ie=s.jsx("span",{className:"typography-meta truncate text-muted-foreground","aria-live":"polite",title:S,children:S}),t[106]=S,t[107]=Ie):Ie=t[107];let Ce;t[108]!==ne||t[109]!==Ne||t[110]!==Ie?(Ce=s.jsxs(st,{label:ne,children:[Ne,Ie]}),t[108]=ne,t[109]=Ne,t[110]=Ie,t[111]=Ce):Ce=t[111];let Me;t[112]!==z||t[113]!==oe||t[114]!==be||t[115]!==Ce?(Me=s.jsxs("div",{children:[z,oe,be,Ce]}),t[112]=z,t[113]=oe,t[114]=be,t[115]=Ce,t[116]=Me):Me=t[116];let he;return t[117]!==v||t[118]!==Me||t[119]!==I||t[120]!==P?(he=s.jsxs($e,{title:v,info:I,contentClassName:"space-y-2",children:[P,Me]}),t[117]=v,t[118]=Me,t[119]=I,t[120]=P,t[121]=he):he=t[121],he};function mk(t){return t.autoDeleteEnabled}function pk(t){return t.autoDeleteAfterDays}function gk(t){return t.sessionRetentionOnlyArchived}function fk(t){return t.setAutoDeleteEnabled}function hk(t){return t.setAutoDeleteAfterDays}function bk(t){return t.setSessionRetentionAction}function xk(t){return t.setSessionRetentionOnlyArchived}const vk=()=>{const t=De.c(17),{t:e}=Ee(),a=re(yk),n=re(jk);let i;t[0]!==e?(i=e("settings.openchamber.mergedWorktreeCleanup.title"),t[0]=e,t[1]=i):i=t[1];let o;t[2]!==e?(o=e("settings.openchamber.mergedWorktreeCleanup.info"),t[2]=e,t[3]=o):o=t[3];let r;t[4]!==e?(r=e("settings.openchamber.mergedWorktreeCleanup.field.enable"),t[4]=e,t[5]=r):r=t[5];let c;t[6]!==e?(c=e("settings.openchamber.mergedWorktreeCleanup.field.enableDescription"),t[6]=e,t[7]=c):c=t[7];let u;t[8]!==a||t[9]!==n||t[10]!==r||t[11]!==c?(u=s.jsx(ct,{settingsItem:"sessions.merged-worktree-cleanup",checked:a,onChange:n,label:r,description:c}),t[8]=a,t[9]=n,t[10]=r,t[11]=c,t[12]=u):u=t[12];let d;return t[13]!==i||t[14]!==o||t[15]!==u?(d=s.jsx($e,{settingsItem:"sessions.merged-worktree-cleanup-section",title:i,info:o,children:u}),t[13]=i,t[14]=o,t[15]=u,t[16]=d):d=t[16],d};function yk(t){return t.mergedWorktreeCleanupEnabled}function jk(t){return t.setMergedWorktreeCleanupEnabled}const kk=()=>{const t=De.c(22),{t:e}=Ee(),a=re(wk),n=re(Sk),i=To(Nk),o=To(Ck);let r;t[0]!==e?(r=e("settings.layout.sessions.sidebar.title"),t[0]=e,t[1]=r):r=t[1];let c;t[2]!==o||t[3]!==i||t[4]!==e?(c=os()?null:s.jsx(ct,{settingsItem:"sessions.show-chats",checked:i,onChange:g=>{o(g),jt({sidebarShowChatsSection:g})},label:e("settings.openchamber.defaults.field.showChats"),ariaLabel:e("settings.openchamber.defaults.field.showChats")}),t[2]=o,t[3]=i,t[4]=e,t[5]=c):c=t[5];let u;t[6]!==e?(u=e("settings.openchamber.sessionWork.field.enabled"),t[6]=e,t[7]=u):u=t[7];let d;t[8]!==e?(d=e("settings.openchamber.sessionWork.field.enabled"),t[8]=e,t[9]=d):d=t[9];let l;t[10]!==e?(l=e("settings.openchamber.sessionWork.info"),t[10]=e,t[11]=l):l=t[11];let f;t[12]!==a||t[13]!==n||t[14]!==u||t[15]!==d||t[16]!==l?(f=s.jsx(ct,{settingsItem:"sessions.work-enabled",checked:a,onChange:n,label:u,ariaLabel:d,info:l}),t[12]=a,t[13]=n,t[14]=u,t[15]=d,t[16]=l,t[17]=f):f=t[17];let p;return t[18]!==r||t[19]!==c||t[20]!==f?(p=s.jsxs($e,{title:r,settingsItem:"sessions.work",contentClassName:bs,children:[c,f]}),t[18]=r,t[19]=c,t[20]=f,t[21]=p):p=t[21],p};function wk(t){return t.sessionWorkEnabled}function Sk(t){return t.setSessionWorkEnabled}function Nk(t){return t.showChatsSection}function Ck(t){return t.setShowChatsSection}const md=(t,e,a)=>!t||!Number.isFinite(t)?e:new Intl.DateTimeFormat(Bo(),{dateStyle:"medium",timeStyle:"short",hour12:a==="auto"?void 0:a==="12h"}).format(t),Ik=()=>{const{t}=Ee(),e=re(T=>T.timeFormatPreference),[a,n]=m.useState(!1),[i,o]=m.useState(!0),[r,c]=m.useState(!1),[u,d]=m.useState(null),[l,f]=m.useState(!1),[p,g]=m.useState(null),[h,y]=m.useState(""),[b,x]=m.useState(!1),w=m.useRef(!1),S=m.useRef(!1),[v,A]=m.useState([]),[I,N]=m.useState(zp),[k,P]=m.useState(""),j=m.useMemo(()=>Up(),[]),C=m.useCallback(async()=>{o(!0),P("");try{const T=await Bp();A(T)}catch(T){const R=T instanceof Error?T.message:t("settings.openchamber.passkeys.toast.loadFailed");P(R)}finally{o(!1)}},[t]);m.useEffect(()=>{let T=!1;return(async()=>{try{if(!j.supported){T||(n(!1),o(!1));return}T||n(!0)}catch{T||n(!1)}if(!T){const R=await ar();if(N(R),!R.enabled){A([]),o(!1);return}await C()}})(),()=>{T=!0,Ll()}},[C,j.supported]);const E=m.useCallback(async()=>{if(!I.enabled){const T=t("settings.openchamber.passkeys.toast.enableUiPasswordFirst");P(T),q.message(T);return}if(!a){P(j.reason),q.message(j.reason);return}if(r){Ll(),c(!1);return}P(""),c(!0);try{await Vp(),N(await ar()),await C(),q.success(t("settings.openchamber.passkeys.toast.added"))}catch(T){if(Hp(T)){q.message(t("settings.openchamber.passkeys.toast.setupCanceled"));return}const R=T instanceof Error?T.message:t("settings.openchamber.passkeys.toast.addFailed");P(R),q.error(R)}finally{c(!1)}},[r,C,I.enabled,j.reason,a,t]),F=m.useCallback(async T=>{d(T),P("");try{await qp(T),N(await ar()),await C(),q.success(t("settings.openchamber.passkeys.toast.removed"))}catch(R){const $=R instanceof Error?R.message:t("settings.openchamber.passkeys.toast.removeFailed");P($),q.error($)}finally{d(null)}},[C,t]),O=m.useCallback(T=>{w.current=!1,y(T.customLabel??""),g(T.id)},[]),K=m.useCallback(()=>{w.current=!0,y(""),g(null)},[]),D=m.useCallback(async T=>{if(w.current){w.current=!1;return}if(!S.current){if(h.trim()===(T.customLabel??"")){g(R=>R===T.id?null:R);return}S.current=!0,x(!0),P("");try{const R=await Wp(T.id,h);R?A($=>$.map(z=>z.id===T.id?R:z)):await C(),g($=>$===T.id?null:$),q.success(t("settings.openchamber.passkeys.toast.renamed"))}catch(R){const $=R instanceof Error?R.message:t("settings.openchamber.passkeys.toast.renameFailed");P($),q.error($)}finally{S.current=!1,x(!1)}}},[C,h,t]),M=m.useCallback(async()=>{f(!0),P("");try{await Gp(),window.location.reload()}catch(T){const R=T instanceof Error?T.message:t("settings.openchamber.passkeys.toast.clearAuthFailed");P(R),q.error(R),f(!1)}},[t]);return s.jsxs($e,{title:t("settings.openchamber.passkeys.title"),children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(st,{label:t("settings.openchamber.passkeys.field.currentDevice"),children:[s.jsx(H,{type:"button",variant:r?"secondary":"outline",size:"xs",onClick:()=>{E()},disabled:i||l,className:"!font-normal",children:t(r?"settings.openchamber.passkeys.actions.cancelSetup":"settings.openchamber.passkeys.actions.add")}),s.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:()=>{M()},disabled:i||r||l,className:"!font-normal text-muted-foreground hover:text-foreground",children:t(l?"settings.openchamber.passkeys.actions.signingOut":"settings.openchamber.passkeys.actions.signOutEverywhere")})]}),!I.enabled&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.uiPasswordRequired")}),I.enabled&&!a&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:j.reason}),i?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.loading")}):v.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.noneSaved")}):s.jsx("div",{className:"space-y-1 pt-1",children:v.map(T=>{const R=p===T.id;return s.jsxs(st,{label:R?s.jsx(qe,{value:h,placeholder:T.label,inputSize:"compact",autoFocus:!0,maxLength:120,disabled:b,"aria-label":t("settings.openchamber.passkeys.actions.rename"),onChange:$=>y($.target.value),onBlur:()=>{D(T)},onKeyDown:$=>{$.key==="Enter"?($.preventDefault(),$.currentTarget.blur()):$.key==="Escape"&&($.preventDefault(),K())}}):s.jsx("span",{title:T.label,children:T.label}),alignEnd:!1,controlClassName:"justify-between sm:flex-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:T.lastUsedAt?t("settings.openchamber.passkeys.item.lastUsed",{time:md(T.lastUsedAt,t("settings.openchamber.passkeys.time.neverUsed"),e)}):t("settings.openchamber.passkeys.item.added",{time:md(T.createdAt,t("settings.openchamber.passkeys.time.neverUsed"),e)})}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[!R&&s.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:()=>O(T),disabled:b,"aria-label":t("settings.openchamber.passkeys.actions.rename"),title:t("settings.openchamber.passkeys.actions.rename"),className:"!font-normal text-muted-foreground hover:text-foreground",children:s.jsx(te,{name:"pencil",className:"h-3.5 w-3.5"})}),s.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:()=>{F(T.id)},disabled:u===T.id,className:"!font-normal text-muted-foreground hover:text-foreground",children:u===T.id?t("settings.openchamber.passkeys.actions.removing"):t("settings.common.actions.delete")})]})]},T.id)})})]}),k&&s.jsx("div",{className:"mt-1 py-1.5",children:s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:k})})]})},Pk=()=>{const t=De.c(14),{t:e}=Ee(),a=Kl(Ak),n=Kl(Tk);let i;t[0]!==e?(i=e("settings.openchamber.appLinks.title"),t[0]=e,t[1]=i):i=t[1];let o;t[2]!==e?(o=e("settings.openchamber.appLinks.info"),t[2]=e,t[3]=o):o=t[3];let r;t[4]!==n||t[5]!==e||t[6]!==a?(r=a.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.appLinks.empty")}):a.map(d=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-mono text-[13px]",children:`${d}://`}),s.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:()=>n(d),className:"!font-normal text-muted-foreground hover:text-foreground","aria-label":e("settings.openchamber.appLinks.removeAria",{scheme:`${d}://`}),children:e("settings.common.actions.delete")})]},d)),t[4]=n,t[5]=e,t[6]=a,t[7]=r):r=t[7];let c;t[8]!==r?(c=s.jsx("div",{className:"space-y-1","data-settings-item":"general.app-links",children:r}),t[8]=r,t[9]=c):c=t[9];let u;return t[10]!==i||t[11]!==o||t[12]!==c?(u=s.jsx($e,{title:i,description:o,children:c}),t[10]=i,t[11]=o,t[12]=c,t[13]=u):u=t[13],u};function Ak(t){return t.trustedSchemes}function Tk(t){return t.removeTrustedScheme}const Ek=()=>{const{t}=Ee(),[e,a]=m.useState(null),n=m.useRef(0);m.useEffect(()=>{let o=!1;return Qs.getConfig(null).then(r=>{!o&&n.current===0&&a(!!r.warming)},r=>console.warn("[session-warming] failed to read config",r)),()=>{o=!0}},[]);const i=m.useCallback(async o=>{const r=e,c=++n.current;a(o),Mt("saving");try{const u=await $t("/api/config/warming",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({enabled:o})});if(!u.ok)throw new Error(`HTTP ${u.status}`);Mt("saved"),Qs.clearConfigCache()}catch(u){console.warn("[session-warming] failed to save",u),Mt("error"),c===n.current&&a(r)}},[e]);return s.jsx(ct,{settingsItem:"sessions.warming",checked:e??!1,disabled:e===null,onChange:o=>{i(o)},label:t("settings.openchamber.defaults.field.sessionWarming"),info:t("settings.openchamber.defaults.field.sessionWarmingInfo")})},Xu=30,Mk=/^(\d+(?:\.\d+)?)\s*([a-z]+)$/i,Dk=new Map([...["ms","millis","millisecond","milliseconds"].map(t=>[t,1/6e4]),...["s","second","seconds"].map(t=>[t,1/60]),...["m","minute","minutes"].map(t=>[t,1]),...["h","hour","hours"].map(t=>[t,60])]),Rk=t=>{if(!t)return null;if(t===!0||!t.duration)return Xu;const e=Mk.exec(t.duration.trim()),a=e?Dk.get(e[2].toLowerCase()):void 0;return e&&a?Math.round(Number(e[1])*a):null},Ok=()=>{const{t}=Ee(),e=hi(S=>S.status),a=hi(S=>S.enabled),n=hi(S=>S.minutes),i=hi(S=>S.setMode),o=hi(S=>S.setMinutes),[r,c]=m.useState(null),[u,d]=m.useState(null),[l,f]=m.useState(null),p=m.useRef(0);m.useEffect(()=>{let S=!1;return Qs.getConfig(null).then(v=>{!S&&p.current===0&&c({on:!!v.warming,minutes:Rk(v.warming)})},v=>console.warn("[session-warming] failed to read config",v)),()=>{S=!0}},[]);const g=u??(r===null||e==="loading"?null:r.on?"all":a?"session":"off"),h=l??(g==="all"?r?.minutes??null:n),y=m.useCallback(async(S,v)=>{const A=++p.current;Mt("saving");try{await S(),Mt("saved")}catch(I){console.warn("[session-warming] failed to save",I),Mt("error")}finally{v(A===p.current)}},[]),b=S=>{d(S),y(async()=>{await i(S),Qs.clearConfigCache(),c(v=>({on:S==="all",minutes:v?.minutes??Xu}))},v=>{v&&d(null)})},x=S=>{if(g!=="all"&&g!=="session")return;const v=g;f(S),y(async()=>{await o(v,S),v==="all"&&(Qs.clearConfigCache(),c({on:!0,minutes:S}))},A=>{A&&f(null)})},w=g===null||g==="off"||e==="unavailable";return s.jsxs(s.Fragment,{children:[s.jsx(st,{settingsItem:"sessions.warming",label:t("settings.openchamber.defaults.field.sessionWarming"),info:t("settings.openchamber.defaults.sessionWarming.info"),children:s.jsx(Xt,{"aria-label":t("settings.openchamber.defaults.sessionWarming.aria"),value:g??"off",onChange:S=>{g!==null&&S!==g&&b(S)},options:[{value:"off",label:t("settings.openchamber.defaults.sessionWarming.off"),disabled:g===null},{value:"all",label:t("settings.openchamber.defaults.sessionWarming.all"),disabled:g===null},{value:"session",label:t("settings.openchamber.defaults.sessionWarming.session"),disabled:g===null||e==="unavailable"}]})}),s.jsx(st,{settingsItem:"sessions.warming-duration",label:t("settings.openchamber.defaults.sessionWarming.duration"),children:s.jsx(Xt,{"aria-label":t("settings.openchamber.defaults.sessionWarming.durationAria"),value:h===null?"":String(h),onChange:S=>{const v=Number(S);v!==h&&x(v)},options:Jp.map(S=>({value:String(S),label:t(`settings.openchamber.defaults.sessionWarming.duration.${S}`),disabled:w}))})})]})},Fk={ask:{icon:"shield-user",color:void 0},safety:{icon:"shield-star",color:"var(--status-success)"},auto:{icon:"shield-check",color:"var(--status-info)"}},Lk=t=>{const e=De.c(42),{agentName:a}=t,{t:n}=Ee(),i=re(Kk),o=re(_k),r=Bt(ul),c=Yo(Bt($k));let u;e[0]!==i||e[1]!==r?(u=Qp(i,r),e[0]=i,e[1]=r,e[2]=u):u=e[2];const d=u;let l;e[3]!==o?(l=C=>{o(C),jt({permissionDefaultMode:C})},e[3]=o,e[4]=l):l=e[4];const f=l;let p;e[5]!==a?(p=()=>{const C=a??ft.getState().currentAgentName;C&&Cn.getState().setSelectedAgent(C),re.getState().requestSettingsJump("agents","agents.permissions")},e[5]=a,e[6]=p):p=e[6];const g=p;let h;e[7]!==g||e[8]!==c||e[9]!==r||e[10]!==n?(h=C=>C==="safety"&&!r?s.jsxs(s.Fragment,{children:[n("settings.sessions.permissions.explain.safetyUnavailable")," ",s.jsx(Vn,{onClick:Fo,children:n("settings.jevAccess.setUp")})]}):C==="safety"?s.jsxs(s.Fragment,{children:[c?n("settings.sessions.permissions.explain.safetyVia",{provider:c}):n("settings.sessions.permissions.explain.safety")," ",s.jsx(Vn,{onClick:Fo,children:n("settings.jevAccess.manage")})]}):s.jsxs(s.Fragment,{children:[n(C==="auto"?"settings.sessions.permissions.explain.auto":"settings.sessions.permissions.explain.ask")," ",s.jsx(Vn,{onClick:g,children:n("settings.sessions.permissions.agentPermissionsLink")})]}),e[7]=g,e[8]=c,e[9]=r,e[10]=n,e[11]=h):h=e[11];const y=h;let b;e[12]!==y||e[13]!==r?(b=(C,E)=>{const{icon:F,color:O}=Fk[C];return{value:C,label:s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(te,{name:F,className:"size-3.5",style:O?{color:O}:void 0}),E]}),tooltip:y(C),disabled:C==="safety"&&!r}},e[12]=y,e[13]=r,e[14]=b):b=e[14];const x=b;let w;e[15]!==n?(w=n("settings.sessions.permissions.defaultMode"),e[15]=n,e[16]=w):w=e[16];let S;e[17]!==n?(S=n("settings.sessions.permissions.defaultModeInfo"),e[17]=n,e[18]=S):S=e[18];let v;e[19]!==n?(v=n("settings.sessions.permissions.defaultMode"),e[19]=n,e[20]=v):v=e[20];let A;e[21]!==x||e[22]!==n?(A=[x("ask",n("settings.sessions.permissions.mode.ask")),x("safety",n("settings.sessions.permissions.mode.safety")),x("auto",n("settings.sessions.permissions.mode.auto"))],e[21]=x,e[22]=n,e[23]=A):A=e[23];let I;e[24]!==f||e[25]!==d||e[26]!==v||e[27]!==A?(I=s.jsx(Xt,{"aria-label":v,value:d,onChange:f,options:A}),e[24]=f,e[25]=d,e[26]=v,e[27]=A,e[28]=I):I=e[28];let N;e[29]!==I||e[30]!==w||e[31]!==S?(N=s.jsx(st,{settingsItem:"sessions.permission-default",label:w,info:S,children:I}),e[29]=I,e[30]=w,e[31]=S,e[32]=N):N=e[32];let k;e[33]!==y||e[34]!==d?(k=s.jsx("p",{className:_t,children:y(d)}),e[33]=y,e[34]=d,e[35]=k):k=e[35];let P;e[36]!==r?(P=r?null:s.jsx(Zo,{}),e[36]=r,e[37]=P):P=e[37];let j;return e[38]!==N||e[39]!==k||e[40]!==P?(j=s.jsxs("div",{className:"space-y-1",children:[N,k,P]}),e[38]=N,e[39]=k,e[40]=P,e[41]=j):j=e[41],j};function Kk(t){return t.permissionDefaultMode}function _k(t){return t.setPermissionDefaultMode}function $k(t){return t.classifier?.effective??null}const Nr=t=>{const e=Un(t);return e||{providerId:"",modelId:""}},zk=()=>{const{t}=Ee(),e=ft(oe=>oe.setProvider),a=ft(oe=>oe.setModel),n=ft(oe=>oe.setAgent),i=ft(oe=>oe.setCurrentVariant),o=ft(oe=>oe.setCurrentVariantOverride),r=ft(oe=>oe.setSettingsDefaultModel),c=ft(oe=>oe.setSettingsDefaultVariant),u=ft(oe=>oe.setSettingsDefaultAgent),d=ft(oe=>oe.selectionSource==="manual"),l=Yp(oe=>oe.currentSessionId),f=_l(oe=>oe.getSessionModelSelection),p=_l(oe=>oe.getSessionAgentSelection),g=ft(oe=>oe.agentSelectionSource==="manual"),y=!!(ft(oe=>{if(oe.agentSelectionSource!=="manual")return!1;const pe=oe.agents.find(se=>se.name===oe.currentAgentName);return!!(pe?.model?.providerID&&pe.model.id)})||d&&l&&f(l)),b=!!(g&&l&&p(l)),x=m.useMemo(()=>os(),[]),w=re(oe=>oe.showDeletionDialog),S=re(oe=>oe.setShowDeletionDialog),v=ft(oe=>oe.providers),A=ft(oe=>oe.modelsMetadata),[I,N]=m.useState(),[k,P]=m.useState(),[j,C]=m.useState(),[E,F]=m.useState(!0),[O,K]=m.useState(),D=ah()??[],[M,T]=m.useState(),[R,$]=m.useState(!0),z=m.useMemo(()=>Nr(I),[I]);m.useEffect(()=>{(async()=>{try{const pe=await fn();if(pe){const se=pe.defaultModel?.trim()||void 0,ve=pe.defaultVariant?.trim()||void 0,be=pe.defaultAgent?.trim()||void 0;se!==void 0&&N(se),ve!==void 0&&P(ve),be!==void 0&&C(be),pe.smallModelUseDefault!==void 0&&F(pe.smallModelUseDefault);const ne=pe.smallModelOverride?.trim();ne&&K(ne);const we=pe.walkthroughModelOverride?.trim();we&&T(we)}}catch(pe){console.warn("Failed to load defaults settings:",pe)}finally{$(!1)}})()},[]);const Q=m.useCallback(async(oe,pe)=>{const se=oe&&pe?`${oe}/${pe}`:void 0;N(se),P(void 0),c(void 0),r(se),y||(i(void 0),oe&&pe&&(v.find(be=>be.id===oe)||su(oe,pe))&&(e(oe),a(pe)));try{await jt({defaultModel:se??"",defaultVariant:""})}catch(ve){console.warn("Failed to save default model:",ve)}},[y,v,i,a,e,r,c]),V="__default__",L=m.useCallback(oe=>oe===V?t("settings.openchamber.defaults.option.default"):oe.charAt(0).toUpperCase()+oe.slice(1),[t]),B=m.useCallback(async oe=>{const pe=oe===V?void 0:oe||void 0;P(pe),c(pe),y||o(pe??null,pe);try{await jt({defaultVariant:pe??""})}catch(se){console.warn("Failed to save default variant:",se)}},[y,o,c]),W=m.useCallback(async oe=>{const pe=oe||void 0;C(pe),u(pe),oe&&!b&&n(oe);try{await jt({defaultAgent:pe??""})}catch(se){console.warn("Failed to save default agent:",se)}},[b,n,u]),Y=m.useCallback(async oe=>{F(oe);try{await jt({smallModelUseDefault:oe})}catch(pe){console.warn("Failed to save small model preference:",pe)}},[]),ae=m.useCallback(async(oe,pe)=>{const se=oe&&pe?`${oe}/${pe}`:void 0;K(se);try{await jt({smallModelOverride:se??""})}catch(ve){console.warn("Failed to save small model override:",ve)}},[]),ee=m.useCallback(async(oe,pe)=>{const se=oe&&pe?`${oe}/${pe}`:void 0;T(se);try{await jt({walkthroughModelOverride:se??""})}catch(ve){console.warn("Failed to save walkthrough model override:",ve)}},[]),G=m.useCallback((oe,pe)=>A.get(`${oe}/${pe}`)?.structured_output!==!1,[A]),le=m.useMemo(()=>Nr(O),[O]),J=m.useMemo(()=>Nr(M),[M]),me=m.useMemo(()=>{if(!z.providerId||!z.modelId)return[];const pe=v.find(se=>se.id===z.providerId)?.models.find(se=>se.id===z.modelId);return Zp(pe?.variants)},[z.modelId,z.providerId,v]),fe=me.length>0;return R?null:s.jsxs(s.Fragment,{children:[s.jsxs($e,{title:t("settings.openchamber.defaults.title"),description:s.jsxs(s.Fragment,{children:[t("settings.openchamber.defaults.summaryPrefix")," ",s.jsx("span",{className:"text-foreground",children:z.providerId?`${z.providerId}/${z.modelId}${fe?` (${k??t("settings.openchamber.defaults.option.defaultLowercase")})`:""}`:t("settings.openchamber.defaults.summaryOpenCodeDefault")}),j?s.jsxs(s.Fragment,{children:[" / ",s.jsx("span",{className:"text-foreground",children:j})]}):null]}),divider:!1,contentClassName:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(st,{settingsItem:"sessions.default-model",label:t("settings.openchamber.defaults.field.defaultModel"),children:s.jsx(Fa,{providerId:z.providerId,modelId:z.modelId,onChange:Q,className:an,offerAuto:!0})}),s.jsx(st,{settingsItem:"sessions.default-thinking",label:t("settings.openchamber.defaults.field.defaultThinking"),children:s.jsxs(Pt,{value:k??V,onValueChange:B,disabled:!fe,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.openchamber.defaults.field.thinkingPlaceholder"),children:L(k??V)})}),s.jsxs(It,{children:[s.jsx(bt,{value:V,children:t("settings.openchamber.defaults.option.default")}),me.map(oe=>s.jsx(bt,{value:oe,children:L(oe)},oe))]})]})}),s.jsx(st,{settingsItem:"sessions.default-agent",label:t("settings.openchamber.defaults.field.defaultAgent"),children:s.jsx(al,{agentName:j||"",onChange:W,filter:oe=>Co(oe.mode),className:an})}),x?null:s.jsx(Lk,{agentName:j}),x?null:s.jsx(Ok,{})]}),s.jsxs("div",{className:bs,children:[s.jsx(ct,{settingsItem:"sessions.deletion-dialog",checked:w,onChange:S,label:t("settings.openchamber.defaults.field.showDeletionDialog"),ariaLabel:t("settings.openchamber.defaults.field.showDeletionDialogAria")}),x?s.jsx(Ek,{}):null]})]}),s.jsxs($e,{title:t("settings.layout.sessions.helperModels.title"),contentClassName:"space-y-2",children:[s.jsx(ct,{settingsItem:"sessions.small-model",checked:E,onChange:oe=>{Y(oe)},label:t("settings.openchamber.defaults.smallModel.useDefault"),ariaLabel:t("settings.openchamber.defaults.smallModel.useDefaultAria"),info:t("settings.openchamber.defaults.smallModel.description")}),s.jsxs("div",{children:[E?null:s.jsx(st,{label:t("settings.openchamber.defaults.smallModel.title"),children:s.jsx(Fa,{providerId:le.providerId,modelId:le.modelId,onChange:ae,allowedProviderIds:D,className:an})}),s.jsx(st,{settingsItem:"sessions.walkthrough-model",label:t("settings.openchamber.defaults.walkthroughModel.title"),info:t("settings.openchamber.defaults.walkthroughModel.description"),children:s.jsx(Fa,{providerId:J.providerId,modelId:J.modelId,onChange:ee,allowedProviderIds:D,isModelAllowed:G,placeholder:t("settings.openchamber.defaults.walkthroughModel.usesSmallModel"),className:an})})]})]})]})},pd={completion:{titleKey:"settings.notifications.page.template.defaults.completion.title",messageKey:"settings.notifications.page.template.defaults.completion.message"},error:{titleKey:"settings.notifications.page.template.defaults.error.title",messageKey:"settings.notifications.page.template.defaults.error.message"},question:{titleKey:"settings.notifications.page.template.defaults.question.title",messageKey:"settings.notifications.page.template.defaults.question.message"},subtask:{titleKey:"settings.notifications.page.template.defaults.subtask.title",messageKey:"settings.notifications.page.template.defaults.subtask.message"}},Uk={completion:"settings.notifications.page.template.event.completion",subtask:"settings.notifications.page.template.event.subtask",error:"settings.notifications.page.template.event.error",question:"settings.notifications.page.template.event.question"},Bk=()=>{const{t}=Ee(),e=m.useMemo(()=>is(),[]),a=m.useMemo(()=>os(),[]),n=m.useMemo(()=>typeof window>"u"?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",[]),i=!e&&!a&&!n,o=re(L=>L.nativeNotificationsEnabled),r=re(L=>L.setNativeNotificationsEnabled),c=re(L=>L.notificationMode),u=re(L=>L.setNotificationMode),d=re(L=>L.notifyOnSubtasks),l=re(L=>L.setNotifyOnSubtasks),f=re(L=>L.notifyOnCompletion),p=re(L=>L.setNotifyOnCompletion),g=re(L=>L.notifyOnError),h=re(L=>L.setNotifyOnError),y=re(L=>L.notifyOnQuestion),b=re(L=>L.setNotifyOnQuestion),x=re(L=>L.notificationTemplates),w=re(L=>L.setNotificationTemplates),[S,v]=m.useState("default"),[A,I]=m.useState(!1),[N,k]=m.useState(!1),[P,j]=m.useState(!1),C=Hi(P);m.useEffect(()=>{if(!i){I(!1),k(!1);return}typeof Notification<"u"&&v(Notification.permission);const L=typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window;I(L),(async()=>{if(!L){k(!1);return}try{const W=await navigator.serviceWorker.getRegistration();if(!W){k(!1);return}const Y=await W.pushManager.getSubscription();k(!!Y)}catch{k(!1)}})()},[i]);const E=async L=>{if(e){r(L);return}if(!i){r(L);return}if(L&&typeof Notification<"u"&&Notification.permission==="default")try{const B=await Notification.requestPermission();v(B),B==="granted"?r(!0):q.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.description")})}catch(B){console.error("Failed to request notification permission:",B),q.error(t("settings.notifications.page.toast.requestPermissionFailed"))}else r(!!(L&&S==="granted"))},F=e||a||n||i&&typeof Notification<"u"&&Notification.permission==="granted",O=(L,B,W)=>{w(Y=>({...Y,[L]:{...Y[L],[B]:W}}))},K=L=>{const B="=".repeat((4-L.length%4)%4),W=(L+B).replace(/-/g,"+").replace(/_/g,"/"),Y=atob(W),ae=new Uint8Array(Y.length);for(let ee=0;ee<Y.length;ee+=1)ae[ee]=Y.charCodeAt(ee);return ae},D=async(L,B,W)=>{let Y=null;const ae=new Promise((ee,G)=>{Y=setTimeout(()=>{G(new Error(W))},B)});try{return await Promise.race([L,ae])}finally{Y&&clearTimeout(Y)}},M=async L=>{if(L.active)return;const B=L.installing||L.waiting;B&&B.state!=="activated"&&await D(new Promise(W=>{const Y=()=>{B.state==="activated"&&(B.removeEventListener("statechange",Y),W())};B.addEventListener("statechange",Y),Y()}),15e3,"Service worker activation timed out")},T=async()=>{if(typeof navigator.serviceWorker.register!="function")throw new Error("navigator.serviceWorker.register unavailable");const L=[{label:"no-options",opts:null},{label:"scope-root",opts:{scope:"/"}},{label:"type-classic",opts:{type:"classic"}},{label:"type-classic-scope",opts:{type:"classic",scope:"/"}},{label:"updateViaCache-none",opts:{type:"classic",updateViaCache:"none",scope:"/"}}];let B=null;for(const W of L)try{const Y=W.opts?navigator.serviceWorker.register("/sw.js",W.opts):navigator.serviceWorker.register("/sw.js");return await D(Y,1e4,`Service worker registration timed out (${W.label})`)}catch(Y){B=Y}throw B instanceof Error?B:new Error("Service worker registration failed")},R=async()=>{if(!("serviceWorker"in navigator))throw new Error("Service worker not supported");const L=await navigator.serviceWorker.getRegistration();if(L)return L;const B=await T();try{await B.update()}catch{}return await M(B),B},$=L=>{const B=L,W=[`type=${typeof L}`,`toString=${String(L)}`,`name=${String(B?.name??"")}`,`message=${String(B?.message??"")}`];let Y="";try{Y=JSON.stringify(L)}catch{}return{summary:W.filter(Boolean).join(" | "),json:Y,stack:typeof B?.stack=="string"?B.stack:""}},z=async()=>{const L=_a();if(!L?.notifications){q.error(t("settings.notifications.page.toast.notificationsApiUnavailable"));return}try{await L.notifications.notifyAgentCompletion({title:t("settings.notifications.page.testNotification.title"),body:t("settings.notifications.page.testNotification.body"),tag:"openchamber-test"})?q.success(t("settings.notifications.page.toast.testNotificationSent")):q.error(t("settings.notifications.page.toast.testNotificationFailed"))}catch(B){console.error("Test notification failed:",B),q.error(t("settings.notifications.page.toast.testNotificationFailed"))}},Q=async()=>{if(!A){q.error(t("settings.notifications.page.toast.pushUnsupported"));return}const L=_a();if(!L?.push){q.error(t("settings.notifications.page.toast.pushApiUnavailable"));return}j(!0);try{if(typeof Notification<"u"&&Notification.permission==="default"){const J=await Notification.requestPermission();if(v(J),J!=="granted"){q.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}}if(typeof Notification<"u"&&Notification.permission!=="granted"){q.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}const B=await L.push.getVapidPublicKey();if(!B?.publicKey){q.error(t("settings.notifications.page.toast.pushKeyLoadFailed"));return}const W=await R();await M(W);const Y=await W.pushManager.getSubscription();if(!("pushManager"in W)||!W.pushManager)throw new Error("PushManager unavailable (requires installed PWA + iOS 16.4+)");const ee=(Y??await D(W.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:K(B.publicKey)}),15e3,"Push subscription timed out")).toJSON(),G=ee.keys;if(!ee.endpoint||!G?.p256dh||!G.auth)throw new Error("Push subscription missing keys");if(!(await D(L.push.subscribe({endpoint:ee.endpoint,keys:{p256dh:G.p256dh,auth:G.auth},origin:typeof window<"u"?window.location.origin:void 0,platform:Fg()}),15e3,"Push subscribe request timed out"))?.ok){q.error(t("settings.notifications.page.toast.enableBackgroundFailed"));return}k(!0),q.success(t("settings.notifications.page.toast.backgroundEnabled"))}catch(B){console.error("[Push] Enable failed:",B);const W=$(B);q.error(t("settings.notifications.page.toast.enableBackgroundFailed"),{description:W.summary})}finally{j(!1)}},V=async()=>{if(!A){k(!1);return}const L=_a();if(!L?.push){q.error(t("settings.notifications.page.toast.pushApiUnavailable"));return}j(!0);try{const W=await(await R()).pushManager.getSubscription();if(!W){k(!1);return}const Y=W.endpoint;await W.unsubscribe(),await L.push.unsubscribe({endpoint:Y}),k(!1),q.success(t("settings.notifications.page.toast.backgroundDisabled"))}finally{j(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs($e,{settingsItem:"notifications.delivery",title:t("settings.notifications.page.delivery.title"),divider:!1,children:[s.jsxs("div",{className:bs,children:[s.jsx(ct,{checked:o&&F,onChange:L=>{E(L)},label:t("settings.notifications.page.delivery.enableLabel"),info:i?t("settings.notifications.page.delivery.browserPermissionHint"):a?t("settings.notifications.page.delivery.vscodeHint"):void 0,ariaLabel:t("settings.notifications.page.delivery.enableAria")}),o&&F&&!n&&s.jsxs(s.Fragment,{children:[s.jsx(ct,{checked:c==="always",onChange:L=>u(L?"always":"hidden-only"),label:t("settings.notifications.page.delivery.focusedLabel"),ariaLabel:t("settings.notifications.page.delivery.focusedAria")}),s.jsx("div",{className:"py-2",children:s.jsx(H,{type:"button",variant:"outline",size:"sm",onClick:()=>{z()},children:t("settings.notifications.page.delivery.testAction")})})]})]}),i&&s.jsxs("div",{className:"mt-1",children:[S==="denied"&&s.jsx("p",{className:"typography-meta text-[var(--status-error)] mt-1",children:t("settings.notifications.page.delivery.permissionDenied")}),S==="granted"&&!o&&s.jsx("p",{className:"typography-meta text-muted-foreground/70 mt-1",children:t("settings.notifications.page.delivery.permissionGrantedButDisabled")})]})]}),o&&F&&s.jsxs(s.Fragment,{children:[s.jsx($e,{settingsItem:"notifications.events",title:t("settings.notifications.page.events.title"),children:s.jsxs("div",{className:bs,children:[s.jsx(ct,{checked:f,onChange:p,label:t("settings.notifications.page.events.completionLabel"),ariaLabel:t("settings.notifications.page.events.completionAria")}),s.jsx(ct,{checked:d,onChange:l,label:t("settings.notifications.page.events.subtaskLabel"),ariaLabel:t("settings.notifications.page.events.subtaskAria")}),s.jsx(ct,{checked:g,onChange:h,label:t("settings.notifications.page.events.errorLabel"),ariaLabel:t("settings.notifications.page.events.errorAria")}),s.jsx(ct,{checked:y,onChange:b,label:t("settings.notifications.page.events.questionLabel"),ariaLabel:t("settings.notifications.page.events.questionAria")})]})}),!n&&s.jsx($e,{title:t("settings.notifications.page.template.title"),description:s.jsxs(s.Fragment,{children:[t("settings.notifications.page.template.variablesLabel")," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{project_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{worktree}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{branch}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{session_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{agent_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{model_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{last_message}"})]}),children:s.jsx(ma,{className:"gap-2 md:grid-cols-2 md:gap-3 lg:gap-3",children:["completion","subtask","error","question"].map(L=>s.jsxs("section",{className:"p-2",children:[s.jsx($a,{className:"capitalize",children:t(Uk[L])}),s.jsxs("div",{className:"mt-1.5 space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:t("settings.notifications.page.template.field.title")}),s.jsx(qe,{value:x[L].title,onChange:B=>O(L,"title",B.target.value),className:"h-7",placeholder:t(pd[L].titleKey)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:t("settings.notifications.page.template.field.message")}),s.jsx(qe,{value:x[L].message,onChange:B=>O(L,"message",B.target.value),className:"h-7",placeholder:t(pd[L].messageKey)})]})]})]},L))})})]}),i&&s.jsx($e,{settingsItem:"notifications.push",title:t("settings.notifications.page.push.title"),children:s.jsx(ct,{checked:A?N:!1,disabled:!A||P,onChange:L=>{L?Q():V()},label:t("settings.notifications.page.push.enableLabel"),description:A?void 0:t("settings.notifications.page.push.unsupportedHint"),info:A?t("settings.notifications.page.push.supportedHint"):void 0,ariaLabel:t("settings.notifications.page.push.enableAria"),labelAccessory:P?s.jsx("span",{className:ze("inline-block h-1.5 w-1.5 rounded-full bg-current text-muted-foreground",C),"aria-label":t("settings.notifications.page.push.loadingAria")}):null})})]})},Rs=t=>{if(!t)return;t.pause();const{src:e}=t;e.startsWith("blob:")&&URL.revokeObjectURL(e),t.removeAttribute("src"),t.load()},pa="oc-surface-elevated oc-raised oc-field w-full min-w-0 h-8 rounded-md bg-surface-elevated px-3 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none",Vk=[{id:"parakeet-tdt-0.6b-v2-int8",labelKey:"settings.voice.page.stt.model.parakeetV2",badgeKey:"settings.voice.page.stt.badge.bestForEnglish",accuracy:5,speed:5,size:"460 MB"},{id:"parakeet-tdt-0.6b-v3-int8",labelKey:"settings.voice.page.stt.model.parakeetV3",badgeKey:"settings.voice.page.stt.badge.bestForMultilingual",accuracy:5,speed:4,size:"465 MB"},{id:"whisper-base-int8",labelKey:"settings.voice.page.stt.model.whisperBase",badgeKey:null,accuracy:3,speed:3,size:"200 MB"},{id:"whisper-tiny-int8",labelKey:"settings.voice.page.stt.model.whisperTiny",badgeKey:null,accuracy:2,speed:4,size:"115 MB"}],gd=t=>{const e=De.c(8),{value:a,label:n}=t,i=`${n}: ${a}/5`;let o;e[0]!==n?(o=s.jsx("span",{className:"typography-micro text-muted-foreground",children:n}),e[0]=n,e[1]=o):o=e[1];const r=`${a/5*100}%`;let c;e[2]!==r?(c=s.jsx("span",{className:"h-1.5 w-8 flex-shrink-0 overflow-hidden rounded-full bg-[var(--interactive-border)]","aria-hidden":"true",children:s.jsx("span",{className:"block h-full rounded-full bg-[var(--primary-base)]",style:{width:r}})}),e[2]=r,e[3]=c):c=e[3];let u;return e[4]!==i||e[5]!==o||e[6]!==c?(u=s.jsxs("span",{className:"flex items-center gap-1.5",title:i,children:[o,c]}),e[4]=i,e[5]=o,e[6]=c,e[7]=u):u=e[7],u},Hk=({selectedModelId:t,onSelect:e})=>{const{t:a}=Ee(),n=Ke.useCallback(p=>a(p),[a]),[i,o]=Ke.useState(new Map),[r,c]=Ke.useState(null),u=Ke.useCallback(async()=>{try{const p=await $t("/api/dictation/status",{query:{provider:"local"}});if(!p.ok)return;const g=await p.json();Array.isArray(g?.models)&&o(new Map(g.models.map(h=>[h.id,h])))}catch{}},[]);Ke.useEffect(()=>{u()},[u]);const d=Array.from(i.values()).some(p=>p.downloading);Ke.useEffect(()=>{if(!d)return;const p=setInterval(()=>{u()},2e3);return()=>clearInterval(p)},[d,u]);const l=async p=>{c(p);try{await $t(`/api/dictation/models/${encodeURIComponent(p)}/download`,{method:"POST"}),await u()}catch{}finally{c(null)}},f=async p=>{c(p);try{await $t(`/api/dictation/models/${encodeURIComponent(p)}`,{method:"DELETE"}),await u()}catch{}finally{c(null)}};return s.jsx("div",{role:"radiogroup","aria-label":a("settings.voice.page.field.model"),className:"grid w-full grid-cols-1 gap-2 @3xl:grid-cols-2",children:Vk.map(p=>{const g=t===p.id,h=i.get(p.id)??null;return s.jsxs("div",{className:ze("flex items-start gap-2 rounded-lg px-3 py-2.5",g?"bg-interactive-selection text-interactive-selection-foreground":"oc-tile"),children:[s.jsxs("div",{className:"flex min-w-0 flex-1 cursor-pointer items-start gap-2",role:"button",tabIndex:0,onClick:()=>e(p.id),onKeyDown:y=>{(y.key===" "||y.key==="Enter")&&(y.preventDefault(),e(p.id))},children:[s.jsx("div",{className:"pt-0.5",children:s.jsx(il,{checked:g,onChange:()=>e(p.id),ariaLabel:n(p.labelKey)})}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("div",{className:"typography-ui-label truncate text-foreground",title:n(p.labelKey),children:n(p.labelKey)}),p.badgeKey?s.jsx("span",{className:"inline-block rounded-full bg-[var(--status-success)]/15 px-2 py-px text-[10px] font-medium text-[var(--status-success)]",children:n(p.badgeKey)}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsx(gd,{value:p.accuracy,label:a("settings.voice.page.stt.meta.accuracy")}),s.jsx(gd,{value:p.speed,label:a("settings.voice.page.stt.meta.speed")}),s.jsx("span",{className:"typography-micro tabular-nums text-muted-foreground",children:p.size})]}),h?.downloadError?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:h.downloadError}):null]})]}),s.jsx("div",{className:"flex h-6 shrink-0 items-center gap-1",children:h?.installed?s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"checkbox-circle",className:"h-4 w-4 flex-shrink-0 text-[var(--status-success)]","aria-label":a("settings.voice.page.stt.modelInstalled")}),s.jsx(H,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]",disabled:r===p.id,onClick:()=>{f(p.id)},title:a("settings.voice.page.stt.modelDelete"),"aria-label":a("settings.voice.page.stt.modelDelete"),children:s.jsx(te,{name:"delete-bin",className:"h-4 w-4"})})]}):h?.downloading?s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(va,{className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:typeof h.downloadProgress=="number"?`${h.downloadProgress}%`:""})]}):s.jsx(H,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0",disabled:r===p.id,onClick:()=>{l(p.id)},title:a("settings.voice.page.stt.modelDownload"),"aria-label":a("settings.voice.page.stt.modelDownload"),children:s.jsx(te,{name:"download",className:"h-4 w-4"})})})]},p.id)})})},qk=[{id:0,label:"Alloy (af)"},{id:1,label:"Bella (af)"},{id:2,label:"Nicole (af)"},{id:3,label:"Sarah (af)"},{id:4,label:"Sky (af)"},{id:5,label:"Adam (am)"},{id:6,label:"Michael (am)"},{id:7,label:"Emma (bf)"},{id:8,label:"Isabella (bf)"},{id:9,label:"George (bm)"},{id:10,label:"Lewis (bm)"}],Xr="kokoro-en-v0_19",Wk="kokoro-multi-lang-v1_1",Gk=[{id:0,label:"Maple (af)"},{id:1,label:"Sol (af)"},{id:2,label:"Vale (bf)"},{id:3,label:"Xiaoxiao (zf)"},{id:58,label:"Yunxi (zm)"}],wi=(t,e)=>`${t}:${e}`,Jk=()=>{const[t,e]=Ke.useState([]),[a,n]=Ke.useState(null),i=Ke.useCallback(async()=>{try{const c=await $t("/api/dictation/status",{query:{provider:"local"}});if(!c.ok)return;const u=await c.json();Array.isArray(u?.ttsModels)&&e(u.ttsModels)}catch{}},[]);Ke.useEffect(()=>{i()},[i]);const o=t.some(c=>c.downloading);Ke.useEffect(()=>{if(!o)return;const c=setInterval(()=>{i()},2e3);return()=>clearInterval(c)},[o,i]);const r=Ke.useCallback(async(c,u)=>{n(c);try{const d=u==="POST"?`/api/dictation/models/${c}/download`:`/api/dictation/models/${c}`;await $t(d,{method:u}),await i()}catch{}finally{n(null)}},[i]);return{models:t,requestingId:a,request:r,refresh:i}},Qk=t=>{const e=qk.map(a=>({modelId:Xr,speakerId:a.id,label:a.label}));for(const a of t)if(!(a.id===Xr||!a.installed)){if(a.id===Wk){for(const n of Gk)e.push({modelId:a.id,speakerId:n.id,label:`${n.label} · Kokoro zh/en`});continue}e.push({modelId:a.id,speakerId:0,label:a.description??a.id})}return e},fd=t=>{const e=De.c(16),{model:a,requestingId:n,request:i,t:o}=t,r=a.description??a.id;let c;e[0]!==r?(c=s.jsx("span",{className:"typography-ui-label text-foreground",children:r}),e[0]=r,e[1]=c):c=e[1];let u;e[2]!==a.downloadProgress||e[3]!==a.downloading||e[4]!==a.id||e[5]!==a.installed||e[6]!==i||e[7]!==n||e[8]!==o?(u=a.installed?s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"checkbox-circle",className:"h-4 w-4 text-[var(--status-success)]","aria-label":o("settings.voice.page.stt.modelInstalled")}),s.jsx(H,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]",disabled:n!==null,onClick:()=>{i(a.id,"DELETE")},title:o("settings.voice.page.stt.modelDelete"),"aria-label":o("settings.voice.page.stt.modelDelete"),children:s.jsx(te,{name:"delete-bin",className:"h-4 w-4"})})]}):a.downloading?s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(va,{className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:typeof a.downloadProgress=="number"?`${a.downloadProgress}%`:""})]}):s.jsx(H,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0",disabled:n!==null,onClick:()=>{i(a.id,"POST")},title:o("settings.voice.page.stt.modelDownload"),"aria-label":o("settings.voice.page.stt.modelDownload"),children:s.jsx(te,{name:"download",className:"h-4 w-4"})}),e[2]=a.downloadProgress,e[3]=a.downloading,e[4]=a.id,e[5]=a.installed,e[6]=i,e[7]=n,e[8]=o,e[9]=u):u=e[9];let d;e[10]!==a.downloadError?(d=a.downloadError?s.jsx("span",{className:"typography-meta text-[var(--status-error)]",children:a.downloadError}):null,e[10]=a.downloadError,e[11]=d):d=e[11];let l;return e[12]!==c||e[13]!==u||e[14]!==d?(l=s.jsxs("div",{className:"flex items-center gap-2 py-1.5",children:[c,u,d]}),e[12]=c,e[13]=u,e[14]=d,e[15]=l):l=e[15],l},Yk=t=>{const e=De.c(21),{models:a,requestingId:n,request:i}=t,{t:o}=Ee(),[r,c]=Ke.useState(!1),[u,d]=Ke.useState("");if(a.length===0)return null;let l,f,p;if(e[0]!==u||e[1]!==a){f=[],l=[];for(const w of a)w.id===Xr||w.installed||w.downloading||w.downloadError?f.push(w):l.push(w);const x=u.trim().toLowerCase();p=x?l.filter(w=>(w.description??"").toLowerCase().includes(x)||w.id.toLowerCase().includes(x)):l,e[0]=u,e[1]=a,e[2]=l,e[3]=f,e[4]=p}else l=e[2],f=e[3],p=e[4];const g=p;let h;e[5]!==f||e[6]!==i||e[7]!==n||e[8]!==o?(h=f.map(x=>s.jsx(fd,{model:x,requestingId:n,request:i,t:o},x.id)),e[5]=f,e[6]=i,e[7]=n,e[8]=o,e[9]=h):h=e[9];let y;e[10]!==l.length||e[11]!==r||e[12]!==u||e[13]!==g||e[14]!==i||e[15]!==n||e[16]!==o?(y=l.length>0?s.jsxs(ha,{open:r,onOpenChange:c,children:[s.jsxs(ba,{className:"group flex w-full items-center justify-between py-1 hover:bg-transparent",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-start",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:o("settings.voice.page.localTts.availableToDownload")}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",l.length,")"]})]}),s.jsx(te,{name:r?"arrow-down-s":"arrow-right-s",className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]}),s.jsxs(xa,{className:"pt-1",children:[s.jsx("input",{type:"text",value:u,onChange:x=>d(x.target.value),placeholder:o("settings.voice.page.localTts.filterPlaceholder"),"aria-label":o("settings.voice.page.localTts.filterPlaceholder"),className:ze(pa,"mb-1")}),g.length===0?s.jsx("div",{className:"typography-meta py-1.5 text-muted-foreground",children:o("settings.voice.page.localTts.filterNoMatch")}):g.map(x=>s.jsx(fd,{model:x,requestingId:n,request:i,t:o},x.id))]})]}):null,e[10]=l.length,e[11]=r,e[12]=u,e[13]=g,e[14]=i,e[15]=n,e[16]=o,e[17]=y):y=e[17];let b;return e[18]!==h||e[19]!==y?(b=s.jsxs("div",{className:"flex flex-col",children:[h,y]}),e[18]=h,e[19]=y,e[20]=b):b=e[20],b},hd=[{value:"alloy",label:"Alloy"},{value:"ash",label:"Ash"},{value:"ballad",label:"Ballad"},{value:"coral",label:"Coral"},{value:"echo",label:"Echo"},{value:"fable",label:"Fable"},{value:"nova",label:"Nova"},{value:"onyx",label:"Onyx"},{value:"sage",label:"Sage"},{value:"shimmer",label:"Shimmer"},{value:"verse",label:"Verse"},{value:"marin",label:"Marin"},{value:"cedar",label:"Cedar"}],Cr=t=>{const e=De.c(34),{kind:a}=t,{t:n}=Ee();let i;e[0]!==a?(i=N=>N.voiceApiKeys[a],e[0]=a,e[1]=i):i=e[1];const o=ft(i),r=ft(Xk),[c,u]=Ke.useState(""),[d,l]=Ke.useState(!1);let f;e[2]!==a||e[3]!==r||e[4]!==n?(f=async N=>{l(!0);const k=await r(a,N);l(!1),k?u(""):q.error(n("settings.voice.page.toast.apiKeySaveFailed"))},e[2]=a,e[3]=r,e[4]=n,e[5]=f):f=e[5];const p=f;let g;e[6]!==c||e[7]!==p?(g=()=>{const N=c.trim();N&&p(N)},e[6]=c,e[7]=p,e[8]=g):g=e[8];const h=g;let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=ze("relative",rn),e[9]=y):y=e[9];let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=N=>u(N.target.value),e[10]=b):b=e[10];let x;e[11]!==h?(x=N=>{N.key==="Enter"&&h()},e[11]=h,e[12]=x):x=e[12];let w;e[13]!==o||e[14]!==n?(w=o?n("settings.voice.page.field.apiKeySavedPlaceholder"):"sk-...",e[13]=o,e[14]=n,e[15]=w):w=e[15];let S;e[16]!==n?(S=n("settings.voice.page.field.apiKey"),e[16]=n,e[17]=S):S=e[17];let v;e[18]!==h||e[19]!==c||e[20]!==d||e[21]!==x||e[22]!==w||e[23]!==S?(v=s.jsx("input",{type:"password",value:c,disabled:d,onChange:b,onBlur:h,onKeyDown:x,placeholder:w,className:pa,"aria-label":S}),e[18]=h,e[19]=c,e[20]=d,e[21]=x,e[22]=w,e[23]=S,e[24]=v):v=e[24];let A;e[25]!==c||e[26]!==d||e[27]!==p||e[28]!==o||e[29]!==n?(A=o&&!c&&s.jsx("button",{type:"button",onClick:()=>{p(null)},disabled:d,"aria-label":n("settings.voice.page.field.apiKeyRemove"),className:"absolute inset-e-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(te,{name:"close",className:"w-3.5 h-3.5"})}),e[25]=c,e[26]=d,e[27]=p,e[28]=o,e[29]=n,e[30]=A):A=e[30];let I;return e[31]!==A||e[32]!==v?(I=s.jsxs("div",{className:y,children:[v,A]}),e[31]=A,e[32]=v,e[33]=I):I=e[33],I},Zk=()=>{const{t}=Ee(),{isMobile:e}=Zs(),a=ft(Z=>Z.voiceProvider),n=ft(Z=>Z.setVoiceProvider),i=ft(Z=>Z.speechRate),o=ft(Z=>Z.setSpeechRate),r=ft(Z=>Z.speechPitch),c=ft(Z=>Z.setSpeechPitch),u=ft(Z=>Z.speechVolume),d=ft(Z=>Z.setSpeechVolume),l=ft(Z=>Z.sayVoice),f=ft(Z=>Z.setSayVoice),p=ft(Z=>Z.localTtsVoiceId),g=ft(Z=>Z.localTtsModelId),h=ft(Z=>Z.setLocalTtsModelId),y=Jk(),b=Ke.useMemo(()=>Qk(y.models),[y.models]),x=ft(Z=>Z.ttsFollowTextLanguage),w=ft(Z=>Z.setTtsFollowTextLanguage),S=ft(Z=>Z.setLocalTtsVoiceId),{speak:v,stop:A,isPlaying:I,error:N}=Xp(),k=Ke.useCallback(()=>{if(I){A();return}const Z=b.find(Oe=>Oe.modelId===g&&Oe.speakerId===p)?.label??String(p);v(t("settings.voice.page.preview.voiceLine",{voiceName:Z}),{model:g,speakerId:p,speed:ft.getState().speechRate})},[I,g,p,b,v,A,t]),P=ft(Z=>Z.browserVoice),j=ft(Z=>Z.setBrowserVoice),C=ft(Z=>Z.openaiVoice),E=ft(Z=>Z.setOpenaiVoice),F=ft(Z=>Z.voiceApiKeys.openai),O=ft(Z=>Z.refreshVoiceApiKeys),K=ft(Z=>Z.openaiCompatibleUrl),D=ft(Z=>Z.setOpenaiCompatibleUrl),M=ft(Z=>Z.openaiCompatibleVoice),T=ft(Z=>Z.setOpenaiCompatibleVoice),R=ft(Z=>Z.openaiCompatibleTtsModel),$=ft(Z=>Z.setOpenaiCompatibleTtsModel),z=ft(Z=>Z.showMessageTTSButtons),Q=ft(Z=>Z.ttsInputMode),V=ft(Z=>Z.setTtsInputMode),L=ft(Z=>Z.ttsChunkedMode),B=ft(Z=>Z.setTtsChunkedMode),W=ft(Z=>Z.sttProvider),Y=ft(Z=>Z.setSttProvider),ae=ft(Z=>Z.sttServerUrl),ee=ft(Z=>Z.setSttServerUrl),G=ft(Z=>Z.sttModel),le=ft(Z=>Z.setSttModel),J=ft(Z=>Z.sttLocalModel),me=ft(Z=>Z.setSttLocalModel),fe=ft(Z=>Z.sttLanguage),oe=ft(Z=>Z.setSttLanguage),pe=ft(Z=>Z.setShowMessageTTSButtons),se=ft(Z=>Z.dictationEnabled),ve=ft(Z=>Z.setDictationEnabled),[be,ne]=Ke.useState(!1),[we,Ne]=Ke.useState([]),[Ie,Ce]=Ke.useState(!1),[Me,he]=Ke.useState(null),[Pe,Re]=Ke.useState(!1),[ce,je]=Ke.useState(!1),[de,ie]=Ke.useState(!1),[xe,Se]=Ke.useState(null),[Le,Ue]=Ke.useState(!1),[Ye,lt]=Ke.useState(null),[at,ut]=Ke.useState([]),[vt,We]=Ke.useState(!1);Ke.useEffect(()=>((async()=>{const Oe=await ir.waitForVoices();ut(Oe)})(),"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=()=>{ut(window.speechSynthesis.getVoices())}),()=>{"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);const Ze=Ke.useMemo(()=>at.filter(Z=>Z.lang).sort((Z,Oe)=>{const Ve=Z.lang.startsWith("en"),X=Oe.lang.startsWith("en");if(Ve&&!X)return-1;if(!Ve&&X)return 1;const _e=Z.lang.localeCompare(Oe.lang);return _e!==0?_e:Z.name.localeCompare(Oe.name)}),[at]),Xe=Ke.useCallback(()=>{if(vt){ir.cancelSpeech(),We(!1);return}const Z=at.find(_e=>_e.name===P),Oe=Z?.name??t("settings.voice.page.preview.browserVoiceFallback"),Ve=t("settings.voice.page.preview.voiceLine",{voiceName:Oe});We(!0);const X=new SpeechSynthesisUtterance(Ve);X.rate=i,X.pitch=r,X.volume=u,Z&&(X.voice=Z,X.lang=Z.lang),X.onend=()=>We(!1),X.onerror=()=>We(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(X)},[P,at,i,r,u,vt,t]);Ke.useEffect(()=>()=>{vt&&ir.cancelSpeech()},[vt]),Ke.useEffect(()=>{O({force:!0})},[O]),Ke.useEffect(()=>{if(!z||a!=="openai"&&a!=="openai-compatible"){Re(F);return}(async()=>{try{const Ve=await(await $t("/api/tts/status")).json(),X=Ve.available,_e=F,nt=Ve.enterpriseMode===!0;je(nt),Re(!nt&&(X||_e))}catch{Re(F)}})()},[F,z,a]),Ke.useEffect(()=>{if(!z){ne(!1),Ne([]);return}$t("/api/tts/say/status").then(Z=>Z.json()).then(Z=>{if(ne(Z.available),Z.voices){const Oe=Z.voices.filter((Ve,X,_e)=>_e.findIndex(nt=>nt.name===Ve.name)===X).sort((Ve,X)=>Ve.name.localeCompare(X.name));Ne(Oe)}}).catch(()=>{ne(!1)})},[z]);const it=Ke.useCallback(async()=>{if(Me){Rs(Me),he(null),Ce(!1);return}Ce(!0);let Z=null;try{const Oe=await $t("/api/tts/say/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.voiceLine",{voiceName:l}),voice:l,rate:Math.round(100+(i-.5)*200)})});if(!Oe.ok)throw new Error("Preview failed");const Ve=await Oe.blob(),X=URL.createObjectURL(Ve);Z=new Audio(X),Z.onended=()=>{Rs(Z),he(null),Ce(!1)},Z.onerror=()=>{Rs(Z),he(null),Ce(!1)},he(Z),await Z.play()}catch{Rs(Z),he(null),Ce(!1)}},[l,i,Me,t]);Ke.useEffect(()=>()=>{Rs(Me)},[Me]);const dt=Ke.useCallback(async()=>{if(xe){Rs(xe),Se(null),ie(!1);return}ie(!0);let Z=null;try{const Oe=await $t("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.voiceLine",{voiceName:C}),voice:C,speed:i})});if(!Oe.ok){const _e=await Oe.json().catch(()=>({error:"Unknown error"}));throw new Error(_e.error||`HTTP ${Oe.status}`)}const Ve=await Oe.blob(),X=URL.createObjectURL(Ve);Z=new Audio(X),Z.onended=()=>{Rs(Z),Se(null),ie(!1)},Z.onerror=()=>{Rs(Z),Se(null),ie(!1)},Se(Z),await Z.play()}catch{Rs(Z),Se(null),ie(!1)}},[C,i,xe,t]);Ke.useEffect(()=>()=>{Rs(xe)},[xe]);const Be=Ke.useCallback(async()=>{if(Ye){Rs(Ye),lt(null),Ue(!1);return}if(!K.trim())return;Ue(!0);let Z=null;try{const Oe=await $t("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.customServerLine"),voice:M,model:R||void 0,speed:i,baseURL:K})});if(!Oe.ok){const _e=await Oe.json().catch(()=>({error:"Unknown error"}));throw new Error(_e.error||`HTTP ${Oe.status}`)}const Ve=await Oe.blob(),X=URL.createObjectURL(Ve);Z=new Audio(X),Z.onended=()=>{Rs(Z),lt(null),Ue(!1)},Z.onerror=()=>{Rs(Z),lt(null),Ue(!1)},lt(Z),await Z.play()}catch{Rs(Z),lt(null),Ue(!1)}},[K,M,R,i,Ye,t]);Ke.useEffect(()=>()=>{Rs(Ye)},[Ye]);const ot="w-40 flex-none h-1.5 bg-[var(--interactive-border)] rounded-full appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:border-0 disabled:opacity-50",et="typography-ui-label w-12 shrink-0 text-end tabular-nums text-muted-foreground",ye=Z=>Z?s.jsx(te,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx(te,{name:"play",className:"w-3.5 h-3.5"});return s.jsxs(s.Fragment,{children:[s.jsxs($e,{settingsItem:"voice.playback",title:t("settings.voice.page.section.playbackAndSummary"),divider:!1,contentClassName:"space-y-3",children:[s.jsx(ct,{checked:z,onChange:pe,label:t("settings.voice.page.field.messageReadAloudButton"),ariaLabel:t("settings.voice.page.field.messageReadAloudButtonAria")}),z&&s.jsxs(s.Fragment,{children:[s.jsx(st,{label:t("settings.voice.page.field.provider"),info:s.jsxs("ul",{className:"space-y-1",children:[s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.browser")})," ",t("settings.voice.page.tooltip.browser")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.local")})," ",t("settings.voice.page.tooltip.localTts")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.openai")})," ",t("settings.voice.page.tooltip.openai")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.custom")})," ",t("settings.voice.page.tooltip.custom")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.say")})," ",t("settings.voice.page.tooltip.say")]})]}),children:s.jsx(Xt,{value:a,onChange:n,"aria-label":t("settings.voice.page.field.provider"),options:[{value:"browser",label:t("settings.voice.page.provider.browser")},{value:"local",label:t("settings.voice.page.provider.local")},{value:"openai",label:t("settings.voice.page.provider.openai")},{value:"openai-compatible",label:t("settings.voice.page.provider.custom")},...be?[{value:"say",label:s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"apple",className:"me-0.5 h-3.5 w-3.5"}),t("settings.voice.page.provider.say")]})}]:[]]})}),ce&&(a==="openai"||a==="openai-compatible")&&s.jsx("p",{className:_t,children:t("settings.voice.page.enterpriseMode")}),a==="openai"&&s.jsx(St,{label:s.jsx("span",{className:ze(!Pe&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.apiKey")}),description:t(Pe&&!F?"settings.voice.page.field.apiKeyHintUsingConfig":Pe?"settings.voice.page.field.apiKeyHintProvide":"settings.voice.page.field.apiKeyHintRequired"),children:s.jsx(Cr,{kind:"openai"})}),a==="openai-compatible"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(St,{label:s.jsx("span",{className:ze(!K.trim()&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.serverUrl")}),info:t("settings.voice.page.field.serverUrlHint"),children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("input",{type:"text",value:K,onChange:Z=>D(Z.target.value),placeholder:"http://localhost:8880/v1",className:pa}),K&&s.jsx("button",{type:"button",onClick:()=>D(""),className:"absolute inset-e-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(te,{name:"close",className:"w-3.5 h-3.5"})})]})}),s.jsx(St,{label:t("settings.voice.page.field.apiKey"),description:t("settings.voice.page.field.apiKeyOptional"),children:s.jsx(Cr,{kind:"openaiCompatible"})}),s.jsx(St,{label:t("settings.voice.page.field.model"),children:s.jsx("input",{type:"text",value:R,onChange:Z=>$(Z.target.value),placeholder:"speaches-ai/Kokoro-82M-v1.0-ONNX",className:pa})}),s.jsxs(St,{label:t("settings.voice.page.field.voice"),info:t("settings.voice.page.field.voiceIdentifierHint"),children:[s.jsx("input",{type:"text",value:M,onChange:Z=>T(Z.target.value),placeholder:"af_sky",className:pa}),s.jsx(H,{size:"sm",variant:"ghost",className:Yt,onClick:Be,title:t("settings.voice.page.actions.preview"),"aria-label":t("settings.voice.page.actions.preview"),disabled:!K.trim(),children:ye(Le)})]})]}),a==="local"&&s.jsx(Yk,{...y}),s.jsxs("div",{children:[a==="openai-compatible"?null:s.jsxs(st,{label:t("settings.voice.page.field.voice"),children:[a==="local"&&s.jsxs(s.Fragment,{children:[s.jsxs(Pt,{value:wi(g,p),onValueChange:Z=>{const Oe=b.find(Ve=>wi(Ve.modelId,Ve.speakerId)===Z);Oe&&(h(Oe.modelId),S(Oe.speakerId))},children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder"),children:Z=>b.find(Oe=>wi(Oe.modelId,Oe.speakerId)===Z)?.label??Z})}),s.jsx(It,{children:b.map(Z=>s.jsx(bt,{value:wi(Z.modelId,Z.speakerId),children:Z.label},wi(Z.modelId,Z.speakerId)))})]}),s.jsx(H,{size:"sm",variant:"ghost",className:Yt,onClick:k,title:t("settings.voice.page.actions.preview"),"aria-label":t("settings.voice.page.actions.preview"),children:ye(I)}),N?s.jsx("span",{className:"typography-meta text-[var(--status-error)]",children:N}):null]}),a==="openai"&&Pe&&s.jsxs(s.Fragment,{children:[s.jsxs(Pt,{value:C,onValueChange:E,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder"),children:Z=>hd.find(Oe=>Oe.value===Z)?.label??Z})}),s.jsx(It,{children:hd.map(Z=>s.jsx(bt,{value:Z.value,children:Z.label},Z.value))})]}),s.jsx(H,{size:"sm",variant:"ghost",className:Yt,onClick:dt,title:t("settings.voice.page.actions.preview"),"aria-label":t("settings.voice.page.actions.preview"),children:ye(de)})]}),a==="say"&&be&&we.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs(Pt,{value:l,onValueChange:f,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder")})}),s.jsx(It,{children:we.map(Z=>s.jsx(bt,{value:Z.name,children:Z.name},Z.name))})]}),s.jsx(H,{size:"sm",variant:"ghost",className:Yt,onClick:it,title:t("settings.voice.page.actions.preview"),"aria-label":t("settings.voice.page.actions.preview"),children:ye(Ie)})]}),a==="browser"&&Ze.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs(Pt,{value:P||"$auto",onValueChange:Z=>j(Z==="$auto"?"":Z),children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.voice.page.field.auto"),children:Z=>Z==="$auto"?t("settings.voice.page.field.auto"):Z})}),s.jsxs(It,{children:[s.jsx(bt,{value:"$auto",children:t("settings.voice.page.field.auto")}),Ze.map(Z=>s.jsxs(bt,{value:Z.name,children:[Z.name," (",Z.lang,")"]},Z.name))]})]}),s.jsx(H,{size:"sm",variant:"ghost",className:Yt,onClick:Xe,title:t("settings.voice.page.actions.preview"),"aria-label":t("settings.voice.page.actions.preview"),children:ye(vt)})]})]}),s.jsx(st,{label:t("settings.voice.page.field.speechRate"),children:e?s.jsx(ds,{value:i,onValueChange:o,min:.5,max:2,step:.1,className:ze(us,"tabular-nums")}):s.jsxs("div",{className:"flex h-8 items-center gap-2",children:[s.jsx("input",{type:"range",min:.5,max:2,step:.1,value:i,onChange:Z=>o(Number(Z.target.value)),className:ot,"aria-label":t("settings.voice.page.field.speechRate")}),s.jsx("span",{className:et,children:`${i.toFixed(1)}×`})]})}),s.jsx(st,{label:t("settings.voice.page.field.speechPitch"),children:e?s.jsx(ds,{value:r,onValueChange:c,min:.5,max:2,step:.1,className:ze(us,"tabular-nums")}):s.jsxs("div",{className:"flex h-8 items-center gap-2",children:[s.jsx("input",{type:"range",min:.5,max:2,step:.1,value:r,onChange:Z=>c(Number(Z.target.value)),className:ot,"aria-label":t("settings.voice.page.field.speechPitch")}),s.jsx("span",{className:et,children:r.toFixed(1)})]})}),s.jsx(st,{label:t("settings.voice.page.field.speechVolume"),children:e?s.jsx(ds,{value:Math.round(u*100),onValueChange:Z=>d(Z/100),min:0,max:100,step:10,className:ze(us,"tabular-nums")}):s.jsxs("div",{className:"flex h-8 items-center gap-2",children:[s.jsx("input",{type:"range",min:0,max:1,step:.1,value:u,onChange:Z=>d(Number(Z.target.value)),className:ot,"aria-label":t("settings.voice.page.field.speechVolume")}),s.jsx("span",{className:et,children:`${Math.round(u*100)}%`})]})}),s.jsx(st,{label:t("settings.voice.page.field.ttsInputMode"),children:s.jsx(Xt,{value:Q,onChange:V,"aria-label":t("settings.voice.page.field.ttsInputMode"),options:[{value:"sanitized",label:t("settings.voice.page.field.ttsInputModeSanitized")},{value:"raw",label:t("settings.voice.page.field.ttsInputModeRaw")},{value:"summarized",label:t("settings.voice.page.field.ttsInputModeSummarized")}]})})]}),(a==="local"||a==="say"||a==="openai"||a==="openai-compatible")&&s.jsxs("div",{className:bs,children:[(a==="local"||a==="say")&&s.jsx(ct,{checked:x,onChange:w,label:t("settings.voice.page.field.followTextLanguage"),ariaLabel:t("settings.voice.page.field.followTextLanguageAria"),info:t("settings.voice.page.field.followTextLanguageInfo")}),(a==="openai"||a==="openai-compatible")&&s.jsx(ct,{checked:L,onChange:B,label:t("settings.voice.page.field.ttsChunkedMode"),ariaLabel:t("settings.voice.page.field.ttsChunkedModeAria"),info:t("settings.voice.page.tooltip.ttsChunked")})]})]})]}),s.jsxs($e,{settingsItem:"voice.speech-recognition",title:t("settings.voice.page.section.speechRecognition"),contentClassName:"space-y-3",children:[s.jsx(ct,{checked:se,onChange:ve,label:t("settings.voice.page.field.enableVoiceInput"),ariaLabel:t("settings.voice.page.field.enableVoiceInputAria")}),se&&s.jsxs(s.Fragment,{children:[s.jsx(st,{label:t("settings.voice.page.field.provider"),info:s.jsxs("ul",{className:"space-y-1",children:[s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.local")})," ",t("settings.voice.page.tooltip.sttLocal")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.server")})," ",t("settings.voice.page.tooltip.sttServer")]})]}),children:s.jsx(Xt,{value:W,onChange:Y,"aria-label":t("settings.voice.page.field.provider"),options:[{value:"local",label:t("settings.voice.page.provider.local")},{value:"openai-compatible",label:t("settings.voice.page.provider.server")}]})}),W==="local"&&s.jsx(St,{label:t("settings.voice.page.field.model"),controlClassName:"max-w-none",children:s.jsx(Hk,{selectedModelId:J,onSelect:me})}),W==="openai-compatible"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(St,{label:s.jsx("span",{className:ze(!ae.trim()&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.serverUrl")}),info:t("settings.voice.page.field.sttServerUrlHint"),children:s.jsxs("div",{className:"relative w-full",children:[s.jsx("input",{type:"text",value:ae,onChange:Z=>ee(Z.target.value),placeholder:"http://localhost:8001/v1",className:pa}),ae&&s.jsx("button",{type:"button",onClick:()=>ee(""),className:"absolute inset-e-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx(te,{name:"close",className:"w-3.5 h-3.5"})})]})}),s.jsx(St,{label:t("settings.voice.page.field.apiKey"),description:t("settings.voice.page.field.apiKeyOptional"),children:s.jsx(Cr,{kind:"stt"})}),s.jsx(St,{label:t("settings.voice.page.field.model"),children:s.jsx("input",{type:"text",value:G,onChange:Z=>le(Z.target.value),placeholder:"deepdml/faster-whisper-large-v3-turbo-ct2",className:pa})}),s.jsx(St,{label:t("settings.voice.page.field.language"),info:t("settings.voice.page.field.sttLanguageHint"),controlClassName:"max-w-[8rem]",children:s.jsx("input",{type:"text",value:fe,onChange:Z=>oe(Z.target.value),placeholder:"auto",className:pa})})]})]})]})]})};function Xk(t){return t.setVoiceApiKey}const vo=[{value:"1800000",label:"30m",ms:1800*1e3},{value:"180000",label:"3m",ms:180*1e3},{value:"7200000",label:"2h",ms:7200*1e3},{value:"28800000",label:"8h",ms:480*60*1e3},{value:"86400000",label:"24h",ms:1440*60*1e3}],yo=[{value:"3600000",label:"1h",ms:3600*1e3},{value:"28800000",label:"8h",ms:480*60*1e3},{value:"43200000",label:"12h",ms:720*60*1e3},{value:"86400000",label:"24h",ms:1440*60*1e3},{value:"604800000",label:"1w",ms:10080*60*1e3},{value:"2592000000",label:"30d",ms:720*60*60*1e3}],ew="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/get-started/create-remote-tunnel/",tw="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/configuration-file/",Ir=[{value:"quick",labelKey:"settings.openchamber.tunnel.option.mode.quick.label",tooltipKey:"settings.openchamber.tunnel.option.mode.quick.tooltip"},{value:"managed-remote",labelKey:"settings.openchamber.tunnel.option.mode.managedRemote.label",tooltipKey:"settings.openchamber.tunnel.option.mode.managedRemote.tooltip"},{value:"managed-local",labelKey:"settings.openchamber.tunnel.option.mode.managedLocal.label",tooltipKey:"settings.openchamber.tunnel.option.mode.managedLocal.tooltip"}],sw=[".yml",".yaml",".json"],nw="settings.openchamber.tunnel.error.invalidConfigExtension",Si=t=>{const e=t.trim().toLowerCase();return sw.some(a=>e.endsWith(a))},aw=t=>t==="ngrok"?"ngrok":"cloudflared",em=()=>{if(typeof window<"u"&&typeof window.__OPENCHAMBER_PLATFORM__=="string"){const e=window.__OPENCHAMBER_PLATFORM__;if(e==="win32"||e==="darwin"||e==="linux")return e}const t=typeof navigator<"u"?`${navigator.platform||""} ${navigator.userAgent||""}`.toLowerCase():"";return t.includes("win")?"win32":t.includes("mac")?"darwin":"linux"},iw=(t,e=em())=>t==="ngrok"?e==="win32"?"winget install ngrok -s msstore":e==="darwin"?"brew install ngrok":"https://ngrok.com/download":e==="win32"?"winget install --id Cloudflare.cloudflared":e==="darwin"?"brew install cloudflared":"https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/",Pr=(t,e)=>{const a=typeof e?.provider=="string"&&e.provider.trim().length>0?e.provider.trim().toLowerCase():t,n=typeof e?.dependency=="string"&&e.dependency.trim().length>0?e.dependency.trim():aw(a),i=typeof e?.platform=="string"&&e.platform.trim().length>0?e.platform.trim():em(),o=typeof e?.installCommand=="string"&&e.installCommand.trim().length>0?e.installCommand.trim():iw(a,i);return{provider:a,dependency:n,installCommand:o}},tm=t=>t==="cloudflare"?"Cloudflare":t==="ngrok"?"Ngrok":t,bd=t=>{const e=De.c(11),{provider:a}=t;let n;e[0]!==a?(n=tm(a),e[0]=a,e[1]=n):n=e[1];const i=n,c=a==="cloudflare"||a==="ngrok"?"text-[var(--status-warning)]":"text-muted-foreground";let u;e[2]!==c?(u=ze("size-4 shrink-0",c),e[2]=c,e[3]=u):u=e[3];let d;e[4]!==u?(d=s.jsx(te,{name:"cloud",className:u}),e[4]=u,e[5]=d):d=e[5];let l;e[6]!==i?(l=s.jsx("span",{children:i}),e[6]=i,e[7]=l):l=e[7];let f;return e[8]!==d||e[9]!==l?(f=s.jsxs("span",{className:"flex items-center gap-2",children:[d,l]}),e[8]=d,e[9]=l,e[10]=f):f=e[10],f},ua=t=>t==="quick"?"quick":t==="managed-remote"?"managed-remote":t==="managed-local"?"managed-local":"quick",el=(t,e,a)=>t.find(i=>i.ms===e)?.value||a,xd=(t,e,a)=>{const n=el(t,e,a);return t.find(i=>i.value===n)?.label||n},vd=t=>{const e=Math.max(0,t),a=Math.floor(e/1e3),n=Math.floor(a/3600),i=Math.floor(a%3600/60),o=a%60;return n>0?`${n}h ${i}m`:i>0?`${i}m ${o}s`:`${o}s`},ow=(t,e)=>Ud(t,e,{hour:"2-digit",precision:"second"}),No=t=>{const e=t.trim();if(!e)return"";try{return(e.includes("://")?new URL(e):new URL(`https://${e}`)).hostname.trim().toLowerCase()}catch{return e.toLowerCase()}},rw=t=>{if(!Array.isArray(t))return[];const e=new Set,a=new Set,n=[];for(const i of t){if(!i||typeof i!="object")continue;const o=i,r=typeof o.id=="string"?o.id.trim():"",c=typeof o.name=="string"?o.name.trim():"",u=No(typeof o.hostname=="string"?o.hostname:"");!r||!c||!u||e.has(r)||a.has(u)||(e.add(r),a.add(u),n.push({id:r,name:c,hostname:u}))}return n},lw=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,cw=()=>{const{t}=Ee(),e=re(_=>_.timeFormatPreference),a=m.useCallback(_=>t(_),[t]),[n,i]=m.useState("checking"),o=Hi(n==="checking"),[r,c]=m.useState(!1),[u,d]=m.useState(null),[l,f]=m.useState(null),[p,g]=m.useState(null),[h,y]=m.useState(null),[b,x]=m.useState(null),[w,S]=m.useState(!1),[v,A]=m.useState(!1),[I,N]=m.useState(!1),[k,P]=m.useState("cloudflare"),[j,C]=m.useState(()=>Pr("cloudflare")),[E,F]=m.useState([]),[O,K]=m.useState("quick"),[D,M]=m.useState(null),[T,R]=m.useState([]),[$,z]=m.useState({}),[Q,V]=m.useState(""),[L,B]=m.useState({}),[W,Y]=m.useState(new Set),[ae,ee]=m.useState(!1),[G,le]=m.useState(""),[J,me]=m.useState(""),[fe,oe]=m.useState(""),[pe,se]=m.useState(1800*1e3),[ve,be]=m.useState(480*60*1e3),[ne,we]=m.useState([]),Ne=Kd(!!u?.bootstrapExpiresAt||ne.length>0),[Ie,Ce]=m.useState(null),Me=t(nw),he=m.useRef(null),Pe=m.useMemo(()=>D?!Si(D):!1,[D]),Re=m.useMemo(()=>T.find(_=>_.id===Q)||T[0]||null,[T,Q]),ce=m.useMemo(()=>ne.map(_=>{const ge=_.expiresAt<=Ne,Ae=_.status==="active"&&!ge,Te=Ae?vd(_.expiresAt-Ne):_.inactiveReason==="expired"||ge?"expired":"inactive",Ge=Te==="expired"?t("settings.openchamber.tunnel.state.expired"):_.inactiveReason==="tunnel-revoked"?t("settings.openchamber.tunnel.state.revoked"):t("settings.openchamber.tunnel.state.inactive"),ue=ua(_.mode);return{..._,isActive:Ae,mode:ue,remainingTextForSession:Te,inactiveLabel:Ge}}),[Ne,ne,t]),je=u?.bootstrapExpiresAt&&u.bootstrapExpiresAt>Ne?vd(u.bootstrapExpiresAt-Ne):t("settings.openchamber.tunnel.state.expired"),de=m.useMemo(()=>u?.connectUrl?u.bootstrapExpiresAt===null?!0:u.bootstrapExpiresAt>Ne:!1,[Ne,u?.bootstrapExpiresAt,u?.connectUrl]),ie=m.useMemo(()=>!u||n!=="active"&&n!=="stopping"?!1:l===O,[l,n,u,O]),xe=m.useMemo(()=>!u||n!=="active"||!l?!1:l!==O,[l,n,u,O]),Se=m.useMemo(()=>{if(typeof Ie=="number"&&Number.isFinite(Ie)&&Ie>0)return Ie;if(typeof window>"u")return null;const ge=qi()||window.location.href;let Ae=0;try{Ae=Number(new URL(ge).port)}catch{Ae=Number(window.location.port)}return Number.isFinite(Ae)&&Ae>0?Ae:null},[Ie]),Le=m.useMemo(()=>E.find(_=>_.provider===k)??null,[E,k]),Ue=m.useMemo(()=>{const _=new Set(Le?.modes?.map(ge=>ge.key).filter(ge=>ge==="quick"||ge==="managed-remote"||ge==="managed-local"));return _.size===0?Ir:Ir.filter(ge=>_.has(ge.value))},[Le]),Ye=m.useMemo(()=>Ue.some(_=>_.value==="managed-remote"||_.value==="managed-local"),[Ue]),lt=m.useMemo(()=>j.provider===k?j:Pr(k),[j,k]),at=m.useCallback(async _=>{await Ks(_)},[]),ut=m.useCallback((_,ge)=>(C(Pr(ge,_)),_.available===!0),[]),vt=m.useCallback(async(_,ge)=>{try{const Ae=await $t("/api/openchamber/tunnel/check",{query:{provider:_},...ge?{signal:ge}:{}});if(!Ae.ok)return null;const Te=await Ae.json();if(ge?.aborted)return null;const Ge=ut(Te,_);return i(ue=>ue==="checking"||ue==="starting"||ue==="active"||ue==="stopping"?ue:Ge?"idle":"not-available"),Ge}catch{return null}},[ut]),We=m.useCallback(async _=>{try{const[ge,Ae,Te,Ge]=await Promise.all([$t("/api/openchamber/tunnel/check",{signal:_}),$t("/api/openchamber/tunnel/status",{signal:_}),fn(),$t("/api/openchamber/tunnel/providers",{signal:_})]),ue=await ge.json(),Fe=await Ae.json(),pt=Te??{},At=Ge.ok?await Ge.json():{},Nt=Fe.ttlConfig?.bootstrapTtlMs??(pt.tunnelBootstrapTtlMs===void 0?1800*1e3:pt.tunnelBootstrapTtlMs),zt=typeof Fe.ttlConfig?.sessionTtlMs=="number"?Fe.ttlConfig.sessionTtlMs:pt.tunnelSessionTtlMs??480*60*1e3,es=ua(Fe.mode??pt.tunnelMode),ss=pt.tunnelProvider??"cloudflare",fs=pt.managedLocalTunnelConfigPath??null,Gt=ut(ue,ss),ms=rw(Fe?.managedRemoteTunnelPresets),cs=typeof Fe.managedRemoteTunnelHostname=="string"?Fe.managedRemoteTunnelHostname:"",ps=ms.length>0?ms:cs?[{id:`legacy-${No(cs)}`,name:cs,hostname:No(cs)}]:[],hs=ps[0]?.id||"";if(c(Fe.enterpriseMode===!0),se(Nt),be(zt),P(ss),F(Array.isArray(At?.providers)?At.providers:[]),K(es),M(fs),R(ps),V(hs),we(Array.isArray(Fe.activeSessions)?Fe.activeSessions:[]),f(Fe.activeTunnelMode?ua(Fe.activeTunnelMode):Fe.active&&Fe.mode?ua(Fe.mode):null),Y(new Set(Array.isArray(Fe.managedRemoteTunnelTokenPresetIds)?Fe.managedRemoteTunnelTokenPresetIds:[])),Ce(typeof Fe.localPort=="number"?Fe.localPort:null),Fe.active&&Fe.url){d({url:Fe.url,connectUrl:null,bootstrapExpiresAt:typeof Fe.bootstrapExpiresAt=="number"?Fe.bootstrapExpiresAt:null}),i("active");return}i(Gt?"idle":"not-available")}catch{_.aborted||(i("error"),y(t("settings.openchamber.tunnel.toast.checkAvailabilityFailed")))}},[ut,t]);m.useEffect(()=>{const _=new AbortController;return We(_.signal),()=>_.abort()},[We]),m.useEffect(()=>{if(!u?.connectUrl){g(null);return}let _=!1;return gu.toDataURL(u.connectUrl,{width:256,margin:2,color:{dark:"#000000",light:"#ffffff"}}).then(ge=>{_||g(ge)}).catch(()=>{_||g(null)}),()=>{_=!0}},[u?.connectUrl]),m.useEffect(()=>{if(n==="starting"||n==="stopping"||n==="checking")return;let _=!1;const ge=async()=>{try{const Te=await $t("/api/openchamber/tunnel/status");if(!Te.ok||_)return;const Ge=await Te.json();if(_)return;we(Array.isArray(Ge.activeSessions)?Ge.activeSessions:[]),Y(new Set(Array.isArray(Ge.managedRemoteTunnelTokenPresetIds)?Ge.managedRemoteTunnelTokenPresetIds:[])),Ce(typeof Ge.localPort=="number"?Ge.localPort:null)}catch{}},Ae=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||ge()},5e3);return()=>{_=!0,window.clearInterval(Ae)}},[n]);const Ze=m.useCallback(async _=>{N(!0);try{await jt(_),Object.prototype.hasOwnProperty.call(_,"tunnelMode")&&_.tunnelMode&&K(_.tunnelMode),Object.prototype.hasOwnProperty.call(_,"tunnelProvider")&&typeof _.tunnelProvider=="string"&&P(_.tunnelProvider),Object.prototype.hasOwnProperty.call(_,"managedLocalTunnelConfigPath")&&M(_.managedLocalTunnelConfigPath??null),Object.prototype.hasOwnProperty.call(_,"managedRemoteTunnelPresets")&&_.managedRemoteTunnelPresets&&R(_.managedRemoteTunnelPresets)}catch{q.error(t("settings.openchamber.tunnel.toast.saveSettingsFailed"))}finally{N(!1)}},[t]),Xe=m.useCallback(async(_,ge)=>{A(!0);try{await jt({tunnelBootstrapTtlMs:_,tunnelSessionTtlMs:ge})}catch{q.error(t("settings.openchamber.tunnel.toast.saveTtlFailed"))}finally{A(!1)}},[t]),it=m.useCallback(async _=>{const ge=_.token.trim();if(ge)try{const Ae={...L,[_.presetId]:ge};await jt({managedRemoteTunnelPresetTokens:Ae}),Y(Te=>{const Ge=new Set(Te);return Ge.add(_.presetId),Ge})}catch{q.error(t("settings.openchamber.tunnel.toast.saveTokenFailed"))}},[L,t]),dt=m.useCallback(async _=>{x(null),y(null);const ge=E.find(Te=>Te.provider===_),Ae=ge?.modes?.some(Te=>Te.key===O)?O:ua(ge?.modes?.[0]?.key);await Ze({tunnelProvider:_,tunnelMode:Ae}),vt(_)},[E,vt,Ze,O]),Be=m.useCallback(async()=>{const _=await pl({filters:[{name:"Config",extensions:["yml","yaml","json"]}]});if(_.success&&typeof _.path=="string"&&_.path.trim().length>0){const ge=_.path.trim();if(!Si(ge)){q.error(Me);return}M(ge),await Ze({managedLocalTunnelConfigPath:ge});return}he.current?.click()},[Me,Ze]),ot=m.useCallback(_=>{const ge=_.trim();M(ge.length>0?ge:null)},[]),et=m.useCallback(async()=>{if(D&&!Si(D)){q.error(Me);return}await Ze({managedLocalTunnelConfigPath:D})},[Me,D,Ze]),ye=m.useCallback(async()=>{M(null),await Ze({managedLocalTunnelConfigPath:null})},[Ze]),Z=m.useCallback(async _=>{const ge=_.target.files?.[0];if(!ge)return;const Ae=ge.name.trim();if(Ae.length!==0){if(!Si(Ae)){q.error(Me);return}M(Ae),await Ze({managedLocalTunnelConfigPath:Ae}),_.target.value=""}},[Me,Ze]),Oe=m.useCallback(async()=>{if(y(null),x(null),O==="managed-local"&&D&&!Si(D)){y(Me),q.error(Me);return}i("starting");try{let _="",ge="";if(O==="managed-remote"){if(!Re){i("idle"),x(t("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst")),q.error(t("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst"));return}_=Re.hostname,ge=(L[Re.id]||"").trim(),await Ze({tunnelMode:"managed-remote",managedRemoteTunnelPresets:T})}const Ae=await $t("/api/openchamber/tunnel/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:k,mode:O,...O==="managed-remote"&&Re?{managedRemoteTunnelPresetId:Re.id,managedRemoteTunnelPresetName:Re.name}:{},...O==="managed-remote"&&_?{managedRemoteTunnelHostname:_}:{},...O==="managed-remote"&&ge?{managedRemoteTunnelToken:ge}:{},...O==="managed-local"&&D?{configPath:D}:{}})}),Te=await Ae.json();if(!Ae.ok||!Te.ok){if(O==="managed-remote"&&typeof Te.error=="string"&&Te.error.includes("Managed remote tunnel token is required")){i("idle"),x(t("settings.openchamber.tunnel.toast.managedRemoteTokenRequiredBeforeStarting")),q.error(t("settings.openchamber.tunnel.toast.addManagedRemoteTokenBeforeStarting"));return}i("error"),y(Te.error||t("settings.openchamber.tunnel.toast.startFailed")),q.error(Te.error||t("settings.openchamber.tunnel.toast.startFailed"));return}const Ge=typeof Te.url=="string"?Te.url:"";if(!Ge){i("error"),y(t("settings.openchamber.tunnel.toast.startedButNoPublicUrl")),q.error(t("settings.openchamber.tunnel.toast.startedButNoPublicUrl"));return}if(d({url:Ge,connectUrl:typeof Te.connectUrl=="string"?Te.connectUrl:null,bootstrapExpiresAt:typeof Te.bootstrapExpiresAt=="number"?Te.bootstrapExpiresAt:null}),f(Te.activeTunnelMode?ua(Te.activeTunnelMode):Te.mode?ua(Te.mode):O),we(Array.isArray(Te.activeSessions)?Te.activeSessions:[]),Array.isArray(Te.managedRemoteTunnelTokenPresetIds)&&Y(new Set(Te.managedRemoteTunnelTokenPresetIds)),typeof Te.localPort=="number"&&Ce(Te.localPort),typeof Te.mode=="string"&&K(ua(Te.mode)),i("active"),Te.replacedTunnel){const ue=typeof Te.revokedBootstrapCount=="number"?Te.revokedBootstrapCount:0,Fe=typeof Te.invalidatedSessionCount=="number"?Te.invalidatedSessionCount:0;ue===1&&Fe===1?q.warning(t("settings.openchamber.tunnel.toast.replacedTunnelSingleSingle")):ue===1?q.warning(t("settings.openchamber.tunnel.toast.replacedTunnelSingleManySessions",{invalidatedSessionCount:Fe})):Fe===1?q.warning(t("settings.openchamber.tunnel.toast.replacedTunnelManyLinksSingleSession",{revokedBootstrapCount:ue})):q.warning(t("settings.openchamber.tunnel.toast.replacedTunnelManyMany",{revokedBootstrapCount:ue,invalidatedSessionCount:Fe}))}else q.success(t("settings.openchamber.tunnel.toast.linkReady"))}catch{i("error"),y(t("settings.openchamber.tunnel.toast.startFailed")),q.error(t("settings.openchamber.tunnel.toast.startFailed"))}},[Me,T,Ze,Re,L,t,k,O,D]),Ve=m.useCallback(async()=>{i("stopping");try{await $t("/api/openchamber/tunnel/stop",{method:"POST"});const _=await $t("/api/openchamber/tunnel/status");if(_.ok){const ge=await _.json();we(Array.isArray(ge.activeSessions)?ge.activeSessions:[]),Y(new Set(Array.isArray(ge.managedRemoteTunnelTokenPresetIds)?ge.managedRemoteTunnelTokenPresetIds:[])),Ce(typeof ge.localPort=="number"?ge.localPort:null)}d(null),f(null),g(null),i("idle"),q.success(t("settings.openchamber.tunnel.toast.stopped"))}catch{i("error"),y(t("settings.openchamber.tunnel.toast.stopFailed")),q.error(t("settings.openchamber.tunnel.toast.stopFailed"))}},[t]),X=m.useCallback(async()=>{if(u?.connectUrl)try{await navigator.clipboard.writeText(u.connectUrl),S(!0),q.success(t("settings.openchamber.tunnel.toast.connectLinkCopied")),setTimeout(()=>S(!1),2e3)}catch{q.error(t("settings.openchamber.tunnel.toast.copyUrlFailed"))}},[t,u?.connectUrl]),_e=m.useCallback(async _=>{const ge=vo.find(Ae=>Ae.value===_);ge&&(se(ge.ms),await Xe(ge.ms,ve))},[Xe,ve]),nt=m.useCallback(async _=>{const ge=yo.find(Ae=>Ae.value===_);!ge||ge.ms===null||(be(ge.ms),await Xe(pe,ge.ms))},[pe,Xe]),ht=m.useCallback(async _=>{x(null),y(null),n!=="active"&&n!=="stopping"&&n!=="starting"&&i("idle"),await Ze({tunnelMode:_,managedRemoteTunnelPresets:T})},[T,Ze,n]),yt=m.useCallback(async(_,ge)=>{try{await jt({managedRemoteTunnelPresets:ge})}catch{q.error(t("settings.openchamber.tunnel.toast.saveSelectedManagedRemoteFailed"))}},[t]),kt=m.useCallback(_=>{const ge=T.find(Ae=>Ae.id===_);ge&&(V(ge.id),x(null),yt(ge,T))},[T,yt]),He=m.useCallback(async()=>{const _=G.trim(),ge=No(J),Ae=fe.trim();if(!_){q.error(t("settings.openchamber.tunnel.toast.tunnelNameRequired"));return}if(!ge){q.error(t("settings.openchamber.tunnel.toast.managedRemoteHostnameRequired"));return}if(!Ae){q.error(t("settings.openchamber.tunnel.toast.managedRemoteTokenRequired"));return}if(T.some(ue=>ue.hostname===ge)){q.error(t("settings.openchamber.tunnel.toast.hostnameAlreadyExists"));return}const Te={id:lw(),name:_,hostname:ge},Ge=[...T,Te];R(Ge),V(Te.id),z(ue=>({...ue,[Te.id]:!0})),B(ue=>({...ue,[Te.id]:Ae})),x(null),ee(!1),le(""),me(""),oe(""),await Ze({tunnelMode:"managed-remote",managedRemoteTunnelPresets:Ge,managedRemoteTunnelPresetTokens:{...L,[Te.id]:Ae}}),await it({presetId:Te.id,presetName:Te.name,hostname:Te.hostname,token:Ae}),q.success(t("settings.openchamber.tunnel.toast.managedRemoteSaved"))},[T,J,G,fe,it,Ze,L,t]),Je=m.useCallback(async _=>{const ge=T.find(Fe=>Fe.id===_);if(!ge)return;const Ae=T.filter(Fe=>Fe.id!==ge.id),Te=Ae[0]?.id||"",Ge=Q===ge.id?Te:Q,ue=Object.fromEntries(Object.entries(L).filter(([Fe,pt])=>Fe!==ge.id&&pt.trim().length>0));R(Ae),V(Ge),z(Fe=>{const pt={...Fe};return delete pt[ge.id],pt}),B(Fe=>{const pt={...Fe};return delete pt[ge.id],pt}),Y(Fe=>{const pt=new Set(Fe);return pt.delete(ge.id),pt}),x(null),await Ze({managedRemoteTunnelPresets:Ae,managedRemoteTunnelPresetTokens:ue}),q.success(t("settings.openchamber.tunnel.toast.managedRemoteRemoved"))},[T,Ze,Q,L,t]);if(n==="checking")return s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("span",{className:ze("h-1.5 w-1.5 rounded-full bg-current",o),"aria-label":t("settings.openchamber.tunnel.state.loading")})});if(r)return s.jsx($e,{title:t("settings.openchamber.tunnel.title"),divider:!1,children:s.jsx("p",{className:Ln,children:t("settings.openchamber.tunnel.enterpriseMode")})});const mt=I||n==="starting"||n==="stopping",Qe=a(Ir.find(_=>_.value===O)?.labelKey??"settings.openchamber.tunnel.option.mode.quick.label");return s.jsxs(s.Fragment,{children:[s.jsxs($e,{title:t("settings.layout.tunnel.section.setup"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.openchamber.tunnel.description")}),s.jsx("p",{children:t("settings.openchamber.tunnel.note.serverSideEnforced")}),s.jsx("p",{children:t("settings.openchamber.tunnel.note.connectLinksOneTime")})]}),divider:!1,contentClassName:"space-y-4",children:[n==="not-available"&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-[var(--status-warning)]/10 p-3",children:[s.jsx(te,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("p",{className:_d,children:t("settings.openchamber.tunnel.notAvailable.dependencyNotFound",{dependency:lt.dependency})}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.tunnel.notAvailable.installHint")}),s.jsx("code",{className:"typography-code block rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:lt.installCommand})]})]}),s.jsxs("div",{children:[s.jsx(st,{label:t("settings.openchamber.tunnel.field.provider"),settingsItem:"tunnel.provider",children:s.jsxs(Pt,{value:k,onValueChange:_=>{dt(_)},disabled:mt,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.openchamber.tunnel.field.providerPlaceholder"),children:tm(k)})}),s.jsxs(It,{children:[E.length>0?E.map(_=>s.jsx(bt,{value:_.provider,children:s.jsx(bd,{provider:_.provider})},_.provider)):s.jsx(bt,{value:"cloudflare",children:s.jsx(bd,{provider:"cloudflare"})}),s.jsx(bt,{value:"__more-soon",disabled:!0,children:t("settings.openchamber.tunnel.option.moreProvidersSoon")})]})]})}),s.jsx(st,{label:t("settings.openchamber.tunnel.field.tunnelType"),settingsItem:"tunnel.type",children:s.jsx(Xt,{value:O,"aria-label":t("settings.openchamber.tunnel.field.tunnelType"),onChange:_=>{ht(_)},options:Ue.map(_=>({value:_.value,label:a(_.labelKey),tooltip:a(_.tooltipKey),disabled:mt}))})})]}),O==="quick"&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-[var(--status-warning)]/10 p-3",children:[s.jsx(te,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.option.mode.quick.tooltip")}),Ye&&s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.warning.quickModeReliability")})]})]}),O==="managed-remote"&&s.jsxs("p",{className:_t,children:[t("settings.openchamber.tunnel.note.managedRemoteRequiresDomain")," ",s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 text-[var(--primary-text)] underline-offset-4 hover:underline",onClick:()=>{at(ew)},children:[t("settings.openchamber.tunnel.actions.openManagedRemoteDocs"),s.jsx(te,{name:"external-link",className:"size-3.5"})]})]}),O==="managed-local"&&s.jsxs("p",{className:_t,children:[t("settings.openchamber.tunnel.note.managedLocalUsesConfig")," ",s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 text-[var(--primary-text)] underline-offset-4 hover:underline",onClick:()=>{at(tw)},children:[t("settings.openchamber.tunnel.actions.openManagedLocalDocs"),s.jsx(te,{name:"external-link",className:"size-3.5"})]})]}),O==="managed-remote"&&s.jsxs("div",{"data-settings-item":"tunnel.managed-remote",className:"oc-tile space-y-2 rounded-lg p-3",children:[typeof Se=="number"&&s.jsx("div",{className:"rounded-md bg-[var(--status-info-background)]/60 px-2 py-1.5",children:s.jsxs("p",{className:"typography-meta text-[var(--status-info)]",children:[t("settings.openchamber.tunnel.note.cloudflareConnectorTarget")," ",s.jsxs("code",{children:["http://localhost:",Se]})]})}),s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[s.jsx($a,{children:t("settings.openchamber.tunnel.section.savedManagedRemoteTunnels")}),s.jsxs(H,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>ee(_=>!_),disabled:n==="starting"||n==="stopping"||I,children:[s.jsx(te,{name:"add",className:"h-3.5 w-3.5"}),t("settings.common.actions.create")]})]}),T.length>0?s.jsx("div",{className:"oc-tile-inset overflow-hidden rounded-md",children:T.map((_,ge)=>{const Ae=L[_.id]||"",Te=W.has(_.id),Ge=$[_.id]??!1;return s.jsx("div",{className:ze(ge<T.length-1&&"border-b border-[var(--interactive-border)]"),children:s.jsxs(ha,{open:Ge,onOpenChange:ue=>{z(Fe=>({...Fe,[_.id]:ue})),ue&&kt(_.id)},className:"py-1.5",children:[s.jsxs("div",{className:"flex items-start gap-2 px-3",children:[s.jsxs(ba,{type:"button",className:"group flex-1 justify-start gap-2 rounded-md px-0 py-1 pe-1 text-start hover:bg-[var(--interactive-hover)]",disabled:n==="starting"||n==="stopping"||I,children:[Ge?s.jsx(te,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):s.jsx(te,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label min-w-0 flex-1 truncate text-foreground",children:_.name})]}),s.jsx(H,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-[var(--status-error)]","aria-label":t("settings.openchamber.tunnel.actions.removePresetAria",{name:_.name}),onClick:()=>{Je(_.id)},disabled:n==="starting"||n==="stopping"||I,children:s.jsx(te,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),s.jsx(xa,{className:"pt-1.5",children:s.jsxs("div",{className:"space-y-1 px-3 pb-2",children:[s.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[t("settings.openchamber.tunnel.field.hostnameLabel")," ",s.jsx("code",{children:_.hostname})]}),s.jsx(qe,{type:"password",value:Ae,onChange:ue=>{const Fe=ue.target.value;x(null),B(pt=>({...pt,[_.id]:Fe}))},onBlur:ue=>{const Fe=ue.currentTarget.value.trim();Fe&&it({presetId:_.id,presetName:_.name,hostname:_.hostname,token:Fe})},placeholder:t(Te?"settings.openchamber.tunnel.field.savedTokenAvailablePlaceholder":"settings.openchamber.tunnel.field.pasteTokenPlaceholder"),className:"h-7",disabled:n==="starting"||n==="stopping"}),s.jsx("div",{className:"flex items-center justify-end",children:s.jsx(H,{variant:"ghost",size:"xs",className:"!font-normal",disabled:n==="starting"||n==="stopping"||Ae.trim().length===0,onClick:()=>{it({presetId:_.id,presetName:_.name,hostname:_.hostname,token:Ae})},children:t("settings.openchamber.tunnel.actions.saveToken")})})]})})]})},_.id)})}):s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t("settings.openchamber.tunnel.empty.noManagedRemoteTunnels")}),ae&&s.jsxs("div",{className:"oc-tile-inset space-y-2 rounded-md p-2",children:[s.jsx(qe,{value:G,onChange:_=>le(_.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetNamePlaceholder"),className:"h-7",disabled:I||n==="starting"||n==="stopping"}),s.jsx(qe,{value:J,onChange:_=>me(_.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetHostnamePlaceholder"),className:"h-7",disabled:I||n==="starting"||n==="stopping"}),s.jsx(qe,{type:"password",value:fe,onChange:_=>oe(_.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetTokenPlaceholder"),className:"h-7",disabled:I||n==="starting"||n==="stopping"}),typeof Se=="number"&&s.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[t("settings.openchamber.tunnel.note.cloudflareConnectorTargetUse")," ",s.jsxs("code",{children:["http://localhost:",Se]}),"."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(H,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{He()},disabled:I||n==="starting"||n==="stopping",children:t("settings.common.actions.saveChanges")}),s.jsx(H,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{ee(!1),le(""),me(""),oe("")},disabled:I||n==="starting"||n==="stopping",children:t("settings.common.actions.cancel")})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("settings.openchamber.tunnel.note.tokensSavedPerTunnel")}),s.jsx(ts,{children:t("settings.openchamber.tunnel.tooltip.tokensSavedPath")})]}),!Re&&b&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:b})]}),O==="managed-local"&&s.jsx("div",{"data-settings-item":"tunnel.managed-local-config",className:"oc-tile space-y-2 rounded-lg p-3",children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:Vt,children:t("settings.openchamber.tunnel.field.configurationFile")}),s.jsx("input",{ref:he,type:"file",accept:".yml,.yaml,.json",className:"hidden",onChange:_=>{Z(_)}}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qe,{value:D||"",onChange:_=>{ot(_.target.value)},onBlur:()=>{et()},placeholder:t("settings.openchamber.tunnel.field.configurationFilePlaceholder"),className:"h-7",disabled:n==="starting"||n==="stopping"||I}),s.jsx(H,{variant:"outline",size:"xs",className:"h-7 w-7 p-0","aria-label":t("settings.openchamber.tunnel.actions.browseConfigFileAria"),onClick:()=>{Be()},disabled:n==="starting"||n==="stopping"||I,children:s.jsx(te,{name:"folder",className:"size-3.5"})}),D&&s.jsx(H,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0","aria-label":t("settings.openchamber.tunnel.actions.clearConfigFileAria"),onClick:()=>{ye()},disabled:n==="starting"||n==="stopping"||I,children:s.jsx(te,{name:"close",className:"size-3.5"})})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t(D?"settings.openchamber.tunnel.note.customConfigUsed":"settings.openchamber.tunnel.note.defaultConfigUsed")}),Pe&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Me})]})})]}),s.jsxs($e,{title:t("settings.layout.tunnel.section.connection"),settingsItem:"tunnel.start",contentClassName:"space-y-4",children:[!ie&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:_t,children:t("settings.openchamber.tunnel.note.startModeAndGenerateLink",{mode:Qe})}),O==="managed-remote"&&s.jsx(st,{label:t("settings.openchamber.tunnel.field.managedRemoteTunnelToConnect"),children:s.jsxs(Pt,{value:Q||(T[0]?.id??""),onValueChange:_=>{kt(_)},disabled:mt||T.length<=1,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{placeholder:t("settings.openchamber.tunnel.field.selectSavedTunnelPlaceholder"),children:Re?.name})}),s.jsx(It,{fitContent:!0,children:T.map(_=>s.jsx(bt,{value:_.id,children:_.name},_.id))})]})}),xe&&s.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-[var(--status-warning-background)] p-3",children:[s.jsx(te,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.warning.replacesActiveTunnel")})]}),s.jsx(H,{size:"sm",onClick:Oe,disabled:n==="starting"||I||O==="managed-remote"&&!Re||O==="managed-local"&&Pe,children:n==="starting"?s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"loader-4",className:"size-3.5 animate-spin"})," ",t("settings.openchamber.tunnel.actions.startingTunnel")]}):t("settings.openchamber.tunnel.actions.startTunnel")})]}),ie&&u&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--status-success)]"}),s.jsx("p",{className:"typography-ui-label font-medium text-foreground",children:t("settings.openchamber.tunnel.state.tunnelReady")})]}),s.jsx(St,{label:t("settings.openchamber.tunnel.field.publicUrlHint"),controlClassName:"max-w-none",children:s.jsx("code",{className:"typography-code block min-w-0 truncate rounded-md oc-tile-inset px-2 py-1.5 text-xs text-foreground",title:u.url,children:u.url})}),de&&u.connectUrl&&s.jsxs("div",{className:"flex flex-col gap-4 @xl:flex-row @xl:items-start",children:[s.jsxs(St,{label:t("settings.openchamber.tunnel.field.connectLink"),description:`${t("settings.openchamber.tunnel.field.expires")}: ${u.bootstrapExpiresAt?je:t("settings.openchamber.tunnel.state.never")}`,descriptionPlacement:"after",className:"min-w-0 flex-1",controlClassName:"max-w-none",children:[s.jsx("code",{className:"typography-code block min-w-0 flex-1 truncate rounded-md oc-tile-inset px-2 py-1.5 text-xs text-foreground",title:u.connectUrl,children:u.connectUrl}),s.jsxs(H,{size:"sm",variant:"ghost",onClick:X,className:"shrink-0 gap-1.5",children:[w?s.jsx(te,{name:"check",className:"size-3.5 text-[var(--status-success)]"}):s.jsx(te,{name:"file-copy",className:"size-3.5"}),t(w?"settings.openchamber.tunnel.actions.copied":"settings.common.actions.copyAll")]})]}),s.jsxs("div",{className:"flex shrink-0 flex-col items-center gap-2 oc-tile rounded-lg p-3",children:[p?s.jsx("img",{src:p,alt:t("settings.openchamber.tunnel.field.connectQrAlt"),className:"size-40"}):s.jsx("div",{className:"size-40 rounded bg-muted/30"}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("settings.openchamber.tunnel.note.scanQrToConnect")})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(H,{size:"sm",onClick:Oe,disabled:n==="stopping"||I||O==="managed-local"&&Pe,children:[s.jsx(te,{name:"restart",className:"size-3.5"}),t("settings.openchamber.tunnel.actions.newConnectLink")]}),s.jsx(H,{size:"sm",variant:"ghost",onClick:Ve,disabled:n==="stopping"||I,className:"text-[var(--status-error)]",children:n==="stopping"?s.jsxs(s.Fragment,{children:[s.jsx(te,{name:"loader-4",className:"size-3.5 animate-spin"})," ",t("settings.openchamber.tunnel.actions.stopping")]}):t("settings.openchamber.tunnel.actions.stopTunnel")})]})]}),n==="error"&&h&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:h}),s.jsx(H,{size:"sm",variant:"ghost",onClick:Oe,children:t("settings.openchamber.tunnel.actions.retry")})]})]}),s.jsxs($e,{title:t("settings.layout.tunnel.section.lifetime"),settingsItem:"tunnel.ttl",children:[s.jsx(st,{label:t("settings.openchamber.tunnel.field.connectLinkTtl"),children:s.jsxs(Pt,{value:el(vo,pe,"1800000"),onValueChange:_=>{_e(_)},disabled:v||mt,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{className:"truncate",children:xd(vo,pe,"1800000")})}),s.jsx(It,{children:vo.map(_=>s.jsx(bt,{value:_.value,children:_.label},_.value))})]})}),s.jsx(st,{label:t("settings.openchamber.tunnel.field.tunnelSessionTtl"),children:s.jsxs(Pt,{value:el(yo,ve,"28800000"),onValueChange:_=>{nt(_)},disabled:v||mt,children:[s.jsx(Ct,{className:Es,children:s.jsx(Kt,{className:"truncate",children:xd(yo,ve,"28800000")})}),s.jsx(It,{children:yo.map(_=>s.jsx(bt,{value:_.value,children:_.label},_.value))})]})})]}),ce.length>0&&s.jsx($e,{title:t("settings.openchamber.tunnel.section.redeemedAccessLinks"),contentClassName:"space-y-1",children:ce.map(_=>{const ge=_.mode==="quick",Ae=_.mode==="managed-remote",Te=ge?"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-[var(--status-warning)]":Ae?"border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)]":"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",Ge=_.isActive?ge?"text-[var(--status-warning)]":Ae?"text-[var(--status-info)]":"text-[var(--status-success)]":"text-muted-foreground/50",ue=t(ge?"settings.openchamber.tunnel.badge.quick":Ae?"settings.openchamber.tunnel.badge.remote":"settings.openchamber.tunnel.badge.local");return s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 oc-tile rounded-md px-3 py-2",children:[s.jsx(te,{name:"checkbox-blank-circle-fill",className:ze("size-2.5 shrink-0",Ge)}),s.jsx("span",{className:ze("rounded-full px-2 py-0.5 text-[10px] font-medium",Te),children:ue}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.tunnel.session.redeemedAt",{time:ow(_.createdAt,e)})}),s.jsx("span",{className:"typography-meta text-foreground",children:_.isActive?t("settings.openchamber.tunnel.session.expiresIn",{remaining:_.remainingTextForSession}):_.inactiveLabel===t("settings.openchamber.tunnel.state.inactive")?t("settings.openchamber.tunnel.state.inactive"):t("settings.openchamber.tunnel.session.inactiveWithReason",{reason:_.inactiveLabel})})]},_.sessionId)})})]})},dw=()=>{const{t}=Ee(),e=Ki(h=>h.opencodeBinary),[a,n]=Ke.useState(""),[i,o]=Ke.useState(!0),[r,c]=Ke.useState(!1),u=re(h=>h.showOpenCodeUpdateNotifications),d=re(h=>h.setShowOpenCodeUpdateNotifications);Ke.useEffect(()=>{let h=!1;return(async()=>{try{const y=await fn();if(h||!y)return;n(y.opencodeBinary??"")}catch{}finally{h||o(!1)}})(),()=>{h=!0}},[]);const l=Ke.useCallback(async()=>{if(!(typeof window>"u")&&is())try{const h=await pl();h.success&&h.path&&h.path.trim().length>0&&n(h.path.trim())}catch{}},[]),f=Ke.useCallback(async()=>{c(!0);try{const h=a.trim(),y=h.length>=2&&(h.startsWith('"')&&h.endsWith('"')||h.startsWith("'")&&h.endsWith("'"))?h.slice(1,-1).trim():h;await jt({opencodeBinary:y}),await Ed({message:t("settings.openchamber.opencodeCli.actions.restartingOpenCode"),mode:"projects",scopes:["all"]})}catch(h){if(h?.requiresManualRestart){q.warning(t("settings.openchamber.opencodeCli.restart.manualRequired"));return}q.error(t("settings.openchamber.opencodeCli.restart.failed"))}finally{c(!1)}},[t,a]),p=Ke.useCallback(async()=>{c(!0);try{await fu(t)}finally{c(!1)}},[t]),g=Ke.useCallback(h=>{d(h),jt({showOpenCodeUpdateNotifications:h})},[d]);return s.jsx($e,{title:t("settings.openchamber.opencodeCli.title"),children:s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs(st,{settingsItem:"sessions.opencode-binary",label:t("settings.openchamber.opencodeCli.field.binaryPath"),info:s.jsxs(s.Fragment,{children:[t("settings.openchamber.opencodeCli.tipPrefix")," ",s.jsx("span",{className:"font-mono",children:"OPENCODE_BINARY"})," ",t("settings.openchamber.opencodeCli.tipMiddle")," ",s.jsx("span",{className:"font-mono",children:"~/.config/openchamber/settings.json"}),"."]}),description:e?t("settings.openchamber.opencodeCli.field.pinnedByAdministrator"):void 0,alignEnd:!1,controlClassName:"@xl:w-[20rem]",children:[s.jsx(qe,{value:e??a,onChange:h=>n(h.target.value),placeholder:t("settings.openchamber.opencodeCli.field.binaryPathPlaceholder"),disabled:i||r||e!==null,className:"h-8 min-w-0 flex-1 font-mono text-xs"}),s.jsx(H,{type:"button",variant:"outline",size:"xs",onClick:l,disabled:i||r||!is()||e!==null,className:Yt,"aria-label":t("settings.openchamber.opencodeCli.actions.browseAria"),title:t("settings.openchamber.opencodeCli.actions.browse"),children:s.jsx(te,{name:"folder",className:"h-4 w-4"})})]}),s.jsxs(_i,{className:bs,children:[s.jsx(ct,{settingsItem:"sessions.opencode-update-notifications",checked:u,onChange:g,label:t("settings.openchamber.opencodeCli.field.showUpdateNotifications"),ariaLabel:t("settings.openchamber.opencodeCli.field.showUpdateNotificationsAria")}),s.jsxs("div",{className:"flex flex-wrap justify-start gap-2 py-1.5","data-settings-item":"sessions.opencode-restart",children:[s.jsx(H,{type:"button",size:"xs",onClick:f,disabled:i||r||e!==null,className:"shrink-0 !font-normal",children:t(r?"settings.openchamber.opencodeCli.actions.restartingOpenCode":"settings.openchamber.opencodeCli.actions.saveAndReload")}),s.jsx(H,{type:"button",variant:"outline",size:"xs",onClick:p,disabled:i||r,className:"shrink-0 !font-normal",children:t("settings.openchamber.opencodeCli.actions.restart")})]})]})]})})},uw=()=>{const{t}=Ee(),e=Pn(),[a,n]=m.useState({state:"loading"}),[i,o]=m.useState(!1),[r,c]=m.useState(!1);m.useEffect(()=>{let l=!1;return Nf().then(f=>{l||n({state:"ready",names:f.names})}).catch(()=>{l||n({state:"failed"})}),()=>{l=!0}},[]);const u=m.useCallback(async l=>{Mt("saving");try{const f=await Cf(l);return n({state:"ready",names:f.names}),o(!0),Mt("saved"),!0}catch{return Mt("error"),q.error(t("settings.environment.editor.saveFailed")),!1}},[t]),d=m.useCallback(async()=>{c(!0);try{await fu(t),o(!1)}finally{c(!1)}},[t]);return s.jsx($e,{title:t("settings.environment.user.title"),info:t("settings.environment.user.info"),settingsItem:"general.environment-variables",children:s.jsxs("div",{className:"space-y-3",children:[e?s.jsx("p",{className:_t,children:t("settings.environment.user.enterpriseNote")}):null,a.state==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:t("settings.environment.editor.loadFailed")}):s.jsx(If,{names:a.state==="ready"?a.names:[],disabled:a.state!=="ready",onSet:(l,f)=>u({[l]:f}),onRemove:l=>u({[l]:null})}),i&&!e?s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("p",{className:_t,children:t("settings.environment.user.restartNote")}),s.jsx(H,{type:"button",variant:"outline",size:"xs",onClick:()=>{d()},disabled:r,className:"shrink-0 !font-normal",children:t(r?"settings.openchamber.opencodeCli.actions.restartingOpenCode":"settings.openchamber.opencodeCli.actions.restart")})]}):null]})})},mw=3e3,sm=1e3,pw=5,gw=(t,e)=>t.imagePulling?mw:t.imageBytes===0&&e<pw?sm:null,yd=["B","KB","MB","GB","TB"],$o=t=>{let e=t,a=0;for(;e>=1e3&&a<yd.length-1;)e/=1e3,a+=1;return`${new Intl.NumberFormat(Bo(),{maximumFractionDigits:a===0?0:1}).format(e)} ${yd[a]}`},nm=t=>{const e=De.c(11);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={kind:"reading"},e[0]=a):a=e[0];const[n,i]=m.useState(a),[o,r]=m.useState(0);let c;e[1]!==t?(c=()=>{const b=new AbortController;return i({kind:"reading"}),t(b.signal).then(x=>{b.signal.aborted||i({kind:"read",value:x})},x=>{b.signal.aborted||i({kind:"failed",error:x})}),()=>b.abort()},e[1]=t,e[2]=c):c=e[2];let u;e[3]!==t||e[4]!==o?(u=[t,o],e[3]=t,e[4]=o,e[5]=u):u=e[5],m.useEffect(c,u);let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=()=>r(ww),e[6]=d):d=e[6];const l=d;let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=b=>i({kind:"read",value:b}),e[7]=f):f=e[7];const p=f;let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=b=>i({kind:"failed",error:b}),e[8]=g):g=e[8];const h=g;let y;return e[9]!==n?(y=[n,l,p,h],e[9]=n,e[10]=y):y=e[10],y},Pi=t=>{const e=De.c(7),{tone:a,children:n}=t;let i;e[0]!==a?(i=a==="busy"?s.jsx(va,{className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 text-muted-foreground"}):s.jsx(te,{name:a==="ready"?"checkbox-circle":"circle",className:ze("mt-[0.2em] h-3.5 w-3.5 shrink-0",a==="ready"?"text-[var(--status-success)]":"text-muted-foreground")}),e[0]=a,e[1]=i):i=e[1];let o;e[2]!==n?(o=s.jsx("span",{children:n}),e[2]=n,e[3]=o):o=e[3];let r;return e[4]!==i||e[5]!==o?(r=s.jsxs("p",{className:"flex items-start gap-1.5 typography-meta text-foreground",role:"status",children:[i,o]}),e[4]=i,e[5]=o,e[6]=r):r=e[6],r},fw=t=>{const e=De.c(44),{disk:a,onCancel:n,onConfirm:i}=t,{t:o}=Ee(),r=re(Sw),c=a!==null;let u;e[0]!==o?(u=o("settings.openchamber.spaces.places.cleanUp.confirmTitle"),e[0]=o,e[1]=u):u=e[1];const d=u;let l;e[2]!==a||e[3]!==o?(l=a?[o("settings.openchamber.spaces.places.cleanUp.frees",{size:$o(a.freeBytes)}),...a.freesImage?[o("settings.openchamber.spaces.places.cleanUp.imageAgain")]:[]]:[],e[2]=a,e[3]=o,e[4]=l):l=e[4];const f=l;let p;e[5]!==o?(p=o("settings.openchamber.spaces.places.cleanUp.cancel"),e[5]=o,e[6]=p):p=e[6];let g;e[7]!==n||e[8]!==p?(g=s.jsx(H,{variant:"outline",size:"sm",onClick:n,children:p}),e[7]=n,e[8]=p,e[9]=g):g=e[9];let h;e[10]!==o?(h=o("settings.openchamber.spaces.places.cleanUp.confirm"),e[10]=o,e[11]=h):h=e[11];let y;e[12]!==i||e[13]!==h?(y=s.jsx(H,{size:"sm",onClick:i,children:h}),e[12]=i,e[13]=h,e[14]=y):y=e[14];let b;e[15]!==g||e[16]!==y?(b=s.jsxs("div",{className:"flex w-full justify-end gap-2",children:[g,y]}),e[15]=g,e[16]=y,e[17]=b):b=e[17];const x=b;if(r){let P;e[18]!==f?(P=s.jsx("div",{className:"flex flex-col gap-1 px-3 pb-4 pt-1",children:f.map(Nw)}),e[18]=f,e[19]=P):P=e[19];let j;return e[20]!==x||e[21]!==n||e[22]!==c||e[23]!==P||e[24]!==d?(j=s.jsx(dl,{open:c,title:d,onClose:n,footer:x,children:P}),e[20]=x,e[21]=n,e[22]=c,e[23]=P,e[24]=d,e[25]=j):j=e[25],j}let w;e[26]!==n?(w=P=>{P||n()},e[26]=n,e[27]=w):w=e[27];let S;e[28]!==d?(S=s.jsx(Ot,{children:d}),e[28]=d,e[29]=S):S=e[29];let v;e[30]!==f?(v=s.jsx(Ft,{className:"flex flex-col gap-1",children:f.map(Cw)}),e[30]=f,e[31]=v):v=e[31];let A;e[32]!==v||e[33]!==S?(A=s.jsxs(Rt,{children:[S,v]}),e[32]=v,e[33]=S,e[34]=A):A=e[34];let I;e[35]!==x?(I=s.jsx(Wt,{children:x}),e[35]=x,e[36]=I):I=e[36];let N;e[37]!==A||e[38]!==I?(N=s.jsxs(Et,{className:"max-w-md",children:[A,I]}),e[37]=A,e[38]=I,e[39]=N):N=e[39];let k;return e[40]!==c||e[41]!==N||e[42]!==w?(k=s.jsx(Tt,{open:c,onOpenChange:w,children:N}),e[40]=c,e[41]=N,e[42]=w,e[43]=k):k=e[43],k},hw=t=>{const e=De.c(19),{outcome:a}=t,{t:n}=Ee();let i;e[0]!==a.kept?(i=a.kept.some(Iw),e[0]=a.kept,e[1]=i):i=e[1];const o=i;let r;e[2]!==a.kept?(r=a.kept.some(Pw),e[2]=a.kept,e[3]=r):r=e[3];const c=r;let u;e[4]!==a.freedBytes||e[5]!==n?(u=n("settings.openchamber.spaces.places.cleanUp.freed",{size:$o(a.freedBytes)}),e[4]=a.freedBytes,e[5]=n,e[6]=u):u=e[6];let d;e[7]!==u?(d=s.jsx("p",{className:"typography-meta text-muted-foreground",children:u}),e[7]=u,e[8]=d):d=e[8];let l;e[9]!==o||e[10]!==n?(l=o?s.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.spaces.places.cleanUp.keptInUse")}):null,e[9]=o,e[10]=n,e[11]=l):l=e[11];let f;e[12]!==c||e[13]!==n?(f=c?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:n("settings.openchamber.spaces.places.cleanUp.keptFailed")}):null,e[12]=c,e[13]=n,e[14]=f):f=e[14];let p;return e[15]!==d||e[16]!==l||e[17]!==f?(p=s.jsxs("div",{className:"space-y-0.5",role:"status",children:[d,l,f]}),e[15]=d,e[16]=l,e[17]=f,e[18]=p):p=e[18],p},bw=t=>{const e=De.c(68),{placeId:a}=t,{t:n}=Ee();let i;e[0]!==a?(i=z=>Ql(a,z),e[0]=a,e[1]=i):i=e[1];const o=i,[r,,c,u]=nm(o);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d={kind:"idle"},e[2]=d):d=e[2];const[l,f]=m.useState(d);let p;e[3]!==a||e[4]!==c?(p=async()=>{f({kind:"cleaning"});try{const z=await Kg(a);c(z.disk),f({kind:"done",outcome:z})}catch(z){const Q=z;if(!(Q instanceof Error))throw Q;f({kind:"failed",error:Q})}},e[3]=a,e[4]=c,e[5]=p):p=e[5];const g=p;let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h={kind:"idle"},e[6]=h):h=e[6];const[y,b]=m.useState(h),x=m.useRef(0);let w;e[7]!==r.kind||e[8]!==r.value||e[9]!==u||e[10]!==a||e[11]!==c?(w=()=>{if(r.kind!=="read")return;const z=gw(r.value,x.current);if(z===null)return;const Q=new AbortController,V=setTimeout(()=>{Ql(a,Q.signal).then(L=>{Q.signal.aborted||(L.imagePulling?x.current=0:L.imageBytes===0&&z===sm&&(x.current=x.current+1),c(L))},L=>{Q.signal.aborted||u(L)})},z);return()=>{Q.abort(),clearTimeout(V)}},e[7]=r.kind,e[8]=r.value,e[9]=u,e[10]=a,e[11]=c,e[12]=w):w=e[12];let S;e[13]!==r||e[14]!==u||e[15]!==a||e[16]!==c?(S=[r,u,a,c],e[13]=r,e[14]=u,e[15]=a,e[16]=c,e[17]=S):S=e[17],m.useEffect(w,S);let v;e[18]!==a||e[19]!==c?(v=async()=>{b({kind:"starting"}),f(Aw),x.current=0;try{c(await _g(a)),b({kind:"idle"})}catch(z){const Q=z;if(!(Q instanceof Error))throw Q;b({kind:"failed",error:Q})}},e[18]=a,e[19]=c,e[20]=v):v=e[20];const A=v;if(r.kind==="reading"){let z;e[21]!==n?(z=n("settings.openchamber.spaces.places.disk.reading"),e[21]=n,e[22]=z):z=e[22];let Q;return e[23]!==z?(Q=s.jsx(Pi,{tone:"busy",children:z}),e[23]=z,e[24]=Q):Q=e[24],Q}if(r.kind==="failed"){let z;e[25]!==r.error||e[26]!==n?(z=n("settings.openchamber.spaces.places.disk.readFailed",{reason:zn(n,Ka(r.error))}),e[25]=r.error,e[26]=n,e[27]=z):z=e[27];let Q;return e[28]!==z?(Q=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:z}),e[28]=z,e[29]=Q):Q=e[29],Q}let I;e[30]!==r.value.imageFailure||e[31]!==y.error||e[32]!==y.kind?(I=y.kind==="failed"?Ka(y.error):r.value.imageFailure,e[30]=r.value.imageFailure,e[31]=y.error,e[32]=y.kind,e[33]=I):I=e[33];const N=I,k=r.value.imagePulling||y.kind==="starting",P=(r.value.imageBytes??0)+r.value.toolsBytes+r.value.spacesBytes,j=r.value.freeBytes>0&&!r.value.imagePulling;let C;e[34]!==r.value.imageBytes||e[35]!==A||e[36]!==k||e[37]!==n?(C=k?s.jsx(Pi,{tone:"busy",children:n("settings.openchamber.spaces.places.image.downloadingNote")}):r.value.imageBytes===null?s.jsxs("div",{className:"space-y-2",children:[s.jsx(Pi,{tone:"todo",children:n("settings.openchamber.spaces.places.image.missing")}),s.jsxs(H,{size:"sm",variant:"outline",onClick:()=>{A()},children:[s.jsx(te,{name:"download",className:"size-3.5"}),n("settings.openchamber.spaces.places.image.downloadNow")]})]}):s.jsx(Pi,{tone:"ready",children:n("settings.openchamber.spaces.places.image.ready")}),e[34]=r.value.imageBytes,e[35]=A,e[36]=k,e[37]=n,e[38]=C):C=e[38];let E;e[39]!==j||e[40]!==l.kind||e[41]!==r.value.freeBytes||e[42]!==n||e[43]!==P?(E=P>0||l.kind==="cleaning"?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.openchamber.spaces.places.disk.total",{size:$o(P)})}),l.kind==="cleaning"?s.jsxs("span",{className:"inline-flex items-center gap-1.5 typography-meta text-muted-foreground",role:"status",children:[s.jsx(va,{className:"size-3.5"}),n("settings.openchamber.spaces.places.cleanUp.running")]}):j?s.jsx(H,{size:"xs",variant:"outline",onClick:()=>f({kind:"confirming"}),children:n("settings.openchamber.spaces.places.cleanUp.freeUp",{size:$o(r.value.freeBytes)})}):null]}):null,e[39]=j,e[40]=l.kind,e[41]=r.value.freeBytes,e[42]=n,e[43]=P,e[44]=E):E=e[44];let F;e[45]!==N||e[46]!==n?(F=N?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",role:"alert",children:zn(n,N)}):null,e[45]=N,e[46]=n,e[47]=F):F=e[47];let O;e[48]!==l.kind||e[49]!==l.outcome?(O=l.kind==="done"?s.jsx(hw,{outcome:l.outcome}):null,e[48]=l.kind,e[49]=l.outcome,e[50]=O):O=e[50];let K;e[51]!==l.error||e[52]!==l.kind||e[53]!==n?(K=l.kind==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",role:"alert",children:n("settings.openchamber.spaces.places.cleanUp.failed",{reason:zn(n,Ka(l.error))})}):null,e[51]=l.error,e[52]=l.kind,e[53]=n,e[54]=K):K=e[54];const D=l.kind==="confirming"?r.value:null;let M;e[55]===Symbol.for("react.memo_cache_sentinel")?(M=()=>f({kind:"idle"}),e[55]=M):M=e[55];let T;e[56]!==g?(T=()=>{g()},e[56]=g,e[57]=T):T=e[57];let R;e[58]!==D||e[59]!==T?(R=s.jsx(fw,{disk:D,onCancel:M,onConfirm:T}),e[58]=D,e[59]=T,e[60]=R):R=e[60];let $;return e[61]!==E||e[62]!==F||e[63]!==O||e[64]!==K||e[65]!==R||e[66]!==C?($=s.jsxs("div",{className:"space-y-2",children:[C,E,F,O,K,R]}),e[61]=E,e[62]=F,e[63]=O,e[64]=K,e[65]=R,e[66]=C,e[67]=$):$=e[67],$},xw=new Map([["docker","settings.openchamber.spaces.places.docker"]]),vw=new Set(["docker",Wi]),yw=t=>{const e=De.c(62),{place:a,title:n,field:i,spaces:o,spacesError:r,onRetry:c}=t,u=i===void 0?null:i,{t:d}=Ee(),l=re(Tw),f=!!(a.setup?.remedy||a.setup?.job);if(!a.available){let N;e[0]!==c||e[1]!==a||e[2]!==f||e[3]!==d?(N=f?s.jsx($l,{place:a,onRecheck:c,withCheck:!0}):s.jsxs("p",{className:"flex items-start gap-1.5 typography-meta text-foreground",role:"status",children:[s.jsx(te,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 text-[var(--status-info)]"}),s.jsx("span",{children:zn(d,a,a.machine===null?void 0:{machine:a.machine})})]}),e[0]=c,e[1]=a,e[2]=f,e[3]=d,e[4]=N):N=e[4];let k;e[5]!==o||e[6]!==d?(k=o&&o.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:o.length===1?d("settings.openchamber.spaces.places.lastSeenSingle"):d("settings.openchamber.spaces.places.lastSeenPlural",{count:o.length})}),o.map(Ew)]}):null,e[5]=o,e[6]=d,e[7]=k):k=e[7];let P;e[8]!==c||e[9]!==f||e[10]!==d?(P=f?null:s.jsx(H,{size:"sm",variant:"outline",onClick:c,children:d("settings.openchamber.spaces.places.retry")}),e[8]=c,e[9]=f,e[10]=d,e[11]=P):P=e[11];let j;e[12]!==u||e[13]!==N||e[14]!==k||e[15]!==P?(j=s.jsxs("div",{className:"space-y-2",children:[u,N,k,P]}),e[12]=u,e[13]=N,e[14]=k,e[15]=P,e[16]=j):j=e[16];let C;return e[17]!==j||e[18]!==n?(C=s.jsx(ni,{title:n,children:j}),e[17]=j,e[18]=n,e[19]=C):C=e[19],C}let p,g,h,y,b,x,w,S,v;if(e[20]!==u||e[21]!==l||e[22]!==c||e[23]!==a||e[24]!==o||e[25]!==r||e[26]!==d||e[27]!==n){const N=o?.filter(Mw).length??0,k=o?.filter(Dw).length??0,P=o?.filter(Rw)??[],j=a.setup?.memory?.engine;let C;e[37]!==j||e[38]!==a.version||e[39]!==d?(C=j==="colima"?d("settings.openchamber.spaces.places.dockerRunningColima",{version:a.version}):j==="docker_desktop"?d("settings.openchamber.spaces.places.dockerRunningDesktop",{version:a.version}):d("settings.openchamber.spaces.places.dockerRunning",{version:a.version}),e[37]=j,e[38]=a.version,e[39]=d,e[40]=C):C=e[40];const E=C;p=ni,v=n,g="space-y-2",h=u,e[41]!==E||e[42]!==a.id||e[43]!==a.version?(y=vw.has(a.id)&&a.version?s.jsx(Pi,{tone:"ready",children:E}):null,e[41]=E,e[42]=a.id,e[43]=a.version,e[44]=y):y=e[44],e[45]!==c||e[46]!==a?(b=s.jsx($l,{place:a,onRecheck:c}),e[45]=c,e[46]=a,e[47]=b):b=e[47],e[48]!==a.id?(x=s.jsx(bw,{placeId:a.id}),e[48]=a.id,e[49]=x):x=e[49],w=o&&N+k>0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:d("settings.openchamber.spaces.places.spaceCount",{running:N,stopped:k})}):r?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:d("spaces.page.loadFailed",{reason:zn(d,Ka(r))})}):null,S=P.length>0?s.jsxs("div",{className:"space-y-1 pt-1",children:[s.jsx("p",{className:"typography-ui-label text-foreground",children:d("settings.openchamber.spaces.places.leftBehind")}),P.map(F=>s.jsx(gl,{entry:F,actions:l?"sheet":"menu",showFolder:!0},F.id))]}):null,e[20]=u,e[21]=l,e[22]=c,e[23]=a,e[24]=o,e[25]=r,e[26]=d,e[27]=n,e[28]=p,e[29]=g,e[30]=h,e[31]=y,e[32]=b,e[33]=x,e[34]=w,e[35]=S,e[36]=v}else p=e[28],g=e[29],h=e[30],y=e[31],b=e[32],x=e[33],w=e[34],S=e[35],v=e[36];let A;e[50]!==g||e[51]!==h||e[52]!==y||e[53]!==b||e[54]!==x||e[55]!==w||e[56]!==S?(A=s.jsxs("div",{className:g,children:[h,y,b,x,w,S]}),e[50]=g,e[51]=h,e[52]=y,e[53]=b,e[54]=x,e[55]=w,e[56]=S,e[57]=A):A=e[57];let I;return e[58]!==p||e[59]!==A||e[60]!==v?(I=s.jsx(p,{title:v,children:A}),e[58]=p,e[59]=A,e[60]=v,e[61]=I):I=e[61],I},jw=t=>{const e=De.c(59),{machine:a,onChange:n}=t,{t:i}=Ee(),[o,r]=m.useState(a??"");let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={kind:"idle"},e[0]=c):c=e[0];const[u,d]=m.useState(c),[l,f]=m.useState(!1);let p,g;e[1]!==l||e[2]!==a?(p=()=>{l||r(a??"")},g=[l,a],e[1]=l,e[2]=a,e[3]=p,e[4]=g):(p=e[3],g=e[4]),m.useEffect(p,g);let h;e[5]!==n?(h=async T=>{d({kind:"saving"}),Mt("saving");try{const R=await $g(T.trim());Mt("saved"),d({kind:"idle"}),f(!1),n(R)}catch(R){const $=R;if(Mt("error"),!($ instanceof Error))throw $;d({kind:"failed",error:$})}},e[5]=n,e[6]=h):h=e[6];const y=h,b=u.kind==="saving";let x;e[7]!==o?(x=o.trim(),e[7]=o,e[8]=x):x=e[8];const w=x===(a??"");let S;e[9]!==i?(S=i("settings.openchamber.spaces.places.machine.label"),e[9]=i,e[10]=S):S=e[10];let v;e[11]!==i?(v=i("settings.openchamber.spaces.places.machine.info"),e[11]=i,e[12]=v):v=e[12];let A;e[13]!==u.kind?(A=T=>{r(T.target.value),f(!0),u.kind==="failed"&&d({kind:"idle"})},e[13]=u.kind,e[14]=A):A=e[14];let I;e[15]!==o||e[16]!==y||e[17]!==b||e[18]!==w?(I=T=>{T.key==="Enter"&&!b&&!w&&(T.preventDefault(),y(o))},e[15]=o,e[16]=y,e[17]=b,e[18]=w,e[19]=I):I=e[19];let N;e[20]!==i?(N=i("settings.openchamber.spaces.places.machine.placeholder"),e[20]=i,e[21]=N):N=e[21];let k;e[22]!==i?(k=i("settings.openchamber.spaces.places.machine.label"),e[22]=i,e[23]=k):k=e[23];let P;e[24]!==o||e[25]!==b||e[26]!==N||e[27]!==k||e[28]!==A||e[29]!==I?(P=s.jsx(qe,{value:o,onChange:A,onKeyDown:I,placeholder:N,"aria-label":k,className:"h-8 min-w-[14rem] flex-1 max-w-[24rem] font-mono",autoComplete:"off",spellCheck:!1,disabled:b}),e[24]=o,e[25]=b,e[26]=N,e[27]=k,e[28]=A,e[29]=I,e[30]=P):P=e[30];const j=b||w;let C;e[31]!==o||e[32]!==y?(C=()=>{y(o)},e[31]=o,e[32]=y,e[33]=C):C=e[33];let E;e[34]!==b||e[35]!==i?(E=b?s.jsxs(s.Fragment,{children:[s.jsx(va,{className:"size-3.5"}),i("settings.openchamber.spaces.places.machine.checking")]}):i("settings.openchamber.spaces.places.machine.check"),e[34]=b,e[35]=i,e[36]=E):E=e[36];let F;e[37]!==j||e[38]!==C||e[39]!==E?(F=s.jsx(H,{size:"sm",variant:"outline",className:"shrink-0",disabled:j,onClick:C,children:E}),e[37]=j,e[38]=C,e[39]=E,e[40]=F):F=e[40];let O;e[41]!==a||e[42]!==y||e[43]!==b||e[44]!==i?(O=a!==null?s.jsx(H,{size:"sm",variant:"ghost",className:"shrink-0 !font-normal",disabled:b,onClick:()=>{y("")},children:i("settings.openchamber.spaces.places.machine.remove")}):null,e[41]=a,e[42]=y,e[43]=b,e[44]=i,e[45]=O):O=e[45];let K;e[46]!==P||e[47]!==F||e[48]!==O||e[49]!==S||e[50]!==v?(K=s.jsxs(st,{settingsItem:"general.isolated-spaces-machine",label:S,info:v,alignEnd:!1,controlClassName:"flex-wrap",children:[P,F,O]}),e[46]=P,e[47]=F,e[48]=O,e[49]=S,e[50]=v,e[51]=K):K=e[51];let D;e[52]!==u.error||e[53]!==u.kind||e[54]!==i?(D=u.kind==="failed"?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",role:"alert",children:zn(i,Ka(u.error))}):null,e[52]=u.error,e[53]=u.kind,e[54]=i,e[55]=D):D=e[55];let M;return e[56]!==K||e[57]!==D?(M=s.jsxs("div",{className:"space-y-1",children:[K,D]}),e[56]=K,e[57]=D,e[58]=M):M=e[58],M},kw=()=>{const t=De.c(47),{t:e}=Ee(),a=re(Ow),[n,i,o]=nm(Lg),{journey:r,error:c}=nu();let u,d,l,f;if(t[0]!==a||t[1]!==r||t[2]!==c||t[3]!==n.error||t[4]!==n.kind||t[5]!==n.value||t[6]!==o||t[7]!==i||t[8]!==e){f=Symbol.for("react.early_return_sentinel");e:{const g=r?Array.from(r.values()):null;let h;t[13]!==i?(h=()=>{i(),Dr().catch(Fw)},t[13]=i,t[14]=h):h=t[14];const y=h;let b;t[15]!==n.kind||t[16]!==n.value||t[17]!==o?(b=j=>{if(n.kind!=="read")return;const C=n.value.filter(Lw);o(j?[...C,j]:C),Dr().catch(Kw)},t[15]=n.kind,t[16]=n.value,t[17]=o,t[18]=b):b=t[18];const x=b;if(n.kind==="reading"){let j;t[19]!==e?(j=e("settings.openchamber.spaces.places.reading"),t[19]=e,t[20]=j):j=t[20];let C;t[21]!==j?(C=s.jsx("p",{className:"typography-meta text-muted-foreground",children:j}),t[21]=j,t[22]=C):C=t[22],f=C;break e}if(n.kind==="failed"){let j;t[23]!==n.error||t[24]!==e?(j=e("settings.openchamber.spaces.places.readFailed",{reason:zn(e,Ka(n.error))}),t[23]=n.error,t[24]=e,t[25]=j):j=t[25];let C;t[26]!==j?(C=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:j}),t[26]=j,t[27]=C):C=t[27];let E;t[28]!==e?(E=e("settings.openchamber.spaces.places.retry"),t[28]=e,t[29]=E):E=t[29];let F;t[30]!==y||t[31]!==E?(F=s.jsx(H,{size:"sm",variant:"outline",onClick:y,children:E}),t[30]=y,t[31]=E,t[32]=F):F=t[32];let O;t[33]!==C||t[34]!==F?(O=s.jsxs("div",{className:"space-y-2",children:[C,F]}),t[33]=C,t[34]=F,t[35]=O):O=t[35],f=O;break e}let w;t[36]!==n.value?(w=n.value.find(_w)??null,t[36]=n.value,t[37]=w):w=t[37];const S=w,v=S?.machine??null;let A;t[38]!==x||t[39]!==v?(A=s.jsx(jw,{machine:v,onChange:x}),t[38]=x,t[39]=v,t[40]=A):A=t[40];const I=A,N=S?[]:g?.filter($w)??[];let k;t[41]!==e?(k=j=>{const C=xw.get(j.id);return j.machine??(C?e(C):j.id)},t[41]=e,t[42]=k):k=t[42];const P=k;u="space-y-6",d=n.value.map(j=>s.jsx(yw,{place:j,title:P(j),field:j.id===Wi?I:void 0,spaces:g?.filter(C=>C.placeId===j.id)??null,spacesError:c,onRetry:y},j.id)),l=S?null:s.jsx(ni,{title:e("settings.openchamber.spaces.places.machine.title"),children:s.jsxs("div",{className:"space-y-2",children:[I,N.length>0?s.jsx("div",{className:"space-y-1 pt-1",children:N.map(j=>s.jsx(gl,{entry:j,actions:a?"sheet":"menu",showFolder:!0},j.id))}):null]})})}t[0]=a,t[1]=r,t[2]=c,t[3]=n.error,t[4]=n.kind,t[5]=n.value,t[6]=o,t[7]=i,t[8]=e,t[9]=u,t[10]=d,t[11]=l,t[12]=f}else u=t[9],d=t[10],l=t[11],f=t[12];if(f!==Symbol.for("react.early_return_sentinel"))return f;let p;return t[43]!==u||t[44]!==d||t[45]!==l?(p=s.jsxs("div",{className:u,children:[d,l]}),t[43]=u,t[44]=d,t[45]=l,t[46]=p):p=t[46],p};function ww(t){return t+1}function Sw(t){return t.isMobile}function Nw(t){return s.jsx("p",{className:"typography-meta text-muted-foreground",children:t},t)}function Cw(t){return s.jsx("span",{children:t},t)}function Iw(t){return t.reason==="in_use"}function Pw(t){return t.reason==="failed"}function Aw(t){return t.kind==="done"||t.kind==="failed"?{kind:"idle"}:t}function Tw(t){return t.isMobile}function Ew(t){return s.jsxs("div",{className:"flex items-center gap-2 opacity-60",children:[s.jsx(te,{name:"box-3",className:"h-4 w-4 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label truncate text-foreground",children:t.name})]},t.id)}function Mw(t){return t.state==="running"}function Dw(t){return t.state==="exited"}function Rw(t){return t.state==="missing"}function Ow(t){return t.isMobile}function Fw(){}function Lw(t){return t.id!==Wi}function Kw(){}function _w(t){return t.id===Wi}function $w(t){return t.placeId===Wi}const jd=4,zw=()=>{const t=De.c(30),{t:e}=Ee(),[a,n]=m.useState(null),[i,o]=m.useState(!1),r=m.useRef(0);let c,u;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{const S=new AbortController;return qg(S.signal).then(n,()=>{S.signal.aborted||o(!0)}),()=>S.abort()},u=[],t[0]=c,t[1]=u):(c=t[0],u=t[1]),m.useEffect(c,u);let d;t[2]!==a?(d=async S=>{const v=a,A=r.current+1;r.current=A,n(S),Mt("saving");try{const I=await Wg(S);A===r.current&&n(I),Mt("saved")}catch(I){const N=I;if(!(N instanceof Error))throw N;A===r.current&&n(v),Mt("error")}},t[2]=a,t[3]=d):d=t[3];const l=d;if(i){let S;t[4]!==e?(S=e("settings.openchamber.spaces.idleStop.loadFailed"),t[4]=e,t[5]=S):S=t[5];let v;return t[6]!==S?(v=s.jsx("p",{className:"ps-6 typography-ui-label text-[var(--status-error)]",children:S}),t[6]=S,t[7]=v):v=t[7],v}if(!a)return null;const f=a.enabled;let p;t[8]!==l||t[9]!==a?(p=S=>{l({...a,enabled:S})},t[8]=l,t[9]=a,t[10]=p):p=t[10];let g;t[11]!==e?(g=e("settings.openchamber.spaces.idleStop.enabled"),t[11]=e,t[12]=g):g=t[12];let h;t[13]!==e?(h=e("settings.openchamber.spaces.idleStop.enabledAria"),t[13]=e,t[14]=h):h=t[14];let y;t[15]!==e?(y=e("settings.openchamber.spaces.idleStop.enabledInfo"),t[15]=e,t[16]=y):y=t[16];let b;t[17]!==a.enabled||t[18]!==p||t[19]!==g||t[20]!==h||t[21]!==y?(b=s.jsx(ct,{settingsItem:"general.isolated-spaces-idle-stop",checked:f,onChange:p,label:g,ariaLabel:h,info:y}),t[17]=a.enabled,t[18]=p,t[19]=g,t[20]=h,t[21]=y,t[22]=b):b=t[22];let x;t[23]!==l||t[24]!==a||t[25]!==e?(x=a.enabled?s.jsx(_i,{className:"space-y-0",children:s.jsxs(st,{label:e("settings.openchamber.spaces.idleStop.after"),children:[s.jsx(ds,{value:a.hours,onValueChange:S=>{l({...a,hours:S})},min:Vg,max:Bg,step:1,deferExternalValueWhileFocused:!0,"aria-label":e("settings.openchamber.spaces.idleStop.afterAria"),className:ze(us,"tabular-nums")}),s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:e("settings.openchamber.spaces.idleStop.hours")}),s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:()=>{l({...a,hours:jd})},disabled:a.hours===jd,className:Yt,"aria-label":e("settings.openchamber.spaces.idleStop.resetAria"),title:e("settings.common.actions.reset"),children:s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"})})]})}):null,t[23]=l,t[24]=a,t[25]=e,t[26]=x):x=t[26];let w;return t[27]!==b||t[28]!==x?(w=s.jsxs(s.Fragment,{children:[b,x]}),t[27]=b,t[28]=x,t[29]=w):w=t[29],w},Uw=()=>{const t=De.c(19),{t:e}=Ee(),a=re(Vw),{journey:n}=nu();let i,o,r,c,u;if(t[0]!==a||t[1]!==n||t[2]!==e){u=Symbol.for("react.early_return_sentinel");e:{const f=n?Hg(n).filter(Hw):[];if(f.length===0){u=null;break e}i=$e,t[8]!==e?(c=e("settings.openchamber.spaces.withoutProject.title"),t[8]=e,t[9]=c):c=t[9],o="space-y-1";let p;t[10]!==a?(p=g=>s.jsx(gl,{entry:g,actions:a?"sheet":"menu",showFolder:!0},g.id),t[10]=a,t[11]=p):p=t[11],r=f.map(p)}t[0]=a,t[1]=n,t[2]=e,t[3]=i,t[4]=o,t[5]=r,t[6]=c,t[7]=u}else i=t[3],o=t[4],r=t[5],c=t[6],u=t[7];if(u!==Symbol.for("react.early_return_sentinel"))return u;let d;t[12]!==o||t[13]!==r?(d=s.jsx("div",{className:o,children:r}),t[12]=o,t[13]=r,t[14]=d):d=t[14];let l;return t[15]!==i||t[16]!==c||t[17]!==d?(l=s.jsx(i,{title:c,children:d}),t[15]=i,t[16]=c,t[17]=d,t[18]=l):l=t[18],l},Bw=()=>{const{t}=Ee(),e=re(h=>h.isolatedSpacesEnabled),a=re(h=>h.setIsolatedSpacesEnabled),[n,i]=m.useState(!1),[o,r]=m.useState(null),[c,u]=m.useState(null),[d,l]=m.useState(null);m.useEffect(()=>{const h=new AbortController;return Yl(h.signal).then(y=>a(y.enabled),()=>{}),()=>h.abort()},[a]);const f=async h=>{i(!0),l(null),r(null),Mt("saving");try{const y=await zg(h);a(y.enabled),u(y.stillRunning.length>0?y:null),Mt("saved"),y.enabled?Dr().catch(()=>{}):(Ug.getState().forgetForSwitchOff(),eg(),tg())}catch(y){if(Mt("error"),!(y instanceof Error))throw y;l(t("settings.openchamber.spaces.switchFailed",{reason:zn(t,Ka(y))}))}finally{i(!1)}},p=async h=>{if(u(null),h){await f(!0);return}i(!0);const y=await Yl().catch(()=>null);if(i(!1),!y||y.enabled&&y.spaces===null){r({kind:"unknown"});return}const b=y.enabled&&y.spaces?y.spaces.filter(x=>x.state==="running").length:0;b>0?r({kind:"stops",count:b}):await f(!1)},g=o?.kind==="unknown"?t("settings.openchamber.spaces.turnOff.unknown"):o?.count===1?t("settings.openchamber.spaces.turnOff.stopsSingle"):t("settings.openchamber.spaces.turnOff.stopsPlural",{count:o?.count??0});return s.jsxs(s.Fragment,{children:[s.jsx($e,{divider:!1,children:s.jsxs("div",{className:bs,children:[s.jsx(ct,{settingsItem:"general.isolated-spaces",checked:e,disabled:n||o!==null,onChange:h=>{p(h)},label:t("settings.openchamber.spaces.field.enabled"),ariaLabel:t("settings.openchamber.spaces.field.enabledAria"),info:t("settings.openchamber.spaces.field.enabledInfo")}),o?s.jsxs("div",{className:"space-y-2 ps-6",role:"alert",children:[s.jsx("p",{className:"typography-ui-label text-[var(--status-warning)]",children:g}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(H,{size:"sm",variant:"outline",disabled:n,onClick:()=>r(null),children:t("settings.openchamber.spaces.turnOff.cancel")}),s.jsx(H,{size:"sm",disabled:n,onClick:()=>{f(!1)},children:t("settings.openchamber.spaces.turnOff.confirm")})]})]}):null,c?.stillRunning.map(h=>s.jsx("p",{className:"ps-6 typography-ui-label text-[var(--status-warning)]",children:t("settings.openchamber.spaces.turnOff.stillRunning",{name:h.name,reason:zn(t,h)})},h.id)),d?s.jsx("p",{className:"ps-6 typography-ui-label text-[var(--status-error)]",children:d}):null,e?s.jsx(zw,{}):null]})}),e?s.jsx($e,{title:t("settings.openchamber.spaces.places.title"),children:s.jsx(kw,{})}):null,e?s.jsx(Uw,{}):null]})};function Vw(t){return t.isMobile}function Hw(t){return t.state!=="missing"}const Ar="builtin",qw=t=>t.filter(e=>cl(e)&&Wd(e.service,"browser")),Ww="ps-[3.75rem]",Aa=t=>{const e=De.c(23),{icon:a,title:n,summary:i,info:o,ariaLabel:r,checked:c,onChange:u,settingsItem:d}=t;let l;e[0]!==a?(l=s.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center oc-tile-inset rounded-lg text-foreground",children:s.jsx(te,{name:a,className:"size-4"})}),e[0]=a,e[1]=l):l=e[1];let f;e[2]!==n?(f=s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:n}),e[2]=n,e[3]=f):f=e[3];let p;e[4]!==o?(p=s.jsx(ts,{children:o}),e[4]=o,e[5]=p):p=e[5];let g;e[6]!==f||e[7]!==p?(g=s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[f,p]}),e[6]=f,e[7]=p,e[8]=g):g=e[8];let h;e[9]!==i?(h=s.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),e[9]=i,e[10]=h):h=e[10];let y;e[11]!==g||e[12]!==h?(y=s.jsxs("div",{className:"min-w-0 flex-1",children:[g,h]}),e[11]=g,e[12]=h,e[13]=y):y=e[13];let b;e[14]!==r||e[15]!==c||e[16]!==u?(b=s.jsx(La,{checked:c,onCheckedChange:u,"aria-label":r}),e[14]=r,e[15]=c,e[16]=u,e[17]=b):b=e[17];let x;return e[18]!==d||e[19]!==l||e[20]!==y||e[21]!==b?(x=s.jsxs("div",{"data-settings-item":d,className:"flex items-center gap-3 px-4 py-3",children:[l,y,b]}),e[18]=d,e[19]=l,e[20]=y,e[21]=b,e[22]=x):x=e[22],x},Gw=()=>{const t=De.c(184),{t:e}=Ee(),a=re(Jw),n=re(Qw),i=re(Yw),o=re(Zw),r=re(Xw),c=re(e3),u=re(t3),d=re(s3),l=Ps(n3),f=re(a3),p=re(i3),g=re(o3),h=re(r3),y=re(l3),b=re(c3),x=re(d3),w=re(u3),S=re(m3),v=re(p3),A=re(g3);let I;t[0]!==n?(I=Qe=>{n(Qe),jt({agentControlToolEnabled:Qe})},t[0]=n,t[1]=I):I=t[1];const N=I;let k;t[2]!==o?(k=Qe=>{o(Qe),jt({agentScheduleToolEnabled:Qe})},t[2]=o,t[3]=k):k=t[3];const P=k;let j;t[4]!==c?(j=Qe=>{c(Qe),jt({agentWebToolEnabled:Qe})},t[4]=c,t[5]=j):j=t[5];const C=j;let E;t[6]!==x?(E=Qe=>{x(Qe),jt({agentNotifyToolEnabled:Qe})},t[6]=x,t[7]=E):E=t[7];const F=E;let O;t[8]!==S?(O=Qe=>{S(Qe),jt({agentRenderToolEnabled:Qe})},t[8]=S,t[9]=O):O=t[9];const K=O;let D;t[10]!==y?(D=Qe=>{y(Qe),jt({agentKnowledgeToolEnabled:Qe})},t[10]=y,t[11]=D):D=t[11];const M=D;let T;t[12]!==A?(T=Qe=>{A(Qe),jt({agentToolsCodeMode:Qe})},t[12]=A,t[13]=T):T=t[13];const R=T;let $;t[14]===Symbol.for("react.memo_cache_sentinel")?($=[],t[14]=$):$=t[14],Ke.useEffect(f3,$);let z;t[15]!==l?(z=qw(l),t[15]=l,t[16]=z):z=t[16];const Q=z;let V;t[17]!==u||t[18]!==Q?(V=Q.some(Qe=>Qe.id===u)?u:Ar,t[17]=u,t[18]=Q,t[19]=V):V=t[19];const L=V;let B;t[20]!==d?(B=Qe=>{d(Qe),jt({browserProvider:Qe})},t[20]=d,t[21]=B):B=t[21];const W=B;let Y;t[22]!==g?(Y=Qe=>{g(Qe),jt({agentMemoryToolEnabled:Qe}).finally(()=>{Qe&&sg.getState().refresh()})},t[22]=g,t[23]=Y):Y=t[23];const ae=Y;let ee;t[24]!==e?(ee=e("settings.openchamber.tools.title"),t[24]=e,t[25]=ee):ee=t[25];let G;t[26]!==e?(G=e("settings.openchamber.tools.field.agentControlTool"),t[26]=e,t[27]=G):G=t[27];let le;t[28]!==e?(le=e("settings.openchamber.tools.field.agentControlToolSummary"),t[28]=e,t[29]=le):le=t[29];let J;t[30]!==e?(J=e("settings.openchamber.tools.field.agentControlToolInfo"),t[30]=e,t[31]=J):J=t[31];let me;t[32]!==e?(me=e("settings.openchamber.tools.field.agentControlToolAria"),t[32]=e,t[33]=me):me=t[33];let fe;t[34]!==a||t[35]!==N||t[36]!==G||t[37]!==le||t[38]!==J||t[39]!==me?(fe=s.jsx(Aa,{icon:"node-tree",settingsItem:"sessions.agent-control-tool",checked:a,onChange:N,title:G,summary:le,info:J,ariaLabel:me}),t[34]=a,t[35]=N,t[36]=G,t[37]=le,t[38]=J,t[39]=me,t[40]=fe):fe=t[40];let oe;t[41]!==e?(oe=e("settings.openchamber.tools.field.agentScheduleTool"),t[41]=e,t[42]=oe):oe=t[42];let pe;t[43]!==e?(pe=e("settings.openchamber.tools.field.agentScheduleToolSummary"),t[43]=e,t[44]=pe):pe=t[44];let se;t[45]!==e?(se=e("settings.openchamber.tools.field.agentScheduleToolInfo"),t[45]=e,t[46]=se):se=t[46];let ve;t[47]!==e?(ve=e("settings.openchamber.tools.field.agentScheduleToolAria"),t[47]=e,t[48]=ve):ve=t[48];let be;t[49]!==i||t[50]!==P||t[51]!==oe||t[52]!==pe||t[53]!==se||t[54]!==ve?(be=s.jsx(Aa,{icon:"calendar-schedule",settingsItem:"sessions.agent-schedule-tool",checked:i,onChange:P,title:oe,summary:pe,info:se,ariaLabel:ve}),t[49]=i,t[50]=P,t[51]=oe,t[52]=pe,t[53]=se,t[54]=ve,t[55]=be):be=t[55];let ne;t[56]!==e?(ne=e("settings.openchamber.tools.field.agentWebTool"),t[56]=e,t[57]=ne):ne=t[57];let we;t[58]!==e?(we=e("settings.openchamber.tools.field.agentWebToolSummary"),t[58]=e,t[59]=we):we=t[59];let Ne;t[60]!==e?(Ne=e("settings.openchamber.tools.field.agentWebToolInfo"),t[60]=e,t[61]=Ne):Ne=t[61];let Ie;t[62]!==e?(Ie=e("settings.openchamber.tools.field.agentWebToolAria"),t[62]=e,t[63]=Ie):Ie=t[63];let Ce;t[64]!==r||t[65]!==C||t[66]!==ne||t[67]!==we||t[68]!==Ne||t[69]!==Ie?(Ce=s.jsx(Aa,{icon:"global",settingsItem:"sessions.agent-web-tool",checked:r,onChange:C,title:ne,summary:we,info:Ne,ariaLabel:Ie}),t[64]=r,t[65]=C,t[66]=ne,t[67]=we,t[68]=Ne,t[69]=Ie,t[70]=Ce):Ce=t[70];let Me;t[71]===Symbol.for("react.memo_cache_sentinel")?(Me=ze("flex min-w-0 items-center gap-2 pb-3 pe-4",Ww),t[71]=Me):Me=t[71];let he;t[72]!==e?(he=e("settings.openchamber.tools.browserProvider.label"),t[72]=e,t[73]=he):he=t[73];let Pe;t[74]!==he?(Pe=s.jsx("span",{className:"truncate typography-meta text-muted-foreground",children:he}),t[74]=he,t[75]=Pe):Pe=t[75];let Re;t[76]!==e?(Re=e("settings.openchamber.tools.browserProvider.info"),t[76]=e,t[77]=Re):Re=t[77];let ce;t[78]!==Re?(ce=s.jsx(ts,{children:Re}),t[78]=Re,t[79]=ce):ce=t[79];const je=!r||Q.length===0;let de;t[80]!==e?(de=e("settings.openchamber.tools.browserProvider.aria"),t[80]=e,t[81]=de):de=t[81];let ie;t[82]!==Q||t[83]!==e?(ie=s.jsx(Kt,{children:Qe=>Qe===Ar?e("settings.openchamber.tools.browserProvider.option.builtin"):Q.find(_=>_.id===Qe)?.name??null}),t[82]=Q,t[83]=e,t[84]=ie):ie=t[84];let xe;t[85]!==de||t[86]!==ie?(xe=s.jsx(Ct,{className:"ms-auto w-auto min-w-0 max-w-[14rem]","aria-label":de,children:ie}),t[85]=de,t[86]=ie,t[87]=xe):xe=t[87];let Se;t[88]!==e?(Se=e("settings.openchamber.tools.browserProvider.option.builtin"),t[88]=e,t[89]=Se):Se=t[89];let Le;t[90]!==Se?(Le=s.jsx(bt,{value:Ar,children:Se}),t[90]=Se,t[91]=Le):Le=t[91];let Ue;t[92]!==Q?(Ue=Q.map(h3),t[92]=Q,t[93]=Ue):Ue=t[93];let Ye;t[94]!==Le||t[95]!==Ue?(Ye=s.jsxs(It,{children:[Le,Ue]}),t[94]=Le,t[95]=Ue,t[96]=Ye):Ye=t[96];let lt;t[97]!==W||t[98]!==L||t[99]!==je||t[100]!==xe||t[101]!==Ye?(lt=s.jsxs(Pt,{value:L,onValueChange:W,disabled:je,children:[xe,Ye]}),t[97]=W,t[98]=L,t[99]=je,t[100]=xe,t[101]=Ye,t[102]=lt):lt=t[102];let at;t[103]!==Pe||t[104]!==ce||t[105]!==lt?(at=s.jsxs("div",{"data-settings-item":"sessions.browser-provider",className:Me,children:[Pe,ce,lt]}),t[103]=Pe,t[104]=ce,t[105]=lt,t[106]=at):at=t[106];let ut;t[107]!==Ce||t[108]!==at?(ut=s.jsxs("div",{children:[Ce,at]}),t[107]=Ce,t[108]=at,t[109]=ut):ut=t[109];let vt;t[110]!==e?(vt=e("settings.openchamber.tools.field.agentNotifyTool"),t[110]=e,t[111]=vt):vt=t[111];let We;t[112]!==e?(We=e("settings.openchamber.tools.field.agentNotifyToolSummary"),t[112]=e,t[113]=We):We=t[113];let Ze;t[114]!==e?(Ze=e("settings.openchamber.tools.field.agentNotifyToolInfo"),t[114]=e,t[115]=Ze):Ze=t[115];let Xe;t[116]!==e?(Xe=e("settings.openchamber.tools.field.agentNotifyToolAria"),t[116]=e,t[117]=Xe):Xe=t[117];let it;t[118]!==b||t[119]!==F||t[120]!==vt||t[121]!==We||t[122]!==Ze||t[123]!==Xe?(it=s.jsx(Aa,{icon:"notification-3",settingsItem:"sessions.agent-notify-tool",checked:b,onChange:F,title:vt,summary:We,info:Ze,ariaLabel:Xe}),t[118]=b,t[119]=F,t[120]=vt,t[121]=We,t[122]=Ze,t[123]=Xe,t[124]=it):it=t[124];let dt;t[125]!==e?(dt=e("settings.openchamber.tools.field.agentRenderTool"),t[125]=e,t[126]=dt):dt=t[126];let Be;t[127]!==e?(Be=e("settings.openchamber.tools.field.agentRenderToolSummary"),t[127]=e,t[128]=Be):Be=t[128];let ot;t[129]!==e?(ot=e("settings.openchamber.tools.field.agentRenderToolInfo"),t[129]=e,t[130]=ot):ot=t[130];let et;t[131]!==e?(et=e("settings.openchamber.tools.field.agentRenderToolAria"),t[131]=e,t[132]=et):et=t[132];let ye;t[133]!==w||t[134]!==K||t[135]!==dt||t[136]!==Be||t[137]!==ot||t[138]!==et?(ye=s.jsx(Aa,{icon:"bar-chart-box",settingsItem:"sessions.agent-render-tool",checked:w,onChange:K,title:dt,summary:Be,info:ot,ariaLabel:et}),t[133]=w,t[134]=K,t[135]=dt,t[136]=Be,t[137]=ot,t[138]=et,t[139]=ye):ye=t[139];let Z;t[140]!==e?(Z=e("settings.openchamber.tools.field.agentKnowledgeTool"),t[140]=e,t[141]=Z):Z=t[141];let Oe;t[142]!==e?(Oe=e("settings.openchamber.tools.field.agentKnowledgeToolSummary"),t[142]=e,t[143]=Oe):Oe=t[143];let Ve;t[144]!==e?(Ve=e("settings.openchamber.tools.field.agentKnowledgeToolInfo"),t[144]=e,t[145]=Ve):Ve=t[145];let X;t[146]!==e?(X=e("settings.openchamber.tools.field.agentKnowledgeToolAria"),t[146]=e,t[147]=X):X=t[147];let _e;t[148]!==h||t[149]!==M||t[150]!==Z||t[151]!==Oe||t[152]!==Ve||t[153]!==X?(_e=s.jsx(Aa,{icon:"sticky-note",settingsItem:"sessions.agent-knowledge-tool",checked:h,onChange:M,title:Z,summary:Oe,info:Ve,ariaLabel:X}),t[148]=h,t[149]=M,t[150]=Z,t[151]=Oe,t[152]=Ve,t[153]=X,t[154]=_e):_e=t[154];let nt;t[155]!==p||t[156]!==f||t[157]!==ae||t[158]!==e?(nt=p?s.jsx(Aa,{icon:"brain",settingsItem:"sessions.agent-memory-tool",checked:f,onChange:ae,title:e("settings.openchamber.tools.field.agentMemoryTool"),summary:e("settings.openchamber.tools.field.agentMemoryToolSummary"),info:e("settings.openchamber.tools.field.agentMemoryToolInfo"),ariaLabel:e("settings.openchamber.tools.field.agentMemoryToolAria")}):null,t[155]=p,t[156]=f,t[157]=ae,t[158]=e,t[159]=nt):nt=t[159];let ht;t[160]!==fe||t[161]!==be||t[162]!==ut||t[163]!==it||t[164]!==ye||t[165]!==_e||t[166]!==nt?(ht=s.jsxs("div",{className:"max-w-[44rem] oc-tile divide-y divide-[var(--interactive-border)] rounded-xl",children:[fe,be,ut,it,ye,_e,nt]}),t[160]=fe,t[161]=be,t[162]=ut,t[163]=it,t[164]=ye,t[165]=_e,t[166]=nt,t[167]=ht):ht=t[167];let yt;t[168]!==e?(yt=e("settings.openchamber.tools.field.agentToolsCodeMode"),t[168]=e,t[169]=yt):yt=t[169];let kt;t[170]!==e?(kt=e("settings.openchamber.tools.field.agentToolsCodeModeAria"),t[170]=e,t[171]=kt):kt=t[171];let He;t[172]!==e?(He=e("settings.openchamber.tools.field.agentToolsCodeModeInfo"),t[172]=e,t[173]=He):He=t[173];let Je;t[174]!==v||t[175]!==R||t[176]!==yt||t[177]!==kt||t[178]!==He?(Je=s.jsx(ct,{className:"mt-4",settingsItem:"sessions.agent-tools-code-mode",checked:v,onChange:R,label:yt,ariaLabel:kt,info:He}),t[174]=v,t[175]=R,t[176]=yt,t[177]=kt,t[178]=He,t[179]=Je):Je=t[179];let mt;return t[180]!==ee||t[181]!==ht||t[182]!==Je?(mt=s.jsxs($e,{title:ee,children:[ht,Je]}),t[180]=ee,t[181]=ht,t[182]=Je,t[183]=mt):mt=t[183],mt};function Jw(t){return t.agentControlToolEnabled}function Qw(t){return t.setAgentControlToolEnabled}function Yw(t){return t.agentScheduleToolEnabled}function Zw(t){return t.setAgentScheduleToolEnabled}function Xw(t){return t.agentWebToolEnabled}function e3(t){return t.setAgentWebToolEnabled}function t3(t){return t.browserProvider}function s3(t){return t.setBrowserProvider}function n3(t){return t.guests}function a3(t){return t.agentMemoryToolEnabled}function i3(t){return t.agentMemoryFeatureAvailable}function o3(t){return t.setAgentMemoryToolEnabled}function r3(t){return t.agentKnowledgeToolEnabled}function l3(t){return t.setAgentKnowledgeToolEnabled}function c3(t){return t.agentNotifyToolEnabled}function d3(t){return t.setAgentNotifyToolEnabled}function u3(t){return t.agentRenderToolEnabled}function m3(t){return t.setAgentRenderToolEnabled}function p3(t){return t.agentToolsCodeMode}function g3(t){return t.setAgentToolsCodeMode}function f3(){nn()}function h3(t){return s.jsx(bt,{value:t.id,children:t.name},t.id)}const ei=Jo(t=>({patches:{},blocked:{},setDraft:(e,a,n)=>t(i=>({patches:{...i.patches,[e]:a??void 0},blocked:{...i.blocked,[e]:n}}))})),b3=()=>{const{patches:t}=ei.getState(),e={...t.app,...t.network};return Object.keys(e).length>0?e:null},am=async()=>{const t=b3();return t?(await jt(t)).ok:!1},x3=()=>{const{t}=Ee(),e=is()&&ri(),[a,n]=Ke.useState(!1),[i,o]=Ke.useState(!1),[r,c]=Ke.useState(!1),[u,d]=Ke.useState(""),[l,f]=Ke.useState(!1),[p,g]=Ke.useState(!1),[h,y]=Ke.useState(null),[b,x]=Ke.useState(!0),[w,S]=Ke.useState(!1),[v,A]=Ke.useState(null),[I,N]=Ke.useState(null);Ke.useEffect(()=>{if(!e){x(!1);return}let V=!1;return(async()=>{try{const L=await fn();if(!L)throw new Error(t("settings.openchamber.desktopNetwork.error.loadFailed"));if(V)return;const B=L.desktopLanAccessEnabled===!0;n(B),o(B),c(L.hasDesktopUiPassword===!0),d(""),f(!1),g(L.desktopLanAccessActive===!0),y(L.desktopLanAccessBlockedReason??null),A(null)}catch(L){V||A(L instanceof Error?L.message:t("settings.openchamber.desktopNetwork.error.loadFailed"))}finally{V||x(!1)}})(),()=>{V=!0}},[e,t]),Ke.useEffect(()=>{if(!e||!i){N(null);return}let V=!1;return(async()=>{const L=await Zd();V||N(L)})(),()=>{V=!0}},[i,e]);const k=u.trim(),P=k.length>0||l,j=i!==a||P,C=Ke.useMemo(()=>{if(typeof window>"u")return null;const L=qi()||window.location.href;let B=0;try{B=Number(new URL(L).port)}catch{B=Number(window.location.port)}return Number.isFinite(B)&&B>0?B:null},[]),E=i&&p&&I&&C?`http://${I}:${C}`:null,F=k.length>0||r&&!l,O=i&&!F,K=a&&!p&&h==="missing-password",D=Ki(V=>V.networkAccessBlocked)||h==="enterprise-mode",M=ei(V=>V.setDraft),T=ei(V=>!!(V.patches.app||V.patches.network)),R=b||w||!T||O;Ke.useEffect(()=>{M("network",j&&!O?{...i!==a?{desktopLanAccessEnabled:i}:{},...k?{desktopUiPassword:k}:l?{desktopUiPassword:""}:{}}:null,O)},[i,j,O,k,l,a,M]),Ke.useEffect(()=>()=>M("network",null,!1),[M]);const $=Ke.useCallback(V=>{d(V),V.trim()&&f(!1)},[]),z=Ke.useCallback(()=>{d(""),f(!0),o(!1)},[]),Q=Ke.useCallback(async()=>{S(!0),A(null);try{if(!await am())throw new Error(t("settings.openchamber.desktopNetwork.error.saveFailed"));if(n(i),k?c(!0):l&&c(!1),d(""),f(!1),!await au())throw new Error(t("settings.openchamber.desktopNetwork.error.savedRestartFailed"))}catch(V){A(V instanceof Error?V.message:t("settings.openchamber.desktopNetwork.error.saveFailed")),S(!1)}},[i,k,l,t]);return e?s.jsxs($e,{title:t("settings.layout.general.network.title"),contentClassName:"space-y-4",children:[s.jsxs(St,{settingsItem:"sessions.desktop-ui-password",label:s.jsx("label",{htmlFor:"desktop-ui-password",children:t("settings.openchamber.desktopPassword.field.password")}),info:t("settings.openchamber.desktopPassword.field.passwordDescription"),children:[s.jsx(qe,{id:"desktop-ui-password",type:"password",className:"h-8 min-w-0 flex-1",value:u,onChange:V=>$(V.target.value),placeholder:t(r&&!l?"settings.openchamber.desktopPassword.field.passwordSetPlaceholder":"settings.openchamber.desktopPassword.field.passwordPlaceholder"),disabled:b||w,required:i&&!F,"aria-invalid":O}),r&&!l?s.jsx(H,{type:"button",variant:"ghost",size:"xs",onClick:z,disabled:b||w,className:"shrink-0 !font-normal",children:t("settings.openchamber.desktopPassword.actions.removePassword")}):null]}),s.jsx(ct,{settingsItem:"sessions.desktop-lan-access",checked:i&&!D,onChange:o,disabled:b||w||D,label:t("settings.openchamber.desktopNetwork.field.allowLanAccess"),info:t("settings.openchamber.desktopNetwork.field.allowLanAccessDescription"),description:D?s.jsx("span",{className:"block",children:t("settings.openchamber.desktopNetwork.field.enterpriseBlocked")}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block text-[var(--status-warning)]/85",children:t("settings.openchamber.desktopNetwork.field.warning")}),O||K?s.jsx("span",{className:"block text-[var(--status-warning)]/85",children:t("settings.openchamber.desktopNetwork.field.passwordRequiredWarning")}):null]}),ariaLabel:t("settings.openchamber.desktopNetwork.field.allowLanAccessAria")}),E&&!D?s.jsxs("p",{className:"typography-meta text-muted-foreground",children:[t(j&&!a?"settings.openchamber.desktopNetwork.hint.openAfterRestart":"settings.openchamber.desktopNetwork.hint.openNow"),s.jsx("span",{className:"font-mono text-foreground",children:E})]}):null,v?s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:v}):null,s.jsx(H,{type:"button",size:"xs",onClick:Q,disabled:R,className:"!font-normal",children:t(w?"settings.common.actions.saving":"settings.openchamber.desktopNetwork.actions.saveAndRestart")})]}):null},im=new Set(["shift","control","alt","meta"]),om=3,v3=3e3,rm={maxKeys:om,macModifiers:rg()};function Sl(t,{macModifiers:e}){const a=[];return e?(t.metaKey&&a.push("mod"),t.ctrlKey&&a.push("ctrl")):(t.ctrlKey&&a.push("mod"),t.metaKey&&a.push("super")),t.shiftKey&&a.push("shift"),t.altKey&&a.push("alt"),a}function Nl(t,e=!1){const a=new Set;return t.altKey&&a.add("alt"),t.ctrlKey&&a.add("control"),t.metaKey&&a.add("meta"),t.shiftKey&&a.add("shift"),e&&a.add(t.key.toLowerCase()),a.size}function y3(t){return t.action.customizable}function kd(t,e){if(Nl(t)>e.maxKeys)return null;const a=Sl(t,e);return a.length>0?qo(a.join("+")):null}function j3(t,e){if(im.has(t.key.toLowerCase())||Nl(t,!0)>e.maxKeys)return null;const a=ig(og(t));return a?qo([...Sl(t,e),a].join("+")):null}function k3(t,e){const a=t.key.toLowerCase();if(!im.has(a)||Nl(t,!0)>e.maxKeys)return null;const n=Sl({metaKey:t.metaKey||a==="meta",ctrlKey:t.ctrlKey||a==="control",shiftKey:t.shiftKey||a==="shift",altKey:t.altKey||a==="alt"},e);return n.length>0?qo(n.join("+")):null}function wd(t){return t.chords.length>0?{...t,livePreview:null,settled:!0}:t}function w3(t,e,a,n=2,i={}){const o={...rm,...i};if(e.repeat||e.isComposing)return t;if(a==="keyup")return{...t,livePreview:kd(e,o)};if(e.key==="Backspace")return{chords:t.chords.slice(0,-1),livePreview:null,settled:!1};const r=j3(e,o);if(r){if(t.settled){const u=[r];return{chords:u,livePreview:null,settled:u.length>=n}}const c=t.chords.length<n?[...t.chords,r]:t.chords;return{chords:c,livePreview:null,settled:c.length>=n}}return{...t,livePreview:kd(e,o)}}const Cl=t=>{const e=De.c(122),{action:a,overrides:n,onSave:i,onOpenChange:o,maxChords:r,maxKeys:c}=t,u=r===void 0?2:r,d=c===void 0?om:c,{t:l}=Ee();let f;e[0]!==l?(f=ve=>l(ve.settingsLabelKey),e[0]=l,e[1]=f):f=e[1];const p=f;let g;e[2]!==p?(g=ve=>ve.action.customizable?p(ve.action):Hn(ve.action.defaultBinding),e[2]=p,e[3]=g):g=e[3];const h=g;let y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y={chords:[],livePreview:null,settled:!1},e[4]=y):y=e[4];const[b,x]=m.useState(y),w=m.useRef(null);let S,v;e[5]!==a?(S=()=>{a&&(x({chords:[],livePreview:null,settled:!1}),w.current?.focus())},v=[a],e[5]=a,e[6]=S,e[7]=v):(S=e[6],v=e[7]),m.useEffect(S,v);const A=b.chords.length===1&&!b.settled;let I,N;e[8]!==A?(I=()=>{if(!A)return;const ve=window.setTimeout(()=>x(wd),v3);return()=>window.clearTimeout(ve)},N=[A],e[8]=A,e[9]=I,e[10]=N):(I=e[9],N=e[10]),m.useEffect(I,N);let k;e[11]!==b.chords?(k=qo(b.chords.join(" ")),e[11]=b.chords,e[12]=k):k=e[12];const P=k;let j;e[13]!==a||e[14]!==P||e[15]!==n?(j=a&&P?ng(a.id,P,n):[],e[13]=a,e[14]=P,e[15]=n,e[16]=j):j=e[16];const C=j;let E;e[17]!==C?(E=C.find(S3),e[17]=C,e[18]=E):E=e[18];const F=E;let O,K,D,M,T,R,$,z,Q,V,L,B,W,Y,ae;if(e[19]!==a||e[20]!==p||e[21]!==P||e[22]!==h||e[23]!==C||e[24]!==u||e[25]!==d||e[26]!==o||e[27]!==i||e[28]!==F||e[29]!==b||e[30]!==l){const ve=C.filter(y3);T=ve.find(N3);const be=ve.find(C3),ne=C.find(I3);let we;e[46]!==o?(we=()=>o(!1),e[46]=o,e[47]=we):we=e[47],D=we,M=()=>{b.settled||x(wd),!(!a||!P||F||T)&&(i(a.id,P,be?.action.id),D())};let Ne;e[48]!==a||e[49]!==u||e[50]!==d||e[51]!==b?(Ne=(Ue,Ye)=>{Ue.preventDefault(),Ue.stopPropagation();const lt=!!(a&&"prefixStyle"in a&&a.prefixStyle);if(Ye==="keyup"&&lt&&b.chords.length===0){const ut=k3(Ue,{...rm,maxKeys:d});if(ut){x({chords:[ut],livePreview:null,settled:!0});return}}const at=w3(b,{altKey:Ue.altKey,code:Ue.nativeEvent.code,ctrlKey:Ue.ctrlKey,isComposing:Ue.nativeEvent.isComposing,key:Ue.key,metaKey:Ue.metaKey,repeat:Ue.repeat,shiftKey:Ue.shiftKey},Ye,u,{maxKeys:d});x(lt&&at.chords.length>1?b:at)},e[48]=a,e[49]=u,e[50]=d,e[51]=b,e[52]=Ne):Ne=e[52];const Ie=Ne;K=Tt,Y=a!==null,ae=P3,O=Et,R="max-w-md",$=w,z=!1;let Ce;e[53]!==a||e[54]!==p||e[55]!==l?(Ce=a?l("settings.openchamber.keyboardShortcuts.dialog.title",{action:p(a)}):"",e[53]=a,e[54]=p,e[55]=l,e[56]=Ce):Ce=e[56];let Me;e[57]!==Ce?(Me=s.jsx(Ot,{children:Ce}),e[57]=Ce,e[58]=Me):Me=e[58];const he=u===1?"settings.openchamber.keyboardShortcuts.dialog.instructionsSingle":"settings.openchamber.keyboardShortcuts.dialog.instructions";let Pe;e[59]!==l||e[60]!==he?(Pe=l(he),e[59]=l,e[60]=he,e[61]=Pe):Pe=e[61];let Re;e[62]!==Pe?(Re=s.jsx(Ft,{children:Pe}),e[62]=Pe,e[63]=Re):Re=e[63],e[64]!==Me||e[65]!==Re?(Q=s.jsxs(Rt,{children:[Me,Re]}),e[64]=Me,e[65]=Re,e[66]=Q):Q=e[66];let ce,je;e[67]!==Ie?(ce=Ue=>Ie(Ue,"keydown"),je=Ue=>Ie(Ue,"keyup"),e[67]=Ie,e[68]=ce,e[69]=je):(ce=e[68],je=e[69]);let de;e[70]===Symbol.for("react.memo_cache_sentinel")?(de=()=>x(A3),e[70]=de):de=e[70];let ie;e[71]!==b.chords?(ie=b.chords.map(T3),e[71]=b.chords,e[72]=ie):ie=e[72];let xe;e[73]!==b.livePreview?(xe=b.livePreview?s.jsx("kbd",{className:"rounded-md border border-dashed border-border bg-muted px-3 py-2 typography-ui-label text-muted-foreground",children:Hn(b.livePreview)}):null,e[73]=b.livePreview,e[74]=xe):xe=e[74];let Se;e[75]!==b.chords.length||e[76]!==b.livePreview||e[77]!==l?(Se=b.chords.length===0&&!b.livePreview?s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:l("settings.openchamber.keyboardShortcuts.dialog.recording")}):null,e[75]=b.chords.length,e[76]=b.livePreview,e[77]=l,e[78]=Se):Se=e[78];let Le;e[79]!==ie||e[80]!==xe||e[81]!==Se?(Le=s.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[ie,xe,Se]}),e[79]=ie,e[80]=xe,e[81]=Se,e[82]=Le):Le=e[82],e[83]!==ce||e[84]!==je||e[85]!==Le?(V=s.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-lg border border-border bg-[var(--surface-elevated)] px-4 py-5 text-center outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,ref:w,onKeyDown:ce,onKeyUp:je,onBlur:de,children:Le}),e[83]=ce,e[84]=je,e[85]=Le,e[86]=V):V=e[86],L=b.settled&&F?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:l("settings.openchamber.keyboardShortcuts.error.internalConflict")}):b.settled&&T?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:l("settings.openchamber.keyboardShortcuts.error.prefixConflict",{action:p(T.action)})}):null,B=b.settled&&be&&!F&&!T?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:l("settings.openchamber.keyboardShortcuts.error.exactConflict",{action:p(be.action)})}):null,W=b.settled&&ne&&!F&&!T?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:l("settings.openchamber.keyboardShortcuts.warning.contextualPrefix",{action:h(ne)})}):null,e[19]=a,e[20]=p,e[21]=P,e[22]=h,e[23]=C,e[24]=u,e[25]=d,e[26]=o,e[27]=i,e[28]=F,e[29]=b,e[30]=l,e[31]=O,e[32]=K,e[33]=D,e[34]=M,e[35]=T,e[36]=R,e[37]=$,e[38]=z,e[39]=Q,e[40]=V,e[41]=L,e[42]=B,e[43]=W,e[44]=Y,e[45]=ae}else O=e[31],K=e[32],D=e[33],M=e[34],T=e[35],R=e[36],$=e[37],z=e[38],Q=e[39],V=e[40],L=e[41],B=e[42],W=e[43],Y=e[44],ae=e[45];let ee;e[87]!==P||e[88]!==b.settled||e[89]!==l?(ee=b.settled&&P&&ag(P)?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:l("settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut")}):null,e[87]=P,e[88]=b.settled,e[89]=l,e[90]=ee):ee=e[90];let G;e[91]!==l?(G=l("settings.common.actions.cancel"),e[91]=l,e[92]=G):G=e[92];let le;e[93]!==D||e[94]!==G?(le=s.jsx(H,{type:"button",variant:"ghost",size:"sm",onClick:D,children:G}),e[93]=D,e[94]=G,e[95]=le):le=e[95];const J=!P||b.settled&&(!!F||!!T);let me;e[96]!==l?(me=l("settings.openchamber.keyboardShortcuts.actions.confirm"),e[96]=l,e[97]=me):me=e[97];let fe;e[98]!==M||e[99]!==J||e[100]!==me?(fe=s.jsx(H,{type:"button",size:"sm",disabled:J,onClick:M,children:me}),e[98]=M,e[99]=J,e[100]=me,e[101]=fe):fe=e[101];let oe;e[102]!==le||e[103]!==fe?(oe=s.jsxs(Wt,{children:[le,fe]}),e[102]=le,e[103]=fe,e[104]=oe):oe=e[104];let pe;e[105]!==O||e[106]!==R||e[107]!==$||e[108]!==z||e[109]!==Q||e[110]!==V||e[111]!==L||e[112]!==B||e[113]!==W||e[114]!==ee||e[115]!==oe?(pe=s.jsxs(O,{className:R,initialFocus:$,showCloseButton:z,children:[Q,V,L,B,W,ee,oe]}),e[105]=O,e[106]=R,e[107]=$,e[108]=z,e[109]=Q,e[110]=V,e[111]=L,e[112]=B,e[113]=W,e[114]=ee,e[115]=oe,e[116]=pe):pe=e[116];let se;return e[117]!==K||e[118]!==Y||e[119]!==ae||e[120]!==pe?(se=s.jsx(K,{open:Y,onOpenChange:ae,children:pe}),e[117]=K,e[118]=Y,e[119]=ae,e[120]=pe,e[121]=se):se=e[121],se};function S3(t){return!t.action.customizable&&t.kind!=="contextual-prefix"}function N3(t){return t.kind==="prefix"}function C3(t){return t.kind==="exact"}function I3(t){return t.kind==="contextual-prefix"}function P3(t,e){t||e.cancel()}function A3(t){return{...t,livePreview:null}}function T3(t,e){return s.jsx("kbd",{className:"rounded-md border border-border bg-muted px-3 py-2 typography-ui-label text-foreground",children:Hn(t)},`${t}-${e}`)}const Tr=[.3,.35,.4,.45,.5,.6,1],E3=t=>{const e=De.c(41),{quake:a,miniChatCombo:n,onReleaseMiniChatShortcut:i}=t,{t:o}=Ee(),[r,c]=Ke.useState(!1),u=re(M3),d=re(D3);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=Wo().find(R3)??null,e[0]=l):l=e[0];const f=l;let p;e[1]!==n||e[2]!==u?(p=n?{...u,mini_chat_global:n}:u,e[1]=n,e[2]=u,e[3]=p):p=e[3];const g=p;let h=Tr[0];for(const D of Tr)Math.abs(D-a.heightFraction)<Math.abs(h-a.heightFraction)&&(h=D);const y=String(h),{saveShortcut:b}=a;let x;e[4]!==i||e[5]!==b||e[6]!==d||e[7]!==u?(x=(D,M,T)=>{b(M).then(R=>{if(!(!R||!T)){if(T==="mini_chat_global"){i();return}d(T,_n),jt({shortcutOverrides:{...u,[T]:_n}})}})},e[4]=i,e[5]=b,e[6]=d,e[7]=u,e[8]=x):x=e[8];const w=x;if(!a.supported)return null;const S=a.enabled;let v;e[9]!==a?(v=D=>{D!==a.enabled&&a.setEnabled(D)},e[9]=a,e[10]=v):v=e[10];const A=a.isSaving;let I;e[11]!==o?(I=o("settings.openchamber.desktopNetwork.field.quakeMode"),e[11]=o,e[12]=I):I=e[12];let N;e[13]!==o?(N=o("settings.openchamber.desktopNetwork.field.quakeModeDescription"),e[13]=o,e[14]=N):N=e[14];let k;e[15]!==o?(k=o("settings.openchamber.desktopNetwork.field.quakeModeAria"),e[15]=o,e[16]=k):k=e[16];let P;e[17]!==a.enabled||e[18]!==a.isSaving||e[19]!==v||e[20]!==I||e[21]!==N||e[22]!==k?(P=s.jsx(ct,{settingsItem:"sessions.desktop-quake-mode",checked:S,onChange:v,disabled:A,label:I,info:N,ariaLabel:k}),e[17]=a.enabled,e[18]=a.isSaving,e[19]=v,e[20]=I,e[21]=N,e[22]=k,e[23]=P):P=e[23];let j;e[24]!==a||e[25]!==o?(j=a.enabled?s.jsxs(st,{label:o("settings.openchamber.desktopNetwork.field.quakeModeShortcut"),info:o("settings.openchamber.desktopNetwork.field.quakeModeShortcutDescription"),description:a.combo&&!a.active?s.jsx("span",{className:"block text-[var(--status-warning)]",children:o("settings.openchamber.desktopNetwork.field.quakeModeShortcutInactive")}):void 0,children:[s.jsx("kbd",{className:"min-w-32 oc-tile-inset rounded-md px-2 py-1 text-center typography-meta text-foreground",children:a.combo?Hn(a.combo):o("settings.openchamber.keyboardShortcuts.unassigned")}),s.jsx(H,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",disabled:a.isSaving,onClick:()=>c(!0),children:o("settings.openchamber.keyboardShortcuts.actions.edit")}),a.storedCombo?s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",disabled:a.isSaving,onClick:()=>{a.saveShortcut(null)},children:o("settings.common.actions.reset")}):null]}):null,e[24]=a,e[25]=o,e[26]=j):j=e[26];let C;e[27]!==y||e[28]!==a||e[29]!==o?(C=a.enabled?s.jsx(st,{label:o("settings.openchamber.desktopNetwork.field.quakeModeHeight"),info:o("settings.openchamber.desktopNetwork.field.quakeModeHeightDescription"),children:s.jsxs(Pt,{value:y,onValueChange:D=>{const M=Number(D);Number.isFinite(M)&&a.setHeight(M)},disabled:a.isSaving,children:[s.jsx(Ct,{className:Es,"aria-label":o("settings.openchamber.desktopNetwork.field.quakeModeHeightAria"),children:s.jsx(Kt,{})}),s.jsx(It,{children:Tr.map(O3)})]})}):null,e[27]=y,e[28]=a,e[29]=o,e[30]=C):C=e[30];const E=r?f:null;let F;e[31]===Symbol.for("react.memo_cache_sentinel")?(F=D=>{D||c(!1)},e[31]=F):F=e[31];let O;e[32]!==w||e[33]!==g||e[34]!==E?(O=s.jsx(Cl,{action:E,overrides:g,onSave:w,onOpenChange:F,maxChords:1,maxKeys:5}),e[32]=w,e[33]=g,e[34]=E,e[35]=O):O=e[35];let K;return e[36]!==P||e[37]!==j||e[38]!==C||e[39]!==O?(K=s.jsxs(s.Fragment,{children:[P,j,C,O]}),e[36]=P,e[37]=j,e[38]=C,e[39]=O,e[40]=K):K=e[40],K};function M3(t){return t.shortcutOverrides}function D3(t){return t.setShortcutOverride}function R3(t){return t.id==="quake_mode_global"}function O3(t){return s.jsx(bt,{value:String(t),children:`${Math.round(t*100)}%`},t)}const F3=(t,e)=>{const{t:a}=Ee(),[n,i]=Ke.useState(null),[o,r]=Ke.useState(!1);Ke.useEffect(()=>{if(!t){i(null);return}let g=!1;return(async()=>{const h=await iu();g||i(h)})(),()=>{g=!0}},[t]);const c=n?.supported===!0,u=Ke.useCallback(async g=>{if(!c||o)return null;r(!0),e(null);try{const h=await g();if(!h?.supported)throw new Error(a("settings.openchamber.desktopNetwork.error.quakeModeSaveFailed"));return i(h),h}catch(h){return e(h instanceof Error?h.message:a("settings.openchamber.desktopNetwork.error.quakeModeSaveFailed")),null}finally{r(!1)}},[o,e,c,a]),d=Ke.useCallback(g=>{u(()=>Gg(g))},[u]),l=Ke.useCallback(async g=>{const h=await u(()=>Rr(g));return h?h.error==="unsupported-combo"?(e(a("settings.openchamber.desktopNetwork.error.quakeModeShortcutUnsupported")),!1):!0:!1},[u,e,a]),f=Ke.useCallback(g=>{u(()=>Jg(g))},[u]),p=Ke.useCallback(()=>{Rr(_n).then(g=>{g&&i(g)})},[]);return{supported:c,enabled:n?.enabled===!0,combo:n?.combo??null,storedCombo:n?.storedCombo??null,active:n?.active===!0,heightFraction:n?.heightFraction??1,isSaving:o,setEnabled:d,saveShortcut:l,setHeight:f,release:p}},Sd=t=>{const e=De.c(2),{message:a}=t;let n;return e[0]!==a?(n=a?s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:a}):null,e[0]=a,e[1]=n):n=e[1],n},L3=()=>{const{t}=Ee(),e=is()&&ri(),a=e&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",n=e&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="linux",[i,o]=Ke.useState(!0),[r,c]=Ke.useState(!1),[u,d]=Ke.useState(!1),[l,f]=Ke.useState(!1),[p,g]=Ke.useState(!1),[h,y]=Ke.useState(!1),[b,x]=Ke.useState(!1),[w,S]=Ke.useState(!1),[v,A]=Ke.useState(!0),[I,N]=Ke.useState(!0),[k,P]=Ke.useState(!1),[j,C]=Ke.useState(!1),[E,F]=Ke.useState(!1),[O,K]=Ke.useState(!1),[D,M]=Ke.useState(!1),[T,R]=Ke.useState(!1),[$,z]=Ke.useState(null),[Q,V]=Ke.useState(!1),[L,B]=Ke.useState(!1),[W,Y]=Ke.useState(!1),ae=re(de=>de.shortcutOverrides),ee=re(de=>de.setShortcutOverride),G=Ke.useMemo(()=>Wo().find(de=>de.id==="mini_chat_global")??null,[]),[le,J]=Ke.useState(null),[me,fe]=Ke.useState(null),oe=F3(e,fe),{release:pe}=oe,se=Ke.useMemo(()=>oe.combo?{...ae,quake_mode_global:oe.combo}:ae,[oe.combo,ae]);Ke.useEffect(()=>{if(!e||!a&&!n){o(!1);return}let de=!1;return(async()=>{try{const ie=await fn();if(!ie)throw new Error(t("settings.openchamber.desktopNetwork.error.loadFailed"));if(de)return;const xe=ie.desktopMacMenuBarEnabled!==!1;A(xe),N(xe);const Se=ie.desktopLinuxNativeFrame===!0;P(Se),C(Se),J(null)}catch(ie){de||J(ie instanceof Error?ie.message:t("settings.openchamber.desktopNetwork.error.loadFailed"))}finally{de||o(!1)}})(),()=>{de=!0}},[n,e,a,t]),Ke.useEffect(()=>{if(!e){d(!1);return}let de=!1;return(async()=>{const ie=await Qg();de||(d(ie?.supported===!0),f(ie?.enabled===!0))})(),()=>{de=!0}},[e]),Ke.useEffect(()=>{if(!e){y(!1);return}let de=!1;return(async()=>{const ie=await Yg();de||(y(ie?.supported===!0),x(ie?.enabled===!0))})(),()=>{de=!0}},[e]),Ke.useEffect(()=>{if(!e){F(!1);return}let de=!1;return(async()=>{const ie=await Zg();de||(F(ie?.supported===!0),K(ie?.enabled===!0))})(),()=>{de=!0}},[e]),Ke.useEffect(()=>{if(!e){R(!1);return}let de=!1;return(async()=>{const ie=await ou();de||(R(ie?.supported===!0),z(ie?.combo??null),V(ie?.active===!0))})(),()=>{de=!0}},[e]);const ve=I!==v||j!==k,be=ei(de=>de.setDraft),ne=ei(de=>!!(de.patches.app||de.patches.network)),we=ei(de=>!!de.blocked.network);Ke.useEffect(()=>{be("app",ve?{...I!==v?{desktopMacMenuBarEnabled:I}:{},...j!==k?{desktopLinuxNativeFrame:j}:{}}:null,!1)},[j,I,ve,k,v,be]),Ke.useEffect(()=>()=>be("app",null,!1),[be]);const Ne=Ke.useCallback(async()=>{if(!u||p)return;const de=!l;f(de),g(!0),J(null);try{const ie=await Xg(de);if(!ie?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.launchAtLoginUnsupported"));f(ie.enabled)}catch(ie){f(!de),J(ie instanceof Error?ie.message:t("settings.openchamber.desktopNetwork.error.launchAtLoginSaveFailed"))}finally{g(!1)}},[p,l,u,t]),Ie=Ke.useCallback(async()=>{if(!h||w)return;const de=!b;x(de),S(!0),J(null);try{const ie=await ef(de);if(!ie)throw new Error(t("settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed"));if(!ie.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.minimizeToTrayUnsupported"));x(ie.enabled)}catch(ie){x(!de),J(ie instanceof Error?ie.message:t("settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed"))}finally{S(!1)}},[w,b,h,t]),Ce=Ke.useCallback(async()=>{if(!E||D)return;const de=!O;K(de),M(!0),J(null);try{const ie=await tf(de);if(!ie?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.keepAwakeUnsupported"));K(ie.enabled)}catch(ie){K(!de),J(ie instanceof Error?ie.message:t("settings.openchamber.desktopNetwork.error.keepAwakeSaveFailed"))}finally{M(!1)}},[D,O,E,t]),Me=Ke.useCallback(async de=>{if(!T||L)return!1;B(!0),fe(null);try{const ie=await Or(de);if(!ie?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.miniChatGlobalShortcutSaveFailed"));return z(ie.combo??null),V(ie.active===!0),ie.error==="unsupported-combo"?(fe(t("settings.openchamber.desktopNetwork.error.miniChatGlobalShortcutUnsupported")),!1):!0}catch(ie){return fe(ie instanceof Error?ie.message:t("settings.openchamber.desktopNetwork.error.miniChatGlobalShortcutSaveFailed")),!1}finally{B(!1)}},[L,T,t]),he=Ke.useCallback((de,ie,xe)=>{Me(ie).then(Se=>{if(!(!Se||!xe)){if(xe==="quake_mode_global"){pe();return}ee(xe,_n),jt({shortcutOverrides:{...ae,[xe]:_n}})}})},[Me,pe,ee,ae]),Pe=Ke.useCallback(()=>{Or(null).then(de=>{de&&(z(de.combo??null),V(de.active===!0))})},[]),Re=Ke.useCallback(async()=>{c(!0),J(null);try{if(!await am())throw new Error(t("settings.openchamber.desktopNetwork.error.saveFailed"));if(A(I),P(j),!await au())throw new Error(t("settings.openchamber.desktopNetwork.error.savedRestartFailed"))}catch(de){J(de instanceof Error?de.message:t("settings.openchamber.desktopNetwork.error.saveFailed")),c(!1)}},[j,I,t]);if(!e)return null;const ce=u||a||n||h||E,je=T||oe.supported;return s.jsxs(s.Fragment,{children:[ce?s.jsxs($e,{title:t("settings.layout.general.desktopApp.title"),divider:!1,contentClassName:"space-y-3",children:[s.jsxs("div",{className:bs,children:[u?s.jsx(ct,{settingsItem:"sessions.desktop-launch-at-login",checked:l,onChange:de=>{de!==l&&Ne()},disabled:p,label:t("settings.openchamber.desktopNetwork.field.launchAtLogin"),info:t("settings.openchamber.desktopNetwork.field.launchAtLoginDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.launchAtLoginAria")}):null,h?s.jsx(ct,{settingsItem:"sessions.desktop-minimize-to-tray",checked:b,onChange:de=>{de!==b&&Ie()},disabled:w,label:t("settings.openchamber.desktopNetwork.field.minimizeToTray"),info:t("settings.openchamber.desktopNetwork.field.minimizeToTrayDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.minimizeToTrayAria")}):null,E?s.jsx(ct,{settingsItem:"sessions.desktop-keep-awake",checked:O,onChange:de=>{de!==O&&Ce()},disabled:D,label:t("settings.openchamber.desktopNetwork.field.keepAwake"),info:t("settings.openchamber.desktopNetwork.field.keepAwakeDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.keepAwakeAria")}):null,a?s.jsx(ct,{settingsItem:"sessions.desktop-mac-menu-bar",checked:I,onChange:N,disabled:i||r,label:t("settings.openchamber.desktopNetwork.field.macMenuBar"),info:t("settings.openchamber.desktopNetwork.field.macMenuBarDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.macMenuBarAria")}):null,n?s.jsx(ct,{settingsItem:"sessions.desktop-linux-native-frame",checked:j,onChange:C,disabled:i||r,label:t("settings.openchamber.desktopNetwork.field.linuxNativeFrame"),info:t("settings.openchamber.desktopNetwork.field.linuxNativeFrameDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.linuxNativeFrame")}):null]}),s.jsx(Sd,{message:le}),a||n?s.jsx(H,{type:"button",size:"xs",onClick:Re,disabled:i||r||!ne||we,className:"!font-normal",children:t(r?"settings.common.actions.saving":"settings.openchamber.desktopNetwork.actions.saveAndRestart")}):null]}):null,je?s.jsxs($e,{title:t("settings.layout.general.quickAccess.title"),info:t("settings.layout.general.quickAccess.info"),divider:ce,contentClassName:"space-y-2",children:[T?s.jsxs(st,{settingsItem:"sessions.desktop-mini-chat-global-shortcut",label:t("settings.openchamber.desktopNetwork.field.miniChatGlobalShortcut"),info:t("settings.openchamber.desktopNetwork.field.miniChatGlobalShortcutDescription"),description:$&&!Q?s.jsx("span",{className:"block text-[var(--status-warning)]",children:t("settings.openchamber.desktopNetwork.field.miniChatGlobalShortcutInactive")}):void 0,children:[s.jsx("kbd",{className:"min-w-32 oc-tile-inset rounded-md px-2 py-1 text-center typography-meta text-foreground",children:$?Hn($):t("settings.openchamber.keyboardShortcuts.unassigned")}),s.jsx(H,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",disabled:L,onClick:()=>Y(!0),children:t("settings.openchamber.keyboardShortcuts.actions.edit")}),$?s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",disabled:L,onClick:()=>{Me(null)},children:t("settings.common.actions.reset")}):null]}):null,s.jsx(E3,{quake:oe,miniChatCombo:$,onReleaseMiniChatShortcut:Pe}),s.jsx(Sd,{message:me}),s.jsx(Cl,{action:W?G:null,overrides:se,onSave:he,onOpenChange:de=>{de||Y(!1)},maxChords:1,maxKeys:5})]}):null]})},K3=2e3,_3=3,$3=(t,e)=>t.state==="unsupported"||t.state==="failed"?!0:e?t.state==="on"&&t.index?.backfill.state!=="running":t.state==="off",z3=t=>{const e=t/1e6;return new Intl.NumberFormat(Bo(),{style:"unit",unit:"megabyte",maximumFractionDigits:e<10?1:0}).format(e)},U3=()=>{const t=De.c(70),{t:e}=Ee(),a=re(B3),n=re(V3),i=re(H3),o=re(q3);let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={kind:"loading"},t[0]=r):r=t[0];const[c,u]=m.useState(r),[d,l]=m.useState(!1),f=m.useRef(i);let p,g;t[1]!==a||t[2]!==i?(p=()=>{const $=a&&i&&!f.current;f.current=i;const z=new AbortController;let Q,V=$?_3:0;const L=()=>{cg(z.signal).then(B=>{if(z.signal.aborted)return;u({kind:"ready",status:B}),B.index?.backfill.state==="running"&&(V=0);const W=V>0;V=V-1,(!$3(B,a)||W)&&(Q=setTimeout(L,K3))}).catch(()=>{z.signal.aborted||u({kind:"error"})})};return L(),()=>{z.abort(),clearTimeout(Q)}},g=[a,i],t[1]=a,t[2]=i,t[3]=p,t[4]=g):(p=t[3],g=t[4]),m.useEffect(p,g);let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{l(!0),lg().then($=>u({kind:"ready",status:$})).catch(()=>u({kind:"error"})).finally(()=>l(!1))},t[5]=h):h=t[5];const y=h,b=c.kind==="ready"?c.status:null,x=b?.state==="unsupported";let w;if(t[6]!==a||t[7]!==b?.sizeBytes||t[8]!==e||t[9]!==c.kind||t[10]!==c.status){const $=z3(b?.sizeBytes??0);if(c.kind==="loading"){let z;t[12]!==e?(z=e("settings.openchamber.messageSearch.status.loading"),t[12]=e,t[13]=z):z=t[13],w=z}else if(c.kind==="error"){let z;t[14]!==e?(z=e("settings.openchamber.messageSearch.status.error"),t[14]=e,t[15]=z):z=t[15],w=z}else if(c.status.state==="unsupported"){let z;t[16]!==e?(z=e("settings.openchamber.messageSearch.status.unsupported"),t[16]=e,t[17]=z):z=t[17],w=z}else if(!a)w=c.status.sizeBytes>0?e("settings.openchamber.messageSearch.status.offWithFile",{size:$}):e("settings.openchamber.messageSearch.status.off");else if(c.status.state==="failed"){let z;t[18]!==e?(z=e("settings.openchamber.messageSearch.status.failed"),t[18]=e,t[19]=z):z=t[19],w=z}else if(c.status.state==="on"&&c.status.index?.backfill.state==="running")w=e("settings.openchamber.messageSearch.status.indexing",{done:c.status.index.backfill.done,total:c.status.index.backfill.total,size:$});else if(c.status.state==="on"&&c.status.index)w=e("settings.openchamber.messageSearch.status.ready",{sessions:c.status.index.sessions,messages:c.status.index.messages,size:$});else{let z;t[20]!==e?(z=e("settings.openchamber.messageSearch.status.loading"),t[20]=e,t[21]=z):z=t[21],w=z}t[6]=a,t[7]=b?.sizeBytes,t[8]=e,t[9]=c.kind,t[10]=c.status,t[11]=w}else w=t[11];let S;t[22]!==e?(S=e("settings.openchamber.messageSearch.title"),t[22]=e,t[23]=S):S=t[23];let v;t[24]!==e?(v=e("settings.openchamber.messageSearch.field.enabled"),t[24]=e,t[25]=v):v=t[25];let A;t[26]!==e?(A=e("settings.openchamber.messageSearch.field.enabled"),t[26]=e,t[27]=A):A=t[27];let I;t[28]!==e?(I=e("settings.openchamber.messageSearch.field.enabledInfo"),t[28]=e,t[29]=I):I=t[29];let N;t[30]!==a||t[31]!==n||t[32]!==v||t[33]!==A||t[34]!==I||t[35]!==x?(N=s.jsx(ct,{settingsItem:"chat.message-search-enabled",checked:a,onChange:n,disabled:x,label:v,ariaLabel:A,info:I}),t[30]=a,t[31]=n,t[32]=v,t[33]=A,t[34]=I,t[35]=x,t[36]=N):N=t[36];const k=a&&i,P=!a||x;let j;t[37]!==e?(j=e("settings.openchamber.messageSearch.field.reasoning"),t[37]=e,t[38]=j):j=t[38];let C;t[39]!==e?(C=e("settings.openchamber.messageSearch.field.reasoning"),t[39]=e,t[40]=C):C=t[40];let E;t[41]!==e?(E=e("settings.openchamber.messageSearch.field.reasoningInfo"),t[41]=e,t[42]=E):E=t[42];let F;t[43]!==o||t[44]!==P||t[45]!==j||t[46]!==C||t[47]!==E||t[48]!==k?(F=s.jsx(ct,{settingsItem:"chat.message-search-reasoning",checked:k,onChange:o,disabled:P,label:j,ariaLabel:C,info:E}),t[43]=o,t[44]=P,t[45]=j,t[46]=C,t[47]=E,t[48]=k,t[49]=F):F=t[49];let O;t[50]!==e?(O=e("settings.openchamber.messageSearch.field.index"),t[50]=e,t[51]=O):O=t[51];let K;t[52]!==a||t[53]!==b||t[54]!==e||t[55]!==d?(K=a?s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:y,disabled:d||b?.state!=="on"&&b?.state!=="failed",children:e(d?"settings.openchamber.messageSearch.actions.working":"settings.openchamber.messageSearch.actions.rebuild")}):s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:y,disabled:d||!b||b.state==="on"||b.sizeBytes===0,children:e(d?"settings.openchamber.messageSearch.actions.working":"settings.openchamber.messageSearch.actions.delete")}),t[52]=a,t[53]=b,t[54]=e,t[55]=d,t[56]=K):K=t[56];let D;t[57]!==O||t[58]!==K?(D=s.jsx(st,{label:O,children:K}),t[57]=O,t[58]=K,t[59]=D):D=t[59];let M;t[60]!==w?(M=s.jsx("p",{className:_t,"aria-live":"polite",children:w}),t[60]=w,t[61]=M):M=t[61];let T;t[62]!==F||t[63]!==D||t[64]!==M?(T=s.jsxs(_i,{children:[F,D,M]}),t[62]=F,t[63]=D,t[64]=M,t[65]=T):T=t[65];let R;return t[66]!==T||t[67]!==S||t[68]!==N?(R=s.jsxs($e,{title:S,settingsItem:"chat.message-search",children:[N,T]}),t[66]=T,t[67]=S,t[68]=N,t[69]=R):R=t[69],R};function B3(t){return t.messageSearchEnabled}function V3(t){return t.setMessageSearchEnabled}function H3(t){return t.messageSearchReasoningEnabled}function q3(t){return t.setMessageSearchReasoningEnabled}const W3=()=>{re.getState().requestSettingsJump("sessions","sessions.small-model")},G3=t=>{const e=De.c(33),{disabled:a}=t,n=a===void 0?!1:a,{t:i}=Ee(),o=re(Q3),r=re(Y3),c=Bt(ul),u=!Pn(),d=c?o:"small-model";let l;e[0]!==i?(l=i("settings.openchamber.visual.goal.checkerLabel"),e[0]=i,e[1]=l):l=e[1];let f;e[2]!==i?(f=i("settings.openchamber.visual.goal.checkerInfo"),e[2]=i,e[3]=f):f=e[3];let p;e[4]!==i?(p=i("settings.openchamber.visual.goal.checkerLabel"),e[4]=i,e[5]=p):p=e[5];const g=n||!c;let h;e[6]!==g?(h={value:"classifier",label:"Jev",disabled:g},e[6]=g,e[7]=h):h=e[7];let y;e[8]!==i?(y=i("settings.openchamber.visual.goal.checker.smallModel"),e[8]=i,e[9]=y):y=e[9];let b;e[10]!==n||e[11]!==y?(b={value:"small-model",label:y,disabled:n},e[10]=n,e[11]=y,e[12]=b):b=e[12];let x;e[13]!==h||e[14]!==b?(x=[h,b],e[13]=h,e[14]=b,e[15]=x):x=e[15];let w;e[16]!==r||e[17]!==d||e[18]!==p||e[19]!==x?(w=s.jsx(Xt,{"aria-label":p,value:d,onChange:r,options:x}),e[16]=r,e[17]=d,e[18]=p,e[19]=x,e[20]=w):w=e[20];let S;e[21]!==w||e[22]!==l||e[23]!==f?(S=s.jsx(st,{settingsItem:"chat.session-goal-checker",label:l,info:f,children:w}),e[21]=w,e[22]=l,e[23]=f,e[24]=S):S=e[24];let v;e[25]!==u||e[26]!==c||e[27]!==d||e[28]!==i?(v=d==="classifier"?s.jsx(Zo,{}):s.jsxs("p",{className:_t,children:[i(c?"settings.openchamber.visual.goal.checker.viaSmallModel":"settings.openchamber.visual.goal.checker.jevMissing")," ",s.jsx(Vn,{onClick:W3,children:i("settings.openchamber.visual.goal.checker.smallModelLink")}),c||!u?null:s.jsxs(s.Fragment,{children:[" · ",s.jsx(Vn,{onClick:Fo,children:i("settings.jevAccess.setUp")})]})]}),e[25]=u,e[26]=c,e[27]=d,e[28]=i,e[29]=v):v=e[29];let A;return e[30]!==S||e[31]!==v?(A=s.jsxs("div",{className:"space-y-1",children:[S,v]}),e[30]=S,e[31]=v,e[32]=A):A=e[32],A},J3=t=>{const e=De.c(32),{disabled:a}=t,n=a===void 0?!1:a,{t:i}=Ee(),o=re(Z3),r=re(X3);let c;e[0]!==i?(c=i("settings.openchamber.visual.goal.maxTurnsLabel"),e[0]=i,e[1]=c):c=e[1];let u;e[2]!==i?(u=i("settings.openchamber.visual.goal.maxTurnsInfo"),e[2]=i,e[3]=u):u=e[3];let d;e[4]!==r?(d=v=>r(Math.floor(v)),e[4]=r,e[5]=d):d=e[5];let l;e[6]!==i?(l=i("settings.openchamber.visual.goal.maxTurnsLabel"),e[6]=i,e[7]=l):l=e[7];let f;e[8]!==n||e[9]!==o||e[10]!==d||e[11]!==l?(f=s.jsx(ds,{value:o,onValueChange:d,min:1,max:sf,step:1,disabled:n,className:us,"aria-label":l}),e[8]=n,e[9]=o,e[10]=d,e[11]=l,e[12]=f):f=e[12];let p;e[13]!==r?(p=()=>r(Zl),e[13]=r,e[14]=p):p=e[14];const g=n||o===Zl;let h;e[15]!==i?(h=i("settings.openchamber.visual.goal.maxTurnsResetAria"),e[15]=i,e[16]=h):h=e[16];let y;e[17]!==i?(y=i("settings.common.actions.reset"),e[17]=i,e[18]=y):y=e[18];let b;e[19]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(te,{name:"restart",className:"h-3.5 w-3.5"}),e[19]=b):b=e[19];let x;e[20]!==y||e[21]!==p||e[22]!==g||e[23]!==h?(x=s.jsx(H,{size:"sm",type:"button",variant:"ghost",onClick:p,disabled:g,className:Yt,"aria-label":h,title:y,children:b}),e[20]=y,e[21]=p,e[22]=g,e[23]=h,e[24]=x):x=e[24];let w;e[25]!==x||e[26]!==f?(w=s.jsxs("div",{className:Fn,children:[f,x]}),e[25]=x,e[26]=f,e[27]=w):w=e[27];let S;return e[28]!==w||e[29]!==c||e[30]!==u?(S=s.jsx(st,{settingsItem:"chat.session-goal-max-turns",label:c,info:u,children:w}),e[28]=w,e[29]=c,e[30]=u,e[31]=S):S=e[31],S};function Q3(t){return t.sessionGoalChecker}function Y3(t){return t.setSessionGoalChecker}function Z3(t){return t.sessionGoalMaxAutoTurns}function X3(t){return t.setSessionGoalMaxAutoTurns}const e0=[{id:"collapsed",labelKey:"settings.openchamber.visual.option.activityRenderMode.collapsed.label"},{id:"summary",labelKey:"settings.openchamber.visual.option.activityRenderMode.summary.label"}],t0=[{id:"markdown",labelKey:"settings.openchamber.visual.option.userMessageRendering.markdown.label"},{id:"plain",labelKey:"settings.openchamber.visual.option.userMessageRendering.plain.label"}],s0=[{id:"svg",labelKey:"settings.openchamber.visual.option.mermaidRendering.svg.label"},{id:"ascii",labelKey:"settings.openchamber.visual.option.mermaidRendering.ascii.label"}],n0=[{id:"dynamic",labelKey:"settings.openchamber.visual.option.diffLayout.dynamic.label"},{id:"inline",labelKey:"settings.openchamber.visual.option.diffLayout.inline.label"},{id:"side-by-side",labelKey:"settings.openchamber.visual.option.diffLayout.sideBySide.label"}],a0=[{id:"steer",labelKey:"settings.openchamber.visual.option.followUpBehavior.steer.label"},{id:"queue",labelKey:"settings.openchamber.visual.option.followUpBehavior.queue.label"}],i0=[{id:"global",labelKey:"settings.openchamber.visual.option.inputHistoryScope.global.label"},{id:"session",labelKey:"settings.openchamber.visual.option.inputHistoryScope.session.label"}],o0=[{id:"ask",labelKey:"settings.openchamber.visual.option.largeTextPaste.ask.label"},{id:"attach",labelKey:"settings.openchamber.visual.option.largeTextPaste.attach.label"},{id:"inline",labelKey:"settings.openchamber.visual.option.largeTextPaste.inline.label"},{id:"inline-double-paste",labelKey:"settings.openchamber.visual.option.largeTextPaste.inlineDoublePaste.label"}],Nd="ps-6",Ja=t=>{const e=De.c(5),{t:a}=Ee();let n;if(e[0]!==t||e[1]!==a){let i;e[3]!==a?(i=o=>({value:o.id,label:a(o.labelKey)}),e[3]=a,e[4]=i):i=e[4],n=t.map(i),e[0]=t,e[1]=a,e[2]=n}else n=e[2];return n},r0=()=>{const t=De.c(234),{t:e}=Ee();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=os(),t[0]=a):a=t[0];const n=a,i=re(u0),o=re(m0),r=re(p0),c=re(g0),u=re(f0),d=re(h0),l=re(b0),f=re(x0),p=re(v0),g=re(y0),h=re(j0),y=re(k0),b=re(w0),x=re(S0),w=re(N0),S=re(C0),v=re(I0),A=re(P0),I=re(A0),N=re(T0),k=re(E0),P=re(M0),j=re(D0),C=re(R0),E=re(O0),F=re(F0),O=re(L0),K=re(K0),D=re(_0),M=re($0),T=re(z0),R=re(U0),$=re(B0),z=re(V0),Q=re(H0),V=re(q0),L=Ja(e0),B=Ja(t0),W=Ja(s0),Y=Ja(n0);let ae;t[1]!==o?(ae=Dt=>{o(Dt),jt({activityRenderMode:Dt,chatRenderMode:"live"})},t[1]=o,t[2]=ae):ae=t[2];const ee=ae;let G;t[3]!==e?(G=e("settings.layout.chat.section.activity"),t[3]=e,t[4]=G):G=t[4];let le;t[5]!==e?(le=e("settings.openchamber.visual.section.activityDefault"),t[5]=e,t[6]=le):le=t[6];let J;t[7]!==e?(J=e("settings.openchamber.visual.section.activityDefaultAria"),t[7]=e,t[8]=J):J=t[8];let me;t[9]!==L||t[10]!==i||t[11]!==ee||t[12]!==J?(me=s.jsx(Xt,{value:i,options:L,onChange:ee,"aria-label":J}),t[9]=L,t[10]=i,t[11]=ee,t[12]=J,t[13]=me):me=t[13];let fe;t[14]!==le||t[15]!==me?(fe=s.jsx(st,{label:le,settingsItem:"chat.activity-default",children:me}),t[14]=le,t[15]=me,t[16]=fe):fe=t[16];let oe;t[17]!==e?(oe=e("settings.openchamber.visual.field.showReasoningTraces"),t[17]=e,t[18]=oe):oe=t[18];let pe;t[19]!==e?(pe=e("settings.openchamber.visual.field.showReasoningTracesAria"),t[19]=e,t[20]=pe):pe=t[20];let se;t[21]!==c||t[22]!==r||t[23]!==oe||t[24]!==pe?(se=s.jsx(ct,{checked:r,onChange:c,label:oe,ariaLabel:pe,settingsItem:"chat.reasoning-traces"}),t[21]=c,t[22]=r,t[23]=oe,t[24]=pe,t[25]=se):se=t[25];let ve;t[26]!==u||t[27]!==d||t[28]!==r||t[29]!==e?(ve=r?s.jsx(ct,{checked:u,onChange:d,label:e("settings.openchamber.visual.field.collapsibleThinkingBlocks"),ariaLabel:e("settings.openchamber.visual.field.collapsibleThinkingBlocksAria"),className:Nd}):null,t[26]=u,t[27]=d,t[28]=r,t[29]=e,t[30]=ve):ve=t[30];let be;t[31]!==u||t[32]!==l||t[33]!==f||t[34]!==r||t[35]!==e?(be=r&&u?s.jsx(ct,{checked:l,onChange:f,label:e("settings.openchamber.visual.field.expandReasoningWhileStreaming"),ariaLabel:e("settings.openchamber.visual.field.expandReasoningWhileStreamingAria"),info:e("settings.openchamber.visual.field.expandReasoningWhileStreamingInfo"),className:Nd}):null,t[31]=u,t[32]=l,t[33]=f,t[34]=r,t[35]=e,t[36]=be):be=t[36];let ne;t[37]!==g?(ne=Dt=>{g(Dt),jt({showToolFileIcons:Dt})},t[37]=g,t[38]=ne):ne=t[38];let we;t[39]!==e?(we=e("settings.openchamber.visual.field.showToolFileIcons"),t[39]=e,t[40]=we):we=t[40];let Ne;t[41]!==e?(Ne=e("settings.openchamber.visual.field.showToolFileIconsAria"),t[41]=e,t[42]=Ne):Ne=t[42];let Ie;t[43]!==p||t[44]!==ne||t[45]!==we||t[46]!==Ne?(Ie=s.jsx(ct,{checked:p,onChange:ne,label:we,ariaLabel:Ne,settingsItem:"chat.tool-file-icons"}),t[43]=p,t[44]=ne,t[45]=we,t[46]=Ne,t[47]=Ie):Ie=t[47];let Ce;t[48]!==y?(Ce=Dt=>{y(Dt),jt({showTurnChangedFiles:Dt})},t[48]=y,t[49]=Ce):Ce=t[49];let Me;t[50]!==e?(Me=e("settings.openchamber.visual.field.showTurnChangedFiles"),t[50]=e,t[51]=Me):Me=t[51];let he;t[52]!==e?(he=e("settings.openchamber.visual.field.showTurnChangedFilesAria"),t[52]=e,t[53]=he):he=t[53];let Pe;t[54]!==h||t[55]!==Ce||t[56]!==Me||t[57]!==he?(Pe=s.jsx(ct,{checked:h,onChange:Ce,label:Me,ariaLabel:he,settingsItem:"chat.changed-files"}),t[54]=h,t[55]=Ce,t[56]=Me,t[57]=he,t[58]=Pe):Pe=t[58];let Re;t[59]!==ve||t[60]!==be||t[61]!==Ie||t[62]!==Pe||t[63]!==se?(Re=s.jsxs("div",{className:bs,"data-settings-item":"chat.reasoning",children:[se,ve,be,Ie,Pe]}),t[59]=ve,t[60]=be,t[61]=Ie,t[62]=Pe,t[63]=se,t[64]=Re):Re=t[64];let ce;t[65]!==G||t[66]!==Re||t[67]!==fe?(ce=s.jsxs($e,{title:G,divider:!1,contentClassName:"space-y-3",children:[fe,Re]}),t[65]=G,t[66]=Re,t[67]=fe,t[68]=ce):ce=t[68];let je;t[69]!==e?(je=e("settings.layout.chat.section.reading"),t[69]=e,t[70]=je):je=t[70];let de;t[71]!==S?(de=Dt=>{S(Dt),jt({wideChatLayoutEnabled:Dt})},t[71]=S,t[72]=de):de=t[72];let ie;t[73]!==e?(ie=e("settings.openchamber.visual.field.wideChatLayout"),t[73]=e,t[74]=ie):ie=t[74];let xe;t[75]!==e?(xe=e("settings.openchamber.visual.field.wideChatLayoutAria"),t[75]=e,t[76]=xe):xe=t[76];let Se;t[77]!==de||t[78]!==ie||t[79]!==xe||t[80]!==w?(Se=s.jsx(ct,{checked:w,onChange:de,label:ie,ariaLabel:xe,settingsItem:"chat.wide-layout"}),t[77]=de,t[78]=ie,t[79]=xe,t[80]=w,t[81]=Se):Se=t[81];let Le;t[82]!==e?(Le=e("settings.openchamber.visual.field.streamingAutoFollow"),t[82]=e,t[83]=Le):Le=t[83];let Ue;t[84]!==e?(Ue=e("settings.openchamber.visual.field.streamingAutoFollowAria"),t[84]=e,t[85]=Ue):Ue=t[85];let Ye;t[86]!==e?(Ye=e("settings.openchamber.visual.field.streamingAutoFollowInfo"),t[86]=e,t[87]=Ye):Ye=t[87];let lt;t[88]!==x||t[89]!==b||t[90]!==Le||t[91]!==Ue||t[92]!==Ye?(lt=s.jsx(ct,{checked:b,onChange:x,label:Le,ariaLabel:Ue,info:Ye,settingsItem:"chat.streaming-auto-follow"}),t[88]=x,t[89]=b,t[90]=Le,t[91]=Ue,t[92]=Ye,t[93]=lt):lt=t[93];let at;t[94]!==N?(at=Dt=>{N(Dt),jt({collapsibleUserMessages:Dt})},t[94]=N,t[95]=at):at=t[95];let ut;t[96]!==e?(ut=e("settings.openchamber.visual.field.collapsibleUserMessages"),t[96]=e,t[97]=ut):ut=t[97];let vt;t[98]!==e?(vt=e("settings.openchamber.visual.field.collapsibleUserMessagesAria"),t[98]=e,t[99]=vt):vt=t[99];let We;t[100]!==I||t[101]!==at||t[102]!==ut||t[103]!==vt?(We=s.jsx(ct,{checked:I,onChange:at,label:ut,ariaLabel:vt,settingsItem:"chat.collapsible-user-messages"}),t[100]=I,t[101]=at,t[102]=ut,t[103]=vt,t[104]=We):We=t[104];let Ze;t[105]!==P?(Ze=Dt=>{P(Dt),jt({stickyUserHeader:Dt})},t[105]=P,t[106]=Ze):Ze=t[106];let Xe;t[107]!==e?(Xe=e("settings.openchamber.visual.field.stickyUserHeader"),t[107]=e,t[108]=Xe):Xe=t[108];let it;t[109]!==e?(it=e("settings.openchamber.visual.field.stickyUserHeaderAria"),t[109]=e,t[110]=it):it=t[110];let dt;t[111]!==k||t[112]!==Ze||t[113]!==Xe||t[114]!==it?(dt=s.jsx(ct,{checked:k,onChange:Ze,label:Xe,ariaLabel:it,settingsItem:"chat.sticky-user-header"}),t[111]=k,t[112]=Ze,t[113]=Xe,t[114]=it,t[115]=dt):dt=t[115];let Be;t[116]!==A?(Be=Dt=>{A(Dt),jt({promptNavigatorEnabled:Dt})},t[116]=A,t[117]=Be):Be=t[117];let ot;t[118]!==e?(ot=e("settings.openchamber.visual.field.promptNavigatorEnabled"),t[118]=e,t[119]=ot):ot=t[119];let et;t[120]!==e?(et=e("settings.openchamber.visual.field.promptNavigatorEnabledAria"),t[120]=e,t[121]=et):et=t[121];let ye;t[122]!==v||t[123]!==Be||t[124]!==ot||t[125]!==et?(ye=s.jsx(ct,{checked:v,onChange:Be,label:ot,ariaLabel:et,settingsItem:"chat.prompt-navigator"}),t[122]=v,t[123]=Be,t[124]=ot,t[125]=et,t[126]=ye):ye=t[126];let Z;t[127]!==C?(Z=Dt=>{C(Dt),jt({showSplitAssistantMessageActions:Dt})},t[127]=C,t[128]=Z):Z=t[128];let Oe;t[129]!==e?(Oe=e("settings.openchamber.visual.field.showSplitAssistantMessageActions"),t[129]=e,t[130]=Oe):Oe=t[130];let Ve;t[131]!==e?(Ve=e("settings.openchamber.visual.field.showSplitAssistantMessageActionsAria"),t[131]=e,t[132]=Ve):Ve=t[132];let X;t[133]!==e?(X=e("settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip"),t[133]=e,t[134]=X):X=t[134];let _e;t[135]!==j||t[136]!==Z||t[137]!==Oe||t[138]!==Ve||t[139]!==X?(_e=s.jsx(ct,{checked:j,onChange:Z,label:Oe,ariaLabel:Ve,info:X,settingsItem:"chat.inline-assistant-actions"}),t[135]=j,t[136]=Z,t[137]=Oe,t[138]=Ve,t[139]=X,t[140]=_e):_e=t[140];let nt;t[141]!==je||t[142]!==Se||t[143]!==lt||t[144]!==We||t[145]!==dt||t[146]!==ye||t[147]!==_e?(nt=s.jsxs($e,{title:je,settingsItem:"chat.message-appearance",contentClassName:bs,children:[Se,lt,We,dt,ye,_e]}),t[141]=je,t[142]=Se,t[143]=lt,t[144]=We,t[145]=dt,t[146]=ye,t[147]=_e,t[148]=nt):nt=t[148];let ht;t[149]!==e?(ht=e("settings.layout.chat.section.formatting"),t[149]=e,t[150]=ht):ht=t[150];let yt;t[151]!==e?(yt=e("settings.openchamber.visual.section.userMessageRendering"),t[151]=e,t[152]=yt):yt=t[152];const kt=E==="markdown"?"markdown":"plain";let He;t[153]!==F?(He=Dt=>{F(Dt),jt({userMessageRenderingMode:Dt})},t[153]=F,t[154]=He):He=t[154];let Je;t[155]!==e?(Je=e("settings.openchamber.visual.section.userMessageRenderingAria"),t[155]=e,t[156]=Je):Je=t[156];let mt;t[157]!==kt||t[158]!==He||t[159]!==Je||t[160]!==B?(mt=s.jsx(Xt,{value:kt,options:B,onChange:He,"aria-label":Je}),t[157]=kt,t[158]=He,t[159]=Je,t[160]=B,t[161]=mt):mt=t[161];let Qe;t[162]!==yt||t[163]!==mt?(Qe=s.jsx(st,{label:yt,settingsItem:"chat.user-message-rendering",children:mt}),t[162]=yt,t[163]=mt,t[164]=Qe):Qe=t[164];let _;t[165]!==e?(_=e("settings.openchamber.visual.section.mermaidRendering"),t[165]=e,t[166]=_):_=t[166];let ge;t[167]!==K?(ge=Dt=>{K(Dt),jt({mermaidRenderingMode:Dt})},t[167]=K,t[168]=ge):ge=t[168];let Ae;t[169]!==e?(Ae=e("settings.openchamber.visual.section.mermaidRenderingAria"),t[169]=e,t[170]=Ae):Ae=t[170];let Te;t[171]!==W||t[172]!==O||t[173]!==ge||t[174]!==Ae?(Te=s.jsx(Xt,{value:O,options:W,onChange:ge,"aria-label":Ae}),t[171]=W,t[172]=O,t[173]=ge,t[174]=Ae,t[175]=Te):Te=t[175];let Ge;t[176]!==_||t[177]!==Te?(Ge=s.jsx(st,{label:_,settingsItem:"chat.mermaid-rendering",children:Te}),t[176]=_,t[177]=Te,t[178]=Ge):Ge=t[178];let ue;t[179]!==Y||t[180]!==D||t[181]!==M||t[182]!==e?(ue=n?null:s.jsx(st,{label:e("settings.openchamber.visual.section.diffLayout"),settingsItem:"chat.diff-layout",children:s.jsx(Xt,{value:D,options:Y,onChange:M,"aria-label":e("settings.openchamber.visual.section.diffLayoutAria")})}),t[179]=Y,t[180]=D,t[181]=M,t[182]=e,t[183]=ue):ue=t[183];let Fe;t[184]!==Qe||t[185]!==Ge||t[186]!==ue?(Fe=s.jsxs("div",{children:[Qe,Ge,ue]}),t[184]=Qe,t[185]=Ge,t[186]=ue,t[187]=Fe):Fe=t[187];let pt;t[188]!==e?(pt=e("settings.openchamber.visual.field.codeBlockLineWrap"),t[188]=e,t[189]=pt):pt=t[189];let At;t[190]!==e?(At=e("settings.openchamber.visual.field.codeBlockLineWrapAria"),t[190]=e,t[191]=At):At=t[191];let Nt;t[192]!==T||t[193]!==R||t[194]!==pt||t[195]!==At?(Nt=s.jsx(ct,{checked:T,onChange:R,label:pt,ariaLabel:At,settingsItem:"chat.code-block-line-wrap"}),t[192]=T,t[193]=R,t[194]=pt,t[195]=At,t[196]=Nt):Nt=t[196];let zt;t[197]!==e?(zt=e("settings.openchamber.visual.field.tableCellWrap"),t[197]=e,t[198]=zt):zt=t[198];let es;t[199]!==e?(es=e("settings.openchamber.visual.field.tableCellWrapAria"),t[199]=e,t[200]=es):es=t[200];let ss;t[201]!==e?(ss=e("settings.openchamber.visual.field.tableCellWrapInfo"),t[201]=e,t[202]=ss):ss=t[202];let fs;t[203]!==z||t[204]!==zt||t[205]!==es||t[206]!==ss||t[207]!==$?(fs=s.jsx(ct,{checked:$,onChange:z,label:zt,ariaLabel:es,info:ss,settingsItem:"chat.table-cell-wrap"}),t[203]=z,t[204]=zt,t[205]=es,t[206]=ss,t[207]=$,t[208]=fs):fs=t[208];let Gt;t[209]!==e?(Gt=e("settings.openchamber.visual.field.copyMessagesAsPlainText"),t[209]=e,t[210]=Gt):Gt=t[210];let ms;t[211]!==e?(ms=e("settings.openchamber.visual.field.copyMessagesAsPlainTextAria"),t[211]=e,t[212]=ms):ms=t[212];let cs;t[213]!==e?(cs=e("settings.openchamber.visual.field.copyMessagesAsPlainTextInfo"),t[213]=e,t[214]=cs):cs=t[214];let ps;t[215]!==Q||t[216]!==V||t[217]!==Gt||t[218]!==ms||t[219]!==cs?(ps=s.jsx(ct,{checked:Q,onChange:V,label:Gt,ariaLabel:ms,info:cs,settingsItem:"chat.copy-plain-text"}),t[215]=Q,t[216]=V,t[217]=Gt,t[218]=ms,t[219]=cs,t[220]=ps):ps=t[220];let hs;t[221]!==Nt||t[222]!==fs||t[223]!==ps?(hs=s.jsxs("div",{className:bs,children:[Nt,fs,ps]}),t[221]=Nt,t[222]=fs,t[223]=ps,t[224]=hs):hs=t[224];let ks;t[225]!==ht||t[226]!==Fe||t[227]!==hs?(ks=s.jsxs($e,{title:ht,contentClassName:"space-y-3",children:[Fe,hs]}),t[225]=ht,t[226]=Fe,t[227]=hs,t[228]=ks):ks=t[228];let ws;t[229]===Symbol.for("react.memo_cache_sentinel")?(ws=n?null:s.jsx(U3,{}),t[229]=ws):ws=t[229];let Xs;return t[230]!==ce||t[231]!==nt||t[232]!==ks?(Xs=s.jsxs(s.Fragment,{children:[ce,nt,ks,ws]}),t[230]=ce,t[231]=nt,t[232]=ks,t[233]=Xs):Xs=t[233],Xs},l0=()=>{const t=De.c(140),{t:e}=Ee(),{isMobile:a}=Zs(),n=re(W0),i=re(G0),o=re(J0),r=re(Q0),c=Xl(Y0),u=Xl(Z0),d=re(X0),l=re(eS),f=re(tS),p=re(sS),g=re(nS),h=re(aS),y=re(iS),b=re(oS),x=re(rS),w=re(lS),S=oo(cS),v=oo(dS),A=oo(uS),I=oo(mS),N=Ja(a0),k=Ja(i0),P=o?n:!a;let j;t[0]!==i||t[1]!==r?(j=at=>{i(at),r(!0),jt({enterToSend:at,enterToSendConfigured:!0})},t[0]=i,t[1]=r,t[2]=j):j=t[2];const C=j;let E;t[3]!==I?(E=at=>{const ut=Math.round(at);nf(ut)&&(I(ut),jt({inputHistoryLimit:ut}))},t[3]=I,t[4]=E):E=t[4];const F=E;let O;t[5]!==e?(O=e("settings.layout.chat.section.sending"),t[5]=e,t[6]=O):O=t[6];let K;t[7]!==P||t[8]!==C||t[9]!==a||t[10]!==e?(K=a?null:s.jsx(st,{label:e("settings.openchamber.visual.field.enterToSend"),info:e("settings.openchamber.visual.field.enterToSendHint"),settingsItem:"chat.enter-to-send",children:s.jsx(Xt,{value:P?"enter":"modifier",options:[{value:"enter",label:e("settings.openchamber.visual.option.enterToSend.enter.label")},{value:"modifier",label:e("settings.openchamber.visual.option.enterToSend.modifier.label")}],onChange:at=>C(at==="enter"),"aria-label":e("settings.openchamber.visual.field.enterToSend")})}),t[7]=P,t[8]=C,t[9]=a,t[10]=e,t[11]=K):K=t[11];let D;t[12]!==e?(D=e("settings.openchamber.visual.section.followUpBehavior"),t[12]=e,t[13]=D):D=t[13];let M;t[14]!==e?(M=e("settings.openchamber.visual.section.followUpBehaviorAria"),t[14]=e,t[15]=M):M=t[15];let T;t[16]!==c||t[17]!==N||t[18]!==u||t[19]!==M?(T=s.jsx(Xt,{value:c,options:N,onChange:u,"aria-label":M}),t[16]=c,t[17]=N,t[18]=u,t[19]=M,t[20]=T):T=t[20];let R;t[21]!==D||t[22]!==T?(R=s.jsx(st,{label:D,settingsItem:"chat.follow-up-behavior",children:T}),t[21]=D,t[22]=T,t[23]=R):R=t[23];let $;t[24]!==K||t[25]!==R?($=s.jsxs("div",{children:[K,R]}),t[24]=K,t[25]=R,t[26]=$):$=t[26];let z;t[27]!==e?(z=e("settings.openchamber.visual.field.largeTextPaste"),t[27]=e,t[28]=z):z=t[28];let Q;t[29]!==e?(Q=e("settings.openchamber.visual.field.largeTextPasteHint"),t[29]=e,t[30]=Q):Q=t[30];let V;t[31]!==e?(V=e("settings.openchamber.visual.field.largeTextPasteAria"),t[31]=e,t[32]=V):V=t[32];let L;t[33]!==d||t[34]!==l||t[35]!==e?(L=o0.map(at=>s.jsx(wn,{selected:d===at.id,onSelect:()=>l(at.id),label:e(at.labelKey),ariaLabel:e("settings.openchamber.visual.field.largeTextPasteOptionAria",{option:e(at.labelKey)})},at.id)),t[33]=d,t[34]=l,t[35]=e,t[36]=L):L=t[36];let B;t[37]!==V||t[38]!==L?(B=s.jsx(Vo,{"aria-label":V,children:L}),t[37]=V,t[38]=L,t[39]=B):B=t[39];let W;t[40]!==Q||t[41]!==B||t[42]!==z?(W=s.jsx(ni,{title:z,info:Q,settingsItem:"chat.large-text-paste",children:B}),t[40]=Q,t[41]=B,t[42]=z,t[43]=W):W=t[43];let Y;t[44]!==e?(Y=e("settings.openchamber.visual.field.allowPromptingSubagentSessions"),t[44]=e,t[45]=Y):Y=t[45];let ae;t[46]!==e?(ae=e("settings.openchamber.visual.field.allowPromptingSubagentSessionsAria"),t[46]=e,t[47]=ae):ae=t[47];let ee;t[48]!==f||t[49]!==p||t[50]!==Y||t[51]!==ae?(ee=s.jsx(ct,{checked:f,onChange:p,label:Y,ariaLabel:ae,settingsItem:"chat.subagent-read-only-banner"}),t[48]=f,t[49]=p,t[50]=Y,t[51]=ae,t[52]=ee):ee=t[52];let G;t[53]!==e?(G=e("settings.openchamber.visual.field.savePastedImagesAsFiles"),t[53]=e,t[54]=G):G=t[54];let le;t[55]!==e?(le=e("settings.openchamber.visual.field.savePastedImagesAsFiles"),t[55]=e,t[56]=le):le=t[56];let J;t[57]!==e?(J=e("settings.openchamber.visual.field.savePastedImagesAsFilesInfo"),t[57]=e,t[58]=J):J=t[58];let me;t[59]!==g||t[60]!==h||t[61]!==G||t[62]!==le||t[63]!==J?(me=s.jsx(ct,{checked:g,onChange:h,label:G,ariaLabel:le,info:J,settingsItem:"chat.save-pasted-images"}),t[59]=g,t[60]=h,t[61]=G,t[62]=le,t[63]=J,t[64]=me):me=t[64];let fe;t[65]!==ee||t[66]!==me?(fe=s.jsxs("div",{className:bs,children:[ee,me]}),t[65]=ee,t[66]=me,t[67]=fe):fe=t[67];let oe;t[68]!==W||t[69]!==O||t[70]!==fe||t[71]!==$?(oe=s.jsxs($e,{title:O,divider:!1,settingsItem:"chat.composer",contentClassName:"space-y-5",children:[$,W,fe]}),t[68]=W,t[69]=O,t[70]=fe,t[71]=$,t[72]=oe):oe=t[72];let pe;t[73]!==e?(pe=e("settings.layout.chat.section.draftsAndHistory"),t[73]=e,t[74]=pe):pe=t[74];let se;t[75]!==e?(se=e("settings.openchamber.visual.field.persistDraftMessages"),t[75]=e,t[76]=se):se=t[76];let ve;t[77]!==e?(ve=e("settings.openchamber.visual.field.persistDraftMessagesAria"),t[77]=e,t[78]=ve):ve=t[78];let be;t[79]!==y||t[80]!==b||t[81]!==se||t[82]!==ve?(be=s.jsx(ct,{checked:y,onChange:b,label:se,ariaLabel:ve,settingsItem:"chat.persist-drafts"}),t[79]=y,t[80]=b,t[81]=se,t[82]=ve,t[83]=be):be=t[83];let ne;t[84]!==x||t[85]!==a||t[86]!==w||t[87]!==e?(ne=a?null:s.jsx(ct,{checked:x,onChange:at=>{w(at),jt({inputSpellcheckEnabled:at})},label:e("settings.openchamber.visual.field.enableSpellcheckInTextInputs"),ariaLabel:e("settings.openchamber.visual.field.enableSpellcheckInTextInputsAria"),settingsItem:"chat.spellcheck"}),t[84]=x,t[85]=a,t[86]=w,t[87]=e,t[88]=ne):ne=t[88];let we;t[89]!==be||t[90]!==ne?(we=s.jsxs("div",{className:bs,children:[be,ne]}),t[89]=be,t[90]=ne,t[91]=we):we=t[91];let Ne;t[92]!==e?(Ne=e("settings.openchamber.visual.field.inputHistoryScope"),t[92]=e,t[93]=Ne):Ne=t[93];let Ie;t[94]!==e?(Ie=e("settings.openchamber.visual.field.inputHistoryScopeDescription"),t[94]=e,t[95]=Ie):Ie=t[95];let Ce;t[96]!==A?(Ce=at=>{A(at),jt({inputHistoryScope:at})},t[96]=A,t[97]=Ce):Ce=t[97];let Me;t[98]!==e?(Me=e("settings.openchamber.visual.section.inputHistoryScopeAria"),t[98]=e,t[99]=Me):Me=t[99];let he;t[100]!==k||t[101]!==S||t[102]!==Ce||t[103]!==Me?(he=s.jsx(Xt,{value:S,options:k,onChange:Ce,"aria-label":Me}),t[100]=k,t[101]=S,t[102]=Ce,t[103]=Me,t[104]=he):he=t[104];let Pe;t[105]!==Ne||t[106]!==Ie||t[107]!==he?(Pe=s.jsx(st,{label:Ne,info:Ie,settingsItem:"chat.input-history-scope",children:he}),t[105]=Ne,t[106]=Ie,t[107]=he,t[108]=Pe):Pe=t[108];let Re;t[109]!==e?(Re=e("settings.openchamber.visual.field.inputHistoryLimit"),t[109]=e,t[110]=Re):Re=t[110];let ce;t[111]!==e?(ce=e("settings.openchamber.visual.field.inputHistoryLimitDescription"),t[111]=e,t[112]=ce):ce=t[112];let je;t[113]!==e?(je=e("settings.openchamber.visual.field.inputHistoryLimitAria"),t[113]=e,t[114]=je):je=t[114];let de;t[115]!==F||t[116]!==v||t[117]!==je?(de=s.jsx(ds,{value:v,onValueChange:F,min:of,max:af,step:1,className:us,deferExternalValueWhileFocused:!0,"aria-label":je}),t[115]=F,t[116]=v,t[117]=je,t[118]=de):de=t[118];let ie;t[119]!==e?(ie=e("settings.openchamber.visual.field.inputHistoryLimitUnit"),t[119]=e,t[120]=ie):ie=t[120];let xe;t[121]!==ie?(xe=s.jsx("span",{className:ga,children:ie}),t[121]=ie,t[122]=xe):xe=t[122];let Se;t[123]!==de||t[124]!==xe?(Se=s.jsxs("div",{className:Fn,children:[de,xe]}),t[123]=de,t[124]=xe,t[125]=Se):Se=t[125];let Le;t[126]!==Re||t[127]!==ce||t[128]!==Se?(Le=s.jsx(st,{label:Re,description:ce,settingsItem:"chat.input-history-limit",children:Se}),t[126]=Re,t[127]=ce,t[128]=Se,t[129]=Le):Le=t[129];let Ue;t[130]!==Pe||t[131]!==Le?(Ue=s.jsxs("div",{children:[Pe,Le]}),t[130]=Pe,t[131]=Le,t[132]=Ue):Ue=t[132];let Ye;t[133]!==pe||t[134]!==we||t[135]!==Ue?(Ye=s.jsxs($e,{title:pe,contentClassName:"space-y-3",children:[we,Ue]}),t[133]=pe,t[134]=we,t[135]=Ue,t[136]=Ye):Ye=t[136];let lt;return t[137]!==oe||t[138]!==Ye?(lt=s.jsxs(s.Fragment,{children:[oe,Ye]}),t[137]=oe,t[138]=Ye,t[139]=lt):lt=t[139],lt},c0=()=>{const t=De.c(54),{t:e}=Ee();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=os(),t[0]=a):a=t[0];const n=a,i=re(pS),o=re(gS),r=re(fS),c=re(hS),u=re(bS),d=re(xS),l=re(vS),f=re(yS),p=Bt(ul),g=re(jS),h=re(kS),y=re(wS),b=re(SS),x=re(NS),w=re(CS);let S;t[1]!==e?(S=e("settings.openchamber.visual.section.sessionAssistance"),t[1]=e,t[2]=S):S=t[2];let v;t[3]!==o?(v=T=>{o(T),jt({draftStartersVisible:T})},t[3]=o,t[4]=v):v=t[4];let A;t[5]!==e?(A=e("settings.openchamber.visual.field.draftStartersVisible"),t[5]=e,t[6]=A):A=t[6];let I;t[7]!==e?(I=e("settings.openchamber.visual.field.draftStartersVisibleAria"),t[7]=e,t[8]=I):I=t[8];let N;t[9]!==i||t[10]!==v||t[11]!==A||t[12]!==I?(N=s.jsx(ct,{checked:i,onChange:v,label:A,ariaLabel:I,settingsItem:"chat.draft-starters-visible"}),t[9]=i,t[10]=v,t[11]=A,t[12]=I,t[13]=N):N=t[13];let k;t[14]!==e?(k=e("settings.openchamber.visual.field.sessionRecap"),t[14]=e,t[15]=k):k=t[15];let P;t[16]!==e?(P=e("settings.openchamber.visual.field.sessionRecapAria"),t[16]=e,t[17]=P):P=t[17];let j;t[18]!==r||t[19]!==c||t[20]!==k||t[21]!==P?(j=s.jsx(ct,{checked:r,onChange:c,label:k,ariaLabel:P,settingsItem:"chat.session-recap"}),t[18]=r,t[19]=c,t[20]=k,t[21]=P,t[22]=j):j=t[22];let C;t[23]!==e?(C=e("settings.openchamber.visual.field.sessionSuggestion"),t[23]=e,t[24]=C):C=t[24];let E;t[25]!==e?(E=e("settings.openchamber.visual.field.sessionSuggestionAria"),t[25]=e,t[26]=E):E=t[26];let F;t[27]!==u||t[28]!==d||t[29]!==E||t[30]!==C?(F=s.jsx(ct,{checked:u,onChange:d,label:C,ariaLabel:E,settingsItem:"chat.session-suggestion"}),t[27]=u,t[28]=d,t[29]=E,t[30]=C,t[31]=F):F=t[31];let O;t[32]!==p||t[33]!==l||t[34]!==f||t[35]!==e?(O=n?null:s.jsx(ct,{checked:p&&l,onChange:f,disabled:!p,label:e("settings.openchamber.visual.field.sessionReviewOffer"),ariaLabel:e("settings.openchamber.visual.field.sessionReviewOffer"),info:e("settings.openchamber.visual.field.sessionReviewOfferInfo"),footer:s.jsx(Zo,{}),settingsItem:"chat.session-review-offer"}),t[32]=p,t[33]=l,t[34]=f,t[35]=e,t[36]=O):O=t[36];let K;t[37]!==S||t[38]!==F||t[39]!==O||t[40]!==N||t[41]!==j?(K=s.jsxs($e,{title:S,settingsItem:"chat.session-assistance",divider:!1,contentClassName:bs,children:[N,j,F,O]}),t[37]=S,t[38]=F,t[39]=O,t[40]=N,t[41]=j,t[42]=K):K=t[42];let D;t[43]!==x||t[44]!==y||t[45]!==g||t[46]!==w||t[47]!==b||t[48]!==h||t[49]!==e?(D=n?null:s.jsxs($e,{title:e("settings.openchamber.visual.goal.sectionTitle"),info:e("settings.openchamber.visual.goal.description"),contentClassName:"space-y-3",children:[s.jsx(ct,{checked:g,onChange:h,label:e("settings.openchamber.visual.field.sessionGoal"),ariaLabel:e("settings.openchamber.visual.field.sessionGoalAria"),settingsItem:"chat.session-goal"}),s.jsxs("div",{children:[s.jsx(G3,{disabled:!g}),s.jsx(J3,{disabled:!g}),s.jsx(st,{label:s.jsx(ct,{checked:y,onChange:b,disabled:!g,label:e("settings.openchamber.visual.goal.budgetLabel"),ariaLabel:e("settings.openchamber.visual.goal.budgetAria")}),settingsItem:"chat.session-goal-budget",children:s.jsx(ds,{value:x,onValueChange:T=>{Number.isFinite(T)&&T>0&&w(Math.floor(T))},min:1e3,max:1e8,step:5e4,disabled:!g||!y,className:us,"aria-label":e("settings.openchamber.visual.goal.budgetAria")})})]})]}),t[43]=x,t[44]=y,t[45]=g,t[46]=w,t[47]=b,t[48]=h,t[49]=e,t[50]=D):D=t[50];let M;return t[51]!==K||t[52]!==D?(M=s.jsxs(s.Fragment,{children:[K,D]}),t[51]=K,t[52]=D,t[53]=M):M=t[53],M},d0=()=>{const t=De.c(34),{t:e}=Ee(),a=zr(IS),n=zr(PS);let i;t[0]!==e?(i=e("settings.layout.chat.tab.messages"),t[0]=e,t[1]=i):i=t[1];let o;t[2]!==i?(o={id:"messages",label:i},t[2]=i,t[3]=o):o=t[3];let r;t[4]!==e?(r=e("settings.layout.chat.tab.composer"),t[4]=e,t[5]=r):r=t[5];let c;t[6]!==r?(c={id:"composer",label:r},t[6]=r,t[7]=c):c=t[7];let u;t[8]!==e?(u=e("settings.layout.chat.tab.assistance"),t[8]=e,t[9]=u):u=t[9];let d;t[10]!==u?(d={id:"assistance",label:u},t[10]=u,t[11]=d):d=t[11];let l;t[12]!==o||t[13]!==c||t[14]!==d?(l=[o,c,d],t[12]=o,t[13]=c,t[14]=d,t[15]=l):l=t[15];const f=l;let p;t[16]!==n||t[17]!==f?(p=w=>{const S=f.find(v=>v.id===w);S&&n(S.id)},t[16]=n,t[17]=f,t[18]=p):p=t[18];let g;t[19]!==p||t[20]!==a||t[21]!==f?(g=s.jsx("div",{className:"mb-8",children:s.jsx(Uo,{items:f,activeId:a,onSelect:p,layoutMode:"fit",variant:"active-pill",pillSize:"form",className:"h-8 max-w-[28rem]"})}),t[19]=p,t[20]=a,t[21]=f,t[22]=g):g=t[22];let h;t[23]!==a?(h=a==="messages"?s.jsx(r0,{}):null,t[23]=a,t[24]=h):h=t[24];let y;t[25]!==a?(y=a==="composer"?s.jsx(l0,{}):null,t[25]=a,t[26]=y):y=t[26];let b;t[27]!==a?(b=a==="assistance"?s.jsx(c0,{}):null,t[27]=a,t[28]=b):b=t[28];let x;return t[29]!==y||t[30]!==b||t[31]!==g||t[32]!==h?(x=s.jsxs(s.Fragment,{children:[g,h,y,b]}),t[29]=y,t[30]=b,t[31]=g,t[32]=h,t[33]=x):x=t[33],x};function u0(t){return t.activityRenderMode}function m0(t){return t.setActivityRenderMode}function p0(t){return t.showReasoningTraces}function g0(t){return t.setShowReasoningTraces}function f0(t){return t.collapsibleThinkingBlocks}function h0(t){return t.setCollapsibleThinkingBlocks}function b0(t){return t.expandReasoningWhileStreaming}function x0(t){return t.setExpandReasoningWhileStreaming}function v0(t){return t.showToolFileIcons}function y0(t){return t.setShowToolFileIcons}function j0(t){return t.showTurnChangedFiles}function k0(t){return t.setShowTurnChangedFiles}function w0(t){return t.streamingAutoFollowEnabled}function S0(t){return t.setStreamingAutoFollowEnabled}function N0(t){return t.wideChatLayoutEnabled}function C0(t){return t.setWideChatLayoutEnabled}function I0(t){return t.promptNavigatorEnabled}function P0(t){return t.setPromptNavigatorEnabled}function A0(t){return t.collapsibleUserMessages}function T0(t){return t.setCollapsibleUserMessages}function E0(t){return t.stickyUserHeader}function M0(t){return t.setStickyUserHeader}function D0(t){return t.showSplitAssistantMessageActions}function R0(t){return t.setShowSplitAssistantMessageActions}function O0(t){return t.userMessageRenderingMode}function F0(t){return t.setUserMessageRenderingMode}function L0(t){return t.mermaidRenderingMode}function K0(t){return t.setMermaidRenderingMode}function _0(t){return t.diffLayoutPreference}function $0(t){return t.setDiffLayoutPreference}function z0(t){return t.codeBlockLineWrap}function U0(t){return t.setCodeBlockLineWrap}function B0(t){return t.tableCellWrap}function V0(t){return t.setTableCellWrap}function H0(t){return t.copyMessagesAsPlainText}function q0(t){return t.setCopyMessagesAsPlainText}function W0(t){return t.enterToSend}function G0(t){return t.setEnterToSend}function J0(t){return t.enterToSendConfigured}function Q0(t){return t.setEnterToSendConfigured}function Y0(t){return t.followUpBehavior}function Z0(t){return t.setFollowUpBehavior}function X0(t){return t.largeTextPasteBehavior}function eS(t){return t.setLargeTextPasteBehavior}function tS(t){return t.allowPromptingSubagentSessions}function sS(t){return t.setAllowPromptingSubagentSessions}function nS(t){return t.savePastedImagesAsFiles}function aS(t){return t.setSavePastedImagesAsFiles}function iS(t){return t.persistChatDraft}function oS(t){return t.setPersistChatDraft}function rS(t){return t.inputSpellcheckEnabled}function lS(t){return t.setInputSpellcheckEnabled}function cS(t){return t.scope}function dS(t){return t.entryLimit}function uS(t){return t.applyScope}function mS(t){return t.applyEntryLimit}function pS(t){return t.draftStartersVisible}function gS(t){return t.setDraftStartersVisible}function fS(t){return t.sessionRecapEnabled}function hS(t){return t.setSessionRecapEnabled}function bS(t){return t.sessionSuggestionEnabled}function xS(t){return t.setSessionSuggestionEnabled}function vS(t){return t.sessionReviewOfferEnabled}function yS(t){return t.setSessionReviewOfferEnabled}function jS(t){return t.sessionGoalEnabled}function kS(t){return t.setSessionGoalEnabled}function wS(t){return t.sessionGoalDefaultBudgetEnabled}function SS(t){return t.setSessionGoalDefaultBudgetEnabled}function NS(t){return t.sessionGoalDefaultBudget}function CS(t){return t.setSessionGoalDefaultBudget}function IS(t){return t.tab}function PS(t){return t.setTab}const AS={changes:"mobile.menu.git",files:"mobile.menu.files",terminal:"mobile.menu.terminal",notes:"contextRail.surface.notes",mcp:"mobile.menu.mcp"},TS=()=>{const t=De.c(22),{t:e}=Ee(),a=re(ES),n=re(MS),i=re(DS),o=re(RS);let r;if(t[0]!==n||t[1]!==a||t[2]!==e){const h=rf(a,n);r=lf(a).map(y=>({id:y,label:e(AS[y]),visible:h.includes(y),locked:h.length===1&&h.includes(y)})),t[0]=n,t[1]=a,t[2]=e,t[3]=r}else r=t[3];const c=r;let u;t[4]!==e?(u=e("settings.layout.general.mobileTabs.title"),t[4]=e,t[5]=u):u=t[5];let d;t[6]!==e?(d=e("settings.layout.general.mobileTabs.info"),t[6]=e,t[7]=d):d=t[7];let l;t[8]!==c||t[9]!==o?(l=(h,y)=>{const b=c.find(x=>x.id===h)?.id;b&&o(b,y)},t[8]=c,t[9]=o,t[10]=l):l=t[10];let f;t[11]!==e?(f=e("settings.layout.general.mobileTabs.dragInstructions"),t[11]=e,t[12]=f):f=t[12];let p;t[13]!==c||t[14]!==i||t[15]!==l||t[16]!==f?(p=s.jsx(Pf,{items:c,onVisibleChange:l,onReorder:i,settingsItemPrefix:"layout.mobile-workspace-tabs.",dragInstructions:f}),t[13]=c,t[14]=i,t[15]=l,t[16]=f,t[17]=p):p=t[17];let g;return t[18]!==u||t[19]!==d||t[20]!==p?(g=s.jsx($e,{title:u,info:d,settingsItem:"layout.mobile-workspace-tabs",children:p}),t[18]=u,t[19]=d,t[20]=p,t[21]=g):g=t[21],g};function ES(t){return t.mobileWorkspaceTabOrder}function MS(t){return t.mobileWorkspaceHiddenTabs}function DS(t){return t.setMobileWorkspaceTabOrder}function RS(t){return t.setMobileWorkspaceTabVisible}const Cd=[{id:"auto",labelKey:"settings.openchamber.visual.option.messageTransport.auto.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.auto.description"},{id:"ws",labelKey:"settings.openchamber.visual.option.messageTransport.ws.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.ws.description"},{id:"sse",labelKey:"settings.openchamber.visual.option.messageTransport.sse.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.sse.description"}],OS=t=>{const e=De.c(84),{divider:a}=t,{t:n}=Ee(),{isMobile:i}=Zs();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=os(),e[0]=o):o=e[0];const r=o,c=re($S),u=re(zS),d=re(US),l=re(BS),f=re(VS),p=re(HS),g=re(qS),h=re(WS),y=re(GS),b=re(JS),x=cf(),w=ft(QS),S=ft(YS);let v;e[1]!==d?(v=Jf(d),e[1]=d,e[2]=v):v=e[2];const A=v.invalidLines;let I;e[3]!==S?(I=me=>{S(me),jt({defaultFileViewerPreview:me}),window.dispatchEvent(new CustomEvent("openchamber:file-viewer-preview-mode-changed",{detail:{enabled:me}}))},e[3]=S,e[4]=I):I=e[4];const N=I,k=!r&&!i;let P;e[5]!==n?(P=n("settings.layout.general.files.title"),e[5]=n,e[6]=P):P=e[6];let j;e[7]!==n?(j=n("settings.openchamber.visual.field.fileEditorKeymap"),e[7]=n,e[8]=j):j=e[8];let C;e[9]!==n?(C=n("settings.openchamber.visual.field.fileEditorKeymap"),e[9]=n,e[10]=C):C=e[10];let E;e[11]!==n?(E=n("settings.openchamber.visual.option.fileEditorKeymap.default"),e[11]=n,e[12]=E):E=e[12];let F;e[13]!==E?(F={value:"default",label:E},e[13]=E,e[14]=F):F=e[14];let O;e[15]!==n?(O=n("settings.openchamber.visual.option.fileEditorKeymap.vim"),e[15]=n,e[16]=O):O=e[16];let K;e[17]!==O?(K={value:"vim",label:O},e[17]=O,e[18]=K):K=e[18];let D;e[19]!==K||e[20]!==F?(D=[F,K],e[19]=K,e[20]=F,e[21]=D):D=e[21];let M;e[22]!==c||e[23]!==u||e[24]!==D||e[25]!==C?(M=s.jsx(Xt,{value:c,onChange:u,"aria-label":C,options:D}),e[22]=c,e[23]=u,e[24]=D,e[25]=C,e[26]=M):M=e[26];let T;e[27]!==M||e[28]!==j?(T=s.jsx(st,{label:j,settingsItem:"appearance.file-editor-keymap",children:M}),e[27]=M,e[28]=j,e[29]=T):T=e[29];let R;e[30]!==c||e[31]!==d||e[32]!==A||e[33]!==l||e[34]!==n?(R=c==="vim"?s.jsx(St,{label:n("settings.openchamber.visual.field.fileEditorVimMappings"),info:n("settings.openchamber.visual.field.fileEditorVimMappingsInfo"),description:A.length>0?n("settings.openchamber.visual.field.fileEditorVimMappingsInvalid",{lines:A.join(", ")}):void 0,descriptionPlacement:"after",settingsItem:"appearance.file-editor-vim-mappings",className:"pt-1 pb-2",children:s.jsx(Cs,{value:d,onChange:me=>l(me.target.value),placeholder:"inoremap jk <Esc>","aria-label":n("settings.openchamber.visual.field.fileEditorVimMappings"),rows:4,spellCheck:!1,className:"w-full font-mono typography-meta"})}):null,e[30]=c,e[31]=d,e[32]=A,e[33]=l,e[34]=n,e[35]=R):R=e[35];let $;e[36]!==f||e[37]!==p||e[38]!==k||e[39]!==n?($=k?s.jsx(st,{label:n("settings.openchamber.visual.field.fileTreeSide"),settingsItem:"appearance.file-tree-side",children:s.jsx(Xt,{value:f,onChange:p,"aria-label":n("settings.openchamber.visual.field.fileTreeSide"),options:[{value:"left",label:n("settings.openchamber.visual.option.fileTreeSide.left")},{value:"right",label:n("settings.openchamber.visual.option.fileTreeSide.right")}]})}):null,e[36]=f,e[37]=p,e[38]=k,e[39]=n,e[40]=$):$=e[40];let z;e[41]!==T||e[42]!==R||e[43]!==$?(z=s.jsxs("div",{children:[T,R,$]}),e[41]=T,e[42]=R,e[43]=$,e[44]=z):z=e[44];let Q;e[45]!==n?(Q=n("settings.openchamber.visual.field.autoSaveEnabled"),e[45]=n,e[46]=Q):Q=e[46];let V;e[47]!==n?(V=n("settings.openchamber.visual.field.autoSaveEnabledAria"),e[47]=n,e[48]=V):V=e[48];let L;e[49]!==n?(L=n("settings.openchamber.visual.field.autoSaveEnabledInfo"),e[49]=n,e[50]=L):L=e[50];let B;e[51]!==g||e[52]!==h||e[53]!==Q||e[54]!==V||e[55]!==L?(B=s.jsx(ct,{checked:g,onChange:h,label:Q,ariaLabel:V,info:L,settingsItem:"appearance.auto-save-enabled"}),e[51]=g,e[52]=h,e[53]=Q,e[54]=V,e[55]=L,e[56]=B):B=e[56];let W;e[57]!==y||e[58]!==b||e[59]!==k||e[60]!==n?(W=k?s.jsx(ct,{checked:y,onChange:b,label:n("settings.openchamber.visual.field.confirmFileTreeMove"),ariaLabel:n("settings.openchamber.visual.field.confirmFileTreeMove"),settingsItem:"appearance.confirm-file-tree-move"}):null,e[57]=y,e[58]=b,e[59]=k,e[60]=n,e[61]=W):W=e[61];let Y;e[62]!==x||e[63]!==n?(Y=r?null:s.jsx(ct,{checked:x,onChange:df,label:n("settings.openchamber.visual.field.showDotfiles"),ariaLabel:n("settings.openchamber.visual.field.showDotfilesAria"),settingsItem:"chat.dotfiles"}),e[62]=x,e[63]=n,e[64]=Y):Y=e[64];let ae;e[65]!==n?(ae=n("settings.openchamber.defaults.field.openFilesPreview"),e[65]=n,e[66]=ae):ae=e[66];let ee;e[67]!==n?(ee=n("settings.openchamber.defaults.field.openFilesPreviewAria"),e[67]=n,e[68]=ee):ee=e[68];let G;e[69]!==w||e[70]!==N||e[71]!==ae||e[72]!==ee?(G=s.jsx(ct,{checked:w,onChange:N,label:ae,ariaLabel:ee,settingsItem:"general.file-viewer-preview"}),e[69]=w,e[70]=N,e[71]=ae,e[72]=ee,e[73]=G):G=e[73];let le;e[74]!==B||e[75]!==W||e[76]!==Y||e[77]!==G?(le=s.jsxs("div",{className:bs,children:[B,W,Y,G]}),e[74]=B,e[75]=W,e[76]=Y,e[77]=G,e[78]=le):le=e[78];let J;return e[79]!==a||e[80]!==z||e[81]!==le||e[82]!==P?(J=s.jsxs($e,{title:P,divider:a,contentClassName:"space-y-4",children:[z,le]}),e[79]=a,e[80]=z,e[81]=le,e[82]=P,e[83]=J):J=e[83],J},FS=()=>{const t=De.c(66),{t:e}=Ee(),{isMobile:a}=Zs(),{terminal:n}=oi(),i=re(ZS),o=re(XS),r=re(eN),c=re(tN),u=re(sN),d=re(nN);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=[],t[0]=l):l=t[0];const[f,p]=m.useState(l),[g,h]=m.useState(0);let y,b;t[1]===Symbol.for("react.memo_cache_sentinel")?(y=()=>Go(()=>{p([]),h(aN)}),b=[],t[1]=y,t[2]=b):(y=t[1],b=t[2]),m.useEffect(y,b);let x;t[3]!==n?(x=()=>{let W=!1;if(n.listShells)return n.listShells().then(Y=>{W||p(Y)}).catch(()=>{W||p([])}),()=>{W=!0}},t[3]=n,t[4]=x):x=t[4];let w;t[5]!==n||t[6]!==g?(w=[n,g],t[5]=n,t[6]=g,t[7]=w):w=t[7],m.useEffect(x,w);let S;if(t[8]!==f||t[9]!==i){e:{const W=f.filter(iN);if(i==="auto"||W.some(ae=>ae.id===i)){S=W;break e}let Y;t[11]!==i?(Y={id:i,name:i,supportsLogin:!1},t[11]=i,t[12]=Y):Y=t[12],S=[Y,...W]}t[8]=f,t[9]=i,t[10]=S}else S=t[10];const v=S;let A;t[13]!==f||t[14]!==i?(A=f.find(W=>W.id===i)?.supportsLogin,t[13]=f,t[14]=i,t[15]=A):A=t[15];const I=A===!0;let N;t[16]!==r||t[17]!==i?(N=r.includes(i),t[16]=r,t[17]=i,t[18]=N):N=t[18];const k=N;let P;t[19]!==c||t[20]!==r||t[21]!==i?(P=W=>{c(W?[...r.filter(Y=>Y!==i),i]:r.filter(Y=>Y!==i))},t[19]=c,t[20]=r,t[21]=i,t[22]=P):P=t[22];const j=P;let C;t[23]!==e?(C=e("settings.layout.general.terminal.title"),t[23]=e,t[24]=C):C=t[24];let E;t[25]!==e?(E=e("settings.openchamber.visual.field.terminalShell"),t[25]=e,t[26]=E):E=t[26];let F;t[27]!==e?(F=e("settings.openchamber.visual.field.terminalShellHint"),t[27]=e,t[28]=F):F=t[28];let O;t[29]!==o?(O=W=>{pf(W)&&o(W)},t[29]=o,t[30]=O):O=t[30];let K;t[31]!==e?(K=e("settings.openchamber.visual.field.terminalShellAria"),t[31]=e,t[32]=K):K=t[32];let D;t[33]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(Kt,{}),t[33]=D):D=t[33];let M;t[34]!==K?(M=s.jsx(Ct,{"aria-label":K,className:Es,children:D}),t[34]=K,t[35]=M):M=t[35];let T;t[36]!==e?(T=e("settings.openchamber.visual.option.terminalShell.auto"),t[36]=e,t[37]=T):T=t[37];let R;t[38]!==T?(R=s.jsx(bt,{value:"auto",children:T}),t[38]=T,t[39]=R):R=t[39];let $;t[40]!==v?($=v.map(oN),t[40]=v,t[41]=$):$=t[41];let z;t[42]!==R||t[43]!==$?(z=s.jsxs(It,{children:[R,$]}),t[42]=R,t[43]=$,t[44]=z):z=t[44];let Q;t[45]!==O||t[46]!==M||t[47]!==z||t[48]!==i?(Q=s.jsxs(Pt,{value:i,onValueChange:O,children:[M,z]}),t[45]=O,t[46]=M,t[47]=z,t[48]=i,t[49]=Q):Q=t[49];let V;t[50]!==E||t[51]!==F||t[52]!==Q?(V=s.jsx(st,{label:E,info:F,settingsItem:"appearance.terminal-shell",children:Q}),t[50]=E,t[51]=F,t[52]=Q,t[53]=V):V=t[53];let L;t[54]!==a||t[55]!==d||t[56]!==j||t[57]!==u||t[58]!==e||t[59]!==k||t[60]!==I?(L=I||!a?s.jsxs("div",{className:bs,children:[I?s.jsx(ct,{checked:k,onChange:j,label:e("settings.openchamber.visual.field.terminalLoginShell"),ariaLabel:e("settings.openchamber.visual.field.terminalLoginShell"),settingsItem:"appearance.terminal-login-shell"}):null,a?null:s.jsx(ct,{checked:u,onChange:d,label:e("settings.openchamber.visual.field.terminalQuickKeys"),ariaLabel:e("settings.openchamber.visual.field.terminalQuickKeysAria"),settingsItem:"appearance.terminal-quick-keys",info:e("settings.openchamber.visual.field.terminalQuickKeysTooltip",{control:Hn("ctrl"),alt:Hn("alt")})})]}):null,t[54]=a,t[55]=d,t[56]=j,t[57]=u,t[58]=e,t[59]=k,t[60]=I,t[61]=L):L=t[61];let B;return t[62]!==V||t[63]!==L||t[64]!==C?(B=s.jsxs($e,{title:C,contentClassName:"space-y-3",children:[V,L]}),t[62]=V,t[63]=L,t[64]=C,t[65]=B):B=t[65],B},LS=()=>{const t=De.c(41),{t:e}=Ee(),{isMobile:a}=Zs(),n=re(rN),i=re(lN),o=re(cN),r=re(dN),c=re(uN),u=re(mN),d=re(pN),l=re(gN),f=re(fN),p=re(hN);let g;t[0]!==e?(g=e("settings.layout.general.panels.title"),t[0]=e,t[1]=g):g=t[1];let h;t[2]!==a||t[3]!==n||t[4]!==i||t[5]!==e?(h=a?null:s.jsx(ct,{checked:n,onChange:i,label:e("settings.openchamber.visual.field.sessionTabs"),ariaLabel:e("settings.openchamber.visual.field.sessionTabsAria"),info:e("settings.openchamber.visual.field.sessionTabsInfo"),settingsItem:"appearance.session-tabs"}),t[2]=a,t[3]=n,t[4]=i,t[5]=e,t[6]=h):h=t[6];let y;t[7]!==a||t[8]!==o||t[9]!==r||t[10]!==e?(y=a?null:s.jsx(ct,{checked:o,onChange:r,label:e("settings.openchamber.visual.field.layoutAnimations"),ariaLabel:e("settings.openchamber.visual.field.layoutAnimationsAria"),info:e("settings.openchamber.visual.field.layoutAnimationsInfo"),settingsItem:"appearance.layout-animations"}),t[7]=a,t[8]=o,t[9]=r,t[10]=e,t[11]=y):y=t[11];let b;t[12]!==a||t[13]!==c||t[14]!==u||t[15]!==e?(b=is()&&!a?s.jsx(ct,{checked:c,onChange:u,label:e("settings.openchamber.visual.field.openLinksInBrowserPanel"),ariaLabel:e("settings.openchamber.visual.field.openLinksInBrowserPanel"),info:e("settings.openchamber.visual.field.openLinksInBrowserPanelInfo"),settingsItem:"appearance.open-links-in-browser-panel"}):null,t[12]=a,t[13]=c,t[14]=u,t[15]=e,t[16]=b):b=t[16];let x;t[17]!==e?(x=e("settings.openchamber.visual.field.openTrackerLinksOnBoard"),t[17]=e,t[18]=x):x=t[18];let w;t[19]!==e?(w=e("settings.openchamber.visual.field.openTrackerLinksOnBoard"),t[19]=e,t[20]=w):w=t[20];let S;t[21]!==e?(S=e("settings.openchamber.visual.field.openTrackerLinksOnBoardInfo"),t[21]=e,t[22]=S):S=t[22];let v;t[23]!==f||t[24]!==p||t[25]!==x||t[26]!==w||t[27]!==S?(v=s.jsx(ct,{checked:f,onChange:p,label:x,ariaLabel:w,info:S,settingsItem:"appearance.open-tracker-links-on-board"}),t[23]=f,t[24]=p,t[25]=x,t[26]=w,t[27]=S,t[28]=v):v=t[28];let A;t[29]!==a||t[30]!==d||t[31]!==l||t[32]!==e?(A=is()&&!a?s.jsx(st,{label:e("settings.openchamber.visual.field.liveBrowserTabs"),info:e("settings.openchamber.visual.field.liveBrowserTabsInfo"),settingsItem:"appearance.live-browser-tabs",children:s.jsxs("div",{className:Fn,children:[s.jsx(ds,{value:d,onValueChange:l,min:mf,max:uf,step:1,className:us,deferExternalValueWhileFocused:!0,"aria-label":e("settings.openchamber.visual.field.liveBrowserTabs")}),s.jsx("span",{className:ga,children:e("settings.openchamber.visual.field.liveBrowserTabsUnit")})]})}):null,t[29]=a,t[30]=d,t[31]=l,t[32]=e,t[33]=A):A=t[33];let I;return t[34]!==g||t[35]!==h||t[36]!==y||t[37]!==b||t[38]!==v||t[39]!==A?(I=s.jsxs($e,{title:g,contentClassName:bs,children:[h,y,b,v,A]}),t[34]=g,t[35]=h,t[36]=y,t[37]=b,t[38]=v,t[39]=A,t[40]=I):I=t[40],I},KS=t=>{const e=De.c(10),{firstSection:a}=t;let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=os(),e[0]=n):n=e[0];const i=n,{isMobile:o}=Zs(),r=!a;let c;e[1]!==r?(c=s.jsx(OS,{divider:r}),e[1]=r,e[2]=c):c=e[2];let u,d;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=i?null:s.jsx(FS,{}),d=i?null:s.jsx(LS,{}),e[3]=u,e[4]=d):(u=e[3],d=e[4]);let l;e[5]!==o?(l=o?s.jsx(TS,{}):null,e[5]=o,e[6]=l):l=e[6];let f;return e[7]!==c||e[8]!==l?(f=s.jsxs(s.Fragment,{children:[c,u,d,l]}),e[7]=c,e[8]=l,e[9]=f):f=e[9],f},_S=()=>{const t=De.c(55),{t:e}=Ee(),a=ft(bN),n=ft(xN),i=re(vN),o=re(yN);let r,c,u,d,l,f,p;if(t[0]!==a||t[1]!==n||t[2]!==o||t[3]!==e){let A;t[11]!==a?(A=E=>E.id===a,t[11]=a,t[12]=A):A=t[12];const I=Cd.find(A);let N;t[13]!==n?(N=E=>{n(E),jt({messageStreamTransport:E})},t[13]=n,t[14]=N):N=t[14];const k=N;let P;t[15]!==o?(P=E=>{o(E),jt({reportUsage:E})},t[15]=o,t[16]=P):P=t[16],c=P,r=$e,t[17]!==e?(u=e("settings.openchamber.visual.section.messageStreamTransport"),t[17]=e,t[18]=u):u=t[18],d="chat.message-transport",l="space-y-2";let j;t[19]!==e?(j=Cd.map(E=>({value:E.id,label:e(E.labelKey)})),t[19]=e,t[20]=j):j=t[20];let C;t[21]!==e?(C=e("settings.openchamber.visual.section.messageStreamTransport"),t[21]=e,t[22]=C):C=t[22],t[23]!==k||t[24]!==a||t[25]!==j||t[26]!==C?(f=s.jsx(Xt,{value:a,options:j,onChange:k,"aria-label":C}),t[23]=k,t[24]=a,t[25]=j,t[26]=C,t[27]=f):f=t[27],p=I?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e(I.descriptionKey)}):null,t[0]=a,t[1]=n,t[2]=o,t[3]=e,t[4]=r,t[5]=c,t[6]=u,t[7]=d,t[8]=l,t[9]=f,t[10]=p}else r=t[4],c=t[5],u=t[6],d=t[7],l=t[8],f=t[9],p=t[10];let g;t[28]!==r||t[29]!==u||t[30]!==d||t[31]!==l||t[32]!==f||t[33]!==p?(g=s.jsxs(r,{title:u,settingsItem:d,contentClassName:l,children:[f,p]}),t[28]=r,t[29]=u,t[30]=d,t[31]=l,t[32]=f,t[33]=p,t[34]=g):g=t[34];let h;t[35]!==e?(h=e("settings.openchamber.visual.section.privacy"),t[35]=e,t[36]=h):h=t[36];let y;t[37]!==e?(y=e("settings.openchamber.visual.field.sendAnonymousUsageReports"),t[37]=e,t[38]=y):y=t[38];let b;t[39]!==e?(b=e("settings.openchamber.visual.field.sendAnonymousUsageReportsHint"),t[39]=e,t[40]=b):b=t[40];let x;t[41]!==e?(x=e("settings.openchamber.visual.field.sendAnonymousUsageReportsAria"),t[41]=e,t[42]=x):x=t[42];let w;t[43]!==c||t[44]!==i||t[45]!==y||t[46]!==b||t[47]!==x?(w=s.jsx(ct,{checked:i,onChange:c,label:y,info:b,ariaLabel:x,settingsItem:"appearance.usage-reports"}),t[43]=c,t[44]=i,t[45]=y,t[46]=b,t[47]=x,t[48]=w):w=t[48];let S;t[49]!==w||t[50]!==h?(S=s.jsx($e,{title:h,children:w}),t[49]=w,t[50]=h,t[51]=S):S=t[51];let v;return t[52]!==S||t[53]!==g?(v=s.jsxs(s.Fragment,{children:[g,S]}),t[52]=S,t[53]=g,t[54]=v):v=t[54],v};function $S(t){return t.fileEditorKeymap}function zS(t){return t.setFileEditorKeymap}function US(t){return t.fileEditorVimMappings}function BS(t){return t.setFileEditorVimMappings}function VS(t){return t.fileTreeSide}function HS(t){return t.setFileTreeSide}function qS(t){return t.autoSaveEnabled}function WS(t){return t.setAutoSaveEnabled}function GS(t){return t.confirmFileTreeMove}function JS(t){return t.setConfirmFileTreeMove}function QS(t){return t.settingsDefaultFileViewerPreview}function YS(t){return t.setSettingsDefaultFileViewerPreview}function ZS(t){return t.terminalShell}function XS(t){return t.setTerminalShell}function eN(t){return t.terminalLoginShells}function tN(t){return t.setTerminalLoginShells}function sN(t){return t.showTerminalQuickKeysOnDesktop}function nN(t){return t.setShowTerminalQuickKeysOnDesktop}function aN(t){return t+1}function iN(t){return t.id!=="auto"}function oN(t){return s.jsx(bt,{value:t.id,children:t.name},t.id)}function rN(t){return t.sessionTabsEnabled}function lN(t){return t.setSessionTabsEnabled}function cN(t){return t.layoutAnimations}function dN(t){return t.setLayoutAnimations}function uN(t){return t.openLinksInBrowserPanel}function mN(t){return t.setOpenLinksInBrowserPanel}function pN(t){return t.liveBrowserTabLimit}function gN(t){return t.setLiveBrowserTabLimit}function fN(t){return t.openTrackerLinksOnBoard}function hN(t){return t.setOpenTrackerLinksOnBoard}function bN(t){return t.settingsMessageStreamTransport}function xN(t){return t.setSettingsMessageStreamTransport}function vN(t){return t.reportUsage}function yN(t){return t.setReportUsage}const lm=t=>`shortcuts.action.${t}`,jN=[{id:"chat.activity-default",page:"chat",titleKey:"settings.openchamber.visual.section.activityDefault",keywords:["activity","collapsed","expanded","live","tools","history"]},{id:"appearance.language",page:"appearance",titleKey:"settings.appearance.language.label",descriptionKey:"settings.appearance.language.description",keywords:["locale","translation","ui language"]},{id:"appearance.time-format",page:"appearance",titleKey:"settings.openchamber.visual.field.timeFormat",keywords:["clock","12h","24h"]},{id:"appearance.week-start",page:"appearance",titleKey:"settings.openchamber.visual.field.weekStartsOn",keywords:["calendar","monday","sunday"]},{id:"appearance.light-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.lightTheme",keywords:["theme","color","light mode"],isAvailable:t=>!t.isVSCode},{id:"appearance.dark-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.darkTheme",keywords:["theme","color","dark mode"],isAvailable:t=>!t.isVSCode},{id:"appearance.import-theme",page:"appearance",titleKey:"settings.themeImport.action",descriptionKey:"settings.themeImport.catalogHint",keywords:["theme","import","vscode","open vsx","openvsx","json","jsonc","syntax","palette"],isAvailable:t=>!t.isVSCode},{id:"appearance.dock-badge",page:"appearance",titleKey:"settings.openchamber.visual.field.dockBadge",descriptionKey:"settings.openchamber.visual.field.dockBadgeHint",keywords:["dock","badge","unread","unseen","counter","count","notification","macos"],isAvailable:t=>t.isMac},{id:"appearance.scrollbars",page:"appearance",titleKey:"settings.openchamber.visual.field.alwaysShowScrollbars",descriptionKey:"settings.openchamber.visual.field.alwaysShowScrollbarsHint",keywords:["scrollbar","scrollbars","scroll","mouse","wheel","accessibility","always visible"]},{id:"appearance.pwa-install-name",page:"appearance",titleKey:"settings.openchamber.visual.field.installAppName",descriptionKey:"settings.openchamber.visual.field.installAppNameHint",keywords:["pwa","installed app"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.pwa-orientation",page:"appearance",titleKey:"settings.openchamber.visual.field.installOrientation",descriptionKey:"settings.openchamber.visual.field.installOrientationHint",keywords:["pwa","portrait","landscape"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.mobile-keyboard-mode",page:"appearance",titleKey:"settings.openchamber.visual.field.mobileKeyboardMode",descriptionKey:"settings.openchamber.visual.field.mobileKeyboardModeHint",keywords:["mobile","keyboard","resize"],isAvailable:t=>t.isMobile&&t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.animated-activity-indicators",page:"appearance",titleKey:"settings.openchamber.visual.field.animatedActivityIndicators",descriptionKey:"settings.openchamber.visual.field.animatedActivityIndicatorsInfo",keywords:["spinner","animation","session","activity","motion","running","indicator"]},{id:"appearance.interface-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.interfaceFontSize",keywords:["font","text size","ui scale"],isAvailable:t=>!t.isMobile},{id:"appearance.terminal-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.terminalFontSize",keywords:["terminal","font","text size"]},{id:"appearance.terminal-shell",page:"general",titleKey:"settings.openchamber.visual.field.terminalShell",descriptionKey:"settings.openchamber.visual.field.terminalShellHint",keywords:["terminal","shell","bash","zsh","fish","pwsh","powershell"],isAvailable:t=>!t.isVSCode},{id:"appearance.editor-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.editorFontSize",keywords:["editor","font","text size","code"]},{id:"appearance.spacing-density",page:"appearance",titleKey:"settings.openchamber.visual.field.spacingDensity",keywords:["density","compact","comfortable","spacing"]},{id:"appearance.input-bar-offset",page:"appearance",titleKey:"settings.openchamber.visual.field.inputBarOffset",descriptionKey:"settings.openchamber.visual.field.inputBarOffsetTooltip",keywords:["input","home bar","offset"],isAvailable:t=>t.isMobile},{id:"appearance.auto-save-enabled",page:"general",titleKey:"settings.openchamber.visual.field.autoSaveEnabled",descriptionKey:"settings.openchamber.visual.field.autoSaveEnabledInfo",keywords:["editor","autosave","auto-save","files","save"]},{id:"appearance.confirm-file-tree-move",page:"general",titleKey:"settings.openchamber.visual.field.confirmFileTreeMove",keywords:["files","tree","move","drag","drop","confirm"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.file-tree-side",page:"general",titleKey:"settings.openchamber.visual.field.fileTreeSide",keywords:["files","tree","explorer","left","right","side","editor"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.layout-animations",page:"general",titleKey:"settings.openchamber.visual.field.layoutAnimations",descriptionKey:"settings.openchamber.visual.field.layoutAnimationsInfo",keywords:["animation","motion","sidebar","panel","slide","instant"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.open-links-in-browser-panel",page:"general",titleKey:"settings.openchamber.visual.field.openLinksInBrowserPanel",descriptionKey:"settings.openchamber.visual.field.openLinksInBrowserPanelInfo",keywords:["links","url","browser","open","preview","external"],isAvailable:t=>t.isDesktop&&!t.isMobile&&!t.isVSCode},{id:"appearance.live-browser-tabs",page:"general",titleKey:"settings.openchamber.visual.field.liveBrowserTabs",descriptionKey:"settings.openchamber.visual.field.liveBrowserTabsInfo",keywords:["browser","tabs","memory","reload","background","loaded"],isAvailable:t=>t.isDesktop&&!t.isMobile&&!t.isVSCode},{id:"layout.mobile-workspace-tabs",page:"general",titleKey:"settings.layout.general.mobileTabs.title",descriptionKey:"settings.layout.general.mobileTabs.info",keywords:["tabs","workspace","panel","order","hide","git","files","terminal","mcp","mobile"],isAvailable:t=>t.isMobile},{id:"appearance.open-tracker-links-on-board",page:"general",titleKey:"settings.openchamber.visual.field.openTrackerLinksOnBoard",descriptionKey:"settings.openchamber.visual.field.openTrackerLinksOnBoardInfo",keywords:["links","github","gitlab","linear","issue","pull request","merge request","board"],isAvailable:t=>!t.isVSCode},{id:"appearance.file-editor-keymap",page:"general",titleKey:"settings.openchamber.visual.field.fileEditorKeymap",keywords:["editor","vim","keymap"]},{id:"appearance.session-tabs",page:"general",titleKey:"settings.openchamber.visual.field.sessionTabsGroup",descriptionKey:"settings.openchamber.visual.field.sessionTabsInfo",keywords:["session","tabs","header","working set"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.terminal-quick-keys",page:"general",titleKey:"settings.openchamber.visual.field.terminalQuickKeys",descriptionKey:"settings.openchamber.visual.field.terminalQuickKeysTooltip",keywords:["terminal","keyboard","esc","ctrl","arrows"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.usage-reports",page:"general",titleKey:"settings.openchamber.visual.field.sendAnonymousUsageReports",descriptionKey:"settings.openchamber.visual.field.sendAnonymousUsageReportsHint",keywords:["telemetry","analytics"]},{id:"general.app-links",page:"general",titleKey:"settings.openchamber.appLinks.title",descriptionKey:"settings.openchamber.appLinks.info",keywords:["security","app link","deep link","scheme","protocol","obsidian","notion"]},{id:"chat.message-transport",page:"general",titleKey:"settings.openchamber.visual.section.messageStreamTransport",keywords:["streaming","sse","websocket"]},{id:"chat.session-recap",page:"chat",titleKey:"settings.openchamber.visual.field.sessionRecap",keywords:["recap","assist","small model","summary"]},{id:"chat.session-assistance",page:"chat",titleKey:"settings.openchamber.visual.section.sessionAssistance",keywords:["recap","suggestion","subagent"]},{id:"chat.session-suggestion",page:"chat",titleKey:"settings.openchamber.visual.field.sessionSuggestion",keywords:["suggestion","assist","small model","follow up"]},{id:"chat.session-review-offer",page:"chat",titleKey:"settings.openchamber.visual.field.sessionReviewOffer",descriptionKey:"settings.openchamber.visual.field.sessionReviewOfferInfo",keywords:["review","walkthrough","changes","diff","jev","classification"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal",page:"chat",titleKey:"settings.openchamber.visual.field.sessionGoal",keywords:["goal","objective","auto continue"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal-checker",page:"chat",titleKey:"settings.openchamber.visual.goal.checkerLabel",keywords:["goal","progress","check","jev","classification","small model"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal-max-turns",page:"chat",titleKey:"settings.openchamber.visual.goal.maxTurnsLabel",keywords:["goal","turns","limit","continuations","safety"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal-budget",page:"chat",titleKey:"settings.openchamber.visual.goal.budgetLabel",keywords:["goal","budget","tokens","limit"],isAvailable:t=>!t.isVSCode},{id:"chat.reasoning-traces",page:"chat",titleKey:"settings.openchamber.visual.field.showReasoningTraces",keywords:["thinking","reasoning"]},{id:"chat.reasoning",page:"chat",titleKey:"settings.openchamber.visual.section.reasoning",keywords:["thinking","traces","collapse","expand","streaming"]},{id:"chat.streaming-auto-follow",page:"chat",titleKey:"settings.openchamber.visual.field.streamingAutoFollow",descriptionKey:"settings.openchamber.visual.field.streamingAutoFollowInfo",keywords:["autoscroll","auto-scroll","follow","stick to bottom","streaming"]},{id:"chat.sticky-user-header",page:"chat",titleKey:"settings.openchamber.visual.field.stickyUserHeader",keywords:["sticky","pin","prompt","header","user messages"]},{id:"chat.prompt-navigator",page:"chat",titleKey:"settings.openchamber.visual.field.promptNavigatorEnabled",keywords:["prompt","navigator","navigation","timeline","scroll"]},{id:"chat.collapsible-user-messages",page:"chat",titleKey:"settings.openchamber.visual.field.collapsibleUserMessages",keywords:["collapse","expand","clamp","long messages","user messages"]},{id:"chat.wide-layout",page:"chat",titleKey:"settings.openchamber.visual.field.wideChatLayout",keywords:["layout","wide","messages"]},{id:"chat.message-appearance",page:"chat",titleKey:"settings.layout.chat.section.reading",keywords:["layout","messages","appearance"]},{id:"chat.code-block-line-wrap",page:"chat",titleKey:"settings.openchamber.visual.field.codeBlockLineWrap",keywords:["code","wrap","line wrap","markdown"]},{id:"chat.table-cell-wrap",page:"chat",titleKey:"settings.openchamber.visual.field.tableCellWrap",descriptionKey:"settings.openchamber.visual.field.tableCellWrapInfo",keywords:["table","wrap","cell","columns","markdown"]},{id:"chat.copy-plain-text",page:"chat",titleKey:"settings.openchamber.visual.field.copyMessagesAsPlainText",descriptionKey:"settings.openchamber.visual.field.copyMessagesAsPlainTextInfo",keywords:["copy","clipboard","plain text","markdown","selection"]},{id:"chat.inline-assistant-actions",page:"chat",titleKey:"settings.openchamber.visual.field.showSplitAssistantMessageActions",descriptionKey:"settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip",keywords:["copy","save image","read aloud"]},{id:"chat.draft-starters-visible",page:"chat",titleKey:"settings.openchamber.visual.field.draftStartersVisible",keywords:["starter","starters","new session","welcome","suggestions"]},{id:"chat.subagent-read-only-banner",page:"chat",titleKey:"settings.openchamber.visual.field.allowPromptingSubagentSessions",keywords:["subagent","read only","prompt","banner"]},{id:"chat.save-pasted-images",page:"chat",titleKey:"settings.openchamber.visual.field.savePastedImagesAsFiles",descriptionKey:"settings.openchamber.visual.field.savePastedImagesAsFilesInfo",keywords:["image","screenshot","paste","vision","text-only","model","path","attachment","file","link"]},{id:"chat.tool-file-icons",page:"chat",titleKey:"settings.openchamber.visual.field.showToolFileIcons",keywords:["tools","files","icons"]},{id:"chat.changed-files",page:"chat",titleKey:"settings.openchamber.visual.field.showTurnChangedFiles",keywords:["changed files","turns"]},{id:"chat.dotfiles",page:"general",titleKey:"settings.openchamber.visual.field.showDotfiles",keywords:["hidden files","dotfiles","file tree","files"],isAvailable:t=>!t.isVSCode},{id:"general.file-viewer-preview",page:"general",titleKey:"settings.openchamber.defaults.field.openFilesPreview",keywords:["preview","markdown","files","viewer","rendered"]},{id:"chat.user-message-rendering",page:"chat",titleKey:"settings.openchamber.visual.section.userMessageRendering",keywords:["markdown","plain text","user message","format"]},{id:"chat.mermaid-rendering",page:"chat",titleKey:"settings.openchamber.visual.section.mermaidRendering",keywords:["mermaid","diagram","svg","ascii"]},{id:"chat.diff-layout",page:"chat",titleKey:"settings.openchamber.visual.section.diffLayout",keywords:["diff","inline","side by side","split","changes"],isAvailable:t=>!t.isVSCode},{id:"chat.follow-up-behavior",page:"chat",titleKey:"settings.openchamber.visual.section.followUpBehavior",descriptionKey:"settings.openchamber.visual.field.followUpBehaviorDescription",keywords:["follow up","queue","steer","send immediately"]},{id:"chat.input-history-scope",page:"chat",titleKey:"settings.openchamber.visual.field.inputHistoryScope",descriptionKey:"settings.openchamber.visual.field.inputHistoryScopeDescription",keywords:["input history","composer history","global","session","reuse"]},{id:"chat.input-history-limit",page:"chat",titleKey:"settings.openchamber.visual.field.inputHistoryLimit",descriptionKey:"settings.openchamber.visual.field.inputHistoryLimitDescription",keywords:["history limit","prompt recall","remember prompts","composer history","submitted prompts","trim history"]},{id:"chat.message-search",page:"chat",titleKey:"settings.openchamber.messageSearch.title",keywords:["search","find","index","messages","history","full text"],isAvailable:t=>!t.isVSCode},{id:"chat.message-search-enabled",page:"chat",titleKey:"settings.openchamber.messageSearch.field.enabled",keywords:["search","find","index","messages"],isAvailable:t=>!t.isVSCode},{id:"chat.message-search-reasoning",page:"chat",titleKey:"settings.openchamber.messageSearch.field.reasoning",keywords:["search","reasoning","thinking","index"],isAvailable:t=>!t.isVSCode},{id:"chat.persist-drafts",page:"chat",titleKey:"settings.openchamber.visual.field.persistDraftMessages",keywords:["draft","message"]},{id:"chat.composer",page:"chat",titleKey:"settings.layout.chat.section.sending",keywords:["composer","input","send","paste","follow-up"]},{id:"chat.spellcheck",page:"chat",titleKey:"settings.openchamber.visual.field.enableSpellcheckInTextInputs",keywords:["spelling","input"],isAvailable:t=>!t.isMobile},{id:"chat.large-text-paste",page:"chat",titleKey:"settings.openchamber.visual.field.largeTextPaste",descriptionKey:"settings.openchamber.visual.field.largeTextPasteHint",keywords:["paste","clipboard","attachment","large","text","file","double paste","ctrl v","cmd v"]},{id:"chat.enter-to-send",page:"chat",titleKey:"settings.openchamber.visual.field.enterToSend",descriptionKey:"settings.openchamber.visual.field.enterToSendHint",keywords:["enter","shift enter","ctrl enter","cmd enter","mod enter","send","newline"],isAvailable:t=>!t.isMobile},{id:"sessions.default-model",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultModel",keywords:["model","provider","new sessions"]},{id:"sessions.default-thinking",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultThinking",keywords:["thinking","reasoning","variant"]},{id:"sessions.default-agent",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultAgent",keywords:["agent","new sessions"]},{id:"sessions.deletion-dialog",page:"sessions",titleKey:"settings.openchamber.defaults.field.showDeletionDialog",keywords:["delete","confirmation"]},{id:"sessions.warming",page:"sessions",titleKey:"settings.openchamber.defaults.field.sessionWarming",descriptionKey:"settings.openchamber.defaults.field.sessionWarmingInfo",keywords:["warming","warm","cache","prompt cache","keep-alive","idle","per session","keep warm"]},{id:"sessions.warming-duration",page:"sessions",titleKey:"settings.openchamber.defaults.sessionWarming.duration",keywords:["warming","warm","duration","how long","hour","cache"],isAvailable:t=>!t.isVSCode},{id:"sessions.permission-default",page:"sessions",titleKey:"settings.sessions.permissions.defaultMode",descriptionKey:"settings.sessions.permissions.defaultModeInfo",keywords:["permissions","auto-accept","accept","safety net","ask","shield","approval","new session"],isAvailable:t=>!t.isVSCode},{id:"sessions.show-chats",page:"sessions",titleKey:"settings.openchamber.defaults.field.showChats",keywords:["chats","sidebar","hide","show","section"],isAvailable:t=>!t.isVSCode},{id:"sessions.work",page:"sessions",titleKey:"settings.openchamber.sessionWork.title",descriptionKey:"settings.openchamber.sessionWork.info",keywords:["in work","in progress","track","done","inbox","sidebar","recent","jev"]},{id:"sessions.work-enabled",page:"sessions",titleKey:"settings.openchamber.sessionWork.field.enabled",keywords:["in work","in progress","track","done","sidebar"]},{id:"sessions.small-model",page:"sessions",titleKey:"settings.openchamber.defaults.smallModel.title",descriptionKey:"settings.openchamber.defaults.smallModel.description",keywords:["small model","utility","summary","recap","cheap","override"]},{id:"sessions.walkthrough-model",page:"sessions",titleKey:"settings.openchamber.defaults.walkthroughModel.title",descriptionKey:"settings.openchamber.defaults.walkthroughModel.description",keywords:["walkthrough","diff","review","changes","structured output","model","override"]},{id:"sessions.auto-cleanup",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.enableAutoCleanup",descriptionKey:"settings.openchamber.sessionRetention.tooltip",keywords:["retention","archive","delete"]},{id:"sessions.merged-worktree-cleanup",page:"sessions",titleKey:"settings.openchamber.mergedWorktreeCleanup.field.enable",descriptionKey:"settings.openchamber.mergedWorktreeCleanup.field.enableDescription",keywords:["pr","pull request","merged","worktree","branch","archive","cleanup","remove"]},{id:"sessions.retention-only-archived",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.onlyArchived",descriptionKey:"settings.openchamber.sessionRetention.field.onlyArchivedDescription",keywords:["archive","archived","only","delete","cleanup","retention"]},{id:"sessions.retention-period",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.retentionPeriod",keywords:["days","cleanup","retention"]},{id:"sessions.retention-action",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.whenSessionsExpire",keywords:["archive","delete","expire"]},{id:"sessions.desktop-launch-at-login",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.launchAtLogin",descriptionKey:"settings.openchamber.desktopNetwork.field.launchAtLoginDescription",keywords:["desktop","startup","login","launch","background","autostart"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-window-controls-position",page:"appearance",titleKey:"settings.openchamber.desktopNetwork.field.windowControlsPosition",descriptionKey:"settings.openchamber.desktopNetwork.field.windowControlsPositionDescription",keywords:["desktop","window","controls","minimize","maximize","close","titlebar","linux","windows"],isAvailable:t=>t.isDesktop&&(t.isWindows||!t.isMac)},{id:"sessions.desktop-window-controls-style",page:"appearance",titleKey:"settings.openchamber.desktopNetwork.field.windowControlsStyle",keywords:["desktop","window","controls","style","traffic","lights","classic","macos","titlebar"],isAvailable:t=>t.isDesktop&&(t.isWindows||!t.isMac)},{id:"sessions.desktop-mac-menu-bar",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.macMenuBar",descriptionKey:"settings.openchamber.desktopNetwork.field.macMenuBarDescription",keywords:["desktop","menu bar","tray","status item","macos","background"],isAvailable:t=>t.isDesktopLocalOrigin&&t.isMac},{id:"sessions.desktop-linux-native-frame",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.linuxNativeFrame",descriptionKey:"settings.openchamber.desktopNetwork.field.linuxNativeFrameDescription",keywords:["desktop","linux","title bar","titlebar","window","frame","decorations","gnome","kde"],isAvailable:t=>t.isDesktopLocalOrigin&&t.isLinux},{id:"sessions.desktop-minimize-to-tray",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.minimizeToTray",descriptionKey:"settings.openchamber.desktopNetwork.field.minimizeToTrayDescription",keywords:["desktop","tray","system tray","minimize","close","background","windows","linux"],isAvailable:t=>t.isDesktopLocalOrigin&&(t.isWindows||t.isLinux)},{id:"sessions.desktop-keep-awake",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.keepAwake",descriptionKey:"settings.openchamber.desktopNetwork.field.keepAwakeDescription",keywords:["desktop","sleep","awake","server","mobile","phone"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-mini-chat-global-shortcut",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.miniChatGlobalShortcut",descriptionKey:"settings.openchamber.desktopNetwork.field.miniChatGlobalShortcutDescription",keywords:["desktop","mini chat","shortcut","hotkey","global","keyboard"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-quake-mode",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.quakeMode",descriptionKey:"settings.openchamber.desktopNetwork.field.quakeModeDescription",keywords:["desktop","quake","dropdown","hotkey","shortcut","height","global","background","tray","terminal"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-ui-password",page:"general",titleKey:"settings.openchamber.desktopPassword.field.password",descriptionKey:"settings.openchamber.desktopPassword.field.passwordDescription",keywords:["desktop","password","auth","login"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-lan-access",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.allowLanAccess",descriptionKey:"settings.openchamber.desktopNetwork.field.allowLanAccessDescription",keywords:["desktop","lan","network","phone","tablet"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.opencode-binary",page:"general",titleKey:"settings.openchamber.opencodeCli.field.binaryPath",keywords:["opencode","cli","binary","path"],isAvailable:t=>!t.isVSCode},{id:"sessions.opencode-restart",page:"general",titleKey:"settings.openchamber.opencodeCli.actions.restart",keywords:["opencode","restart","reload","plugin"],isAvailable:t=>!t.isVSCode},{id:"general.environment-variables",page:"general",titleKey:"settings.environment.user.title",descriptionKey:"settings.environment.user.info",keywords:["environment","env","variables","api key","token","secret","opencode","terminal","git"],isAvailable:t=>!t.isVSCode},{id:"sessions.opencode-update-notifications",page:"general",titleKey:"settings.openchamber.opencodeCli.field.showUpdateNotifications",keywords:["opencode","cli","updates"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-control-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentControlTool",descriptionKey:"settings.openchamber.tools.field.agentControlToolInfo",keywords:["agent","tool","orchestration","openchamber","sessions","worktree","control"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-schedule-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentScheduleTool",descriptionKey:"settings.openchamber.tools.field.agentScheduleToolInfo",keywords:["agent","tool","schedule","scheduled","task","cron","recurring","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-web-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentWebTool",descriptionKey:"settings.openchamber.tools.field.agentWebToolInfo",keywords:["agent","tool","web","browser","page","preview","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.browser-provider",page:"general",titleKey:"settings.openchamber.tools.browserProvider.label",descriptionKey:"settings.openchamber.tools.browserProvider.info",keywords:["agent","browser","provider","extension","chrome","server","headless"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-notify-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentNotifyTool",descriptionKey:"settings.openchamber.tools.field.agentNotifyToolInfo",keywords:["agent","tool","notify","notification","alert","ping","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-render-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentRenderTool",descriptionKey:"settings.openchamber.tools.field.agentRenderToolInfo",keywords:["agent","tool","render","page","html","chart","table","diagram","generative","ui","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-knowledge-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentKnowledgeTool",descriptionKey:"settings.openchamber.tools.field.agentKnowledgeToolInfo",keywords:["agent","tool","project","knowledge","notes","todos","plans","openchamber"],isAvailable:t=>!t.isVSCode},{id:"general.isolated-spaces",page:"isolated-spaces",titleKey:"settings.openchamber.spaces.field.enabled",descriptionKey:"settings.openchamber.spaces.field.enabledInfo",keywords:["isolated","space","spaces","container","docker","sandbox","agent"],isAvailable:t=>!t.isVSCode&&Af()},{id:"general.isolated-spaces-idle-stop",page:"isolated-spaces",titleKey:"settings.openchamber.spaces.idleStop.enabled",descriptionKey:"settings.openchamber.spaces.idleStop.enabledInfo",keywords:["idle","stop","space","spaces","container","hours","timeout","sleep"],isAvailable:t=>!t.isVSCode&&re.getState().isolatedSpacesEnabled},{id:"general.isolated-spaces-machine",page:"isolated-spaces",titleKey:"settings.openchamber.spaces.places.machine.label",descriptionKey:"settings.openchamber.spaces.places.machine.info",keywords:["machine","ssh","remote","docker","space","spaces","host","server"],isAvailable:t=>!t.isVSCode&&re.getState().isolatedSpacesEnabled},{id:"sessions.agent-memory-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentMemoryTool",descriptionKey:"settings.openchamber.tools.field.agentMemoryToolInfo",keywords:["agent","tool","memory","remember","recall","preferences","openchamber"],isAvailable:t=>!t.isVSCode&&re.getState().agentMemoryFeatureAvailable},{id:"git.gitlab-account",page:"integrations",titleKey:"settings.gitlab.title",descriptionKey:"settings.gitlab.info",keywords:["gitlab","account","oauth","pat","merge request","issues","glab"],isAvailable:t=>!t.isVSCode},{id:"git.gitlab-connect",page:"integrations",titleKey:"settings.gitlab.actions.connect",keywords:["gitlab","connect","add account","oauth","pat","token","instance"],isAvailable:t=>!t.isVSCode},{id:"routing.token",page:"routing",titleKey:"settings.routing.token.label",descriptionKey:"settings.routing.token.info",keywords:["jev","typesafe","api key","token","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable},{id:"sessions.agent-tools-code-mode",page:"general",titleKey:"settings.openchamber.tools.field.agentToolsCodeMode",descriptionKey:"settings.openchamber.tools.field.agentToolsCodeModeInfo",keywords:["agent","tool","code mode","codemode","execute","openchamber"],isAvailable:t=>!t.isVSCode},{id:"routing.enabled",page:"routing",titleKey:"settings.routing.auto.enable",descriptionKey:"settings.routing.auto.enableInfo",keywords:["auto","routing","model","jev","automatic"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"routing.preserve-cache",page:"routing",titleKey:"settings.routing.auto.preserveCache",descriptionKey:"settings.routing.auto.preserveCacheInfo",keywords:["cache","prompt cache","auto","routing","switch","model","cost"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"routing.fallback-model",page:"routing",titleKey:"settings.routing.auto.fallbackModel",descriptionKey:"settings.routing.auto.fallbackModelInfo",keywords:["fallback","default","model","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"routing.add-category",page:"routing",titleKey:"settings.routing.categories.title",descriptionKey:"settings.routing.categories.description",keywords:["category","categories","task type","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"git.identities",page:"git",titleKey:"settings.gitIdentities.page.section.title",descriptionKey:"settings.gitIdentities.page.empty.description",keywords:["identity","profile","author","email","credentials","account","transport","ssh","ssh key","signing","commit signing","ssh signing","gpg"]},{id:"git.changes-view",page:"git",titleKey:"settings.openchamber.git.changesViewTitle",keywords:["changes","flat list","tree view"]},{id:"git.gitmoji",page:"git",titleKey:"settings.openchamber.git.enableGitmoji",keywords:["commit","emoji"]},{id:"git.gitignored-files",page:"git",titleKey:"settings.openchamber.git.showGitignored",keywords:["ignored","files","gitignore"]},{id:"usage.work-status-panel",page:"usage",titleKey:"settings.usage.page.options.showInWorkStatus",descriptionKey:"settings.usage.page.options.showInWorkStatusTooltip",keywords:["quota","work","status","panel"]},{id:"usage.model-quotas",page:"usage",titleKey:"settings.usage.page.section.modelQuotas",keywords:["models","quota","limits","tokens"]},{id:"projects.name",page:"projects",titleKey:"settings.projects.page.field.projectName",keywords:["label","display name","project metadata"]},{id:"projects.default-agent",page:"projects",titleKey:"settings.projects.page.field.projectAgent",keywords:["agent","default","new chat","project metadata"]},{id:"projects.default-model",page:"projects",titleKey:"settings.projects.page.field.projectModel",keywords:["model","default","new chat","project metadata"]},{id:"projects.default-thinking",page:"projects",titleKey:"settings.projects.page.field.projectThinking",keywords:["thinking","variant","reasoning","effort","model","project metadata"]},{id:"projects.icon",page:"projects",titleKey:"settings.projects.page.field.projectIcon",keywords:["icon","favicon","upload","color","accent color","appearance","project metadata"]},{id:"projects.close",page:"projects",titleKey:"settings.projects.page.actions.closeProject",keywords:["close","remove","delete","forget","project"],isAvailable:t=>!t.isVSCode},{id:"projects.actions",page:"projects",titleKey:"settings.projects.actions.title",descriptionKey:"settings.projects.actions.info",keywords:["run","run button","commands","dev server","scripts","project actions"]},{id:"projects.worktree",page:"projects",titleKey:"settings.projects.page.section.worktree",keywords:["worktree","branch","repository"]},{id:"projects.worktree.setup.wait",page:"projects",titleKey:"settings.openchamber.worktrees.setup.waitForCommands",keywords:["worktree","setup commands","bootstrap","wait"]},{id:"projects.worktree.setup.replace",page:"projects",titleKey:"settings.projects.shared.replaceMode",keywords:["worktree","setup commands","shared","team","only mine"]},{id:"projects.environment",page:"projects",titleKey:"settings.projects.environment.title",descriptionKey:"settings.projects.environment.info",keywords:["environment","env","variables","direnv","devenv","nix","envrc","path","terminal","git hooks"],isAvailable:t=>!t.isVSCode},{id:"projects.shared",page:"projects",titleKey:"settings.projects.team.title",descriptionKey:"settings.projects.team.info",keywords:["shared","team","repository",".openchamber","project.json","trust"]},{id:"projects.shared.plansDir",page:"projects",titleKey:"settings.projects.shared.plansDir",descriptionKey:"settings.projects.shared.plansDirInfo",keywords:["plans","folder","shared","team","docs"]},{id:"remote-instances.client-auth",page:"remote-instances",titleKey:"settings.remoteInstances.clientAuth.title",descriptionKey:"settings.remoteInstances.clientAuth.description",keywords:["pairing link","client token","connect desktop","remote access","relay","devices","connect from anywhere"],isAvailable:t=>!t.isVSCode},{id:"remote-instances.direct-hosts",page:"remote-instances",titleKey:"settings.remoteInstances.direct.title",descriptionKey:"settings.remoteInstances.direct.description",keywords:["server url","connection token","import link","host switcher","additional headers","request headers","cloudflare access","service token"],isAvailable:t=>t.isDesktop},{id:"behavior.system-prompt",page:"behavior",titleKey:"settings.behavior.page.section.systemPrompt",descriptionKey:"settings.behavior.page.warning.title",keywords:["agents.md","global instructions","system prompt"]},{id:"behavior.response-style",page:"behavior",titleKey:"settings.behavior.page.section.responseStyle",descriptionKey:"settings.behavior.page.responseStyle.tooltip",keywords:["tone","concise","detailed","custom instructions"]},{id:"agents.create",page:"agents",titleKey:"settings.agents.page.title.new",keywords:["create","add","new agent"]},{id:"agents.name",page:"agents",titleKey:"settings.agents.page.field.agentName",keywords:["agent","name"]},{id:"agents.mode",page:"agents",titleKey:"settings.agents.page.field.mode",descriptionKey:"settings.agents.page.field.modeTooltip",keywords:["primary","subagent","visibility"]},{id:"agents.color",page:"agents",titleKey:"settings.agents.page.field.color",descriptionKey:"settings.agents.page.field.colorTooltip",keywords:["colour","hex","accent"]},{id:"agents.model",page:"agents",titleKey:"settings.agents.page.field.overrideModel",keywords:["model","provider"]},{id:"agents.variant",page:"agents",titleKey:"settings.agents.page.field.variant",descriptionKey:"settings.agents.page.field.variantTooltip",keywords:["thinking","reasoning","variant","depth"]},{id:"agents.temperature",page:"agents",titleKey:"settings.agents.page.field.temperature",descriptionKey:"settings.agents.page.field.temperatureTooltip",keywords:["randomness","creative"]},{id:"agents.top-p",page:"agents",titleKey:"settings.agents.page.field.topP",descriptionKey:"settings.agents.page.field.topPTooltip",keywords:["sampling","nucleus"]},{id:"agents.system-prompt",page:"agents",titleKey:"settings.agents.page.section.systemPrompt",keywords:["prompt","instructions"]},{id:"agents.steps",page:"agents",titleKey:"settings.agents.page.field.steps",descriptionKey:"settings.agents.page.field.stepsTooltip",keywords:["steps","loop","tool calls"]},{id:"agents.permissions",page:"agents",titleKey:"settings.agents.page.section.toolPermissions",keywords:["tools","permissions","rules","allow","ask","deny"]},{id:"commands.create",page:"commands",titleKey:"settings.commands.page.title.new",keywords:["create","add","new command"]},{id:"commands.name",page:"commands",titleKey:"settings.commands.page.field.commandName",keywords:["slash command","name"]},{id:"commands.agent",page:"commands",titleKey:"settings.commands.page.field.overrideAgent",keywords:["agent","execution"]},{id:"commands.model",page:"commands",titleKey:"settings.agents.page.field.overrideModel",keywords:["model","provider"]},{id:"commands.variant",page:"commands",titleKey:"settings.agents.page.field.variant",keywords:["variant","reasoning","thinking"]},{id:"commands.subagent",page:"commands",titleKey:"settings.commands.page.field.subagent",descriptionKey:"settings.commands.page.field.subagentTooltip",keywords:["subagent","background","child session"]},{id:"commands.template",page:"commands",titleKey:"settings.commands.page.section.template",keywords:["prompt","template","arguments","shell","file"]},{id:"mcp.create",page:"mcp",titleKey:"settings.mcp.sidebar.actions.addServerTitle",keywords:["create","add","server"]},{id:"mcp.server",page:"mcp",titleKey:"settings.mcp.page.server.title",keywords:["server","name","transport"]},{id:"mcp.command",page:"mcp",titleKey:"settings.mcp.page.connection.command",keywords:["stdio","local","command"]},{id:"mcp.environment",page:"mcp",titleKey:"settings.mcp.page.env.title",keywords:["env","variables","api key"]},{id:"mcp.advanced",page:"mcp",titleKey:"settings.mcp.page.advanced.title",keywords:["oauth","headers","timeout","code mode","codemode"]},{id:"plugins.create",page:"plugins",titleKey:"settings.plugins.sidebar.actions.addTitle",keywords:["add","plugin","npm","path","file"]},{id:"plugins.spec",page:"plugins",titleKey:"settings.plugins.page.field.spec",keywords:["npm","package","path"]},{id:"plugins.options",page:"plugins",titleKey:"settings.plugins.page.field.options",keywords:["json","configuration"]},{id:"plugins.content",page:"plugins",titleKey:"settings.plugins.page.field.content",keywords:["file","code"]},{id:"snippets.create",page:"snippets",titleKey:"settings.snippets.sidebar.actions.create",keywords:["add","new snippet"]},{id:"snippets.content",page:"snippets",titleKey:"settings.snippets.page.field.content",keywords:["markdown","prompt","template"]},{id:"providers.connect",page:"providers",titleKey:"settings.providers.page.connect.title",keywords:["add provider","connect provider","credentials"]},{id:"providers.classification",page:"providers",titleKey:"settings.classification.page.title",descriptionKey:"settings.classification.page.description",keywords:["jev","typesafe","zen","api key","token","safety net","auto","routing","classification","promotion","off","disable","privacy","custom endpoint","base url","openai-compatible","system one","self-hosted","proxy"],isAvailable:t=>!t.isVSCode&&t.routingAvailable},{id:"providers.custom",page:"providers",titleKey:"settings.providers.page.custom.title",descriptionKey:"settings.providers.page.custom.description",keywords:["other","custom","openai-compatible","base url","api key"]},{id:"providers.auth",page:"providers",titleKey:"settings.providers.accounts.title",keywords:["api key","oauth","credentials","accounts","switch account","disconnect"]},{id:"providers.models",page:"providers",titleKey:"settings.providers.page.models.title",keywords:["models","hide","show"]},{id:"web-search.provider",page:"web-search",titleKey:"settings.webSearch.section.provider",descriptionKey:"settings.webSearch.section.providerInfo",keywords:["web search","websearch","internet","default provider","disable","off","random"]},{id:"web-search.providers",page:"web-search",titleKey:"settings.webSearch.section.providers",descriptionKey:"settings.webSearch.section.providersInfo",keywords:["api key","exa","tavily","firecrawl","parallel","tinyfish","searxng","brave","kagi","perplexity","linkup","serper","credentials"]},{id:"skills.create",page:"skills.installed",titleKey:"settings.skills.page.title.newSkill",keywords:["create","add","new skill"]},{id:"skills.basic-information",page:"skills.installed",titleKey:"settings.skills.page.section.basicInformation",keywords:["name","location","description","manual","invocation","autoinvoke"]},{id:"skills.instructions",page:"skills.installed",titleKey:"settings.skills.page.section.instructions",keywords:["markdown","skill.md","content"]},{id:"skills.supporting-files",page:"skills.installed",titleKey:"settings.skills.page.section.supportingFiles",keywords:["files","resources"]},{id:"skills.catalog.source",page:"skills.catalog",titleKey:"settings.skills.catalog.page.section.sourceRepository",keywords:["catalog","repository","source","refresh"]},{id:"skills.catalog.search",page:"skills.catalog",titleKey:"settings.skills.catalog.shared.field.searchSkillsPlaceholder",keywords:["find skills","install skills","catalog search"]},{id:"skills.catalog.add-catalog",page:"skills.catalog",titleKey:"settings.skills.catalog.page.actions.addCatalog",keywords:["external repository","add source","catalog"]},{id:"magic-prompts.visible-prompt",page:"magic-prompts",titleKey:"settings.magicPrompts.page.block.visiblePrompt",keywords:["prompt text","user message","template"],isAvailable:t=>!t.isVSCode},{id:"magic-prompts.instructions",page:"magic-prompts",titleKey:"settings.magicPrompts.page.block.instructions",keywords:["hidden prompt","instructions","template"],isAvailable:t=>!t.isVSCode},{id:"magic-prompts.reset-overrides",page:"magic-prompts",titleKey:"settings.magicPrompts.page.actions.resetAllOverrides",keywords:["reset","default prompts","overrides"],isAvailable:t=>!t.isVSCode},{id:"shortcuts.keyboard-shortcuts",page:"shortcuts",titleKey:"settings.openchamber.keyboardShortcuts.title",descriptionKey:"settings.openchamber.keyboardShortcuts.tooltip",keywords:["keyboard","hotkeys","bindings"]},...Wo().filter(t=>t.category!=="desktop").map(t=>({id:lm(t.id),page:"shortcuts",titleKey:t.settingsLabelKey,keywords:["shortcut","hotkey","keyboard","keybinding"]})),{id:"voice.playback",page:"voice",titleKey:"settings.voice.page.section.playbackAndSummary",keywords:["tts","read aloud","voice","provider","speech rate","speech pitch","speech volume","tts input mode","markdown"]},{id:"voice.speech-recognition",page:"voice",titleKey:"settings.voice.page.section.speechRecognition",keywords:["stt","dictation","voice input","transcribe","whisper","parakeet","microphone"]},{id:"tunnel.provider",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.provider",descriptionKey:"settings.openchamber.tunnel.description",keywords:["remote access","cloudflare","ngrok"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.type",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.tunnelType",keywords:["quick","managed remote","managed local"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.ttl",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.connectLinkTtl",descriptionKey:"settings.openchamber.tunnel.field.tunnelSessionTtl",keywords:["expiry","expiration","session ttl","connect link ttl"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.managed-remote",page:"tunnel",titleKey:"settings.openchamber.tunnel.section.savedManagedRemoteTunnels",keywords:["cloudflare","hostname","token","managed remote"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.managed-local-config",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.configurationFile",descriptionKey:"settings.openchamber.tunnel.note.managedLocalUsesConfig",keywords:["cloudflared","config","yaml","json","managed local"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.start",page:"tunnel",titleKey:"settings.openchamber.tunnel.actions.startTunnel",descriptionKey:"settings.openchamber.tunnel.note.connectLinksOneTime",keywords:["connect link","qr code","public url","remote access"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"notifications.delivery",page:"notifications",titleKey:"settings.notifications.page.delivery.title",keywords:["desktop notifications","system notifications"]},{id:"notifications.events",page:"notifications",titleKey:"settings.notifications.page.events.title",keywords:["completion","subtasks","errors","questions"]},{id:"notifications.push",page:"notifications",titleKey:"settings.notifications.page.push.title",keywords:["background","push"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"integrations.first-party",page:"integrations",titleKey:"settings.integrations.firstParty.title",descriptionKey:"settings.integrations.firstParty.info",keywords:["built-in","first-party","native","github","linear"],isAvailable:t=>!t.isVSCode},{id:"integrations.github",page:"integrations",titleKey:"settings.integrations.github.title",descriptionKey:"settings.integrations.github.description",keywords:["github","account","oauth","gh","cli","prs","pull request","issues","connect"],isAvailable:t=>!t.isVSCode},{id:"git.github-connect",page:"integrations",titleKey:"settings.github.page.actions.connect",keywords:["github","connect","add account","oauth","device flow"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear",page:"integrations",titleKey:"settings.integrations.linear.title",descriptionKey:"settings.integrations.linear.description",keywords:["linear","issues","oauth","connect","workspace"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear.add-workspace",page:"integrations",titleKey:"settings.integrations.linear.actions.addWorkspace",descriptionKey:"settings.integrations.linear.description",keywords:["linear","workspace","add","connect","oauth"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear.mapping",page:"integrations",titleKey:"settings.integrations.linear.mapping.defaultProject",descriptionKey:"settings.integrations.linear.mapping.defaultProject.info",keywords:["linear","project","team","map","workspace","directory"],isAvailable:t=>!t.isVSCode},{id:"integrations.third-party",page:"integrations",titleKey:"settings.integrations.thirdParty.title",descriptionKey:"settings.integrations.thirdParty.info",keywords:["plugin","provider","install","update","remove","subscription"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"integrations.third-party.opencode-claude",page:"integrations",titleKey:"settings.integrations.thirdParty.opencodeClaude.name",descriptionKey:"settings.integrations.thirdParty.opencodeClaude.description",keywords:["claude","anthropic","claude code","pro","max","agent sdk","@openchamber/opencode-claude"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"integrations.extensions",page:"integrations",titleKey:"settings.integrations.extensionCatalog.title",descriptionKey:"settings.integrations.extensionCatalog.info",keywords:["extension","install","update","remove","openchamber"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"integrations.extensions.excalidraw",page:"integrations",titleKey:"settings.integrations.extensionCatalog.excalidraw.name",descriptionKey:"settings.integrations.extensionCatalog.excalidraw.description",keywords:["excalidraw","drawing","diagram","canvas","whiteboard","obsidian","sketch"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"integrations.extensions.resource-monitor",page:"integrations",titleKey:"settings.integrations.extensionCatalog.resourceMonitor.name",descriptionKey:"settings.integrations.extensionCatalog.resourceMonitor.description",keywords:["resource","monitor","cpu","memory","ram","process","activity","task manager","dev server","port","performance"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"integrations.guests",page:"integrations",titleKey:"settings.integrations.guests.title",descriptionKey:"settings.integrations.guests.info",keywords:["guest","extension","oauth","clickup","gitlab","panel","connect"],isAvailable:t=>!t.isVSCode},{id:"extensions.add",page:"extensions",titleKey:"settings.extensions.add.label",descriptionKey:"settings.extensions.add.info",keywords:["folder","path","zip","git","url","install","guest","panel"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"extensions.gitIdentity",page:"extensions",titleKey:"settings.extensions.identity.title",descriptionKey:"settings.extensions.add.info",keywords:["ssh","key","identity","git","private","clone","extension"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"extensions.updates.check",page:"extensions",titleKey:"settings.extensions.updates.check",keywords:["update","upgrade","version","git","extension","guest","refresh"],isAvailable:t=>!t.isVSCode&&!t.isMobile}];function Id(t){return t.trim().toLocaleLowerCase()}function kN({query:t,runtimeCtx:e,visiblePageSlugs:a,t:n,getPageTitle:i}){const o=Id(t);if(!o)return[];const r=a?new Set(a):null,c=o.split(/\s+/).filter(Boolean);return jN.flatMap(u=>{if(r&&!r.has(u.page))return[];const d=Ga(u.page);if(!d||d.isAvailable&&!d.isAvailable(e)||u.isAvailable&&!u.isAvailable(e))return[];const l=n(u.titleKey),f=u.descriptionKey?n(u.descriptionKey):null,p=Id([l,f,i(u.page),...u.keywords??[]].filter(Boolean).join(" "));return c.every(g=>p.includes(g))?[{...u,title:l,description:f,pageTitle:i(u.page)}]:[]})}const wN=["session","models","panels","navigation","application"],SN=()=>{const t=De.c(34),{t:e}=Ee(),a=re(NN),n=re(CN),i=re(IN),o=re(PN),[r,c]=m.useState(null),[u,d]=m.useState(null);let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{ou().then(T=>d(T?.combo??null)).catch(AN)},t[0]=l):l=t[0];const f=l;let p,g;t[1]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{f()},g=[f],t[1]=p,t[2]=g):(p=t[1],g=t[2]),m.useEffect(p,g);const[h,y]=m.useState(null);let b;t[3]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{iu().then(T=>y(T?.combo??null)).catch(TN)},t[3]=b):b=t[3];const x=b;let w,S;t[4]===Symbol.for("react.memo_cache_sentinel")?(w=()=>{x()},S=[x],t[4]=w,t[5]=S):(w=t[4],S=t[5]),m.useEffect(w,S);let v;t[6]===Symbol.for("react.memo_cache_sentinel")?(v=Wo(),t[6]=v):v=t[6];const A=v,I=EN;let N;t[7]!==n||t[8]!==a?(N=(T,R,$)=>{const z={...a,[T]:R};n(T,R),$==="mini_chat_global"?Or(null).then(Q=>{Q&&d(Q.combo)}):$==="quake_mode_global"?Rr(_n).then(Q=>{Q&&y(Q.combo)}):$&&(z[$]=_n,n($,_n)),I(z)},t[7]=n,t[8]=a,t[9]=N):N=t[9];const k=N;let P;t[10]!==i||t[11]!==a?(P=T=>{const R={...a};delete R[T],i(T),I(R)},t[10]=i,t[11]=a,t[12]=P):P=t[12];const j=P;let C;t[13]!==a||t[14]!==e?(C=T=>{const R="prefixStyle"in T&&T.prefixStyle,$=R?dg(T.id,a):Jd(T.id,a),z=Hn($,e("settings.openchamber.keyboardShortcuts.unassigned"));if(!R||!$||$===_n)return z;const Q=T.id==="switch_session_tab"?e("settings.openchamber.keyboardShortcuts.action.switch_session_tab.suffix"):e("settings.openchamber.keyboardShortcuts.action.switch_context_surface.suffix");return`${z}${Q}`},t[13]=a,t[14]=e,t[15]=C):C=t[15];const E=C;let F;t[16]!==u||t[17]!==h||t[18]!==a?(F={...a},u&&(F.mini_chat_global=u),h&&(F.quake_mode_global=h),t[16]=u,t[17]=h,t[18]=a,t[19]=F):F=t[19];let O;t[20]!==o||t[21]!==j||t[22]!==E||t[23]!==a||t[24]!==e?(O=wN.map((T,R)=>{const $=A.filter(z=>z.category===T);return $.length===0?null:s.jsx($e,{settingsItem:R===0?"shortcuts.keyboard-shortcuts":void 0,title:e(`settings.openchamber.keyboardShortcuts.category.${T}`),divider:R!==0,info:R===0?e("settings.openchamber.keyboardShortcuts.tooltip"):void 0,headerAction:R===0?s.jsx(H,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{o(),I({})},children:e("settings.openchamber.keyboardShortcuts.actions.resetAll")}):void 0,children:s.jsx("div",{children:$.map(z=>s.jsxs(st,{label:e(z.settingsLabelKey),settingsItem:lm(z.id),children:[s.jsx("kbd",{className:"min-w-32 oc-tile-inset rounded-md px-2 py-1 text-center typography-meta text-foreground",children:E(z)}),s.jsx(H,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",onClick:()=>{f(),x(),c(z)},children:e("settings.openchamber.keyboardShortcuts.actions.edit")}),z.id in a?s.jsx(H,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>j(z.id),children:e("settings.common.actions.reset")}):null]},z.id))})},T)}),t[20]=o,t[21]=j,t[22]=E,t[23]=a,t[24]=e,t[25]=O):O=t[25];let K;t[26]===Symbol.for("react.memo_cache_sentinel")?(K=T=>{T||c(null)},t[26]=K):K=t[26];let D;t[27]!==r||t[28]!==F||t[29]!==k?(D=s.jsx(Cl,{action:r,overrides:F,onSave:k,onOpenChange:K}),t[27]=r,t[28]=F,t[29]=k,t[30]=D):D=t[30];let M;return t[31]!==O||t[32]!==D?(M=s.jsxs(s.Fragment,{children:[O,D]}),t[31]=O,t[32]=D,t[33]=M):M=t[33],M};function NN(t){return t.shortcutOverrides}function CN(t){return t.setShortcutOverride}function IN(t){return t.clearShortcutOverride}function PN(t){return t.resetAllShortcutOverrides}function AN(){}function TN(){}function EN(t){jt({shortcutOverrides:t})}const cm=()=>{const t=De.c(2),[e,a]=m.useState(0);let n,i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>Go(()=>a(BN)),i=[],t[0]=n,t[1]=i):(n=t[0],i=t[1]),m.useEffect(n,i),e},MN=t=>{const e=De.c(68),{section:a}=t,{t:n}=Ee(),i=cm();let o;e[0]!==i||e[1]!==a?(o=()=>{switch(a){case"general":return s.jsx(RN,{});case"visual":return s.jsx(ON,{});case"chat":return s.jsx(FN,{});case"sessions":return s.jsx(LN,{runtimeEndpointEpoch:i});case"shortcuts":return s.jsx(DN,{});case"git":return s.jsx(KN,{});case"notifications":return s.jsx(_N,{});case"voice":return s.jsx($N,{});case"tunnel":return s.jsx(UN,{});case"spaces":return s.jsx(zN,{});default:return null}},e[0]=i,e[1]=a,e[2]=o):o=e[2];const r=o;let c;e[3]!==n?(c=n("settings.page.general.title"),e[3]=n,e[4]=c):c=e[4];let u;e[5]!==n?(u=n("settings.page.appearance.title"),e[5]=n,e[6]=u):u=e[6];let d;e[7]!==n?(d=n("settings.page.chat.title"),e[7]=n,e[8]=d):d=e[8];let l;e[9]!==n?(l=n("settings.page.sessions.title"),e[9]=n,e[10]=l):l=e[10];let f;e[11]!==n?(f=n("settings.page.shortcuts.title"),e[11]=n,e[12]=f):f=e[12];let p;e[13]!==n?(p=n("settings.page.git.title"),e[13]=n,e[14]=p):p=e[14];let g;e[15]!==n?(g=n("settings.page.git.title"),e[15]=n,e[16]=g):g=e[16];let h;e[17]!==n?(h=n("settings.page.notifications.title"),e[17]=n,e[18]=h):h=e[18];let y;e[19]!==n?(y=n("settings.page.voice.title"),e[19]=n,e[20]=y):y=e[20];let b;e[21]!==n?(b=n("settings.page.tunnel.title"),e[21]=n,e[22]=b):b=e[22];let x;e[23]!==n?(x=n("settings.openchamber.spaces.title"),e[23]=n,e[24]=x):x=e[24];let w;e[25]!==y||e[26]!==b||e[27]!==x||e[28]!==c||e[29]!==u||e[30]!==d||e[31]!==l||e[32]!==f||e[33]!==p||e[34]!==g||e[35]!==h?(w={general:c,visual:u,chat:d,sessions:l,shortcuts:f,git:p,github:g,notifications:h,voice:y,tunnel:b,spaces:x},e[25]=y,e[26]=b,e[27]=x,e[28]=c,e[29]=u,e[30]=d,e[31]=l,e[32]=f,e[33]=p,e[34]=g,e[35]=h,e[36]=w):w=e[36];const S=w[a];let v;e[37]!==n?(v=n("settings.page.general.description"),e[37]=n,e[38]=v):v=e[38];let A;e[39]!==n?(A=n("settings.page.appearance.description"),e[39]=n,e[40]=A):A=e[40];let I;e[41]!==n?(I=n("settings.page.chat.description"),e[41]=n,e[42]=I):I=e[42];let N;e[43]!==n?(N=n("settings.page.sessions.description"),e[43]=n,e[44]=N):N=e[44];let k;e[45]!==n?(k=n("settings.page.shortcuts.description"),e[45]=n,e[46]=k):k=e[46];let P;e[47]!==n?(P=n("settings.page.notifications.description"),e[47]=n,e[48]=P):P=e[48];let j;e[49]!==n?(j=n("settings.page.voice.description"),e[49]=n,e[50]=j):j=e[50];let C;e[51]!==n?(C=n("settings.page.tunnel.description"),e[51]=n,e[52]=C):C=e[52];let E;e[53]!==v||e[54]!==A||e[55]!==I||e[56]!==N||e[57]!==k||e[58]!==P||e[59]!==j||e[60]!==C?(E={general:v,visual:A,chat:I,sessions:N,shortcuts:k,git:void 0,github:void 0,notifications:P,voice:j,tunnel:C,spaces:void 0},e[53]=v,e[54]=A,e[55]=I,e[56]=N,e[57]=k,e[58]=P,e[59]=j,e[60]=C,e[61]=E):E=e[61];const F=E[a];let O;e[62]!==r?(O=r(),e[62]=r,e[63]=O):O=e[63];let K;return e[64]!==F||e[65]!==S||e[66]!==O?(K=s.jsx(qt,{title:S,description:F,showSaveStatus:!0,className:"openchamber-page-body",children:O}),e[64]=F,e[65]=S,e[66]=O,e[67]=K):K=e[67],K},DN=()=>{const t=De.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(SN,{}),t[0]=e):e=t[0],e},RN=()=>{const t=De.c(15);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=os(),t[0]=e):e=t[0];const a=e,n=cm();let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i=is()&&ri(),t[1]=i):i=t[1];const o=i;let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=Di()&&!is()&&!a&&!Qd(),t[2]=r):r=t[2];const c=r;let u,d,l,f,p,g;t[3]===Symbol.for("react.memo_cache_sentinel")?(u=o&&s.jsx(L3,{}),d=s.jsx(KS,{firstSection:!o}),l=o&&s.jsx(x3,{}),f=c&&s.jsx(Ik,{}),p=s.jsx(Pk,{}),g=!a&&s.jsx(dw,{}),t[3]=u,t[4]=d,t[5]=l,t[6]=f,t[7]=p,t[8]=g):(u=t[3],d=t[4],l=t[5],f=t[6],p=t[7],g=t[8]);let h;t[9]!==n?(h=!a&&s.jsx(uw,{},n),t[9]=n,t[10]=h):h=t[10];let y,b;t[11]===Symbol.for("react.memo_cache_sentinel")?(y=!a&&s.jsx(Gw,{}),b=s.jsx(_S,{}),t[11]=y,t[12]=b):(y=t[11],b=t[12]);let x;return t[13]!==h?(x=s.jsxs(s.Fragment,{children:[u,d,l,f,p,g,h,y,b]}),t[13]=h,t[14]=x):x=t[14],x},ON=()=>{const t=De.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=os(),t[0]=e):e=t[0];const a=e;let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(rk,{visibleSettings:["theme","windowControlsPosition","pwaInstallName","pwaOrientation","mobileKeyboardMode","timeFormat",...a?[]:["weekStart"],"fontSize","terminalFontSize","editorFontSize","spacing","scrollbars","inputBarOffset","animatedActivityIndicators"]}),t[1]=n):n=t[1],n},FN=()=>{const t=De.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(d0,{}),t[0]=e):e=t[0],e},LN=t=>{const e=De.c(7),{runtimeEndpointEpoch:a}=t;let n;e[0]!==a?(n=s.jsx(zk,{},a),e[0]=a,e[1]=n):n=e[1];let i,o,r;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(kk,{}),o=s.jsx(uk,{}),r=!os()&&s.jsx(vk,{}),e[2]=i,e[3]=o,e[4]=r):(i=e[2],o=e[3],r=e[4]);let c;return e[5]!==n?(c=s.jsxs(s.Fragment,{children:[n,i,o,r]}),e[5]=n,e[6]=c):c=e[6],c},KN=()=>{const t=De.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(_u,{}),t[0]=e):e=t[0],e},_N=()=>{const t=De.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Bk,{}),t[0]=e):e=t[0],e},$N=()=>{const t=De.c(1);if(os())return null;let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Zk,{}),t[0]=e):e=t[0],e},zN=()=>{const t=De.c(1);if(os())return null;let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Bw,{}),t[0]=e):e=t[0],e},UN=()=>{const t=De.c(1);if(os())return null;let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(cw,{}),t[0]=e):e=t[0],e};function BN(t){return t+1}const Pd=280,VN=32,dm="__openchamberSettingsDetail",Ad=t=>{const e=kh(t);e&&zr.getState().setTab(e)},HN=30,qN=["general","appearance","chat","notifications","sessions","routing","shortcuts","voice","integrations","extensions","usage","about","projects","remote-instances","tunnel","git","isolated-spaces","providers","web-search","agents","behavior","commands","mcp","plugins","magic-prompts","snippets","skills.installed","skills.catalog"],WN=["general","projects","opencode","content"];function GN(t,e,a,n,i){const o=os(),r=!t&&Di();return{isVSCode:o,isWeb:r,isDesktop:t,isMobile:e,routingAvailable:a,enterpriseMode:n,jevBlockedByEnterprise:i}}function Td(t,e){return t.isAvailable?t.isAvailable(e):!0}function Ni(t,e){const a=new Set(e);let n=t,i=1;for(;a.has(n);)n=`${t}-${i}`,i+=1;return n}function Er(t){const e=t?.[dm];return e?.page==null||e.stage!=="page-content"?null:{page:Fr(e.page),stage:e.stage}}function JN(){return window.history.state??{}}const hC=({onClose:t,forceMobile:e,isWindowed:a,visiblePageSlugs:n,initialMobileStage:i="nav",registerBackHandler:o})=>{const{t:r}=Ee(),c=Zs(),u=e??c.isMobile,d=re(ce=>ce.settingsPage),l=re(ce=>ce.isSettingsDialogOpen),f=re(ce=>ce.setSettingsPage),p=re(ce=>ce.shortcutOverrides.open_settings),g=Fr(d),[h,y]=m.useState(i),b=m.useRef(i==="nav"?g:null);m.useEffect(()=>{!u&&g==="home"&&f("general")},[u,f,g]);const[x,w]=m.useState(""),[S,v]=m.useState(null),[A,I]=m.useState(0),N=m.useRef(null),k=m.useRef(!1),P=m.useRef([]),j=m.useRef(0),C=m.useRef(!1),E=m.useMemo(()=>is(),[]),F=m.useMemo(()=>is()&&ri(),[]),O=m.useMemo(()=>is()&&window.__OPENCHAMBER_PLATFORM__==="darwin",[]),K=m.useMemo(()=>is()&&window.__OPENCHAMBER_PLATFORM__==="win32",[]),D=m.useMemo(()=>is()&&window.__OPENCHAMBER_PLATFORM__==="linux",[]),M=re(ce=>ce.routingFeatureAvailable),T=Pn(),R=ug(),$=m.useMemo(()=>GN(E,u,M,T,R),[E,u,M,T,R]),z=m.useMemo(()=>{const ce=n?new Set(n):null;return Tf.filter(je=>je.slug!=="home").filter(je=>!ce||ce.has(je.slug)).filter(je=>Td(je,$)).filter(je=>!($.isVSCode&&je.slug==="projects")).filter(je=>!(u&&je.slug==="shortcuts"))},[$,u,n]),Q=m.useMemo(()=>{const ce=new Map(qN.map((je,de)=>[je,de]));return z.slice().sort((je,de)=>(ce.get(je.slug)??999)-(ce.get(de.slug)??999))},[z]),V=on(ce=>ce.activeProjectId),L=Hs();m.useEffect(()=>{if(!(!l&&!$.isVSCode&&!a)){if(g==="agents"){Cn.getState().loadAgents(L);return}if(g==="commands"){ti.getState().loadCommands(L);return}if(g==="mcp"){$n.getState().loadMcpConfigs({directory:L});return}if(g==="plugins"){Lt.getState().loadPlugins();return}(g==="skills.installed"||g==="skills.catalog")&&(Js.getState().loadSkills(L),Nn.getState().loadCatalog()),g==="snippets"&&Ao.getState().loadSnippets()}},[V,l,a,$.isVSCode,L,g]);const B=m.useCallback(ce=>{if(f(ce),b.current=ce,!u)return;const je=Ga(ce);if(!je||je.slug==="home"){y("nav");return}y(je.kind==="split"?"page-sidebar":"page-content")},[u,f]),W=m.useMemo(()=>Ga(g),[g]),Y=m.useMemo(()=>({general:"general",appearance:"visual",chat:"chat",shortcuts:"shortcuts",sessions:"sessions",notifications:"notifications",voice:"voice",tunnel:"tunnel","isolated-spaces":"spaces"}),[]),ae=m.useCallback(ce=>{switch(ce){case"general":return r("settings.page.general.title");case"projects":return r("settings.page.projects.title");case"remote-instances":return r("settings.page.remoteInstances.title");case"providers":return r("settings.page.providers.title");case"web-search":return r("settings.page.webSearch.title");case"usage":return r("settings.page.usage.title");case"agents":return r("settings.page.agents.title");case"behavior":return r("settings.page.behavior.title");case"commands":return r("settings.page.commands.title");case"mcp":return r("settings.page.mcp.title");case"plugins":return r("settings.page.plugins.title");case"skills.installed":return r("settings.page.skills.title");case"skills.catalog":return r("settings.page.skillsCatalog.title");case"git":return r("settings.page.git.title");case"integrations":return r("settings.page.integrations.title");case"extensions":return r("settings.page.extensions.title");case"appearance":return r("settings.page.appearance.title");case"chat":return r("settings.page.chat.title");case"shortcuts":return r("settings.page.shortcuts.title");case"sessions":return r("settings.page.sessions.title");case"routing":return r("settings.page.routing.title");case"magic-prompts":return r("settings.page.magicPrompts.title");case"snippets":return r("settings.page.snippets.title");case"notifications":return r("settings.page.notifications.title");case"voice":return r("settings.page.voice.title");case"tunnel":return r("settings.page.tunnel.title");case"isolated-spaces":return r("settings.openchamber.spaces.title");case"about":return r("settings.page.about.title");default:return r("settings.view.home.title")}},[r]),ee=m.useMemo(()=>kN({query:x,runtimeCtx:{...$,isDesktopLocalOrigin:F,isMac:O,isWindows:K,isLinux:D},visiblePageSlugs:n,t:r,getPageTitle:ae}),[ae,F,O,K,D,$,x,r,n]),G=m.useCallback(ce=>{if(ce.id.startsWith("agents.")){const de=Cn.getState(),ie=Ni("new-agent",de.agents.map(xe=>xe.name));return de.setAgentDraft({name:ie,scope:"user"}),de.setSelectedAgent(ie),ce.id==="agents.create"?"agents.name":ce.id}if(ce.id.startsWith("commands.")){const de=ti.getState(),ie=Ni("new-command",de.commands.map(xe=>xe.name));return de.setCommandDraft({name:ie,scope:"user"}),de.setSelectedCommand(ie),ce.id==="commands.create"?"commands.name":ce.id}if(ce.id.startsWith("mcp.")){const de=$n.getState(),ie=Ni("new-mcp-server",de.mcpServers.map(xe=>xe.name));return de.setMcpDraft({name:ie,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),de.setSelectedMcp(ie),ce.id==="mcp.create"?"mcp.server":ce.id}if(ce.id.startsWith("snippets.")){const de=Ao.getState(),ie=Ni("new-snippet",de.snippets.map(xe=>xe.name));return de.setSnippetDraft({name:ie,scope:"global"}),de.setSelectedSnippet(ie),ce.id==="snippets.create"?"snippets.content":ce.id}if(ce.id.startsWith("skills.")){const de=Js.getState(),ie=Ni("new-skill",de.skills.map(xe=>xe.name));return de.setSkillDraft({name:ie,scope:"user",source:"opencode",description:"",instructions:""}),de.setSelectedSkill(ie),ce.id==="skills.create"?"skills.basic-information":ce.id}if(ce.id==="providers.connect"&&re.getState().setSettingsProvidersConnectRequested(!0),ce.id==="providers.classification"&&re.getState().setSettingsProvidersClassificationRequested(!0),ce.id==="plugins.create")return"plugins.spec";if(ce.id==="extensions.gitIdentity")return"extensions.add";const je=yh(ce.id);return je&&$r.getState().setTab(je),Ad(ce.id),ce.id},[]),le=m.useMemo(()=>{const ce=[],je=new Map;for(const de of ee){let ie=je.get(de.page);ie||(ie={page:de.page,pageTitle:de.pageTitle,results:[]},je.set(de.page,ie),ce.push(ie)),ie.results.push(de)}return ce},[ee]);m.useEffect(()=>{I(0),j.current=0,C.current=!1},[x]),m.useEffect(()=>{j.current=A},[A]),m.useEffect(()=>{P.current[A]?.scrollIntoView({block:"nearest"})},[A]),m.useEffect(()=>{A>=ee.length&&I(Math.max(0,ee.length-1)),P.current.length=ee.length},[A,ee.length]);const J=m.useCallback(ce=>{const je=G(ce);v(je),B(ce.page),u&&y("page-content"),ce.id==="plugins.create"&&window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("openchamber:settings-open-plugin-add"))},50)},[u,B,G]),me=m.useCallback(ce=>{if(x.trim()){if(ce.key==="Escape"){ce.preventDefault(),w("");return}if(ee.length!==0){if(ce.key==="ArrowDown"){ce.preventDefault(),C.current=!0,I(je=>(je+1)%ee.length);return}if(ce.key==="ArrowUp"){ce.preventDefault(),C.current=!0,I(je=>(je-1+ee.length)%ee.length);return}if(ce.key==="Enter"){ce.preventDefault();const je=(j.current%ee.length+ee.length)%ee.length,de=ee[je]??ee[0];de&&J(de)}}}},[J,x,ee]),fe=re(ce=>ce.settingsJumpRequest);m.useEffect(()=>{fe&&(re.getState().clearSettingsJumpRequest(),fe.itemId&&Ad(fe.itemId),v(fe.itemId),B(Fr(fe.page)),u&&y("page-content"))},[u,B,fe]),m.useEffect(()=>{const ce=S;if(!ce)return;let je=!1,de=0,ie=0;const xe=()=>{if(je)return;const Se=globalThis.CSS?.escape?globalThis.CSS.escape(ce):ce.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Le=N.current?.querySelector(`[data-settings-item="${Se}"]`);if(!Le){de+=1,de<HN&&(ie=window.requestAnimationFrame(xe));return}v(null),Le.scrollIntoView({block:"center",behavior:"smooth"}),Le.setAttribute("data-settings-search-highlight","true"),window.setTimeout(()=>{Le.removeAttribute("data-settings-search-highlight")},1600)};return ie=window.requestAnimationFrame(xe),()=>{je=!0,window.cancelAnimationFrame(ie)}},[S,g]);const oe=m.useCallback(()=>s.jsx("div",{className:"flex h-full items-center justify-center px-6",children:s.jsxs("div",{className:"max-w-md text-center",children:[s.jsx("div",{className:Wn,children:r("settings.view.unavailable.title")}),s.jsx("p",{className:"typography-ui text-muted-foreground mt-1",children:r("settings.view.unavailable.description")})]})}),[r]),pe=m.useCallback((ce,je)=>{switch(ce){case"projects":return s.jsx(_v,{onItemSelect:je.onItemSelect});case"agents":return s.jsx(Ph,{onItemSelect:je.onItemSelect});case"commands":return s.jsx(kb,{onItemSelect:je.onItemSelect});case"skills.installed":return s.jsx(Jx,{onItemSelect:je.onItemSelect});case"usage":return s.jsx(Fy,{onItemSelect:je.onItemSelect});case"magic-prompts":return s.jsx(a2,{onItemSelect:je.onItemSelect});case"snippets":return s.jsx(l2,{onItemSelect:je.onItemSelect});default:return null}},[]),se=m.useCallback(ce=>{const je=Ga(ce);if(je&&!Td(je,$))return oe();switch(ce){case"projects":return s.jsx(Vv,{});case"remote-instances":return s.jsx(j1,{});case"agents":return s.jsx(Zh,{});case"behavior":return s.jsx(ab,{});case"commands":return s.jsx(Ab,{});case"mcp":return s.jsx(Xb,{});case"plugins":return s.jsx(Ex,{});case"skills.installed":return s.jsx(vc,{view:"installed"});case"skills.catalog":return s.jsx(vc,{view:"catalog"});case"providers":return s.jsx(Ry,{});case"web-search":return s.jsx(ub,{});case"usage":return s.jsx(s2,{});case"about":return s.jsx(qt,{title:r("settings.page.about.title"),showSaveStatus:!1,children:s.jsx(gh,{})});case"magic-prompts":return s.jsx(r2,{});case"snippets":return s.jsx(m2,{});case"git":return s.jsx(x2,{});case"integrations":return s.jsx(uj,{});case"routing":return s.jsx(vj,{});case"extensions":return s.jsx(Dj,{});case"general":case"appearance":case"chat":case"shortcuts":case"sessions":case"notifications":case"voice":case"tunnel":case"isolated-spaces":{const de=Y[ce]??"visual";return s.jsx(MN,{section:de})}default:return null}},[Y,oe,$,r]);m.useEffect(()=>{if(!u||h!=="nav"||g==="home"||b.current===g)return;const ce=Ga(g);!ce||ce.slug==="home"||(b.current=g,y(ce.kind==="split"?"page-sidebar":"page-content"))},[u,h,g]);const ve=u&&h!=="nav",be=u&&h==="page-content"&&W?.kind==="split",ne=r(be?"settings.view.actions.back":ve?"settings.view.actions.backToSettings":"settings.view.actions.closeSettings"),we=Jd("open_settings",p===void 0?void 0:{open_settings:p}),Ne=we?r("settings.view.actions.closeSettingsWithShortcut",{shortcut:Hn(we)}):r("settings.view.actions.closeSettings"),Ie=m.useCallback(ce=>{if($.isVSCode)return;const je=Er(window.history.state);je?.page===ce&&je.stage==="page-content"||window.history.pushState({...JN(),[dm]:{page:ce,stage:"page-content"}},"",window.location.href)},[$.isVSCode]),Ce=m.useCallback(()=>{k.current=!0,y("page-content"),Ie(g)},[Ie,g]);m.useEffect(()=>{if(!u||h!=="page-content"||!k.current)return;k.current=!1;const ce=window.requestAnimationFrame(()=>{N.current?.querySelector("[data-settings-page-heading]")?.focus({preventScroll:!0})});return()=>{window.cancelAnimationFrame(ce)}},[u,h,g]);const Me=m.useCallback(()=>{if(be){if(Er(window.history.state)?.page===g&&!$.isVSCode){window.history.back();return}y("page-sidebar");return}y("nav")},[be,$.isVSCode,g]);m.useEffect(()=>{if(o)return o(()=>!u||h==="nav"?!1:(Me(),!0)),()=>o(null)},[Me,u,h,o]),m.useEffect(()=>{if(!u||$.isVSCode)return;const ce=je=>{if(Ga(g)?.kind!=="split")return;if(Er(je.state)?.page===g){y("page-content");return}y(ie=>ie==="page-content"?"page-sidebar":ie)};return window.addEventListener("popstate",ce),()=>{window.removeEventListener("popstate",ce)}},[u,$.isVSCode,g]);const he=()=>{const ce=x.trim().length>0;return s.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[s.jsx("div",{className:"px-4 pt-3",children:s.jsxs("div",{className:"oc-surface-elevated oc-raised oc-field flex h-10 items-center gap-1.5 rounded-md bg-surface-elevated/70 px-2 text-muted-foreground sm:h-8",children:[s.jsx(te,{name:"search",className:"h-4 w-4 shrink-0"}),s.jsx("input",{value:x,onChange:je=>w(je.target.value),onKeyDown:me,placeholder:r("settings.view.search.placeholder"),"aria-label":r("settings.view.search.aria"),"data-settings-search":"",className:"typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70"}),ce&&s.jsx("button",{type:"button",onClick:()=>w(""),"aria-label":r("settings.view.search.clear"),className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-interactive-hover hover:text-foreground sm:h-5 sm:w-5",children:s.jsx(te,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsx(Os,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx("div",{className:"flex flex-col gap-0.5 px-4 pt-4 pb-2",children:ce?ee.length>0?(()=>{let je=0;return le.map(de=>s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:"px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70",children:de.pageTitle}),de.results.map(ie=>{const xe=je;je+=1;const Se=xe===A,Le=!!ie.description;return s.jsxs("button",{type:"button",ref:Ue=>{P.current[xe]=Ue},onMouseMove:()=>{C.current=!1,I(xe)},onClick:()=>J(ie),className:ze("flex w-full flex-col rounded-md px-2 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Le?"min-h-11 py-1.5":"py-2",Se?"bg-interactive-selection":"hover:bg-interactive-hover"),children:[s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:ie.title}),Le&&s.jsx("span",{className:"typography-micro text-muted-foreground/70 line-clamp-2",children:ie.description})]},ie.id)})]},de.page))})():s.jsx("div",{className:"px-2 py-6 text-center typography-ui text-muted-foreground",children:r("settings.view.search.noResults")}):(()=>{const je=new Map;for(const ie of Q){const xe=ie.group,Se=je.get(xe);Se?Se.push(ie):je.set(xe,[ie])}return WN.map(ie=>({group:ie,pages:je.get(ie)??[]})).filter(ie=>ie.pages.length>0).map(({group:ie,pages:xe},Se)=>s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:ze("px-3 pb-1 typography-micro font-semibold uppercase tracking-wide text-muted-foreground sm:px-2 sm:pb-0.5",Se===0?"pt-1":"pt-4 sm:pt-3"),children:r(`settings.view.nav.group.${ie}`)}),xe.map(Le=>{const Ue=g===Le.slug&&!(u&&h==="nav"),Ye=Ef(Le.slug);return!Ye&&Le.slug!=="mcp"?null:s.jsx(mg,{children:s.jsx(pg,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>B(Le.slug),"aria-current":Ue?"page":void 0,className:ze("flex h-11 w-full items-center gap-2.5 rounded-md px-3 overflow-hidden sm:h-8 sm:gap-2 sm:px-2",Ue?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:[Le.slug==="mcp"?s.jsx(gg,{className:"h-[18px] w-[18px] shrink-0 sm:h-4 sm:w-4"}):s.jsx(te,{name:Ye,className:"h-[18px] w-[18px] shrink-0 sm:h-4 sm:w-4"}),s.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap overflow-hidden transition-opacity duration-150 opacity-100",children:[s.jsx("span",{className:"typography-ui-label font-normal truncate",children:ae(Le.slug)}),Le.slug==="tunnel"&&s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:r("settings.view.badge.beta")})]})]})})},Le.slug)})]},ie))})()})})]})},Pe=()=>{if(h==="nav")return s.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:s.jsx("div",{className:"flex h-full min-h-0 flex-col",children:s.jsx(Ia,{children:he()})})});if(!W)return s.jsx("div",{className:"flex-1 bg-background"});if(h==="page-sidebar"){if(W.kind!=="split"){const je=se(g);return s.jsx(Os,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Ia,{children:je})})}return s.jsx(Os,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Ia,{children:pe(g,{onItemSelect:Ce})})})}const ce=se(g);return s.jsx(Os,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Ia,{children:ce})})},Re=()=>{if(!W||g==="home")return null;const ce=t?VN:0,je=s.jsx(Mf.Provider,{value:ce,children:s.jsx(Ia,{children:se(g)})});return W.kind==="split"?s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[s.jsx("div",{className:ze("border-e",$.isVSCode?"bg-background":"bg-sidebar"),style:{width:Pd,minWidth:Pd,borderColor:"var(--interactive-border)"},children:s.jsx(Ia,{children:pe(g,{})})}),s.jsx(Os,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,verticalTrackStart:ce,children:je})]}):s.jsx(Os,{outerClassName:"h-full min-h-0",className:"bg-background",disableHorizontal:!0,verticalTrackStart:ce,children:je})};return s.jsxs("div",{ref:N,"data-settings-view":"true",className:ze("relative flex h-full min-h-0 flex-col overflow-hidden bg-background"),children:[u?s.jsxs("div",{className:ze("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",h!=="nav"&&"border-b","bg-background"),style:h!=="nav"?{borderColor:"var(--interactive-border)"}:void 0,children:[ve?s.jsx("button",{type:"button",onClick:Me,"aria-label":ne,className:"inline-flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(te,{name:"arrow-left-s",className:"h-5 w-5"})}):null,s.jsx("div",{className:"min-w-0 flex-1 px-2 typography-ui-label font-medium text-foreground truncate",children:h==="nav"?r("settings.view.home.title"):W?ae(W.slug):r("settings.view.home.title")}),t&&s.jsx("button",{type:"button",onClick:t,"aria-label":r("settings.view.actions.closeSettings"),title:Ne,className:"inline-flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(te,{name:"close",className:"h-5 w-5"})})]}):s.jsxs(s.Fragment,{children:[ve&&s.jsx("div",{className:ze("absolute inset-s-3 z-50",a?"top-2":"top-3"),children:s.jsx("button",{type:"button",onClick:Me,"aria-label":r("settings.view.actions.back"),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(te,{name:"arrow-left-s",className:"h-5 w-5"})})}),t&&s.jsx("div",{className:ze("absolute inset-e-0.5 z-50",a?"top-0.5":"top-1"),children:s.jsx("button",{type:"button",onClick:t,"aria-label":r("settings.view.actions.closeSettings"),title:Ne,className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:s.jsx(te,{name:"close",className:"h-5 w-5"})})})]}),s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:u?Pe():s.jsxs(s.Fragment,{children:[s.jsx("div",{className:ze("relative flex h-full min-h-0 w-36 min-w-36 flex-col overflow-hidden border-e sm:w-64 sm:min-w-64",E?"bg-sidebar":$.isVSCode?"bg-background":"bg-sidebar"),style:{borderColor:"var(--interactive-border)"},children:s.jsx(Ia,{children:he()})}),s.jsx("div",{className:"flex-1 overflow-hidden bg-background",children:Re()})]})})]})};export{gh as A,hC as S};