@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.
- package/dist/assets/{AboutDialog-BItSBkkK.js → AboutDialog-C8mAGhnz.js} +1 -1
- package/dist/assets/{ArchiveView-CEGi3y1V.js → ArchiveView-4-LVDLmf.js} +1 -1
- package/dist/assets/{ChangedPathLabel-CQNGnF-T.js → ChangedPathLabel-BCiU4QDF.js} +1 -1
- package/dist/assets/{CommandPalette-DWX1HV4m.js → CommandPalette-DEcmPHdC.js} +1 -1
- package/dist/assets/{DiffView-Be1Xoy_F.js → DiffView-CaDZ4gTk.js} +3 -3
- package/dist/assets/{FilesView-DONPk8-K.js → FilesView-Csrs_BGv.js} +1 -1
- package/dist/assets/{GitView-D10y-u46.js → GitView-DvxCZgCW.js} +3 -3
- package/dist/assets/{GuestSurfacePane-Cot0OO7x.js → GuestSurfacePane-DNg0xBTD.js} +1 -1
- package/dist/assets/{HelpDialog-Bw836_tH.js → HelpDialog-CLyz3_xd.js} +1 -1
- package/dist/assets/{InProgressOperationBanner-saAihIub.js → InProgressOperationBanner-BVDKUDqn.js} +2 -2
- package/dist/assets/{IntegrationsCatalogView-BtdMeTHf.js → IntegrationsCatalogView-u1gS0Vk8.js} +1 -1
- package/dist/assets/{JsonTreeView-BOQC0uTM.js → JsonTreeView-BpJU14WJ.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-CuZntPVf.js → MarkdownRendererImpl-t3OoYn_0.js} +1 -1
- package/dist/assets/{MemoryDebugPanel-BZgSuf-z.js → MemoryDebugPanel-9z1jGWze.js} +1 -1
- package/dist/assets/{OnboardingScreen-Bx2h2w69.js → OnboardingScreen-xzT7ckY0.js} +1 -1
- package/dist/assets/{OpenCodeStatusDialog-N9JgIC1p.js → OpenCodeStatusDialog-skpJZSjK.js} +1 -1
- package/dist/assets/{PatchDiff-Ca_Ci2CX.js → PatchDiff-BWW_8bob.js} +1 -1
- package/dist/assets/{PierreDiffViewer-Ck0P8Q2W.js → PierreDiffViewer-BZDNV4Uj.js} +1 -1
- package/dist/assets/{PlanView-dx70wKWR.js → PlanView-D7wshtfZ.js} +1 -1
- package/dist/assets/{ProjectActionsDialog-BS20dYCJ.js → ProjectActionsDialog-BPh74BCt.js} +1 -1
- package/dist/assets/{PullRequestComparisonSelector-DOW9_VlK.js → PullRequestComparisonSelector-BBdU2rL1.js} +3 -3
- package/dist/assets/{RunOverview-DtxjzGnX.js → RunOverview-Cngm2OOp.js} +2 -2
- package/dist/assets/{ScheduledTasksDialog-HcypGtky.js → ScheduledTasksDialog-DUjDdkw2.js} +1 -1
- package/dist/assets/{SettingsView-IBrGwDoM.js → SettingsView-CCZOw018.js} +2 -2
- package/dist/assets/{SettingsWindow-Bugr9Hmx.js → SettingsWindow-Cndsj5Vu.js} +1 -1
- package/dist/assets/{SourceBoardView-BD5rmib8.js → SourceBoardView-8Wp0oUvB.js} +1 -1
- package/dist/assets/{SpaceAccessDialog-BYhp5gfB.js → SpaceAccessDialog-CxfCzTpe.js} +1 -1
- package/dist/assets/{SpaceApplyDialog-CC0axZal.js → SpaceApplyDialog-CYp0A76N.js} +1 -1
- package/dist/assets/{SpaceRow-DDWTQgfP.js → SpaceRow-CQp4PkPJ.js} +1 -1
- package/dist/assets/{SpaceSetupOutput-BqurG7V4.js → SpaceSetupOutput-RNo0mWrR.js} +1 -1
- package/dist/assets/{SpacesView-Bcbb9aXY.js → SpacesView-BwcDCv3D.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-BS1PSa4l.js → SubmoduleDiffSummary-BQduif5s.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DXWQ17Fv.js → ToolOutputDialog-BVCvqYsK.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-DXRs6cSg.js → ToolPartDiffPreview-BXpCHBW9.js} +1 -1
- package/dist/assets/{UsageStatsView-DFVydqMY.js → UsageStatsView-CsC_RzAH.js} +1 -1
- package/dist/assets/{Virtualizer-B8rX50qD.js → Virtualizer-nenVQKi3.js} +1 -1
- package/dist/assets/{WalkthroughView-CECS5lDs.js → WalkthroughView-CdIYpttA.js} +1 -1
- package/dist/assets/{WorktreesView-FH0uzPQG.js → WorktreesView-D102xE1o.js} +1 -1
- package/dist/assets/{appThemeRegistry-CnS_OWEL.js → appThemeRegistry-BWap7OfW.js} +1 -1
- package/dist/assets/{ar-BlEU--PN.js → ar-9CiK5cuu.js} +3 -3
- package/dist/assets/{computeVirtualFileMetrics-rZJ-MSfY.js → computeVirtualFileMetrics-DDyA16hp.js} +1 -1
- package/dist/assets/{de-DWs4Mcjc.js → de-Drq6oIkP.js} +3 -3
- package/dist/assets/{decorate-Bbbyq0tX.js → decorate-CemSwkUs.js} +1 -1
- package/dist/assets/{es-k5T7CE97.js → es-0bkFr34F.js} +3 -3
- package/dist/assets/{flexokiTheme-DECIbITo.js → flexokiTheme-PoX6Vqyn.js} +1 -1
- package/dist/assets/{fr-CzmypgZ8.js → fr-CjgWVupK.js} +3 -3
- package/dist/assets/{he-DdkxJnUn.js → he-BrJa9oPB.js} +4 -4
- package/dist/assets/{index-DElZNtel.js → index-B2WHEal3.js} +1 -1
- package/dist/assets/{initializeSharedPreferences-C5qncsHs.js → initializeSharedPreferences-1Vo6G7CM.js} +1 -1
- package/dist/assets/{install-D-H6uk7D.js → install-FletzeYD.js} +1 -1
- package/dist/assets/{isDiffPlainText-DMFSMXcK.js → isDiffPlainText-yXcpftjI.js} +1 -1
- package/dist/assets/{isFilePlainText-BQGSJxcX.js → isFilePlainText-Dpm-_Qu8.js} +1 -1
- package/dist/assets/{ja-Qqkyglaf.js → ja-cfyrqWPa.js} +3 -3
- package/dist/assets/katex.min-F4TD1ekM.js +69 -0
- package/dist/assets/{ko-B8idPK2d.js → ko-herKAlGO.js} +3 -3
- package/dist/assets/{main-DMdUGpFx.js → main-CO7wKNtS.js} +2 -2
- package/dist/assets/{main-CcnDurk6.js → main-DN47yDMe.js} +19 -19
- package/dist/assets/markdownCore-BY21GJ_M.js +10 -0
- package/dist/assets/{miniChat-B8DW3cmv.js → miniChat-BmFJFQph.js} +2 -2
- package/dist/assets/{mobile-Caqsx1Op.js → mobile-DTi98S93.js} +2 -2
- package/dist/assets/{moveWorkspacePath-By4gjwmW.js → moveWorkspacePath-CENAo75W.js} +1 -1
- package/dist/assets/{nl-CFXZKHp7.js → nl-mZ4VCoiQ.js} +3 -3
- package/dist/assets/{parseDiffFromFile-C9ASoy7R.js → parseDiffFromFile-BSmRvd3V.js} +1 -1
- package/dist/assets/{pierreDiffTint-IfgQ6oty.js → pierreDiffTint-cyYFR1bm.js} +1 -1
- package/dist/assets/{pl-slLgZWDu.js → pl-C98lvkcZ.js} +4 -4
- package/dist/assets/{pt-BR-C319g_nn.js → pt-BR-CB63WPLS.js} +3 -3
- package/dist/assets/{relocateRestoredSession-DBWTClOj.js → relocateRestoredSession-D8Sf_FG_.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-C5irgP-w.js → renderElectronMiniChatApp-DmQ8i5jp.js} +2 -2
- package/dist/assets/{renderMobileApp-DnyN_ARh.js → renderMobileApp-CND9CafV.js} +3 -3
- package/dist/assets/{restartOpenCode-VU-OEAvZ.js → restartOpenCode-D8ExMl55.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-BJUtkqal.js → runtimeEndpointReset-lg1O2gVX.js} +3 -3
- package/dist/assets/{scheduledTasksApi-FZ9stPNl.js → scheduledTasksApi-CJBNpwgy.js} +1 -1
- package/dist/assets/{selectionMarkdown-DV_HvvmZ.js → selectionMarkdown-B_3WTOUr.js} +1 -1
- package/dist/assets/{shikiHighlight-BKmAuapa.js → shikiHighlight-DBj_a_TN.js} +1 -1
- package/dist/assets/{space-apply-Br_BRuH8.js → space-apply-COMscpEL.js} +1 -1
- package/dist/assets/{space-close-D_1iLJrX.js → space-close-DDLvYCUc.js} +1 -1
- package/dist/assets/{spaceNetwork-Dcj-qJy-.js → spaceNetwork-CNxs51y4.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-Bye_bpEL.js → textMateThemeFromAppTheme-tYpAceV3.js} +1 -1
- package/dist/assets/{tr-DNnJ5oqk.js → tr-C5KUa-8X.js} +3 -3
- package/dist/assets/{uk-Bw0BJwHw.js → uk-D44Grdmc.js} +3 -3
- package/dist/assets/{useAppFontEffects-d9vsRNKm.js → useAppFontEffects-Dm6zEvrf.js} +200 -199
- package/dist/assets/{useCallableModelProviders-8CrUkERW.js → useCallableModelProviders-BK3j8Sde.js} +1 -1
- package/dist/assets/{useDiffFindSurface-sw5jZ-9V.js → useDiffFindSurface-CaCh-qt2.js} +1 -1
- package/dist/assets/{useInlineCommentController-Cw5IRM5Y.js → useInlineCommentController-a2JepiF3.js} +1 -1
- package/dist/assets/{useMarkdownLocalAssets-D3a1j44d.js → useMarkdownLocalAssets-BEApAshz.js} +2 -2
- package/dist/assets/{useRootScrollLock-BWsNuapq.js → useRootScrollLock-mqVhK2HB.js} +2 -2
- package/dist/assets/{useWalkthroughReview-D7I1H6_J.js → useWalkthroughReview-BspAr9Aa.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DP_Bh3S8.js → vendor-codemirror-language-data-VzNDjH03.js} +2 -2
- package/dist/assets/{zh-CN-Brx5Btej.js → zh-CN-DwBC4Qtd.js} +3 -3
- package/dist/assets/{zh-TW-WokiutLA.js → zh-TW-DXEqDBAm.js} +3 -3
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +2 -2
- package/server/index.js +4 -2
- package/server/lib/git/service.test.js +1 -1
- package/server/lib/opencode/openchamber-routes.test.js +1 -0
- package/server/lib/opencode/settings-helpers.js +2 -2
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +1 -1
- package/server/lib/outbound-proxy.test.js +2 -2
- package/server/lib/spaces/tools.test.js +2 -2
- package/dist/assets/katex.min-u4DtE8E5.js +0 -69
- package/dist/assets/markdownCore-BwFkWhmZ.js +0 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{_ as Es}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as W,r as je,j as r,R as y,c as md}from"./vendor-react-BUCujlKS.js";import{a9 as hd,aa as da,u as se,ac as _o,I as B,B as Q,z as Ft,mN as gd,hO as xd,mO as bd,cx as Er,t as cs,q as ds,l as us,n as Mn,aW as lo,N as ne,x as Oi,aA as Lo,A as Y,a2 as yd,mP as vd,mQ as wd,ak as Sd,mR as jd,mS as Nd,mT as kd,G as _e,dv as Cd,aH as ys,cU as Fi,aP as Pt,a1 as Ot,hV as Bi,cG as Id,cI as Vi,mU as Td,cJ as Ui,C as zi,cK as Ki,D as vs,mV as Tn,ha as ua,y as It,iv as fa,iz as Rd,aU as lt,gI as yn,aS as Bt,aT as Vt,aR as Ut,gM as Gi,gG as Wi,gN as qi,mW as Ed,mX as Dd,mY as Pd,ji as Ad,jh as _d,mZ as pa,m_ as Ld,m$ as $d,n0 as ma,n1 as Md,n2 as Od,n3 as Fd,n4 as Bd,n5 as Vd,aF as On,n6 as Ud,n7 as Hi,cH as Rs,cL as Yi,c6 as co,i7 as yr,fh as is,cc as hn,ca as gn,c9 as Dn,cb as xn,c3 as Ds,o as Gs,en as $o,aC as Bs,i3 as ha,hU as uo,c0 as Ji,i5 as zd,i2 as ga,i1 as fr,eu as Kd,n8 as Gd,mx as Wd,n9 as fo,iE as qd,b0 as Xi,aG as Qi,cT as Hd,cS as Zi,cR as Yd,hb as Jd,hd as Xd,na as pr,nb as Qd,iU as Zd,b_ as eu,nc as tu,mu as su,a5 as Jt,cD as el,nd as nu,ne as ru,L as po,nf as ou,k as Dr,V as Ps,W as As,X as _s,az as tl,ay as sl,as as nl,at as au,au as Zn,av as Os,fW as Kr,bg as Pn,fk as iu,fq as os,dA as lu,ng as cu,nh as du,g9 as Gr,b9 as An,kK as uu,kN as fu,f1 as rl,bc as pu,ni as mu,F as Fn,j as hu,k4 as ol,r as _n,nj as gu,nk as xu,f as er,nl as al,nm as xa,H as ls,nn as mo,cE as bu,hh as yu,dZ as vu,no as wu,np as Su,eC as ju,nq as Nu,nr as ku,ns as Cu,nt as Iu,nu as Tu,aL as Vs,nv as Ru,nw as Eu,nx as Du,lX as Pu,ny as Au,e6 as il,ee as _u,Y as ll,e4 as Lu,hA as $u,dm as Mo,b7 as yt,eU as Mu,me as Ou,cy as Fu,jW as Dt,K as Bn,nz as Bu,nA as vr,nB as cl,cF as Vu,eN as Uu,nC as zu,nD as kn,nE as Ku,nF as dl,nG as Gu,fr as ul,fd as Wu,fe as qu,fg as Hu,fY as Yu,nH as Ju,am as wr,nI as Xu,ir as Qu,fp as Zu,gc as ef,fj as tf,nJ as Oo,mb as sf,mf as nf,nK as rf,lE as ba,U as ho,ma as of,nL as af,lq as lf,d5 as cf,nM as ya,nN as fl,nO as go,nP as df,nQ as uf,nR as va,nS as ff,nT as wa,nU as pl,nV as pf,nW as mf,nX as hf,nY as gf,nZ as xf,n_ as bf,br as Vn,n$ as ml,o0 as yf,e2 as vf,e1 as wf,e0 as Sf,bd as jf,o1 as Nf,aD as Ln,o2 as kf,o3 as Cf,o4 as If,o5 as Tf,h0 as Rf,bj as hl,bf as gl,cu as Ws,o6 as Ef,o7 as Df,o8 as Pf,b4 as xl,o9 as Af,oa as Sa,ob as _f,ez as Lf,oc as $f,c5 as Mf,cg as Of,od as bl,oe as yl,aE as vl,bs as wl,of as Sl,og as Ff,oh as Bf,oi as Vf,oj as jl,hk as bs,ok as Uf,al as zf,ol as Kf,om as Gf,on as Nl,aJ as Wf,oo as qf,op as ja,fb as Hf,aM as Yf,aN as Jf,aO as Xf,oq as Qf,or as Zf,os as ep,ot as tp,jl as sp,ou as np,ov as rp,ow as op,kU as kl,ox as mn,oy as ap,hy as ip,fZ as lp,bv as cp,gH as dp,fX as un,ff as bn,oz as up,g7 as fp,oA as pp,oB as mp,oC as hp,oD as gp,fm as Na,fn as ka,oE as xp,oF as bp,oG as Cl,mK as yp,J as vp,jU as wp,jV as Sp,oH as jp,lt as Np,ie as kp,oI as Cp,oJ as Ip,oK as Tp,oL as Rp,oM as Ep,oN as Dp,oO as Pp,P as Ap,ah as _p,hi as Lp,bl as $p,iY as Mp,ce as Op,gV as Fp,hp as Bp,hQ as Vp}from"./useAppFontEffects-d9vsRNKm.js";import{k as wt,a5 as be,b3 as Ks,dx as Up,a7 as $s,m as Il,q as Tl,dy as zp,dz as Ca,dA as Kp,bk as Gp,aB as Rl,l as qs,ay as Wp,u as Ce,b4 as El,bi as qp,bj as Ia,aU as Dl,dB as Hp,dC as Ta,bR as Ht,dD as Ra,aR as Yp,dE as Jp,dF as Xp,dG as Qp,ax as Pl,bF as Zp,t as At,an as em,n as Ct,a$ as Pr,b as ct,p as tm,e as Ar,da as Ze,dH as sm,d6 as nm,a6 as xo,cE as wn,bT as _r,bW as rm,bX as om,dI as am,dJ as im,as as Al,a_ as lm,dK as _l,dL as cm,bd as dm,aT as um,dM as fm,c$ as Lr,bo as Ea,ac as pm,ae as mm,ad as hm,dN as gm,dO as Ll,dP as xm,dQ as bm,bm as ym,dc as Fo,aI as vm,dR as wm,df as Sm,dS as Cn,c2 as Wr,dT as $l,cv as jm,at as Nm,ao as km,s as Cm}from"./katex.min-u4DtE8E5.js";import{o as zt,b as vn,s as nt,_ as Da,l as Sr,c as Im,a as Bo,d as Tm,n as jr,r as Rm,N as Em,e as Dm}from"./vendor-zod-DDir2TeQ.js";import{u as Pm,m as Am}from"./vendor-framer-motion-DxDVhOLc.js";import{c as Un,d as _m,u as Lm}from"./vendor-zustand-BAGL70zf.js";import{n as $m,o as Mm,p as Om,h as Ml,P as Ol,e as Fl,f as Bl,g as Vl}from"./vendor-base-ui-CPKyhvxM.js";import{f as Ul,h as mr,i as Fm,T as Bm,M as Vm,D as zl,j as Kl,P as Um}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as zm,a as Gl,S as Wl,v as ql,u as Hl}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Yl}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{toast as hr}from"./vendor-sonner-DFyL3AvE.js";const Km=["typescript","javascript","tsx","jsx","json","markdown"],Jl={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-line"}};let Pa=null;const Xl=()=>(Pa??=Promise.all([Es(()=>import("./index-DElZNtel.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113])),Es(()=>import("./workerFactory-Bw5qLmrM.js"),[]),Es(()=>import("./appThemeRegistry-CnS_OWEL.js"),__vite__mapDeps([114,115,101,102,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100]))]).then(([t,e,s])=>({WorkerPoolManager:t.WorkerPoolManager,workerFactory:e.workerFactory,ensurePierreThemeRegistered:s.ensurePierreThemeRegistered})),Pa),$n={},Aa=new Set,bo=new Set;let gr={light:"pierre-light",dark:"pierre-dark"};const Gm=()=>{for(const t of bo)t()},Ql=(t,e)=>{e.setRenderOptions({theme:gr,lineDiffType:Jl[t].lineDiffType})},yo=t=>{typeof window>"u"||Aa.has(t)||(Aa.add(t),Xl().then(e=>{if($n[t])return;const s=Jl[t],n=new e.WorkerPoolManager({workerFactory:e.workerFactory,poolSize:s.poolSize,totalASTLRUCacheSize:s.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:Km,lineDiffType:s.lineDiffType,preferredHighlighter:"shiki-wasm"});n.initialize(),$n[t]=n,Ql(t,n),Gm()}))},Wm=t=>(bo.add(t),()=>bo.delete(t)),qm=t=>{if(!(gr.light===t.light&&gr.dark===t.dark)){gr=t;for(const e of Object.keys($n)){const s=$n[e];s&&Ql(e,s)}}},iw=t=>{const e=W.c(15),{children:s}=t,n=hd();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=da(!1),e[0]=o):o=e[0];const a=o;let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=da(!0),e[1]=i):i=e[1];const l=i,c=n?.lightThemeId??a.metadata.id,d=n?.darkThemeId??l.metadata.id;let u;e[2]!==c||e[3]!==n?.availableThemes?(u=n?.availableThemes.find(v=>v.metadata.id===c)??a,e[2]=c,e[3]=n?.availableThemes,e[4]=u):u=e[4];const f=u;let p;e[5]!==d||e[6]!==n?.availableThemes?(p=n?.availableThemes.find(v=>v.metadata.id===d)??l,e[5]=d,e[6]=n?.availableThemes,e[7]=p):p=e[7];const g=p;let h,x;e[8]!==g||e[9]!==f?(h=()=>{let v=!1;return Xl().then(w=>{v||(w.ensurePierreThemeRegistered(f),w.ensurePierreThemeRegistered(g),qm({light:f.metadata.id,dark:g.metadata.id}))}),()=>{v=!0}},x=[g,f],e[8]=g,e[9]=f,e[10]=h,e[11]=x):(h=e[10],x=e[11]),je.useEffect(h,x);let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[12]=m):m=e[12],je.useEffect(Ym,m);let b;return e[13]!==s?(b=r.jsx(r.Fragment,{children:s}),e[13]=s,e[14]=b):b=e[14],b},lw=t=>{const e=W.c(5),s=t===void 0?"unified":t;let n;e[0]!==s?(n=()=>$n[s],e[0]=s,e[1]=n):n=e[1];const o=je.useSyncExternalStore(Wm,n,Jm);let a,i;return e[2]!==s?(a=()=>{yo(s)},i=[s],e[2]=s,e[3]=a,e[4]=i):(a=e[3],i=e[4]),je.useEffect(a,i),o};function Hm(){yo("unified"),yo("split")}function Ym(){if(typeof window>"u")return;const t=Hm;if(typeof window.requestIdleCallback=="function"){const s=window.requestIdleCallback(t,{timeout:5e3});return()=>window.cancelIdleCallback(s)}const e=window.setTimeout(t,2e3);return()=>window.clearTimeout(e)}function Jm(){}const Xm=zt({state:Da(["compatible","incompatible","unavailable"]),version:nt().nullable(),installation:Da(["managed","external","bundled"]),binary:nt().nullable().optional(),minimumVersion:nt().optional(),canInstall:vn()}),Zl=async()=>{const t=await wt("/api/opencode/compatibility",{signal:AbortSignal.timeout(2e4)});if(!t.ok)throw new Error("Could not check OpenCode compatibility");return Xm.parse(await t.json())},Qm=async(t="reconnect")=>{if(t==="install-v2"){if(!(await wt("/api/opencode/install-v2",{method:"POST"})).ok)throw new Error("OpenCode v2 installation failed");return{state:"recovered"}}const e=await Zl();if(e.state==="incompatible")return{state:"incompatible",compatibility:e};if(e.state==="unavailable")throw new Error("Could not determine OpenCode compatibility");if(!(await wt("/api/config/reload",{method:"POST"})).ok)throw new Error("OpenCode recovery failed");return{state:"recovered"}};class Zm extends Error{}const Nr=async()=>{const t=be(),e=Ks();if(await Up())return null;if(be()!==t||Ks()!==e)throw new Zm;return Zl()};let vo=null;const cw=()=>{const t=Nr();t.catch(()=>{}),vo={runtimeKey:be(),check:t}},eh=()=>{const t=vo;return vo=null,t&&t.runtimeKey===be()?t.check.catch(Nr):Nr()},dw=({children:t,enabled:e=!0})=>{const{t:s}=se(),[n,o]=je.useState(null),a=je.useId(),[i,l]=je.useState(null),[c,d]=je.useState(!1),u=je.useRef(0);je.useEffect(()=>{if(!e)return;let b=!0;const v=async S=>{const I=++u.current;try{const k=await S;k&&b&&I===u.current&&o(k)}catch{}};v(eh());const w=$s(()=>{u.current+=1,o(null),l(null),d(!1),v(Nr())});return()=>{b=!1,u.current+=1,w()}},[e]),je.useEffect(()=>{n?.state==="incompatible"&&document.getElementById("initial-loading")?.remove()},[n]);const f=async b=>{if(i)return;const v=++u.current;l(b),d(!1);try{const w=await Qm(b);if(v!==u.current)return;w.state==="incompatible"?o(w.compatibility):window.location.reload()}catch{v===u.current&&d(!0)}finally{v===u.current&&l(null)}};if(!e||n?.state!=="incompatible")return r.jsx(r.Fragment,{children:t});const p=n.installation==="external",g=n.installation==="bundled",h=n.minimumVersion,x=!!(h&&n.version?.startsWith("2.")),m=g?"opencodeCompatibility.bundled":x?p?"opencodeCompatibility.outdatedExternal":"opencodeCompatibility.outdatedLocal":p?"opencodeCompatibility.external":"opencodeCompatibility.local";return r.jsx("section",{className:"app-region-drag flex h-full min-h-0 items-center justify-center overflow-y-auto bg-background px-6 py-10 text-foreground select-none","aria-labelledby":a,children:r.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center text-center",children:[r.jsx(_o,{width:48,height:48}),r.jsx("h1",{id:a,className:"mt-6 text-xl font-semibold tracking-tight",children:s(x?"opencodeCompatibility.outdatedTitle":"opencodeCompatibility.title")}),r.jsxs("p",{className:"mt-2 text-sm leading-relaxed text-muted-foreground text-balance",children:[s(m,{version:n.version??"",minimum:h??""}),n.canInstall&&r.jsxs(r.Fragment,{children:[" ",s("opencodeCompatibility.installDescription")]})]}),n.version&&r.jsxs("div",{className:"mt-5 inline-flex items-center gap-2 rounded-md border border-border px-2.5 py-1 font-mono text-xs","aria-hidden":!0,children:[r.jsx("span",{className:"text-muted-foreground",children:n.version}),r.jsx(B,{name:"arrow-right",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-foreground",children:x?`${h}+`:"2.x"})]}),n.binary&&r.jsx("p",{className:"mt-2 max-w-full break-all font-mono text-xs text-muted-foreground select-text",children:n.binary}),c&&r.jsx("p",{role:"alert",className:"mt-5 rounded-md border border-[var(--status-error)]/30 bg-[var(--status-error-background)] px-3 py-2 text-sm text-[var(--status-error-text)]",children:s("opencodeCompatibility.failed")}),r.jsxs("div",{className:"app-region-no-drag mt-7 flex flex-wrap items-center justify-center gap-2",children:[n.canInstall&&r.jsxs(Q,{disabled:i!==null,onClick:()=>{f("install-v2")},children:[i==="install-v2"?r.jsx(Ft,{className:"size-4"}):r.jsx(B,{name:"download",className:"size-4"}),r.jsx("span",{role:i==="install-v2"?"status":void 0,children:s(i==="install-v2"?"opencodeCompatibility.installing":x?"opencodeCompatibility.update":"opencodeCompatibility.install")})]}),r.jsxs(Q,{variant:n.canInstall?"ghost":"default",disabled:i!==null,onClick:()=>{f("reconnect")},children:[i==="reconnect"?r.jsx(Ft,{className:"size-4"}):r.jsx(B,{name:"refresh",className:"size-4"}),r.jsx("span",{role:i==="reconnect"?"status":void 0,children:s(i==="reconnect"?"opencodeCompatibility.reconnecting":"opencodeCompatibility.reconnect")})]})]}),r.jsxs("a",{className:"app-region-no-drag mt-6 inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",href:g?"https://github.com/openchamber/openchamber/releases/latest":"https://opencode.ai/download",target:"_blank",rel:"noopener noreferrer",children:[s("opencodeCompatibility.guide"),r.jsx(B,{name:"external-link",className:"size-3"})]}),r.jsx("div",{className:"app-region-no-drag mt-3 w-full",children:r.jsx(gd,{})})]})})},qr=(t,e)=>Il(Tl.getState().dictionary,t,e),th=t=>{const e=t.message.toLowerCase();return e.includes("code signature")||e.includes("did not pass validation")||e.includes("code requirement")||e.includes("not signed")?"signature":e.includes("command is disabled")?"updater-disabled":"unknown"},sh=t=>{const e=th(t);return e==="signature"?qr("updateDialog.error.signatureRejected"):e==="updater-disabled"?qr("updateDialog.error.updaterDisabled"):t.message.trim()||qr("updateDialog.error.restartFailed")},_a="openchamber.update-install-id";function nh(){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(_a)?.trim();if(t)return t;const e=bd(globalThis.crypto);return e?(window.localStorage.setItem(_a,e),e):void 0}catch{return}}function rh(){if(typeof window>"u")return"unknown";try{const{deviceType:t}=xd();return t}catch{return"unknown"}}function oh(){const t=typeof window<"u"?window.__OPENCHAMBER_ELECTRON__?.arch?.toLowerCase?.():void 0;if(t==="arm64"||t==="aarch64")return"arm64";if(t==="x64"||t==="amd64"||t==="x86_64")return"x64";const e=typeof window<"u"?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e==="arm64"||e==="aarch64")return"arm64";if(e==="x64"||e==="amd64"||e==="x86_64")return"x64";const n=(typeof navigator<"u"?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(n==="arm"||n==="arm64"||n==="aarch64")return"arm64";if(n==="x86"||n==="x64"||n==="amd64")return"x64";const o=typeof navigator<"u"?navigator.userAgent.toLowerCase():"";return o.includes("aarch64")||o.includes("arm64")||o.includes("armv")?"arm64":o.includes("x86_64")||o.includes("x64")||o.includes("amd64")||o.includes("win64")?"x64":"unknown"}function ah(){const t=qp();if(t==="android"||t==="ios")return t;if(typeof navigator>"u")return"web";const e=(navigator.platform||"").toLowerCase();return e.includes("mac")?"macos":e.includes("win")?"windows":e.includes("linux")?"linux":"web"}function ec(t){const e=Ce.getState().reportUsage,s=new URLSearchParams({reportUsage:e?"true":"false"});if(s.set("deviceClass",rh()),s.set("arch",oh()),s.set("platform",ah()),e&&(t==="desktop"||t==="mobile")){const n=nh();n&&s.set("installId",n)}return t==="desktop"?(s.set("appType","desktop-electron"),s.set("instanceMode",El()?"local":"remote"),s):t==="vscode"?(s.set("appType","vscode"),s.set("instanceMode","local"),s):t==="mobile"?(s.set("appType","mobile-capacitor"),s.set("instanceMode","remote"),s):(s.set("appType","web"),s.set("instanceMode","unknown"),s)}function tc(t){return{available:t.available??!1,version:t.version,currentVersion:t.currentVersion??"unknown",body:t.body,releaseUrl:t.releaseUrl,downloadUrl:t.downloadUrl,nextSuggestedCheckInSec:typeof t.nextSuggestedCheckInSec=="number"&&Number.isFinite(t.nextSuggestedCheckInSec)?t.nextSuggestedCheckInSec:void 0,packageManager:t.packageManager,updateCommand:t.updateCommand,installBlocked:t.installBlocked==="service-manager"||t.installBlocked==="manual-install"||t.installBlocked==="desktop-host"?t.installBlocked:void 0}}async function tr(t,e){try{const s=ec(t),n=typeof window<"u"?window.__VSCODE_CONFIG__?.extensionVersion:void 0;e?s.set("currentVersion",e):t==="vscode"&&n&&s.set("currentVersion",n);const o=await wt(`/api/openchamber/update-check?${s.toString()}`,{method:"GET",headers:{Accept:"application/json"},priority:"low"});if(!o.ok)throw new Error(`Server responded with ${o.status}`);return tc(await o.json())}catch(s){return console.warn("Failed to check for updates:",s),null}}const ih=zt({error:nt().trim().min(1)});async function uw(){const t=ec("web");t.set("reportUsage","false");const e=await wt(`/api/openchamber/update-check?${t.toString()}`,{method:"GET",headers:{Accept:"application/json"}}),s=await e.json().catch(()=>null);if(!e.ok){const n=ih.safeParse(s);throw new Error(n.success?n.data.error:`Server responded with ${e.status}`)}return tc(s??{})}function lh(){return Gp()?"mobile":Rl()?"desktop":qs()?"vscode":Wp()?"web":null}const La={checking:!1,available:!1,downloading:!1,downloaded:!1,installing:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},ch=Un()((t,e)=>({...La,checkForUpdates:async()=>{const s=lh();if(!s)return null;t({checking:!0,error:null,runtimeType:s});try{let n=null,o=null;if(s==="desktop"){const a="2.4.1",[i,l]=await Promise.allSettled([Ca(),tr("desktop",a)]),c=i.status==="fulfilled"?i.value:null;return o=l.status==="fulfilled"?l.value?.nextSuggestedCheckInSec??null:null,t({checking:!1,available:c?.available??!1,info:c,lastChecked:Date.now(),nextCheckInSec:o}),o}else s==="web"?(n=await tr("web"),o=n?.nextSuggestedCheckInSec??null):s==="vscode"?o=(await tr("vscode"))?.nextSuggestedCheckInSec??null:s==="mobile"&&(n=await tr("mobile","2.4.1"),o=n?.nextSuggestedCheckInSec??null);return t({checking:!1,available:s==="vscode"?!1:n?.available??!1,info:s==="vscode"?null:n,lastChecked:Date.now(),nextCheckInSec:o}),o}catch(n){return t({checking:!1,error:n instanceof Error?n.message:"Failed to check for updates"}),null}},downloadUpdate:async()=>{const{available:s,runtimeType:n}=e();if(!(n!=="desktop"||!s)){t({downloading:!0,error:null,progress:null});try{const o=await Ca();if(!o?.available)throw new Error("Update detected, but desktop package is not ready yet. Retry in a moment.");if(t(i=>({info:i.info?{...i.info,...o,body:i.info.body||o.body,available:i.info.available}:o})),!await Kp(i=>{t({progress:i})}))throw new Error("Desktop update only works on Local instance");t({downloading:!1,downloaded:!0})}catch(o){t({downloading:!1,error:o instanceof Error?o.message:"Failed to download update"})}}},restartToUpdate:async()=>{const{downloaded:s,installing:n,runtimeType:o}=e();if(!(o!=="desktop"||!s||n)){t({error:null,installing:!0});try{if(!await zp())throw new Error(Il(Tl.getState().dictionary,"updateDialog.error.restartUnavailable"))}catch(a){t({installing:!1,error:sh(a instanceof Error?a:new Error(String(a)))})}}},dismiss:()=>{t({available:!1,downloaded:!1,installing:!1,info:null})},reset:()=>{t(La)}})),dh=zt({success:Sr(!0),autoRestart:vn().optional(),updateOwner:nt().optional(),version:nt().min(1).optional()}),uh=zt({available:vn(),currentVersion:nt().optional(),error:nt().optional()}),sc=zt({error:nt(),code:nt().optional()});async function fh(t=wt){try{const e=await t("/api/openchamber/update-install",{method:"POST",headers:{"Content-Type":"application/json"}}),s=await e.json();if(!e.ok){const a=sc.safeParse(s);return{success:!1,error:a.success?a.data.error:void 0}}const n=dh.safeParse(s);if(!n.success)return{success:!1};const o=n.data;return o.updateOwner==="electron-updater"?o.version?{success:!0,autoRestart:o.autoRestart!==!1,target:{owner:"electron",version:o.version}}:{success:!1}:{success:!0,autoRestart:o.autoRestart!==!1,target:{owner:"package-manager"}}}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function ph(t,e,{fetchUpdate:s=wt,maxWaitMs:n=600*1e3,intervalMs:o=2e3}={}){const a=Date.now()+n;for(;Date.now()<a;){const i=AbortSignal.timeout(Math.max(1,Math.min(1e4,a-Date.now())));try{const c=await s("/api/openchamber/update-check?appType=web&reportUsage=false&updateStatus=true",{method:"GET",headers:{Accept:"application/json"},signal:i});if(c.ok){const d=uh.safeParse(await c.json());if(d.success&&!d.data.error){const u=d.data;if(t.owner==="electron"?u.currentVersion===t.version:u.available===!1||e!==void 0&&u.currentVersion!==void 0&&u.currentVersion!==e)return{status:"applied"}}}else{const d=sc.safeParse(await c.json().catch(()=>null));if(d.success&&d.data.code==="DESKTOP_UPDATE_RESTART_FAILED")return{status:"failed",error:d.data.error};if(t.owner==="package-manager"&&(c.status===401||c.status===403)&&(await s("/health",{headers:{Accept:"application/json"},signal:i})).ok)return{status:"applied"}}}catch{}const l=a-Date.now();l>0&&await new Promise(c=>setTimeout(c,Math.min(o,l)))}return{status:"timeout"}}const $a="https://github.com/openchamber/openchamber/releases";function mh(t){const e=new Date(`${t}T00:00:00`);return Number.isNaN(e.getTime())?t:new Intl.DateTimeFormat(Oi(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function hh(t){return t.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function Ma(t){return t.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function gh(t,e){const s=t.split(".").map(o=>Number.parseInt(o,10)),n=e.split(".").map(o=>Number.parseInt(o,10));for(let o=0;o<3;o+=1){const a=Number.isFinite(s[o])?s[o]:0,i=Number.isFinite(n[o])?n[o]:0;if(a!==i)return i-a}return 0}function xh(t){const e=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,s=[];let n;for(;(n=e.exec(t))!==null;)s.push({version:n[1]??"",date:n[2]??"",start:n.index});return s.length===0?[]:s.map((o,a)=>{const i=s[a+1]?.start??t.length,l=t.slice(o.start,i).trim();return{version:o.version,date:o.date,start:o.start,end:i,raw:l}})}const fw=({open:t,onOpenChange:e,info:s,downloading:n,downloaded:o,installing:a=!1,progress:i,error:l,onDownload:c,onRestart:d,runtimeType:u="desktop"})=>{const{t:f}=se(),[p,g]=je.useState(!1),[h,x]=je.useState("idle"),[m,b]=je.useState(null),v=s?.version?s.releaseUrl||`${$a}/tag/v${s.version}`:$a,w=s?.downloadUrl||v,S=i?.total?Math.round(i.downloaded/i.total*100):0,I=u==="web",k=I&&s?.installBlocked==="desktop-host",R=u==="mobile",P=s?.updateCommand||"openchamber update";je.useEffect(()=>{t||(x("idle"),b(null))},[t]);const T=async()=>{(await Lo(P)).ok&&(g(!0),setTimeout(()=>g(!1),2e3))},D=je.useCallback(async E=>{await Er(E)},[]),A=je.useCallback(async()=>{x("updating"),b(null);const E=await fh();if(!E.success){x("error"),b(E.error||f("updateDialog.error.updateFailed"));return}E.autoRestart&&(x("restarting"),await new Promise($=>setTimeout($,2e3))),x("reconnecting");const L=await ph(E.target,s?.currentVersion);L.status==="applied"?window.location.reload():(x("error"),b(L.status==="failed"?L.error:f("updateDialog.error.takingLonger")))},[s?.currentVersion,f]),N=je.useCallback(()=>{D(w)},[D,w]),j=h!=="idle"&&h!=="error",_=je.useMemo(()=>{if(!s?.body)return null;const E=s.body.trim();if(!E)return null;const L=xh(E);if(L.length===0)return{kind:"raw",title:f("updateDialog.changelog.title"),content:Ma(E)};const $=[...L].sort((M,C)=>gh(M.version,C.version));return{kind:"sections",title:f("updateDialog.changelog.title"),sections:$.map(M=>({version:M.version,dateLabel:mh(M.date),content:Ma(hh(M.raw)||E)}))}},[s?.body,f]);return r.jsx(cs,{open:t,onOpenChange:j?void 0:e,children:r.jsxs(ds,{className:"max-w-4xl p-5 border-[var(--interactive-border)]",showCloseButton:!0,children:[r.jsxs("div",{className:"flex items-center mb-1",children:[r.jsxs(us,{className:"flex items-center gap-2.5",children:[r.jsx(B,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),r.jsx("span",{className:"text-lg font-semibold text-foreground",children:f(h==="restarting"||h==="reconnecting"?"updateDialog.header.updating":"updateDialog.header.updateAvailable")})]}),(s?.currentVersion||s?.version)&&r.jsxs("div",{className:"flex items-center gap-2 font-mono text-sm ms-3",children:[s?.currentVersion&&r.jsx("span",{className:"text-muted-foreground",children:s.currentVersion}),s?.currentVersion&&s?.version&&r.jsx("span",{className:"text-muted-foreground/50",children:"→"}),s?.version&&r.jsx("span",{className:"text-[var(--primary-base)] font-medium",children:s.version})]})]}),r.jsxs("div",{className:"space-y-2",children:[I&&j&&r.jsxs("div",{className:"rounded-lg bg-surface-elevated/30 p-5 border border-border",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Ft,{className:"h-5 w-5 text-[var(--primary-base)]"}),r.jsxs("div",{className:"typography-ui-label text-foreground",children:[h==="updating"&&f("updateDialog.status.installingUpdate"),h==="restarting"&&f("updateDialog.status.serverRestarting"),h==="reconnecting"&&f("updateDialog.status.waitingForServer")]})]}),r.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:f("updateDialog.status.autoReloadHint")})]}),_&&!j&&r.jsx("div",{className:"rounded-lg border border-border bg-surface-elevated/20 overflow-hidden",children:r.jsx(Mn,{className:"max-h-[400px] p-0",fillContainer:!1,children:_.kind==="raw"?r.jsx("div",{className:"p-4 typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline [&_h3]:!mt-4 [&_h3]:!mb-1.5 [&_h3]:!text-xs [&_h3]:!font-medium [&_h3]:!uppercase [&_h3]:!tracking-wide [&_h3]:!text-muted-foreground [&_h3:first-child]:!mt-0",onClickCapture:E=>{const $=E.target.closest("a");$&&$.href&&(E.preventDefault(),E.stopPropagation(),D($.href))},children:r.jsx(lo,{content:_.content,disableLinkSafety:!0,enableFileReferences:!1})}):r.jsx("div",{className:"divide-y divide-border",children:_.sections.map(E=>r.jsxs("div",{className:"p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsxs("span",{className:"typography-ui-label font-mono text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-1.5 py-0.5 rounded",children:["v",E.version]}),r.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:E.dateLabel})]}),r.jsx("div",{className:"typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline [&_h3]:!mt-4 [&_h3]:!mb-1.5 [&_h3]:!text-xs [&_h3]:!font-medium [&_h3]:!uppercase [&_h3]:!tracking-wide [&_h3]:!text-muted-foreground [&_h3:first-child]:!mt-0",onClickCapture:L=>{const M=L.target.closest("a");M&&M.href&&(L.preventDefault(),L.stopPropagation(),D(M.href))},children:r.jsx(lo,{content:E.content,disableLinkSafety:!0,enableFileReferences:!1})})]},E.version))})})}),I&&s?.packageManager!=="electron"&&s?.installBlocked!=="manual-install"&&h==="error"&&r.jsxs("div",{className:"space-y-2 mt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[r.jsx(B,{name:"terminal",className:"h-4 w-4"}),r.jsx("span",{children:f("updateDialog.fallback.updateViaTerminal")})]}),r.jsxs("div",{className:"flex items-center gap-2 p-1 ps-3 bg-surface-elevated/50 rounded-md border border-border",children:[r.jsx("code",{className:"flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap",children:P}),r.jsx("button",{onClick:T,className:ne("flex items-center justify-center p-2 rounded","text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]","transition-colors",p&&"text-[var(--status-success)]"),title:f(p?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:p?r.jsx(B,{name:"check",className:"h-4 w-4"}):r.jsx(B,{name:"clipboard",className:"h-4 w-4"})})]})]}),!I&&!R&&n&&r.jsxs("div",{className:"space-y-2 mt-4",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:f("updateDialog.status.downloadingPayload")}),r.jsxs("span",{className:"font-mono text-foreground",children:[S,"%"]})]}),r.jsx("div",{className:"h-1.5 bg-[var(--surface-subtle)] rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[var(--primary-base)] transition-all duration-300",style:{width:`${S}%`}})})]}),k&&r.jsx("p",{className:"mt-4 typography-meta text-muted-foreground",children:f("updateDialog.desktopHostInstall",{version:s?.version||""})}),(l||m)&&r.jsx("div",{className:"p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg",children:r.jsx("p",{className:"text-sm text-[var(--status-error)]",children:l||m})})]}),r.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[r.jsxs("a",{href:v,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors shrink-0",children:[r.jsx(B,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),r.jsxs("div",{className:"flex-1 flex justify-end",children:[!I&&!R&&!o&&!n&&r.jsxs("button",{onClick:c,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[r.jsx(B,{name:"download",className:"h-4 w-4"}),f("updateDialog.actions.downloadUpdate")]}),!I&&!R&&n&&r.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[r.jsx(Ft,{className:"h-4 w-4"}),f("updateDialog.status.downloading")]}),!I&&!R&&o&&a&&r.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)]/50 text-white cursor-not-allowed",children:[r.jsx(Ft,{className:"h-4 w-4"}),f("updateDialog.status.restarting")]}),!I&&!R&&o&&!a&&r.jsxs("button",{onClick:d,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)] text-white hover:opacity-90 transition-opacity",children:[r.jsx(B,{name:"restart",className:"h-4 w-4"}),f("updateDialog.actions.restartToUpdate")]}),R&&r.jsxs(Q,{onClick:N,size:"default",children:[r.jsx(B,{name:"external-link",className:"h-4 w-4"}),f("updateDialog.actions.openMobileUpdate")]}),I&&!j&&!k&&r.jsxs("button",{onClick:A,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[r.jsx(B,{name:"download",className:"h-4 w-4"}),f("updateDialog.actions.updateNow")]}),I&&j&&r.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[r.jsx(Ft,{className:"h-4 w-4"}),f("updateDialog.status.updating")]})]})]})]})})},pw=t=>!(t.dismissed==="true"||t.sessionShown==="true"||t.hasActiveToast),bh=t=>!(!t.version||t.seenVersions.has(t.version)||t.dismissedVersion!==null&&t.dismissedVersion===t.version),yh=t=>{if(t===null||typeof t!="object")return"";const e=t.version;return typeof e!="string"?"":e.trim()},vh=t=>!t||t.available!==!0||typeof t.latestVersion!="string"?"":t.latestVersion.trim(),wh=t=>t?.upgrade?.supported===!0,Sh=zt({available:vn().nullable().optional(),currentVersion:nt().nullable().optional(),latestVersion:nt().nullable().optional(),upgrade:zt({supported:vn().nullable().optional()}).nullable().optional()}),jh=zt({success:vn().optional(),version:nt().optional(),error:nt().optional()});async function Nh(){const t=await wt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!t.ok)throw new Error(t.statusText||"OpenCode upgrade status check failed");const e=Sh.safeParse(await t.json().catch(()=>null));if(!e.success)throw new Error("OpenCode upgrade status check failed");const s=e.data,n=s.currentVersion?.trim()||null,o=vh(s)||null;return{currentVersion:n,availableVersion:o,supported:wh(s)}}async function kh(t){const e=await wt("/api/opencode/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),s=jh.safeParse(await e.json().catch(()=>null)),n=s.success?s.data:null;if(!e.ok||n?.success===!1)throw new Error(n?.error||e.statusText||t);return n?.version??null}const Oa=()=>Rl()&&!El(),mw=()=>y.useSyncExternalStore($s,Oa,Oa),Ms="opencode-update-available",sr="opencode-upgrade-progress",Ch=5e3,Ih=[1e4,6e4],Fa="opencode-update-toast-dismissed-version",hw=()=>{const{t}=se(),e=Ce(i=>i.showOpenCodeUpdateNotifications),s=je.useRef(new Set),n=je.useRef(!1);je.useEffect(()=>{e||Y.dismiss(Ms)},[e]);const o=je.useCallback(()=>{Y.dismiss(sr),yd({message:t("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[t]),a=je.useCallback(async()=>{if(!n.current){n.current=!0,Y.dismiss(Ms),Y.message(t("opencodeUpdate.toast.upgrading.title"),{id:sr,description:t("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:r.jsx(Ft,{className:"h-4 w-4 text-muted-foreground"})});try{const i=await kh(t("opencodeUpdate.toast.failed.description"));Y.success(t("opencodeUpdate.toast.updated.title"),{id:sr,description:i?t("opencodeUpdate.toast.updated.descriptionWithVersion",{version:i}):t("opencodeUpdate.toast.updated.description"),duration:1/0,icon:r.jsx(B,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:t("opencodeUpdate.toast.actions.reload"),onClick:o}})}catch(i){Y.error(t("opencodeUpdate.toast.failed.title"),{id:sr,description:i instanceof Error?i.message:t("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{n.current=!1}}},[o,t]);return je.useEffect(()=>{const i=(p,g)=>{if(!Ce.getState().showOpenCodeUpdateNotifications){Y.dismiss(Ms);return}if(!bh({version:p,dismissedVersion:Ia().getItem(Fa),seenVersions:s.current}))return;s.current.add(p);const x={label:t("opencodeUpdate.toast.actions.dismiss"),onClick:()=>{Ia().setItem(Fa,p),Dl({openCodeUpdateToastDismissedVersion:p}),Y.dismiss(Ms)}};Y.info(t("opencodeUpdate.toast.available.title"),g?{id:Ms,description:t("opencodeUpdate.toast.available.description",{version:p}),duration:1/0,action:{label:t("opencodeUpdate.toast.actions.update"),onClick:a},cancel:x}:{id:Ms,description:t("opencodeUpdate.toast.available.manualDescription",{version:p}),duration:1/0,action:x})};let l=!1;const c=[],d=async(p,g=be())=>{try{const h=await Nh();!l&&g===be()&&h.availableVersion&&i(h.availableVersion,h.supported)}catch{const h=Ih[p];!l&&g===be()&&h!==void 0&&c.push(setTimeout(()=>{d(p+1,g)},h))}},u=p=>{yh(p.detail)&&d(0)};e&&c.push(setTimeout(()=>{d(0)},Ch));const f=$s(({runtimeKey:p})=>{s.current.clear(),Y.dismiss(Ms),Ce.getState().showOpenCodeUpdateNotifications&&d(0,p)});return window.addEventListener("openchamber:opencode-update-available",u),()=>{l=!0;for(const p of c)clearTimeout(p);f(),window.removeEventListener("openchamber:opencode-update-available",u)}},[a,e,t]),null},gw=()=>{const t=W.c(3),[e,s]=y.useState(Th),{isUpdating:n}=e;let o,a;if(t[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>wd(s),a=[],t[0]=o,t[1]=a):(o=t[0],a=t[1]),y.useEffect(o,a),!n)return null;let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-background/90",children:r.jsx(_o,{width:80,height:80,isAnimated:!0})}),t[2]=i):i=t[2],i};function Th(){return vd()}const Rh=1e4,xw=t=>{const e=W.c(22),{ready:s,animated:n}=t,o=n===void 0?!1:n,{t:a}=se(),[i,l]=y.useState(!1),[c,d]=y.useState(!1),u=Pm();let f,p;if(e[0]!==s?(f=()=>{if(s)return;d(!1);const R=setTimeout(()=>d(!0),Rh);return()=>clearTimeout(R)},p=[s],e[0]=s,e[1]=f,e[2]=p):(f=e[1],p=e[2]),y.useEffect(f,p),i)return null;const g=s?"ready":"loading";let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h={loading:{opacity:1},ready:{opacity:0}},e[3]=h):h=e[3];const x=u||!s?0:.3;let m;e[4]!==x?(m={duration:x,ease:"easeOut"},e[4]=x,e[5]=m):m=e[5];let b;e[6]!==s?(b=R=>{R==="ready"&&s&&l(!0)},e[6]=s,e[7]=b):b=e[7];const v=s?"none":"auto";let w;e[8]!==v?(w={pointerEvents:v},e[8]=v,e[9]=w):w=e[9];let S;e[10]!==o?(S=r.jsx(_o,{width:120,height:120,isAnimated:o,variant:"splash"}),e[10]=o,e[11]=S):S=e[11];let I;e[12]!==c||e[13]!==a?(I=c?r.jsx("p",{role:"status",className:"absolute inset-x-0 top-[calc(50%+84px)] px-6 text-center typography-small text-muted-foreground",children:a("startup.overlay.slow")}):null,e[12]=c,e[13]=a,e[14]=I):I=e[14];let k;return e[15]!==w||e[16]!==S||e[17]!==I||e[18]!==g||e[19]!==m||e[20]!==b?(k=r.jsxs(Am.div,{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",initial:"loading",animate:g,variants:h,transition:m,onAnimationComplete:b,style:w,children:[S,I]}),e[15]=w,e[16]=S,e[17]=I,e[18]=g,e[19]=m,e[20]=b,e[21]=k):k=e[21],k};class Eh extends y.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,s){this.setState({error:e,errorInfo:s})}componentDidUpdate(e,s){e.sessionId!==this.props.sessionId&&s.hasError&&this.state.hasError&&this.handleReset()}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?r.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:r.jsxs(Sd,{className:"w-full max-w-md",children:[r.jsx(jd,{className:"text-center",children:r.jsxs(Nd,{className:"flex items-center justify-center gap-2 text-destructive",children:[r.jsx(B,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),r.jsxs(kd,{className:"space-y-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground text-center",children:this.props.texts.description}),this.props.sessionId&&r.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:[this.props.texts.sessionLabel,": ",this.props.sessionId]}),this.state.error&&r.jsxs("details",{className:"text-xs font-mono bg-muted p-3 rounded",children:[r.jsx("summary",{className:"cursor-pointer hover:bg-interactive-hover/80",children:this.props.texts.detailsSummary}),r.jsx("pre",{className:"mt-2 max-h-48 overflow-auto",children:this.state.error.toString()})]}),r.jsx("div",{className:"flex gap-2",children:r.jsxs(Q,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[r.jsx(B,{name:"restart",className:"h-4 w-4 me-2"}),this.props.texts.resetAction]})}),r.jsx("div",{className:"text-xs text-muted-foreground text-center",children:this.props.texts.persistentHint})]})]})}):this.props.children}}function Dh(t){const e=W.c(22),{t:s}=se();let n;e[0]!==s?(n=s("chat.errorBoundary.title"),e[0]=s,e[1]=n):n=e[1];let o;e[2]!==s?(o=s("chat.errorBoundary.description"),e[2]=s,e[3]=o):o=e[3];let a;e[4]!==s?(a=s("chat.errorBoundary.sessionLabel"),e[4]=s,e[5]=a):a=e[5];let i;e[6]!==s?(i=s("chat.errorBoundary.detailsSummary"),e[6]=s,e[7]=i):i=e[7];let l;e[8]!==s?(l=s("chat.errorBoundary.resetAction"),e[8]=s,e[9]=l):l=e[9];let c;e[10]!==s?(c=s("chat.errorBoundary.persistentHint"),e[10]=s,e[11]=c):c=e[11];let d;e[12]!==n||e[13]!==o||e[14]!==a||e[15]!==i||e[16]!==l||e[17]!==c?(d={title:n,description:o,sessionLabel:a,detailsSummary:i,resetAction:l,persistentHint:c},e[12]=n,e[13]=o,e[14]=a,e[15]=i,e[16]=l,e[17]=c,e[18]=d):d=e[18];let u;return e[19]!==t||e[20]!==d?(u=r.jsx(Eh,{...t,texts:d}),e[19]=t,e[20]=d,e[21]=u):u=e[21],u}const bw=t=>{const e=W.c(9),{active:s,readOnly:n,pinnedSession:o}=t,a=s===void 0?!0:s,i=n===void 0?!1:n;let l;e[0]!==o?(l=p=>o?null:p.currentSessionId,e[0]=o,e[1]=l):l=e[1];const c=_e(l),d=o?.sessionId??c??void 0;let u;e[2]!==a||e[3]!==o||e[4]!==i?(u=r.jsx(Cd,{active:a,readOnly:i,pinnedSession:o}),e[2]=a,e[3]=o,e[4]=i,e[5]=u):u=e[5];let f;return e[6]!==d||e[7]!==u?(f=r.jsx(Dh,{sessionId:d,children:u}),e[6]=d,e[7]=u,e[8]=f):f=e[8],f},Ph=$m,yw=t=>{const e=W.c(14);let s,n,o,a;e[0]!==t?({className:o,asChild:s,children:n,...a}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=o,e[4]=a):(s=e[1],n=e[2],o=e[3],a=e[4]);let i;e[5]!==s||e[6]!==n?(i=s&&je.isValidElement(n)?{render:n}:{children:n},e[5]=s,e[6]=n,e[7]=i):i=e[7];const l=i;let c;e[8]!==o?(c=ne("flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-start text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",o),e[8]=o,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==l||e[12]!==c?(d=r.jsx(Mm,{className:c,...a,...l}),e[10]=a,e[11]=l,e[12]=c,e[13]=d):d=e[13],d},Ah=t=>{const e=W.c(8);let s,n;e[0]!==t?({className:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let o;e[3]!==s?(o=ne("transition-opacity duration-100 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0","motion-reduce:transition-none",s),e[3]=s,e[4]=o):o=e[4];let a;return e[5]!==n||e[6]!==o?(a=r.jsx(Om,{className:o,...n}),e[5]=n,e[6]=o,e[7]=a):a=e[7],a},_h=(t,e=()=>Pt.getState().load(t,{force:!0}))=>{const s=ys(t);if(!s)return()=>{};const n=be();let o=!1,a=!1,i=!1,l=!1;const c=()=>!o&&n===be()&&document.visibilityState!=="hidden"&&navigator.onLine!==!1,d=()=>{l=!0,!(!c()||a||i)&&(a=!0,queueMicrotask(()=>{a=!1,c()&&(l=!1,i=!0,e().finally(()=>{i=!1,l&&d()}))}))},u=Fi(f=>{(f.type==="project-context-changed"&&f.projectId===s||f.type==="event-stream-ready")&&d()});return window.addEventListener("focus",d),window.addEventListener("online",d),document.addEventListener("visibilitychange",d),d(),()=>{o=!0,u(),window.removeEventListener("focus",d),window.removeEventListener("online",d),document.removeEventListener("visibilitychange",d)}},Ba=t=>({providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:t.agent});function Lh(t){const e=W.c(129),{t:s}=se(),{open:n,onOpenChange:o,target:a,projectDirectory:i,submitting:l,allowRunAsGoal:c,onConfirm:d}=t,u=l===void 0?!1:l,f=c===void 0?!1:c;let p;e[0]!==f?(p=f&&!qs(),e[0]=f,e[1]=p):p=e[1];const g=p,h=Ot(Wh),x=Ot(Gh),m=Bi(Kh),b=Ot(zh),v=Ot(Uh),w=Ot(Vh),S=Ot(Bh),I=Ot(Fh);let k;e[2]!==I||e[3]!==w||e[4]!==v||e[5]!==S?(k=()=>Ba({providerID:v,modelID:w,variant:S,agent:I}),e[2]=I,e[3]=w,e[4]=v,e[5]=S,e[6]=k):k=e[6];const[R,P]=y.useState(k);let T,D;e[7]!==m||e[8]!==x||e[9]!==h||e[10]!==n||e[11]!==i?(T=()=>{n&&(h({directory:i,source:"todoSendDialog"}),x({directory:i}),m())},D=[n,h,x,m,i],e[7]=m,e[8]=x,e[9]=h,e[10]=n,e[11]=i,e[12]=T,e[13]=D):(T=e[12],D=e[13]),y.useEffect(T,D);let A,N;e[14]!==I||e[15]!==w||e[16]!==v||e[17]!==S||e[18]!==n?(A=()=>{n&&P(Ba({providerID:v,modelID:w,variant:S,agent:I}))},N=[n,v,w,S,I],e[14]=I,e[15]=w,e[16]=v,e[17]=S,e[18]=n,e[19]=A,e[20]=N):(A=e[19],N=e[20]),y.useEffect(A,N);let j,_;e[21]!==R.modelID||e[22]!==R.providerID||e[23]!==n||e[24]!==b?(j=()=>{if(!n||b.length===0)return;const Ae=b.find(Fe=>Fe.id===R.providerID)??b[0],Re=Array.isArray(Ae?.models)?Ae.models:[],at=Re.some(Fe=>Fe.id===R.modelID),Ne=Re[0]?.id??"";Ae?.id===R.providerID&&at||P(Fe=>({...Fe,providerID:Ae?.id??"",modelID:at?Fe.modelID:Ne,variant:""}))},_=[n,b,R.providerID,R.modelID],e[21]=R.modelID,e[22]=R.providerID,e[23]=n,e[24]=b,e[25]=j,e[26]=_):(j=e[25],_=e[26]),y.useEffect(j,_);const E=Oh;let L;if(e[27]!==R.modelID||e[28]!==R.providerID||e[29]!==b){let Ae;e[31]!==R.providerID?(Ae=Ne=>Ne.id===R.providerID,e[31]=R.providerID,e[32]=Ae):Ae=e[32];const at=b.find(Ae)?.models?.find(Ne=>Ne.id===R.modelID);L=Id(at?.variants),e[27]=R.modelID,e[28]=R.providerID,e[29]=b,e[30]=L}else L=e[30];const $=L,M=$.length>0;let C,O;e[33]!==R.variant||e[34]!==M?(C=()=>{M||!R.variant||P(Mh)},O=[M,R.variant],e[33]=R.variant,e[34]=M,e[35]=C,e[36]=O):(C=e[35],O=e[36]),y.useEffect(C,O);let z;e[37]!==R.modelID||e[38]!==R.providerID?(z=R.providerID.trim().length>0&&R.modelID.trim().length>0,e[37]=R.modelID,e[38]=R.providerID,e[39]=z):z=e[39];const G=z;let U;e[40]!==G||e[41]!==R||e[42]!==d||e[43]!==u?(U=()=>{!G||u||d(R)},e[40]=G,e[41]=R,e[42]=d,e[43]=u,e[44]=U):U=e[44];const K=U;let X,re;e[45]!==K||e[46]!==n?(X=()=>{if(!n)return;const Ae=Re=>{(Re.metaKey||Re.ctrlKey)&&Re.key==="Enter"&&(Re.preventDefault(),K())};return window.addEventListener("keydown",Ae),()=>window.removeEventListener("keydown",Ae)},re=[n,K],e[45]=K,e[46]=n,e[47]=X,e[48]=re):(X=e[47],re=e[48]),y.useEffect(X,re);let ee;e[49]!==s||e[50]!==a?(ee=s(a==="worktree"?"rightSidebar.contextNotesTodo.sendDialog.title.newWorktree":"rightSidebar.contextNotesTodo.sendDialog.title.newSession"),e[49]=s,e[50]=a,e[51]=ee):ee=e[51];const xe=ee;let ce;e[52]!==o||e[53]!==u?(ce=Ae=>{u||o(Ae)},e[52]=o,e[53]=u,e[54]=ce):ce=e[54];let he;e[55]!==xe?(he=r.jsx(vs,{children:r.jsx(us,{children:xe})}),e[55]=xe,e[56]=he):he=e[56];let ie;e[57]!==s?(ie=s("chat.modelControls.model"),e[57]=s,e[58]=ie):ie=e[58];let pe;e[59]!==ie?(pe=r.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:ie}),e[59]=ie,e[60]=pe):pe=e[60];let le;e[61]===Symbol.for("react.memo_cache_sentinel")?(le=(Ae,Re)=>{P(at=>({...at,providerID:Ae,modelID:Re,variant:""}))},e[61]=le):le=e[61];let de;e[62]!==R.modelID||e[63]!==R.providerID?(de=r.jsx(Vi,{providerId:R.providerID,modelId:R.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:le}),e[62]=R.modelID,e[63]=R.providerID,e[64]=de):de=e[64];let te;e[65]!==pe||e[66]!==de?(te=r.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[pe,de]}),e[65]=pe,e[66]=de,e[67]=te):te=e[67];let J;e[68]!==s?(J=s("sessions.scheduledTasks.editor.thinkingLevel.label"),e[68]=s,e[69]=J):J=e[69];let q;e[70]!==J?(q=r.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:J}),e[70]=J,e[71]=q):q=e[71];const oe=!M;let ue;e[72]===Symbol.for("react.memo_cache_sentinel")?(ue=Ae=>P(Re=>({...Re,variant:Ae})),e[72]=ue):ue=e[72];let Ie;e[73]!==R.variant||e[74]!==oe||e[75]!==$?(Ie=r.jsx(Td,{value:R.variant,options:$,disabled:oe,onChange:ue}),e[73]=R.variant,e[74]=oe,e[75]=$,e[76]=Ie):Ie=e[76];let Le;e[77]!==q||e[78]!==Ie?(Le=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[q,Ie]}),e[77]=q,e[78]=Ie,e[79]=Le):Le=e[79];let we;e[80]!==s?(we=s("sessions.scheduledTasks.editor.agent.label"),e[80]=s,e[81]=we):we=e[81];let $e;e[82]!==we?($e=r.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:we}),e[82]=we,e[83]=$e):$e=e[83];let ke;e[84]===Symbol.for("react.memo_cache_sentinel")?(ke=Ae=>P(Re=>({...Re,agent:Ae})),e[84]=ke):ke=e[84];let Te;e[85]!==R.agent?(Te=r.jsx(Ui,{agentName:R.agent,filter:E,dropdownPortalToBody:!0,onChange:ke}),e[85]=R.agent,e[86]=Te):Te=e[86];let ae;e[87]!==$e||e[88]!==Te?(ae=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[$e,Te]}),e[87]=$e,e[88]=Te,e[89]=ae):ae=e[89];let fe;e[90]!==te||e[91]!==Le||e[92]!==ae?(fe=r.jsxs("div",{className:"flex flex-col gap-4",children:[te,Le,ae]}),e[90]=te,e[91]=Le,e[92]=ae,e[93]=fe):fe=e[93];const ge=`flex items-center gap-3 ${g?"justify-between":"justify-end"}`;let Oe;e[94]!==R.runAsGoal||e[95]!==g||e[96]!==u||e[97]!==s?(Oe=g?r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(zi,{checked:R.runAsGoal===!0,onChange:Ae=>P(Re=>({...Re,runAsGoal:Ae})),disabled:u,ariaLabel:s("sessions.scheduledTasks.editor.goal.aria")}),r.jsx("button",{type:"button",className:"truncate typography-ui-label text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:u,onClick:()=>P($h),children:s("sessions.scheduledTasks.editor.goal.label")})]}):null,e[94]=R.runAsGoal,e[95]=g,e[96]=u,e[97]=s,e[98]=Oe):Oe=e[98];let Be;e[99]!==o?(Be=()=>o(!1),e[99]=o,e[100]=Be):Be=e[100];let Xe;e[101]!==s?(Xe=s("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[101]=s,e[102]=Xe):Xe=e[102];let Ue;e[103]!==u||e[104]!==Be||e[105]!==Xe?(Ue=r.jsx(Q,{variant:"ghost",size:"sm",onClick:Be,disabled:u,children:Xe}),e[103]=u,e[104]=Be,e[105]=Xe,e[106]=Ue):Ue=e[106];const Ye=!G||u;let ze;e[107]!==u||e[108]!==s?(ze=s(u?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[107]=u,e[108]=s,e[109]=ze):ze=e[109];let Me;e[110]!==K||e[111]!==Ye||e[112]!==ze?(Me=r.jsx(Q,{size:"sm",onClick:K,disabled:Ye,children:ze}),e[110]=K,e[111]=Ye,e[112]=ze,e[113]=Me):Me=e[113];let Pe;e[114]!==Ue||e[115]!==Me?(Pe=r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[Ue,Me]}),e[114]=Ue,e[115]=Me,e[116]=Pe):Pe=e[116];let Ge;e[117]!==ge||e[118]!==Oe||e[119]!==Pe?(Ge=r.jsxs("div",{className:ge,children:[Oe,Pe]}),e[117]=ge,e[118]=Oe,e[119]=Pe,e[120]=Ge):Ge=e[120];let et;e[121]!==he||e[122]!==fe||e[123]!==Ge?(et=r.jsxs(ds,{className:"max-w-md overflow-visible",children:[he,fe,Ge]}),e[121]=he,e[122]=fe,e[123]=Ge,e[124]=et):et=e[124];let tt;return e[125]!==n||e[126]!==ce||e[127]!==et?(tt=r.jsx(cs,{open:n,onOpenChange:ce,children:et}),e[125]=n,e[126]=ce,e[127]=et,e[128]=tt):tt=e[128],tt}function $h(t){return{...t,runAsGoal:t.runAsGoal!==!0}}function Mh(t){return{...t,variant:""}}function Oh(t){return Ki(t.mode)}function Fh(t){return t.currentAgentName||""}function Bh(t){return t.currentVariant||""}function Vh(t){return t.currentModelId}function Uh(t){return t.currentProviderId}function zh(t){return t.providers}function Kh(t){return t.loadAgents}function Gh(t){return t.loadAgents}function Wh(t){return t.loadProviders}const Vo=y.createContext(null);function Uo(){return y.useContext(Vo)!==null}function qh(t){const e=W.c(3),{value:s,children:n}=t;let o;return e[0]!==n||e[1]!==s?(o=r.jsx(Vo.Provider,{value:s,children:n}),e[0]=n,e[1]=s,e[2]=o):o=e[2],o}function zo(t){const e=W.c(5),{children:s}=t,n=y.useContext(Vo);if(!n)return s;let o;e[0]!==s?(o=r.jsx("div",{"data-context-panel-toolbar":"",className:"flex min-w-0 flex-1 items-stretch",children:s}),e[0]=s,e[1]=o):o=e[1];let a;return e[2]!==n||e[3]!==o?(a=md.createPortal(o,n),e[2]=n,e[3]=o,e[4]=a):a=e[4],a}const nr="flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition-shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",rr="ring-2 ring-foreground ring-offset-2 ring-offset-background",Hh=t=>{const e=W.c(40),{value:s,onChange:n,labels:o,legacyCss:a}=t,i=a===void 0?null:a,l=s.toLowerCase(),c=ua.some(U=>U===l),d=l!==""&&!Tn(l)&&i!==null,u=l!==""&&!c&&!d,f=y.useRef(null),[p,g]=y.useState(s);let h;e[0]!==g||e[1]!==s?(h=()=>g(s),e[0]=g,e[1]=s,e[2]=h):h=e[2];let x;e[3]!==s?(x=[s],e[3]=s,e[4]=x):x=e[4],y.useEffect(h,x);let m;e[5]!==p?(m=p.trim()!==""&&!Tn(p.trim()),e[5]=p,e[6]=m):m=e[6];const b=m;let v;e[7]!==p||e[8]!==n?(v=()=>{const U=p.trim();(U===""||Tn(U))&&n(U.toLowerCase())},e[7]=p,e[8]=n,e[9]=v):v=e[9];const w=v;let S;e[10]!==n?(S=()=>n(""),e[10]=n,e[11]=S):S=e[11];const I=l==="",k=l===""&&rr;let R;e[12]!==k?(R=ne(nr,"border border-border text-muted-foreground",k),e[12]=k,e[13]=R):R=e[13];let P;e[14]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(B,{name:"close",className:"h-3.5 w-3.5"}),e[14]=P):P=e[14];let T;e[15]!==o.empty||e[16]!==S||e[17]!==I||e[18]!==R?(T=r.jsx("button",{type:"button",onClick:S,"aria-pressed":I,className:R,title:o.empty,"aria-label":o.empty,children:P}),e[15]=o.empty,e[16]=S,e[17]=I,e[18]=R,e[19]=T):T=e[19];let D;e[20]!==d||e[21]!==i?(D=d?r.jsx("span",{"aria-hidden":"true",className:ne(nr,rr),style:{backgroundColor:i}}):null,e[20]=d,e[21]=i,e[22]=D):D=e[22];const A=ua.map(U=>r.jsx("button",{type:"button",onClick:()=>n(U),"aria-pressed":l===U,className:ne(nr,l===U&&rr),style:{backgroundColor:U},title:U,"aria-label":o.swatch(U)},U));let N;e[23]===Symbol.for("react.memo_cache_sentinel")?(N=()=>f.current?.click(),e[23]=N):N=e[23];const j=u?rr:"border border-dashed border-border text-muted-foreground hover:text-foreground";let _;e[24]!==j?(_=ne(nr,j),e[24]=j,e[25]=_):_=e[25];let E;e[26]!==u?(E=u?null:r.jsx(B,{name:"add",className:"h-3.5 w-3.5"}),e[26]=u,e[27]=E):E=e[27];const L="color",$=-1,M="true",C=Tn(l)?l:"#808080";let O;e[28]!==n?(O=U=>n(U.target.value.toLowerCase()),e[28]=n,e[29]=O):O=e[29];let z;e[30]!==C||e[31]!==O?(z=r.jsx("input",{ref:f,type:L,tabIndex:$,"aria-hidden":M,value:C,onChange:O,className:"sr-only"}),e[30]=C,e[31]=O,e[32]=z):z=e[32];let G;return e[33]!==w||e[34]!==p||e[35]!==b||e[36]!==u||e[37]!==o.hex||e[38]!==g?(G=u?r.jsx(It,{value:p,onChange:U=>g(U.target.value),onBlur:w,onKeyDown:U=>{U.key==="Enter"&&w()},placeholder:"#RRGGBB","aria-invalid":b,"aria-label":o.hex,className:"h-7 w-24 rounded-md px-2 font-mono typography-meta"}):null,e[33]=w,e[34]=p,e[35]=b,e[36]=u,e[37]=o.hex,e[38]=g,e[39]=G):G=e[39],r.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[T,D,A,r.jsx("button",{type:"button",onClick:N,"aria-pressed":u,className:_,style:u?{backgroundColor:l}:void 0,title:o.custom,"aria-label":o.custom,children:E}),z,G]})},Yh=y.createContext(0),Jh=t=>{const e=W.c(23),{children:s,className:n,outerClassName:o,title:a,titleLeading:i,titleAccessory:l,description:c,headerEnd:d,showSaveStatus:u,onBlurCapture:f}=t,p=u===void 0?!1:u,g=y.useContext(Yh),h=a!=null||c!=null||d!=null||p,x=typeof a=="string"||typeof a=="number",m=i!=null||l!=null;let b;e[0]!==o?(b=ne("h-full overlay-scrollbar-wrapper--stable-gutter",o),e[0]=o,e[1]=b):b=e[1];let v;e[2]!==n?(v=ne("mx-auto max-w-[840px] space-y-0 px-6 py-6 @3xl:px-12 @3xl:py-8","[&>section:first-of-type]:border-t-0 [&>section:first-of-type]:pt-0",n),e[2]=n,e[3]=v):v=e[3];let w;e[4]!==c||e[5]!==h||e[6]!==m||e[7]!==d||e[8]!==x||e[9]!==p||e[10]!==a||e[11]!==l||e[12]!==i?(w=h&&r.jsxs("div",{className:"mb-2 flex flex-wrap items-start justify-between gap-x-4 gap-y-3 pb-6",children:[r.jsxs("div",{className:"min-w-0 flex-1 basis-64 space-y-1",children:[a!=null?x?m?r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i,r.jsx("h1",{"data-settings-page-heading":!0,tabIndex:-1,className:ne(fa,"min-w-0 truncate"),children:a}),r.jsx("span",{className:"shrink-0",children:l})]}):r.jsx("h1",{"data-settings-page-heading":!0,tabIndex:-1,className:fa,children:a}):a:null,c!=null?typeof c=="string"||typeof c=="number"?r.jsx("p",{className:Rd,children:c}):c:null]}),r.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-3",children:[d,p&&r.jsx(Qh,{})]})]}),e[4]=c,e[5]=h,e[6]=m,e[7]=d,e[8]=x,e[9]=p,e[10]=a,e[11]=l,e[12]=i,e[13]=w):w=e[13];let S;e[14]!==s||e[15]!==f||e[16]!==v||e[17]!==w?(S=r.jsxs("div",{className:v,onBlurCapture:f,children:[w,s]}),e[14]=s,e[15]=f,e[16]=v,e[17]=w,e[18]=S):S=e[18];let I;return e[19]!==g||e[20]!==b||e[21]!==S?(I=r.jsx(Mn,{outerClassName:b,className:"w-full @container",verticalTrackStart:g,children:S}),e[19]=g,e[20]=b,e[21]=S,e[22]=I):I=e[22],I},Xh=500,Qh=()=>{const t=W.c(13),{t:e}=se(),s=y.useSyncExternalStore(Hp,Ta,Ta),[n,o]=y.useState(!1);let a,i;if(t[0]!==s?(a=()=>{if(s!=="saving"){o(!1);return}const u=setTimeout(()=>o(!0),Xh);return()=>clearTimeout(u)},i=[s],t[0]=s,t[1]=a,t[2]=i):(a=t[1],i=t[2]),y.useEffect(a,i),s==="error"){let u;t[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(B,{name:"error-warning",className:"size-3.5"}),t[3]=u):u=t[3];let f;t[4]!==e?(f=e("settings.common.status.saveFailed"),t[4]=e,t[5]=f):f=t[5];let p;return t[6]!==f?(p=r.jsxs("div",{"aria-live":"assertive",className:"flex shrink-0 items-center gap-1.5 typography-meta text-[var(--status-error)]",children:[u,r.jsx("span",{children:f})]}),t[6]=f,t[7]=p):p=t[7],p}if(s!=="saving"||!n)return null;let l;t[8]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(B,{name:"loader-4",className:"size-3.5 animate-spin"}),t[8]=l):l=t[8];let c;t[9]!==e?(c=e("settings.common.actions.saving"),t[9]=e,t[10]=c):c=t[10];let d;return t[11]!==c?(d=r.jsxs("div",{"aria-live":"polite",className:"flex shrink-0 items-center gap-1.5 typography-meta text-muted-foreground",children:[l,r.jsx("span",{children:c})]}),t[11]=c,t[12]=d):d=t[12],d},vw="grid grid-cols-1 gap-3 @xl:grid-cols-2 @3xl:grid-cols-3",wo=ne("group flex min-h-[132px] flex-col rounded-xl p-4 text-start","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]"),Zh={success:"bg-[var(--status-success)]/15 text-[var(--status-success)]",warning:"bg-[var(--status-warning)]/15 text-[var(--status-warning)]",error:"bg-[var(--status-error)]/15 text-[var(--status-error)]",info:"bg-[var(--status-info)]/15 text-[var(--status-info)]",neutral:"oc-tile-inset text-muted-foreground"},Ko=t=>{const e=W.c(5),{tone:s,children:n}=t,o=Zh[s];let a;e[0]!==o?(a=ne("max-w-40 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",o),e[0]=o,e[1]=a):a=e[1];let i;return e[2]!==n||e[3]!==a?(i=r.jsx("span",{className:a,children:n}),e[2]=n,e[3]=a,e[4]=i):i=e[4],i},eg=t=>{const e=W.c(2),{children:s}=t;let n;return e[0]!==s?(n=r.jsx("span",{className:"oc-tile-inset shrink-0 rounded-full px-2 py-px text-[10px] font-medium",children:s}),e[0]=s,e[1]=n):n=e[1],n},nc=t=>{const e=W.c(5),{action:s}=t;let n;e[0]!==s.icon?(n=s.icon?r.jsx(B,{name:s.icon,className:"size-4"}):null,e[0]=s.icon,e[1]=n):n=e[1];let o;return e[2]!==s.label||e[3]!==n?(o=r.jsxs(r.Fragment,{children:[n,s.label]}),e[2]=s.label,e[3]=n,e[4]=o):o=e[4],o},ww=t=>{const e=W.c(60),{icon:s,title:n,subtitle:o,description:a,badges:i,footer:l,muted:c,onOpen:d,actions:u,actionsLabel:f}=t,p=(u?.length??0)>0,g=c&&"opacity-60";let h;e[0]!==g?(h=ne("oc-tile-inset flex size-10 shrink-0 items-center justify-center rounded-[10px]",g),e[0]=g,e[1]=h):h=e[1];let x;e[2]!==s||e[3]!==h?(x=r.jsx("span",{className:h,children:s}),e[2]=s,e[3]=h,e[4]=x):x=e[4];let m;e[5]!==i?(m=i?r.jsx("span",{className:"flex min-w-0 flex-wrap justify-end gap-1",children:i}):null,e[5]=i,e[6]=m):m=e[6];let b;e[7]!==x||e[8]!==m?(b=r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[x,m]}),e[7]=x,e[8]=m,e[9]=b):b=e[9];const v=c&&"opacity-60";let w;e[10]!==v?(w=ne("mt-3 min-w-0",v),e[10]=v,e[11]=w):w=e[11];let S;e[12]!==n?(S=r.jsx("div",{className:"truncate text-sm font-semibold text-foreground",title:n,children:n}),e[12]=n,e[13]=S):S=e[13];let I;e[14]!==o?(I=o?r.jsx("div",{className:"mt-0.5 truncate font-mono typography-micro text-muted-foreground",title:o,children:o}):null,e[14]=o,e[15]=I):I=e[15];let k;e[16]!==a?(k=a?r.jsx("div",{className:"mt-1 line-clamp-2 typography-micro text-muted-foreground",children:a}):null,e[16]=a,e[17]=k):k=e[17];let R;e[18]!==k||e[19]!==w||e[20]!==S||e[21]!==I?(R=r.jsxs("div",{className:w,children:[S,I,k]}),e[18]=k,e[19]=w,e[20]=S,e[21]=I,e[22]=R):R=e[22];const P=p&&"pe-8";let T;e[23]!==P?(T=ne("mt-auto flex min-w-0 items-center gap-2 pt-3 typography-micro text-muted-foreground",P),e[23]=P,e[24]=T):T=e[24];let D;e[25]!==p||e[26]!==d?(D=d&&!p?r.jsx(B,{name:"arrow-right-s",className:"ms-auto size-4 shrink-0 opacity-0 transition-opacity duration-150 group-hover:opacity-70 group-focus-visible:opacity-70","aria-hidden":!0}):null,e[25]=p,e[26]=d,e[27]=D):D=e[27];let A;e[28]!==l||e[29]!==T||e[30]!==D?(A=r.jsxs("div",{className:T,children:[l,D]}),e[28]=l,e[29]=T,e[30]=D,e[31]=A):A=e[31];let N;e[32]!==R||e[33]!==A||e[34]!==b?(N=r.jsxs(r.Fragment,{children:[b,R,A]}),e[32]=R,e[33]=A,e[34]=b,e[35]=N):N=e[35];const j=N;let _;e[36]!==j||e[37]!==d?(_=d?r.jsx("button",{type:"button",onClick:d,className:ne(wo,"oc-tile oc-tile-hover h-full w-full"),children:j}):r.jsx("div",{className:ne(wo,"oc-tile h-full"),children:j}),e[36]=j,e[37]=d,e[38]=_):_=e[38];const E=_;if(!p||!u)return E;let L;e[39]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("div",{className:"group relative"}),e[39]=L):L=e[39];let $;e[40]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(B,{name:"more-2",className:"size-4"}),e[40]=$):$=e[40];let M;e[41]!==f?(M=r.jsx(Bt,{asChild:!0,children:r.jsx(Q,{variant:"ghost",size:"icon",className:"absolute bottom-3 inset-e-3 h-7 w-7 text-muted-foreground opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100 data-[state=open]:opacity-100","aria-label":f,title:f,children:$})}),e[41]=f,e[42]=M):M=e[42];let C;e[43]!==u?(C=u.map(tg),e[43]=u,e[44]=C):C=e[44];let O;e[45]!==C?(O=r.jsx(Vt,{align:"end",className:"w-fit min-w-32",children:C}),e[45]=C,e[46]=O):O=e[46];let z;e[47]!==M||e[48]!==O?(z=r.jsxs(Ut,{children:[M,O]}),e[47]=M,e[48]=O,e[49]=z):z=e[49];let G;e[50]!==E||e[51]!==z?(G=r.jsxs(Gi,{render:L,children:[E,z]}),e[50]=E,e[51]=z,e[52]=G):G=e[52];let U;e[53]!==u?(U=u.map(sg),e[53]=u,e[54]=U):U=e[54];let K;e[55]!==U?(K=r.jsx(Wi,{className:"w-fit min-w-32",children:U}),e[55]=U,e[56]=K):K=e[56];let X;return e[57]!==G||e[58]!==K?(X=r.jsxs(qi,{children:[G,K]}),e[57]=G,e[58]=K,e[59]=X):X=e[59],X},Sw=t=>{const e=W.c(11),{label:s,hint:n,onClick:o,settingsItem:a}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=ne(wo,"oc-tile-hover items-center justify-center gap-2 text-center border border-dashed border-[color-mix(in_srgb,var(--foreground)_14%,transparent)] text-muted-foreground hover:text-foreground"),e[0]=i):i=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("span",{className:"oc-tile-inset flex size-10 items-center justify-center rounded-[10px]",children:r.jsx(B,{name:"add",className:"size-5"})}),e[1]=l):l=e[1];let c;e[2]!==s?(c=r.jsx("span",{className:"typography-ui-label font-medium",children:s}),e[2]=s,e[3]=c):c=e[3];let d;e[4]!==n?(d=n?r.jsx("span",{className:"typography-micro",children:n}):null,e[4]=n,e[5]=d):d=e[5];let u;return e[6]!==o||e[7]!==a||e[8]!==c||e[9]!==d?(u=r.jsxs("button",{type:"button",onClick:o,"data-settings-item":a,className:i,children:[l,c,d]}),e[6]=o,e[7]=a,e[8]=c,e[9]=d,e[10]=u):u=e[10],u},jw=t=>{const e=W.c(7),{value:s,onChange:n,placeholder:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(B,{name:"search",className:"pointer-events-none absolute inset-s-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground","aria-hidden":!0}),e[0]=a):a=e[0];let i;e[1]!==n?(i=c=>n(c.target.value),e[1]=n,e[2]=i):i=e[2];let l;return e[3]!==o||e[4]!==i||e[5]!==s?(l=r.jsxs("div",{className:"relative mb-4 max-w-[24rem]",children:[a,r.jsx(It,{value:s,onChange:i,placeholder:o,"aria-label":o,className:"ps-8"})]}),e[3]=o,e[4]=i,e[5]=s,e[6]=l):l=e[6],l},Nw=t=>{const e=W.c(4),{label:s,onClick:n}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(B,{name:"arrow-left-s",className:"size-4"}),e[0]=o):o=e[0];let a;return e[1]!==s||e[2]!==n?(a=r.jsx(Q,{variant:"ghost",size:"icon",className:"-ms-2 h-7 w-7 shrink-0",onClick:n,"aria-label":s,title:s,children:o}),e[1]=s,e[2]=n,e[3]=a):a=e[3],a},kw=t=>{const e=W.c(2),{name:s}=t;let n;return e[0]!==s?(n=r.jsx(B,{name:s,className:"size-5 text-muted-foreground"}),e[0]=s,e[1]=n):n=e[1],n};function tg(t){return r.jsx(lt,{variant:t.destructive?"destructive":"default",onClick:t.onSelect,children:r.jsx(nc,{action:t})},t.label)}function sg(t){return r.jsx(yn,{className:ne(t.destructive&&"text-destructive focus:text-destructive"),onClick:t.onSelect,children:r.jsx(nc,{action:t})},t.label)}let Go=0,rc=be(),or=0,xr=0,ar=0,ir=0,fn=0;const kr=new Map,Rn=()=>({runtimeKey:be(),generation:Go}),xs=t=>t.runtimeKey===be()&&t.runtimeKey===rc&&t.generation===Go,Hr=t=>{const e=(kr.get(t)??0)+1;return kr.set(t,e),xr+=1,{...Rn(),mutationGeneration:e}},pn=(t,e)=>xs(t)&&kr.get(e)===t.mutationGeneration,Va=Im([Qp,Sr("")]).nullable().transform(t=>t||null),Fs=Un()(_m((t,e)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,isLoading:!1,setSelectedProfile:s=>t({selectedProfileId:s}),loadProfiles:async()=>{const s=Rn(),n=++or,o=xr;t({isLoading:!0});try{const a=Xp.parse(await _d());return!xs(s)||n!==or?!1:(t(o===xr?{profiles:a,isLoading:!1}:{isLoading:!1}),!0)}catch(a){return!xs(s)||n!==or||(console.error("Failed to load git identity profiles:",a),t({isLoading:!1})),!1}},loadGlobalIdentity:async()=>{const s=Rn(),n=++ar;try{const o=await Ad(),a=o===null?null:Jp.parse(o);return!xs(s)||n!==ar?!1:(t({globalIdentity:{id:"global",name:a?.userName??"",userName:a?.userName??"",userEmail:a?.userEmail??"",color:"info",icon:"fingerprint"}}),!0)}catch(o){return!xs(s)||n!==ar||console.error("Failed to load global git identity:",o),!1}},loadDefaultGitIdentityId:async()=>{const s=Rn(),n=++ir,o=fn;try{const a=await Yp();if(!xs(s))return!1;const i=Va.parse(a?.defaultGitIdentityId??null);return n!==ir||o!==fn?!1:(t({defaultGitIdentityId:i}),!0)}catch(a){return!xs(s)||n!==ir||console.error("Failed to load default git identity setting:",a),!1}},setDefaultGitIdentityId:async s=>{const n=Rn(),o=++fn,a=Va.parse(s);try{const i=a;return await Dl({defaultGitIdentityId:a??""}),!xs(n)||o!==fn?!1:(t({defaultGitIdentityId:i}),!0)}catch(i){return!xs(n)||o!==fn||console.error("Failed to save default git identity setting:",i),!1}},createProfile:async s=>{const n={...s,id:s.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:s.color||"keyword",icon:s.icon||"branch"},o=Hr(n.id);try{Ht("saving");const a=Ra.parse(await Pd(n));if(a.id!==n.id)throw new Error("Created Git identity profile ID does not match the request");return pn(o,n.id)?(t(i=>({profiles:[...i.profiles.filter(l=>l.id!==a.id),a]})),Ht("saved"),!0):!1}catch(a){return pn(o,n.id)&&(Ht("error"),console.error("Failed to create git identity profile:",a)),!1}},updateProfile:async(s,n)=>{const o=e().profiles.find(i=>i.id===s);if(!o)return!1;const a=Hr(s);try{Ht("saving");const i=Ra.parse(await Dd(s,{...o,...n,id:s}));if(i.id!==s)throw new Error("Updated Git identity profile ID does not match the request");return pn(a,s)?(t(l=>({profiles:l.profiles.map(c=>c.id===s?i:c)})),Ht("saved"),!0):!1}catch(i){return pn(a,s)&&(Ht("error"),console.error("Failed to update git identity profile:",i)),!1}},deleteProfile:async s=>{const n=Hr(s);try{return Ht("saving"),await Ed(s),pn(n,s)?(t(o=>({profiles:o.profiles.filter(a=>a.id!==s),selectedProfileId:o.selectedProfileId===s?null:o.selectedProfileId,defaultGitIdentityId:o.defaultGitIdentityId===s?null:o.defaultGitIdentityId})),Ht("saved"),!0):!1}catch(o){return pn(n,s)&&(Ht("error"),console.error("Failed to delete git identity profile:",o)),!1}},getProfileById:s=>s==="global"?e().globalIdentity||void 0:e().profiles.find(n=>n.id===s),resetForRuntimeSwitch:s=>{Go+=1,rc=s,or+=1,ar+=1,ir+=1,fn+=1,xr+=1,kr.clear(),Ht("saved"),t({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,isLoading:!1})}}),{name:"git-identities-store"})),Ua=(t,e)=>e.updatedAtMs-t.updatedAtMs,za=Un((t,e)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!e().isLoading){t({isLoading:!0,error:null});try{const[s,n]=await Promise.all([Od(),ma()]),o={};for(const a of n.sort(Ua))o[a.id]=a;e().listenerReady||await Fd(a=>{t(i=>({statusesById:{...i.statusesById,[a.id]:a}}))}),t({instances:s.instances,statusesById:o,isLoading:!1,initialized:!0,listenerReady:!0})}catch(s){t({isLoading:!1,error:s instanceof Error?s.message:String(s)})}}},loadImports:async()=>{if(!e().isImportsLoading){t({isImportsLoading:!0,error:null});try{const s=await Md();t({importCandidates:s,isImportsLoading:!1})}catch(s){t({isImportsLoading:!1,error:s instanceof Error?s.message:String(s)})}}},refreshStatuses:async()=>{try{const s=await ma(),n={};for(const o of s.sort(Ua))n[o.id]=o;t({statusesById:n})}catch(s){t({error:s instanceof Error?s.message:String(s)})}},setInstances:async s=>{t({isSaving:!0,error:null});try{await $d({instances:s}),t({instances:s,isSaving:!1}),await e().refreshStatuses()}catch(n){throw t({isSaving:!1,error:n instanceof Error?n.message:String(n)}),n}},upsertInstance:async s=>{const n=e().instances,o=n.some(a=>a.id===s.id)?n.map(a=>a.id===s.id?s:a):[s,...n];await e().setInstances(o)},createFromCommand:async(s,n,o)=>{const a=Bd(s,n);o&&o.trim()&&(a.nickname=o.trim()),await e().upsertInstance(a)},removeInstance:async s=>{await pa(s).catch(()=>{});const n=e().instances.filter(o=>o.id!==s);await e().setInstances(n),t(o=>{const a={...o.statusesById};return delete a[s],{statusesById:a}})},connect:async s=>{t({error:null});try{await Ld(s),await e().refreshStatuses()}catch(n){throw t({error:n instanceof Error?n.message:String(n)}),n}},disconnect:async s=>{t({error:null});try{await pa(s),await e().refreshStatuses()}catch(n){throw t({error:n instanceof Error?n.message:String(n)}),n}},retry:async s=>{await e().connect(s)},getStatus:s=>e().statusesById[s]||null,clearError:()=>t({error:null})})),ng=Vd,oc=t=>ng[t||"play"]??"play",So=[{value:"macos",label:"macOS"},{value:"linux",label:"Linux"},{value:"windows",label:"Windows"}],rg=t=>{const e=new Set(t.personal.projectActions.map(n=>n.id)),s=new Set(t.personal.hiddenSharedActionIds);return[...t.shared.projectActions.filter(n=>!e.has(n.id)).map(n=>({action:n,source:"shared",hidden:s.has(n.id)})),...t.personal.projectActions.map(n=>({action:n,source:"personal",hidden:!1}))]},ac=t=>t.shared.status!=="invalid",og=t=>{const e={...t};return delete e.source,e},Ka=(t,e)=>{const s=og(e);return t.some(n=>n.id===s.id)?t.map(n=>n.id===s.id?s:n):[...t,s]},Cr=(t,e)=>t.filter(s=>s.id!==e),ag=async(t,e,s,n,o)=>{const a=o==="shared"?await e.sharedActions(Ka(t.shared.projectActions,s)):await e.personalActions(Ka(t.personal.projectActions,s));return!a||n===null||n===o?a:n==="shared"?e.sharedActions(Cr(t.shared.projectActions,s.id)):e.personalActions(Cr(t.personal.projectActions,s.id))},ig=async(t,e,s)=>s.source==="personal"?e.personalActions(Cr(t.personal.projectActions,s.action.id)):await e.sharedActions(Cr(t.shared.projectActions,s.action.id))?(s.hidden&&await e.hiddenSharedActionIds(t.personal.hiddenSharedActionIds.filter(n=>n!==s.action.id)),!0):!1,lg=(t,e,s,n)=>{const o=t.personal.hiddenSharedActionIds.filter(a=>a!==s);return e.hiddenSharedActionIds(n?[...o,s]:o)},cg=t=>{const e=t.personal.setupWorktreeMode==="replace";return[...t.shared.setupWorktree.map((s,n)=>({command:s,source:"shared",index:n,skipped:e})),...t.personal.setupWorktree.map((s,n)=>({command:s,source:"personal",index:n,skipped:!1}))]},ic=(t,e)=>e==="shared"?t.shared.setupWorktree:t.personal.setupWorktree,lc=(t,e,s)=>e==="shared"?t.sharedCommands(s):t.personalCommands(s),cc=(t,e,s,n)=>{const o=n.trim(),a=ic(t,s.source);return lc(e,s.source,o?a.map((i,l)=>l===s.index?o:i):a.filter((i,l)=>l!==s.index))},dg=(t,e,s)=>e.personalCommands([...t.personal.setupWorktree,s.trim()]),dc=(t,e,s)=>cc(t,e,s,""),ug=async(t,e,s)=>{const n=s.source==="shared"?"personal":"shared";return await lc(e,n,[...ic(t,n),s.command])?dc(t,e,s):!1},Yr="__none__",fg=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,pg=({target:t,canShare:e,onOpenChange:s,onSave:n,onDelete:o})=>{const{t:a}=se(),{isMobile:i}=On(),l=y.useMemo(()=>Pl(),[]),c=za(T=>T.instances),d=za(T=>T.load),[u,f]=y.useState({id:"",name:"",command:""}),[p,g]=y.useState("personal"),[h,x]=y.useState(!1);y.useEffect(()=>{t&&(f(t.action??{id:fg(),name:"",command:"",icon:"play"}),g(t.source))},[t]),y.useEffect(()=>{!l||!t||d().catch(()=>{})},[l,d,t]);const m=y.useMemo(()=>l?Ud(c):[],[c,l]),b=T=>f(D=>({...D,...T})),v=u.platforms??[],w=u.autoOpenUrl===!0,S=T=>{const D=v.includes(T)?v.filter(A=>A!==T):[...v,T];b({platforms:D.length>0&&D.length<So.length?D:void 0})},I=u.name.trim().length>0&&u.command.trim().length>0&&!h&&(p==="personal"||e),k=t?.action===null,R=async T=>{x(!0);try{await T()&&s(!1)}finally{x(!1)}},P=()=>R(()=>n({...u,name:u.name.trim(),command:u.command.trim(),openUrl:u.autoOpenUrl&&u.openUrl?.trim()||void 0,desktopOpenSshForward:u.autoOpenUrl?u.desktopOpenSshForward:void 0},p));return r.jsx(cs,{open:t!==null,onOpenChange:s,children:r.jsxs(ds,{className:"max-w-3xl",children:[r.jsx(vs,{children:r.jsx(us,{children:a(k?"settings.projects.actionEditor.titleNew":"settings.projects.actionEditor.titleEdit")})}),r.jsxs("div",{className:i?"flex flex-col gap-5":"grid grid-cols-2 gap-x-10",children:[r.jsxs("div",{className:"flex min-w-0 flex-col gap-5",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Ut,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(Q,{type:"button",variant:"outline",size:"icon",className:"shrink-0","aria-label":a("settings.projects.actions.field.selectIconAria"),children:r.jsx(B,{name:oc(u.icon),className:"h-4 w-4"})})}),r.jsx(Vt,{align:"start",className:"w-56 p-2",children:r.jsx("div",{className:"grid grid-cols-6 gap-1",children:Hi.map(T=>{const D=(u.icon||"play")===T.key;return r.jsx("button",{type:"button",onClick:()=>b({icon:T.key}),"aria-pressed":D,className:ne("inline-flex h-8 w-8 items-center justify-center rounded-md text-foreground hover:bg-[var(--interactive-hover)]",D&&"bg-interactive-selection text-interactive-selection-foreground"),"aria-label":a("settings.projects.actions.field.iconAria",{icon:T.label}),children:r.jsx(B,{name:T.Icon,className:"h-4 w-4"})},T.key)})})})]}),r.jsx(It,{value:u.name,autoFocus:k,onChange:T=>b({name:T.target.value}),placeholder:a("settings.projects.actions.field.actionNamePlaceholder"),"aria-label":a("settings.projects.actions.field.actionNamePlaceholder"),className:"min-w-0 flex-1"})]}),r.jsx(Rs,{label:a("settings.projects.actions.field.command"),controlClassName:"max-w-none",children:r.jsx(Yi,{value:u.command,onChange:T=>b({command:T.target.value}),placeholder:a("settings.projects.actions.field.commandPlaceholder"),"aria-label":a("settings.projects.actions.field.command"),className:"min-h-[132px] w-full font-mono text-xs"})}),r.jsx(Rs,{label:a("settings.projects.actionEditor.savedIn"),descriptionPlacement:"after",description:r.jsx("span",{className:"block min-h-[2lh]",children:a(!e&&p==="shared"?"settings.projects.actionEditor.savedIn.teamUnavailable":p==="shared"?"settings.projects.actionEditor.savedIn.teamHint":"settings.projects.actionEditor.savedIn.personalHint")}),children:r.jsx(co,{value:p,onChange:g,"aria-label":a("settings.projects.actionEditor.savedIn"),options:[{value:"shared",label:a("settings.projects.scope.team"),disabled:!e&&p!=="shared"},{value:"personal",label:a("settings.projects.scope.personal")}]})})]}),r.jsxs("div",{className:"flex min-w-0 flex-col gap-5",children:[r.jsxs("div",{className:"flex flex-col gap-5",children:[r.jsx(Rs,{label:a("settings.projects.actions.runIn.label"),info:a("settings.projects.actions.runIn.info"),children:r.jsx(co,{value:u.runIn==="parent"?"parent":"worktree",onChange:T=>b({runIn:T==="parent"?"parent":void 0}),"aria-label":a("settings.projects.actions.runIn.aria"),options:[{value:"worktree",label:a("settings.projects.actions.runIn.worktree")},{value:"parent",label:a("settings.projects.actions.runIn.project")}]})}),r.jsx(Rs,{label:a("settings.projects.actionEditor.platforms"),children:r.jsxs("div",{role:"group","aria-label":a("settings.projects.actionEditor.platforms"),className:"flex flex-wrap items-center gap-1",children:[r.jsx(Q,{type:"button",variant:"chip",size:"xs",className:"!font-normal","aria-pressed":v.length===0,onClick:()=>b({platforms:void 0}),children:a("settings.projects.actionEditor.platformsAll")}),So.map(T=>r.jsx(Q,{type:"button",variant:"chip",size:"xs",className:"!font-normal","aria-pressed":v.includes(T.value),onClick:()=>S(T.value),children:T.label},T.value))]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(yr,{checked:u.autoOpenUrl===!0,onChange:T=>b({autoOpenUrl:T?!0:void 0}),label:a("settings.projects.actionEditor.openUrl"),info:a("settings.projects.actions.field.overrideUrlTooltip")}),r.jsxs("div",{className:"space-y-2 ps-6",children:[r.jsx(It,{value:u.openUrl??"",disabled:!w,onChange:T=>b({openUrl:T.target.value}),placeholder:a("settings.projects.actions.field.overrideUrlPlaceholder"),"aria-label":a("settings.projects.actions.field.overrideUrlPlaceholder"),className:"w-full font-mono text-xs"}),r.jsx("p",{className:ne(is,!w&&"opacity-60"),children:a("settings.projects.actions.field.overrideUrlVariables")}),l?r.jsxs(hn,{value:u.desktopOpenSshForward&&m.some(T=>T.id===u.desktopOpenSshForward)?u.desktopOpenSshForward:Yr,onValueChange:T=>b({desktopOpenSshForward:T===Yr?void 0:T}),disabled:!w||m.length===0,children:[r.jsx(gn,{className:"w-full","aria-label":a("settings.projects.actions.field.desktopSshForward"),children:r.jsx(Dn,{children:T=>m.length===0?a("settings.projects.actions.state.noDesktopSshForwards"):m.find(D=>D.id===T)?.label??a("settings.projects.actions.field.useOutputManualUrl")})}),r.jsxs(xn,{children:[r.jsx(Ds,{value:Yr,children:a("settings.projects.actions.field.useOutputManualUrl")}),m.map(T=>r.jsx(Ds,{value:T.id,children:T.label},T.id))]})]}):null]})]})]})]}),r.jsxs(Gs,{className:"sm:justify-between",children:[k?r.jsx("span",{}):r.jsx(Q,{type:"button",size:"sm",variant:"ghost",className:"text-[var(--status-error)]",disabled:h,onClick:()=>{R(o)},children:t?.source==="shared"?a("settings.projects.actions.menu.deleteForEveryone"):a("settings.projects.actions.menu.delete")}),r.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row",children:[r.jsx(Q,{type:"button",size:"sm",variant:"outline",onClick:()=>s(!1),children:a("dialog.common.actions.cancel")}),r.jsx(Q,{type:"button",size:"sm",disabled:!I,onClick:()=>{P()},children:a("settings.projects.actionEditor.save")})]})]})]})})},uc=t=>{const e=W.c(3),{source:s}=t,{t:n}=se();let o;return e[0]!==s||e[1]!==n?(o=s==="shared"?r.jsx(Ko,{tone:"info",children:n("settings.projects.scope.team")}):r.jsx(eg,{children:n("settings.projects.scope.personal")}),e[0]=s,e[1]=n,e[2]=o):o=e[2],o},Wo=t=>{const e=W.c(18),{setupState:s}=t,{t:n}=se();if(s.load.state==="failed"){let i;e[0]!==n?(i=n("settings.projects.setup.loadFailed"),e[0]=n,e[1]=i):i=e[1];let l;e[2]!==i?(l=r.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:i}),e[2]=i,e[3]=l):l=e[3];let c;e[4]!==s?(c=()=>{s.reload()},e[4]=s,e[5]=c):c=e[5];let d;e[6]!==n?(d=n("settings.projects.setup.retry"),e[6]=n,e[7]=d):d=e[7];let u;e[8]!==c||e[9]!==d?(u=r.jsx(Q,{type:"button",size:"xs",variant:"outline",onClick:c,children:d}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let f;return e[11]!==l||e[12]!==u?(f=r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l,u]}),e[11]=l,e[12]=u,e[13]=f):f=e[13],f}let o;e[14]!==n?(o=n("settings.projects.actions.state.loading"),e[14]=n,e[15]=o):o=e[15];let a;return e[16]!==o?(a=r.jsx("p",{className:is,children:o}),e[16]=o,e[17]=a):a=e[17],a},mg=t=>{const e=W.c(66),{setup:s,setupState:n}=t,{t:o}=se(),{write:a,reload:i}=n,{confirm:l,dialog:c}=$o(),[d,u]=y.useState(null);let f,p,g,h,x,m;if(e[0]!==l||e[1]!==i||e[2]!==s||e[3]!==o||e[4]!==a){const N=rg(s);let j;e[11]!==s?(j=ac(s),e[11]=s,e[12]=j):j=e[12],g=j;let _;e[13]!==i||e[14]!==o?(_=async C=>(C||Y.error(o("settings.projects.actions.toast.saveFailed")),await i(),C),e[13]=i,e[14]=o,e[15]=_):_=e[15],p=_;let E;e[16]!==l||e[17]!==p||e[18]!==s||e[19]!==o||e[20]!==a?(E=async C=>C.source==="shared"&&!await l({title:o("settings.projects.actions.confirmDelete.title",{name:C.action.name}),message:o("settings.projects.actions.confirmDelete.message"),action:o("settings.projects.actions.menu.delete"),destructive:!0})?!1:p(await ig(s,a,C)),e[16]=l,e[17]=p,e[18]=s,e[19]=o,e[20]=a,e[21]=E):E=e[21],f=E;let L;e[22]!==f||e[23]!==p||e[24]!==s||e[25]!==g||e[26]!==o||e[27]!==a?(L=C=>{if(C.source==="personal")return[{label:o("settings.projects.actions.menu.delete"),icon:"delete-bin",destructive:!0,onSelect:()=>{f(C)}}];const O=[{label:C.hidden?o("settings.projects.actions.menu.show"):o("settings.projects.shared.actions.hide"),icon:C.hidden?"eye":"eye-off",onSelect:()=>{lg(s,a,C.action.id,!C.hidden).then(p)}}];return g&&O.push({label:o("settings.projects.actions.menu.deleteForEveryone"),icon:"delete-bin",destructive:!0,onSelect:()=>{f(C)}}),O},e[22]=f,e[23]=p,e[24]=s,e[25]=g,e[26]=o,e[27]=a,e[28]=L):L=e[28];const $=L;e[29]!==s.shared.path||e[30]!==s.shared.reason||e[31]!==s.shared.status||e[32]!==o?(m=s.shared.status==="invalid"?r.jsx("p",{className:"mb-3 typography-meta text-[var(--status-warning)]",children:o("settings.projects.shared.invalid",{path:s.shared.path,reason:s.shared.reason??""})}):null,e[29]=s.shared.path,e[30]=s.shared.reason,e[31]=s.shared.status,e[32]=o,e[33]=m):m=e[33],h="max-w-[44rem] divide-y divide-[var(--interactive-border)] overflow-hidden rounded-xl border border-[var(--interactive-border)]";let M;e[34]!==$||e[35]!==o?(M=C=>{const O=C.action.platforms??[];return r.jsxs("li",{className:"flex items-center gap-2 pe-2 transition-colors hover:bg-[var(--interactive-hover)]",children:[r.jsxs("button",{type:"button",onClick:()=>u({target:{action:C.action,source:C.source},entry:C}),className:"flex min-w-0 flex-1 items-center gap-3 py-2 ps-3 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[r.jsx(B,{name:oc(C.action.icon),className:ne("size-4 shrink-0 text-muted-foreground",C.hidden&&"opacity-60")}),r.jsxs("span",{className:ne("min-w-0 flex-1",C.hidden&&"opacity-60"),children:[r.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:C.action.name}),r.jsx("span",{className:"block truncate font-mono typography-micro text-muted-foreground",title:C.action.command,children:C.action.command})]}),O.length>0?r.jsx("span",{className:"hidden shrink-0 typography-micro text-muted-foreground @xl:inline",children:O.map(gg).join(", ")}):null,C.hidden?r.jsx(Ko,{tone:"neutral",children:o("settings.projects.actions.hiddenBadge")}):null,r.jsx(uc,{source:C.source})]}),r.jsxs(Ut,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground","aria-label":o("settings.projects.actions.menuAria"),children:r.jsx(B,{name:"more-2",className:"size-4"})})}),r.jsx(Vt,{align:"end",className:"w-fit min-w-40",children:$(C).map(xg)})]})]},`${C.source}:${C.action.id}`)},e[34]=$,e[35]=o,e[36]=M):M=e[36],x=N.map(M),e[0]=l,e[1]=i,e[2]=s,e[3]=o,e[4]=a,e[5]=f,e[6]=p,e[7]=g,e[8]=h,e[9]=x,e[10]=m}else f=e[5],p=e[6],g=e[7],h=e[8],x=e[9],m=e[10];let b;e[37]===Symbol.for("react.memo_cache_sentinel")?(b=()=>u({target:{action:null,source:"personal"},entry:null}),e[37]=b):b=e[37];let v;e[38]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(B,{name:"add",className:"size-4 shrink-0"}),e[38]=v):v=e[38];let w;e[39]!==o?(w=o("settings.projects.actions.new"),e[39]=o,e[40]=w):w=e[40];let S;e[41]!==w?(S=r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:b,className:"flex w-full items-center gap-3 py-2.5 ps-3 text-start typography-ui-label text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[v,w]})}),e[41]=w,e[42]=S):S=e[42];let I;e[43]!==h||e[44]!==x||e[45]!==S?(I=r.jsxs("ul",{className:h,children:[x,S]}),e[43]=h,e[44]=x,e[45]=S,e[46]=I):I=e[46];const k=d?.target??null;let R;e[47]===Symbol.for("react.memo_cache_sentinel")?(R=N=>{N||u(null)},e[47]=R):R=e[47];let P;e[48]!==d?.entry?.source||e[49]!==p||e[50]!==s||e[51]!==a?(P=async(N,j)=>p(await ag(s,a,N,d?.entry?.source??null,j)),e[48]=d?.entry?.source,e[49]=p,e[50]=s,e[51]=a,e[52]=P):P=e[52];let T;e[53]!==d||e[54]!==f?(T=async()=>d?.entry?f(d.entry):!1,e[53]=d,e[54]=f,e[55]=T):T=e[55];let D;e[56]!==g||e[57]!==P||e[58]!==T||e[59]!==k?(D=r.jsx(pg,{target:k,canShare:g,onOpenChange:R,onSave:P,onDelete:T}),e[56]=g,e[57]=P,e[58]=T,e[59]=k,e[60]=D):D=e[60];let A;return e[61]!==c||e[62]!==D||e[63]!==m||e[64]!==I?(A=r.jsxs(r.Fragment,{children:[m,I,D,c]}),e[61]=c,e[62]=D,e[63]=m,e[64]=I,e[65]=A):A=e[65],A},hg=t=>{const e=W.c(10),{setupState:s}=t,{t:n}=se();let o;e[0]!==n?(o=n("settings.projects.actions.title"),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==n?(a=n("settings.projects.actions.info"),e[2]=n,e[3]=a):a=e[3];let i;e[4]!==s?(i=s.load.state==="ready"?r.jsx(mg,{setup:s.load.setup,setupState:s}):r.jsx(Wo,{setupState:s}),e[4]=s,e[5]=i):i=e[5];let l;return e[6]!==o||e[7]!==a||e[8]!==i?(l=r.jsx(Bs,{title:o,info:a,settingsItem:"projects.actions",divider:!1,children:i}),e[6]=o,e[7]=a,e[8]=i,e[9]=l):l=e[9],l};function gg(t){return So.find(e=>e.value===t)?.label??t}function xg(t){return r.jsxs(lt,{variant:t.destructive?"destructive":"default",onClick:t.onSelect,children:[t.icon?r.jsx(B,{name:t.icon,className:"size-4"}):null,t.label]},t.label)}const bg=/^[A-Za-z_][A-Za-z0-9_]*$/,fc=zt({names:Bo(nt())}),yg=Tm("state",[zt({state:Sr("applied"),count:jr()}),zt({state:Sr("failed"),reason:nt(),exitCode:jr().nullable().optional()})]),qo=zt({names:Bo(nt()),command:nt().nullable(),status:yg.nullable()}),zn=async(t,e,s)=>{if(!t.ok){const n=await t.json().catch(()=>null),o=zt({error:nt()}).safeParse(n);throw new Error(o.success?o.data.error:`${s}: ${t.status}`)}return e.parse(await t.json())},pc={"Content-Type":"application/json",Accept:"application/json"},mc=t=>({method:"PUT",headers:pc,body:JSON.stringify(t)}),Ho=t=>`/api/environment/projects/${encodeURIComponent(t)}`,Cw=async()=>zn(await wt("/api/environment",{headers:{Accept:"application/json"}}),fc,"Failed to read environment variables"),Iw=async t=>zn(await wt("/api/environment",mc({variables:t})),fc,"Failed to save environment variables"),vg=async t=>zn(await wt(Ho(t),{headers:{Accept:"application/json"}}),qo,"Failed to read project environment"),wg=async(t,e)=>zn(await wt(Ho(t),mc(e)),qo,"Failed to save project environment"),Ga=async t=>zn(await wt(`${Ho(t)}/reload`,{method:"POST",headers:pc}),qo,"Failed to run the environment command"),Sg=({names:t,disabled:e=!1,onSet:s,onRemove:n})=>{const{t:o}=se(),[a,i]=y.useState(""),[l,c]=y.useState(""),[d,u]=y.useState(null),[f,p]=y.useState(""),[g,h]=y.useState(!1),x=a.trim(),m=x.length>0&&!bg.test(x),b=e||g,v=async k=>{h(!0);try{return await k()}finally{h(!1)}},w=async()=>{!x||m||await v(()=>s(x,l))&&(i(""),c(""))},S=async k=>{await v(()=>s(k,f))&&(u(null),p(""))},I=()=>{u(null),p("")};return r.jsxs("div",{className:"space-y-3",children:[t.length===0?r.jsx("p",{className:is,children:o("settings.environment.editor.empty")}):r.jsx("ul",{className:"w-full max-w-[32rem] space-y-1",children:t.map(k=>r.jsxs("li",{className:"flex min-h-8 flex-wrap items-center gap-2",children:[r.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-foreground",children:k}),d===k?r.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-2",onSubmit:R=>{R.preventDefault(),S(k)},children:[r.jsx(It,{type:"password",autoFocus:!0,value:f,onChange:R=>p(R.target.value),placeholder:o("settings.environment.editor.newValuePlaceholder"),"aria-label":o("settings.environment.editor.newValueAria",{name:k}),disabled:b,className:"h-8 min-w-0 max-w-[16rem] flex-1 font-mono text-xs"}),r.jsx(Q,{type:"submit",size:"xs",disabled:b,className:"shrink-0 !font-normal",children:o("settings.environment.editor.save")}),r.jsx(Q,{type:"button",variant:"ghost",size:"xs",onClick:I,disabled:g,className:"shrink-0 !font-normal",children:o("settings.common.actions.cancel")})]}):r.jsxs("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:[r.jsx(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>{u(k),p("")},disabled:b,className:ha,"aria-label":o("settings.environment.editor.replaceAria",{name:k}),title:o("settings.environment.editor.replace"),children:r.jsx(B,{name:"pencil",className:"h-3.5 w-3.5"})}),r.jsx(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>{v(()=>n(k))},disabled:b,className:ha,"aria-label":o("settings.environment.editor.removeAria",{name:k}),title:o("settings.environment.editor.remove"),children:r.jsx(B,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]},k))}),r.jsxs("form",{className:"space-y-1.5",onSubmit:k=>{k.preventDefault(),w()},children:[r.jsxs("div",{className:"flex w-full max-w-[32rem] flex-wrap items-center gap-2",children:[r.jsx(It,{value:a,onChange:k=>i(k.target.value),placeholder:"NAME","aria-label":o("settings.environment.editor.nameAria"),"aria-invalid":m||void 0,disabled:b,className:"h-8 w-40 font-mono text-xs"}),r.jsx(It,{type:"password",value:l,onChange:k=>c(k.target.value),placeholder:o("settings.environment.editor.valuePlaceholder"),"aria-label":o("settings.environment.editor.valueAria"),disabled:b,className:"h-8 min-w-0 flex-1 font-mono text-xs"}),r.jsxs(Q,{type:"submit",variant:"outline",size:"xs",disabled:b||!x||m,className:"shrink-0 !font-normal",children:[r.jsx(B,{name:"add",className:"h-3.5 w-3.5"}),o("settings.environment.editor.add")]})]}),m?r.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:o("settings.environment.editor.invalidName")}):null]})]})},jg=t=>{switch(t){case"timeout":return"settings.projects.environment.status.timeout";case"unrecognized-output":return"settings.projects.environment.status.unrecognizedOutput";case"spawn":return"settings.projects.environment.status.spawn";case"output-too-large":return"settings.projects.environment.status.outputTooLarge";default:return"settings.projects.environment.status.failed"}},Ng=t=>{const e=W.c(9),{t:s}=se();if(!t)return null;if(t.state==="applied"){let o;return e[0]!==t.count||e[1]!==s?(o=t.count===1?s("settings.projects.environment.status.appliedSingle"):s("settings.projects.environment.status.appliedPlural",{count:t.count}),e[0]=t.count,e[1]=s,e[2]=o):o=e[2],o}if(t.reason==="exit"){let o;return e[3]!==t.exitCode||e[4]!==s?(o=t.exitCode===null||t.exitCode===void 0?s("settings.projects.environment.status.stopped"):s("settings.projects.environment.status.exitCode",{code:t.exitCode}),e[3]=t.exitCode,e[4]=s,e[5]=o):o=e[5],o}let n;return e[6]!==t.reason||e[7]!==s?(n=s(jg(t.reason)),e[6]=t.reason,e[7]=s,e[8]=n):n=e[8],n},kg=({projectRef:t})=>{const{t:e}=se(),[s,n]=y.useState({state:"loading"}),[o,a]=y.useState(""),[i,l]=y.useState(!1),c=y.useCallback(b=>{n({state:"ready",environment:b}),a(b.command??"")},[]);y.useEffect(()=>{let b=!1;return n({state:"loading"}),vg(t.id).then(v=>{b||c(v)}).catch(()=>{b||n({state:"failed"})}),()=>{b=!0}},[c,t.id]);const d=y.useCallback(async b=>{Ht("saving");try{return c(await wg(t.id,b)),Ht("saved"),!0}catch{return Ht("error"),Y.error(e("settings.environment.editor.saveFailed")),!1}},[c,t.id,e]),u=s.state==="ready"?s.environment.command??"":"",f=o.trim()!==u,p=async()=>{l(!0);try{await d({command:o.trim()||null})&&o.trim()&&c(await Ga(t.id))}catch{Y.error(e("settings.projects.environment.runFailed"))}finally{l(!1)}},g=async()=>{l(!0);try{c(await Ga(t.id))}catch{Y.error(e("settings.projects.environment.runFailed"))}finally{l(!1)}},h=s.state==="ready"?s.environment.status:null,x=Ng(h),m=s.state!=="ready"||i;return r.jsx(Bs,{divider:!1,title:e("settings.projects.environment.title"),info:e("settings.projects.environment.info"),settingsItem:"projects.environment",children:s.state==="failed"?r.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("settings.environment.editor.loadFailed")}):r.jsxs("div",{className:"space-y-6",children:[r.jsx(Sg,{names:s.state==="ready"?s.environment.names:[],disabled:s.state!=="ready",onSet:(b,v)=>d({variables:{[b]:v}}),onRemove:b=>d({variables:{[b]:null}})}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:uo,children:e("settings.projects.environment.command.label")}),r.jsx(Ji,{children:e("settings.projects.environment.command.info")})]}),r.jsxs("form",{className:"flex w-full max-w-[32rem] flex-wrap items-center gap-2",onSubmit:b=>{b.preventDefault(),p()},children:[r.jsx(It,{value:o,onChange:b=>a(b.target.value),placeholder:"direnv export json","aria-label":e("settings.projects.environment.command.label"),disabled:m,className:"h-8 min-w-0 flex-1 font-mono text-xs"}),f?r.jsx(Q,{type:"submit",size:"xs",disabled:m,className:"shrink-0 !font-normal",children:e("settings.environment.editor.save")}):u?r.jsx(Q,{type:"button",variant:"outline",size:"xs",onClick:()=>{g()},disabled:m,className:"shrink-0 !font-normal",children:e("settings.projects.environment.command.runAgain")}):null]}),u&&x?r.jsx("p",{className:h?.state==="failed"?"typography-meta text-[var(--status-error)]":is,children:x}):null]})]})})},Jr="__default__",hc=t=>t.charAt(0).toUpperCase()+t.slice(1),Cg=t=>{const e=W.c(43),{form:s}=t,{t:n}=se();let o;e[0]!==s.project?.path?(o=k=>qd(k,s.project?.path),e[0]=s.project?.path,e[1]=o):o=e[1];const a=Ot(o),{parsedDefaultModel:i,defaultVariant:l}=s;let c;e:{const{providerId:k,modelId:R}=i;if(!k||!R){let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T=[],e[2]=T):T=e[2],c=T;break e}let P;if(e[3]!==R||e[4]!==k||e[5]!==a){const T=a.find(D=>D.id===k)?.models.find(D=>D.id===R);P=zd(T),e[3]=R,e[4]=k,e[5]=a,e[6]=P}else P=e[6];c=P}const d=c;if(!s.project)return null;let u;e[7]!==n?(u=n("settings.projects.page.section.chatDefaults"),e[7]=n,e[8]=u):u=e[8];let f;e[9]!==n?(f=n("settings.projects.page.section.chatDefaultsDescription"),e[9]=n,e[10]=f):f=e[10];let p;e[11]!==n?(p=n("settings.projects.page.field.projectAgent"),e[11]=n,e[12]=p):p=e[12];const g=s.defaultAgent||"";let h;e[13]!==s?(h=k=>s.setDefaultAgent(k||void 0),e[13]=s,e[14]=h):h=e[14];let x;e[15]!==s.project.path||e[16]!==g||e[17]!==h?(x=r.jsx(Ui,{directory:s.project.path,agentName:g,onChange:h,filter:Rg,className:ga}),e[15]=s.project.path,e[16]=g,e[17]=h,e[18]=x):x=e[18];let m;e[19]!==p||e[20]!==x?(m=r.jsx(fr,{settingsItem:"projects.default-agent",label:p,children:x}),e[19]=p,e[20]=x,e[21]=m):m=e[21];let b;e[22]!==n?(b=n("settings.projects.page.field.projectModel"),e[22]=n,e[23]=b):b=e[23];let v;e[24]!==s.handleDefaultModelChange||e[25]!==s.project.path||e[26]!==i.modelId||e[27]!==i.providerId?(v=r.jsx(Vi,{directory:s.project.path,providerId:i.providerId,modelId:i.modelId,onChange:s.handleDefaultModelChange,className:ga}),e[24]=s.handleDefaultModelChange,e[25]=s.project.path,e[26]=i.modelId,e[27]=i.providerId,e[28]=v):v=e[28];let w;e[29]!==b||e[30]!==v?(w=r.jsx(fr,{settingsItem:"projects.default-model",label:b,children:v}),e[29]=b,e[30]=v,e[31]=w):w=e[31];let S;e[32]!==d||e[33]!==l||e[34]!==s||e[35]!==n?(S=d.length>0?r.jsx(fr,{settingsItem:"projects.default-thinking",label:n("settings.projects.page.field.projectThinking"),children:r.jsxs(hn,{value:l??Jr,onValueChange:k=>s.handleDefaultVariantChange(k===Jr?void 0:k),children:[r.jsx(gn,{className:Kd,"aria-label":n("settings.projects.page.field.projectThinking"),children:r.jsx(Dn,{children:l?hc(l):n("settings.projects.page.option.thinkingDefault")})}),r.jsxs(xn,{children:[r.jsx(Ds,{value:Jr,children:n("settings.projects.page.option.thinkingDefault")}),d.map(Eg)]})]})}):null,e[32]=d,e[33]=l,e[34]=s,e[35]=n,e[36]=S):S=e[36];let I;return e[37]!==w||e[38]!==S||e[39]!==u||e[40]!==f||e[41]!==m?(I=r.jsxs(Bs,{title:u,info:f,divider:!1,contentClassName:"space-y-0",children:[m,w,S]}),e[37]=w,e[38]=S,e[39]=u,e[40]=f,e[41]=m,e[42]=I):I=e[42],I},Ig=({projectRef:t,setupState:e})=>{const{t:s}=se(),{load:n,reload:o}=e,a=n.state==="ready"?n.setup:null,[i,l]=y.useState(""),[c,d]=y.useState(!1),u=a?.shared.plansDir??"";y.useEffect(()=>l(u),[u]);const f=async()=>{const h=i.trim();if(h!==u){d(!0);try{if(!await fo(t,{plansDir:h||null})){Y.error(s("settings.projects.shared.toast.shareFailed")),l(u);return}await o()}finally{d(!1)}}},p=async()=>{if(a){d(!0);try{await Wd(t,a),await o()}finally{d(!1)}}},g=async()=>{d(!0);try{await Gd(t)||Y.error(s("settings.projects.shared.toast.shareFailed")),await o()}finally{d(!1)}};return r.jsx(Bs,{title:s("settings.projects.team.title"),settingsItem:"projects.shared",contentClassName:"space-y-5",children:a?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:ne("max-w-[40rem]",a.shared.status==="invalid"?"typography-meta text-[var(--status-warning)]":is),children:a.shared.status==="invalid"?s("settings.projects.shared.invalid",{path:a.shared.path,reason:a.shared.reason??""}):a.shared.status==="ok"?s("settings.projects.team.description.ok",{path:a.shared.path}):s("settings.projects.team.description.missing",{path:a.shared.path})}),a.trust.hash!==null?r.jsxs("div",{className:ne("flex max-w-[40rem] items-center gap-3 rounded-lg p-3",a.trust.trusted?"oc-tile":"bg-[var(--status-warning)]/10"),children:[r.jsx(B,{name:a.trust.trusted?"shield-check":"error-warning",className:ne("size-4 shrink-0",a.trust.trusted?"text-[var(--status-success)]":"text-[var(--status-warning)]")}),r.jsx("p",{className:"min-w-0 flex-1 typography-meta text-foreground",children:a.trust.trusted?s("settings.projects.team.trust.allowed"):s("settings.projects.team.trust.waiting")}),a.trust.trusted?r.jsx(Q,{type:"button",size:"xs",variant:"ghost",className:"shrink-0 !font-normal",disabled:c,onClick:()=>{g()},children:s("settings.projects.team.trust.revoke")}):r.jsx(Q,{type:"button",size:"xs",variant:"outline",className:"shrink-0",disabled:c,onClick:()=>{p()},children:s("settings.projects.team.trust.review")})]}):null,r.jsx(fr,{label:s("settings.projects.shared.plansDir"),info:s("settings.projects.shared.plansDirInfo"),settingsItem:"projects.shared.plansDir",children:r.jsx(It,{value:i,onChange:h=>l(h.target.value),onBlur:()=>{f()},onKeyDown:h=>{h.key==="Enter"&&h.currentTarget.blur()},placeholder:s("settings.projects.shared.plansDirPlaceholder"),"aria-label":s("settings.projects.shared.plansDirAria"),disabled:c||a.shared.status==="invalid",className:"h-8 rounded-md px-3 font-mono text-xs"})})]}):r.jsx(Wo,{setupState:e})})},Tg=t=>{const e=W.c(8),{form:s,projectRef:n,setupState:o}=t;let a;e[0]!==s?(a=r.jsx(Cg,{form:s}),e[0]=s,e[1]=a):a=e[1];let i;e[2]!==n||e[3]!==o?(i=r.jsx(Ig,{projectRef:n,setupState:o}),e[2]=n,e[3]=o,e[4]=i):i=e[4];let l;return e[5]!==a||e[6]!==i?(l=r.jsxs(r.Fragment,{children:[a,i]}),e[5]=a,e[6]=i,e[7]=l):l=e[7],l};function Rg(t){return Ki(t.mode)}function Eg(t){return r.jsx(Ds,{value:t,children:hc(t)},t)}const gc=t=>{const e=W.c(23),{form:s,className:n}=t,{currentTheme:o}=Qi(),{project:a}=s;if(!a)return null;if(s.effectiveHasImageIcon&&s.showImagePreview){let g;e[0]!==n?(g=ne("inline-flex items-center justify-center overflow-hidden rounded-[4px]",n),e[0]=n,e[1]=g):g=e[1];let h;e[2]!==s.iconBackground?(h=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[2]=s.iconBackground,e[3]=h):h=e[3];let x;e[4]!==o||e[5]!==s||e[6]!==a?(x=s.hasPendingUploadImageIcon&&s.pendingUploadIconPreviewUrl?r.jsx("img",{src:s.pendingUploadIconPreviewUrl,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>s.setPreviewImageFailed(!0)}):r.jsx(Hd,{project:{...a,iconImage:s.currentIconImage??a.iconImage},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>s.setPreviewImageFailed(!0)}),e[4]=o,e[5]=s,e[6]=a,e[7]=x):x=e[7];let m;return e[8]!==g||e[9]!==h||e[10]!==x?(m=r.jsx("span",{className:g,style:h,children:x}),e[8]=g,e[9]=h,e[10]=x,e[11]=m):m=e[11],m}let i;e[12]!==s.color?(i=Zi(s.color),e[12]=s.color,e[13]=i):i=e[13];const l=i,c=(s.icon?Yd[s.icon]:null)??"folder",d=!l&&"text-muted-foreground";let u;e[14]!==n||e[15]!==d?(u=ne(n,d),e[14]=n,e[15]=d,e[16]=u):u=e[16];let f;e[17]!==l?(f=l?{color:l}:void 0,e[17]=l,e[18]=f):f=e[18];let p;return e[19]!==c||e[20]!==u||e[21]!==f?(p=r.jsx(B,{name:c,className:u,style:f}),e[19]=c,e[20]=u,e[21]=f,e[22]=p):p=e[22],p},Dg="flex h-8 w-8 items-center justify-center rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",Pg=t=>{const e=W.c(66),{form:s,onUploadClick:n}=t,{t:o}=se(),[a,i]=y.useState(s.effectiveHasImageIcon?"image":"symbol");let l;e[0]!==s.color?(l=s.color&&!Tn(s.color)?Zi(s.color):null,e[0]=s.color,e[1]=l):l=e[1];const c=l;let d;e[2]!==s?(d=O=>{const z=O||null;s.setColor(z),s.setIconBackground(Xd(z))},e[2]=s,e[3]=d):d=e[3];const u=d;let f;e[4]!==s?(f=O=>{s.setIcon(O),s.effectiveHasImageIcon&&s.handleRemoveImageIcon()},e[4]=s,e[5]=f):f=e[5];const p=f;let g;e[6]!==o?(g=o("settings.projects.appearance.color"),e[6]=o,e[7]=g):g=e[7];let h;e[8]!==g?(h=r.jsx("div",{className:uo,children:g}),e[8]=g,e[9]=h):h=e[9];const x=s.color??"";let m;e[10]!==o?(m=o("settings.projects.appearance.colorNone"),e[10]=o,e[11]=m):m=e[11];let b,v;e[12]!==o?(b=O=>o("settings.projects.appearance.colorSwatchAria",{color:O}),v=o("settings.projects.appearance.colorCustomAria"),e[12]=o,e[13]=b,e[14]=v):(b=e[13],v=e[14]);let w;e[15]!==o?(w=o("settings.projects.appearance.colorHexAria"),e[15]=o,e[16]=w):w=e[16];let S;e[17]!==w||e[18]!==m||e[19]!==b||e[20]!==v?(S={empty:m,swatch:b,custom:v,hex:w},e[17]=w,e[18]=m,e[19]=b,e[20]=v,e[21]=S):S=e[21];let I;e[22]!==c||e[23]!==u||e[24]!==S||e[25]!==x?(I=r.jsx(Hh,{value:x,onChange:u,legacyCss:c,labels:S}),e[22]=c,e[23]=u,e[24]=S,e[25]=x,e[26]=I):I=e[26];let k;e[27]!==I||e[28]!==h?(k=r.jsxs("div",{className:"space-y-2",children:[h,I]}),e[27]=I,e[28]=h,e[29]=k):k=e[29];let R;e[30]!==o?(R=o("settings.projects.appearance.icon"),e[30]=o,e[31]=R):R=e[31];let P;e[32]!==R?(P=r.jsx("div",{className:uo,children:R}),e[32]=R,e[33]=P):P=e[33];let T;e[34]!==o?(T=o("settings.projects.appearance.icon"),e[34]=o,e[35]=T):T=e[35];let D;e[36]!==o?(D=o("settings.projects.appearance.mode.symbol"),e[36]=o,e[37]=D):D=e[37];let A;e[38]!==D?(A={value:"symbol",label:D},e[38]=D,e[39]=A):A=e[39];let N;e[40]!==o?(N=o("settings.projects.appearance.mode.image"),e[40]=o,e[41]=N):N=e[41];let j;e[42]!==N?(j={value:"image",label:N},e[42]=N,e[43]=j):j=e[43];let _;e[44]!==A||e[45]!==j?(_=[A,j],e[44]=A,e[45]=j,e[46]=_):_=e[46];let E;e[47]!==a||e[48]!==T||e[49]!==_?(E=r.jsx(co,{value:a,onChange:i,"aria-label":T,options:_}),e[47]=a,e[48]=T,e[49]=_,e[50]=E):E=e[50];let L;e[51]!==P||e[52]!==E?(L=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[P,E]}),e[51]=P,e[52]=E,e[53]=L):L=e[53];let $;e[54]!==s||e[55]!==a||e[56]!==n||e[57]!==p||e[58]!==o?($=a==="symbol"?r.jsx("div",{className:"grid grid-cols-8 gap-1",children:[{key:null,Icon:"folder",label:o("settings.projects.appearance.symbolNone")},...Jd].map(O=>{const z=!s.effectiveHasImageIcon&&s.icon===O.key;return r.jsx("button",{type:"button",onClick:()=>p(O.key),"aria-pressed":z,"aria-label":O.label,title:O.label,className:ne(Dg,z?"bg-interactive-selection text-interactive-selection-foreground":"text-foreground hover:bg-[var(--interactive-hover)]"),children:r.jsx(B,{name:O.Icon,className:"h-4 w-4"})},O.key??"none")})}):r.jsxs("div",{className:"space-y-3",children:[s.effectiveHasImageIcon?r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"flex h-12 w-12 shrink-0 items-center justify-center oc-tile-inset rounded-xl",children:r.jsx(gc,{form:s,className:"h-7 w-7"})}),r.jsx("p",{className:is,children:o("settings.projects.appearance.imageColorHint")})]}):r.jsx("p",{className:is,children:o("settings.projects.appearance.imageEmpty")}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.hasCustomIcon?null:r.jsxs(r.Fragment,{children:[r.jsx(Q,{type:"button",size:"sm",variant:"outline",onClick:n,disabled:s.isUploadingIcon,children:s.isUploadingIcon?o("settings.projects.page.actions.uploading"):o("settings.projects.page.actions.uploadIcon")}),r.jsx(Q,{type:"button",size:"sm",variant:"outline",onClick:()=>{s.handleDiscoverIcon()},disabled:s.isDiscoveringIcon,children:s.isDiscoveringIcon?o("settings.projects.page.actions.discovering"):o("settings.projects.page.actions.discoverFavicon")})]}),s.hasRemovableImageIcon?r.jsx(Q,{type:"button",size:"sm",variant:"ghost",className:"text-[var(--status-error)]",onClick:s.handleRemoveImageIcon,disabled:s.isRemovingCustomIcon,children:s.isRemovingCustomIcon?o("settings.projects.page.actions.removing"):o("settings.projects.page.actions.removeProjectIcon")}):null]})]}),e[54]=s,e[55]=a,e[56]=n,e[57]=p,e[58]=o,e[59]=$):$=e[59];let M;e[60]!==L||e[61]!==$?(M=r.jsxs("div",{className:"space-y-2",children:[L,$]}),e[60]=L,e[61]=$,e[62]=M):M=e[62];let C;return e[63]!==k||e[64]!==M?(C=r.jsxs("div",{className:"space-y-4",children:[k,M]}),e[63]=k,e[64]=M,e[65]=C):C=e[65],C},Ag=({form:t})=>{const{t:e}=se(),s=t.fileInputRef,[n,o]=y.useState(null),a=i=>{const l=i instanceof HTMLElement?i.closest('[data-slot="dialog-content"], [role="dialog"]'):null;o(l instanceof HTMLElement?l:null)};return t.project?r.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[r.jsx("input",{ref:s,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:i=>{const l=i.target.files?.[0]??null;t.handleUploadIcon(l),i.currentTarget.value=""}}),r.jsxs(Ml,{children:[r.jsxs(Ol,{"data-settings-item":"projects.icon","aria-label":e("settings.projects.header.appearanceAria"),title:e("settings.projects.header.appearanceAria"),onPointerDownCapture:i=>a(i.currentTarget),onFocusCapture:i=>a(i.currentTarget),className:"relative flex h-12 w-12 shrink-0 items-center justify-center oc-tile-inset rounded-xl hover:bg-[var(--interactive-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] data-[popup-open]:bg-interactive-selection",children:[r.jsx(gc,{form:t,className:"h-6 w-6"}),r.jsx("span",{"aria-hidden":"true",className:"absolute -bottom-1 -end-1 flex h-[18px] w-[18px] items-center justify-center rounded-full border border-[var(--interactive-border)] bg-background text-muted-foreground",children:r.jsx(B,{name:"pencil",className:"h-2.5 w-2.5"})})]}),r.jsx(Fl,{container:n??void 0,children:r.jsx(Bl,{side:"bottom",align:"start",sideOffset:6,className:"z-[120]",children:r.jsx(Vl,{"aria-label":e("settings.projects.header.appearanceAria"),className:ne(Xi,"w-[22.5rem] max-w-[calc(100vw-2rem)] p-3"),children:r.jsx(Pg,{form:t,onUploadClick:()=>s.current?.click()})})})})]}),r.jsxs("div",{className:"min-w-0 flex-1 space-y-0.5",children:[r.jsx(It,{"data-settings-item":"projects.name",inputSize:"compact",value:t.name,onChange:i=>t.setName(i.target.value),placeholder:e("settings.projects.page.field.projectNamePlaceholder"),"aria-label":e("settings.projects.page.field.projectName"),className:"-ms-2 w-full max-w-[24rem] bg-transparent px-2 [&:not(:hover):not(:focus)]:shadow-none typography-settings-section-title md:typography-settings-section-title"}),r.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:t.project.path,children:t.project.path})]})]}):null},Wa=t=>{const e=W.c(18),{value:s,disabled:n,autoFocus:o,placeholder:a,ariaLabel:i,onCommit:l}=t,[c,d]=y.useState(s);let u,f;e[0]!==s?(u=()=>d(s),f=[s],e[0]=s,e[1]=u,e[2]=f):(u=e[1],f=e[2]),y.useEffect(u,f);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=m=>d(m.target.value),e[3]=p):p=e[3];let g;e[4]!==c||e[5]!==l||e[6]!==s?(g=()=>{c.trim()!==s&&l(c)},e[4]=c,e[5]=l,e[6]=s,e[7]=g):g=e[7];let h;e[8]!==s?(h=m=>{m.key==="Enter"&&m.currentTarget.blur(),m.key==="Escape"&&(d(s),m.currentTarget.blur())},e[8]=s,e[9]=h):h=e[9];let x;return e[10]!==i||e[11]!==o||e[12]!==n||e[13]!==c||e[14]!==a||e[15]!==g||e[16]!==h?(x=r.jsx(It,{value:c,disabled:n,autoFocus:o,placeholder:a,"aria-label":i,onChange:p,onBlur:g,onKeyDown:h,className:"min-w-0 flex-1 font-mono text-xs"}),e[10]=i,e[11]=o,e[12]=n,e[13]=c,e[14]=a,e[15]=g,e[16]=h,e[17]=x):x=e[17],x},_g=t=>{const e=W.c(45),{projectRef:s,setup:n,setupState:o}=t,{t:a}=se(),{write:i,reload:l}=o,[c,d]=y.useState(!1),[u,f]=y.useState(n.setupWorktreeWait);let p,g;e[0]!==n.setupWorktreeWait?(p=()=>f(n.setupWorktreeWait),g=[n.setupWorktreeWait],e[0]=n.setupWorktreeWait,e[1]=p,e[2]=g):(p=e[1],g=e[2]),y.useEffect(p,g);let h,x,m,b;if(e[3]!==l||e[4]!==n||e[5]!==a||e[6]!==i){const T=cg(n);let D;e[11]!==n?(D=ac(n),e[11]=n,e[12]=D):D=e[12];const A=D;h=n.personal.setupWorktreeMode==="replace";let N;e[13]!==l||e[14]!==a?(N=async j=>{j||Y.error(a("settings.openchamber.worktrees.setup.toast.saveFailed")),await l()},e[13]=l,e[14]=a,e[15]=N):N=e[15],x=N,m="space-y-4",b=T.length>0?r.jsx("ol",{className:"max-w-[40rem] space-y-1.5",children:T.map((j,_)=>{const E=j.source==="personal"||A;return r.jsxs("li",{className:ne("flex items-center gap-2",j.skipped&&"opacity-60"),children:[r.jsx("span",{className:"w-4 shrink-0 text-end typography-meta tabular-nums text-muted-foreground",children:_+1}),r.jsx(Wa,{value:j.command,disabled:!E,ariaLabel:a("settings.projects.worktrees.commandAria",{position:_+1}),onCommit:L=>{cc(n,i,j,L).then(x)}}),j.skipped?r.jsx(Ko,{tone:"neutral",children:a("settings.projects.worktrees.skipped")}):r.jsx(uc,{source:j.source}),r.jsxs(Ut,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground","aria-label":a("settings.projects.worktrees.commandMenuAria"),disabled:!E,children:r.jsx(B,{name:"more-2",className:"size-4"})})}),r.jsxs(Vt,{align:"end",className:"w-fit min-w-40",children:[A?r.jsx(lt,{onClick:()=>{ug(n,i,j).then(x)},children:j.source==="shared"?a("settings.projects.shared.actions.makePersonal"):a("settings.projects.shared.actions.share")}):null,r.jsx(lt,{variant:"destructive",onClick:()=>{dc(n,i,j).then(x)},children:j.source==="shared"?a("settings.projects.worktrees.removeForEveryone"):a("settings.openchamber.worktrees.setup.removeCommandAria")})]})]})]},`${j.source}:${j.index}:${j.command}`)})}):null,e[3]=l,e[4]=n,e[5]=a,e[6]=i,e[7]=h,e[8]=x,e[9]=m,e[10]=b}else h=e[7],x=e[8],m=e[9],b=e[10];let v;e[16]!==c||e[17]!==x||e[18]!==n||e[19]!==a||e[20]!==i?(v=c?r.jsx("div",{className:"flex max-w-[40rem] items-center gap-2 ps-6",children:r.jsx(Wa,{value:"",autoFocus:!0,placeholder:a("settings.openchamber.worktrees.setup.commandPlaceholder"),ariaLabel:a("settings.openchamber.worktrees.setup.addCommand"),onCommit:T=>{d(!1),T.trim()&&dg(n,i,T).then(x)}})}):r.jsxs(Q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>d(!0),children:[r.jsx(B,{name:"add",className:"h-3.5 w-3.5"}),a("settings.openchamber.worktrees.setup.addCommand")]}),e[16]=c,e[17]=x,e[18]=n,e[19]=a,e[20]=i,e[21]=v):v=e[21];let w;e[22]!==s||e[23]!==h||e[24]!==x||e[25]!==n.shared.setupWorktree.length||e[26]!==a?(w=n.shared.setupWorktree.length>0?r.jsx(yr,{settingsItem:"projects.worktree.setup.replace",checked:h,onChange:T=>{pr(s,{setupWorktreeMode:T?"replace":"append"}).then(x)},label:a("settings.projects.shared.replaceMode")}):null,e[22]=s,e[23]=h,e[24]=x,e[25]=n.shared.setupWorktree.length,e[26]=a,e[27]=w):w=e[27];let S;e[28]!==s||e[29]!==x?(S=T=>{f(T),Qd(s,T).then(x)},e[28]=s,e[29]=x,e[30]=S):S=e[30];let I;e[31]!==a?(I=a("settings.openchamber.worktrees.setup.waitForCommands"),e[31]=a,e[32]=I):I=e[32];let k;e[33]!==S||e[34]!==I||e[35]!==u?(k=r.jsx(yr,{settingsItem:"projects.worktree.setup.wait",checked:u,onChange:S,label:I}),e[33]=S,e[34]=I,e[35]=u,e[36]=k):k=e[36];let R;e[37]!==w||e[38]!==k?(R=r.jsxs("div",{className:Zd,children:[w,k]}),e[37]=w,e[38]=k,e[39]=R):R=e[39];let P;return e[40]!==R||e[41]!==m||e[42]!==b||e[43]!==v?(P=r.jsxs("div",{className:m,children:[b,v,R]}),e[40]=R,e[41]=m,e[42]=b,e[43]=v,e[44]=P):P=e[44],P},Lg=t=>{const e=W.c(35),{projectRef:s,setupState:n,onOpenWorktrees:o}=t,{t:a}=se(),[i,l]=y.useState(null);let c,d;if(e[0]!==s.path?(c=()=>{let w=!1;return l(null),eu(s.path).then(S=>{w||l(S)}).catch($g),()=>{w=!0}},d=[s.path],e[0]=s.path,e[1]=c,e[2]=d):(c=e[1],d=e[2]),y.useEffect(c,d),i===!1){let w;e[3]!==a?(w=a("settings.openchamber.worktrees.setup.title"),e[3]=a,e[4]=w):w=e[4];let S;e[5]!==a?(S=a("settings.openchamber.worktrees.state.gitOnly"),e[5]=a,e[6]=S):S=e[6];let I;e[7]!==S?(I=r.jsx("p",{className:is,children:S}),e[7]=S,e[8]=I):I=e[8];let k;return e[9]!==w||e[10]!==I?(k=r.jsx(Bs,{title:w,settingsItem:"projects.worktree",divider:!1,children:I}),e[9]=w,e[10]=I,e[11]=k):k=e[11],k}let u;e[12]!==a?(u=a("settings.openchamber.worktrees.setup.title"),e[12]=a,e[13]=u):u=e[13];let f;e[14]!==a?(f=a("settings.openchamber.worktrees.setup.tooltipPrefix"),e[14]=a,e[15]=f):f=e[15];let p;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("code",{className:"rounded bg-sidebar-accent/50 px-1 font-mono text-xs",children:"$ROOT_PROJECT_PATH"}),e[16]=p):p=e[16];let g;e[17]!==a?(g=a("settings.openchamber.worktrees.setup.tooltipSuffix"),e[17]=a,e[18]=g):g=e[18];let h;e[19]!==f||e[20]!==g?(h=r.jsxs(Ji,{children:[f," ",p," ",g]}),e[19]=f,e[20]=g,e[21]=h):h=e[21];let x;e[22]!==s||e[23]!==n?(x=n.load.state==="ready"?r.jsx(_g,{projectRef:s,setup:n.load.setup,setupState:n}):r.jsx(Wo,{setupState:n}),e[22]=s,e[23]=n,e[24]=x):x=e[24];let m;e[25]!==u||e[26]!==h||e[27]!==x?(m=r.jsx(Bs,{title:u,settingsItem:"projects.worktree",divider:!1,titleAccessory:h,children:x}),e[25]=u,e[26]=h,e[27]=x,e[28]=m):m=e[28];let b;e[29]!==o||e[30]!==a?(b=o?r.jsx(Bs,{title:a("settings.projects.worktrees.manageTitle"),children:r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("p",{className:is,children:a("settings.projects.worktrees.manageDescription")}),r.jsxs(Q,{type:"button",variant:"outline",size:"sm",onClick:o,children:[a("sessions.sidebar.project.actions.manageWorktrees"),r.jsx(B,{name:"arrow-right-s",className:"h-4 w-4"})]})]})}):null,e[29]=o,e[30]=a,e[31]=b):b=e[31];let v;return e[32]!==b||e[33]!==m?(v=r.jsxs(r.Fragment,{children:[m,b]}),e[32]=b,e[33]=m,e[34]=v):v=e[34],v};function $g(){}const Mg=t=>{const e=W.c(26);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={state:"loading"},e[0]=s):s=e[0];const[n,o]=y.useState(s),a=y.useRef(0);let i;e[1]!==t?(i=async()=>{const S=a.current=a.current+1;try{const I=await tu(t);S===a.current&&o({state:"ready",setup:I})}catch{S===a.current&&o({state:"failed"})}},e[1]=t,e[2]=i):i=e[2];const l=i;let c,d;e[3]!==l?(c=()=>(o({state:"loading"}),l(),()=>{a.current=a.current+1}),d=[l],e[3]=l,e[4]=c,e[5]=d):(c=e[4],d=e[5]),y.useEffect(c,d);let u;e[6]!==t?(u=S=>(S&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(su,{detail:{projectId:t.id}})),S),e[6]=t,e[7]=u):u=e[7];const f=u;let p,g,h;e[8]!==f||e[9]!==t?(p=async S=>f(await pr(t,{projectActions:S})),g=async S=>f(await fo(t,{projectActions:S})!==null),h=async S=>f(await pr(t,{hiddenSharedActionIds:S})),e[8]=f,e[9]=t,e[10]=p,e[11]=g,e[12]=h):(p=e[10],g=e[11],h=e[12]);let x,m;e[13]!==t?(x=S=>pr(t,{setupWorktree:S}),m=async S=>await fo(t,{setupWorktree:S})!==null,e[13]=t,e[14]=x,e[15]=m):(x=e[14],m=e[15]);let b;e[16]!==p||e[17]!==g||e[18]!==h||e[19]!==x||e[20]!==m?(b={personalActions:p,sharedActions:g,hiddenSharedActionIds:h,personalCommands:x,sharedCommands:m},e[16]=p,e[17]=g,e[18]=h,e[19]=x,e[20]=m,e[21]=b):b=e[21];const v=b;let w;return e[22]!==n||e[23]!==l||e[24]!==v?(w={load:n,reload:l,write:v},e[22]=n,e[23]=l,e[24]=v,e[25]=w):w=e[25],w},Og=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Fg=t=>{if(!t)return null;const e=t.trim();return e&&Og.test(e)?e.toLowerCase():null},Xr={label:"",icon:null,color:null,iconBackground:null,defaultAgent:void 0,defaultModel:void 0,defaultVariant:void 0},Bg=t=>({label:t.label??"",icon:t.icon??null,color:t.color??null,iconBackground:t.iconBackground??null,defaultAgent:t.defaultAgent,defaultModel:t.defaultModel,defaultVariant:t.defaultVariant}),qa=(t,e)=>t.label===e.label&&t.icon===e.icon&&t.color===e.color&&t.iconBackground===e.iconBackground&&t.defaultAgent===e.defaultAgent&&t.defaultModel===e.defaultModel&&t.defaultVariant===e.defaultVariant,Vg=t=>{const{t:e}=se(),s=Jt(oe=>oe.uploadProjectIcon),n=Jt(oe=>oe.removeProjectIcon),o=Jt(oe=>oe.discoverProjectIcon),a=Jt(oe=>t?oe.projects.find(ue=>ue.id===t.id)?.iconImage??null:null),[i,l]=y.useState(""),[c,d]=y.useState(null),[u,f]=y.useState(null),[p,g]=y.useState(null),[h,x]=y.useState(void 0),[m,b]=y.useState(void 0),[v,w]=y.useState(void 0),[S,I]=y.useState(!1),[k,R]=y.useState(!1),[P,T]=y.useState(!1),[D,A]=y.useState(!1),[N,j]=y.useState(null),[_,E]=y.useState(null),[L,$]=y.useState(!1),M=y.useRef(null),C=y.useCallback(()=>{j(null),E(oe=>(oe&&URL.revokeObjectURL(oe),null))},[]),O=t?.id??null,z=y.useRef(Xr);z.current={label:i,icon:c,color:u,iconBackground:p,defaultAgent:h,defaultModel:m,defaultVariant:v};const G=y.useRef({projectId:null,identity:Xr});y.useEffect(()=>{if(!t){G.current={projectId:null,identity:Xr},l(""),d(null),f(null),g(null),x(void 0),b(void 0),w(void 0);return}const oe=Bg(t),ue=G.current,Ie=ue.projectId!==t.id;if(!Ie){if(qa(z.current,oe)){G.current={projectId:t.id,identity:oe};return}if(!qa(z.current,ue.identity))return}G.current={projectId:t.id,identity:oe},l(oe.label),d(oe.icon),f(oe.color),g(oe.iconBackground),x(oe.defaultAgent),b(oe.defaultModel),w(oe.defaultVariant),Ie&&(A(!1),C(),$(!1))},[t,C]),y.useEffect(()=>()=>{C()},[C]);const U=y.useMemo(()=>Zp(m)??{providerId:"",modelId:""},[m]),K=!!t?.iconImage,X=!!(N&&_),re=t?.iconImage?.source==="custom",ee=K&&!D||X,xe=ee,ce=!!(t&&K&&!D),he=!L&&(X||ce),ie=!!t&&(i.trim()!==(t?.label??"").trim()||c!==(t?.icon??null)||u!==(t?.color??null)||p!==(t?.iconBackground??null)||(h??void 0)!==(t?.defaultAgent??void 0)||(m??void 0)!==(t?.defaultModel??void 0)||(v??void 0)!==(t?.defaultVariant??void 0)||D||!!N),pe=y.useCallback((oe,ue)=>{b(oe&&ue?`${oe}/${ue}`:void 0),w(void 0)},[]),le=y.useCallback(oe=>{w(oe)},[]),de=y.useCallback(oe=>{!t||!oe||S||(A(!1),$(!1),j(oe),E(ue=>(ue&&URL.revokeObjectURL(ue),URL.createObjectURL(oe))))},[S,t]),te=y.useCallback(()=>{!t||!xe||k||(X&&C(),A(!!K),$(!1))},[C,X,xe,K,k,t]),J=y.useCallback(async()=>{if(!(!t||P)){C(),A(!1),$(!1),T(!0);try{const oe=await o(t.id);if(!oe.ok){Y.error(oe.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(oe.skipped){Y.success(e("settings.projects.page.toast.customIconAlreadySet"));return}Y.success(e("settings.projects.page.toast.iconDiscovered"))}finally{T(!1)}}},[C,o,P,t,e]),q=y.useCallback(async oe=>{const ue=oe?.silent===!0;if(!t)return null;const Ie=i.trim();if(!Ie)return null;if(N){I(!0);const we=await s(t.id,N);if(I(!1),!we.ok)return Y.error(we.error||e("settings.projects.page.toast.uploadIconFailed")),null;ue||Y.success(e("settings.projects.page.toast.iconUpdated")),C(),A(!1)}const Le=D&&!!t.iconImage;if(Le){R(!0);const we=await n(t.id);if(R(!1),!we.ok)return Y.error(we.error||e("settings.projects.page.toast.removeIconFailed")),null;ue||Y.success(e("settings.projects.page.toast.iconRemoved")),A(!1),g(null)}return{label:Ie,icon:c,color:u,iconBackground:Fg(Le?null:p),defaultAgent:h??null,defaultModel:m??null,defaultVariant:m?v??null:null}},[C,u,h,m,v,c,p,i,D,N,t,n,e,s]);return y.useEffect(()=>{$(!1)},[O,a?.updatedAt]),{projectId:O,name:i,setName:l,icon:c,setIcon:d,color:u,setColor:f,iconBackground:p,setIconBackground:g,defaultAgent:h,setDefaultAgent:x,defaultModel:m,defaultVariant:v,parsedDefaultModel:U,handleDefaultModelChange:pe,handleDefaultVariantChange:le,isUploadingIcon:S,isRemovingCustomIcon:k,isDiscoveringIcon:P,pendingRemoveImageIcon:D,setPendingRemoveImageIcon:A,pendingUploadIconFile:N,pendingUploadIconPreviewUrl:_,previewImageFailed:L,setPreviewImageFailed:$,hasStoredImageIcon:K,hasPendingUploadImageIcon:X,hasCustomIcon:re,effectiveHasImageIcon:ee,hasRemovableImageIcon:xe,showStoredImagePreview:ce,showImagePreview:he,fileInputRef:M,clearPendingUploadIcon:C,handleUploadIcon:de,handleRemoveImageIcon:te,handleDiscoverIcon:J,hasChanges:ie,prepareSaveData:q,currentIconImage:a,project:t}},Ug=450,zg=(t,e)=>{const{t:s}=se(),{projectId:n,hasChanges:o,name:a,icon:i,color:l,iconBackground:c,defaultModel:d,pendingRemoveImageIcon:u,pendingUploadIconFile:f,isUploadingIcon:p,isRemovingCustomIcon:g,prepareSaveData:h}=t,x=y.useRef(!1),m=y.useRef(null);y.useEffect(()=>{if(!o){m.current=null;return}if(!a.trim()||p||g||x.current)return;const b=window.setTimeout(()=>{x.current||(x.current=!0,(async()=>{try{const v=await h({silent:!0});if(v){const w=JSON.stringify(v),S=m.current;if(S&&S.projectId===n&&S.data===w)return;try{await e(v),m.current={projectId:n,data:w}}catch{Y.error(s("settings.projects.page.toast.saveFailed"))}}}finally{x.current=!1}})())},Ug);return()=>{window.clearTimeout(b)}},[l,d,o,i,c,g,p,a,e,u,f,h,n,s])},Kg=t=>t==="general"||t==="actions"||t==="worktrees"||t==="environment",Tw=t=>{const e=W.c(70),{project:s,onIdentitySave:n,tab:o,onTabChange:a,frame:i,onOpenWorktrees:l,onCloseProject:c}=t,{t:d}=se(),u=Vg(s);zg(u,n);let f;e[0]!==s.id||e[1]!==s.path?(f={id:s.id,path:s.path},e[0]=s.id,e[1]=s.path,e[2]=f):f=e[2];const p=f,g=Mg(p);let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=qs(),e[3]=h):h=e[3];const x=!h,m=o==="environment"&&!x?"general":o;let b;e[4]!==d?(b=d("settings.projects.tab.general"),e[4]=d,e[5]=b):b=e[5];let v;e[6]!==b?(v={id:"general",label:b},e[6]=b,e[7]=v):v=e[7];let w;e[8]!==d?(w=d("settings.projects.tab.actions"),e[8]=d,e[9]=w):w=e[9];let S;e[10]!==w?(S={id:"actions",label:w},e[10]=w,e[11]=S):S=e[11];let I;e[12]!==d?(I=d("settings.projects.tab.worktrees"),e[12]=d,e[13]=I):I=e[13];let k;e[14]!==I?(k={id:"worktrees",label:I},e[14]=I,e[15]=k):k=e[15];let R;e[16]!==d?(R=x?[{id:"environment",label:d("settings.projects.tab.environment")}]:[],e[16]=d,e[17]=R):R=e[17];let P;e[18]!==v||e[19]!==S||e[20]!==k||e[21]!==R?(P=[v,S,k,...R],e[18]=v,e[19]=S,e[20]=k,e[21]=R,e[22]=P):P=e[22];const T=P;let D;e[23]!==u?(D=r.jsx(Ag,{form:u}),e[23]=u,e[24]=D):D=e[24];const A=D;let N;e[25]!==a?(N=K=>{Kg(K)&&a(K)},e[25]=a,e[26]=N):N=e[26];let j;e[27]!==m||e[28]!==N||e[29]!==T?(j=r.jsx(el,{items:T,activeId:m,onSelect:N,layoutMode:"fit",variant:"active-pill",pillSize:"form",className:"h-8 max-w-[32rem]"}),e[27]=m,e[28]=N,e[29]=T,e[30]=j):j=e[30];const _=j;let E;e[31]!==m||e[32]!==u||e[33]!==p||e[34]!==g?(E=m==="general"?r.jsx(Tg,{form:u,projectRef:p,setupState:g}):null,e[31]=m,e[32]=u,e[33]=p,e[34]=g,e[35]=E):E=e[35];let L;e[36]!==m||e[37]!==g?(L=m==="actions"?r.jsx(hg,{setupState:g}):null,e[36]=m,e[37]=g,e[38]=L):L=e[38];let $;e[39]!==m||e[40]!==l||e[41]!==p||e[42]!==g?($=m==="worktrees"?r.jsx(Lg,{projectRef:p,setupState:g,onOpenWorktrees:l}):null,e[39]=m,e[40]=l,e[41]=p,e[42]=g,e[43]=$):$=e[43];let M;e[44]!==m||e[45]!==p?(M=m==="environment"?r.jsx(kg,{projectRef:p}):null,e[44]=m,e[45]=p,e[46]=M):M=e[46];let C;e[47]!==E||e[48]!==L||e[49]!==$||e[50]!==M?(C=r.jsxs(r.Fragment,{children:[E,L,$,M]}),e[47]=E,e[48]=L,e[49]=$,e[50]=M,e[51]=C):C=e[51];const O=C;if(i==="page"){let K;e[52]!==c||e[53]!==d?(K=c?r.jsxs(Q,{variant:"ghost",size:"xs",className:"!font-normal text-[var(--status-error)] hover:text-[var(--status-error)]","data-settings-item":"projects.close",onClick:c,children:[r.jsx(B,{name:"close",className:"size-3.5"}),d("settings.projects.page.actions.closeProject")]}):null,e[52]=c,e[53]=d,e[54]=K):K=e[54];const X=K;let re;e[55]!==_?(re=r.jsx("div",{className:"mb-8",children:_}),e[55]=_,e[56]=re):re=e[56];let ee;return e[57]!==X||e[58]!==A||e[59]!==re||e[60]!==O?(ee=r.jsxs(Jh,{title:A,headerEnd:X,showSaveStatus:!0,outerClassName:"bg-background",children:[re,O]}),e[57]=X,e[58]=A,e[59]=re,e[60]=O,e[61]=ee):ee=e[61],ee}let z;e[62]!==A||e[63]!==_?(z=r.jsxs("div",{className:"shrink-0 space-y-6 px-4 pt-6 pb-5 sm:px-6 sm:pt-8",children:[A,_]}),e[62]=A,e[63]=_,e[64]=z):z=e[64];let G;e[65]!==O?(G=r.jsx(Mn,{outerClassName:"min-h-0 flex-1",className:"w-full",children:r.jsx("div",{className:"px-4 pb-6 sm:px-6 [&>section:first-of-type]:border-t-0 [&>section:first-of-type]:pt-0",children:O})}),e[65]=O,e[66]=G):G=e[66];let U;return e[67]!==z||e[68]!==G?(U=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col @container",children:[z,G]}),e[67]=z,e[68]=G,e[69]=U):U=e[69],U};let jo=null,Ha=0,Qr=!1;function Gg(){return jo?.runtimeKey===be()?jo.catalog:null}async function Wg(t){try{return(await(t?At.getScopedSdkClient(t):At.getSdkClient()).integration.list()).data}catch(e){throw em("integration.list",e)}}async function qg(){const t=be(),e=++Ha,s=At.getDirectory()||null,[n,o]=await Promise.all([Wg(s),nu(s).catch(()=>null)]),a={integrations:n,webSearchIds:o?new Set(o.map(i=>i.id)):null};return e===Ha&&t===be()&&(jo={runtimeKey:t,catalog:a}),a}function Rw(){Qr||Gg()||(Qr=!0,(async()=>{try{await qg()}catch(t){console.warn("[providers] could not prefetch the integration list:",t instanceof Error?t.message:String(t))}finally{Qr=!1}})())}const xc=[{id:"openai",noteKey:"settings.providers.connect.note.openai",recommended:!0},{id:"opencode-go",noteKey:"settings.providers.connect.note.opencodeGo",recommended:!0},{id:"openrouter",noteKey:"settings.providers.connect.note.openrouter",recommended:!0},{id:"anthropic",noteKey:"settings.providers.connect.note.anthropic",recommended:!1},{id:"github-copilot",noteKey:"settings.providers.connect.note.githubCopilot",recommended:!1},{id:"google",noteKey:"settings.providers.connect.note.google",recommended:!1},{id:"vercel",noteKey:"settings.providers.connect.note.vercel",recommended:!1}],Hg=new Set(xc.map(t=>t.id)),Ew=(t,e)=>t.integrations.filter(s=>s.connections.length===0&&!s.id.startsWith("mcp_")&&!t.webSearchIds?.has(s.id)&&!ru(s)&&!e.has(s.id)).map(s=>({id:s.id,name:s.name||s.id})).sort((s,n)=>s.name.localeCompare(n.name,void 0,{sensitivity:"base"})),Dw=t=>{const e=new Map(t.map(s=>[s.id,s]));return{popular:xc.flatMap(s=>{const n=e.get(s.id);return n?[{...n,...s}]:[]}),others:t.filter(s=>!Hg.has(s.id))}},bc="openchamber:recent-git-branches:v1",yc=5,Yg=Rm(nt(),Bo(nt())),vc=t=>{const e=Ct(t);return e?`${be()}:${e}`:null},wc=()=>{try{const t=localStorage.getItem(bc),e=Yg.safeParse(t?JSON.parse(t):null);return e.success?Object.fromEntries(Object.entries(e.data).map(([s,n])=>[s,n.slice(0,yc)])):{}}catch{return{}}},Ya=t=>{const e=vc(t);return e?wc()[e]??[]:[]},Ja=(t,e)=>{const s=vc(t);if(!s||!e)return[];const n=wc(),o=[e,...(n[s]??[]).filter(a=>a!==e)].slice(0,yc);try{localStorage.setItem(bc,JSON.stringify({...n,[s]:o}))}catch{}return o},No=t=>{const e=t.trim().replace(/[\s\x00-\x1f\x7f~^:?*[\\]+/g,"-").replace(/@\{/g,"-").replace(/\.{2,}/g,".").replace(/-{2,}/g,"-").split("/").map(s=>s.replace(/^[-.]+/,"").replace(/(?:\.lock|-)+$/,"")).filter(Boolean).join("/").replace(/(?:\.lock|\.)+$/,"");return e==="@"?"":e},Jg=({currentBranch:t,localBranches:e,remoteBranches:s,branchInfo:n,currentBranchAhead:o=0,onCheckout:a,onCreate:i,disabled:l=!1,directory:c,switchBlockedNotice:d=null})=>{const{t:u}=se(),{isMobile:f}=On(),[p,g]=y.useState(!1),[h,x]=y.useState(""),[m,b]=y.useState(!1),[v,w]=y.useState(""),[S,I]=y.useState(!1),[k,R]=y.useState(()=>Ya(c)),[P,T]=y.useState({}),D=y.useRef(null),A=y.useCallback(C=>{C.stopPropagation()},[]),N=y.useMemo(()=>No(v),[v]),j=y.useMemo(()=>po(e,h,C=>[C]),[h,e]),_=y.useMemo(()=>po(s,h,C=>[C]),[h,s]),E=C=>{if(C===t){g(!1);return}R(Ja(c,C)),a(C),g(!1),x("")},L=()=>{b(!0),setTimeout(()=>D.current?.focus(),50)},$=async()=>{if(!(!N||S)){I(!0);try{await i(N),w(""),b(!1),g(!1)}finally{I(!1)}}},M=()=>{w(""),b(!1)};if(y.useEffect(()=>{p||(x(""),b(!1),w(""))},[p]),y.useEffect(()=>{c&&R(t?Ja(c,t):Ya(c))},[t,c]),y.useEffect(()=>{if(!p)return;const C=k.filter(z=>e.includes(z)).slice(0,5);if(C.length===0)return T({});let O=!1;return ou(c,C).then(({counts:z})=>{O||T(z)}).catch(()=>{O||T({})}),()=>{O=!0}},[c,p,e,k]),f){const C=k.filter(z=>e.includes(z)),O=(z,G=!1)=>{const U=P[z]??(z===t?o:0),K=U===1?u("gitView.branch.unpushedSingle"):u("gitView.branch.unpushedPlural",{count:U});return r.jsxs("button",{type:"button",onClick:()=>E(z),className:"flex w-full items-center gap-2 rounded-lg px-2 py-2.5 text-start typography-ui-label hover:bg-interactive-hover",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:z}),U>0?r.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-muted-foreground",title:K,"aria-label":K,children:[r.jsx(B,{name:"arrow-up",className:"size-3","aria-hidden":"true"}),r.jsx("span",{"aria-hidden":"true",children:U})]}):null,t===z?r.jsx(B,{name:"check",className:"size-4 shrink-0 text-primary"}):null]},`${G?"remote":"local"}-${z}`)};return r.jsxs(r.Fragment,{children:[r.jsxs(Q,{variant:"ghost",size:"sm",className:"min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:l,onClick:()=>g(!0),children:[r.jsx(B,{name:"git-branch",className:"size-4 text-primary"}),r.jsx("span",{className:"min-w-0 truncate font-medium text-start",children:t||u("gitView.branch.detachedHead")}),r.jsx(B,{name:"arrow-down-s",className:"size-4 opacity-60"})]}),r.jsx(Dr,{open:p,title:u("gitView.branch.currentBranchTooltip"),onClose:()=>g(!1),children:r.jsxs("div",{className:"flex flex-col gap-2 px-3 pb-4 pt-1",children:[r.jsx("input",{value:h,onChange:z=>x(z.target.value),placeholder:u("gitView.branch.searchPlaceholder"),className:"oc-surface-elevated oc-raised oc-field h-9 w-full rounded-lg bg-surface-elevated px-3 typography-meta outline-none placeholder:text-muted-foreground"}),d?r.jsxs("div",{className:"flex items-start gap-2 px-2 py-1",children:[r.jsx(B,{name:"alert",className:"mt-0.5 size-3.5 shrink-0 text-[var(--status-warning)]","aria-hidden":"true"}),r.jsx("span",{className:"typography-micro text-muted-foreground",children:d})]}):null,C.length>0?r.jsxs("section",{children:[r.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:u("gitView.branch.recentBranches")}),C.map(z=>O(z))]}):null,r.jsxs("section",{children:[r.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:u("gitView.branch.localBranches")}),j.map(z=>O(z))]}),r.jsxs("section",{children:[r.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:u("gitView.branch.remoteBranches")}),_.map(z=>O(z,!0))]})]})})]})}return r.jsxs(Ut,{open:p,onOpenChange:g,children:[r.jsxs(Ps,{children:[r.jsx(As,{asChild:!0,children:r.jsx(Bt,{asChild:!0,children:r.jsxs(Q,{variant:"ghost",size:"sm",className:"branch-selector__trigger max-w-full justify-start gap-1.5 px-2 py-1",disabled:l,children:[r.jsx(B,{name:"git-branch",className:"size-4 text-primary"}),r.jsx("span",{className:"grid min-w-0 grid-cols-[minmax(0,max-content)]",children:r.jsx("span",{className:"truncate font-medium text-start",children:t||u("gitView.branch.detachedHead")})}),r.jsx(B,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),r.jsx(_s,{sideOffset:8,children:u("gitView.branch.currentBranchTooltip")})]}),r.jsx(Vt,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:r.jsxs(tl,{className:"h-full min-h-0",shouldFilter:!1,children:[r.jsx(sl,{placeholder:u("gitView.branch.searchPlaceholder"),value:h,onValueChange:x,onKeyDown:A}),d?r.jsxs("div",{className:"flex items-start gap-2 border-b border-border/60 px-3 py-2",children:[r.jsx(B,{name:"alert",className:"mt-0.5 size-3.5 shrink-0 text-[var(--status-warning)]","aria-hidden":"true"}),r.jsx("span",{className:"typography-micro text-muted-foreground",children:d})]}):null,r.jsxs(nl,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[r.jsx(au,{children:u("gitView.branch.empty")}),r.jsx(Zn,{children:m?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[r.jsx("input",{ref:D,placeholder:u("gitView.branch.newBranchPlaceholder"),value:v,onChange:C=>w(C.target.value),onClick:C=>C.stopPropagation(),onKeyDown:C=>{A(C),C.key==="Enter"?(C.preventDefault(),$()):C.key==="Escape"&&(C.preventDefault(),M())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),r.jsx("button",{type:"button",onClick:$,disabled:!N||S,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:S?r.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):r.jsx(B,{name:"add",className:"size-4"})}),r.jsx("button",{type:"button",onClick:M,disabled:S,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:r.jsx(B,{name:"close",className:"size-4"})})]}):r.jsxs(Os,{onSelect:L,children:[r.jsx(B,{name:"add",className:"size-4"}),r.jsx("span",{children:u("gitView.branch.create")})]})}),r.jsx(Kr,{}),k.filter(C=>e.includes(C)).length>0?r.jsxs(r.Fragment,{children:[r.jsx(Zn,{heading:u("gitView.branch.recentBranches"),children:k.filter(C=>e.includes(C)).map(C=>r.jsxs(Os,{onSelect:()=>E(C),children:[r.jsxs("span",{className:"flex flex-1 items-center gap-2 min-w-0",children:[r.jsx("span",{className:"typography-ui-label text-foreground truncate",children:C}),(()=>{const O=P[C]??(C===t?o:0),z=O===1?u("gitView.branch.unpushedSingle"):u("gitView.branch.unpushedPlural",{count:O});return O>0?r.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full px-1.5 py-0.5 typography-micro text-muted-foreground",title:z,"aria-label":z,children:[r.jsx(B,{name:"arrow-up",className:"size-3","aria-hidden":"true"}),r.jsx("span",{"aria-hidden":"true",children:O})]}):null})()]}),t===C?r.jsx("span",{className:"typography-micro text-primary",children:u("gitView.branch.currentBadge")}):null]},`recent-${C}`))}),r.jsx(Kr,{})]}):null,r.jsxs(Zn,{heading:u("gitView.branch.localBranches"),children:[j.map(C=>r.jsxs(Os,{onSelect:()=>E(C),children:[r.jsxs("span",{className:"flex flex-1 flex-col",children:[r.jsx("span",{className:"typography-ui-label text-foreground",children:C}),(n?.[C]?.ahead||n?.[C]?.behind)&&r.jsxs("span",{className:"typography-micro text-muted-foreground",children:[n[C].ahead||0," ahead ·"," ",n[C].behind||0," behind"]})]}),t===C&&r.jsx("span",{className:"typography-micro text-primary",children:u("gitView.branch.currentBadge")})]},`local-${C}`)),j.length===0&&r.jsx(Os,{disabled:!0,className:"justify-center",children:r.jsx("span",{className:"typography-meta text-muted-foreground",children:u("gitView.branch.noLocalBranches")})})]}),r.jsx(Kr,{}),r.jsxs(Zn,{heading:u("gitView.branch.remoteBranches"),children:[_.map(C=>r.jsx(Os,{onSelect:()=>E(C),children:r.jsx("span",{className:"typography-ui-label text-foreground",children:C})},`remote-${C}`)),_.length===0&&r.jsx(Os,{disabled:!0,className:"justify-center",children:r.jsx("span",{className:"typography-meta text-muted-foreground",children:u("gitView.branch.noRemoteBranches")})})]})]})]})})]})},Xg=({currentBranch:t,onRename:e,showEditButton:s=!0})=>{const{t:n}=se(),[o,a]=y.useState(!1),[i,l]=y.useState(t||""),[c,d]=y.useState(!1),u=y.useRef(null),f=()=>{!t||!e||(l(t),a(!0),setTimeout(()=>u.current?.focus(),0))},p=async()=>{if(!t||!e)return;const x=No(i);if(x){if(x===t){a(!1);return}d(!0);try{await e(t,x),a(!1),l("")}finally{d(!1)}}},g=()=>{a(!1),l("")},h=x=>{x.key==="Enter"?(x.preventDefault(),p()):x.key==="Escape"&&(x.preventDefault(),g())};return o?r.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-7",children:r.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:x=>{x.preventDefault(),p()},children:[r.jsx(B,{name:"git-branch",className:"size-4 text-primary"}),r.jsx("input",{ref:u,value:i,onChange:x=>l(x.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:n("gitView.branch.namePlaceholder"),onKeyDown:h,autoFocus:!0}),r.jsx("button",{type:"submit",disabled:c||!No(i),"aria-label":n(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:n(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:c?r.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):r.jsx(B,{name:"check",className:"size-4"})}),r.jsx("button",{type:"button",onClick:g,disabled:c,"aria-label":n("gitView.branch.renameCancel"),title:n("gitView.branch.renameCancel"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:r.jsx(B,{name:"close",className:"size-4"})})]})}):r.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-7",children:[r.jsx(B,{name:"git-branch",className:"size-4 text-primary shrink-0"}),r.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[r.jsx("span",{className:"truncate typography-ui-label font-normal text-foreground",children:t||n("gitView.branch.detachedHead")}),s&&e&&t&&r.jsx(Q,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:f,title:n("gitView.branch.renameTitle"),children:r.jsx(B,{name:"edit",className:"size-4"})})]})]})},Qg=t=>{const e=W.c(42),{syncAction:s,remotes:n,onFetch:o,onPull:a,onSync:i,onPublish:l,onChooseSyncTargets:c,currentBranch:d,hasTracking:u,onRemoveRemote:f,disabled:p,removingRemoteName:g,aheadCount:h,behindCount:x,trackingRemoteName:m,hasUncommittedChanges:b,choosesPushDestination:v}=t,w=n===void 0?[]:n,S=u===void 0?!1:u,I=g===void 0?null:g,k=h===void 0?0:h,R=x===void 0?0:x,P=b===void 0?!1:b,T=v===void 0?!1:v,{t:D}=se(),A=y.useRef(!1),N=!!I,j=m?w.find(ge=>ge.name===m):void 0,_=R>0&&P,E=!d||d==="HEAD",L=!S,$=p||s!==null||N||E||!L&&_,M=p||s!==null||N||w.length===0,C=!j||P,O=E||S&&k===0,z=k>0||R>0,G=T?"gitView.publish.pushTo":"gitView.publish.title";let U;e[0]!==D||e[1]!==G?(U=D(G),e[0]=D,e[1]=G,e[2]=U):U=e[2];const K=U;let X;e[3]!==L||e[4]!==K||e[5]!==D?(X=L?K:D("gitView.sync.sync"),e[3]=L,e[4]=K,e[5]=D,e[6]=X):X=e[6];const re=X,ee=R>0?`↓${R}`:null,xe=k>0?`↑${k}`:null;let ce;e[7]!==ee||e[8]!==xe?(ce=[ee,xe].filter(Boolean),e[7]=ee,e[8]=xe,e[9]=ce):ce=e[9];const he=ce.join(" "),ie=E?D("gitView.publish.detached"):L?K:_?D("gitView.sync.commitOrStashTooltip"):j?z?D("gitView.sync.syncChangesTooltip",{ahead:k,behind:R}):D("gitView.sync.syncChanges"):D("gitView.sync.noRemoteTooltip"),pe=()=>{if(L){l();return}if(!j){c();return}i(j)};let le;e[10]===Symbol.for("react.memo_cache_sentinel")?(le=ne("inline-flex h-7 items-center gap-1.5 px-2 typography-ui-label font-medium text-foreground","transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"),e[10]=le):le=e[10];let de;e[11]!==L||e[12]!==K||e[13]!==D?(de=L?K:D("gitView.sync.syncChanges"),e[11]=L,e[12]=K,e[13]=D,e[14]=de):de=e[14];let te;e[15]!==s?(te=s==="sync"||s==="publish"?r.jsx(Ft,{className:"size-4"}):r.jsx(B,{name:"refresh",className:"size-4"}),e[15]=s,e[16]=te):te=e[16];let J;e[17]!==he||e[18]!==re?(J=he?r.jsxs("span",{className:"sync-actions__text whitespace-nowrap tabular-nums",children:[r.jsx("span",{className:"sync-actions__label",children:re})," ",he]}):r.jsx("span",{className:"sync-actions__text sync-actions__label whitespace-nowrap",children:re}),e[17]=he,e[18]=re,e[19]=J):J=e[19];let q;e[20]!==ie?(q=r.jsx(_s,{sideOffset:8,children:ie}),e[20]=ie,e[21]=q):q=e[21];let oe;e[22]===Symbol.for("react.memo_cache_sentinel")?(oe=ne("inline-flex h-7 w-6 items-center justify-center border-s border-[var(--interactive-border)] text-muted-foreground","transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"),e[22]=oe):oe=e[22];let ue;e[23]!==D?(ue=D("gitView.sync.moreActionsAria"),e[23]=D,e[24]=ue):ue=e[24];let Ie;e[25]===Symbol.for("react.memo_cache_sentinel")?(Ie=r.jsx(B,{name:"arrow-down-s",className:"size-4"}),e[25]=Ie):Ie=e[25];let Le;e[26]!==M||e[27]!==ue?(Le=r.jsx(Bt,{asChild:!0,children:r.jsx("button",{type:"button",className:oe,disabled:M,"aria-label":ue,children:Ie})}),e[26]=M,e[27]=ue,e[28]=Le):Le=e[28];let we;e[29]===Symbol.for("react.memo_cache_sentinel")?(we=r.jsx(B,{name:"arrow-up",className:"size-4 text-muted-foreground"}),e[29]=we):we=e[29];let $e;e[30]!==S||e[31]!==K||e[32]!==D?($e=S?D("gitView.sync.push"):K,e[30]=S,e[31]=K,e[32]=D,e[33]=$e):$e=e[33];let ke;e[34]!==O||e[35]!==l||e[36]!==$e?(ke=r.jsxs(lt,{disabled:O,onSelect:l,children:[we,$e]}),e[34]=O,e[35]=l,e[36]=$e,e[37]=ke):ke=e[37];let Te;e[38]===Symbol.for("react.memo_cache_sentinel")?(Te=r.jsx(B,{name:"arrow-down",className:"size-4 text-muted-foreground"}),e[38]=Te):Te=e[38];let ae;e[39]!==D?(ae=D("gitView.sync.pullRebase"),e[39]=D,e[40]=ae):ae=e[40];let fe;return e[41]===Symbol.for("react.memo_cache_sentinel")?(fe=r.jsx(Pn,{}),e[41]=fe):fe=e[41],r.jsxs("div",{className:"inline-flex items-center rounded-md border border-border/60 bg-[var(--surface-elevated)] overflow-hidden",children:[r.jsxs(Ps,{children:[r.jsx(As,{asChild:!0,children:r.jsx("span",{className:"inline-flex",tabIndex:_||E?0:void 0,children:r.jsxs("button",{type:"button",onClick:pe,disabled:$,className:le,"aria-label":de,children:[te,J]})})}),q]}),r.jsxs(Ut,{children:[Le,r.jsxs(Vt,{align:"end",className:"w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",children:[ke,r.jsxs(lt,{disabled:C,onSelect:()=>{j&&a(j)},children:[Te,ae]}),fe,w.map(ge=>r.jsx(lt,{onSelect:Oe=>{if(A.current){Oe.preventDefault(),A.current=!1;return}o(ge)},children:r.jsxs("div",{className:"flex w-full items-center gap-2",children:[r.jsx(B,{name:"download",className:"size-4 text-muted-foreground"}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:"typography-ui-label text-foreground",children:D("gitView.sync.fetchFromRemote",{name:ge.name})}),r.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:ge.fetchUrl})]})}),f&&ge.name!==m?r.jsx(Q,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:s!==null||N,onPointerDown:Oe=>{A.current=!0,Oe.preventDefault(),Oe.stopPropagation()},onClick:Oe=>{A.current=!0,Oe.preventDefault(),Oe.stopPropagation(),f(ge)},"aria-label":D("gitView.header.removeRemoteAria",{name:ge.name}),title:D("gitView.header.removeRemoteTitle",{name:ge.name}),children:I===ge.name?r.jsx(Ft,{className:"size-3.5"}):r.jsx(B,{name:"close",className:"size-3.5"})}):null]})},ge.name))]})]})]})},Sc={code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"},Zg={code:"!",color:"var(--status-error)",descriptionKey:"diffView.change.conflicted"},e1=new Map([["?",{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"}],["A",{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"}],["D",{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"}],["R",{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"}],["C",{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"}],["M",Sc]]),t1=t=>{const e=t.index?.trim()??"",s=t.working_dir?.trim()??"";return e==="U"||s==="U"||e==="A"&&s==="A"||e==="D"&&s==="D"},s1=t=>t.index?.trim()==="?"||t.working_dir?.trim()==="?",n1=t=>(t??[]).some(e=>!s1(e)),r1=t=>{const e=t.index?.trim(),s=t.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Pw=t=>t1(t)?Zg:e1.get(r1(t))??Sc,o1=t=>{const e=W.c(27),{repositories:s,selectedRepository:n,onSelectRepository:o,repositoryRoot:a}=t,{t:i}=se();let l;e[0]!==a?(l=w=>{if(w===a)return w.split("/").filter(Boolean).pop()??w;const S=`${a??""}/`;return w.startsWith(S)?w.slice(S.length):w},e[0]=a,e[1]=l):l=e[1];const c=l,d=n??void 0;let u;e[2]!==o?(u=w=>{w&&o(w)},e[2]=o,e[3]=u):u=e[3];let f;e[4]!==i?(f=i("gitView.empty.selectRepositoryPlaceholder"),e[4]=i,e[5]=f):f=e[5];let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(B,{name:"folder-3",className:"size-4 text-muted-foreground"}),e[6]=p):p=e[6];let g;e[7]!==c||e[8]!==n?(g=n?c(n):"",e[7]=c,e[8]=n,e[9]=g):g=e[9];let h;e[10]!==g?(h=r.jsx("span",{className:"grid min-w-0 grid-cols-[minmax(0,max-content)]",children:r.jsx("span",{className:"truncate font-medium text-start",children:g})}),e[10]=g,e[11]=h):h=e[11];let x;e[12]!==f||e[13]!==h?(x=r.jsxs(gn,{className:"max-w-[13rem] gap-1.5 px-2 py-1","aria-label":f,children:[p,h]}),e[12]=f,e[13]=h,e[14]=x):x=e[14];let m;if(e[15]!==c||e[16]!==s){let w;e[18]!==c?(w=S=>r.jsx(Ds,{value:S,children:r.jsx("span",{className:"truncate",children:c(S)})},S),e[18]=c,e[19]=w):w=e[19],m=s.map(w),e[15]=c,e[16]=s,e[17]=m}else m=e[17];let b;e[20]!==m?(b=r.jsx(xn,{align:"start",children:m}),e[20]=m,e[21]=b):b=e[21];let v;return e[22]!==b||e[23]!==d||e[24]!==u||e[25]!==x?(v=r.jsxs(hn,{value:d,onValueChange:u,children:[x,b]}),e[22]=b,e[23]=d,e[24]=u,e[25]=x,e[26]=v):v=e[26],v},a1=(t,e)=>{const s=t.account?iu(t.account.instance):null;if(s&&e.host&&s!==e.host)return{applicable:!1,reason:"host",host:s};const n=Pr(t);return(n==="account"||n==="anonymous")&&!e.https?{applicable:!1,reason:"scheme",scheme:"https"}:n==="ssh"&&!e.ssh?{applicable:!1,reason:"scheme",scheme:"ssh"}:{applicable:!0}};class Yo extends Error{constructor(){super("stale-runtime"),this.name="StaleRuntimeError"}}const jc=(t=be)=>{const e=t();return()=>{if(t()!==e)throw new Yo}},Nc=(t,e,s,n)=>{const o=e.repository.remotes.find(l=>l.name===s);if(!o)return null;const a={directory:n,expectedRepositoryId:e.repository.repositoryId,expectedRevision:e.revision,expectedConfigRevision:e.repository.configRevision,expectedFetchFingerprint:o.fetch.fingerprint,expectedPushFingerprint:o.push.fingerprint,remote:s},i=Pr(t);return i==="account"&&t.account?{...a,transport:"https",credentialAccount:t.account}:i==="ssh"&&t.sshCredentialId?{...a,transport:"ssh",sshCredentialId:t.sshCredentialId}:i==="anonymous"?{...a,transport:"anonymous"}:i==="system"?{...a,transport:"system",unverifiedConfirmed:!0}:null},i1=(t,e)=>t.applicable?"":t.reason==="host"?e("gitView.identity.unavailableHost",{host:t.host}):e(t.scheme==="ssh"?"gitView.identity.unavailableNeedsSsh":"gitView.identity.unavailableNeedsHttps"),l1=async({directory:t,identity:e,remoteName:s},{git:n,sourceControl:o,runtimeKey:a})=>{const i=jc(a);let l=s&&n.configureTransportBinding?await c1({directory:t,identity:e,remoteName:s},{configureTransportBinding:n.configureTransportBinding,removeTransportBinding:n.removeTransportBinding,sourceControl:o,requireRuntime:i}):{status:"applied"};if(l.status==="failed"&&l.reason==="runtime")return l;try{i()}catch{return{status:"failed",reason:"runtime"}}try{e.id&&await n.setGitIdentity(t,e.id)}catch{l.status==="applied"&&(l={status:"failed",reason:"author"})}return l},Aw=(t,e)=>{const s="configure",n=Pr(t);return n==="system"?{...e,operation:s,transport:n,unverifiedConfirmed:!0}:n==="account"&&t.account?{...e,operation:s,transport:"https",credentialAccount:t.account}:n==="ssh"&&t.sshCredentialId?{...e,operation:s,transport:n,sshCredentialId:t.sshCredentialId}:n==="anonymous"?{...e,operation:s,transport:n}:null},_w=async({directory:t,identity:e,remoteName:s},{git:n,sourceControl:o,runtimeKey:a})=>{if(!n.configureTransportBinding)return{status:"failed",reason:"binding"};const i=jc(a),l=()=>{try{return i(),!0}catch{return!1}},c=os.scope(t);let d;try{d=await o.repositoryBinding(t)}catch{return{status:"failed",reason:"binding"}}const u=Nc(e,d,s,t);if(!u)return{status:"failed",reason:"binding"};try{i()}catch{return{status:"failed",reason:"runtime"}}const f=os.captureMutation(c,d);let p={status:"applied"};try{const g=await n.configureTransportBinding(u);i(),g.status==="configured"?os.setMutationResult(f,g.binding):await os.reconcile(f,o)}catch(g){if(g instanceof Yo||!l())return{status:"failed",reason:"runtime"};p={status:"failed",reason:"binding"},await os.reconcile(f,o)}finally{f.release()}return p},c1=async({directory:t,identity:e,remoteName:s},{configureTransportBinding:n,removeTransportBinding:o,sourceControl:a,requireRuntime:i})=>{const l=os.scope(t);let c;try{c=await a.repositoryBinding(t)}catch{return{status:"failed",reason:"binding"}}try{i()}catch{return{status:"failed",reason:"runtime"}}const d=os.captureMutation(l,c);let u={status:"applied"};try{const f=c.binding?.providers[0],p=f&&{provider:f.provider,instance:f.instance,accountId:f.accountId,primaryRemote:f.primaryRemote},g={directory:t,expectedRepositoryId:c.repository.repositoryId,expectedRevision:c.revision};if(i(),e.account){const x={...e.account,primaryRemote:s};c=await a.repositoryProviderBindingMutate(p?{...g,operation:"replace",target:p,provider:x}:{...g,operation:"add",provider:x})}else p&&(c=await a.repositoryProviderBindingMutate({...g,operation:"remove",target:p}));const h=Nc(e,c,s,t);if(h){i();const x=await n(h);x.status==="configured"&&(c=x.binding)}for(const x of c.repository.remotes){const m=x.name;if(m===s)continue;const b=c.binding?.remotes.find(v=>v.name===m&&!v.inherited);if(!(!b||b.readiness!=="ready")){i();try{if(o){const v=await o({directory:t,expectedRepositoryId:c.repository.repositoryId,expectedRevision:c.revision,expectedConfigRevision:c.repository.configRevision,expectedFetchFingerprint:x.fetch.fingerprint,expectedPushFingerprint:x.push.fingerprint,remote:m});v.status==="removed"&&(c=v.binding)}}catch{u={status:"failed",reason:"binding"}}}}i(),os.setMutationResult(d,c)}catch(f){if(f instanceof Yo)return{status:"failed",reason:"runtime"};try{i()}catch{return{status:"failed",reason:"runtime"}}u={status:"failed",reason:"binding"},await os.reconcile(d,a)}finally{d.release()}return u},d1=t=>{const e=W.c(2);let s;return e[0]!==t?(s=n=>{const o=Ct(t??null);if(!o)return!1;for(const a of n.availableWorktreesByProject.values())if(lu(a,o)?.provenance?.kind==="contributor-fork")return!0;return!1},e[0]=t,e[1]=s):s=e[1],_e(s)},Xa=(t,e)=>{const s=t.trim(),n=cu({name:"",fetchUrl:s,pushUrl:s},[...e]);if(!n)return null;let o;const a=/^(?:[^@/:\s]+@)?[^/:\s]+:([^\s]+)$/.exec(s);if(a&&!s.includes("://"))o=a[1];else try{const d=new URL(s);if(!["https:","http:","ssh:","git:"].includes(d.protocol))return null;o=d.pathname}catch{return null}o=o.replace(/^\/+|\/+$/g,"").replace(/\.git$/i,"");const i=new URL(du(n));if(!["https:","http:"].includes(i.protocol)||i.username||i.password)return null;const l=i.pathname.replace(/^\/+|\/+$/g,"");l&&o.startsWith(`${l}/`)&&(o=o.slice(l.length+1));const c=o.split("/");return c.length<2||n.provider==="github"&&c.length!==2||c.some(d=>!/^[a-zA-Z0-9_.-]+$/.test(d)||[".","..","-"].includes(d))?null:(i.pathname=`/${l?`${l}/`:""}${o}`,i.search="",i.hash="",{provider:n.provider,url:i.toString()})},kc=(t,e)=>{const s=t.find(o=>o.name==="origin"),n=s?[s,...t.filter(o=>o!==s)]:t;for(const o of n){const a=Xa(o.fetchUrl,e)??Xa(o.pushUrl,e);if(a)return a}return null},In={layout:"data-diff-toolbar-more-layout",whitespace:"data-diff-toolbar-more-whitespace",wrap:"data-diff-toolbar-more-wrap",tree:"data-diff-toolbar-more-tree",walkthrough:"data-diff-toolbar-more-walkthrough"},Qa=[In.layout,In.whitespace,In.wrap,In.tree,In.walkthrough],Cc={steps:["data-diff-toolbar-compact-walkthrough","data-diff-toolbar-compact",...Qa],clippedText:".truncate",overflowSteps:Qa},Ic=(t,e)=>{const s=y.useRef(null),n=y.useRef(null),o=y.useRef(e);o.current=e,y.useLayoutEffect(()=>{const a=t.current;if(n.current?.container!==a&&(n.current?.release(),n.current=a?{container:a,release:f1(a,()=>o.current)}:null),!a)return;const i=`${a.childElementCount}\0${a.textContent??""}`,l=s.current;l?.container===a&&l.signature===i||(s.current={container:a,signature:i},Tc(a,o.current))}),y.useEffect(()=>()=>{n.current?.release(),n.current=null},[])},Lw=t=>Ic(t,Cc),u1=(t,e)=>{if(t.scrollWidth>t.clientWidth+1)return!1;if(!e)return!0;for(const s of t.querySelectorAll(e))if(s.scrollWidth>s.clientWidth+1)return!1;return!0},Tc=(t,{steps:e,clippedText:s,overflowSteps:n}=Cc)=>{for(const o of e)t.removeAttribute(o);for(const o of e){if(u1(t,n?.includes(o)?void 0:s))return;t.setAttribute(o,"")}},f1=(t,e)=>{let s=!1;const n=()=>{s||(s=!0,Tc(t,e()),s=!1)},o=globalThis.document?.fonts??null;o?.addEventListener("loadingdone",n);const a=new ResizeObserver(n);return a.observe(t),()=>{o?.removeEventListener("loadingdone",n),a.disconnect()}},p1={steps:["data-git-header-branch-shrinks","data-git-header-compact","data-git-header-tight"],clippedText:"[data-git-header-pickers]"},m1={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3",fingerprint:"fingerprint",github:"github",gitlab:"gitlab"},h1={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)",success:"var(--status-success)",info:"var(--status-info)",warning:"var(--status-warning)"};function Rc(t){return t&&h1[t]||"var(--primary)"}const Za=t=>{const e=W.c(8),{icon:s,className:n,colorToken:o}=t,a=m1[s??"branch"]??"user-3";let i;e[0]!==o?(i=Rc(o),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==i?(l={color:i},e[2]=i,e[3]=l):l=e[3];let c;return e[4]!==n||e[5]!==a||e[6]!==l?(c=r.jsx(B,{name:a,className:n,style:l}),e[4]=n,e[5]=a,e[6]=l,e[7]=c):c=e[7],c},Ec=t=>{const e=W.c(56),{activeProfile:s,identities:n,onSelect:o,isApplying:a,iconOnly:i,attention:l,onConfigure:c,applicability:d,triggerClassName:u,menuAlign:f,onOpen:p}=t,g=i===void 0?!1:i,h=l===void 0?null:l,x=f===void 0?"end":f,{t:m}=se(),b=a||n.length===0;let v;e[0]!==p?(v=O=>{O&&p?.()},e[0]=p,e[1]=v):v=e[1];let w;e[2]!==u?(w=ne("min-w-0 max-w-[15rem] justify-start gap-1.5 px-2 py-1 typography-ui-label",u),e[2]=u,e[3]=w):w=e[3];const S=s?.color;let I;e[4]!==S?(I=Rc(S),e[4]=S,e[5]=I):I=e[5];let k;e[6]!==I?(k={color:I},e[6]=I,e[7]=k):k=e[7];let R;e[8]!==m?(R=m("gitView.header.identityTooltip"),e[8]=m,e[9]=R):R=e[9];let P;e[10]!==s?.color||e[11]!==s?.icon||e[12]!==a?(P=a?r.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):r.jsx(Za,{icon:s?.icon,colorToken:s?.color,className:"size-4"}),e[10]=s?.color,e[11]=s?.icon,e[12]=a,e[13]=P):P=e[13];let T;e[14]!==s||e[15]!==g||e[16]!==m?(T=!g&&r.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-start",children:s?Gr(s,m):m("gitView.header.noIdentity")}),e[14]=s,e[15]=g,e[16]=m,e[17]=T):T=e[17];let D;e[18]!==h?(D=h?r.jsx(B,{name:"close-circle",className:"size-3.5 shrink-0 text-[var(--status-error)]"}):null,e[18]=h,e[19]=D):D=e[19];let A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(B,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[20]=A):A=e[20];let N;e[21]!==b||e[22]!==P||e[23]!==T||e[24]!==D||e[25]!==w||e[26]!==k||e[27]!==R?(N=r.jsx(As,{asChild:!0,children:r.jsx(Bt,{asChild:!0,children:r.jsxs(Q,{variant:"ghost",size:"sm",className:w,style:k,disabled:b,"aria-label":R,children:[P,T,D,A]})})}),e[21]=b,e[22]=P,e[23]=T,e[24]=D,e[25]=w,e[26]=k,e[27]=R,e[28]=N):N=e[28];let j;e[29]!==s||e[30]!==h||e[31]!==g||e[32]!==m?(j=h??(g&&s?Gr(s,m):m("gitView.header.identityTooltip")),e[29]=s,e[30]=h,e[31]=g,e[32]=m,e[33]=j):j=e[33];let _;e[34]!==j?(_=r.jsx(_s,{sideOffset:8,children:j}),e[34]=j,e[35]=_):_=e[35];let E;e[36]!==N||e[37]!==_?(E=r.jsxs(Ps,{children:[N,_]}),e[36]=N,e[37]=_,e[38]=E):E=e[38];let L;e[39]!==s?.id||e[40]!==d||e[41]!==n||e[42]!==o||e[43]!==m?(L=n.length===0?r.jsx("div",{className:"px-2 py-1.5",children:r.jsx("p",{className:"typography-meta text-muted-foreground",children:m("gitView.header.noProfiles")})}):n.map(O=>{const z=s?.id===O.id,G=d?.(O)??{applicable:!0};return r.jsx(lt,{disabled:!G.applicable,onSelect:()=>o(O),children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Za,{icon:O.icon,colorToken:O.color,className:"size-4"}),r.jsxs("span",{className:"flex min-w-0 flex-col",children:[r.jsx("span",{className:"typography-ui-label text-foreground",children:Gr(O,m)}),r.jsx("span",{className:"typography-meta text-muted-foreground",children:G.applicable?O.userEmail||m("gitView.identity.systemNoAuthor"):i1(G,m)})]}),z?r.jsx(B,{name:"check",className:"ms-auto size-4 text-foreground"}):null]})},O.id)}),e[39]=s?.id,e[40]=d,e[41]=n,e[42]=o,e[43]=m,e[44]=L):L=e[44];let $;e[45]!==c||e[46]!==m?($=c?r.jsxs(r.Fragment,{children:[r.jsx(Pn,{}),r.jsxs(lt,{onSelect:c,children:[r.jsx(B,{name:"settings-3",className:"size-4"}),m("gitView.context.configure")]})]}):null,e[45]=c,e[46]=m,e[47]=$):$=e[47];let M;e[48]!==x||e[49]!==L||e[50]!==$?(M=r.jsxs(Vt,{align:x,className:"w-64 overflow-y-auto",children:[L,$]}),e[48]=x,e[49]=L,e[50]=$,e[51]=M):M=e[51];let C;return e[52]!==E||e[53]!==M||e[54]!==v?(C=r.jsxs(Ut,{onOpenChange:v,children:[E,M]}),e[52]=E,e[53]=M,e[54]=v,e[55]=C):C=e[55],C},g1=t=>{const e=W.c(21),{comparison:s,trackingBranch:n,tooltipDelayMs:o}=t,a=o===void 0?1e3:o,{t:i}=se(),l=`${s.remote}/${s.branch}`,c=s.ahead===0&&s.behind===0;let d;e[0]!==i||e[1]!==l||e[2]!==n?(d=n?i("gitView.header.upstreamTooltipTracking",{target:l,tracking:n}):i("gitView.header.upstreamTooltip",{target:l}),e[0]=i,e[1]=l,e[2]=n,e[3]=d):d=e[3];const u=d;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(B,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=f):f=e[4];let p;e[5]!==l?(p=r.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:l}),e[5]=l,e[6]=p):p=e[6];let g;e[7]!==s.ahead||e[8]!==s.behind||e[9]!==c||e[10]!==i?(g=c?r.jsx("span",{className:"tabular-nums text-muted-foreground",children:i("gitView.header.upstreamSynced")}):r.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[s.ahead>0?r.jsxs("span",{className:"text-[var(--status-info)]",children:["↑",s.ahead]}):null,s.behind>0?r.jsxs("span",{className:"text-[var(--status-warning)]",children:["↓",s.behind]}):null]}),e[7]=s.ahead,e[8]=s.behind,e[9]=c,e[10]=i,e[11]=g):g=e[11];let h;e[12]!==p||e[13]!==g?(h=r.jsx(As,{asChild:!0,children:r.jsxs("div",{className:"inline-flex h-7 max-w-full items-center gap-1.5 rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 typography-micro text-muted-foreground",children:[f,p,g]})}),e[12]=p,e[13]=g,e[14]=h):h=e[14];let x;e[15]!==u?(x=r.jsx(_s,{sideOffset:8,children:u}),e[15]=u,e[16]=x):x=e[16];let m;return e[17]!==h||e[18]!==x||e[19]!==a?(m=r.jsxs(Ps,{delayDuration:a,children:[h,x]}),e[17]=h,e[18]=x,e[19]=a,e[20]=m):m=e[20],m},$w=t=>{const e=W.c(124),{directory:s,status:n,localBranches:o,remoteBranches:a,branchInfo:i,syncAction:l,operationBlocked:c,remotes:d,onFetch:u,onPull:f,onSync:p,onPublish:g,onChooseSyncTargets:h,onRemoveRemote:x,removingRemoteName:m,onCheckoutBranch:b,onCreateBranch:v,onRenameBranch:w,activeIdentityProfile:S,availableIdentities:I,onSelectIdentity:k,isApplyingIdentity:R,identityAttention:P,identityApplicability:T,onConfigureRepository:D,onIdentityMenuOpen:A,isWorktreeMode:N,onOpenHistory:j,onOpenGraph:_,onOpenStashes:E,onOpenUpdateBranch:L,onOpenReintegrateCommits:$,pullRequest:M,pullRequestProvider:C,prChecks:O,onOpenPullRequest:z,repositoryOptions:G,selectedRepository:U,onSelectRepository:K,repositoryRoot:X}=t,re=c===void 0?!1:c,ee=P===void 0?null:P,xe=Uo(),{t:ce}=se(),{isMobile:he}=On(),ie=d1(s),pe=An(x1),le=y.useRef(null);if(Ic(le,p1),!n)return null;let de;e[0]!==G?(de=G??[],e[0]=G,e[1]=de):de=e[1];let te;e[2]!==de?(te=de.filter(Boolean),e[2]=de,e[3]=te):te=e[3];const J=te;let q,oe;if(e[4]!==pe||e[5]!==_||e[6]!==j||e[7]!==$||e[8]!==E||e[9]!==L||e[10]!==d||e[11]!==ce){const mt=kc(d,pe),Ve=!!(j||_||E||L||$);q="flex items-center gap-1 shrink-0",oe=Ve||mt?r.jsxs(Ut,{children:[r.jsxs(Ps,{children:[r.jsx(As,{asChild:!0,children:r.jsx(Bt,{asChild:!0,children:r.jsx(Q,{variant:"ghost",size:"sm",className:"w-7 px-0","aria-label":ce("gitView.header.repositoryViews"),children:r.jsx(B,{name:"more-fill",className:"size-4"})})})}),r.jsx(_s,{sideOffset:8,children:ce("gitView.header.repositoryViews")})]}),r.jsxs(Vt,{align:"end",children:[j?r.jsxs(lt,{onSelect:j,children:[r.jsx(B,{name:"history",className:"size-4"}),ce("gitView.history.title")]}):null,_?r.jsxs(lt,{onSelect:_,children:[r.jsx(B,{name:"git-branch",className:"size-4"}),ce("gitView.graph.title")]}):null,E?r.jsxs(lt,{onSelect:E,children:[r.jsx(B,{name:"archive-stack",className:"size-4"}),ce("gitView.stashes.title")]}):null,L?r.jsxs(lt,{onSelect:L,children:[r.jsx(B,{name:"git-merge",className:"size-4"}),ce("gitView.header.updateBranch")]}):null,$?r.jsxs(lt,{onSelect:$,children:[r.jsx(B,{name:"split-cells-horizontal",className:"size-4"}),ce("gitView.integrate.title")]}):null,mt?r.jsxs(r.Fragment,{children:[Ve?r.jsx(Pn,{}):null,r.jsxs(lt,{onSelect:()=>{Er(mt.url)},children:[r.jsx(B,{name:mt.provider==="gitlab"?"gitlab":"github",className:"size-4"}),ce("gitView.header.openRepository",{provider:uu(mt.provider)})]})]}):null]})]}):null,e[4]=pe,e[5]=_,e[6]=j,e[7]=$,e[8]=E,e[9]=L,e[10]=d,e[11]=ce,e[12]=q,e[13]=oe}else q=e[12],oe=e[13];let ue;e[14]!==q||e[15]!==oe?(ue=r.jsx("div",{className:q,children:oe}),e[14]=q,e[15]=oe,e[16]=ue):ue=e[16];const Ie=ue,Le=O?O.state==="success"?"var(--status-success)":O.state==="failure"?"var(--status-error)":"var(--status-warning)":null;let we;e[17]!==O?.state||e[18]!==M?(we=M?fu({state:M.state,draft:M.draft,checksState:O?.state,mergeable:M.mergeable,mergeableState:M.mergeableState}):null,e[17]=O?.state,e[18]=M,e[19]=we):we=e[19];const $e=we;let ke;e[20]!==z||e[21]!==Le||e[22]!==$e||e[23]!==M||e[24]!==C||e[25]!==ce?(ke=M&&z?r.jsxs(Ps,{children:[r.jsx(As,{asChild:!0,children:r.jsxs(Q,{variant:"ghost",size:"sm",onClick:z,className:"gap-1.5 px-2 typography-micro",children:[r.jsx(B,{name:"git-pull-request",className:"size-3.5",style:{color:`var(--pr-${$e})`}}),r.jsx("span",{className:"tabular-nums text-foreground/80",children:C==="gitlab"?rl("gitlab",M.number):ce("gitView.pr.numberLabel",{number:M.number})}),Le?r.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:Le}}):null]})}),r.jsx(_s,{sideOffset:8,children:ce(pu("gitView.header.openPullRequest",C))})]}):null,e[20]=z,e[21]=Le,e[22]=$e,e[23]=M,e[24]=C,e[25]=ce,e[26]=ke):ke=e[26];const Te=ke,ae=n.current,fe=!!n.tracking,ge=!n||re,Oe=n.ahead,Be=n.behind;let Xe;e[27]!==n.tracking?(Xe=n.tracking?.split("/")[0],e[27]=n.tracking,e[28]=Xe):Xe=e[28];const Ue=n.tracking;let Ye;e[29]!==n.files?(Ye=n1(n.files),e[29]=n.files,e[30]=Ye):Ye=e[30];let ze;e[31]!==ie||e[32]!==h||e[33]!==u||e[34]!==g||e[35]!==f||e[36]!==x||e[37]!==p||e[38]!==d||e[39]!==m||e[40]!==n.ahead||e[41]!==n.behind||e[42]!==n.current||e[43]!==n.tracking||e[44]!==l||e[45]!==fe||e[46]!==ge||e[47]!==Xe||e[48]!==Ye?(ze=r.jsx(Qg,{syncAction:l,remotes:d,onFetch:u,onPull:f,onSync:p,onPublish:g,onChooseSyncTargets:h,currentBranch:ae,hasTracking:fe,onRemoveRemote:x,removingRemoteName:m,disabled:ge,iconOnly:!0,aheadCount:Oe,behindCount:Be,trackingRemoteName:Xe,trackingBranch:Ue,hasUncommittedChanges:Ye,choosesPushDestination:ie}),e[31]=ie,e[32]=h,e[33]=u,e[34]=g,e[35]=f,e[36]=x,e[37]=p,e[38]=d,e[39]=m,e[40]=n.ahead,e[41]=n.behind,e[42]=n.current,e[43]=n.tracking,e[44]=l,e[45]=fe,e[46]=ge,e[47]=Xe,e[48]=Ye,e[49]=ze):ze=e[49];const Me=ze;let Pe;e[50]!==n.tracking||e[51]!==n.upstreamComparison?(Pe=n.upstreamComparison?r.jsx(g1,{comparison:n.upstreamComparison,trackingBranch:n.tracking,tooltipDelayMs:1e3}):null,e[50]=n.tracking,e[51]=n.upstreamComparison,e[52]=Pe):Pe=e[52];const Ge=Pe;let et;e[53]!==S||e[54]!==I||e[55]!==T||e[56]!==ee||e[57]!==R||e[58]!==D||e[59]!==A||e[60]!==k?(et=r.jsx(Ec,{iconOnly:!0,activeProfile:S,identities:I,onSelect:k,isApplying:R,attention:ee,onConfigure:D,onOpen:A,applicability:T}),e[53]=S,e[54]=I,e[55]=T,e[56]=ee,e[57]=R,e[58]=D,e[59]=A,e[60]=k,e[61]=et):et=e[61];const tt=et;let Ae;e[62]!==i||e[63]!==s||e[64]!==he||e[65]!==N||e[66]!==o||e[67]!==b||e[68]!==v||e[69]!==w||e[70]!==a||e[71]!==n.ahead||e[72]!==n.current||e[73]!==n.files?.length||e[74]!==ce?(Ae=N&&!he?r.jsx(Xg,{currentBranch:n.current,onRename:w}):r.jsx(Jg,{directory:s,currentBranch:n.current,localBranches:o,remoteBranches:a,branchInfo:i,currentBranchAhead:n.ahead,onCheckout:b,onCreate:v,switchBlockedNotice:(n.files?.length??0)>0?ce("gitView.branch.switchBlockedNotice"):null}),e[62]=i,e[63]=s,e[64]=he,e[65]=N,e[66]=o,e[67]=b,e[68]=v,e[69]=w,e[70]=a,e[71]=n.ahead,e[72]=n.current,e[73]=n.files?.length,e[74]=ce,e[75]=Ae):Ae=e[75];let Re;e[76]!==K||e[77]!==J||e[78]!==X||e[79]!==U?(Re=J.length>0&&K?r.jsx(o1,{repositories:J,selectedRepository:U??null,onSelectRepository:K,repositoryRoot:X}):null,e[76]=K,e[77]=J,e[78]=X,e[79]=U,e[80]=Re):Re=e[80];let at;e[81]!==Ae||e[82]!==Re?(at=r.jsxs("div",{"data-git-header-pickers":"",className:"flex min-w-0 flex-1 items-center gap-1",children:[Ae,Re]}),e[81]=Ae,e[82]=Re,e[83]=at):at=e[83];const Ne=at;if(xe){let mt;e[84]!==Me?(mt=r.jsx("div",{className:"shrink-0",children:Me}),e[84]=Me,e[85]=mt):mt=e[85];let Ve;e[86]!==Ne||e[87]!==Ie||e[88]!==mt?(Ve=r.jsx(zo,{children:r.jsxs("div",{ref:le,className:"flex min-w-0 flex-1 items-center gap-2 pe-1",children:[Ne,Ie,mt]})}),e[86]=Ne,e[87]=Ie,e[88]=mt,e[89]=Ve):Ve=e[89];let jt;e[90]!==tt?(jt=r.jsx("div",{className:"shrink-0",children:tt}),e[90]=tt,e[91]=jt):jt=e[91];let Ke;e[92]!==Te?(Ke=Te?r.jsx("div",{className:"shrink-0",children:Te}):null,e[92]=Te,e[93]=Ke):Ke=e[93];let ht;e[94]===Symbol.for("react.memo_cache_sentinel")?(ht=r.jsx("div",{className:"min-w-0 flex-1"}),e[94]=ht):ht=e[94];let Qe;e[95]!==Ge?(Qe=Ge?r.jsx("div",{className:"min-w-0 shrink",children:Ge}):null,e[95]=Ge,e[96]=Qe):Qe=e[96];let ut;e[97]!==jt||e[98]!==Ke||e[99]!==Qe?(ut=r.jsxs("header",{className:"flex h-10 min-w-0 items-center gap-2 px-3",children:[jt,Ke,ht,Qe]}),e[97]=jt,e[98]=Ke,e[99]=Qe,e[100]=ut):ut=e[100];let _t;return e[101]!==Ve||e[102]!==ut?(_t=r.jsxs(r.Fragment,{children:[Ve,ut]}),e[101]=Ve,e[102]=ut,e[103]=_t):_t=e[103],_t}let Fe;e[104]!==tt?(Fe=r.jsx("div",{className:"flex shrink-0 items-center gap-1",children:tt}),e[104]=tt,e[105]=Fe):Fe=e[105];let pt;e[106]!==Ne||e[107]!==Fe?(pt=r.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[Ne,Fe]}),e[106]=Ne,e[107]=Fe,e[108]=pt):pt=e[108];let rt;e[109]!==Te?(rt=Te?r.jsx("div",{className:"shrink-0",children:Te}):null,e[109]=Te,e[110]=rt):rt=e[110];let it;e[111]===Symbol.for("react.memo_cache_sentinel")?(it=r.jsx("div",{className:"min-w-0 flex-1"}),e[111]=it):it=e[111];let We;e[112]!==Ge?(We=Ge?r.jsx("div",{className:"min-w-0 shrink",children:Ge}):null,e[112]=Ge,e[113]=We):We=e[113];let Je;e[114]!==Me?(Je=r.jsx("div",{className:"shrink-0",children:Me}),e[114]=Me,e[115]=Je):Je=e[115];let Tt;e[116]!==Ie||e[117]!==rt||e[118]!==We||e[119]!==Je?(Tt=r.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[rt,it,We,Ie,Je]}),e[116]=Ie,e[117]=rt,e[118]=We,e[119]=Je,e[120]=Tt):Tt=e[120];let St;return e[121]!==pt||e[122]!==Tt?(St=r.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[pt,Tt]}),e[121]=pt,e[122]=Tt,e[123]=St):St=e[123],St};function x1(t){return t.identities}const Dc=()=>{const t=mu();return{displayMode:t,installed:t!=="browser",browserTab:t==="browser"}},Mw=()=>{const t=W.c(2),[e,s]=y.useState(b1);let n,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=[window.matchMedia("(display-mode: standalone)"),window.matchMedia("(display-mode: minimal-ui)"),window.matchMedia("(display-mode: fullscreen)"),window.matchMedia("(display-mode: window-controls-overlay)")],i=()=>{s(Dc())};i();for(const l of a)typeof l.addEventListener=="function"?l.addEventListener("change",i):typeof l.addListener=="function"&&l.addListener(i);return window.addEventListener("appinstalled",i),window.addEventListener("focus",i),()=>{for(const l of a)typeof l.removeEventListener=="function"?l.removeEventListener("change",i):typeof l.removeListener=="function"&&l.removeListener(i);window.removeEventListener("appinstalled",i),window.removeEventListener("focus",i)}},o=[],t[0]=n,t[1]=o):(n=t[0],o=t[1]),y.useEffect(n,o),e};function b1(){return Dc()}const Jo={start:"spaces.actions.start",stop:"spaces.actions.stop",restart_opencode:"spaces.actions.restartOpenCode",restart:"spaces.actions.restart",setup:"spaces.actions.setup",remove:"spaces.actions.remove"},Pc={start:"play",stop:"stop",restart_opencode:"refresh",restart:"restart",setup:"terminal-box",remove:"delete-bin"},Ac=(t,e)=>{e==="remove"?ct.getState().openDeleteDialog(t):_n(t,e)},_c=t=>{const e=W.c(15);let s;e[0]!==t?(s=u=>u.journey?.get(t),e[0]=t,e[1]=s):s=e[1];const n=ct(s);let o;e[2]!==t?(o=u=>u.actions.get(t)?.kind==="running",e[2]=t,e[3]=o):o=e[3];const a=ct(o);let i;e[4]!==n?(i=hu(n),e[4]=n,e[5]=i):i=e[5];let l;e[6]!==n?(l=ol(n),e[6]=n,e[7]=l):l=e[7];let c;e[8]!==n?(c=u=>gu(n,u),e[8]=n,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==i||e[12]!==l||e[13]!==c?(d={actions:i,applicable:l,busy:a,unavailable:c},e[10]=a,e[11]=i,e[12]=l,e[13]=c,e[14]=d):d=e[14],d},Xo=t=>ct.getState().openApplyDialog(t),Ow=t=>{const e=W.c(33),{spaceId:s,label:n,className:o}=t,{t:a}=se(),{actions:i,applicable:l,busy:c,unavailable:d}=_c(s);if(i.length===0)return null;const u=o??"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";let f;e[0]!==n||e[1]!==a?(f=a("spaces.actions.menuAria",{label:n}),e[0]=n,e[1]=a,e[2]=f):f=e[2];let p;e[3]!==a?(p=a("spaces.actions.menu"),e[3]=a,e[4]=p):p=e[4];let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(B,{name:"more-2",className:"h-4 w-4"}),e[5]=g):g=e[5];let h;e[6]!==u||e[7]!==f||e[8]!==p?(h=r.jsx(Bt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:v1,className:u,"aria-label":f,title:p,children:g})}),e[6]=u,e[7]=f,e[8]=p,e[9]=h):h=e[9];let x;e[10]!==l||e[11]!==c||e[12]!==s||e[13]!==a?(x=l?r.jsxs(r.Fragment,{children:[r.jsxs(lt,{disabled:c,onClick:()=>Xo(s),className:"gap-2",children:[r.jsx(B,{name:"git-merge",className:"h-4 w-4"}),a("spaces.actions.apply")]}),r.jsx(Pn,{})]}):null,e[10]=l,e[11]=c,e[12]=s,e[13]=a,e[14]=x):x=e[14];let m;if(e[15]!==i||e[16]!==c||e[17]!==s||e[18]!==a||e[19]!==d){let w;e[21]!==i.length||e[22]!==c||e[23]!==s||e[24]!==a||e[25]!==d?(w=S=>r.jsxs(y.Fragment,{children:[S==="remove"&&i.length>1?r.jsx(Pn,{}):null,r.jsxs(lt,{variant:S==="remove"?"destructive":"default",disabled:c||d(S),onClick:()=>Ac(s,S),className:"gap-2",children:[r.jsx(B,{name:Pc[S],className:"h-4 w-4"}),a(Jo[S])]})]},S),e[21]=i.length,e[22]=c,e[23]=s,e[24]=a,e[25]=d,e[26]=w):w=e[26],m=i.map(w),e[15]=i,e[16]=c,e[17]=s,e[18]=a,e[19]=d,e[20]=m}else m=e[20];let b;e[27]!==x||e[28]!==m?(b=r.jsxs(Vt,{align:"end",className:"min-w-[200px]",onClick:w1,children:[x,m]}),e[27]=x,e[28]=m,e[29]=b):b=e[29];let v;return e[30]!==h||e[31]!==b?(v=r.jsxs(Ut,{children:[h,b]}),e[30]=h,e[31]=b,e[32]=v):v=e[32],v},Fw=()=>{const t=W.c(23),{t:e}=se(),s=ct(S1);let n;t[0]!==s?(n=m=>s?m.journey?.get(s)?.name:void 0,t[0]=s,t[1]=n):n=t[1];const o=ct(n),{actions:a,applicable:i,busy:l,unavailable:c}=_c(s??""),d=j1,u=s!==null;let f;t[2]!==o||t[3]!==e?(f=o??e("spaces.actions.menu"),t[2]=o,t[3]=e,t[4]=f):f=t[4];let p;t[5]!==i||t[6]!==l||t[7]!==s||t[8]!==e?(p=s&&i?r.jsxs(Q,{variant:"ghost",className:"justify-start gap-2",disabled:l,onClick:()=>{d(),Xo(s)},children:[r.jsx(B,{name:"git-merge",className:"h-4 w-4"}),e("spaces.actions.apply")]}):null,t[5]=i,t[6]=l,t[7]=s,t[8]=e,t[9]=p):p=t[9];let g;t[10]!==a||t[11]!==l||t[12]!==s||t[13]!==e||t[14]!==c?(g=s?a.map(m=>r.jsxs(Q,{variant:m==="remove"?"destructive":"ghost",className:"justify-start gap-2",disabled:l||c(m),onClick:()=>{d(),Ac(s,m)},children:[r.jsx(B,{name:Pc[m],className:"h-4 w-4"}),e(Jo[m])]},m)):null,t[10]=a,t[11]=l,t[12]=s,t[13]=e,t[14]=c,t[15]=g):g=t[15];let h;t[16]!==p||t[17]!==g?(h=r.jsxs("div",{className:"flex flex-col gap-1 px-3 pb-4 pt-1",children:[p,g]}),t[16]=p,t[17]=g,t[18]=h):h=t[18];let x;return t[19]!==u||t[20]!==f||t[21]!==h?(x=r.jsx(Dr,{open:u,title:f,onClose:d,children:h}),t[19]=u,t[20]=f,t[21]=h,t[22]=x):x=t[22],x},y1=()=>{const t=W.c(5),{t:e}=se(),s=ct(N1),n=Ce(k1);let o,a;t[0]!==n||t[1]!==s||t[2]!==e?(o=()=>{if(s===null)return;ct.getState().noteChatsArchived(null);const i=e("spaces.archive.notice",{name:s});if(n){Y.success(i);return}Y.success(i,{action:{label:e("spaces.archive.noticeOpen"),onClick:C1}})},a=[n,s,e],t[0]=n,t[1]=s,t[2]=e,t[3]=o,t[4]=a):(o=t[3],a=t[4]),y.useEffect(o,a)},Bw=()=>{const t=W.c(60),{t:e}=se();y1();const s=Ce(I1),n=ct(T1),o=ct(R1);let a;t[0]!==n?(a=T=>n?T.journey?.get(n)?.name??"":"",t[0]=n,t[1]=a):a=t[1];const i=ct(a);let l;t[2]!==n?(l=T=>ol(n?T.journey?.get(n):void 0),t[2]=n,t[3]=l):l=t[3];const c=ct(l);let d;t[4]!==c||t[5]!==i||t[6]!==o?(d={name:i,unsaved:o,applicable:c},t[4]=c,t[5]=i,t[6]=o,t[7]=d):d=t[7];const[u,f]=y.useState(d);n!==null&&(u.name!==i||u.unsaved!==o||u.applicable!==c)&&f({name:i,unsaved:o,applicable:c});let p,g,h,x;if(t[8]!==c||t[9]!==u||t[10]!==i||t[11]!==n||t[12]!==e||t[13]!==o){const T=n!==null?{name:i,unsaved:o,applicable:c}:u;g=E1;let D;t[18]!==n||t[19]!==o?(D=()=>{n&&(g(),_n(n,"remove",{deleteUnsavedChats:o!==null}))},t[18]=n,t[19]=o,t[20]=D):D=t[20];const A=D;let N;t[21]!==n?(N=()=>{n&&(g(),Xo(n))},t[21]=n,t[22]=N):N=t[22];const j=N;x=e("spaces.delete.title",{name:T.name});const _=T.applicable?r.jsx(Q,{variant:"outline",size:"sm",className:"me-auto",onClick:j,children:e("spaces.delete.applyFirst")}):null;let E;t[23]!==e?(E=e("spaces.delete.cancel"),t[23]=e,t[24]=E):E=t[24];let L;t[25]!==E?(L=r.jsx(Q,{variant:"outline",size:"sm",onClick:g,children:E}),t[25]=E,t[26]=L):L=t[26];const $=T.unsaved?e("spaces.delete.deleteAnyway"):e("spaces.delete.confirm");let M;t[27]!==A||t[28]!==$?(M=r.jsx(Q,{variant:"destructive",size:"sm",onClick:A,children:$}),t[27]=A,t[28]=$,t[29]=M):M=t[29];let C;t[30]!==M||t[31]!==_||t[32]!==L?(C=r.jsxs("div",{className:"flex w-full justify-end gap-2",children:[_,L,M]}),t[30]=M,t[31]=_,t[32]=L,t[33]=C):C=t[33],p=C,h=T.unsaved?[...T.unsaved.failed>0||T.unsaved.tooLarge.length===0?[e("spaces.delete.chatsNotSaved",{name:T.name})]:[],...T.unsaved.tooLarge.map(O=>e("spaces.delete.chatTooLarge",{title:O}))]:[e("spaces.delete.body")],t[8]=c,t[9]=u,t[10]=i,t[11]=n,t[12]=e,t[13]=o,t[14]=p,t[15]=g,t[16]=h,t[17]=x}else p=t[14],g=t[15],h=t[16],x=t[17];const m=h;if(s){const T=n!==null;let D;t[34]!==m?(D=r.jsx("div",{className:"flex flex-col gap-1 px-3 pb-4 pt-1",children:m.map(D1)}),t[34]=m,t[35]=D):D=t[35];let A;return t[36]!==p||t[37]!==g||t[38]!==T||t[39]!==D||t[40]!==x?(A=r.jsx(Dr,{open:T,title:x,onClose:g,footer:p,children:D}),t[36]=p,t[37]=g,t[38]=T,t[39]=D,t[40]=x,t[41]=A):A=t[41],A}const b=n!==null;let v;t[42]!==g?(v=T=>{T||g()},t[42]=g,t[43]=v):v=t[43];let w;t[44]!==x?(w=r.jsx(us,{children:x}),t[44]=x,t[45]=w):w=t[45];let S;t[46]!==m?(S=r.jsx(Fn,{className:"flex flex-col gap-1",children:m.map(P1)}),t[46]=m,t[47]=S):S=t[47];let I;t[48]!==w||t[49]!==S?(I=r.jsxs(vs,{children:[w,S]}),t[48]=w,t[49]=S,t[50]=I):I=t[50];let k;t[51]!==p?(k=r.jsx(Gs,{children:p}),t[51]=p,t[52]=k):k=t[52];let R;t[53]!==I||t[54]!==k?(R=r.jsxs(ds,{className:"max-w-md",children:[I,k]}),t[53]=I,t[54]=k,t[55]=R):R=t[55];let P;return t[56]!==R||t[57]!==b||t[58]!==v?(P=r.jsx(cs,{open:b,onOpenChange:v,children:R}),t[56]=R,t[57]=b,t[58]=v,t[59]=P):P=t[59],P};function v1(t){return t.stopPropagation()}function w1(t){return t.stopPropagation()}function S1(t){return t.actionsSheet}function j1(){return ct.getState().closeActionsSheet()}function N1(t){return t.archivedNotice}function k1(t){return t.isMobile}function C1(){Ce.getState().setSettingsDialogOpen(!1),Ce.getState().setArchivePageOpen(!0)}function I1(t){return t.isMobile}function T1(t){return t.deleteDialog}function R1(t){return t.deleteUnsaved}function E1(){return ct.getState().closeDeleteDialog()}function D1(t,e){return r.jsx("p",{className:"typography-meta text-muted-foreground",children:t},e)}function P1(t,e){return r.jsx("span",{children:t},e)}const A1={checking_place:"spaces.group.step.checkingPlace",creating:"spaces.group.step.creating",downloading_image:"spaces.group.step.downloadingImage",preparing_tools:"spaces.group.step.preparingTools",setting_network:"spaces.group.step.settingNetwork",bringing_code:"spaces.group.step.bringingCode",giving_access:"spaces.group.step.givingAccess"},_1={start:"spaces.group.busy.start",stop:"spaces.group.busy.stop",restart_opencode:"spaces.group.busy.restartOpenCode",restart:"spaces.group.busy.restart",setup:"spaces.group.busy.setup",remove:"spaces.group.busy.remove"},L1={start:"spaces.group.actionFailed.start",stop:"spaces.group.actionFailed.stop",restart_opencode:"spaces.group.actionFailed.restartOpenCode",restart:"spaces.group.actionFailed.restart",setup:"spaces.group.actionFailed.setup",remove:"spaces.group.actionFailed.remove"},$1={container_gone:{text:"spaces.group.state.containerGone",tone:"warning",action:"remove"},gatekeeper_gone:{text:"spaces.group.state.gatekeeperGone",tone:"error",action:"remove"},stopped:{text:"spaces.group.state.stopped",tone:"muted",action:"start"},stopped_idle:{text:"spaces.group.state.stoppedIdle",tone:"muted",action:"start"},damaged:{text:"spaces.group.state.damaged",tone:"warning",action:"restart"},not_answering:{text:"spaces.group.state.notAnswering",tone:"warning",action:"restart"}},Yt=t=>{const e=W.c(8),{icon:s,tone:n,children:o}=t,a=n==="error"?"flex items-start gap-1.5 text-[var(--status-error)]":n==="warning"?"flex items-start gap-1.5 text-[var(--status-warning)]":"flex items-start gap-1.5 text-muted-foreground";let i;e[0]!==s?(i=s==="loader-4"?r.jsx(Ft,{className:"mt-px h-3 w-3 shrink-0"}):r.jsx(B,{name:s,className:"mt-px h-3 w-3 shrink-0"}),e[0]=s,e[1]=i):i=e[1];let l;e[2]!==o?(l=r.jsx("span",{className:"min-w-0 whitespace-normal break-words text-[11px] leading-tight",children:o}),e[2]=o,e[3]=l):l=e[3];let c;return e[4]!==a||e[5]!==i||e[6]!==l?(c=r.jsxs("span",{className:a,children:[i,l]}),e[4]=a,e[5]=i,e[6]=l,e[7]=c):c=e[7],c},ei=80,ti=t=>{const e=t.trim().split(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B2WHEal3.js","assets/computeVirtualFileMetrics-DDyA16hp.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/useAppFontEffects-Dm6zEvrf.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/katex.min-F4TD1ekM.js","assets/vendor-zod-DDir2TeQ.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-client-h8RufjAw.js","assets/katex-CQK6Iqoe.css","assets/vendor-base-ui-CPKyhvxM.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-tanstack-react-virtual-Bmi0tTrf.js","assets/vendor-tanstack-virtual-core-CdGDGrnp.js","assets/vendor-framer-motion-DxDVhOLc.js","assets/vendor-motion-dom-HXPOMxb7.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-codemirror-commands-dar6chwA.js","assets/vendor-codemirror-state-Dek9sMtw.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-B66jUSmE.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-codemirror-language-DyL0aCoH.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-streamparser-CmlTsbN2.js","assets/vendor-codemirror-lang-javascript-Cem6LjJ8.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-CIqXJolH.js","assets/vendor-codemirror-lang-json-C9rLLO0q.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-9qjxcVkg.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-D7VQUxeE.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-Cikh4w2I.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-VzNDjH03.js","assets/vendor-codemirror-lang-python-DVl8-2Op.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-legendapp-list-D2O6oUGf.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/themeResolver-yJ9XpNMI.js","assets/vendor-pierre-theming-Dgp7B_O4.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/isFilePlainText-Dpm-_Qu8.js","assets/isDiffPlainText-yXcpftjI.js","assets/vendor-diff-C3JhlQdm.js","assets/vendor-lru_map-Tstukz9J.js","assets/appThemeRegistry-BWap7OfW.js","assets/textMateThemeFromAppTheme-tYpAceV3.js","assets/NoteEditor-CTAjn_F2.js","assets/PlanView-D7wshtfZ.js","assets/flexokiTheme-PoX6Vqyn.js","assets/vendor-codemirror-search-BKAwkhkm.js","assets/vendor-replit-codemirror-vim-CKWqK1yR.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/useInlineCommentController-a2JepiF3.js","assets/useMarkdownLocalAssets-BEApAshz.js","assets/vendor-capacitor-keyboard-CYccoJjr.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as Es}from"./vendor-vite-runtime-DD1OZmLC.js";import{f as W,r as je,j as r,R as y,c as md}from"./vendor-react-BUCujlKS.js";import{a9 as hd,aa as da,u as se,ac as _o,I as B,B as Q,z as Ft,mO as gd,hP as xd,mP as bd,cy as Er,t as cs,q as ds,l as us,n as Mn,aW as lo,N as ne,x as Oi,aA as Lo,A as Y,a2 as yd,mQ as vd,mR as wd,ak as Sd,mS as jd,mT as Nd,mU as kd,G as _e,dw as Cd,aH as ys,cV as Fi,aP as Pt,a1 as Ot,hW as Bi,cH as Id,cJ as Vi,mV as Td,cK as Ui,C as zi,cL as Ki,D as vs,mW as Tn,hb as ua,y as It,iw as fa,iA as Rd,aU as lt,gJ as yn,aS as Bt,aT as Vt,aR as Ut,gN as Gi,gH as Wi,gO as qi,mX as Ed,mY as Dd,mZ as Pd,jj as Ad,ji as _d,m_ as pa,m$ as Ld,n0 as $d,n1 as ma,n2 as Md,n3 as Od,n4 as Fd,n5 as Bd,n6 as Vd,aF as On,n7 as Ud,n8 as Hi,cI as Rs,cM as Yi,c7 as co,i8 as yr,fi as is,cd as hn,cb as gn,ca as Dn,cc as xn,c4 as Ds,o as Gs,eo as $o,aC as Bs,i4 as ha,hV as uo,c1 as Ji,i6 as zd,i3 as ga,i2 as fr,ev as Kd,n9 as Gd,my as Wd,na as fo,iF as qd,b0 as Xi,aG as Qi,cU as Hd,cT as Zi,cS as Yd,hc as Jd,he as Xd,nb as pr,nc as Qd,iV as Zd,b$ as eu,nd as tu,mv as su,a5 as Jt,cE as el,ne as nu,nf as ru,L as po,ng as ou,k as Dr,V as Ps,W as As,X as _s,az as tl,ay as sl,as as nl,at as au,au as Zn,av as Os,fX as Kr,bg as Pn,fl as iu,fr as os,dB as lu,nh as cu,ni as du,ga as Gr,b9 as An,kL as uu,kO as fu,f2 as rl,bc as pu,nj as mu,F as Fn,j as hu,k5 as ol,r as _n,nk as gu,nl as xu,f as er,nm as al,nn as xa,H as ls,no as mo,cF as bu,hi as yu,d_ as vu,np as wu,nq as Su,eD as ju,nr as Nu,ns as ku,nt as Cu,nu as Iu,nv as Tu,aL as Vs,nw as Ru,nx as Eu,ny as Du,lY as Pu,nz as Au,e7 as il,ef as _u,Y as ll,e5 as Lu,hB as $u,dn as Mo,b7 as yt,eV as Mu,mf as Ou,cz as Fu,jX as Dt,K as Bn,nA as Bu,nB as vr,nC as cl,cG as Vu,eO as Uu,nD as zu,nE as kn,nF as Ku,nG as dl,nH as Gu,fs as ul,fe as Wu,ff as qu,fh as Hu,fZ as Yu,nI as Ju,am as wr,nJ as Xu,is as Qu,fq as Zu,gd as ef,fk as tf,nK as Oo,mc as sf,mg as nf,nL as rf,lF as ba,U as ho,mb as of,nM as af,lr as lf,d6 as cf,nN as ya,nO as fl,nP as go,nQ as df,nR as uf,nS as va,nT as ff,nU as wa,nV as pl,nW as pf,nX as mf,nY as hf,nZ as gf,n_ as xf,n$ as bf,br as Vn,o0 as ml,o1 as yf,e3 as vf,e2 as wf,e1 as Sf,bd as jf,o2 as Nf,aD as Ln,o3 as kf,o4 as Cf,o5 as If,o6 as Tf,h1 as Rf,bj as hl,bf as gl,cv as Ws,o7 as Ef,o8 as Df,o9 as Pf,b4 as xl,oa as Af,ob as Sa,oc as _f,eA as Lf,od as $f,c6 as Mf,ch as Of,oe as bl,of as yl,aE as vl,bs as wl,og as Sl,oh as Ff,oi as Bf,oj as Vf,ok as jl,hl as bs,ol as Uf,al as zf,om as Kf,on as Gf,oo as Nl,aJ as Wf,op as qf,oq as ja,fc as Hf,aM as Yf,aN as Jf,aO as Xf,or as Qf,os as Zf,ot as ep,ou as tp,jm as sp,ov as np,ow as rp,ox as op,kV as kl,oy as mn,oz as ap,hz as ip,f_ as lp,bv as cp,gI as dp,fY as un,fg as bn,oA as up,g8 as fp,oB as pp,oC as mp,oD as hp,oE as gp,fn as Na,fo as ka,oF as xp,oG as bp,oH as Cl,mL as yp,J as vp,jV as wp,jW as Sp,oI as jp,lu as Np,ig as kp,oJ as Cp,oK as Ip,oL as Tp,oM as Rp,oN as Ep,oO as Dp,oP as Pp,P as Ap,ah as _p,hj as Lp,bl as $p,iZ as Mp,cf as Op,gW as Fp,hq as Bp,hR as Vp}from"./useAppFontEffects-Dm6zEvrf.js";import{k as wt,a5 as be,b3 as Ks,dy as Up,a7 as $s,m as Il,q as Tl,dz as zp,dA as Ca,dB as Kp,bk as Gp,aB as Rl,l as qs,ay as Wp,u as Ce,b4 as El,bi as qp,bj as Ia,aU as Dl,dC as Hp,dD as Ta,bR as Ht,dE as Ra,aR as Yp,dF as Jp,dG as Xp,dH as Qp,ax as Pl,bF as Zp,t as At,an as em,n as Ct,a$ as Pr,b as ct,p as tm,e as Ar,db as Ze,dI as sm,d6 as nm,a6 as xo,cE as wn,bT as _r,bW as rm,bX as om,dJ as am,dK as im,as as Al,a_ as lm,dL as _l,dM as cm,bd as dm,aT as um,dN as fm,c$ as Lr,bo as Ea,ac as pm,ae as mm,ad as hm,dO as gm,dP as Ll,dQ as xm,dR as bm,bm as ym,dd as Fo,aI as vm,dS as wm,dg as Sm,dT as Cn,c2 as Wr,dU as $l,cv as jm,at as Nm,ao as km,s as Cm}from"./katex.min-F4TD1ekM.js";import{o as zt,b as vn,s as nt,_ as Da,l as Sr,c as Im,a as Bo,d as Tm,n as jr,r as Rm,N as Em,e as Dm}from"./vendor-zod-DDir2TeQ.js";import{u as Pm,m as Am}from"./vendor-framer-motion-DxDVhOLc.js";import{c as Un,d as _m,u as Lm}from"./vendor-zustand-BAGL70zf.js";import{n as $m,o as Mm,p as Om,h as Ml,P as Ol,e as Fl,f as Bl,g as Vl}from"./vendor-base-ui-CPKyhvxM.js";import{f as Ul,h as mr,i as Fm,T as Bm,M as Vm,D as zl,j as Kl,P as Um}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as zm,a as Gl,S as Wl,v as ql,u as Hl}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Yl}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{toast as hr}from"./vendor-sonner-DFyL3AvE.js";const Km=["typescript","javascript","tsx","jsx","json","markdown"],Jl={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:"none"},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:"word-line"}};let Pa=null;const Xl=()=>(Pa??=Promise.all([Es(()=>import("./index-B2WHEal3.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113])),Es(()=>import("./workerFactory-Bw5qLmrM.js"),[]),Es(()=>import("./appThemeRegistry-BWap7OfW.js"),__vite__mapDeps([114,115,101,102,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100]))]).then(([t,e,s])=>({WorkerPoolManager:t.WorkerPoolManager,workerFactory:e.workerFactory,ensurePierreThemeRegistered:s.ensurePierreThemeRegistered})),Pa),$n={},Aa=new Set,bo=new Set;let gr={light:"pierre-light",dark:"pierre-dark"};const Gm=()=>{for(const t of bo)t()},Ql=(t,e)=>{e.setRenderOptions({theme:gr,lineDiffType:Jl[t].lineDiffType})},yo=t=>{typeof window>"u"||Aa.has(t)||(Aa.add(t),Xl().then(e=>{if($n[t])return;const s=Jl[t],n=new e.WorkerPoolManager({workerFactory:e.workerFactory,poolSize:s.poolSize,totalASTLRUCacheSize:s.totalASTLRUCacheSize},{theme:{light:"pierre-light",dark:"pierre-dark"},langs:Km,lineDiffType:s.lineDiffType,preferredHighlighter:"shiki-wasm"});n.initialize(),$n[t]=n,Ql(t,n),Gm()}))},Wm=t=>(bo.add(t),()=>bo.delete(t)),qm=t=>{if(!(gr.light===t.light&&gr.dark===t.dark)){gr=t;for(const e of Object.keys($n)){const s=$n[e];s&&Ql(e,s)}}},iw=t=>{const e=W.c(15),{children:s}=t,n=hd();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=da(!1),e[0]=o):o=e[0];const a=o;let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=da(!0),e[1]=i):i=e[1];const l=i,c=n?.lightThemeId??a.metadata.id,d=n?.darkThemeId??l.metadata.id;let u;e[2]!==c||e[3]!==n?.availableThemes?(u=n?.availableThemes.find(v=>v.metadata.id===c)??a,e[2]=c,e[3]=n?.availableThemes,e[4]=u):u=e[4];const f=u;let p;e[5]!==d||e[6]!==n?.availableThemes?(p=n?.availableThemes.find(v=>v.metadata.id===d)??l,e[5]=d,e[6]=n?.availableThemes,e[7]=p):p=e[7];const g=p;let h,x;e[8]!==g||e[9]!==f?(h=()=>{let v=!1;return Xl().then(w=>{v||(w.ensurePierreThemeRegistered(f),w.ensurePierreThemeRegistered(g),qm({light:f.metadata.id,dark:g.metadata.id}))}),()=>{v=!0}},x=[g,f],e[8]=g,e[9]=f,e[10]=h,e[11]=x):(h=e[10],x=e[11]),je.useEffect(h,x);let m;e[12]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[12]=m):m=e[12],je.useEffect(Ym,m);let b;return e[13]!==s?(b=r.jsx(r.Fragment,{children:s}),e[13]=s,e[14]=b):b=e[14],b},lw=t=>{const e=W.c(5),s=t===void 0?"unified":t;let n;e[0]!==s?(n=()=>$n[s],e[0]=s,e[1]=n):n=e[1];const o=je.useSyncExternalStore(Wm,n,Jm);let a,i;return e[2]!==s?(a=()=>{yo(s)},i=[s],e[2]=s,e[3]=a,e[4]=i):(a=e[3],i=e[4]),je.useEffect(a,i),o};function Hm(){yo("unified"),yo("split")}function Ym(){if(typeof window>"u")return;const t=Hm;if(typeof window.requestIdleCallback=="function"){const s=window.requestIdleCallback(t,{timeout:5e3});return()=>window.cancelIdleCallback(s)}const e=window.setTimeout(t,2e3);return()=>window.clearTimeout(e)}function Jm(){}const Xm=zt({state:Da(["compatible","incompatible","unavailable"]),version:nt().nullable(),installation:Da(["managed","external","bundled"]),binary:nt().nullable().optional(),minimumVersion:nt().optional(),canInstall:vn()}),Zl=async()=>{const t=await wt("/api/opencode/compatibility",{signal:AbortSignal.timeout(2e4)});if(!t.ok)throw new Error("Could not check OpenCode compatibility");return Xm.parse(await t.json())},Qm=async(t="reconnect")=>{if(t==="install-v2"){if(!(await wt("/api/opencode/install-v2",{method:"POST"})).ok)throw new Error("OpenCode v2 installation failed");return{state:"recovered"}}const e=await Zl();if(e.state==="incompatible")return{state:"incompatible",compatibility:e};if(e.state==="unavailable")throw new Error("Could not determine OpenCode compatibility");if(!(await wt("/api/config/reload",{method:"POST"})).ok)throw new Error("OpenCode recovery failed");return{state:"recovered"}};class Zm extends Error{}const Nr=async()=>{const t=be(),e=Ks();if(await Up())return null;if(be()!==t||Ks()!==e)throw new Zm;return Zl()};let vo=null;const cw=()=>{const t=Nr();t.catch(()=>{}),vo={runtimeKey:be(),check:t}},eh=()=>{const t=vo;return vo=null,t&&t.runtimeKey===be()?t.check.catch(Nr):Nr()},dw=({children:t,enabled:e=!0})=>{const{t:s}=se(),[n,o]=je.useState(null),a=je.useId(),[i,l]=je.useState(null),[c,d]=je.useState(!1),u=je.useRef(0);je.useEffect(()=>{if(!e)return;let b=!0;const v=async S=>{const I=++u.current;try{const k=await S;k&&b&&I===u.current&&o(k)}catch{}};v(eh());const w=$s(()=>{u.current+=1,o(null),l(null),d(!1),v(Nr())});return()=>{b=!1,u.current+=1,w()}},[e]),je.useEffect(()=>{n?.state==="incompatible"&&document.getElementById("initial-loading")?.remove()},[n]);const f=async b=>{if(i)return;const v=++u.current;l(b),d(!1);try{const w=await Qm(b);if(v!==u.current)return;w.state==="incompatible"?o(w.compatibility):window.location.reload()}catch{v===u.current&&d(!0)}finally{v===u.current&&l(null)}};if(!e||n?.state!=="incompatible")return r.jsx(r.Fragment,{children:t});const p=n.installation==="external",g=n.installation==="bundled",h=n.minimumVersion,x=!!(h&&n.version?.startsWith("2.")),m=g?"opencodeCompatibility.bundled":x?p?"opencodeCompatibility.outdatedExternal":"opencodeCompatibility.outdatedLocal":p?"opencodeCompatibility.external":"opencodeCompatibility.local";return r.jsx("section",{className:"app-region-drag flex h-full min-h-0 items-center justify-center overflow-y-auto bg-background px-6 py-10 text-foreground select-none","aria-labelledby":a,children:r.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center text-center",children:[r.jsx(_o,{width:48,height:48}),r.jsx("h1",{id:a,className:"mt-6 text-xl font-semibold tracking-tight",children:s(x?"opencodeCompatibility.outdatedTitle":"opencodeCompatibility.title")}),r.jsxs("p",{className:"mt-2 text-sm leading-relaxed text-muted-foreground text-balance",children:[s(m,{version:n.version??"",minimum:h??""}),n.canInstall&&r.jsxs(r.Fragment,{children:[" ",s("opencodeCompatibility.installDescription")]})]}),n.version&&r.jsxs("div",{className:"mt-5 inline-flex items-center gap-2 rounded-md border border-border px-2.5 py-1 font-mono text-xs","aria-hidden":!0,children:[r.jsx("span",{className:"text-muted-foreground",children:n.version}),r.jsx(B,{name:"arrow-right",className:"size-3.5 text-muted-foreground"}),r.jsx("span",{className:"text-foreground",children:x?`${h}+`:"2.x"})]}),n.binary&&r.jsx("p",{className:"mt-2 max-w-full break-all font-mono text-xs text-muted-foreground select-text",children:n.binary}),c&&r.jsx("p",{role:"alert",className:"mt-5 rounded-md border border-[var(--status-error)]/30 bg-[var(--status-error-background)] px-3 py-2 text-sm text-[var(--status-error-text)]",children:s("opencodeCompatibility.failed")}),r.jsxs("div",{className:"app-region-no-drag mt-7 flex flex-wrap items-center justify-center gap-2",children:[n.canInstall&&r.jsxs(Q,{disabled:i!==null,onClick:()=>{f("install-v2")},children:[i==="install-v2"?r.jsx(Ft,{className:"size-4"}):r.jsx(B,{name:"download",className:"size-4"}),r.jsx("span",{role:i==="install-v2"?"status":void 0,children:s(i==="install-v2"?"opencodeCompatibility.installing":x?"opencodeCompatibility.update":"opencodeCompatibility.install")})]}),r.jsxs(Q,{variant:n.canInstall?"ghost":"default",disabled:i!==null,onClick:()=>{f("reconnect")},children:[i==="reconnect"?r.jsx(Ft,{className:"size-4"}):r.jsx(B,{name:"refresh",className:"size-4"}),r.jsx("span",{role:i==="reconnect"?"status":void 0,children:s(i==="reconnect"?"opencodeCompatibility.reconnecting":"opencodeCompatibility.reconnect")})]})]}),r.jsxs("a",{className:"app-region-no-drag mt-6 inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",href:g?"https://github.com/openchamber/openchamber/releases/latest":"https://opencode.ai/download",target:"_blank",rel:"noopener noreferrer",children:[s("opencodeCompatibility.guide"),r.jsx(B,{name:"external-link",className:"size-3"})]}),r.jsx("div",{className:"app-region-no-drag mt-3 w-full",children:r.jsx(gd,{})})]})})},qr=(t,e)=>Il(Tl.getState().dictionary,t,e),th=t=>{const e=t.message.toLowerCase();return e.includes("code signature")||e.includes("did not pass validation")||e.includes("code requirement")||e.includes("not signed")?"signature":e.includes("command is disabled")?"updater-disabled":"unknown"},sh=t=>{const e=th(t);return e==="signature"?qr("updateDialog.error.signatureRejected"):e==="updater-disabled"?qr("updateDialog.error.updaterDisabled"):t.message.trim()||qr("updateDialog.error.restartFailed")},_a="openchamber.update-install-id";function nh(){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(_a)?.trim();if(t)return t;const e=bd(globalThis.crypto);return e?(window.localStorage.setItem(_a,e),e):void 0}catch{return}}function rh(){if(typeof window>"u")return"unknown";try{const{deviceType:t}=xd();return t}catch{return"unknown"}}function oh(){const t=typeof window<"u"?window.__OPENCHAMBER_ELECTRON__?.arch?.toLowerCase?.():void 0;if(t==="arm64"||t==="aarch64")return"arm64";if(t==="x64"||t==="amd64"||t==="x86_64")return"x64";const e=typeof window<"u"?window.__VSCODE_CONFIG__?.arch?.toLowerCase?.():void 0;if(e==="arm64"||e==="aarch64")return"arm64";if(e==="x64"||e==="amd64"||e==="x86_64")return"x64";const n=(typeof navigator<"u"?navigator.userAgentData:void 0)?.architecture?.toLowerCase?.();if(n==="arm"||n==="arm64"||n==="aarch64")return"arm64";if(n==="x86"||n==="x64"||n==="amd64")return"x64";const o=typeof navigator<"u"?navigator.userAgent.toLowerCase():"";return o.includes("aarch64")||o.includes("arm64")||o.includes("armv")?"arm64":o.includes("x86_64")||o.includes("x64")||o.includes("amd64")||o.includes("win64")?"x64":"unknown"}function ah(){const t=qp();if(t==="android"||t==="ios")return t;if(typeof navigator>"u")return"web";const e=(navigator.platform||"").toLowerCase();return e.includes("mac")?"macos":e.includes("win")?"windows":e.includes("linux")?"linux":"web"}function ec(t){const e=Ce.getState().reportUsage,s=new URLSearchParams({reportUsage:e?"true":"false"});if(s.set("deviceClass",rh()),s.set("arch",oh()),s.set("platform",ah()),e&&(t==="desktop"||t==="mobile")){const n=nh();n&&s.set("installId",n)}return t==="desktop"?(s.set("appType","desktop-electron"),s.set("instanceMode",El()?"local":"remote"),s):t==="vscode"?(s.set("appType","vscode"),s.set("instanceMode","local"),s):t==="mobile"?(s.set("appType","mobile-capacitor"),s.set("instanceMode","remote"),s):(s.set("appType","web"),s.set("instanceMode","unknown"),s)}function tc(t){return{available:t.available??!1,version:t.version,currentVersion:t.currentVersion??"unknown",body:t.body,releaseUrl:t.releaseUrl,downloadUrl:t.downloadUrl,nextSuggestedCheckInSec:typeof t.nextSuggestedCheckInSec=="number"&&Number.isFinite(t.nextSuggestedCheckInSec)?t.nextSuggestedCheckInSec:void 0,packageManager:t.packageManager,updateCommand:t.updateCommand,installBlocked:t.installBlocked==="service-manager"||t.installBlocked==="manual-install"||t.installBlocked==="desktop-host"?t.installBlocked:void 0}}async function tr(t,e){try{const s=ec(t),n=typeof window<"u"?window.__VSCODE_CONFIG__?.extensionVersion:void 0;e?s.set("currentVersion",e):t==="vscode"&&n&&s.set("currentVersion",n);const o=await wt(`/api/openchamber/update-check?${s.toString()}`,{method:"GET",headers:{Accept:"application/json"},priority:"low"});if(!o.ok)throw new Error(`Server responded with ${o.status}`);return tc(await o.json())}catch(s){return console.warn("Failed to check for updates:",s),null}}const ih=zt({error:nt().trim().min(1)});async function uw(){const t=ec("web");t.set("reportUsage","false");const e=await wt(`/api/openchamber/update-check?${t.toString()}`,{method:"GET",headers:{Accept:"application/json"}}),s=await e.json().catch(()=>null);if(!e.ok){const n=ih.safeParse(s);throw new Error(n.success?n.data.error:`Server responded with ${e.status}`)}return tc(s??{})}function lh(){return Gp()?"mobile":Rl()?"desktop":qs()?"vscode":Wp()?"web":null}const La={checking:!1,available:!1,downloading:!1,downloaded:!1,installing:!1,info:null,progress:null,error:null,runtimeType:null,lastChecked:null,nextCheckInSec:null},ch=Un()((t,e)=>({...La,checkForUpdates:async()=>{const s=lh();if(!s)return null;t({checking:!0,error:null,runtimeType:s});try{let n=null,o=null;if(s==="desktop"){const a="2.5.0",[i,l]=await Promise.allSettled([Ca(),tr("desktop",a)]),c=i.status==="fulfilled"?i.value:null;return o=l.status==="fulfilled"?l.value?.nextSuggestedCheckInSec??null:null,t({checking:!1,available:c?.available??!1,info:c,lastChecked:Date.now(),nextCheckInSec:o}),o}else s==="web"?(n=await tr("web"),o=n?.nextSuggestedCheckInSec??null):s==="vscode"?o=(await tr("vscode"))?.nextSuggestedCheckInSec??null:s==="mobile"&&(n=await tr("mobile","2.5.0"),o=n?.nextSuggestedCheckInSec??null);return t({checking:!1,available:s==="vscode"?!1:n?.available??!1,info:s==="vscode"?null:n,lastChecked:Date.now(),nextCheckInSec:o}),o}catch(n){return t({checking:!1,error:n instanceof Error?n.message:"Failed to check for updates"}),null}},downloadUpdate:async()=>{const{available:s,runtimeType:n}=e();if(!(n!=="desktop"||!s)){t({downloading:!0,error:null,progress:null});try{const o=await Ca();if(!o?.available)throw new Error("Update detected, but desktop package is not ready yet. Retry in a moment.");if(t(i=>({info:i.info?{...i.info,...o,body:i.info.body||o.body,available:i.info.available}:o})),!await Kp(i=>{t({progress:i})}))throw new Error("Desktop update only works on Local instance");t({downloading:!1,downloaded:!0})}catch(o){t({downloading:!1,error:o instanceof Error?o.message:"Failed to download update"})}}},restartToUpdate:async()=>{const{downloaded:s,installing:n,runtimeType:o}=e();if(!(o!=="desktop"||!s||n)){t({error:null,installing:!0});try{if(!await zp())throw new Error(Il(Tl.getState().dictionary,"updateDialog.error.restartUnavailable"))}catch(a){t({installing:!1,error:sh(a instanceof Error?a:new Error(String(a)))})}}},dismiss:()=>{t({available:!1,downloaded:!1,installing:!1,info:null})},reset:()=>{t(La)}})),dh=zt({success:Sr(!0),autoRestart:vn().optional(),updateOwner:nt().optional(),version:nt().min(1).optional()}),uh=zt({available:vn(),currentVersion:nt().optional(),error:nt().optional()}),sc=zt({error:nt(),code:nt().optional()});async function fh(t=wt){try{const e=await t("/api/openchamber/update-install",{method:"POST",headers:{"Content-Type":"application/json"}}),s=await e.json();if(!e.ok){const a=sc.safeParse(s);return{success:!1,error:a.success?a.data.error:void 0}}const n=dh.safeParse(s);if(!n.success)return{success:!1};const o=n.data;return o.updateOwner==="electron-updater"?o.version?{success:!0,autoRestart:o.autoRestart!==!1,target:{owner:"electron",version:o.version}}:{success:!1}:{success:!0,autoRestart:o.autoRestart!==!1,target:{owner:"package-manager"}}}catch(e){return{success:!1,error:e instanceof Error?e.message:void 0}}}async function ph(t,e,{fetchUpdate:s=wt,maxWaitMs:n=600*1e3,intervalMs:o=2e3}={}){const a=Date.now()+n;for(;Date.now()<a;){const i=AbortSignal.timeout(Math.max(1,Math.min(1e4,a-Date.now())));try{const c=await s("/api/openchamber/update-check?appType=web&reportUsage=false&updateStatus=true",{method:"GET",headers:{Accept:"application/json"},signal:i});if(c.ok){const d=uh.safeParse(await c.json());if(d.success&&!d.data.error){const u=d.data;if(t.owner==="electron"?u.currentVersion===t.version:u.available===!1||e!==void 0&&u.currentVersion!==void 0&&u.currentVersion!==e)return{status:"applied"}}}else{const d=sc.safeParse(await c.json().catch(()=>null));if(d.success&&d.data.code==="DESKTOP_UPDATE_RESTART_FAILED")return{status:"failed",error:d.data.error};if(t.owner==="package-manager"&&(c.status===401||c.status===403)&&(await s("/health",{headers:{Accept:"application/json"},signal:i})).ok)return{status:"applied"}}}catch{}const l=a-Date.now();l>0&&await new Promise(c=>setTimeout(c,Math.min(o,l)))}return{status:"timeout"}}const $a="https://github.com/openchamber/openchamber/releases";function mh(t){const e=new Date(`${t}T00:00:00`);return Number.isNaN(e.getTime())?t:new Intl.DateTimeFormat(Oi(),{year:"numeric",month:"short",day:"numeric"}).format(e)}function hh(t){return t.replace(/^## \[[^\]]+\] - \d{4}-\d{2}-\d{2}\s*\n?/,"").trim()}function Ma(t){return t.replace(/(^|[^a-zA-Z0-9])@([a-zA-Z0-9-]+)/g,"$1[@$2](https://github.com/$2)")}function gh(t,e){const s=t.split(".").map(o=>Number.parseInt(o,10)),n=e.split(".").map(o=>Number.parseInt(o,10));for(let o=0;o<3;o+=1){const a=Number.isFinite(s[o])?s[o]:0,i=Number.isFinite(n[o])?n[o]:0;if(a!==i)return i-a}return 0}function xh(t){const e=/^## \[(\d+\.\d+\.\d+)\] - (\d{4}-\d{2}-\d{2})\s*$/gm,s=[];let n;for(;(n=e.exec(t))!==null;)s.push({version:n[1]??"",date:n[2]??"",start:n.index});return s.length===0?[]:s.map((o,a)=>{const i=s[a+1]?.start??t.length,l=t.slice(o.start,i).trim();return{version:o.version,date:o.date,start:o.start,end:i,raw:l}})}const fw=({open:t,onOpenChange:e,info:s,downloading:n,downloaded:o,installing:a=!1,progress:i,error:l,onDownload:c,onRestart:d,runtimeType:u="desktop"})=>{const{t:f}=se(),[p,g]=je.useState(!1),[h,x]=je.useState("idle"),[m,b]=je.useState(null),v=s?.version?s.releaseUrl||`${$a}/tag/v${s.version}`:$a,w=s?.downloadUrl||v,S=i?.total?Math.round(i.downloaded/i.total*100):0,I=u==="web",k=I&&s?.installBlocked==="desktop-host",R=u==="mobile",P=s?.updateCommand||"openchamber update";je.useEffect(()=>{t||(x("idle"),b(null))},[t]);const T=async()=>{(await Lo(P)).ok&&(g(!0),setTimeout(()=>g(!1),2e3))},D=je.useCallback(async E=>{await Er(E)},[]),A=je.useCallback(async()=>{x("updating"),b(null);const E=await fh();if(!E.success){x("error"),b(E.error||f("updateDialog.error.updateFailed"));return}E.autoRestart&&(x("restarting"),await new Promise($=>setTimeout($,2e3))),x("reconnecting");const L=await ph(E.target,s?.currentVersion);L.status==="applied"?window.location.reload():(x("error"),b(L.status==="failed"?L.error:f("updateDialog.error.takingLonger")))},[s?.currentVersion,f]),N=je.useCallback(()=>{D(w)},[D,w]),j=h!=="idle"&&h!=="error",_=je.useMemo(()=>{if(!s?.body)return null;const E=s.body.trim();if(!E)return null;const L=xh(E);if(L.length===0)return{kind:"raw",title:f("updateDialog.changelog.title"),content:Ma(E)};const $=[...L].sort((M,C)=>gh(M.version,C.version));return{kind:"sections",title:f("updateDialog.changelog.title"),sections:$.map(M=>({version:M.version,dateLabel:mh(M.date),content:Ma(hh(M.raw)||E)}))}},[s?.body,f]);return r.jsx(cs,{open:t,onOpenChange:j?void 0:e,children:r.jsxs(ds,{className:"max-w-4xl p-5 border-[var(--interactive-border)]",showCloseButton:!0,children:[r.jsxs("div",{className:"flex items-center mb-1",children:[r.jsxs(us,{className:"flex items-center gap-2.5",children:[r.jsx(B,{name:"download-cloud",className:"h-5 w-5 text-[var(--primary-base)]"}),r.jsx("span",{className:"text-lg font-semibold text-foreground",children:f(h==="restarting"||h==="reconnecting"?"updateDialog.header.updating":"updateDialog.header.updateAvailable")})]}),(s?.currentVersion||s?.version)&&r.jsxs("div",{className:"flex items-center gap-2 font-mono text-sm ms-3",children:[s?.currentVersion&&r.jsx("span",{className:"text-muted-foreground",children:s.currentVersion}),s?.currentVersion&&s?.version&&r.jsx("span",{className:"text-muted-foreground/50",children:"→"}),s?.version&&r.jsx("span",{className:"text-[var(--primary-base)] font-medium",children:s.version})]})]}),r.jsxs("div",{className:"space-y-2",children:[I&&j&&r.jsxs("div",{className:"rounded-lg bg-surface-elevated/30 p-5 border border-border",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Ft,{className:"h-5 w-5 text-[var(--primary-base)]"}),r.jsxs("div",{className:"typography-ui-label text-foreground",children:[h==="updating"&&f("updateDialog.status.installingUpdate"),h==="restarting"&&f("updateDialog.status.serverRestarting"),h==="reconnecting"&&f("updateDialog.status.waitingForServer")]})]}),r.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:f("updateDialog.status.autoReloadHint")})]}),_&&!j&&r.jsx("div",{className:"rounded-lg border border-border bg-surface-elevated/20 overflow-hidden",children:r.jsx(Mn,{className:"max-h-[400px] p-0",fillContainer:!1,children:_.kind==="raw"?r.jsx("div",{className:"p-4 typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline [&_h3]:!mt-4 [&_h3]:!mb-1.5 [&_h3]:!text-xs [&_h3]:!font-medium [&_h3]:!uppercase [&_h3]:!tracking-wide [&_h3]:!text-muted-foreground [&_h3:first-child]:!mt-0",onClickCapture:E=>{const $=E.target.closest("a");$&&$.href&&(E.preventDefault(),E.stopPropagation(),D($.href))},children:r.jsx(lo,{content:_.content,disableLinkSafety:!0,enableFileReferences:!1})}):r.jsx("div",{className:"divide-y divide-border",children:_.sections.map(E=>r.jsxs("div",{className:"p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsxs("span",{className:"typography-ui-label font-mono text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-1.5 py-0.5 rounded",children:["v",E.version]}),r.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:E.dateLabel})]}),r.jsx("div",{className:"typography-markdown-body text-foreground leading-relaxed break-words [&_a]:!text-[var(--primary-base)] [&_a]:!no-underline [&_a:hover]:!underline [&_h3]:!mt-4 [&_h3]:!mb-1.5 [&_h3]:!text-xs [&_h3]:!font-medium [&_h3]:!uppercase [&_h3]:!tracking-wide [&_h3]:!text-muted-foreground [&_h3:first-child]:!mt-0",onClickCapture:L=>{const M=L.target.closest("a");M&&M.href&&(L.preventDefault(),L.stopPropagation(),D(M.href))},children:r.jsx(lo,{content:E.content,disableLinkSafety:!0,enableFileReferences:!1})})]},E.version))})})}),I&&s?.packageManager!=="electron"&&s?.installBlocked!=="manual-install"&&h==="error"&&r.jsxs("div",{className:"space-y-2 mt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[r.jsx(B,{name:"terminal",className:"h-4 w-4"}),r.jsx("span",{children:f("updateDialog.fallback.updateViaTerminal")})]}),r.jsxs("div",{className:"flex items-center gap-2 p-1 ps-3 bg-surface-elevated/50 rounded-md border border-border",children:[r.jsx("code",{className:"flex-1 font-mono text-sm text-foreground overflow-x-auto whitespace-nowrap",children:P}),r.jsx("button",{onClick:T,className:ne("flex items-center justify-center p-2 rounded","text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]","transition-colors",p&&"text-[var(--status-success)]"),title:f(p?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:p?r.jsx(B,{name:"check",className:"h-4 w-4"}):r.jsx(B,{name:"clipboard",className:"h-4 w-4"})})]})]}),!I&&!R&&n&&r.jsxs("div",{className:"space-y-2 mt-4",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:f("updateDialog.status.downloadingPayload")}),r.jsxs("span",{className:"font-mono text-foreground",children:[S,"%"]})]}),r.jsx("div",{className:"h-1.5 bg-[var(--surface-subtle)] rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-[var(--primary-base)] transition-all duration-300",style:{width:`${S}%`}})})]}),k&&r.jsx("p",{className:"mt-4 typography-meta text-muted-foreground",children:f("updateDialog.desktopHostInstall",{version:s?.version||""})}),(l||m)&&r.jsx("div",{className:"p-3 mt-4 bg-[var(--status-error-background)] border border-[var(--status-error-border)] rounded-lg",children:r.jsx("p",{className:"text-sm text-[var(--status-error)]",children:l||m})})]}),r.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4",children:[r.jsxs("a",{href:v,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors shrink-0",children:[r.jsx(B,{name:"external-link",className:"h-4 w-4"}),"GitHub"]}),r.jsxs("div",{className:"flex-1 flex justify-end",children:[!I&&!R&&!o&&!n&&r.jsxs("button",{onClick:c,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[r.jsx(B,{name:"download",className:"h-4 w-4"}),f("updateDialog.actions.downloadUpdate")]}),!I&&!R&&n&&r.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[r.jsx(Ft,{className:"h-4 w-4"}),f("updateDialog.status.downloading")]}),!I&&!R&&o&&a&&r.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)]/50 text-white cursor-not-allowed",children:[r.jsx(Ft,{className:"h-4 w-4"}),f("updateDialog.status.restarting")]}),!I&&!R&&o&&!a&&r.jsxs("button",{onClick:d,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--status-success)] text-white hover:opacity-90 transition-opacity",children:[r.jsx(B,{name:"restart",className:"h-4 w-4"}),f("updateDialog.actions.restartToUpdate")]}),R&&r.jsxs(Q,{onClick:N,size:"default",children:[r.jsx(B,{name:"external-link",className:"h-4 w-4"}),f("updateDialog.actions.openMobileUpdate")]}),I&&!j&&!k&&r.jsxs("button",{onClick:A,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity",children:[r.jsx(B,{name:"download",className:"h-4 w-4"}),f("updateDialog.actions.updateNow")]}),I&&j&&r.jsxs("button",{disabled:!0,className:"flex items-center justify-center gap-2 px-5 py-2 rounded-md text-sm font-medium bg-[var(--primary-base)]/50 text-[var(--primary-foreground)] cursor-not-allowed",children:[r.jsx(Ft,{className:"h-4 w-4"}),f("updateDialog.status.updating")]})]})]})]})})},pw=t=>!(t.dismissed==="true"||t.sessionShown==="true"||t.hasActiveToast),bh=t=>!(!t.version||t.seenVersions.has(t.version)||t.dismissedVersion!==null&&t.dismissedVersion===t.version),yh=t=>{if(t===null||typeof t!="object")return"";const e=t.version;return typeof e!="string"?"":e.trim()},vh=t=>!t||t.available!==!0||typeof t.latestVersion!="string"?"":t.latestVersion.trim(),wh=t=>t?.upgrade?.supported===!0,Sh=zt({available:vn().nullable().optional(),currentVersion:nt().nullable().optional(),latestVersion:nt().nullable().optional(),upgrade:zt({supported:vn().nullable().optional()}).nullable().optional()}),jh=zt({success:vn().optional(),version:nt().optional(),error:nt().optional()});async function Nh(){const t=await wt("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!t.ok)throw new Error(t.statusText||"OpenCode upgrade status check failed");const e=Sh.safeParse(await t.json().catch(()=>null));if(!e.success)throw new Error("OpenCode upgrade status check failed");const s=e.data,n=s.currentVersion?.trim()||null,o=vh(s)||null;return{currentVersion:n,availableVersion:o,supported:wh(s)}}async function kh(t){const e=await wt("/api/opencode/upgrade",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),s=jh.safeParse(await e.json().catch(()=>null)),n=s.success?s.data:null;if(!e.ok||n?.success===!1)throw new Error(n?.error||e.statusText||t);return n?.version??null}const Oa=()=>Rl()&&!El(),mw=()=>y.useSyncExternalStore($s,Oa,Oa),Ms="opencode-update-available",sr="opencode-upgrade-progress",Ch=5e3,Ih=[1e4,6e4],Fa="opencode-update-toast-dismissed-version",hw=()=>{const{t}=se(),e=Ce(i=>i.showOpenCodeUpdateNotifications),s=je.useRef(new Set),n=je.useRef(!1);je.useEffect(()=>{e||Y.dismiss(Ms)},[e]);const o=je.useCallback(()=>{Y.dismiss(sr),yd({message:t("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]}).catch(()=>{})},[t]),a=je.useCallback(async()=>{if(!n.current){n.current=!0,Y.dismiss(Ms),Y.message(t("opencodeUpdate.toast.upgrading.title"),{id:sr,description:t("opencodeUpdate.toast.upgrading.description"),duration:1/0,icon:r.jsx(Ft,{className:"h-4 w-4 text-muted-foreground"})});try{const i=await kh(t("opencodeUpdate.toast.failed.description"));Y.success(t("opencodeUpdate.toast.updated.title"),{id:sr,description:i?t("opencodeUpdate.toast.updated.descriptionWithVersion",{version:i}):t("opencodeUpdate.toast.updated.description"),duration:1/0,icon:r.jsx(B,{name:"check",className:"h-4 w-4 text-[var(--status-success)]"}),action:{label:t("opencodeUpdate.toast.actions.reload"),onClick:o}})}catch(i){Y.error(t("opencodeUpdate.toast.failed.title"),{id:sr,description:i instanceof Error?i.message:t("opencodeUpdate.toast.failed.description"),duration:1/0})}finally{n.current=!1}}},[o,t]);return je.useEffect(()=>{const i=(p,g)=>{if(!Ce.getState().showOpenCodeUpdateNotifications){Y.dismiss(Ms);return}if(!bh({version:p,dismissedVersion:Ia().getItem(Fa),seenVersions:s.current}))return;s.current.add(p);const x={label:t("opencodeUpdate.toast.actions.dismiss"),onClick:()=>{Ia().setItem(Fa,p),Dl({openCodeUpdateToastDismissedVersion:p}),Y.dismiss(Ms)}};Y.info(t("opencodeUpdate.toast.available.title"),g?{id:Ms,description:t("opencodeUpdate.toast.available.description",{version:p}),duration:1/0,action:{label:t("opencodeUpdate.toast.actions.update"),onClick:a},cancel:x}:{id:Ms,description:t("opencodeUpdate.toast.available.manualDescription",{version:p}),duration:1/0,action:x})};let l=!1;const c=[],d=async(p,g=be())=>{try{const h=await Nh();!l&&g===be()&&h.availableVersion&&i(h.availableVersion,h.supported)}catch{const h=Ih[p];!l&&g===be()&&h!==void 0&&c.push(setTimeout(()=>{d(p+1,g)},h))}},u=p=>{yh(p.detail)&&d(0)};e&&c.push(setTimeout(()=>{d(0)},Ch));const f=$s(({runtimeKey:p})=>{s.current.clear(),Y.dismiss(Ms),Ce.getState().showOpenCodeUpdateNotifications&&d(0,p)});return window.addEventListener("openchamber:opencode-update-available",u),()=>{l=!0;for(const p of c)clearTimeout(p);f(),window.removeEventListener("openchamber:opencode-update-available",u)}},[a,e,t]),null},gw=()=>{const t=W.c(3),[e,s]=y.useState(Th),{isUpdating:n}=e;let o,a;if(t[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>wd(s),a=[],t[0]=o,t[1]=a):(o=t[0],a=t[1]),y.useEffect(o,a),!n)return null;let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=r.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-background/90",children:r.jsx(_o,{width:80,height:80,isAnimated:!0})}),t[2]=i):i=t[2],i};function Th(){return vd()}const Rh=1e4,xw=t=>{const e=W.c(22),{ready:s,animated:n}=t,o=n===void 0?!1:n,{t:a}=se(),[i,l]=y.useState(!1),[c,d]=y.useState(!1),u=Pm();let f,p;if(e[0]!==s?(f=()=>{if(s)return;d(!1);const R=setTimeout(()=>d(!0),Rh);return()=>clearTimeout(R)},p=[s],e[0]=s,e[1]=f,e[2]=p):(f=e[1],p=e[2]),y.useEffect(f,p),i)return null;const g=s?"ready":"loading";let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h={loading:{opacity:1},ready:{opacity:0}},e[3]=h):h=e[3];const x=u||!s?0:.3;let m;e[4]!==x?(m={duration:x,ease:"easeOut"},e[4]=x,e[5]=m):m=e[5];let b;e[6]!==s?(b=R=>{R==="ready"&&s&&l(!0)},e[6]=s,e[7]=b):b=e[7];const v=s?"none":"auto";let w;e[8]!==v?(w={pointerEvents:v},e[8]=v,e[9]=w):w=e[9];let S;e[10]!==o?(S=r.jsx(_o,{width:120,height:120,isAnimated:o,variant:"splash"}),e[10]=o,e[11]=S):S=e[11];let I;e[12]!==c||e[13]!==a?(I=c?r.jsx("p",{role:"status",className:"absolute inset-x-0 top-[calc(50%+84px)] px-6 text-center typography-small text-muted-foreground",children:a("startup.overlay.slow")}):null,e[12]=c,e[13]=a,e[14]=I):I=e[14];let k;return e[15]!==w||e[16]!==S||e[17]!==I||e[18]!==g||e[19]!==m||e[20]!==b?(k=r.jsxs(Am.div,{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-[var(--splash-background,var(--surface-background))] text-foreground",initial:"loading",animate:g,variants:h,transition:m,onAnimationComplete:b,style:w,children:[S,I]}),e[15]=w,e[16]=S,e[17]=I,e[18]=g,e[19]=m,e[20]=b,e[21]=k):k=e[21],k};class Eh extends y.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,s){this.setState({error:e,errorInfo:s})}componentDidUpdate(e,s){e.sessionId!==this.props.sessionId&&s.hasError&&this.state.hasError&&this.handleReset()}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?r.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:r.jsxs(Sd,{className:"w-full max-w-md",children:[r.jsx(jd,{className:"text-center",children:r.jsxs(Nd,{className:"flex items-center justify-center gap-2 text-destructive",children:[r.jsx(B,{name:"chat-3",className:"h-5 w-5"}),this.props.texts.title]})}),r.jsxs(kd,{className:"space-y-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground text-center",children:this.props.texts.description}),this.props.sessionId&&r.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:[this.props.texts.sessionLabel,": ",this.props.sessionId]}),this.state.error&&r.jsxs("details",{className:"text-xs font-mono bg-muted p-3 rounded",children:[r.jsx("summary",{className:"cursor-pointer hover:bg-interactive-hover/80",children:this.props.texts.detailsSummary}),r.jsx("pre",{className:"mt-2 max-h-48 overflow-auto",children:this.state.error.toString()})]}),r.jsx("div",{className:"flex gap-2",children:r.jsxs(Q,{onClick:this.handleReset,variant:"outline",className:"flex-1",children:[r.jsx(B,{name:"restart",className:"h-4 w-4 me-2"}),this.props.texts.resetAction]})}),r.jsx("div",{className:"text-xs text-muted-foreground text-center",children:this.props.texts.persistentHint})]})]})}):this.props.children}}function Dh(t){const e=W.c(22),{t:s}=se();let n;e[0]!==s?(n=s("chat.errorBoundary.title"),e[0]=s,e[1]=n):n=e[1];let o;e[2]!==s?(o=s("chat.errorBoundary.description"),e[2]=s,e[3]=o):o=e[3];let a;e[4]!==s?(a=s("chat.errorBoundary.sessionLabel"),e[4]=s,e[5]=a):a=e[5];let i;e[6]!==s?(i=s("chat.errorBoundary.detailsSummary"),e[6]=s,e[7]=i):i=e[7];let l;e[8]!==s?(l=s("chat.errorBoundary.resetAction"),e[8]=s,e[9]=l):l=e[9];let c;e[10]!==s?(c=s("chat.errorBoundary.persistentHint"),e[10]=s,e[11]=c):c=e[11];let d;e[12]!==n||e[13]!==o||e[14]!==a||e[15]!==i||e[16]!==l||e[17]!==c?(d={title:n,description:o,sessionLabel:a,detailsSummary:i,resetAction:l,persistentHint:c},e[12]=n,e[13]=o,e[14]=a,e[15]=i,e[16]=l,e[17]=c,e[18]=d):d=e[18];let u;return e[19]!==t||e[20]!==d?(u=r.jsx(Eh,{...t,texts:d}),e[19]=t,e[20]=d,e[21]=u):u=e[21],u}const bw=t=>{const e=W.c(9),{active:s,readOnly:n,pinnedSession:o}=t,a=s===void 0?!0:s,i=n===void 0?!1:n;let l;e[0]!==o?(l=p=>o?null:p.currentSessionId,e[0]=o,e[1]=l):l=e[1];const c=_e(l),d=o?.sessionId??c??void 0;let u;e[2]!==a||e[3]!==o||e[4]!==i?(u=r.jsx(Cd,{active:a,readOnly:i,pinnedSession:o}),e[2]=a,e[3]=o,e[4]=i,e[5]=u):u=e[5];let f;return e[6]!==d||e[7]!==u?(f=r.jsx(Dh,{sessionId:d,children:u}),e[6]=d,e[7]=u,e[8]=f):f=e[8],f},Ph=$m,yw=t=>{const e=W.c(14);let s,n,o,a;e[0]!==t?({className:o,asChild:s,children:n,...a}=t,e[0]=t,e[1]=s,e[2]=n,e[3]=o,e[4]=a):(s=e[1],n=e[2],o=e[3],a=e[4]);let i;e[5]!==s||e[6]!==n?(i=s&&je.isValidElement(n)?{render:n}:{children:n},e[5]=s,e[6]=n,e[7]=i):i=e[7];const l=i;let c;e[8]!==o?(c=ne("flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-start text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",o),e[8]=o,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==l||e[12]!==c?(d=r.jsx(Mm,{className:c,...a,...l}),e[10]=a,e[11]=l,e[12]=c,e[13]=d):d=e[13],d},Ah=t=>{const e=W.c(8);let s,n;e[0]!==t?({className:s,...n}=t,e[0]=t,e[1]=s,e[2]=n):(s=e[1],n=e[2]);let o;e[3]!==s?(o=ne("transition-opacity duration-100 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0","motion-reduce:transition-none",s),e[3]=s,e[4]=o):o=e[4];let a;return e[5]!==n||e[6]!==o?(a=r.jsx(Om,{className:o,...n}),e[5]=n,e[6]=o,e[7]=a):a=e[7],a},_h=(t,e=()=>Pt.getState().load(t,{force:!0}))=>{const s=ys(t);if(!s)return()=>{};const n=be();let o=!1,a=!1,i=!1,l=!1;const c=()=>!o&&n===be()&&document.visibilityState!=="hidden"&&navigator.onLine!==!1,d=()=>{l=!0,!(!c()||a||i)&&(a=!0,queueMicrotask(()=>{a=!1,c()&&(l=!1,i=!0,e().finally(()=>{i=!1,l&&d()}))}))},u=Fi(f=>{(f.type==="project-context-changed"&&f.projectId===s||f.type==="event-stream-ready")&&d()});return window.addEventListener("focus",d),window.addEventListener("online",d),document.addEventListener("visibilitychange",d),d(),()=>{o=!0,u(),window.removeEventListener("focus",d),window.removeEventListener("online",d),document.removeEventListener("visibilitychange",d)}},Ba=t=>({providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:t.agent});function Lh(t){const e=W.c(129),{t:s}=se(),{open:n,onOpenChange:o,target:a,projectDirectory:i,submitting:l,allowRunAsGoal:c,onConfirm:d}=t,u=l===void 0?!1:l,f=c===void 0?!1:c;let p;e[0]!==f?(p=f&&!qs(),e[0]=f,e[1]=p):p=e[1];const g=p,h=Ot(Wh),x=Ot(Gh),m=Bi(Kh),b=Ot(zh),v=Ot(Uh),w=Ot(Vh),S=Ot(Bh),I=Ot(Fh);let k;e[2]!==I||e[3]!==w||e[4]!==v||e[5]!==S?(k=()=>Ba({providerID:v,modelID:w,variant:S,agent:I}),e[2]=I,e[3]=w,e[4]=v,e[5]=S,e[6]=k):k=e[6];const[R,P]=y.useState(k);let T,D;e[7]!==m||e[8]!==x||e[9]!==h||e[10]!==n||e[11]!==i?(T=()=>{n&&(h({directory:i,source:"todoSendDialog"}),x({directory:i}),m())},D=[n,h,x,m,i],e[7]=m,e[8]=x,e[9]=h,e[10]=n,e[11]=i,e[12]=T,e[13]=D):(T=e[12],D=e[13]),y.useEffect(T,D);let A,N;e[14]!==I||e[15]!==w||e[16]!==v||e[17]!==S||e[18]!==n?(A=()=>{n&&P(Ba({providerID:v,modelID:w,variant:S,agent:I}))},N=[n,v,w,S,I],e[14]=I,e[15]=w,e[16]=v,e[17]=S,e[18]=n,e[19]=A,e[20]=N):(A=e[19],N=e[20]),y.useEffect(A,N);let j,_;e[21]!==R.modelID||e[22]!==R.providerID||e[23]!==n||e[24]!==b?(j=()=>{if(!n||b.length===0)return;const Ae=b.find(Fe=>Fe.id===R.providerID)??b[0],Re=Array.isArray(Ae?.models)?Ae.models:[],at=Re.some(Fe=>Fe.id===R.modelID),Ne=Re[0]?.id??"";Ae?.id===R.providerID&&at||P(Fe=>({...Fe,providerID:Ae?.id??"",modelID:at?Fe.modelID:Ne,variant:""}))},_=[n,b,R.providerID,R.modelID],e[21]=R.modelID,e[22]=R.providerID,e[23]=n,e[24]=b,e[25]=j,e[26]=_):(j=e[25],_=e[26]),y.useEffect(j,_);const E=Oh;let L;if(e[27]!==R.modelID||e[28]!==R.providerID||e[29]!==b){let Ae;e[31]!==R.providerID?(Ae=Ne=>Ne.id===R.providerID,e[31]=R.providerID,e[32]=Ae):Ae=e[32];const at=b.find(Ae)?.models?.find(Ne=>Ne.id===R.modelID);L=Id(at?.variants),e[27]=R.modelID,e[28]=R.providerID,e[29]=b,e[30]=L}else L=e[30];const $=L,M=$.length>0;let C,O;e[33]!==R.variant||e[34]!==M?(C=()=>{M||!R.variant||P(Mh)},O=[M,R.variant],e[33]=R.variant,e[34]=M,e[35]=C,e[36]=O):(C=e[35],O=e[36]),y.useEffect(C,O);let z;e[37]!==R.modelID||e[38]!==R.providerID?(z=R.providerID.trim().length>0&&R.modelID.trim().length>0,e[37]=R.modelID,e[38]=R.providerID,e[39]=z):z=e[39];const G=z;let U;e[40]!==G||e[41]!==R||e[42]!==d||e[43]!==u?(U=()=>{!G||u||d(R)},e[40]=G,e[41]=R,e[42]=d,e[43]=u,e[44]=U):U=e[44];const K=U;let X,re;e[45]!==K||e[46]!==n?(X=()=>{if(!n)return;const Ae=Re=>{(Re.metaKey||Re.ctrlKey)&&Re.key==="Enter"&&(Re.preventDefault(),K())};return window.addEventListener("keydown",Ae),()=>window.removeEventListener("keydown",Ae)},re=[n,K],e[45]=K,e[46]=n,e[47]=X,e[48]=re):(X=e[47],re=e[48]),y.useEffect(X,re);let ee;e[49]!==s||e[50]!==a?(ee=s(a==="worktree"?"rightSidebar.contextNotesTodo.sendDialog.title.newWorktree":"rightSidebar.contextNotesTodo.sendDialog.title.newSession"),e[49]=s,e[50]=a,e[51]=ee):ee=e[51];const xe=ee;let ce;e[52]!==o||e[53]!==u?(ce=Ae=>{u||o(Ae)},e[52]=o,e[53]=u,e[54]=ce):ce=e[54];let he;e[55]!==xe?(he=r.jsx(vs,{children:r.jsx(us,{children:xe})}),e[55]=xe,e[56]=he):he=e[56];let ie;e[57]!==s?(ie=s("chat.modelControls.model"),e[57]=s,e[58]=ie):ie=e[58];let pe;e[59]!==ie?(pe=r.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:ie}),e[59]=ie,e[60]=pe):pe=e[60];let le;e[61]===Symbol.for("react.memo_cache_sentinel")?(le=(Ae,Re)=>{P(at=>({...at,providerID:Ae,modelID:Re,variant:""}))},e[61]=le):le=e[61];let de;e[62]!==R.modelID||e[63]!==R.providerID?(de=r.jsx(Vi,{providerId:R.providerID,modelId:R.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:le}),e[62]=R.modelID,e[63]=R.providerID,e[64]=de):de=e[64];let te;e[65]!==pe||e[66]!==de?(te=r.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[pe,de]}),e[65]=pe,e[66]=de,e[67]=te):te=e[67];let J;e[68]!==s?(J=s("sessions.scheduledTasks.editor.thinkingLevel.label"),e[68]=s,e[69]=J):J=e[69];let q;e[70]!==J?(q=r.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:J}),e[70]=J,e[71]=q):q=e[71];const oe=!M;let ue;e[72]===Symbol.for("react.memo_cache_sentinel")?(ue=Ae=>P(Re=>({...Re,variant:Ae})),e[72]=ue):ue=e[72];let Ie;e[73]!==R.variant||e[74]!==oe||e[75]!==$?(Ie=r.jsx(Td,{value:R.variant,options:$,disabled:oe,onChange:ue}),e[73]=R.variant,e[74]=oe,e[75]=$,e[76]=Ie):Ie=e[76];let Le;e[77]!==q||e[78]!==Ie?(Le=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[q,Ie]}),e[77]=q,e[78]=Ie,e[79]=Le):Le=e[79];let we;e[80]!==s?(we=s("sessions.scheduledTasks.editor.agent.label"),e[80]=s,e[81]=we):we=e[81];let $e;e[82]!==we?($e=r.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:we}),e[82]=we,e[83]=$e):$e=e[83];let ke;e[84]===Symbol.for("react.memo_cache_sentinel")?(ke=Ae=>P(Re=>({...Re,agent:Ae})),e[84]=ke):ke=e[84];let Te;e[85]!==R.agent?(Te=r.jsx(Ui,{agentName:R.agent,filter:E,dropdownPortalToBody:!0,onChange:ke}),e[85]=R.agent,e[86]=Te):Te=e[86];let ae;e[87]!==$e||e[88]!==Te?(ae=r.jsxs("div",{className:"flex flex-col gap-1.5",children:[$e,Te]}),e[87]=$e,e[88]=Te,e[89]=ae):ae=e[89];let fe;e[90]!==te||e[91]!==Le||e[92]!==ae?(fe=r.jsxs("div",{className:"flex flex-col gap-4",children:[te,Le,ae]}),e[90]=te,e[91]=Le,e[92]=ae,e[93]=fe):fe=e[93];const ge=`flex items-center gap-3 ${g?"justify-between":"justify-end"}`;let Oe;e[94]!==R.runAsGoal||e[95]!==g||e[96]!==u||e[97]!==s?(Oe=g?r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(zi,{checked:R.runAsGoal===!0,onChange:Ae=>P(Re=>({...Re,runAsGoal:Ae})),disabled:u,ariaLabel:s("sessions.scheduledTasks.editor.goal.aria")}),r.jsx("button",{type:"button",className:"truncate typography-ui-label text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",disabled:u,onClick:()=>P($h),children:s("sessions.scheduledTasks.editor.goal.label")})]}):null,e[94]=R.runAsGoal,e[95]=g,e[96]=u,e[97]=s,e[98]=Oe):Oe=e[98];let Be;e[99]!==o?(Be=()=>o(!1),e[99]=o,e[100]=Be):Be=e[100];let Xe;e[101]!==s?(Xe=s("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[101]=s,e[102]=Xe):Xe=e[102];let Ue;e[103]!==u||e[104]!==Be||e[105]!==Xe?(Ue=r.jsx(Q,{variant:"ghost",size:"sm",onClick:Be,disabled:u,children:Xe}),e[103]=u,e[104]=Be,e[105]=Xe,e[106]=Ue):Ue=e[106];const Ye=!G||u;let ze;e[107]!==u||e[108]!==s?(ze=s(u?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[107]=u,e[108]=s,e[109]=ze):ze=e[109];let Me;e[110]!==K||e[111]!==Ye||e[112]!==ze?(Me=r.jsx(Q,{size:"sm",onClick:K,disabled:Ye,children:ze}),e[110]=K,e[111]=Ye,e[112]=ze,e[113]=Me):Me=e[113];let Pe;e[114]!==Ue||e[115]!==Me?(Pe=r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[Ue,Me]}),e[114]=Ue,e[115]=Me,e[116]=Pe):Pe=e[116];let Ge;e[117]!==ge||e[118]!==Oe||e[119]!==Pe?(Ge=r.jsxs("div",{className:ge,children:[Oe,Pe]}),e[117]=ge,e[118]=Oe,e[119]=Pe,e[120]=Ge):Ge=e[120];let et;e[121]!==he||e[122]!==fe||e[123]!==Ge?(et=r.jsxs(ds,{className:"max-w-md overflow-visible",children:[he,fe,Ge]}),e[121]=he,e[122]=fe,e[123]=Ge,e[124]=et):et=e[124];let tt;return e[125]!==n||e[126]!==ce||e[127]!==et?(tt=r.jsx(cs,{open:n,onOpenChange:ce,children:et}),e[125]=n,e[126]=ce,e[127]=et,e[128]=tt):tt=e[128],tt}function $h(t){return{...t,runAsGoal:t.runAsGoal!==!0}}function Mh(t){return{...t,variant:""}}function Oh(t){return Ki(t.mode)}function Fh(t){return t.currentAgentName||""}function Bh(t){return t.currentVariant||""}function Vh(t){return t.currentModelId}function Uh(t){return t.currentProviderId}function zh(t){return t.providers}function Kh(t){return t.loadAgents}function Gh(t){return t.loadAgents}function Wh(t){return t.loadProviders}const Vo=y.createContext(null);function Uo(){return y.useContext(Vo)!==null}function qh(t){const e=W.c(3),{value:s,children:n}=t;let o;return e[0]!==n||e[1]!==s?(o=r.jsx(Vo.Provider,{value:s,children:n}),e[0]=n,e[1]=s,e[2]=o):o=e[2],o}function zo(t){const e=W.c(5),{children:s}=t,n=y.useContext(Vo);if(!n)return s;let o;e[0]!==s?(o=r.jsx("div",{"data-context-panel-toolbar":"",className:"flex min-w-0 flex-1 items-stretch",children:s}),e[0]=s,e[1]=o):o=e[1];let a;return e[2]!==n||e[3]!==o?(a=md.createPortal(o,n),e[2]=n,e[3]=o,e[4]=a):a=e[4],a}const nr="flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition-shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",rr="ring-2 ring-foreground ring-offset-2 ring-offset-background",Hh=t=>{const e=W.c(40),{value:s,onChange:n,labels:o,legacyCss:a}=t,i=a===void 0?null:a,l=s.toLowerCase(),c=ua.some(U=>U===l),d=l!==""&&!Tn(l)&&i!==null,u=l!==""&&!c&&!d,f=y.useRef(null),[p,g]=y.useState(s);let h;e[0]!==g||e[1]!==s?(h=()=>g(s),e[0]=g,e[1]=s,e[2]=h):h=e[2];let x;e[3]!==s?(x=[s],e[3]=s,e[4]=x):x=e[4],y.useEffect(h,x);let m;e[5]!==p?(m=p.trim()!==""&&!Tn(p.trim()),e[5]=p,e[6]=m):m=e[6];const b=m;let v;e[7]!==p||e[8]!==n?(v=()=>{const U=p.trim();(U===""||Tn(U))&&n(U.toLowerCase())},e[7]=p,e[8]=n,e[9]=v):v=e[9];const w=v;let S;e[10]!==n?(S=()=>n(""),e[10]=n,e[11]=S):S=e[11];const I=l==="",k=l===""&&rr;let R;e[12]!==k?(R=ne(nr,"border border-border text-muted-foreground",k),e[12]=k,e[13]=R):R=e[13];let P;e[14]===Symbol.for("react.memo_cache_sentinel")?(P=r.jsx(B,{name:"close",className:"h-3.5 w-3.5"}),e[14]=P):P=e[14];let T;e[15]!==o.empty||e[16]!==S||e[17]!==I||e[18]!==R?(T=r.jsx("button",{type:"button",onClick:S,"aria-pressed":I,className:R,title:o.empty,"aria-label":o.empty,children:P}),e[15]=o.empty,e[16]=S,e[17]=I,e[18]=R,e[19]=T):T=e[19];let D;e[20]!==d||e[21]!==i?(D=d?r.jsx("span",{"aria-hidden":"true",className:ne(nr,rr),style:{backgroundColor:i}}):null,e[20]=d,e[21]=i,e[22]=D):D=e[22];const A=ua.map(U=>r.jsx("button",{type:"button",onClick:()=>n(U),"aria-pressed":l===U,className:ne(nr,l===U&&rr),style:{backgroundColor:U},title:U,"aria-label":o.swatch(U)},U));let N;e[23]===Symbol.for("react.memo_cache_sentinel")?(N=()=>f.current?.click(),e[23]=N):N=e[23];const j=u?rr:"border border-dashed border-border text-muted-foreground hover:text-foreground";let _;e[24]!==j?(_=ne(nr,j),e[24]=j,e[25]=_):_=e[25];let E;e[26]!==u?(E=u?null:r.jsx(B,{name:"add",className:"h-3.5 w-3.5"}),e[26]=u,e[27]=E):E=e[27];const L="color",$=-1,M="true",C=Tn(l)?l:"#808080";let O;e[28]!==n?(O=U=>n(U.target.value.toLowerCase()),e[28]=n,e[29]=O):O=e[29];let z;e[30]!==C||e[31]!==O?(z=r.jsx("input",{ref:f,type:L,tabIndex:$,"aria-hidden":M,value:C,onChange:O,className:"sr-only"}),e[30]=C,e[31]=O,e[32]=z):z=e[32];let G;return e[33]!==w||e[34]!==p||e[35]!==b||e[36]!==u||e[37]!==o.hex||e[38]!==g?(G=u?r.jsx(It,{value:p,onChange:U=>g(U.target.value),onBlur:w,onKeyDown:U=>{U.key==="Enter"&&w()},placeholder:"#RRGGBB","aria-invalid":b,"aria-label":o.hex,className:"h-7 w-24 rounded-md px-2 font-mono typography-meta"}):null,e[33]=w,e[34]=p,e[35]=b,e[36]=u,e[37]=o.hex,e[38]=g,e[39]=G):G=e[39],r.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[T,D,A,r.jsx("button",{type:"button",onClick:N,"aria-pressed":u,className:_,style:u?{backgroundColor:l}:void 0,title:o.custom,"aria-label":o.custom,children:E}),z,G]})},Yh=y.createContext(0),Jh=t=>{const e=W.c(23),{children:s,className:n,outerClassName:o,title:a,titleLeading:i,titleAccessory:l,description:c,headerEnd:d,showSaveStatus:u,onBlurCapture:f}=t,p=u===void 0?!1:u,g=y.useContext(Yh),h=a!=null||c!=null||d!=null||p,x=typeof a=="string"||typeof a=="number",m=i!=null||l!=null;let b;e[0]!==o?(b=ne("h-full overlay-scrollbar-wrapper--stable-gutter",o),e[0]=o,e[1]=b):b=e[1];let v;e[2]!==n?(v=ne("mx-auto max-w-[840px] space-y-0 px-6 py-6 @3xl:px-12 @3xl:py-8","[&>section:first-of-type]:border-t-0 [&>section:first-of-type]:pt-0",n),e[2]=n,e[3]=v):v=e[3];let w;e[4]!==c||e[5]!==h||e[6]!==m||e[7]!==d||e[8]!==x||e[9]!==p||e[10]!==a||e[11]!==l||e[12]!==i?(w=h&&r.jsxs("div",{className:"mb-2 flex flex-wrap items-start justify-between gap-x-4 gap-y-3 pb-6",children:[r.jsxs("div",{className:"min-w-0 flex-1 basis-64 space-y-1",children:[a!=null?x?m?r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[i,r.jsx("h1",{"data-settings-page-heading":!0,tabIndex:-1,className:ne(fa,"min-w-0 truncate"),children:a}),r.jsx("span",{className:"shrink-0",children:l})]}):r.jsx("h1",{"data-settings-page-heading":!0,tabIndex:-1,className:fa,children:a}):a:null,c!=null?typeof c=="string"||typeof c=="number"?r.jsx("p",{className:Rd,children:c}):c:null]}),r.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-3",children:[d,p&&r.jsx(Qh,{})]})]}),e[4]=c,e[5]=h,e[6]=m,e[7]=d,e[8]=x,e[9]=p,e[10]=a,e[11]=l,e[12]=i,e[13]=w):w=e[13];let S;e[14]!==s||e[15]!==f||e[16]!==v||e[17]!==w?(S=r.jsxs("div",{className:v,onBlurCapture:f,children:[w,s]}),e[14]=s,e[15]=f,e[16]=v,e[17]=w,e[18]=S):S=e[18];let I;return e[19]!==g||e[20]!==b||e[21]!==S?(I=r.jsx(Mn,{outerClassName:b,className:"w-full @container",verticalTrackStart:g,children:S}),e[19]=g,e[20]=b,e[21]=S,e[22]=I):I=e[22],I},Xh=500,Qh=()=>{const t=W.c(13),{t:e}=se(),s=y.useSyncExternalStore(Hp,Ta,Ta),[n,o]=y.useState(!1);let a,i;if(t[0]!==s?(a=()=>{if(s!=="saving"){o(!1);return}const u=setTimeout(()=>o(!0),Xh);return()=>clearTimeout(u)},i=[s],t[0]=s,t[1]=a,t[2]=i):(a=t[1],i=t[2]),y.useEffect(a,i),s==="error"){let u;t[3]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(B,{name:"error-warning",className:"size-3.5"}),t[3]=u):u=t[3];let f;t[4]!==e?(f=e("settings.common.status.saveFailed"),t[4]=e,t[5]=f):f=t[5];let p;return t[6]!==f?(p=r.jsxs("div",{"aria-live":"assertive",className:"flex shrink-0 items-center gap-1.5 typography-meta text-[var(--status-error)]",children:[u,r.jsx("span",{children:f})]}),t[6]=f,t[7]=p):p=t[7],p}if(s!=="saving"||!n)return null;let l;t[8]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(B,{name:"loader-4",className:"size-3.5 animate-spin"}),t[8]=l):l=t[8];let c;t[9]!==e?(c=e("settings.common.actions.saving"),t[9]=e,t[10]=c):c=t[10];let d;return t[11]!==c?(d=r.jsxs("div",{"aria-live":"polite",className:"flex shrink-0 items-center gap-1.5 typography-meta text-muted-foreground",children:[l,r.jsx("span",{children:c})]}),t[11]=c,t[12]=d):d=t[12],d},vw="grid grid-cols-1 gap-3 @xl:grid-cols-2 @3xl:grid-cols-3",wo=ne("group flex min-h-[132px] flex-col rounded-xl p-4 text-start","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]"),Zh={success:"bg-[var(--status-success)]/15 text-[var(--status-success)]",warning:"bg-[var(--status-warning)]/15 text-[var(--status-warning)]",error:"bg-[var(--status-error)]/15 text-[var(--status-error)]",info:"bg-[var(--status-info)]/15 text-[var(--status-info)]",neutral:"oc-tile-inset text-muted-foreground"},Ko=t=>{const e=W.c(5),{tone:s,children:n}=t,o=Zh[s];let a;e[0]!==o?(a=ne("max-w-40 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",o),e[0]=o,e[1]=a):a=e[1];let i;return e[2]!==n||e[3]!==a?(i=r.jsx("span",{className:a,children:n}),e[2]=n,e[3]=a,e[4]=i):i=e[4],i},eg=t=>{const e=W.c(2),{children:s}=t;let n;return e[0]!==s?(n=r.jsx("span",{className:"oc-tile-inset shrink-0 rounded-full px-2 py-px text-[10px] font-medium",children:s}),e[0]=s,e[1]=n):n=e[1],n},nc=t=>{const e=W.c(5),{action:s}=t;let n;e[0]!==s.icon?(n=s.icon?r.jsx(B,{name:s.icon,className:"size-4"}):null,e[0]=s.icon,e[1]=n):n=e[1];let o;return e[2]!==s.label||e[3]!==n?(o=r.jsxs(r.Fragment,{children:[n,s.label]}),e[2]=s.label,e[3]=n,e[4]=o):o=e[4],o},ww=t=>{const e=W.c(60),{icon:s,title:n,subtitle:o,description:a,badges:i,footer:l,muted:c,onOpen:d,actions:u,actionsLabel:f}=t,p=(u?.length??0)>0,g=c&&"opacity-60";let h;e[0]!==g?(h=ne("oc-tile-inset flex size-10 shrink-0 items-center justify-center rounded-[10px]",g),e[0]=g,e[1]=h):h=e[1];let x;e[2]!==s||e[3]!==h?(x=r.jsx("span",{className:h,children:s}),e[2]=s,e[3]=h,e[4]=x):x=e[4];let m;e[5]!==i?(m=i?r.jsx("span",{className:"flex min-w-0 flex-wrap justify-end gap-1",children:i}):null,e[5]=i,e[6]=m):m=e[6];let b;e[7]!==x||e[8]!==m?(b=r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[x,m]}),e[7]=x,e[8]=m,e[9]=b):b=e[9];const v=c&&"opacity-60";let w;e[10]!==v?(w=ne("mt-3 min-w-0",v),e[10]=v,e[11]=w):w=e[11];let S;e[12]!==n?(S=r.jsx("div",{className:"truncate text-sm font-semibold text-foreground",title:n,children:n}),e[12]=n,e[13]=S):S=e[13];let I;e[14]!==o?(I=o?r.jsx("div",{className:"mt-0.5 truncate font-mono typography-micro text-muted-foreground",title:o,children:o}):null,e[14]=o,e[15]=I):I=e[15];let k;e[16]!==a?(k=a?r.jsx("div",{className:"mt-1 line-clamp-2 typography-micro text-muted-foreground",children:a}):null,e[16]=a,e[17]=k):k=e[17];let R;e[18]!==k||e[19]!==w||e[20]!==S||e[21]!==I?(R=r.jsxs("div",{className:w,children:[S,I,k]}),e[18]=k,e[19]=w,e[20]=S,e[21]=I,e[22]=R):R=e[22];const P=p&&"pe-8";let T;e[23]!==P?(T=ne("mt-auto flex min-w-0 items-center gap-2 pt-3 typography-micro text-muted-foreground",P),e[23]=P,e[24]=T):T=e[24];let D;e[25]!==p||e[26]!==d?(D=d&&!p?r.jsx(B,{name:"arrow-right-s",className:"ms-auto size-4 shrink-0 opacity-0 transition-opacity duration-150 group-hover:opacity-70 group-focus-visible:opacity-70","aria-hidden":!0}):null,e[25]=p,e[26]=d,e[27]=D):D=e[27];let A;e[28]!==l||e[29]!==T||e[30]!==D?(A=r.jsxs("div",{className:T,children:[l,D]}),e[28]=l,e[29]=T,e[30]=D,e[31]=A):A=e[31];let N;e[32]!==R||e[33]!==A||e[34]!==b?(N=r.jsxs(r.Fragment,{children:[b,R,A]}),e[32]=R,e[33]=A,e[34]=b,e[35]=N):N=e[35];const j=N;let _;e[36]!==j||e[37]!==d?(_=d?r.jsx("button",{type:"button",onClick:d,className:ne(wo,"oc-tile oc-tile-hover h-full w-full"),children:j}):r.jsx("div",{className:ne(wo,"oc-tile h-full"),children:j}),e[36]=j,e[37]=d,e[38]=_):_=e[38];const E=_;if(!p||!u)return E;let L;e[39]===Symbol.for("react.memo_cache_sentinel")?(L=r.jsx("div",{className:"group relative"}),e[39]=L):L=e[39];let $;e[40]===Symbol.for("react.memo_cache_sentinel")?($=r.jsx(B,{name:"more-2",className:"size-4"}),e[40]=$):$=e[40];let M;e[41]!==f?(M=r.jsx(Bt,{asChild:!0,children:r.jsx(Q,{variant:"ghost",size:"icon",className:"absolute bottom-3 inset-e-3 h-7 w-7 text-muted-foreground opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100 data-[state=open]:opacity-100","aria-label":f,title:f,children:$})}),e[41]=f,e[42]=M):M=e[42];let C;e[43]!==u?(C=u.map(tg),e[43]=u,e[44]=C):C=e[44];let O;e[45]!==C?(O=r.jsx(Vt,{align:"end",className:"w-fit min-w-32",children:C}),e[45]=C,e[46]=O):O=e[46];let z;e[47]!==M||e[48]!==O?(z=r.jsxs(Ut,{children:[M,O]}),e[47]=M,e[48]=O,e[49]=z):z=e[49];let G;e[50]!==E||e[51]!==z?(G=r.jsxs(Gi,{render:L,children:[E,z]}),e[50]=E,e[51]=z,e[52]=G):G=e[52];let U;e[53]!==u?(U=u.map(sg),e[53]=u,e[54]=U):U=e[54];let K;e[55]!==U?(K=r.jsx(Wi,{className:"w-fit min-w-32",children:U}),e[55]=U,e[56]=K):K=e[56];let X;return e[57]!==G||e[58]!==K?(X=r.jsxs(qi,{children:[G,K]}),e[57]=G,e[58]=K,e[59]=X):X=e[59],X},Sw=t=>{const e=W.c(11),{label:s,hint:n,onClick:o,settingsItem:a}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=ne(wo,"oc-tile-hover items-center justify-center gap-2 text-center border border-dashed border-[color-mix(in_srgb,var(--foreground)_14%,transparent)] text-muted-foreground hover:text-foreground"),e[0]=i):i=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx("span",{className:"oc-tile-inset flex size-10 items-center justify-center rounded-[10px]",children:r.jsx(B,{name:"add",className:"size-5"})}),e[1]=l):l=e[1];let c;e[2]!==s?(c=r.jsx("span",{className:"typography-ui-label font-medium",children:s}),e[2]=s,e[3]=c):c=e[3];let d;e[4]!==n?(d=n?r.jsx("span",{className:"typography-micro",children:n}):null,e[4]=n,e[5]=d):d=e[5];let u;return e[6]!==o||e[7]!==a||e[8]!==c||e[9]!==d?(u=r.jsxs("button",{type:"button",onClick:o,"data-settings-item":a,className:i,children:[l,c,d]}),e[6]=o,e[7]=a,e[8]=c,e[9]=d,e[10]=u):u=e[10],u},jw=t=>{const e=W.c(7),{value:s,onChange:n,placeholder:o}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=r.jsx(B,{name:"search",className:"pointer-events-none absolute inset-s-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground","aria-hidden":!0}),e[0]=a):a=e[0];let i;e[1]!==n?(i=c=>n(c.target.value),e[1]=n,e[2]=i):i=e[2];let l;return e[3]!==o||e[4]!==i||e[5]!==s?(l=r.jsxs("div",{className:"relative mb-4 max-w-[24rem]",children:[a,r.jsx(It,{value:s,onChange:i,placeholder:o,"aria-label":o,className:"ps-8"})]}),e[3]=o,e[4]=i,e[5]=s,e[6]=l):l=e[6],l},Nw=t=>{const e=W.c(4),{label:s,onClick:n}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(B,{name:"arrow-left-s",className:"size-4"}),e[0]=o):o=e[0];let a;return e[1]!==s||e[2]!==n?(a=r.jsx(Q,{variant:"ghost",size:"icon",className:"-ms-2 h-7 w-7 shrink-0",onClick:n,"aria-label":s,title:s,children:o}),e[1]=s,e[2]=n,e[3]=a):a=e[3],a},kw=t=>{const e=W.c(2),{name:s}=t;let n;return e[0]!==s?(n=r.jsx(B,{name:s,className:"size-5 text-muted-foreground"}),e[0]=s,e[1]=n):n=e[1],n};function tg(t){return r.jsx(lt,{variant:t.destructive?"destructive":"default",onClick:t.onSelect,children:r.jsx(nc,{action:t})},t.label)}function sg(t){return r.jsx(yn,{className:ne(t.destructive&&"text-destructive focus:text-destructive"),onClick:t.onSelect,children:r.jsx(nc,{action:t})},t.label)}let Go=0,rc=be(),or=0,xr=0,ar=0,ir=0,fn=0;const kr=new Map,Rn=()=>({runtimeKey:be(),generation:Go}),xs=t=>t.runtimeKey===be()&&t.runtimeKey===rc&&t.generation===Go,Hr=t=>{const e=(kr.get(t)??0)+1;return kr.set(t,e),xr+=1,{...Rn(),mutationGeneration:e}},pn=(t,e)=>xs(t)&&kr.get(e)===t.mutationGeneration,Va=Im([Qp,Sr("")]).nullable().transform(t=>t||null),Fs=Un()(_m((t,e)=>({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,isLoading:!1,setSelectedProfile:s=>t({selectedProfileId:s}),loadProfiles:async()=>{const s=Rn(),n=++or,o=xr;t({isLoading:!0});try{const a=Xp.parse(await _d());return!xs(s)||n!==or?!1:(t(o===xr?{profiles:a,isLoading:!1}:{isLoading:!1}),!0)}catch(a){return!xs(s)||n!==or||(console.error("Failed to load git identity profiles:",a),t({isLoading:!1})),!1}},loadGlobalIdentity:async()=>{const s=Rn(),n=++ar;try{const o=await Ad(),a=o===null?null:Jp.parse(o);return!xs(s)||n!==ar?!1:(t({globalIdentity:{id:"global",name:a?.userName??"",userName:a?.userName??"",userEmail:a?.userEmail??"",color:"info",icon:"fingerprint"}}),!0)}catch(o){return!xs(s)||n!==ar||console.error("Failed to load global git identity:",o),!1}},loadDefaultGitIdentityId:async()=>{const s=Rn(),n=++ir,o=fn;try{const a=await Yp();if(!xs(s))return!1;const i=Va.parse(a?.defaultGitIdentityId??null);return n!==ir||o!==fn?!1:(t({defaultGitIdentityId:i}),!0)}catch(a){return!xs(s)||n!==ir||console.error("Failed to load default git identity setting:",a),!1}},setDefaultGitIdentityId:async s=>{const n=Rn(),o=++fn,a=Va.parse(s);try{const i=a;return await Dl({defaultGitIdentityId:a??""}),!xs(n)||o!==fn?!1:(t({defaultGitIdentityId:i}),!0)}catch(i){return!xs(n)||o!==fn||console.error("Failed to save default git identity setting:",i),!1}},createProfile:async s=>{const n={...s,id:s.id||`profile-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,color:s.color||"keyword",icon:s.icon||"branch"},o=Hr(n.id);try{Ht("saving");const a=Ra.parse(await Pd(n));if(a.id!==n.id)throw new Error("Created Git identity profile ID does not match the request");return pn(o,n.id)?(t(i=>({profiles:[...i.profiles.filter(l=>l.id!==a.id),a]})),Ht("saved"),!0):!1}catch(a){return pn(o,n.id)&&(Ht("error"),console.error("Failed to create git identity profile:",a)),!1}},updateProfile:async(s,n)=>{const o=e().profiles.find(i=>i.id===s);if(!o)return!1;const a=Hr(s);try{Ht("saving");const i=Ra.parse(await Dd(s,{...o,...n,id:s}));if(i.id!==s)throw new Error("Updated Git identity profile ID does not match the request");return pn(a,s)?(t(l=>({profiles:l.profiles.map(c=>c.id===s?i:c)})),Ht("saved"),!0):!1}catch(i){return pn(a,s)&&(Ht("error"),console.error("Failed to update git identity profile:",i)),!1}},deleteProfile:async s=>{const n=Hr(s);try{return Ht("saving"),await Ed(s),pn(n,s)?(t(o=>({profiles:o.profiles.filter(a=>a.id!==s),selectedProfileId:o.selectedProfileId===s?null:o.selectedProfileId,defaultGitIdentityId:o.defaultGitIdentityId===s?null:o.defaultGitIdentityId})),Ht("saved"),!0):!1}catch(o){return pn(n,s)&&(Ht("error"),console.error("Failed to delete git identity profile:",o)),!1}},getProfileById:s=>s==="global"?e().globalIdentity||void 0:e().profiles.find(n=>n.id===s),resetForRuntimeSwitch:s=>{Go+=1,rc=s,or+=1,ar+=1,ir+=1,fn+=1,xr+=1,kr.clear(),Ht("saved"),t({selectedProfileId:null,defaultGitIdentityId:null,profiles:[],globalIdentity:null,isLoading:!1})}}),{name:"git-identities-store"})),Ua=(t,e)=>e.updatedAtMs-t.updatedAtMs,za=Un((t,e)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!e().isLoading){t({isLoading:!0,error:null});try{const[s,n]=await Promise.all([Od(),ma()]),o={};for(const a of n.sort(Ua))o[a.id]=a;e().listenerReady||await Fd(a=>{t(i=>({statusesById:{...i.statusesById,[a.id]:a}}))}),t({instances:s.instances,statusesById:o,isLoading:!1,initialized:!0,listenerReady:!0})}catch(s){t({isLoading:!1,error:s instanceof Error?s.message:String(s)})}}},loadImports:async()=>{if(!e().isImportsLoading){t({isImportsLoading:!0,error:null});try{const s=await Md();t({importCandidates:s,isImportsLoading:!1})}catch(s){t({isImportsLoading:!1,error:s instanceof Error?s.message:String(s)})}}},refreshStatuses:async()=>{try{const s=await ma(),n={};for(const o of s.sort(Ua))n[o.id]=o;t({statusesById:n})}catch(s){t({error:s instanceof Error?s.message:String(s)})}},setInstances:async s=>{t({isSaving:!0,error:null});try{await $d({instances:s}),t({instances:s,isSaving:!1}),await e().refreshStatuses()}catch(n){throw t({isSaving:!1,error:n instanceof Error?n.message:String(n)}),n}},upsertInstance:async s=>{const n=e().instances,o=n.some(a=>a.id===s.id)?n.map(a=>a.id===s.id?s:a):[s,...n];await e().setInstances(o)},createFromCommand:async(s,n,o)=>{const a=Bd(s,n);o&&o.trim()&&(a.nickname=o.trim()),await e().upsertInstance(a)},removeInstance:async s=>{await pa(s).catch(()=>{});const n=e().instances.filter(o=>o.id!==s);await e().setInstances(n),t(o=>{const a={...o.statusesById};return delete a[s],{statusesById:a}})},connect:async s=>{t({error:null});try{await Ld(s),await e().refreshStatuses()}catch(n){throw t({error:n instanceof Error?n.message:String(n)}),n}},disconnect:async s=>{t({error:null});try{await pa(s),await e().refreshStatuses()}catch(n){throw t({error:n instanceof Error?n.message:String(n)}),n}},retry:async s=>{await e().connect(s)},getStatus:s=>e().statusesById[s]||null,clearError:()=>t({error:null})})),ng=Vd,oc=t=>ng[t||"play"]??"play",So=[{value:"macos",label:"macOS"},{value:"linux",label:"Linux"},{value:"windows",label:"Windows"}],rg=t=>{const e=new Set(t.personal.projectActions.map(n=>n.id)),s=new Set(t.personal.hiddenSharedActionIds);return[...t.shared.projectActions.filter(n=>!e.has(n.id)).map(n=>({action:n,source:"shared",hidden:s.has(n.id)})),...t.personal.projectActions.map(n=>({action:n,source:"personal",hidden:!1}))]},ac=t=>t.shared.status!=="invalid",og=t=>{const e={...t};return delete e.source,e},Ka=(t,e)=>{const s=og(e);return t.some(n=>n.id===s.id)?t.map(n=>n.id===s.id?s:n):[...t,s]},Cr=(t,e)=>t.filter(s=>s.id!==e),ag=async(t,e,s,n,o)=>{const a=o==="shared"?await e.sharedActions(Ka(t.shared.projectActions,s)):await e.personalActions(Ka(t.personal.projectActions,s));return!a||n===null||n===o?a:n==="shared"?e.sharedActions(Cr(t.shared.projectActions,s.id)):e.personalActions(Cr(t.personal.projectActions,s.id))},ig=async(t,e,s)=>s.source==="personal"?e.personalActions(Cr(t.personal.projectActions,s.action.id)):await e.sharedActions(Cr(t.shared.projectActions,s.action.id))?(s.hidden&&await e.hiddenSharedActionIds(t.personal.hiddenSharedActionIds.filter(n=>n!==s.action.id)),!0):!1,lg=(t,e,s,n)=>{const o=t.personal.hiddenSharedActionIds.filter(a=>a!==s);return e.hiddenSharedActionIds(n?[...o,s]:o)},cg=t=>{const e=t.personal.setupWorktreeMode==="replace";return[...t.shared.setupWorktree.map((s,n)=>({command:s,source:"shared",index:n,skipped:e})),...t.personal.setupWorktree.map((s,n)=>({command:s,source:"personal",index:n,skipped:!1}))]},ic=(t,e)=>e==="shared"?t.shared.setupWorktree:t.personal.setupWorktree,lc=(t,e,s)=>e==="shared"?t.sharedCommands(s):t.personalCommands(s),cc=(t,e,s,n)=>{const o=n.trim(),a=ic(t,s.source);return lc(e,s.source,o?a.map((i,l)=>l===s.index?o:i):a.filter((i,l)=>l!==s.index))},dg=(t,e,s)=>e.personalCommands([...t.personal.setupWorktree,s.trim()]),dc=(t,e,s)=>cc(t,e,s,""),ug=async(t,e,s)=>{const n=s.source==="shared"?"personal":"shared";return await lc(e,n,[...ic(t,n),s.command])?dc(t,e,s):!1},Yr="__none__",fg=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`action_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,pg=({target:t,canShare:e,onOpenChange:s,onSave:n,onDelete:o})=>{const{t:a}=se(),{isMobile:i}=On(),l=y.useMemo(()=>Pl(),[]),c=za(T=>T.instances),d=za(T=>T.load),[u,f]=y.useState({id:"",name:"",command:""}),[p,g]=y.useState("personal"),[h,x]=y.useState(!1);y.useEffect(()=>{t&&(f(t.action??{id:fg(),name:"",command:"",icon:"play"}),g(t.source))},[t]),y.useEffect(()=>{!l||!t||d().catch(()=>{})},[l,d,t]);const m=y.useMemo(()=>l?Ud(c):[],[c,l]),b=T=>f(D=>({...D,...T})),v=u.platforms??[],w=u.autoOpenUrl===!0,S=T=>{const D=v.includes(T)?v.filter(A=>A!==T):[...v,T];b({platforms:D.length>0&&D.length<So.length?D:void 0})},I=u.name.trim().length>0&&u.command.trim().length>0&&!h&&(p==="personal"||e),k=t?.action===null,R=async T=>{x(!0);try{await T()&&s(!1)}finally{x(!1)}},P=()=>R(()=>n({...u,name:u.name.trim(),command:u.command.trim(),openUrl:u.autoOpenUrl&&u.openUrl?.trim()||void 0,desktopOpenSshForward:u.autoOpenUrl?u.desktopOpenSshForward:void 0},p));return r.jsx(cs,{open:t!==null,onOpenChange:s,children:r.jsxs(ds,{className:"max-w-3xl",children:[r.jsx(vs,{children:r.jsx(us,{children:a(k?"settings.projects.actionEditor.titleNew":"settings.projects.actionEditor.titleEdit")})}),r.jsxs("div",{className:i?"flex flex-col gap-5":"grid grid-cols-2 gap-x-10",children:[r.jsxs("div",{className:"flex min-w-0 flex-col gap-5",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Ut,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(Q,{type:"button",variant:"outline",size:"icon",className:"shrink-0","aria-label":a("settings.projects.actions.field.selectIconAria"),children:r.jsx(B,{name:oc(u.icon),className:"h-4 w-4"})})}),r.jsx(Vt,{align:"start",className:"w-56 p-2",children:r.jsx("div",{className:"grid grid-cols-6 gap-1",children:Hi.map(T=>{const D=(u.icon||"play")===T.key;return r.jsx("button",{type:"button",onClick:()=>b({icon:T.key}),"aria-pressed":D,className:ne("inline-flex h-8 w-8 items-center justify-center rounded-md text-foreground hover:bg-[var(--interactive-hover)]",D&&"bg-interactive-selection text-interactive-selection-foreground"),"aria-label":a("settings.projects.actions.field.iconAria",{icon:T.label}),children:r.jsx(B,{name:T.Icon,className:"h-4 w-4"})},T.key)})})})]}),r.jsx(It,{value:u.name,autoFocus:k,onChange:T=>b({name:T.target.value}),placeholder:a("settings.projects.actions.field.actionNamePlaceholder"),"aria-label":a("settings.projects.actions.field.actionNamePlaceholder"),className:"min-w-0 flex-1"})]}),r.jsx(Rs,{label:a("settings.projects.actions.field.command"),controlClassName:"max-w-none",children:r.jsx(Yi,{value:u.command,onChange:T=>b({command:T.target.value}),placeholder:a("settings.projects.actions.field.commandPlaceholder"),"aria-label":a("settings.projects.actions.field.command"),className:"min-h-[132px] w-full font-mono text-xs"})}),r.jsx(Rs,{label:a("settings.projects.actionEditor.savedIn"),descriptionPlacement:"after",description:r.jsx("span",{className:"block min-h-[2lh]",children:a(!e&&p==="shared"?"settings.projects.actionEditor.savedIn.teamUnavailable":p==="shared"?"settings.projects.actionEditor.savedIn.teamHint":"settings.projects.actionEditor.savedIn.personalHint")}),children:r.jsx(co,{value:p,onChange:g,"aria-label":a("settings.projects.actionEditor.savedIn"),options:[{value:"shared",label:a("settings.projects.scope.team"),disabled:!e&&p!=="shared"},{value:"personal",label:a("settings.projects.scope.personal")}]})})]}),r.jsxs("div",{className:"flex min-w-0 flex-col gap-5",children:[r.jsxs("div",{className:"flex flex-col gap-5",children:[r.jsx(Rs,{label:a("settings.projects.actions.runIn.label"),info:a("settings.projects.actions.runIn.info"),children:r.jsx(co,{value:u.runIn==="parent"?"parent":"worktree",onChange:T=>b({runIn:T==="parent"?"parent":void 0}),"aria-label":a("settings.projects.actions.runIn.aria"),options:[{value:"worktree",label:a("settings.projects.actions.runIn.worktree")},{value:"parent",label:a("settings.projects.actions.runIn.project")}]})}),r.jsx(Rs,{label:a("settings.projects.actionEditor.platforms"),children:r.jsxs("div",{role:"group","aria-label":a("settings.projects.actionEditor.platforms"),className:"flex flex-wrap items-center gap-1",children:[r.jsx(Q,{type:"button",variant:"chip",size:"xs",className:"!font-normal","aria-pressed":v.length===0,onClick:()=>b({platforms:void 0}),children:a("settings.projects.actionEditor.platformsAll")}),So.map(T=>r.jsx(Q,{type:"button",variant:"chip",size:"xs",className:"!font-normal","aria-pressed":v.includes(T.value),onClick:()=>S(T.value),children:T.label},T.value))]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(yr,{checked:u.autoOpenUrl===!0,onChange:T=>b({autoOpenUrl:T?!0:void 0}),label:a("settings.projects.actionEditor.openUrl"),info:a("settings.projects.actions.field.overrideUrlTooltip")}),r.jsxs("div",{className:"space-y-2 ps-6",children:[r.jsx(It,{value:u.openUrl??"",disabled:!w,onChange:T=>b({openUrl:T.target.value}),placeholder:a("settings.projects.actions.field.overrideUrlPlaceholder"),"aria-label":a("settings.projects.actions.field.overrideUrlPlaceholder"),className:"w-full font-mono text-xs"}),r.jsx("p",{className:ne(is,!w&&"opacity-60"),children:a("settings.projects.actions.field.overrideUrlVariables")}),l?r.jsxs(hn,{value:u.desktopOpenSshForward&&m.some(T=>T.id===u.desktopOpenSshForward)?u.desktopOpenSshForward:Yr,onValueChange:T=>b({desktopOpenSshForward:T===Yr?void 0:T}),disabled:!w||m.length===0,children:[r.jsx(gn,{className:"w-full","aria-label":a("settings.projects.actions.field.desktopSshForward"),children:r.jsx(Dn,{children:T=>m.length===0?a("settings.projects.actions.state.noDesktopSshForwards"):m.find(D=>D.id===T)?.label??a("settings.projects.actions.field.useOutputManualUrl")})}),r.jsxs(xn,{children:[r.jsx(Ds,{value:Yr,children:a("settings.projects.actions.field.useOutputManualUrl")}),m.map(T=>r.jsx(Ds,{value:T.id,children:T.label},T.id))]})]}):null]})]})]})]}),r.jsxs(Gs,{className:"sm:justify-between",children:[k?r.jsx("span",{}):r.jsx(Q,{type:"button",size:"sm",variant:"ghost",className:"text-[var(--status-error)]",disabled:h,onClick:()=>{R(o)},children:t?.source==="shared"?a("settings.projects.actions.menu.deleteForEveryone"):a("settings.projects.actions.menu.delete")}),r.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row",children:[r.jsx(Q,{type:"button",size:"sm",variant:"outline",onClick:()=>s(!1),children:a("dialog.common.actions.cancel")}),r.jsx(Q,{type:"button",size:"sm",disabled:!I,onClick:()=>{P()},children:a("settings.projects.actionEditor.save")})]})]})]})})},uc=t=>{const e=W.c(3),{source:s}=t,{t:n}=se();let o;return e[0]!==s||e[1]!==n?(o=s==="shared"?r.jsx(Ko,{tone:"info",children:n("settings.projects.scope.team")}):r.jsx(eg,{children:n("settings.projects.scope.personal")}),e[0]=s,e[1]=n,e[2]=o):o=e[2],o},Wo=t=>{const e=W.c(18),{setupState:s}=t,{t:n}=se();if(s.load.state==="failed"){let i;e[0]!==n?(i=n("settings.projects.setup.loadFailed"),e[0]=n,e[1]=i):i=e[1];let l;e[2]!==i?(l=r.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:i}),e[2]=i,e[3]=l):l=e[3];let c;e[4]!==s?(c=()=>{s.reload()},e[4]=s,e[5]=c):c=e[5];let d;e[6]!==n?(d=n("settings.projects.setup.retry"),e[6]=n,e[7]=d):d=e[7];let u;e[8]!==c||e[9]!==d?(u=r.jsx(Q,{type:"button",size:"xs",variant:"outline",onClick:c,children:d}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let f;return e[11]!==l||e[12]!==u?(f=r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l,u]}),e[11]=l,e[12]=u,e[13]=f):f=e[13],f}let o;e[14]!==n?(o=n("settings.projects.actions.state.loading"),e[14]=n,e[15]=o):o=e[15];let a;return e[16]!==o?(a=r.jsx("p",{className:is,children:o}),e[16]=o,e[17]=a):a=e[17],a},mg=t=>{const e=W.c(66),{setup:s,setupState:n}=t,{t:o}=se(),{write:a,reload:i}=n,{confirm:l,dialog:c}=$o(),[d,u]=y.useState(null);let f,p,g,h,x,m;if(e[0]!==l||e[1]!==i||e[2]!==s||e[3]!==o||e[4]!==a){const N=rg(s);let j;e[11]!==s?(j=ac(s),e[11]=s,e[12]=j):j=e[12],g=j;let _;e[13]!==i||e[14]!==o?(_=async C=>(C||Y.error(o("settings.projects.actions.toast.saveFailed")),await i(),C),e[13]=i,e[14]=o,e[15]=_):_=e[15],p=_;let E;e[16]!==l||e[17]!==p||e[18]!==s||e[19]!==o||e[20]!==a?(E=async C=>C.source==="shared"&&!await l({title:o("settings.projects.actions.confirmDelete.title",{name:C.action.name}),message:o("settings.projects.actions.confirmDelete.message"),action:o("settings.projects.actions.menu.delete"),destructive:!0})?!1:p(await ig(s,a,C)),e[16]=l,e[17]=p,e[18]=s,e[19]=o,e[20]=a,e[21]=E):E=e[21],f=E;let L;e[22]!==f||e[23]!==p||e[24]!==s||e[25]!==g||e[26]!==o||e[27]!==a?(L=C=>{if(C.source==="personal")return[{label:o("settings.projects.actions.menu.delete"),icon:"delete-bin",destructive:!0,onSelect:()=>{f(C)}}];const O=[{label:C.hidden?o("settings.projects.actions.menu.show"):o("settings.projects.shared.actions.hide"),icon:C.hidden?"eye":"eye-off",onSelect:()=>{lg(s,a,C.action.id,!C.hidden).then(p)}}];return g&&O.push({label:o("settings.projects.actions.menu.deleteForEveryone"),icon:"delete-bin",destructive:!0,onSelect:()=>{f(C)}}),O},e[22]=f,e[23]=p,e[24]=s,e[25]=g,e[26]=o,e[27]=a,e[28]=L):L=e[28];const $=L;e[29]!==s.shared.path||e[30]!==s.shared.reason||e[31]!==s.shared.status||e[32]!==o?(m=s.shared.status==="invalid"?r.jsx("p",{className:"mb-3 typography-meta text-[var(--status-warning)]",children:o("settings.projects.shared.invalid",{path:s.shared.path,reason:s.shared.reason??""})}):null,e[29]=s.shared.path,e[30]=s.shared.reason,e[31]=s.shared.status,e[32]=o,e[33]=m):m=e[33],h="max-w-[44rem] divide-y divide-[var(--interactive-border)] overflow-hidden rounded-xl border border-[var(--interactive-border)]";let M;e[34]!==$||e[35]!==o?(M=C=>{const O=C.action.platforms??[];return r.jsxs("li",{className:"flex items-center gap-2 pe-2 transition-colors hover:bg-[var(--interactive-hover)]",children:[r.jsxs("button",{type:"button",onClick:()=>u({target:{action:C.action,source:C.source},entry:C}),className:"flex min-w-0 flex-1 items-center gap-3 py-2 ps-3 text-start focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[r.jsx(B,{name:oc(C.action.icon),className:ne("size-4 shrink-0 text-muted-foreground",C.hidden&&"opacity-60")}),r.jsxs("span",{className:ne("min-w-0 flex-1",C.hidden&&"opacity-60"),children:[r.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:C.action.name}),r.jsx("span",{className:"block truncate font-mono typography-micro text-muted-foreground",title:C.action.command,children:C.action.command})]}),O.length>0?r.jsx("span",{className:"hidden shrink-0 typography-micro text-muted-foreground @xl:inline",children:O.map(gg).join(", ")}):null,C.hidden?r.jsx(Ko,{tone:"neutral",children:o("settings.projects.actions.hiddenBadge")}):null,r.jsx(uc,{source:C.source})]}),r.jsxs(Ut,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground","aria-label":o("settings.projects.actions.menuAria"),children:r.jsx(B,{name:"more-2",className:"size-4"})})}),r.jsx(Vt,{align:"end",className:"w-fit min-w-40",children:$(C).map(xg)})]})]},`${C.source}:${C.action.id}`)},e[34]=$,e[35]=o,e[36]=M):M=e[36],x=N.map(M),e[0]=l,e[1]=i,e[2]=s,e[3]=o,e[4]=a,e[5]=f,e[6]=p,e[7]=g,e[8]=h,e[9]=x,e[10]=m}else f=e[5],p=e[6],g=e[7],h=e[8],x=e[9],m=e[10];let b;e[37]===Symbol.for("react.memo_cache_sentinel")?(b=()=>u({target:{action:null,source:"personal"},entry:null}),e[37]=b):b=e[37];let v;e[38]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(B,{name:"add",className:"size-4 shrink-0"}),e[38]=v):v=e[38];let w;e[39]!==o?(w=o("settings.projects.actions.new"),e[39]=o,e[40]=w):w=e[40];let S;e[41]!==w?(S=r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:b,className:"flex w-full items-center gap-3 py-2.5 ps-3 text-start typography-ui-label text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[v,w]})}),e[41]=w,e[42]=S):S=e[42];let I;e[43]!==h||e[44]!==x||e[45]!==S?(I=r.jsxs("ul",{className:h,children:[x,S]}),e[43]=h,e[44]=x,e[45]=S,e[46]=I):I=e[46];const k=d?.target??null;let R;e[47]===Symbol.for("react.memo_cache_sentinel")?(R=N=>{N||u(null)},e[47]=R):R=e[47];let P;e[48]!==d?.entry?.source||e[49]!==p||e[50]!==s||e[51]!==a?(P=async(N,j)=>p(await ag(s,a,N,d?.entry?.source??null,j)),e[48]=d?.entry?.source,e[49]=p,e[50]=s,e[51]=a,e[52]=P):P=e[52];let T;e[53]!==d||e[54]!==f?(T=async()=>d?.entry?f(d.entry):!1,e[53]=d,e[54]=f,e[55]=T):T=e[55];let D;e[56]!==g||e[57]!==P||e[58]!==T||e[59]!==k?(D=r.jsx(pg,{target:k,canShare:g,onOpenChange:R,onSave:P,onDelete:T}),e[56]=g,e[57]=P,e[58]=T,e[59]=k,e[60]=D):D=e[60];let A;return e[61]!==c||e[62]!==D||e[63]!==m||e[64]!==I?(A=r.jsxs(r.Fragment,{children:[m,I,D,c]}),e[61]=c,e[62]=D,e[63]=m,e[64]=I,e[65]=A):A=e[65],A},hg=t=>{const e=W.c(10),{setupState:s}=t,{t:n}=se();let o;e[0]!==n?(o=n("settings.projects.actions.title"),e[0]=n,e[1]=o):o=e[1];let a;e[2]!==n?(a=n("settings.projects.actions.info"),e[2]=n,e[3]=a):a=e[3];let i;e[4]!==s?(i=s.load.state==="ready"?r.jsx(mg,{setup:s.load.setup,setupState:s}):r.jsx(Wo,{setupState:s}),e[4]=s,e[5]=i):i=e[5];let l;return e[6]!==o||e[7]!==a||e[8]!==i?(l=r.jsx(Bs,{title:o,info:a,settingsItem:"projects.actions",divider:!1,children:i}),e[6]=o,e[7]=a,e[8]=i,e[9]=l):l=e[9],l};function gg(t){return So.find(e=>e.value===t)?.label??t}function xg(t){return r.jsxs(lt,{variant:t.destructive?"destructive":"default",onClick:t.onSelect,children:[t.icon?r.jsx(B,{name:t.icon,className:"size-4"}):null,t.label]},t.label)}const bg=/^[A-Za-z_][A-Za-z0-9_]*$/,fc=zt({names:Bo(nt())}),yg=Tm("state",[zt({state:Sr("applied"),count:jr()}),zt({state:Sr("failed"),reason:nt(),exitCode:jr().nullable().optional()})]),qo=zt({names:Bo(nt()),command:nt().nullable(),status:yg.nullable()}),zn=async(t,e,s)=>{if(!t.ok){const n=await t.json().catch(()=>null),o=zt({error:nt()}).safeParse(n);throw new Error(o.success?o.data.error:`${s}: ${t.status}`)}return e.parse(await t.json())},pc={"Content-Type":"application/json",Accept:"application/json"},mc=t=>({method:"PUT",headers:pc,body:JSON.stringify(t)}),Ho=t=>`/api/environment/projects/${encodeURIComponent(t)}`,Cw=async()=>zn(await wt("/api/environment",{headers:{Accept:"application/json"}}),fc,"Failed to read environment variables"),Iw=async t=>zn(await wt("/api/environment",mc({variables:t})),fc,"Failed to save environment variables"),vg=async t=>zn(await wt(Ho(t),{headers:{Accept:"application/json"}}),qo,"Failed to read project environment"),wg=async(t,e)=>zn(await wt(Ho(t),mc(e)),qo,"Failed to save project environment"),Ga=async t=>zn(await wt(`${Ho(t)}/reload`,{method:"POST",headers:pc}),qo,"Failed to run the environment command"),Sg=({names:t,disabled:e=!1,onSet:s,onRemove:n})=>{const{t:o}=se(),[a,i]=y.useState(""),[l,c]=y.useState(""),[d,u]=y.useState(null),[f,p]=y.useState(""),[g,h]=y.useState(!1),x=a.trim(),m=x.length>0&&!bg.test(x),b=e||g,v=async k=>{h(!0);try{return await k()}finally{h(!1)}},w=async()=>{!x||m||await v(()=>s(x,l))&&(i(""),c(""))},S=async k=>{await v(()=>s(k,f))&&(u(null),p(""))},I=()=>{u(null),p("")};return r.jsxs("div",{className:"space-y-3",children:[t.length===0?r.jsx("p",{className:is,children:o("settings.environment.editor.empty")}):r.jsx("ul",{className:"w-full max-w-[32rem] space-y-1",children:t.map(k=>r.jsxs("li",{className:"flex min-h-8 flex-wrap items-center gap-2",children:[r.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-foreground",children:k}),d===k?r.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-2",onSubmit:R=>{R.preventDefault(),S(k)},children:[r.jsx(It,{type:"password",autoFocus:!0,value:f,onChange:R=>p(R.target.value),placeholder:o("settings.environment.editor.newValuePlaceholder"),"aria-label":o("settings.environment.editor.newValueAria",{name:k}),disabled:b,className:"h-8 min-w-0 max-w-[16rem] flex-1 font-mono text-xs"}),r.jsx(Q,{type:"submit",size:"xs",disabled:b,className:"shrink-0 !font-normal",children:o("settings.environment.editor.save")}),r.jsx(Q,{type:"button",variant:"ghost",size:"xs",onClick:I,disabled:g,className:"shrink-0 !font-normal",children:o("settings.common.actions.cancel")})]}):r.jsxs("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:[r.jsx(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>{u(k),p("")},disabled:b,className:ha,"aria-label":o("settings.environment.editor.replaceAria",{name:k}),title:o("settings.environment.editor.replace"),children:r.jsx(B,{name:"pencil",className:"h-3.5 w-3.5"})}),r.jsx(Q,{type:"button",variant:"ghost",size:"xs",onClick:()=>{v(()=>n(k))},disabled:b,className:ha,"aria-label":o("settings.environment.editor.removeAria",{name:k}),title:o("settings.environment.editor.remove"),children:r.jsx(B,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]},k))}),r.jsxs("form",{className:"space-y-1.5",onSubmit:k=>{k.preventDefault(),w()},children:[r.jsxs("div",{className:"flex w-full max-w-[32rem] flex-wrap items-center gap-2",children:[r.jsx(It,{value:a,onChange:k=>i(k.target.value),placeholder:"NAME","aria-label":o("settings.environment.editor.nameAria"),"aria-invalid":m||void 0,disabled:b,className:"h-8 w-40 font-mono text-xs"}),r.jsx(It,{type:"password",value:l,onChange:k=>c(k.target.value),placeholder:o("settings.environment.editor.valuePlaceholder"),"aria-label":o("settings.environment.editor.valueAria"),disabled:b,className:"h-8 min-w-0 flex-1 font-mono text-xs"}),r.jsxs(Q,{type:"submit",variant:"outline",size:"xs",disabled:b||!x||m,className:"shrink-0 !font-normal",children:[r.jsx(B,{name:"add",className:"h-3.5 w-3.5"}),o("settings.environment.editor.add")]})]}),m?r.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:o("settings.environment.editor.invalidName")}):null]})]})},jg=t=>{switch(t){case"timeout":return"settings.projects.environment.status.timeout";case"unrecognized-output":return"settings.projects.environment.status.unrecognizedOutput";case"spawn":return"settings.projects.environment.status.spawn";case"output-too-large":return"settings.projects.environment.status.outputTooLarge";default:return"settings.projects.environment.status.failed"}},Ng=t=>{const e=W.c(9),{t:s}=se();if(!t)return null;if(t.state==="applied"){let o;return e[0]!==t.count||e[1]!==s?(o=t.count===1?s("settings.projects.environment.status.appliedSingle"):s("settings.projects.environment.status.appliedPlural",{count:t.count}),e[0]=t.count,e[1]=s,e[2]=o):o=e[2],o}if(t.reason==="exit"){let o;return e[3]!==t.exitCode||e[4]!==s?(o=t.exitCode===null||t.exitCode===void 0?s("settings.projects.environment.status.stopped"):s("settings.projects.environment.status.exitCode",{code:t.exitCode}),e[3]=t.exitCode,e[4]=s,e[5]=o):o=e[5],o}let n;return e[6]!==t.reason||e[7]!==s?(n=s(jg(t.reason)),e[6]=t.reason,e[7]=s,e[8]=n):n=e[8],n},kg=({projectRef:t})=>{const{t:e}=se(),[s,n]=y.useState({state:"loading"}),[o,a]=y.useState(""),[i,l]=y.useState(!1),c=y.useCallback(b=>{n({state:"ready",environment:b}),a(b.command??"")},[]);y.useEffect(()=>{let b=!1;return n({state:"loading"}),vg(t.id).then(v=>{b||c(v)}).catch(()=>{b||n({state:"failed"})}),()=>{b=!0}},[c,t.id]);const d=y.useCallback(async b=>{Ht("saving");try{return c(await wg(t.id,b)),Ht("saved"),!0}catch{return Ht("error"),Y.error(e("settings.environment.editor.saveFailed")),!1}},[c,t.id,e]),u=s.state==="ready"?s.environment.command??"":"",f=o.trim()!==u,p=async()=>{l(!0);try{await d({command:o.trim()||null})&&o.trim()&&c(await Ga(t.id))}catch{Y.error(e("settings.projects.environment.runFailed"))}finally{l(!1)}},g=async()=>{l(!0);try{c(await Ga(t.id))}catch{Y.error(e("settings.projects.environment.runFailed"))}finally{l(!1)}},h=s.state==="ready"?s.environment.status:null,x=Ng(h),m=s.state!=="ready"||i;return r.jsx(Bs,{divider:!1,title:e("settings.projects.environment.title"),info:e("settings.projects.environment.info"),settingsItem:"projects.environment",children:s.state==="failed"?r.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("settings.environment.editor.loadFailed")}):r.jsxs("div",{className:"space-y-6",children:[r.jsx(Sg,{names:s.state==="ready"?s.environment.names:[],disabled:s.state!=="ready",onSet:(b,v)=>d({variables:{[b]:v}}),onRemove:b=>d({variables:{[b]:null}})}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:uo,children:e("settings.projects.environment.command.label")}),r.jsx(Ji,{children:e("settings.projects.environment.command.info")})]}),r.jsxs("form",{className:"flex w-full max-w-[32rem] flex-wrap items-center gap-2",onSubmit:b=>{b.preventDefault(),p()},children:[r.jsx(It,{value:o,onChange:b=>a(b.target.value),placeholder:"direnv export json","aria-label":e("settings.projects.environment.command.label"),disabled:m,className:"h-8 min-w-0 flex-1 font-mono text-xs"}),f?r.jsx(Q,{type:"submit",size:"xs",disabled:m,className:"shrink-0 !font-normal",children:e("settings.environment.editor.save")}):u?r.jsx(Q,{type:"button",variant:"outline",size:"xs",onClick:()=>{g()},disabled:m,className:"shrink-0 !font-normal",children:e("settings.projects.environment.command.runAgain")}):null]}),u&&x?r.jsx("p",{className:h?.state==="failed"?"typography-meta text-[var(--status-error)]":is,children:x}):null]})]})})},Jr="__default__",hc=t=>t.charAt(0).toUpperCase()+t.slice(1),Cg=t=>{const e=W.c(43),{form:s}=t,{t:n}=se();let o;e[0]!==s.project?.path?(o=k=>qd(k,s.project?.path),e[0]=s.project?.path,e[1]=o):o=e[1];const a=Ot(o),{parsedDefaultModel:i,defaultVariant:l}=s;let c;e:{const{providerId:k,modelId:R}=i;if(!k||!R){let T;e[2]===Symbol.for("react.memo_cache_sentinel")?(T=[],e[2]=T):T=e[2],c=T;break e}let P;if(e[3]!==R||e[4]!==k||e[5]!==a){const T=a.find(D=>D.id===k)?.models.find(D=>D.id===R);P=zd(T),e[3]=R,e[4]=k,e[5]=a,e[6]=P}else P=e[6];c=P}const d=c;if(!s.project)return null;let u;e[7]!==n?(u=n("settings.projects.page.section.chatDefaults"),e[7]=n,e[8]=u):u=e[8];let f;e[9]!==n?(f=n("settings.projects.page.section.chatDefaultsDescription"),e[9]=n,e[10]=f):f=e[10];let p;e[11]!==n?(p=n("settings.projects.page.field.projectAgent"),e[11]=n,e[12]=p):p=e[12];const g=s.defaultAgent||"";let h;e[13]!==s?(h=k=>s.setDefaultAgent(k||void 0),e[13]=s,e[14]=h):h=e[14];let x;e[15]!==s.project.path||e[16]!==g||e[17]!==h?(x=r.jsx(Ui,{directory:s.project.path,agentName:g,onChange:h,filter:Rg,className:ga}),e[15]=s.project.path,e[16]=g,e[17]=h,e[18]=x):x=e[18];let m;e[19]!==p||e[20]!==x?(m=r.jsx(fr,{settingsItem:"projects.default-agent",label:p,children:x}),e[19]=p,e[20]=x,e[21]=m):m=e[21];let b;e[22]!==n?(b=n("settings.projects.page.field.projectModel"),e[22]=n,e[23]=b):b=e[23];let v;e[24]!==s.handleDefaultModelChange||e[25]!==s.project.path||e[26]!==i.modelId||e[27]!==i.providerId?(v=r.jsx(Vi,{directory:s.project.path,providerId:i.providerId,modelId:i.modelId,onChange:s.handleDefaultModelChange,className:ga}),e[24]=s.handleDefaultModelChange,e[25]=s.project.path,e[26]=i.modelId,e[27]=i.providerId,e[28]=v):v=e[28];let w;e[29]!==b||e[30]!==v?(w=r.jsx(fr,{settingsItem:"projects.default-model",label:b,children:v}),e[29]=b,e[30]=v,e[31]=w):w=e[31];let S;e[32]!==d||e[33]!==l||e[34]!==s||e[35]!==n?(S=d.length>0?r.jsx(fr,{settingsItem:"projects.default-thinking",label:n("settings.projects.page.field.projectThinking"),children:r.jsxs(hn,{value:l??Jr,onValueChange:k=>s.handleDefaultVariantChange(k===Jr?void 0:k),children:[r.jsx(gn,{className:Kd,"aria-label":n("settings.projects.page.field.projectThinking"),children:r.jsx(Dn,{children:l?hc(l):n("settings.projects.page.option.thinkingDefault")})}),r.jsxs(xn,{children:[r.jsx(Ds,{value:Jr,children:n("settings.projects.page.option.thinkingDefault")}),d.map(Eg)]})]})}):null,e[32]=d,e[33]=l,e[34]=s,e[35]=n,e[36]=S):S=e[36];let I;return e[37]!==w||e[38]!==S||e[39]!==u||e[40]!==f||e[41]!==m?(I=r.jsxs(Bs,{title:u,info:f,divider:!1,contentClassName:"space-y-0",children:[m,w,S]}),e[37]=w,e[38]=S,e[39]=u,e[40]=f,e[41]=m,e[42]=I):I=e[42],I},Ig=({projectRef:t,setupState:e})=>{const{t:s}=se(),{load:n,reload:o}=e,a=n.state==="ready"?n.setup:null,[i,l]=y.useState(""),[c,d]=y.useState(!1),u=a?.shared.plansDir??"";y.useEffect(()=>l(u),[u]);const f=async()=>{const h=i.trim();if(h!==u){d(!0);try{if(!await fo(t,{plansDir:h||null})){Y.error(s("settings.projects.shared.toast.shareFailed")),l(u);return}await o()}finally{d(!1)}}},p=async()=>{if(a){d(!0);try{await Wd(t,a),await o()}finally{d(!1)}}},g=async()=>{d(!0);try{await Gd(t)||Y.error(s("settings.projects.shared.toast.shareFailed")),await o()}finally{d(!1)}};return r.jsx(Bs,{title:s("settings.projects.team.title"),settingsItem:"projects.shared",contentClassName:"space-y-5",children:a?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:ne("max-w-[40rem]",a.shared.status==="invalid"?"typography-meta text-[var(--status-warning)]":is),children:a.shared.status==="invalid"?s("settings.projects.shared.invalid",{path:a.shared.path,reason:a.shared.reason??""}):a.shared.status==="ok"?s("settings.projects.team.description.ok",{path:a.shared.path}):s("settings.projects.team.description.missing",{path:a.shared.path})}),a.trust.hash!==null?r.jsxs("div",{className:ne("flex max-w-[40rem] items-center gap-3 rounded-lg p-3",a.trust.trusted?"oc-tile":"bg-[var(--status-warning)]/10"),children:[r.jsx(B,{name:a.trust.trusted?"shield-check":"error-warning",className:ne("size-4 shrink-0",a.trust.trusted?"text-[var(--status-success)]":"text-[var(--status-warning)]")}),r.jsx("p",{className:"min-w-0 flex-1 typography-meta text-foreground",children:a.trust.trusted?s("settings.projects.team.trust.allowed"):s("settings.projects.team.trust.waiting")}),a.trust.trusted?r.jsx(Q,{type:"button",size:"xs",variant:"ghost",className:"shrink-0 !font-normal",disabled:c,onClick:()=>{g()},children:s("settings.projects.team.trust.revoke")}):r.jsx(Q,{type:"button",size:"xs",variant:"outline",className:"shrink-0",disabled:c,onClick:()=>{p()},children:s("settings.projects.team.trust.review")})]}):null,r.jsx(fr,{label:s("settings.projects.shared.plansDir"),info:s("settings.projects.shared.plansDirInfo"),settingsItem:"projects.shared.plansDir",children:r.jsx(It,{value:i,onChange:h=>l(h.target.value),onBlur:()=>{f()},onKeyDown:h=>{h.key==="Enter"&&h.currentTarget.blur()},placeholder:s("settings.projects.shared.plansDirPlaceholder"),"aria-label":s("settings.projects.shared.plansDirAria"),disabled:c||a.shared.status==="invalid",className:"h-8 rounded-md px-3 font-mono text-xs"})})]}):r.jsx(Wo,{setupState:e})})},Tg=t=>{const e=W.c(8),{form:s,projectRef:n,setupState:o}=t;let a;e[0]!==s?(a=r.jsx(Cg,{form:s}),e[0]=s,e[1]=a):a=e[1];let i;e[2]!==n||e[3]!==o?(i=r.jsx(Ig,{projectRef:n,setupState:o}),e[2]=n,e[3]=o,e[4]=i):i=e[4];let l;return e[5]!==a||e[6]!==i?(l=r.jsxs(r.Fragment,{children:[a,i]}),e[5]=a,e[6]=i,e[7]=l):l=e[7],l};function Rg(t){return Ki(t.mode)}function Eg(t){return r.jsx(Ds,{value:t,children:hc(t)},t)}const gc=t=>{const e=W.c(23),{form:s,className:n}=t,{currentTheme:o}=Qi(),{project:a}=s;if(!a)return null;if(s.effectiveHasImageIcon&&s.showImagePreview){let g;e[0]!==n?(g=ne("inline-flex items-center justify-center overflow-hidden rounded-[4px]",n),e[0]=n,e[1]=g):g=e[1];let h;e[2]!==s.iconBackground?(h=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[2]=s.iconBackground,e[3]=h):h=e[3];let x;e[4]!==o||e[5]!==s||e[6]!==a?(x=s.hasPendingUploadImageIcon&&s.pendingUploadIconPreviewUrl?r.jsx("img",{src:s.pendingUploadIconPreviewUrl,alt:"",className:"h-full w-full object-contain",draggable:!1,onError:()=>s.setPreviewImageFailed(!0)}):r.jsx(Hd,{project:{...a,iconImage:s.currentIconImage??a.iconImage},options:{themeVariant:o.metadata.variant,iconColor:o.colors.surface.foreground},className:"h-full w-full object-contain",onError:()=>s.setPreviewImageFailed(!0)}),e[4]=o,e[5]=s,e[6]=a,e[7]=x):x=e[7];let m;return e[8]!==g||e[9]!==h||e[10]!==x?(m=r.jsx("span",{className:g,style:h,children:x}),e[8]=g,e[9]=h,e[10]=x,e[11]=m):m=e[11],m}let i;e[12]!==s.color?(i=Zi(s.color),e[12]=s.color,e[13]=i):i=e[13];const l=i,c=(s.icon?Yd[s.icon]:null)??"folder",d=!l&&"text-muted-foreground";let u;e[14]!==n||e[15]!==d?(u=ne(n,d),e[14]=n,e[15]=d,e[16]=u):u=e[16];let f;e[17]!==l?(f=l?{color:l}:void 0,e[17]=l,e[18]=f):f=e[18];let p;return e[19]!==c||e[20]!==u||e[21]!==f?(p=r.jsx(B,{name:c,className:u,style:f}),e[19]=c,e[20]=u,e[21]=f,e[22]=p):p=e[22],p},Dg="flex h-8 w-8 items-center justify-center rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",Pg=t=>{const e=W.c(66),{form:s,onUploadClick:n}=t,{t:o}=se(),[a,i]=y.useState(s.effectiveHasImageIcon?"image":"symbol");let l;e[0]!==s.color?(l=s.color&&!Tn(s.color)?Zi(s.color):null,e[0]=s.color,e[1]=l):l=e[1];const c=l;let d;e[2]!==s?(d=O=>{const z=O||null;s.setColor(z),s.setIconBackground(Xd(z))},e[2]=s,e[3]=d):d=e[3];const u=d;let f;e[4]!==s?(f=O=>{s.setIcon(O),s.effectiveHasImageIcon&&s.handleRemoveImageIcon()},e[4]=s,e[5]=f):f=e[5];const p=f;let g;e[6]!==o?(g=o("settings.projects.appearance.color"),e[6]=o,e[7]=g):g=e[7];let h;e[8]!==g?(h=r.jsx("div",{className:uo,children:g}),e[8]=g,e[9]=h):h=e[9];const x=s.color??"";let m;e[10]!==o?(m=o("settings.projects.appearance.colorNone"),e[10]=o,e[11]=m):m=e[11];let b,v;e[12]!==o?(b=O=>o("settings.projects.appearance.colorSwatchAria",{color:O}),v=o("settings.projects.appearance.colorCustomAria"),e[12]=o,e[13]=b,e[14]=v):(b=e[13],v=e[14]);let w;e[15]!==o?(w=o("settings.projects.appearance.colorHexAria"),e[15]=o,e[16]=w):w=e[16];let S;e[17]!==w||e[18]!==m||e[19]!==b||e[20]!==v?(S={empty:m,swatch:b,custom:v,hex:w},e[17]=w,e[18]=m,e[19]=b,e[20]=v,e[21]=S):S=e[21];let I;e[22]!==c||e[23]!==u||e[24]!==S||e[25]!==x?(I=r.jsx(Hh,{value:x,onChange:u,legacyCss:c,labels:S}),e[22]=c,e[23]=u,e[24]=S,e[25]=x,e[26]=I):I=e[26];let k;e[27]!==I||e[28]!==h?(k=r.jsxs("div",{className:"space-y-2",children:[h,I]}),e[27]=I,e[28]=h,e[29]=k):k=e[29];let R;e[30]!==o?(R=o("settings.projects.appearance.icon"),e[30]=o,e[31]=R):R=e[31];let P;e[32]!==R?(P=r.jsx("div",{className:uo,children:R}),e[32]=R,e[33]=P):P=e[33];let T;e[34]!==o?(T=o("settings.projects.appearance.icon"),e[34]=o,e[35]=T):T=e[35];let D;e[36]!==o?(D=o("settings.projects.appearance.mode.symbol"),e[36]=o,e[37]=D):D=e[37];let A;e[38]!==D?(A={value:"symbol",label:D},e[38]=D,e[39]=A):A=e[39];let N;e[40]!==o?(N=o("settings.projects.appearance.mode.image"),e[40]=o,e[41]=N):N=e[41];let j;e[42]!==N?(j={value:"image",label:N},e[42]=N,e[43]=j):j=e[43];let _;e[44]!==A||e[45]!==j?(_=[A,j],e[44]=A,e[45]=j,e[46]=_):_=e[46];let E;e[47]!==a||e[48]!==T||e[49]!==_?(E=r.jsx(co,{value:a,onChange:i,"aria-label":T,options:_}),e[47]=a,e[48]=T,e[49]=_,e[50]=E):E=e[50];let L;e[51]!==P||e[52]!==E?(L=r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[P,E]}),e[51]=P,e[52]=E,e[53]=L):L=e[53];let $;e[54]!==s||e[55]!==a||e[56]!==n||e[57]!==p||e[58]!==o?($=a==="symbol"?r.jsx("div",{className:"grid grid-cols-8 gap-1",children:[{key:null,Icon:"folder",label:o("settings.projects.appearance.symbolNone")},...Jd].map(O=>{const z=!s.effectiveHasImageIcon&&s.icon===O.key;return r.jsx("button",{type:"button",onClick:()=>p(O.key),"aria-pressed":z,"aria-label":O.label,title:O.label,className:ne(Dg,z?"bg-interactive-selection text-interactive-selection-foreground":"text-foreground hover:bg-[var(--interactive-hover)]"),children:r.jsx(B,{name:O.Icon,className:"h-4 w-4"})},O.key??"none")})}):r.jsxs("div",{className:"space-y-3",children:[s.effectiveHasImageIcon?r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"flex h-12 w-12 shrink-0 items-center justify-center oc-tile-inset rounded-xl",children:r.jsx(gc,{form:s,className:"h-7 w-7"})}),r.jsx("p",{className:is,children:o("settings.projects.appearance.imageColorHint")})]}):r.jsx("p",{className:is,children:o("settings.projects.appearance.imageEmpty")}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.hasCustomIcon?null:r.jsxs(r.Fragment,{children:[r.jsx(Q,{type:"button",size:"sm",variant:"outline",onClick:n,disabled:s.isUploadingIcon,children:s.isUploadingIcon?o("settings.projects.page.actions.uploading"):o("settings.projects.page.actions.uploadIcon")}),r.jsx(Q,{type:"button",size:"sm",variant:"outline",onClick:()=>{s.handleDiscoverIcon()},disabled:s.isDiscoveringIcon,children:s.isDiscoveringIcon?o("settings.projects.page.actions.discovering"):o("settings.projects.page.actions.discoverFavicon")})]}),s.hasRemovableImageIcon?r.jsx(Q,{type:"button",size:"sm",variant:"ghost",className:"text-[var(--status-error)]",onClick:s.handleRemoveImageIcon,disabled:s.isRemovingCustomIcon,children:s.isRemovingCustomIcon?o("settings.projects.page.actions.removing"):o("settings.projects.page.actions.removeProjectIcon")}):null]})]}),e[54]=s,e[55]=a,e[56]=n,e[57]=p,e[58]=o,e[59]=$):$=e[59];let M;e[60]!==L||e[61]!==$?(M=r.jsxs("div",{className:"space-y-2",children:[L,$]}),e[60]=L,e[61]=$,e[62]=M):M=e[62];let C;return e[63]!==k||e[64]!==M?(C=r.jsxs("div",{className:"space-y-4",children:[k,M]}),e[63]=k,e[64]=M,e[65]=C):C=e[65],C},Ag=({form:t})=>{const{t:e}=se(),s=t.fileInputRef,[n,o]=y.useState(null),a=i=>{const l=i instanceof HTMLElement?i.closest('[data-slot="dialog-content"], [role="dialog"]'):null;o(l instanceof HTMLElement?l:null)};return t.project?r.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[r.jsx("input",{ref:s,type:"file",accept:"image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg",className:"hidden",onChange:i=>{const l=i.target.files?.[0]??null;t.handleUploadIcon(l),i.currentTarget.value=""}}),r.jsxs(Ml,{children:[r.jsxs(Ol,{"data-settings-item":"projects.icon","aria-label":e("settings.projects.header.appearanceAria"),title:e("settings.projects.header.appearanceAria"),onPointerDownCapture:i=>a(i.currentTarget),onFocusCapture:i=>a(i.currentTarget),className:"relative flex h-12 w-12 shrink-0 items-center justify-center oc-tile-inset rounded-xl hover:bg-[var(--interactive-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] data-[popup-open]:bg-interactive-selection",children:[r.jsx(gc,{form:t,className:"h-6 w-6"}),r.jsx("span",{"aria-hidden":"true",className:"absolute -bottom-1 -end-1 flex h-[18px] w-[18px] items-center justify-center rounded-full border border-[var(--interactive-border)] bg-background text-muted-foreground",children:r.jsx(B,{name:"pencil",className:"h-2.5 w-2.5"})})]}),r.jsx(Fl,{container:n??void 0,children:r.jsx(Bl,{side:"bottom",align:"start",sideOffset:6,className:"z-[120]",children:r.jsx(Vl,{"aria-label":e("settings.projects.header.appearanceAria"),className:ne(Xi,"w-[22.5rem] max-w-[calc(100vw-2rem)] p-3"),children:r.jsx(Pg,{form:t,onUploadClick:()=>s.current?.click()})})})})]}),r.jsxs("div",{className:"min-w-0 flex-1 space-y-0.5",children:[r.jsx(It,{"data-settings-item":"projects.name",inputSize:"compact",value:t.name,onChange:i=>t.setName(i.target.value),placeholder:e("settings.projects.page.field.projectNamePlaceholder"),"aria-label":e("settings.projects.page.field.projectName"),className:"-ms-2 w-full max-w-[24rem] bg-transparent px-2 [&:not(:hover):not(:focus)]:shadow-none typography-settings-section-title md:typography-settings-section-title"}),r.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:t.project.path,children:t.project.path})]})]}):null},Wa=t=>{const e=W.c(18),{value:s,disabled:n,autoFocus:o,placeholder:a,ariaLabel:i,onCommit:l}=t,[c,d]=y.useState(s);let u,f;e[0]!==s?(u=()=>d(s),f=[s],e[0]=s,e[1]=u,e[2]=f):(u=e[1],f=e[2]),y.useEffect(u,f);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=m=>d(m.target.value),e[3]=p):p=e[3];let g;e[4]!==c||e[5]!==l||e[6]!==s?(g=()=>{c.trim()!==s&&l(c)},e[4]=c,e[5]=l,e[6]=s,e[7]=g):g=e[7];let h;e[8]!==s?(h=m=>{m.key==="Enter"&&m.currentTarget.blur(),m.key==="Escape"&&(d(s),m.currentTarget.blur())},e[8]=s,e[9]=h):h=e[9];let x;return e[10]!==i||e[11]!==o||e[12]!==n||e[13]!==c||e[14]!==a||e[15]!==g||e[16]!==h?(x=r.jsx(It,{value:c,disabled:n,autoFocus:o,placeholder:a,"aria-label":i,onChange:p,onBlur:g,onKeyDown:h,className:"min-w-0 flex-1 font-mono text-xs"}),e[10]=i,e[11]=o,e[12]=n,e[13]=c,e[14]=a,e[15]=g,e[16]=h,e[17]=x):x=e[17],x},_g=t=>{const e=W.c(45),{projectRef:s,setup:n,setupState:o}=t,{t:a}=se(),{write:i,reload:l}=o,[c,d]=y.useState(!1),[u,f]=y.useState(n.setupWorktreeWait);let p,g;e[0]!==n.setupWorktreeWait?(p=()=>f(n.setupWorktreeWait),g=[n.setupWorktreeWait],e[0]=n.setupWorktreeWait,e[1]=p,e[2]=g):(p=e[1],g=e[2]),y.useEffect(p,g);let h,x,m,b;if(e[3]!==l||e[4]!==n||e[5]!==a||e[6]!==i){const T=cg(n);let D;e[11]!==n?(D=ac(n),e[11]=n,e[12]=D):D=e[12];const A=D;h=n.personal.setupWorktreeMode==="replace";let N;e[13]!==l||e[14]!==a?(N=async j=>{j||Y.error(a("settings.openchamber.worktrees.setup.toast.saveFailed")),await l()},e[13]=l,e[14]=a,e[15]=N):N=e[15],x=N,m="space-y-4",b=T.length>0?r.jsx("ol",{className:"max-w-[40rem] space-y-1.5",children:T.map((j,_)=>{const E=j.source==="personal"||A;return r.jsxs("li",{className:ne("flex items-center gap-2",j.skipped&&"opacity-60"),children:[r.jsx("span",{className:"w-4 shrink-0 text-end typography-meta tabular-nums text-muted-foreground",children:_+1}),r.jsx(Wa,{value:j.command,disabled:!E,ariaLabel:a("settings.projects.worktrees.commandAria",{position:_+1}),onCommit:L=>{cc(n,i,j,L).then(x)}}),j.skipped?r.jsx(Ko,{tone:"neutral",children:a("settings.projects.worktrees.skipped")}):r.jsx(uc,{source:j.source}),r.jsxs(Ut,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground","aria-label":a("settings.projects.worktrees.commandMenuAria"),disabled:!E,children:r.jsx(B,{name:"more-2",className:"size-4"})})}),r.jsxs(Vt,{align:"end",className:"w-fit min-w-40",children:[A?r.jsx(lt,{onClick:()=>{ug(n,i,j).then(x)},children:j.source==="shared"?a("settings.projects.shared.actions.makePersonal"):a("settings.projects.shared.actions.share")}):null,r.jsx(lt,{variant:"destructive",onClick:()=>{dc(n,i,j).then(x)},children:j.source==="shared"?a("settings.projects.worktrees.removeForEveryone"):a("settings.openchamber.worktrees.setup.removeCommandAria")})]})]})]},`${j.source}:${j.index}:${j.command}`)})}):null,e[3]=l,e[4]=n,e[5]=a,e[6]=i,e[7]=h,e[8]=x,e[9]=m,e[10]=b}else h=e[7],x=e[8],m=e[9],b=e[10];let v;e[16]!==c||e[17]!==x||e[18]!==n||e[19]!==a||e[20]!==i?(v=c?r.jsx("div",{className:"flex max-w-[40rem] items-center gap-2 ps-6",children:r.jsx(Wa,{value:"",autoFocus:!0,placeholder:a("settings.openchamber.worktrees.setup.commandPlaceholder"),ariaLabel:a("settings.openchamber.worktrees.setup.addCommand"),onCommit:T=>{d(!1),T.trim()&&dg(n,i,T).then(x)}})}):r.jsxs(Q,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>d(!0),children:[r.jsx(B,{name:"add",className:"h-3.5 w-3.5"}),a("settings.openchamber.worktrees.setup.addCommand")]}),e[16]=c,e[17]=x,e[18]=n,e[19]=a,e[20]=i,e[21]=v):v=e[21];let w;e[22]!==s||e[23]!==h||e[24]!==x||e[25]!==n.shared.setupWorktree.length||e[26]!==a?(w=n.shared.setupWorktree.length>0?r.jsx(yr,{settingsItem:"projects.worktree.setup.replace",checked:h,onChange:T=>{pr(s,{setupWorktreeMode:T?"replace":"append"}).then(x)},label:a("settings.projects.shared.replaceMode")}):null,e[22]=s,e[23]=h,e[24]=x,e[25]=n.shared.setupWorktree.length,e[26]=a,e[27]=w):w=e[27];let S;e[28]!==s||e[29]!==x?(S=T=>{f(T),Qd(s,T).then(x)},e[28]=s,e[29]=x,e[30]=S):S=e[30];let I;e[31]!==a?(I=a("settings.openchamber.worktrees.setup.waitForCommands"),e[31]=a,e[32]=I):I=e[32];let k;e[33]!==S||e[34]!==I||e[35]!==u?(k=r.jsx(yr,{settingsItem:"projects.worktree.setup.wait",checked:u,onChange:S,label:I}),e[33]=S,e[34]=I,e[35]=u,e[36]=k):k=e[36];let R;e[37]!==w||e[38]!==k?(R=r.jsxs("div",{className:Zd,children:[w,k]}),e[37]=w,e[38]=k,e[39]=R):R=e[39];let P;return e[40]!==R||e[41]!==m||e[42]!==b||e[43]!==v?(P=r.jsxs("div",{className:m,children:[b,v,R]}),e[40]=R,e[41]=m,e[42]=b,e[43]=v,e[44]=P):P=e[44],P},Lg=t=>{const e=W.c(35),{projectRef:s,setupState:n,onOpenWorktrees:o}=t,{t:a}=se(),[i,l]=y.useState(null);let c,d;if(e[0]!==s.path?(c=()=>{let w=!1;return l(null),eu(s.path).then(S=>{w||l(S)}).catch($g),()=>{w=!0}},d=[s.path],e[0]=s.path,e[1]=c,e[2]=d):(c=e[1],d=e[2]),y.useEffect(c,d),i===!1){let w;e[3]!==a?(w=a("settings.openchamber.worktrees.setup.title"),e[3]=a,e[4]=w):w=e[4];let S;e[5]!==a?(S=a("settings.openchamber.worktrees.state.gitOnly"),e[5]=a,e[6]=S):S=e[6];let I;e[7]!==S?(I=r.jsx("p",{className:is,children:S}),e[7]=S,e[8]=I):I=e[8];let k;return e[9]!==w||e[10]!==I?(k=r.jsx(Bs,{title:w,settingsItem:"projects.worktree",divider:!1,children:I}),e[9]=w,e[10]=I,e[11]=k):k=e[11],k}let u;e[12]!==a?(u=a("settings.openchamber.worktrees.setup.title"),e[12]=a,e[13]=u):u=e[13];let f;e[14]!==a?(f=a("settings.openchamber.worktrees.setup.tooltipPrefix"),e[14]=a,e[15]=f):f=e[15];let p;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx("code",{className:"rounded bg-sidebar-accent/50 px-1 font-mono text-xs",children:"$ROOT_PROJECT_PATH"}),e[16]=p):p=e[16];let g;e[17]!==a?(g=a("settings.openchamber.worktrees.setup.tooltipSuffix"),e[17]=a,e[18]=g):g=e[18];let h;e[19]!==f||e[20]!==g?(h=r.jsxs(Ji,{children:[f," ",p," ",g]}),e[19]=f,e[20]=g,e[21]=h):h=e[21];let x;e[22]!==s||e[23]!==n?(x=n.load.state==="ready"?r.jsx(_g,{projectRef:s,setup:n.load.setup,setupState:n}):r.jsx(Wo,{setupState:n}),e[22]=s,e[23]=n,e[24]=x):x=e[24];let m;e[25]!==u||e[26]!==h||e[27]!==x?(m=r.jsx(Bs,{title:u,settingsItem:"projects.worktree",divider:!1,titleAccessory:h,children:x}),e[25]=u,e[26]=h,e[27]=x,e[28]=m):m=e[28];let b;e[29]!==o||e[30]!==a?(b=o?r.jsx(Bs,{title:a("settings.projects.worktrees.manageTitle"),children:r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("p",{className:is,children:a("settings.projects.worktrees.manageDescription")}),r.jsxs(Q,{type:"button",variant:"outline",size:"sm",onClick:o,children:[a("sessions.sidebar.project.actions.manageWorktrees"),r.jsx(B,{name:"arrow-right-s",className:"h-4 w-4"})]})]})}):null,e[29]=o,e[30]=a,e[31]=b):b=e[31];let v;return e[32]!==b||e[33]!==m?(v=r.jsxs(r.Fragment,{children:[m,b]}),e[32]=b,e[33]=m,e[34]=v):v=e[34],v};function $g(){}const Mg=t=>{const e=W.c(26);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={state:"loading"},e[0]=s):s=e[0];const[n,o]=y.useState(s),a=y.useRef(0);let i;e[1]!==t?(i=async()=>{const S=a.current=a.current+1;try{const I=await tu(t);S===a.current&&o({state:"ready",setup:I})}catch{S===a.current&&o({state:"failed"})}},e[1]=t,e[2]=i):i=e[2];const l=i;let c,d;e[3]!==l?(c=()=>(o({state:"loading"}),l(),()=>{a.current=a.current+1}),d=[l],e[3]=l,e[4]=c,e[5]=d):(c=e[4],d=e[5]),y.useEffect(c,d);let u;e[6]!==t?(u=S=>(S&&typeof window<"u"&&window.dispatchEvent(new CustomEvent(su,{detail:{projectId:t.id}})),S),e[6]=t,e[7]=u):u=e[7];const f=u;let p,g,h;e[8]!==f||e[9]!==t?(p=async S=>f(await pr(t,{projectActions:S})),g=async S=>f(await fo(t,{projectActions:S})!==null),h=async S=>f(await pr(t,{hiddenSharedActionIds:S})),e[8]=f,e[9]=t,e[10]=p,e[11]=g,e[12]=h):(p=e[10],g=e[11],h=e[12]);let x,m;e[13]!==t?(x=S=>pr(t,{setupWorktree:S}),m=async S=>await fo(t,{setupWorktree:S})!==null,e[13]=t,e[14]=x,e[15]=m):(x=e[14],m=e[15]);let b;e[16]!==p||e[17]!==g||e[18]!==h||e[19]!==x||e[20]!==m?(b={personalActions:p,sharedActions:g,hiddenSharedActionIds:h,personalCommands:x,sharedCommands:m},e[16]=p,e[17]=g,e[18]=h,e[19]=x,e[20]=m,e[21]=b):b=e[21];const v=b;let w;return e[22]!==n||e[23]!==l||e[24]!==v?(w={load:n,reload:l,write:v},e[22]=n,e[23]=l,e[24]=v,e[25]=w):w=e[25],w},Og=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Fg=t=>{if(!t)return null;const e=t.trim();return e&&Og.test(e)?e.toLowerCase():null},Xr={label:"",icon:null,color:null,iconBackground:null,defaultAgent:void 0,defaultModel:void 0,defaultVariant:void 0},Bg=t=>({label:t.label??"",icon:t.icon??null,color:t.color??null,iconBackground:t.iconBackground??null,defaultAgent:t.defaultAgent,defaultModel:t.defaultModel,defaultVariant:t.defaultVariant}),qa=(t,e)=>t.label===e.label&&t.icon===e.icon&&t.color===e.color&&t.iconBackground===e.iconBackground&&t.defaultAgent===e.defaultAgent&&t.defaultModel===e.defaultModel&&t.defaultVariant===e.defaultVariant,Vg=t=>{const{t:e}=se(),s=Jt(oe=>oe.uploadProjectIcon),n=Jt(oe=>oe.removeProjectIcon),o=Jt(oe=>oe.discoverProjectIcon),a=Jt(oe=>t?oe.projects.find(ue=>ue.id===t.id)?.iconImage??null:null),[i,l]=y.useState(""),[c,d]=y.useState(null),[u,f]=y.useState(null),[p,g]=y.useState(null),[h,x]=y.useState(void 0),[m,b]=y.useState(void 0),[v,w]=y.useState(void 0),[S,I]=y.useState(!1),[k,R]=y.useState(!1),[P,T]=y.useState(!1),[D,A]=y.useState(!1),[N,j]=y.useState(null),[_,E]=y.useState(null),[L,$]=y.useState(!1),M=y.useRef(null),C=y.useCallback(()=>{j(null),E(oe=>(oe&&URL.revokeObjectURL(oe),null))},[]),O=t?.id??null,z=y.useRef(Xr);z.current={label:i,icon:c,color:u,iconBackground:p,defaultAgent:h,defaultModel:m,defaultVariant:v};const G=y.useRef({projectId:null,identity:Xr});y.useEffect(()=>{if(!t){G.current={projectId:null,identity:Xr},l(""),d(null),f(null),g(null),x(void 0),b(void 0),w(void 0);return}const oe=Bg(t),ue=G.current,Ie=ue.projectId!==t.id;if(!Ie){if(qa(z.current,oe)){G.current={projectId:t.id,identity:oe};return}if(!qa(z.current,ue.identity))return}G.current={projectId:t.id,identity:oe},l(oe.label),d(oe.icon),f(oe.color),g(oe.iconBackground),x(oe.defaultAgent),b(oe.defaultModel),w(oe.defaultVariant),Ie&&(A(!1),C(),$(!1))},[t,C]),y.useEffect(()=>()=>{C()},[C]);const U=y.useMemo(()=>Zp(m)??{providerId:"",modelId:""},[m]),K=!!t?.iconImage,X=!!(N&&_),re=t?.iconImage?.source==="custom",ee=K&&!D||X,xe=ee,ce=!!(t&&K&&!D),he=!L&&(X||ce),ie=!!t&&(i.trim()!==(t?.label??"").trim()||c!==(t?.icon??null)||u!==(t?.color??null)||p!==(t?.iconBackground??null)||(h??void 0)!==(t?.defaultAgent??void 0)||(m??void 0)!==(t?.defaultModel??void 0)||(v??void 0)!==(t?.defaultVariant??void 0)||D||!!N),pe=y.useCallback((oe,ue)=>{b(oe&&ue?`${oe}/${ue}`:void 0),w(void 0)},[]),le=y.useCallback(oe=>{w(oe)},[]),de=y.useCallback(oe=>{!t||!oe||S||(A(!1),$(!1),j(oe),E(ue=>(ue&&URL.revokeObjectURL(ue),URL.createObjectURL(oe))))},[S,t]),te=y.useCallback(()=>{!t||!xe||k||(X&&C(),A(!!K),$(!1))},[C,X,xe,K,k,t]),J=y.useCallback(async()=>{if(!(!t||P)){C(),A(!1),$(!1),T(!0);try{const oe=await o(t.id);if(!oe.ok){Y.error(oe.error||e("settings.projects.page.toast.discoverIconFailed"));return}if(oe.skipped){Y.success(e("settings.projects.page.toast.customIconAlreadySet"));return}Y.success(e("settings.projects.page.toast.iconDiscovered"))}finally{T(!1)}}},[C,o,P,t,e]),q=y.useCallback(async oe=>{const ue=oe?.silent===!0;if(!t)return null;const Ie=i.trim();if(!Ie)return null;if(N){I(!0);const we=await s(t.id,N);if(I(!1),!we.ok)return Y.error(we.error||e("settings.projects.page.toast.uploadIconFailed")),null;ue||Y.success(e("settings.projects.page.toast.iconUpdated")),C(),A(!1)}const Le=D&&!!t.iconImage;if(Le){R(!0);const we=await n(t.id);if(R(!1),!we.ok)return Y.error(we.error||e("settings.projects.page.toast.removeIconFailed")),null;ue||Y.success(e("settings.projects.page.toast.iconRemoved")),A(!1),g(null)}return{label:Ie,icon:c,color:u,iconBackground:Fg(Le?null:p),defaultAgent:h??null,defaultModel:m??null,defaultVariant:m?v??null:null}},[C,u,h,m,v,c,p,i,D,N,t,n,e,s]);return y.useEffect(()=>{$(!1)},[O,a?.updatedAt]),{projectId:O,name:i,setName:l,icon:c,setIcon:d,color:u,setColor:f,iconBackground:p,setIconBackground:g,defaultAgent:h,setDefaultAgent:x,defaultModel:m,defaultVariant:v,parsedDefaultModel:U,handleDefaultModelChange:pe,handleDefaultVariantChange:le,isUploadingIcon:S,isRemovingCustomIcon:k,isDiscoveringIcon:P,pendingRemoveImageIcon:D,setPendingRemoveImageIcon:A,pendingUploadIconFile:N,pendingUploadIconPreviewUrl:_,previewImageFailed:L,setPreviewImageFailed:$,hasStoredImageIcon:K,hasPendingUploadImageIcon:X,hasCustomIcon:re,effectiveHasImageIcon:ee,hasRemovableImageIcon:xe,showStoredImagePreview:ce,showImagePreview:he,fileInputRef:M,clearPendingUploadIcon:C,handleUploadIcon:de,handleRemoveImageIcon:te,handleDiscoverIcon:J,hasChanges:ie,prepareSaveData:q,currentIconImage:a,project:t}},Ug=450,zg=(t,e)=>{const{t:s}=se(),{projectId:n,hasChanges:o,name:a,icon:i,color:l,iconBackground:c,defaultModel:d,pendingRemoveImageIcon:u,pendingUploadIconFile:f,isUploadingIcon:p,isRemovingCustomIcon:g,prepareSaveData:h}=t,x=y.useRef(!1),m=y.useRef(null);y.useEffect(()=>{if(!o){m.current=null;return}if(!a.trim()||p||g||x.current)return;const b=window.setTimeout(()=>{x.current||(x.current=!0,(async()=>{try{const v=await h({silent:!0});if(v){const w=JSON.stringify(v),S=m.current;if(S&&S.projectId===n&&S.data===w)return;try{await e(v),m.current={projectId:n,data:w}}catch{Y.error(s("settings.projects.page.toast.saveFailed"))}}}finally{x.current=!1}})())},Ug);return()=>{window.clearTimeout(b)}},[l,d,o,i,c,g,p,a,e,u,f,h,n,s])},Kg=t=>t==="general"||t==="actions"||t==="worktrees"||t==="environment",Tw=t=>{const e=W.c(70),{project:s,onIdentitySave:n,tab:o,onTabChange:a,frame:i,onOpenWorktrees:l,onCloseProject:c}=t,{t:d}=se(),u=Vg(s);zg(u,n);let f;e[0]!==s.id||e[1]!==s.path?(f={id:s.id,path:s.path},e[0]=s.id,e[1]=s.path,e[2]=f):f=e[2];const p=f,g=Mg(p);let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=qs(),e[3]=h):h=e[3];const x=!h,m=o==="environment"&&!x?"general":o;let b;e[4]!==d?(b=d("settings.projects.tab.general"),e[4]=d,e[5]=b):b=e[5];let v;e[6]!==b?(v={id:"general",label:b},e[6]=b,e[7]=v):v=e[7];let w;e[8]!==d?(w=d("settings.projects.tab.actions"),e[8]=d,e[9]=w):w=e[9];let S;e[10]!==w?(S={id:"actions",label:w},e[10]=w,e[11]=S):S=e[11];let I;e[12]!==d?(I=d("settings.projects.tab.worktrees"),e[12]=d,e[13]=I):I=e[13];let k;e[14]!==I?(k={id:"worktrees",label:I},e[14]=I,e[15]=k):k=e[15];let R;e[16]!==d?(R=x?[{id:"environment",label:d("settings.projects.tab.environment")}]:[],e[16]=d,e[17]=R):R=e[17];let P;e[18]!==v||e[19]!==S||e[20]!==k||e[21]!==R?(P=[v,S,k,...R],e[18]=v,e[19]=S,e[20]=k,e[21]=R,e[22]=P):P=e[22];const T=P;let D;e[23]!==u?(D=r.jsx(Ag,{form:u}),e[23]=u,e[24]=D):D=e[24];const A=D;let N;e[25]!==a?(N=K=>{Kg(K)&&a(K)},e[25]=a,e[26]=N):N=e[26];let j;e[27]!==m||e[28]!==N||e[29]!==T?(j=r.jsx(el,{items:T,activeId:m,onSelect:N,layoutMode:"fit",variant:"active-pill",pillSize:"form",className:"h-8 max-w-[32rem]"}),e[27]=m,e[28]=N,e[29]=T,e[30]=j):j=e[30];const _=j;let E;e[31]!==m||e[32]!==u||e[33]!==p||e[34]!==g?(E=m==="general"?r.jsx(Tg,{form:u,projectRef:p,setupState:g}):null,e[31]=m,e[32]=u,e[33]=p,e[34]=g,e[35]=E):E=e[35];let L;e[36]!==m||e[37]!==g?(L=m==="actions"?r.jsx(hg,{setupState:g}):null,e[36]=m,e[37]=g,e[38]=L):L=e[38];let $;e[39]!==m||e[40]!==l||e[41]!==p||e[42]!==g?($=m==="worktrees"?r.jsx(Lg,{projectRef:p,setupState:g,onOpenWorktrees:l}):null,e[39]=m,e[40]=l,e[41]=p,e[42]=g,e[43]=$):$=e[43];let M;e[44]!==m||e[45]!==p?(M=m==="environment"?r.jsx(kg,{projectRef:p}):null,e[44]=m,e[45]=p,e[46]=M):M=e[46];let C;e[47]!==E||e[48]!==L||e[49]!==$||e[50]!==M?(C=r.jsxs(r.Fragment,{children:[E,L,$,M]}),e[47]=E,e[48]=L,e[49]=$,e[50]=M,e[51]=C):C=e[51];const O=C;if(i==="page"){let K;e[52]!==c||e[53]!==d?(K=c?r.jsxs(Q,{variant:"ghost",size:"xs",className:"!font-normal text-[var(--status-error)] hover:text-[var(--status-error)]","data-settings-item":"projects.close",onClick:c,children:[r.jsx(B,{name:"close",className:"size-3.5"}),d("settings.projects.page.actions.closeProject")]}):null,e[52]=c,e[53]=d,e[54]=K):K=e[54];const X=K;let re;e[55]!==_?(re=r.jsx("div",{className:"mb-8",children:_}),e[55]=_,e[56]=re):re=e[56];let ee;return e[57]!==X||e[58]!==A||e[59]!==re||e[60]!==O?(ee=r.jsxs(Jh,{title:A,headerEnd:X,showSaveStatus:!0,outerClassName:"bg-background",children:[re,O]}),e[57]=X,e[58]=A,e[59]=re,e[60]=O,e[61]=ee):ee=e[61],ee}let z;e[62]!==A||e[63]!==_?(z=r.jsxs("div",{className:"shrink-0 space-y-6 px-4 pt-6 pb-5 sm:px-6 sm:pt-8",children:[A,_]}),e[62]=A,e[63]=_,e[64]=z):z=e[64];let G;e[65]!==O?(G=r.jsx(Mn,{outerClassName:"min-h-0 flex-1",className:"w-full",children:r.jsx("div",{className:"px-4 pb-6 sm:px-6 [&>section:first-of-type]:border-t-0 [&>section:first-of-type]:pt-0",children:O})}),e[65]=O,e[66]=G):G=e[66];let U;return e[67]!==z||e[68]!==G?(U=r.jsxs("div",{className:"flex min-h-0 flex-1 flex-col @container",children:[z,G]}),e[67]=z,e[68]=G,e[69]=U):U=e[69],U};let jo=null,Ha=0,Qr=!1;function Gg(){return jo?.runtimeKey===be()?jo.catalog:null}async function Wg(t){try{return(await(t?At.getScopedSdkClient(t):At.getSdkClient()).integration.list()).data}catch(e){throw em("integration.list",e)}}async function qg(){const t=be(),e=++Ha,s=At.getDirectory()||null,[n,o]=await Promise.all([Wg(s),nu(s).catch(()=>null)]),a={integrations:n,webSearchIds:o?new Set(o.map(i=>i.id)):null};return e===Ha&&t===be()&&(jo={runtimeKey:t,catalog:a}),a}function Rw(){Qr||Gg()||(Qr=!0,(async()=>{try{await qg()}catch(t){console.warn("[providers] could not prefetch the integration list:",t instanceof Error?t.message:String(t))}finally{Qr=!1}})())}const xc=[{id:"openai",noteKey:"settings.providers.connect.note.openai",recommended:!0},{id:"opencode-go",noteKey:"settings.providers.connect.note.opencodeGo",recommended:!0},{id:"openrouter",noteKey:"settings.providers.connect.note.openrouter",recommended:!0},{id:"anthropic",noteKey:"settings.providers.connect.note.anthropic",recommended:!1},{id:"github-copilot",noteKey:"settings.providers.connect.note.githubCopilot",recommended:!1},{id:"google",noteKey:"settings.providers.connect.note.google",recommended:!1},{id:"vercel",noteKey:"settings.providers.connect.note.vercel",recommended:!1}],Hg=new Set(xc.map(t=>t.id)),Ew=(t,e)=>t.integrations.filter(s=>s.connections.length===0&&!s.id.startsWith("mcp_")&&!t.webSearchIds?.has(s.id)&&!ru(s)&&!e.has(s.id)).map(s=>({id:s.id,name:s.name||s.id})).sort((s,n)=>s.name.localeCompare(n.name,void 0,{sensitivity:"base"})),Dw=t=>{const e=new Map(t.map(s=>[s.id,s]));return{popular:xc.flatMap(s=>{const n=e.get(s.id);return n?[{...n,...s}]:[]}),others:t.filter(s=>!Hg.has(s.id))}},bc="openchamber:recent-git-branches:v1",yc=5,Yg=Rm(nt(),Bo(nt())),vc=t=>{const e=Ct(t);return e?`${be()}:${e}`:null},wc=()=>{try{const t=localStorage.getItem(bc),e=Yg.safeParse(t?JSON.parse(t):null);return e.success?Object.fromEntries(Object.entries(e.data).map(([s,n])=>[s,n.slice(0,yc)])):{}}catch{return{}}},Ya=t=>{const e=vc(t);return e?wc()[e]??[]:[]},Ja=(t,e)=>{const s=vc(t);if(!s||!e)return[];const n=wc(),o=[e,...(n[s]??[]).filter(a=>a!==e)].slice(0,yc);try{localStorage.setItem(bc,JSON.stringify({...n,[s]:o}))}catch{}return o},No=t=>{const e=t.trim().replace(/[\s\x00-\x1f\x7f~^:?*[\\]+/g,"-").replace(/@\{/g,"-").replace(/\.{2,}/g,".").replace(/-{2,}/g,"-").split("/").map(s=>s.replace(/^[-.]+/,"").replace(/(?:\.lock|-)+$/,"")).filter(Boolean).join("/").replace(/(?:\.lock|\.)+$/,"");return e==="@"?"":e},Jg=({currentBranch:t,localBranches:e,remoteBranches:s,branchInfo:n,currentBranchAhead:o=0,onCheckout:a,onCreate:i,disabled:l=!1,directory:c,switchBlockedNotice:d=null})=>{const{t:u}=se(),{isMobile:f}=On(),[p,g]=y.useState(!1),[h,x]=y.useState(""),[m,b]=y.useState(!1),[v,w]=y.useState(""),[S,I]=y.useState(!1),[k,R]=y.useState(()=>Ya(c)),[P,T]=y.useState({}),D=y.useRef(null),A=y.useCallback(C=>{C.stopPropagation()},[]),N=y.useMemo(()=>No(v),[v]),j=y.useMemo(()=>po(e,h,C=>[C]),[h,e]),_=y.useMemo(()=>po(s,h,C=>[C]),[h,s]),E=C=>{if(C===t){g(!1);return}R(Ja(c,C)),a(C),g(!1),x("")},L=()=>{b(!0),setTimeout(()=>D.current?.focus(),50)},$=async()=>{if(!(!N||S)){I(!0);try{await i(N),w(""),b(!1),g(!1)}finally{I(!1)}}},M=()=>{w(""),b(!1)};if(y.useEffect(()=>{p||(x(""),b(!1),w(""))},[p]),y.useEffect(()=>{c&&R(t?Ja(c,t):Ya(c))},[t,c]),y.useEffect(()=>{if(!p)return;const C=k.filter(z=>e.includes(z)).slice(0,5);if(C.length===0)return T({});let O=!1;return ou(c,C).then(({counts:z})=>{O||T(z)}).catch(()=>{O||T({})}),()=>{O=!0}},[c,p,e,k]),f){const C=k.filter(z=>e.includes(z)),O=(z,G=!1)=>{const U=P[z]??(z===t?o:0),K=U===1?u("gitView.branch.unpushedSingle"):u("gitView.branch.unpushedPlural",{count:U});return r.jsxs("button",{type:"button",onClick:()=>E(z),className:"flex w-full items-center gap-2 rounded-lg px-2 py-2.5 text-start typography-ui-label hover:bg-interactive-hover",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate",children:z}),U>0?r.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-muted-foreground",title:K,"aria-label":K,children:[r.jsx(B,{name:"arrow-up",className:"size-3","aria-hidden":"true"}),r.jsx("span",{"aria-hidden":"true",children:U})]}):null,t===z?r.jsx(B,{name:"check",className:"size-4 shrink-0 text-primary"}):null]},`${G?"remote":"local"}-${z}`)};return r.jsxs(r.Fragment,{children:[r.jsxs(Q,{variant:"ghost",size:"sm",className:"min-w-0 max-w-full justify-start gap-1.5 px-2 py-1",disabled:l,onClick:()=>g(!0),children:[r.jsx(B,{name:"git-branch",className:"size-4 text-primary"}),r.jsx("span",{className:"min-w-0 truncate font-medium text-start",children:t||u("gitView.branch.detachedHead")}),r.jsx(B,{name:"arrow-down-s",className:"size-4 opacity-60"})]}),r.jsx(Dr,{open:p,title:u("gitView.branch.currentBranchTooltip"),onClose:()=>g(!1),children:r.jsxs("div",{className:"flex flex-col gap-2 px-3 pb-4 pt-1",children:[r.jsx("input",{value:h,onChange:z=>x(z.target.value),placeholder:u("gitView.branch.searchPlaceholder"),className:"oc-surface-elevated oc-raised oc-field h-9 w-full rounded-lg bg-surface-elevated px-3 typography-meta outline-none placeholder:text-muted-foreground"}),d?r.jsxs("div",{className:"flex items-start gap-2 px-2 py-1",children:[r.jsx(B,{name:"alert",className:"mt-0.5 size-3.5 shrink-0 text-[var(--status-warning)]","aria-hidden":"true"}),r.jsx("span",{className:"typography-micro text-muted-foreground",children:d})]}):null,C.length>0?r.jsxs("section",{children:[r.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:u("gitView.branch.recentBranches")}),C.map(z=>O(z))]}):null,r.jsxs("section",{children:[r.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:u("gitView.branch.localBranches")}),j.map(z=>O(z))]}),r.jsxs("section",{children:[r.jsx("p",{className:"px-2 pb-1 pt-2 typography-meta text-muted-foreground",children:u("gitView.branch.remoteBranches")}),_.map(z=>O(z,!0))]})]})})]})}return r.jsxs(Ut,{open:p,onOpenChange:g,children:[r.jsxs(Ps,{children:[r.jsx(As,{asChild:!0,children:r.jsx(Bt,{asChild:!0,children:r.jsxs(Q,{variant:"ghost",size:"sm",className:"branch-selector__trigger max-w-full justify-start gap-1.5 px-2 py-1",disabled:l,children:[r.jsx(B,{name:"git-branch",className:"size-4 text-primary"}),r.jsx("span",{className:"grid min-w-0 grid-cols-[minmax(0,max-content)]",children:r.jsx("span",{className:"truncate font-medium text-start",children:t||u("gitView.branch.detachedHead")})}),r.jsx(B,{name:"arrow-down-s",className:"size-4 opacity-60"})]})})}),r.jsx(_s,{sideOffset:8,children:u("gitView.branch.currentBranchTooltip")})]}),r.jsx(Vt,{align:"start",className:"w-72 p-0 max-h-[60vh] flex flex-col",children:r.jsxs(tl,{className:"h-full min-h-0",shouldFilter:!1,children:[r.jsx(sl,{placeholder:u("gitView.branch.searchPlaceholder"),value:h,onValueChange:x,onKeyDown:A}),d?r.jsxs("div",{className:"flex items-start gap-2 border-b border-border/60 px-3 py-2",children:[r.jsx(B,{name:"alert",className:"mt-0.5 size-3.5 shrink-0 text-[var(--status-warning)]","aria-hidden":"true"}),r.jsx("span",{className:"typography-micro text-muted-foreground",children:d})]}):null,r.jsxs(nl,{scrollbarClassName:"overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero",disableHorizontal:!0,children:[r.jsx(au,{children:u("gitView.branch.empty")}),r.jsx(Zn,{children:m?r.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg",children:[r.jsx("input",{ref:D,placeholder:u("gitView.branch.newBranchPlaceholder"),value:v,onChange:C=>w(C.target.value),onClick:C=>C.stopPropagation(),onKeyDown:C=>{A(C),C.key==="Enter"?(C.preventDefault(),$()):C.key==="Escape"&&(C.preventDefault(),M())},className:"flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground"}),r.jsx("button",{type:"button",onClick:$,disabled:!N||S,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:S?r.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):r.jsx(B,{name:"add",className:"size-4"})}),r.jsx("button",{type:"button",onClick:M,disabled:S,className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:r.jsx(B,{name:"close",className:"size-4"})})]}):r.jsxs(Os,{onSelect:L,children:[r.jsx(B,{name:"add",className:"size-4"}),r.jsx("span",{children:u("gitView.branch.create")})]})}),r.jsx(Kr,{}),k.filter(C=>e.includes(C)).length>0?r.jsxs(r.Fragment,{children:[r.jsx(Zn,{heading:u("gitView.branch.recentBranches"),children:k.filter(C=>e.includes(C)).map(C=>r.jsxs(Os,{onSelect:()=>E(C),children:[r.jsxs("span",{className:"flex flex-1 items-center gap-2 min-w-0",children:[r.jsx("span",{className:"typography-ui-label text-foreground truncate",children:C}),(()=>{const O=P[C]??(C===t?o:0),z=O===1?u("gitView.branch.unpushedSingle"):u("gitView.branch.unpushedPlural",{count:O});return O>0?r.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full px-1.5 py-0.5 typography-micro text-muted-foreground",title:z,"aria-label":z,children:[r.jsx(B,{name:"arrow-up",className:"size-3","aria-hidden":"true"}),r.jsx("span",{"aria-hidden":"true",children:O})]}):null})()]}),t===C?r.jsx("span",{className:"typography-micro text-primary",children:u("gitView.branch.currentBadge")}):null]},`recent-${C}`))}),r.jsx(Kr,{})]}):null,r.jsxs(Zn,{heading:u("gitView.branch.localBranches"),children:[j.map(C=>r.jsxs(Os,{onSelect:()=>E(C),children:[r.jsxs("span",{className:"flex flex-1 flex-col",children:[r.jsx("span",{className:"typography-ui-label text-foreground",children:C}),(n?.[C]?.ahead||n?.[C]?.behind)&&r.jsxs("span",{className:"typography-micro text-muted-foreground",children:[n[C].ahead||0," ahead ·"," ",n[C].behind||0," behind"]})]}),t===C&&r.jsx("span",{className:"typography-micro text-primary",children:u("gitView.branch.currentBadge")})]},`local-${C}`)),j.length===0&&r.jsx(Os,{disabled:!0,className:"justify-center",children:r.jsx("span",{className:"typography-meta text-muted-foreground",children:u("gitView.branch.noLocalBranches")})})]}),r.jsx(Kr,{}),r.jsxs(Zn,{heading:u("gitView.branch.remoteBranches"),children:[_.map(C=>r.jsx(Os,{onSelect:()=>E(C),children:r.jsx("span",{className:"typography-ui-label text-foreground",children:C})},`remote-${C}`)),_.length===0&&r.jsx(Os,{disabled:!0,className:"justify-center",children:r.jsx("span",{className:"typography-meta text-muted-foreground",children:u("gitView.branch.noRemoteBranches")})})]})]})]})})]})},Xg=({currentBranch:t,onRename:e,showEditButton:s=!0})=>{const{t:n}=se(),[o,a]=y.useState(!1),[i,l]=y.useState(t||""),[c,d]=y.useState(!1),u=y.useRef(null),f=()=>{!t||!e||(l(t),a(!0),setTimeout(()=>u.current?.focus(),0))},p=async()=>{if(!t||!e)return;const x=No(i);if(x){if(x===t){a(!1);return}d(!0);try{await e(t,x),a(!1),l("")}finally{d(!1)}}},g=()=>{a(!1),l("")},h=x=>{x.key==="Enter"?(x.preventDefault(),p()):x.key==="Escape"&&(x.preventDefault(),g())};return o?r.jsx("div",{className:"flex items-center gap-2 rounded-md bg-primary/12 px-2 py-1 h-7",children:r.jsxs("form",{className:"flex w-full items-center gap-2",onSubmit:x=>{x.preventDefault(),p()},children:[r.jsx(B,{name:"git-branch",className:"size-4 text-primary"}),r.jsx("input",{ref:u,value:i,onChange:x=>l(x.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",placeholder:n("gitView.branch.namePlaceholder"),onKeyDown:h,autoFocus:!0}),r.jsx("button",{type:"submit",disabled:c||!No(i),"aria-label":n(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),title:n(c?"gitView.branch.renameSaving":"gitView.branch.renameSave"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:c?r.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):r.jsx(B,{name:"check",className:"size-4"})}),r.jsx("button",{type:"button",onClick:g,disabled:c,"aria-label":n("gitView.branch.renameCancel"),title:n("gitView.branch.renameCancel"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:r.jsx(B,{name:"close",className:"size-4"})})]})}):r.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5 px-2 py-1 h-7",children:[r.jsx(B,{name:"git-branch",className:"size-4 text-primary shrink-0"}),r.jsxs("div",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[r.jsx("span",{className:"truncate typography-ui-label font-normal text-foreground",children:t||n("gitView.branch.detachedHead")}),s&&e&&t&&r.jsx(Q,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 shrink-0",onClick:f,title:n("gitView.branch.renameTitle"),children:r.jsx(B,{name:"edit",className:"size-4"})})]})]})},Qg=t=>{const e=W.c(42),{syncAction:s,remotes:n,onFetch:o,onPull:a,onSync:i,onPublish:l,onChooseSyncTargets:c,currentBranch:d,hasTracking:u,onRemoveRemote:f,disabled:p,removingRemoteName:g,aheadCount:h,behindCount:x,trackingRemoteName:m,hasUncommittedChanges:b,choosesPushDestination:v}=t,w=n===void 0?[]:n,S=u===void 0?!1:u,I=g===void 0?null:g,k=h===void 0?0:h,R=x===void 0?0:x,P=b===void 0?!1:b,T=v===void 0?!1:v,{t:D}=se(),A=y.useRef(!1),N=!!I,j=m?w.find(ge=>ge.name===m):void 0,_=R>0&&P,E=!d||d==="HEAD",L=!S,$=p||s!==null||N||E||!L&&_,M=p||s!==null||N||w.length===0,C=!j||P,O=E||S&&k===0,z=k>0||R>0,G=T?"gitView.publish.pushTo":"gitView.publish.title";let U;e[0]!==D||e[1]!==G?(U=D(G),e[0]=D,e[1]=G,e[2]=U):U=e[2];const K=U;let X;e[3]!==L||e[4]!==K||e[5]!==D?(X=L?K:D("gitView.sync.sync"),e[3]=L,e[4]=K,e[5]=D,e[6]=X):X=e[6];const re=X,ee=R>0?`↓${R}`:null,xe=k>0?`↑${k}`:null;let ce;e[7]!==ee||e[8]!==xe?(ce=[ee,xe].filter(Boolean),e[7]=ee,e[8]=xe,e[9]=ce):ce=e[9];const he=ce.join(" "),ie=E?D("gitView.publish.detached"):L?K:_?D("gitView.sync.commitOrStashTooltip"):j?z?D("gitView.sync.syncChangesTooltip",{ahead:k,behind:R}):D("gitView.sync.syncChanges"):D("gitView.sync.noRemoteTooltip"),pe=()=>{if(L){l();return}if(!j){c();return}i(j)};let le;e[10]===Symbol.for("react.memo_cache_sentinel")?(le=ne("inline-flex h-7 items-center gap-1.5 px-2 typography-ui-label font-medium text-foreground","transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"),e[10]=le):le=e[10];let de;e[11]!==L||e[12]!==K||e[13]!==D?(de=L?K:D("gitView.sync.syncChanges"),e[11]=L,e[12]=K,e[13]=D,e[14]=de):de=e[14];let te;e[15]!==s?(te=s==="sync"||s==="publish"?r.jsx(Ft,{className:"size-4"}):r.jsx(B,{name:"refresh",className:"size-4"}),e[15]=s,e[16]=te):te=e[16];let J;e[17]!==he||e[18]!==re?(J=he?r.jsxs("span",{className:"sync-actions__text whitespace-nowrap tabular-nums",children:[r.jsx("span",{className:"sync-actions__label",children:re})," ",he]}):r.jsx("span",{className:"sync-actions__text sync-actions__label whitespace-nowrap",children:re}),e[17]=he,e[18]=re,e[19]=J):J=e[19];let q;e[20]!==ie?(q=r.jsx(_s,{sideOffset:8,children:ie}),e[20]=ie,e[21]=q):q=e[21];let oe;e[22]===Symbol.for("react.memo_cache_sentinel")?(oe=ne("inline-flex h-7 w-6 items-center justify-center border-s border-[var(--interactive-border)] text-muted-foreground","transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"),e[22]=oe):oe=e[22];let ue;e[23]!==D?(ue=D("gitView.sync.moreActionsAria"),e[23]=D,e[24]=ue):ue=e[24];let Ie;e[25]===Symbol.for("react.memo_cache_sentinel")?(Ie=r.jsx(B,{name:"arrow-down-s",className:"size-4"}),e[25]=Ie):Ie=e[25];let Le;e[26]!==M||e[27]!==ue?(Le=r.jsx(Bt,{asChild:!0,children:r.jsx("button",{type:"button",className:oe,disabled:M,"aria-label":ue,children:Ie})}),e[26]=M,e[27]=ue,e[28]=Le):Le=e[28];let we;e[29]===Symbol.for("react.memo_cache_sentinel")?(we=r.jsx(B,{name:"arrow-up",className:"size-4 text-muted-foreground"}),e[29]=we):we=e[29];let $e;e[30]!==S||e[31]!==K||e[32]!==D?($e=S?D("gitView.sync.push"):K,e[30]=S,e[31]=K,e[32]=D,e[33]=$e):$e=e[33];let ke;e[34]!==O||e[35]!==l||e[36]!==$e?(ke=r.jsxs(lt,{disabled:O,onSelect:l,children:[we,$e]}),e[34]=O,e[35]=l,e[36]=$e,e[37]=ke):ke=e[37];let Te;e[38]===Symbol.for("react.memo_cache_sentinel")?(Te=r.jsx(B,{name:"arrow-down",className:"size-4 text-muted-foreground"}),e[38]=Te):Te=e[38];let ae;e[39]!==D?(ae=D("gitView.sync.pullRebase"),e[39]=D,e[40]=ae):ae=e[40];let fe;return e[41]===Symbol.for("react.memo_cache_sentinel")?(fe=r.jsx(Pn,{}),e[41]=fe):fe=e[41],r.jsxs("div",{className:"inline-flex items-center rounded-md border border-border/60 bg-[var(--surface-elevated)] overflow-hidden",children:[r.jsxs(Ps,{children:[r.jsx(As,{asChild:!0,children:r.jsx("span",{className:"inline-flex",tabIndex:_||E?0:void 0,children:r.jsxs("button",{type:"button",onClick:pe,disabled:$,className:le,"aria-label":de,children:[te,J]})})}),q]}),r.jsxs(Ut,{children:[Le,r.jsxs(Vt,{align:"end",className:"w-[min(360px,calc(100vw-2rem))] max-h-[320px] overflow-y-auto",children:[ke,r.jsxs(lt,{disabled:C,onSelect:()=>{j&&a(j)},children:[Te,ae]}),fe,w.map(ge=>r.jsx(lt,{onSelect:Oe=>{if(A.current){Oe.preventDefault(),A.current=!1;return}o(ge)},children:r.jsxs("div",{className:"flex w-full items-center gap-2",children:[r.jsx(B,{name:"download",className:"size-4 text-muted-foreground"}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:"typography-ui-label text-foreground",children:D("gitView.sync.fetchFromRemote",{name:ge.name})}),r.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:ge.fetchUrl})]})}),f&&ge.name!==m?r.jsx(Q,{type:"button",variant:"destructive",size:"xs",className:"h-6 w-6 px-0",disabled:s!==null||N,onPointerDown:Oe=>{A.current=!0,Oe.preventDefault(),Oe.stopPropagation()},onClick:Oe=>{A.current=!0,Oe.preventDefault(),Oe.stopPropagation(),f(ge)},"aria-label":D("gitView.header.removeRemoteAria",{name:ge.name}),title:D("gitView.header.removeRemoteTitle",{name:ge.name}),children:I===ge.name?r.jsx(Ft,{className:"size-3.5"}):r.jsx(B,{name:"close",className:"size-3.5"})}):null]})},ge.name))]})]})]})},Sc={code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"},Zg={code:"!",color:"var(--status-error)",descriptionKey:"diffView.change.conflicted"},e1=new Map([["?",{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"}],["A",{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"}],["D",{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"}],["R",{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"}],["C",{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"}],["M",Sc]]),t1=t=>{const e=t.index?.trim()??"",s=t.working_dir?.trim()??"";return e==="U"||s==="U"||e==="A"&&s==="A"||e==="D"&&s==="D"},s1=t=>t.index?.trim()==="?"||t.working_dir?.trim()==="?",n1=t=>(t??[]).some(e=>!s1(e)),r1=t=>{const e=t.index?.trim(),s=t.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Pw=t=>t1(t)?Zg:e1.get(r1(t))??Sc,o1=t=>{const e=W.c(27),{repositories:s,selectedRepository:n,onSelectRepository:o,repositoryRoot:a}=t,{t:i}=se();let l;e[0]!==a?(l=w=>{if(w===a)return w.split("/").filter(Boolean).pop()??w;const S=`${a??""}/`;return w.startsWith(S)?w.slice(S.length):w},e[0]=a,e[1]=l):l=e[1];const c=l,d=n??void 0;let u;e[2]!==o?(u=w=>{w&&o(w)},e[2]=o,e[3]=u):u=e[3];let f;e[4]!==i?(f=i("gitView.empty.selectRepositoryPlaceholder"),e[4]=i,e[5]=f):f=e[5];let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(B,{name:"folder-3",className:"size-4 text-muted-foreground"}),e[6]=p):p=e[6];let g;e[7]!==c||e[8]!==n?(g=n?c(n):"",e[7]=c,e[8]=n,e[9]=g):g=e[9];let h;e[10]!==g?(h=r.jsx("span",{className:"grid min-w-0 grid-cols-[minmax(0,max-content)]",children:r.jsx("span",{className:"truncate font-medium text-start",children:g})}),e[10]=g,e[11]=h):h=e[11];let x;e[12]!==f||e[13]!==h?(x=r.jsxs(gn,{className:"max-w-[13rem] gap-1.5 px-2 py-1","aria-label":f,children:[p,h]}),e[12]=f,e[13]=h,e[14]=x):x=e[14];let m;if(e[15]!==c||e[16]!==s){let w;e[18]!==c?(w=S=>r.jsx(Ds,{value:S,children:r.jsx("span",{className:"truncate",children:c(S)})},S),e[18]=c,e[19]=w):w=e[19],m=s.map(w),e[15]=c,e[16]=s,e[17]=m}else m=e[17];let b;e[20]!==m?(b=r.jsx(xn,{align:"start",children:m}),e[20]=m,e[21]=b):b=e[21];let v;return e[22]!==b||e[23]!==d||e[24]!==u||e[25]!==x?(v=r.jsxs(hn,{value:d,onValueChange:u,children:[x,b]}),e[22]=b,e[23]=d,e[24]=u,e[25]=x,e[26]=v):v=e[26],v},a1=(t,e)=>{const s=t.account?iu(t.account.instance):null;if(s&&e.host&&s!==e.host)return{applicable:!1,reason:"host",host:s};const n=Pr(t);return(n==="account"||n==="anonymous")&&!e.https?{applicable:!1,reason:"scheme",scheme:"https"}:n==="ssh"&&!e.ssh?{applicable:!1,reason:"scheme",scheme:"ssh"}:{applicable:!0}};class Yo extends Error{constructor(){super("stale-runtime"),this.name="StaleRuntimeError"}}const jc=(t=be)=>{const e=t();return()=>{if(t()!==e)throw new Yo}},Nc=(t,e,s,n)=>{const o=e.repository.remotes.find(l=>l.name===s);if(!o)return null;const a={directory:n,expectedRepositoryId:e.repository.repositoryId,expectedRevision:e.revision,expectedConfigRevision:e.repository.configRevision,expectedFetchFingerprint:o.fetch.fingerprint,expectedPushFingerprint:o.push.fingerprint,remote:s},i=Pr(t);return i==="account"&&t.account?{...a,transport:"https",credentialAccount:t.account}:i==="ssh"&&t.sshCredentialId?{...a,transport:"ssh",sshCredentialId:t.sshCredentialId}:i==="anonymous"?{...a,transport:"anonymous"}:i==="system"?{...a,transport:"system",unverifiedConfirmed:!0}:null},i1=(t,e)=>t.applicable?"":t.reason==="host"?e("gitView.identity.unavailableHost",{host:t.host}):e(t.scheme==="ssh"?"gitView.identity.unavailableNeedsSsh":"gitView.identity.unavailableNeedsHttps"),l1=async({directory:t,identity:e,remoteName:s},{git:n,sourceControl:o,runtimeKey:a})=>{const i=jc(a);let l=s&&n.configureTransportBinding?await c1({directory:t,identity:e,remoteName:s},{configureTransportBinding:n.configureTransportBinding,removeTransportBinding:n.removeTransportBinding,sourceControl:o,requireRuntime:i}):{status:"applied"};if(l.status==="failed"&&l.reason==="runtime")return l;try{i()}catch{return{status:"failed",reason:"runtime"}}try{e.id&&await n.setGitIdentity(t,e.id)}catch{l.status==="applied"&&(l={status:"failed",reason:"author"})}return l},Aw=(t,e)=>{const s="configure",n=Pr(t);return n==="system"?{...e,operation:s,transport:n,unverifiedConfirmed:!0}:n==="account"&&t.account?{...e,operation:s,transport:"https",credentialAccount:t.account}:n==="ssh"&&t.sshCredentialId?{...e,operation:s,transport:n,sshCredentialId:t.sshCredentialId}:n==="anonymous"?{...e,operation:s,transport:n}:null},_w=async({directory:t,identity:e,remoteName:s},{git:n,sourceControl:o,runtimeKey:a})=>{if(!n.configureTransportBinding)return{status:"failed",reason:"binding"};const i=jc(a),l=()=>{try{return i(),!0}catch{return!1}},c=os.scope(t);let d;try{d=await o.repositoryBinding(t)}catch{return{status:"failed",reason:"binding"}}const u=Nc(e,d,s,t);if(!u)return{status:"failed",reason:"binding"};try{i()}catch{return{status:"failed",reason:"runtime"}}const f=os.captureMutation(c,d);let p={status:"applied"};try{const g=await n.configureTransportBinding(u);i(),g.status==="configured"?os.setMutationResult(f,g.binding):await os.reconcile(f,o)}catch(g){if(g instanceof Yo||!l())return{status:"failed",reason:"runtime"};p={status:"failed",reason:"binding"},await os.reconcile(f,o)}finally{f.release()}return p},c1=async({directory:t,identity:e,remoteName:s},{configureTransportBinding:n,removeTransportBinding:o,sourceControl:a,requireRuntime:i})=>{const l=os.scope(t);let c;try{c=await a.repositoryBinding(t)}catch{return{status:"failed",reason:"binding"}}try{i()}catch{return{status:"failed",reason:"runtime"}}const d=os.captureMutation(l,c);let u={status:"applied"};try{const f=c.binding?.providers[0],p=f&&{provider:f.provider,instance:f.instance,accountId:f.accountId,primaryRemote:f.primaryRemote},g={directory:t,expectedRepositoryId:c.repository.repositoryId,expectedRevision:c.revision};if(i(),e.account){const x={...e.account,primaryRemote:s};c=await a.repositoryProviderBindingMutate(p?{...g,operation:"replace",target:p,provider:x}:{...g,operation:"add",provider:x})}else p&&(c=await a.repositoryProviderBindingMutate({...g,operation:"remove",target:p}));const h=Nc(e,c,s,t);if(h){i();const x=await n(h);x.status==="configured"&&(c=x.binding)}for(const x of c.repository.remotes){const m=x.name;if(m===s)continue;const b=c.binding?.remotes.find(v=>v.name===m&&!v.inherited);if(!(!b||b.readiness!=="ready")){i();try{if(o){const v=await o({directory:t,expectedRepositoryId:c.repository.repositoryId,expectedRevision:c.revision,expectedConfigRevision:c.repository.configRevision,expectedFetchFingerprint:x.fetch.fingerprint,expectedPushFingerprint:x.push.fingerprint,remote:m});v.status==="removed"&&(c=v.binding)}}catch{u={status:"failed",reason:"binding"}}}}i(),os.setMutationResult(d,c)}catch(f){if(f instanceof Yo)return{status:"failed",reason:"runtime"};try{i()}catch{return{status:"failed",reason:"runtime"}}u={status:"failed",reason:"binding"},await os.reconcile(d,a)}finally{d.release()}return u},d1=t=>{const e=W.c(2);let s;return e[0]!==t?(s=n=>{const o=Ct(t??null);if(!o)return!1;for(const a of n.availableWorktreesByProject.values())if(lu(a,o)?.provenance?.kind==="contributor-fork")return!0;return!1},e[0]=t,e[1]=s):s=e[1],_e(s)},Xa=(t,e)=>{const s=t.trim(),n=cu({name:"",fetchUrl:s,pushUrl:s},[...e]);if(!n)return null;let o;const a=/^(?:[^@/:\s]+@)?[^/:\s]+:([^\s]+)$/.exec(s);if(a&&!s.includes("://"))o=a[1];else try{const d=new URL(s);if(!["https:","http:","ssh:","git:"].includes(d.protocol))return null;o=d.pathname}catch{return null}o=o.replace(/^\/+|\/+$/g,"").replace(/\.git$/i,"");const i=new URL(du(n));if(!["https:","http:"].includes(i.protocol)||i.username||i.password)return null;const l=i.pathname.replace(/^\/+|\/+$/g,"");l&&o.startsWith(`${l}/`)&&(o=o.slice(l.length+1));const c=o.split("/");return c.length<2||n.provider==="github"&&c.length!==2||c.some(d=>!/^[a-zA-Z0-9_.-]+$/.test(d)||[".","..","-"].includes(d))?null:(i.pathname=`/${l?`${l}/`:""}${o}`,i.search="",i.hash="",{provider:n.provider,url:i.toString()})},kc=(t,e)=>{const s=t.find(o=>o.name==="origin"),n=s?[s,...t.filter(o=>o!==s)]:t;for(const o of n){const a=Xa(o.fetchUrl,e)??Xa(o.pushUrl,e);if(a)return a}return null},In={layout:"data-diff-toolbar-more-layout",whitespace:"data-diff-toolbar-more-whitespace",wrap:"data-diff-toolbar-more-wrap",tree:"data-diff-toolbar-more-tree",walkthrough:"data-diff-toolbar-more-walkthrough"},Qa=[In.layout,In.whitespace,In.wrap,In.tree,In.walkthrough],Cc={steps:["data-diff-toolbar-compact-walkthrough","data-diff-toolbar-compact",...Qa],clippedText:".truncate",overflowSteps:Qa},Ic=(t,e)=>{const s=y.useRef(null),n=y.useRef(null),o=y.useRef(e);o.current=e,y.useLayoutEffect(()=>{const a=t.current;if(n.current?.container!==a&&(n.current?.release(),n.current=a?{container:a,release:f1(a,()=>o.current)}:null),!a)return;const i=`${a.childElementCount}\0${a.textContent??""}`,l=s.current;l?.container===a&&l.signature===i||(s.current={container:a,signature:i},Tc(a,o.current))}),y.useEffect(()=>()=>{n.current?.release(),n.current=null},[])},Lw=t=>Ic(t,Cc),u1=(t,e)=>{if(t.scrollWidth>t.clientWidth+1)return!1;if(!e)return!0;for(const s of t.querySelectorAll(e))if(s.scrollWidth>s.clientWidth+1)return!1;return!0},Tc=(t,{steps:e,clippedText:s,overflowSteps:n}=Cc)=>{for(const o of e)t.removeAttribute(o);for(const o of e){if(u1(t,n?.includes(o)?void 0:s))return;t.setAttribute(o,"")}},f1=(t,e)=>{let s=!1;const n=()=>{s||(s=!0,Tc(t,e()),s=!1)},o=globalThis.document?.fonts??null;o?.addEventListener("loadingdone",n);const a=new ResizeObserver(n);return a.observe(t),()=>{o?.removeEventListener("loadingdone",n),a.disconnect()}},p1={steps:["data-git-header-branch-shrinks","data-git-header-compact","data-git-header-tight"],clippedText:"[data-git-header-pickers]"},m1={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart",user:"user-3",fingerprint:"fingerprint",github:"github",gitlab:"gitlab"},h1={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)",success:"var(--status-success)",info:"var(--status-info)",warning:"var(--status-warning)"};function Rc(t){return t&&h1[t]||"var(--primary)"}const Za=t=>{const e=W.c(8),{icon:s,className:n,colorToken:o}=t,a=m1[s??"branch"]??"user-3";let i;e[0]!==o?(i=Rc(o),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==i?(l={color:i},e[2]=i,e[3]=l):l=e[3];let c;return e[4]!==n||e[5]!==a||e[6]!==l?(c=r.jsx(B,{name:a,className:n,style:l}),e[4]=n,e[5]=a,e[6]=l,e[7]=c):c=e[7],c},Ec=t=>{const e=W.c(56),{activeProfile:s,identities:n,onSelect:o,isApplying:a,iconOnly:i,attention:l,onConfigure:c,applicability:d,triggerClassName:u,menuAlign:f,onOpen:p}=t,g=i===void 0?!1:i,h=l===void 0?null:l,x=f===void 0?"end":f,{t:m}=se(),b=a||n.length===0;let v;e[0]!==p?(v=O=>{O&&p?.()},e[0]=p,e[1]=v):v=e[1];let w;e[2]!==u?(w=ne("min-w-0 max-w-[15rem] justify-start gap-1.5 px-2 py-1 typography-ui-label",u),e[2]=u,e[3]=w):w=e[3];const S=s?.color;let I;e[4]!==S?(I=Rc(S),e[4]=S,e[5]=I):I=e[5];let k;e[6]!==I?(k={color:I},e[6]=I,e[7]=k):k=e[7];let R;e[8]!==m?(R=m("gitView.header.identityTooltip"),e[8]=m,e[9]=R):R=e[9];let P;e[10]!==s?.color||e[11]!==s?.icon||e[12]!==a?(P=a?r.jsx(B,{name:"loader-4",className:"size-4 animate-spin"}):r.jsx(Za,{icon:s?.icon,colorToken:s?.color,className:"size-4"}),e[10]=s?.color,e[11]=s?.icon,e[12]=a,e[13]=P):P=e[13];let T;e[14]!==s||e[15]!==g||e[16]!==m?(T=!g&&r.jsx("span",{className:"git-identity-label min-w-0 flex-1 truncate text-start",children:s?Gr(s,m):m("gitView.header.noIdentity")}),e[14]=s,e[15]=g,e[16]=m,e[17]=T):T=e[17];let D;e[18]!==h?(D=h?r.jsx(B,{name:"close-circle",className:"size-3.5 shrink-0 text-[var(--status-error)]"}):null,e[18]=h,e[19]=D):D=e[19];let A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=r.jsx(B,{name:"arrow-down-s",className:"size-4 opacity-60"}),e[20]=A):A=e[20];let N;e[21]!==b||e[22]!==P||e[23]!==T||e[24]!==D||e[25]!==w||e[26]!==k||e[27]!==R?(N=r.jsx(As,{asChild:!0,children:r.jsx(Bt,{asChild:!0,children:r.jsxs(Q,{variant:"ghost",size:"sm",className:w,style:k,disabled:b,"aria-label":R,children:[P,T,D,A]})})}),e[21]=b,e[22]=P,e[23]=T,e[24]=D,e[25]=w,e[26]=k,e[27]=R,e[28]=N):N=e[28];let j;e[29]!==s||e[30]!==h||e[31]!==g||e[32]!==m?(j=h??(g&&s?Gr(s,m):m("gitView.header.identityTooltip")),e[29]=s,e[30]=h,e[31]=g,e[32]=m,e[33]=j):j=e[33];let _;e[34]!==j?(_=r.jsx(_s,{sideOffset:8,children:j}),e[34]=j,e[35]=_):_=e[35];let E;e[36]!==N||e[37]!==_?(E=r.jsxs(Ps,{children:[N,_]}),e[36]=N,e[37]=_,e[38]=E):E=e[38];let L;e[39]!==s?.id||e[40]!==d||e[41]!==n||e[42]!==o||e[43]!==m?(L=n.length===0?r.jsx("div",{className:"px-2 py-1.5",children:r.jsx("p",{className:"typography-meta text-muted-foreground",children:m("gitView.header.noProfiles")})}):n.map(O=>{const z=s?.id===O.id,G=d?.(O)??{applicable:!0};return r.jsx(lt,{disabled:!G.applicable,onSelect:()=>o(O),children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Za,{icon:O.icon,colorToken:O.color,className:"size-4"}),r.jsxs("span",{className:"flex min-w-0 flex-col",children:[r.jsx("span",{className:"typography-ui-label text-foreground",children:Gr(O,m)}),r.jsx("span",{className:"typography-meta text-muted-foreground",children:G.applicable?O.userEmail||m("gitView.identity.systemNoAuthor"):i1(G,m)})]}),z?r.jsx(B,{name:"check",className:"ms-auto size-4 text-foreground"}):null]})},O.id)}),e[39]=s?.id,e[40]=d,e[41]=n,e[42]=o,e[43]=m,e[44]=L):L=e[44];let $;e[45]!==c||e[46]!==m?($=c?r.jsxs(r.Fragment,{children:[r.jsx(Pn,{}),r.jsxs(lt,{onSelect:c,children:[r.jsx(B,{name:"settings-3",className:"size-4"}),m("gitView.context.configure")]})]}):null,e[45]=c,e[46]=m,e[47]=$):$=e[47];let M;e[48]!==x||e[49]!==L||e[50]!==$?(M=r.jsxs(Vt,{align:x,className:"w-64 overflow-y-auto",children:[L,$]}),e[48]=x,e[49]=L,e[50]=$,e[51]=M):M=e[51];let C;return e[52]!==E||e[53]!==M||e[54]!==v?(C=r.jsxs(Ut,{onOpenChange:v,children:[E,M]}),e[52]=E,e[53]=M,e[54]=v,e[55]=C):C=e[55],C},g1=t=>{const e=W.c(21),{comparison:s,trackingBranch:n,tooltipDelayMs:o}=t,a=o===void 0?1e3:o,{t:i}=se(),l=`${s.remote}/${s.branch}`,c=s.ahead===0&&s.behind===0;let d;e[0]!==i||e[1]!==l||e[2]!==n?(d=n?i("gitView.header.upstreamTooltipTracking",{target:l,tracking:n}):i("gitView.header.upstreamTooltip",{target:l}),e[0]=i,e[1]=l,e[2]=n,e[3]=d):d=e[3];const u=d;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=r.jsx(B,{name:"git-branch",className:"size-3.5 shrink-0"}),e[4]=f):f=e[4];let p;e[5]!==l?(p=r.jsx("span",{className:"min-w-0 truncate text-foreground/80",children:l}),e[5]=l,e[6]=p):p=e[6];let g;e[7]!==s.ahead||e[8]!==s.behind||e[9]!==c||e[10]!==i?(g=c?r.jsx("span",{className:"tabular-nums text-muted-foreground",children:i("gitView.header.upstreamSynced")}):r.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[s.ahead>0?r.jsxs("span",{className:"text-[var(--status-info)]",children:["↑",s.ahead]}):null,s.behind>0?r.jsxs("span",{className:"text-[var(--status-warning)]",children:["↓",s.behind]}):null]}),e[7]=s.ahead,e[8]=s.behind,e[9]=c,e[10]=i,e[11]=g):g=e[11];let h;e[12]!==p||e[13]!==g?(h=r.jsx(As,{asChild:!0,children:r.jsxs("div",{className:"inline-flex h-7 max-w-full items-center gap-1.5 rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2 typography-micro text-muted-foreground",children:[f,p,g]})}),e[12]=p,e[13]=g,e[14]=h):h=e[14];let x;e[15]!==u?(x=r.jsx(_s,{sideOffset:8,children:u}),e[15]=u,e[16]=x):x=e[16];let m;return e[17]!==h||e[18]!==x||e[19]!==a?(m=r.jsxs(Ps,{delayDuration:a,children:[h,x]}),e[17]=h,e[18]=x,e[19]=a,e[20]=m):m=e[20],m},$w=t=>{const e=W.c(124),{directory:s,status:n,localBranches:o,remoteBranches:a,branchInfo:i,syncAction:l,operationBlocked:c,remotes:d,onFetch:u,onPull:f,onSync:p,onPublish:g,onChooseSyncTargets:h,onRemoveRemote:x,removingRemoteName:m,onCheckoutBranch:b,onCreateBranch:v,onRenameBranch:w,activeIdentityProfile:S,availableIdentities:I,onSelectIdentity:k,isApplyingIdentity:R,identityAttention:P,identityApplicability:T,onConfigureRepository:D,onIdentityMenuOpen:A,isWorktreeMode:N,onOpenHistory:j,onOpenGraph:_,onOpenStashes:E,onOpenUpdateBranch:L,onOpenReintegrateCommits:$,pullRequest:M,pullRequestProvider:C,prChecks:O,onOpenPullRequest:z,repositoryOptions:G,selectedRepository:U,onSelectRepository:K,repositoryRoot:X}=t,re=c===void 0?!1:c,ee=P===void 0?null:P,xe=Uo(),{t:ce}=se(),{isMobile:he}=On(),ie=d1(s),pe=An(x1),le=y.useRef(null);if(Ic(le,p1),!n)return null;let de;e[0]!==G?(de=G??[],e[0]=G,e[1]=de):de=e[1];let te;e[2]!==de?(te=de.filter(Boolean),e[2]=de,e[3]=te):te=e[3];const J=te;let q,oe;if(e[4]!==pe||e[5]!==_||e[6]!==j||e[7]!==$||e[8]!==E||e[9]!==L||e[10]!==d||e[11]!==ce){const mt=kc(d,pe),Ve=!!(j||_||E||L||$);q="flex items-center gap-1 shrink-0",oe=Ve||mt?r.jsxs(Ut,{children:[r.jsxs(Ps,{children:[r.jsx(As,{asChild:!0,children:r.jsx(Bt,{asChild:!0,children:r.jsx(Q,{variant:"ghost",size:"sm",className:"w-7 px-0","aria-label":ce("gitView.header.repositoryViews"),children:r.jsx(B,{name:"more-fill",className:"size-4"})})})}),r.jsx(_s,{sideOffset:8,children:ce("gitView.header.repositoryViews")})]}),r.jsxs(Vt,{align:"end",children:[j?r.jsxs(lt,{onSelect:j,children:[r.jsx(B,{name:"history",className:"size-4"}),ce("gitView.history.title")]}):null,_?r.jsxs(lt,{onSelect:_,children:[r.jsx(B,{name:"git-branch",className:"size-4"}),ce("gitView.graph.title")]}):null,E?r.jsxs(lt,{onSelect:E,children:[r.jsx(B,{name:"archive-stack",className:"size-4"}),ce("gitView.stashes.title")]}):null,L?r.jsxs(lt,{onSelect:L,children:[r.jsx(B,{name:"git-merge",className:"size-4"}),ce("gitView.header.updateBranch")]}):null,$?r.jsxs(lt,{onSelect:$,children:[r.jsx(B,{name:"split-cells-horizontal",className:"size-4"}),ce("gitView.integrate.title")]}):null,mt?r.jsxs(r.Fragment,{children:[Ve?r.jsx(Pn,{}):null,r.jsxs(lt,{onSelect:()=>{Er(mt.url)},children:[r.jsx(B,{name:mt.provider==="gitlab"?"gitlab":"github",className:"size-4"}),ce("gitView.header.openRepository",{provider:uu(mt.provider)})]})]}):null]})]}):null,e[4]=pe,e[5]=_,e[6]=j,e[7]=$,e[8]=E,e[9]=L,e[10]=d,e[11]=ce,e[12]=q,e[13]=oe}else q=e[12],oe=e[13];let ue;e[14]!==q||e[15]!==oe?(ue=r.jsx("div",{className:q,children:oe}),e[14]=q,e[15]=oe,e[16]=ue):ue=e[16];const Ie=ue,Le=O?O.state==="success"?"var(--status-success)":O.state==="failure"?"var(--status-error)":"var(--status-warning)":null;let we;e[17]!==O?.state||e[18]!==M?(we=M?fu({state:M.state,draft:M.draft,checksState:O?.state,mergeable:M.mergeable,mergeableState:M.mergeableState}):null,e[17]=O?.state,e[18]=M,e[19]=we):we=e[19];const $e=we;let ke;e[20]!==z||e[21]!==Le||e[22]!==$e||e[23]!==M||e[24]!==C||e[25]!==ce?(ke=M&&z?r.jsxs(Ps,{children:[r.jsx(As,{asChild:!0,children:r.jsxs(Q,{variant:"ghost",size:"sm",onClick:z,className:"gap-1.5 px-2 typography-micro",children:[r.jsx(B,{name:"git-pull-request",className:"size-3.5",style:{color:`var(--pr-${$e})`}}),r.jsx("span",{className:"tabular-nums text-foreground/80",children:C==="gitlab"?rl("gitlab",M.number):ce("gitView.pr.numberLabel",{number:M.number})}),Le?r.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:Le}}):null]})}),r.jsx(_s,{sideOffset:8,children:ce(pu("gitView.header.openPullRequest",C))})]}):null,e[20]=z,e[21]=Le,e[22]=$e,e[23]=M,e[24]=C,e[25]=ce,e[26]=ke):ke=e[26];const Te=ke,ae=n.current,fe=!!n.tracking,ge=!n||re,Oe=n.ahead,Be=n.behind;let Xe;e[27]!==n.tracking?(Xe=n.tracking?.split("/")[0],e[27]=n.tracking,e[28]=Xe):Xe=e[28];const Ue=n.tracking;let Ye;e[29]!==n.files?(Ye=n1(n.files),e[29]=n.files,e[30]=Ye):Ye=e[30];let ze;e[31]!==ie||e[32]!==h||e[33]!==u||e[34]!==g||e[35]!==f||e[36]!==x||e[37]!==p||e[38]!==d||e[39]!==m||e[40]!==n.ahead||e[41]!==n.behind||e[42]!==n.current||e[43]!==n.tracking||e[44]!==l||e[45]!==fe||e[46]!==ge||e[47]!==Xe||e[48]!==Ye?(ze=r.jsx(Qg,{syncAction:l,remotes:d,onFetch:u,onPull:f,onSync:p,onPublish:g,onChooseSyncTargets:h,currentBranch:ae,hasTracking:fe,onRemoveRemote:x,removingRemoteName:m,disabled:ge,iconOnly:!0,aheadCount:Oe,behindCount:Be,trackingRemoteName:Xe,trackingBranch:Ue,hasUncommittedChanges:Ye,choosesPushDestination:ie}),e[31]=ie,e[32]=h,e[33]=u,e[34]=g,e[35]=f,e[36]=x,e[37]=p,e[38]=d,e[39]=m,e[40]=n.ahead,e[41]=n.behind,e[42]=n.current,e[43]=n.tracking,e[44]=l,e[45]=fe,e[46]=ge,e[47]=Xe,e[48]=Ye,e[49]=ze):ze=e[49];const Me=ze;let Pe;e[50]!==n.tracking||e[51]!==n.upstreamComparison?(Pe=n.upstreamComparison?r.jsx(g1,{comparison:n.upstreamComparison,trackingBranch:n.tracking,tooltipDelayMs:1e3}):null,e[50]=n.tracking,e[51]=n.upstreamComparison,e[52]=Pe):Pe=e[52];const Ge=Pe;let et;e[53]!==S||e[54]!==I||e[55]!==T||e[56]!==ee||e[57]!==R||e[58]!==D||e[59]!==A||e[60]!==k?(et=r.jsx(Ec,{iconOnly:!0,activeProfile:S,identities:I,onSelect:k,isApplying:R,attention:ee,onConfigure:D,onOpen:A,applicability:T}),e[53]=S,e[54]=I,e[55]=T,e[56]=ee,e[57]=R,e[58]=D,e[59]=A,e[60]=k,e[61]=et):et=e[61];const tt=et;let Ae;e[62]!==i||e[63]!==s||e[64]!==he||e[65]!==N||e[66]!==o||e[67]!==b||e[68]!==v||e[69]!==w||e[70]!==a||e[71]!==n.ahead||e[72]!==n.current||e[73]!==n.files?.length||e[74]!==ce?(Ae=N&&!he?r.jsx(Xg,{currentBranch:n.current,onRename:w}):r.jsx(Jg,{directory:s,currentBranch:n.current,localBranches:o,remoteBranches:a,branchInfo:i,currentBranchAhead:n.ahead,onCheckout:b,onCreate:v,switchBlockedNotice:(n.files?.length??0)>0?ce("gitView.branch.switchBlockedNotice"):null}),e[62]=i,e[63]=s,e[64]=he,e[65]=N,e[66]=o,e[67]=b,e[68]=v,e[69]=w,e[70]=a,e[71]=n.ahead,e[72]=n.current,e[73]=n.files?.length,e[74]=ce,e[75]=Ae):Ae=e[75];let Re;e[76]!==K||e[77]!==J||e[78]!==X||e[79]!==U?(Re=J.length>0&&K?r.jsx(o1,{repositories:J,selectedRepository:U??null,onSelectRepository:K,repositoryRoot:X}):null,e[76]=K,e[77]=J,e[78]=X,e[79]=U,e[80]=Re):Re=e[80];let at;e[81]!==Ae||e[82]!==Re?(at=r.jsxs("div",{"data-git-header-pickers":"",className:"flex min-w-0 flex-1 items-center gap-1",children:[Ae,Re]}),e[81]=Ae,e[82]=Re,e[83]=at):at=e[83];const Ne=at;if(xe){let mt;e[84]!==Me?(mt=r.jsx("div",{className:"shrink-0",children:Me}),e[84]=Me,e[85]=mt):mt=e[85];let Ve;e[86]!==Ne||e[87]!==Ie||e[88]!==mt?(Ve=r.jsx(zo,{children:r.jsxs("div",{ref:le,className:"flex min-w-0 flex-1 items-center gap-2 pe-1",children:[Ne,Ie,mt]})}),e[86]=Ne,e[87]=Ie,e[88]=mt,e[89]=Ve):Ve=e[89];let jt;e[90]!==tt?(jt=r.jsx("div",{className:"shrink-0",children:tt}),e[90]=tt,e[91]=jt):jt=e[91];let Ke;e[92]!==Te?(Ke=Te?r.jsx("div",{className:"shrink-0",children:Te}):null,e[92]=Te,e[93]=Ke):Ke=e[93];let ht;e[94]===Symbol.for("react.memo_cache_sentinel")?(ht=r.jsx("div",{className:"min-w-0 flex-1"}),e[94]=ht):ht=e[94];let Qe;e[95]!==Ge?(Qe=Ge?r.jsx("div",{className:"min-w-0 shrink",children:Ge}):null,e[95]=Ge,e[96]=Qe):Qe=e[96];let ut;e[97]!==jt||e[98]!==Ke||e[99]!==Qe?(ut=r.jsxs("header",{className:"flex h-10 min-w-0 items-center gap-2 px-3",children:[jt,Ke,ht,Qe]}),e[97]=jt,e[98]=Ke,e[99]=Qe,e[100]=ut):ut=e[100];let _t;return e[101]!==Ve||e[102]!==ut?(_t=r.jsxs(r.Fragment,{children:[Ve,ut]}),e[101]=Ve,e[102]=ut,e[103]=_t):_t=e[103],_t}let Fe;e[104]!==tt?(Fe=r.jsx("div",{className:"flex shrink-0 items-center gap-1",children:tt}),e[104]=tt,e[105]=Fe):Fe=e[105];let pt;e[106]!==Ne||e[107]!==Fe?(pt=r.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[Ne,Fe]}),e[106]=Ne,e[107]=Fe,e[108]=pt):pt=e[108];let rt;e[109]!==Te?(rt=Te?r.jsx("div",{className:"shrink-0",children:Te}):null,e[109]=Te,e[110]=rt):rt=e[110];let it;e[111]===Symbol.for("react.memo_cache_sentinel")?(it=r.jsx("div",{className:"min-w-0 flex-1"}),e[111]=it):it=e[111];let We;e[112]!==Ge?(We=Ge?r.jsx("div",{className:"min-w-0 shrink",children:Ge}):null,e[112]=Ge,e[113]=We):We=e[113];let Je;e[114]!==Me?(Je=r.jsx("div",{className:"shrink-0",children:Me}),e[114]=Me,e[115]=Je):Je=e[115];let Tt;e[116]!==Ie||e[117]!==rt||e[118]!==We||e[119]!==Je?(Tt=r.jsxs("div",{className:"mt-3 flex h-8 min-w-0 items-center gap-2",children:[rt,it,We,Ie,Je]}),e[116]=Ie,e[117]=rt,e[118]=We,e[119]=Je,e[120]=Tt):Tt=e[120];let St;return e[121]!==pt||e[122]!==Tt?(St=r.jsxs("header",{className:"@container/git-header px-3 py-2 bg-transparent",children:[pt,Tt]}),e[121]=pt,e[122]=Tt,e[123]=St):St=e[123],St};function x1(t){return t.identities}const Dc=()=>{const t=mu();return{displayMode:t,installed:t!=="browser",browserTab:t==="browser"}},Mw=()=>{const t=W.c(2),[e,s]=y.useState(b1);let n,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const a=[window.matchMedia("(display-mode: standalone)"),window.matchMedia("(display-mode: minimal-ui)"),window.matchMedia("(display-mode: fullscreen)"),window.matchMedia("(display-mode: window-controls-overlay)")],i=()=>{s(Dc())};i();for(const l of a)typeof l.addEventListener=="function"?l.addEventListener("change",i):typeof l.addListener=="function"&&l.addListener(i);return window.addEventListener("appinstalled",i),window.addEventListener("focus",i),()=>{for(const l of a)typeof l.removeEventListener=="function"?l.removeEventListener("change",i):typeof l.removeListener=="function"&&l.removeListener(i);window.removeEventListener("appinstalled",i),window.removeEventListener("focus",i)}},o=[],t[0]=n,t[1]=o):(n=t[0],o=t[1]),y.useEffect(n,o),e};function b1(){return Dc()}const Jo={start:"spaces.actions.start",stop:"spaces.actions.stop",restart_opencode:"spaces.actions.restartOpenCode",restart:"spaces.actions.restart",setup:"spaces.actions.setup",remove:"spaces.actions.remove"},Pc={start:"play",stop:"stop",restart_opencode:"refresh",restart:"restart",setup:"terminal-box",remove:"delete-bin"},Ac=(t,e)=>{e==="remove"?ct.getState().openDeleteDialog(t):_n(t,e)},_c=t=>{const e=W.c(15);let s;e[0]!==t?(s=u=>u.journey?.get(t),e[0]=t,e[1]=s):s=e[1];const n=ct(s);let o;e[2]!==t?(o=u=>u.actions.get(t)?.kind==="running",e[2]=t,e[3]=o):o=e[3];const a=ct(o);let i;e[4]!==n?(i=hu(n),e[4]=n,e[5]=i):i=e[5];let l;e[6]!==n?(l=ol(n),e[6]=n,e[7]=l):l=e[7];let c;e[8]!==n?(c=u=>gu(n,u),e[8]=n,e[9]=c):c=e[9];let d;return e[10]!==a||e[11]!==i||e[12]!==l||e[13]!==c?(d={actions:i,applicable:l,busy:a,unavailable:c},e[10]=a,e[11]=i,e[12]=l,e[13]=c,e[14]=d):d=e[14],d},Xo=t=>ct.getState().openApplyDialog(t),Ow=t=>{const e=W.c(33),{spaceId:s,label:n,className:o}=t,{t:a}=se(),{actions:i,applicable:l,busy:c,unavailable:d}=_c(s);if(i.length===0)return null;const u=o??"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";let f;e[0]!==n||e[1]!==a?(f=a("spaces.actions.menuAria",{label:n}),e[0]=n,e[1]=a,e[2]=f):f=e[2];let p;e[3]!==a?(p=a("spaces.actions.menu"),e[3]=a,e[4]=p):p=e[4];let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=r.jsx(B,{name:"more-2",className:"h-4 w-4"}),e[5]=g):g=e[5];let h;e[6]!==u||e[7]!==f||e[8]!==p?(h=r.jsx(Bt,{asChild:!0,children:r.jsx("button",{type:"button",onClick:v1,className:u,"aria-label":f,title:p,children:g})}),e[6]=u,e[7]=f,e[8]=p,e[9]=h):h=e[9];let x;e[10]!==l||e[11]!==c||e[12]!==s||e[13]!==a?(x=l?r.jsxs(r.Fragment,{children:[r.jsxs(lt,{disabled:c,onClick:()=>Xo(s),className:"gap-2",children:[r.jsx(B,{name:"git-merge",className:"h-4 w-4"}),a("spaces.actions.apply")]}),r.jsx(Pn,{})]}):null,e[10]=l,e[11]=c,e[12]=s,e[13]=a,e[14]=x):x=e[14];let m;if(e[15]!==i||e[16]!==c||e[17]!==s||e[18]!==a||e[19]!==d){let w;e[21]!==i.length||e[22]!==c||e[23]!==s||e[24]!==a||e[25]!==d?(w=S=>r.jsxs(y.Fragment,{children:[S==="remove"&&i.length>1?r.jsx(Pn,{}):null,r.jsxs(lt,{variant:S==="remove"?"destructive":"default",disabled:c||d(S),onClick:()=>Ac(s,S),className:"gap-2",children:[r.jsx(B,{name:Pc[S],className:"h-4 w-4"}),a(Jo[S])]})]},S),e[21]=i.length,e[22]=c,e[23]=s,e[24]=a,e[25]=d,e[26]=w):w=e[26],m=i.map(w),e[15]=i,e[16]=c,e[17]=s,e[18]=a,e[19]=d,e[20]=m}else m=e[20];let b;e[27]!==x||e[28]!==m?(b=r.jsxs(Vt,{align:"end",className:"min-w-[200px]",onClick:w1,children:[x,m]}),e[27]=x,e[28]=m,e[29]=b):b=e[29];let v;return e[30]!==h||e[31]!==b?(v=r.jsxs(Ut,{children:[h,b]}),e[30]=h,e[31]=b,e[32]=v):v=e[32],v},Fw=()=>{const t=W.c(23),{t:e}=se(),s=ct(S1);let n;t[0]!==s?(n=m=>s?m.journey?.get(s)?.name:void 0,t[0]=s,t[1]=n):n=t[1];const o=ct(n),{actions:a,applicable:i,busy:l,unavailable:c}=_c(s??""),d=j1,u=s!==null;let f;t[2]!==o||t[3]!==e?(f=o??e("spaces.actions.menu"),t[2]=o,t[3]=e,t[4]=f):f=t[4];let p;t[5]!==i||t[6]!==l||t[7]!==s||t[8]!==e?(p=s&&i?r.jsxs(Q,{variant:"ghost",className:"justify-start gap-2",disabled:l,onClick:()=>{d(),Xo(s)},children:[r.jsx(B,{name:"git-merge",className:"h-4 w-4"}),e("spaces.actions.apply")]}):null,t[5]=i,t[6]=l,t[7]=s,t[8]=e,t[9]=p):p=t[9];let g;t[10]!==a||t[11]!==l||t[12]!==s||t[13]!==e||t[14]!==c?(g=s?a.map(m=>r.jsxs(Q,{variant:m==="remove"?"destructive":"ghost",className:"justify-start gap-2",disabled:l||c(m),onClick:()=>{d(),Ac(s,m)},children:[r.jsx(B,{name:Pc[m],className:"h-4 w-4"}),e(Jo[m])]},m)):null,t[10]=a,t[11]=l,t[12]=s,t[13]=e,t[14]=c,t[15]=g):g=t[15];let h;t[16]!==p||t[17]!==g?(h=r.jsxs("div",{className:"flex flex-col gap-1 px-3 pb-4 pt-1",children:[p,g]}),t[16]=p,t[17]=g,t[18]=h):h=t[18];let x;return t[19]!==u||t[20]!==f||t[21]!==h?(x=r.jsx(Dr,{open:u,title:f,onClose:d,children:h}),t[19]=u,t[20]=f,t[21]=h,t[22]=x):x=t[22],x},y1=()=>{const t=W.c(5),{t:e}=se(),s=ct(N1),n=Ce(k1);let o,a;t[0]!==n||t[1]!==s||t[2]!==e?(o=()=>{if(s===null)return;ct.getState().noteChatsArchived(null);const i=e("spaces.archive.notice",{name:s});if(n){Y.success(i);return}Y.success(i,{action:{label:e("spaces.archive.noticeOpen"),onClick:C1}})},a=[n,s,e],t[0]=n,t[1]=s,t[2]=e,t[3]=o,t[4]=a):(o=t[3],a=t[4]),y.useEffect(o,a)},Bw=()=>{const t=W.c(60),{t:e}=se();y1();const s=Ce(I1),n=ct(T1),o=ct(R1);let a;t[0]!==n?(a=T=>n?T.journey?.get(n)?.name??"":"",t[0]=n,t[1]=a):a=t[1];const i=ct(a);let l;t[2]!==n?(l=T=>ol(n?T.journey?.get(n):void 0),t[2]=n,t[3]=l):l=t[3];const c=ct(l);let d;t[4]!==c||t[5]!==i||t[6]!==o?(d={name:i,unsaved:o,applicable:c},t[4]=c,t[5]=i,t[6]=o,t[7]=d):d=t[7];const[u,f]=y.useState(d);n!==null&&(u.name!==i||u.unsaved!==o||u.applicable!==c)&&f({name:i,unsaved:o,applicable:c});let p,g,h,x;if(t[8]!==c||t[9]!==u||t[10]!==i||t[11]!==n||t[12]!==e||t[13]!==o){const T=n!==null?{name:i,unsaved:o,applicable:c}:u;g=E1;let D;t[18]!==n||t[19]!==o?(D=()=>{n&&(g(),_n(n,"remove",{deleteUnsavedChats:o!==null}))},t[18]=n,t[19]=o,t[20]=D):D=t[20];const A=D;let N;t[21]!==n?(N=()=>{n&&(g(),Xo(n))},t[21]=n,t[22]=N):N=t[22];const j=N;x=e("spaces.delete.title",{name:T.name});const _=T.applicable?r.jsx(Q,{variant:"outline",size:"sm",className:"me-auto",onClick:j,children:e("spaces.delete.applyFirst")}):null;let E;t[23]!==e?(E=e("spaces.delete.cancel"),t[23]=e,t[24]=E):E=t[24];let L;t[25]!==E?(L=r.jsx(Q,{variant:"outline",size:"sm",onClick:g,children:E}),t[25]=E,t[26]=L):L=t[26];const $=T.unsaved?e("spaces.delete.deleteAnyway"):e("spaces.delete.confirm");let M;t[27]!==A||t[28]!==$?(M=r.jsx(Q,{variant:"destructive",size:"sm",onClick:A,children:$}),t[27]=A,t[28]=$,t[29]=M):M=t[29];let C;t[30]!==M||t[31]!==_||t[32]!==L?(C=r.jsxs("div",{className:"flex w-full justify-end gap-2",children:[_,L,M]}),t[30]=M,t[31]=_,t[32]=L,t[33]=C):C=t[33],p=C,h=T.unsaved?[...T.unsaved.failed>0||T.unsaved.tooLarge.length===0?[e("spaces.delete.chatsNotSaved",{name:T.name})]:[],...T.unsaved.tooLarge.map(O=>e("spaces.delete.chatTooLarge",{title:O}))]:[e("spaces.delete.body")],t[8]=c,t[9]=u,t[10]=i,t[11]=n,t[12]=e,t[13]=o,t[14]=p,t[15]=g,t[16]=h,t[17]=x}else p=t[14],g=t[15],h=t[16],x=t[17];const m=h;if(s){const T=n!==null;let D;t[34]!==m?(D=r.jsx("div",{className:"flex flex-col gap-1 px-3 pb-4 pt-1",children:m.map(D1)}),t[34]=m,t[35]=D):D=t[35];let A;return t[36]!==p||t[37]!==g||t[38]!==T||t[39]!==D||t[40]!==x?(A=r.jsx(Dr,{open:T,title:x,onClose:g,footer:p,children:D}),t[36]=p,t[37]=g,t[38]=T,t[39]=D,t[40]=x,t[41]=A):A=t[41],A}const b=n!==null;let v;t[42]!==g?(v=T=>{T||g()},t[42]=g,t[43]=v):v=t[43];let w;t[44]!==x?(w=r.jsx(us,{children:x}),t[44]=x,t[45]=w):w=t[45];let S;t[46]!==m?(S=r.jsx(Fn,{className:"flex flex-col gap-1",children:m.map(P1)}),t[46]=m,t[47]=S):S=t[47];let I;t[48]!==w||t[49]!==S?(I=r.jsxs(vs,{children:[w,S]}),t[48]=w,t[49]=S,t[50]=I):I=t[50];let k;t[51]!==p?(k=r.jsx(Gs,{children:p}),t[51]=p,t[52]=k):k=t[52];let R;t[53]!==I||t[54]!==k?(R=r.jsxs(ds,{className:"max-w-md",children:[I,k]}),t[53]=I,t[54]=k,t[55]=R):R=t[55];let P;return t[56]!==R||t[57]!==b||t[58]!==v?(P=r.jsx(cs,{open:b,onOpenChange:v,children:R}),t[56]=R,t[57]=b,t[58]=v,t[59]=P):P=t[59],P};function v1(t){return t.stopPropagation()}function w1(t){return t.stopPropagation()}function S1(t){return t.actionsSheet}function j1(){return ct.getState().closeActionsSheet()}function N1(t){return t.archivedNotice}function k1(t){return t.isMobile}function C1(){Ce.getState().setSettingsDialogOpen(!1),Ce.getState().setArchivePageOpen(!0)}function I1(t){return t.isMobile}function T1(t){return t.deleteDialog}function R1(t){return t.deleteUnsaved}function E1(){return ct.getState().closeDeleteDialog()}function D1(t,e){return r.jsx("p",{className:"typography-meta text-muted-foreground",children:t},e)}function P1(t,e){return r.jsx("span",{children:t},e)}const A1={checking_place:"spaces.group.step.checkingPlace",creating:"spaces.group.step.creating",downloading_image:"spaces.group.step.downloadingImage",preparing_tools:"spaces.group.step.preparingTools",setting_network:"spaces.group.step.settingNetwork",bringing_code:"spaces.group.step.bringingCode",giving_access:"spaces.group.step.givingAccess"},_1={start:"spaces.group.busy.start",stop:"spaces.group.busy.stop",restart_opencode:"spaces.group.busy.restartOpenCode",restart:"spaces.group.busy.restart",setup:"spaces.group.busy.setup",remove:"spaces.group.busy.remove"},L1={start:"spaces.group.actionFailed.start",stop:"spaces.group.actionFailed.stop",restart_opencode:"spaces.group.actionFailed.restartOpenCode",restart:"spaces.group.actionFailed.restart",setup:"spaces.group.actionFailed.setup",remove:"spaces.group.actionFailed.remove"},$1={container_gone:{text:"spaces.group.state.containerGone",tone:"warning",action:"remove"},gatekeeper_gone:{text:"spaces.group.state.gatekeeperGone",tone:"error",action:"remove"},stopped:{text:"spaces.group.state.stopped",tone:"muted",action:"start"},stopped_idle:{text:"spaces.group.state.stoppedIdle",tone:"muted",action:"start"},damaged:{text:"spaces.group.state.damaged",tone:"warning",action:"restart"},not_answering:{text:"spaces.group.state.notAnswering",tone:"warning",action:"restart"}},Yt=t=>{const e=W.c(8),{icon:s,tone:n,children:o}=t,a=n==="error"?"flex items-start gap-1.5 text-[var(--status-error)]":n==="warning"?"flex items-start gap-1.5 text-[var(--status-warning)]":"flex items-start gap-1.5 text-muted-foreground";let i;e[0]!==s?(i=s==="loader-4"?r.jsx(Ft,{className:"mt-px h-3 w-3 shrink-0"}):r.jsx(B,{name:s,className:"mt-px h-3 w-3 shrink-0"}),e[0]=s,e[1]=i):i=e[1];let l;e[2]!==o?(l=r.jsx("span",{className:"min-w-0 whitespace-normal break-words text-[11px] leading-tight",children:o}),e[2]=o,e[3]=l):l=e[3];let c;return e[4]!==a||e[5]!==i||e[6]!==l?(c=r.jsxs("span",{className:a,children:[i,l]}),e[4]=a,e[5]=i,e[6]=l,e[7]=c):c=e[7],c},ei=80,ti=t=>{const e=t.trim().split(`
|
|
3
3
|
`),s=e[0]??"";return s.length>ei||e.length>1?`${s.slice(0,ei)}…`:s},Lc="self-start rounded text-start opacity-80 hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",M1=t=>{const e=W.c(37),{spaceId:s,setup:n}=t,{t:o}=se();if(!n||n.state==="done"||n.state==="queued")return null;let a;e[0]!==s?(a=()=>{_n(s,"setup")},e[0]=s,e[1]=a):a=e[1];let i;e[2]!==o?(i=o("spaces.group.setup.runAgain"),e[2]=o,e[3]=i):i=e[3];let l;e[4]!==a||e[5]!==i?(l=r.jsx(Q,{variant:"outline",size:"xs",onClick:a,children:i}),e[4]=a,e[5]=i,e[6]=l):l=e[6];const c=l;if(n.state==="running"){const x=n.index+1;let m;e[7]!==n.command||e[8]!==n.total||e[9]!==o||e[10]!==x?(m=o("spaces.group.setup.running",{current:x,total:n.total,command:ti(n.command)}),e[7]=n.command,e[8]=n.total,e[9]=o,e[10]=x,e[11]=m):m=e[11];let b;return e[12]!==m?(b=r.jsx(Yt,{icon:"loader-4",tone:"muted",children:m}),e[12]=m,e[13]=b):b=e[13],b}if(n.state==="interrupted"){let x;e[14]!==o?(x=o("spaces.group.setup.interrupted"),e[14]=o,e[15]=x):x=e[15];let m;e[16]!==x?(m=r.jsx(Yt,{icon:"alert",tone:"warning",children:x}),e[16]=x,e[17]=m):m=e[17];let b;e[18]!==c?(b=r.jsx("div",{className:"flex flex-wrap gap-1",children:c}),e[18]=c,e[19]=b):b=e[19];let v;return e[20]!==m||e[21]!==b?(v=r.jsxs("div",{className:"flex flex-col gap-1",children:[m,b]}),e[20]=m,e[21]=b,e[22]=v):v=e[22],v}let d;e[23]!==o?(d=o("spaces.group.setup.output"),e[23]=o,e[24]=d):d=e[24];let u;e[25]!==s?(u=()=>ct.getState().openSetupOutputDialog(s),e[25]=s,e[26]=u):u=e[26];const f=n.timedOut?"spaces.group.setup.timedOut":"spaces.group.setup.failed";let p;e[27]!==n.command||e[28]!==o||e[29]!==f?(p=o(f,{command:ti(n.command)}),e[27]=n.command,e[28]=o,e[29]=f,e[30]=p):p=e[30];let g;e[31]!==p?(g=r.jsx(Yt,{icon:"alert",tone:"warning",children:p}),e[31]=p,e[32]=g):g=e[32];let h;return e[33]!==d||e[34]!==u||e[35]!==g?(h=r.jsx("button",{type:"button",className:Lc,title:d,onClick:u,children:g}),e[33]=d,e[34]=u,e[35]=g,e[36]=h):h=e[36],h},Vw=t=>{const e=W.c(135),{spaceId:s,className:n}=t,{t:o}=se();let a;e[0]!==s?(a=D=>D.journey?.get(s),e[0]=s,e[1]=a):a=e[1];const i=ct(a),l=Ot(O1);let c;e[2]!==l?(c=D=>l.find(A=>A.id===D)?.name??D,e[2]=l,e[3]=c):c=e[3];const d=c;let u;e[4]!==i?.name||e[5]!==s||e[6]!==o?(u=(D,A)=>r.jsx("button",{type:"button",className:Lc,title:o("spaces.group.access.give"),"aria-label":o("spaces.group.access.giveAria",{label:i?.name??""}),onClick:()=>ct.getState().openAccessDialog(s,D),children:r.jsx(Yt,{icon:"alert",tone:"warning",children:A})}),e[4]=i?.name,e[5]=s,e[6]=o,e[7]=u):u=e[7];const f=u;let p;e[8]!==s?(p=D=>D.spaces.get(s),e[8]=s,e[9]=p):p=e[9];const g=ct(p);let h;e[10]!==s?(h=D=>D.actions.get(s),e[10]=s,e[11]=h):h=e[11];const x=ct(h);let m,b,v;if(e[12]!==x||e[13]!==n||e[14]!==i||e[15]!==g||e[16]!==s||e[17]!==o){v=Symbol.for("react.early_return_sentinel");e:{b=xu(i,g,x);let D;if(e[21]!==s||e[22]!==o?(D=A=>r.jsx(Q,{variant:"outline",size:"xs",className:"self-start",onClick:()=>A==="remove"?ct.getState().openDeleteDialog(s):void _n(s,A),children:o(Jo[A])}),e[21]=s,e[22]=o,e[23]=D):D=e[23],m=D,i?.state==="preparing"&&i.step&&i.step!=="ready"&&i.step!=="failed"){const A=A1[i.step];let N;e[24]!==o||e[25]!==A?(N=o(A),e[24]=o,e[25]=A,e[26]=N):N=e[26];let j;e[27]!==N?(j=r.jsx(Yt,{icon:"loader-4",tone:"muted",children:N}),e[27]=N,e[28]=j):j=e[28];let _;e[29]!==n||e[30]!==j?(_=r.jsx("div",{className:n,children:j}),e[29]=n,e[30]=j,e[31]=_):_=e[31],v=_;break e}if(b?.kind==="busy"){const A=_1[b.action];let N;e[32]!==o||e[33]!==A?(N=o(A),e[32]=o,e[33]=A,e[34]=N):N=e[34];let j;e[35]!==N?(j=r.jsx(Yt,{icon:"loader-4",tone:"muted",children:N}),e[35]=N,e[36]=j):j=e[36];let _;e[37]!==n||e[38]!==j?(_=r.jsx("div",{className:n,children:j}),e[37]=n,e[38]=j,e[39]=_):_=e[39],v=_;break e}if(i?.state==="failed"){const A=x?.kind==="failed"?x.failure:null;let N;e[40]!==n?(N=ne("flex flex-col gap-1",n),e[40]=n,e[41]=N):N=e[41];let j;e[42]!==i.failure||e[43]!==o?(j=o("spaces.group.failed",{reason:i.failure?er(o,i.failure):o("spaces.group.failedNoReason")}),e[42]=i.failure,e[43]=o,e[44]=j):j=e[44];let _;e[45]!==j?(_=r.jsx(Yt,{icon:"error-warning",tone:"error",children:j}),e[45]=j,e[46]=_):_=e[46];let E;e[47]!==A||e[48]!==o?(E=A?r.jsx(Yt,{icon:"error-warning",tone:"error",children:o("spaces.group.removeFailed",{reason:er(o,A)})}):null,e[47]=A,e[48]=o,e[49]=E):E=e[49];let L;e[50]!==s?(L=()=>{_n(s,"remove")},e[50]=s,e[51]=L):L=e[51];let $;e[52]!==o?($=o("spaces.group.remove"),e[52]=o,e[53]=$):$=e[53];let M;e[54]!==L||e[55]!==$?(M=r.jsx(Q,{variant:"outline",size:"xs",className:"self-start",onClick:L,children:$}),e[54]=L,e[55]=$,e[56]=M):M=e[56];let C;e[57]!==_||e[58]!==E||e[59]!==M||e[60]!==N?(C=r.jsxs("div",{className:N,children:[_,E,M]}),e[57]=_,e[58]=E,e[59]=M,e[60]=N,e[61]=C):C=e[61],v=C;break e}if(b?.kind==="action_failed"&&b.action==="setup"&&(b.failure.code==="space_setup_no_commands"||b.failure.code==="space_setup_shared_skipped")){const A=b.failure.code==="space_setup_no_commands"?"spaces.group.setup.noCommands":"spaces.group.setup.sharedSkipped";let N;e[62]!==o||e[63]!==A?(N=o(A),e[62]=o,e[63]=A,e[64]=N):N=e[64];let j;e[65]!==N?(j=r.jsx(Yt,{icon:"alert",tone:"muted",children:N}),e[65]=N,e[66]=j):j=e[66];let _;e[67]!==n||e[68]!==j?(_=r.jsx("div",{className:n,children:j}),e[67]=n,e[68]=j,e[69]=_):_=e[69],v=_;break e}if(b?.kind==="action_failed"){let A;e[70]!==n?(A=ne("flex flex-col gap-1",n),e[70]=n,e[71]=A):A=e[71],v=r.jsxs("div",{className:A,children:[r.jsx(Yt,{icon:"error-warning",tone:"error",children:o(L1[b.action],{reason:er(o,b.failure)})}),m(b.action)]});break e}if(b?.kind==="unreachable"){let A;e[72]!==n?(A=ne("flex flex-col gap-1",n),e[72]=n,e[73]=A):A=e[73];const N=b.gone?o("spaces.group.state.machineRemoved"):b.machine===null?o("spaces.group.state.unreachable"):o("spaces.group.state.unreachableMachine",{machine:b.machine});let j;e[74]!==N?(j=r.jsx(Yt,{icon:"alert",tone:"warning",children:N}),e[74]=N,e[75]=j):j=e[75];const _=b.gone?m("remove"):null;let E;e[76]!==j||e[77]!==_||e[78]!==A?(E=r.jsxs("div",{className:A,children:[j,_]}),e[76]=j,e[77]=_,e[78]=A,e[79]=E):E=e[79],v=E;break e}}e[12]=x,e[13]=n,e[14]=i,e[15]=g,e[16]=s,e[17]=o,e[18]=m,e[19]=b,e[20]=v}else m=e[18],b=e[19],v=e[20];if(v!==Symbol.for("react.early_return_sentinel"))return v;if(b){const D=$1[b.kind];let A;e[80]!==n?(A=ne("flex flex-col gap-1",n),e[80]=n,e[81]=A):A=e[81];const N=D.tone==="muted"?"stop":D.tone==="error"?"error-warning":"alert",j=D.tone;let _;e[82]!==D.text||e[83]!==o?(_=o(D.text),e[82]=D.text,e[83]=o,e[84]=_):_=e[84];let E;e[85]!==D.tone||e[86]!==_||e[87]!==N?(E=r.jsx(Yt,{icon:N,tone:j,children:_}),e[85]=D.tone,e[86]=_,e[87]=N,e[88]=E):E=e[88];let L;e[89]!==m||e[90]!==D.action?(L=m(D.action),e[89]=m,e[90]=D.action,e[91]=L):L=e[91];let $;return e[92]!==E||e[93]!==L||e[94]!==A?($=r.jsxs("div",{className:A,children:[E,L]}),e[92]=E,e[93]=L,e[94]=A,e[95]=$):$=e[95],$}let w;if(e[96]!==i||e[97]!==f||e[98]!==d||e[99]!==o){e:{let D;e[101]!==i?.accessFailures?(D=i?.accessFailures??[],e[101]=i?.accessFailures,e[102]=D):D=e[102];const A=D;if(A.length>0){let j;if(e[103]!==A||e[104]!==f||e[105]!==d||e[106]!==o){let E;e[108]!==f||e[109]!==d||e[110]!==o?(E=L=>r.jsx(y.Fragment,{children:f(L.provider,o("spaces.group.accessMissing",{provider:d(L.provider),reason:er(o,L,{name:xa.get(L.provider)??d(L.provider)})}))},L.provider),e[108]=f,e[109]=d,e[110]=o,e[111]=E):E=e[111],j=A.map(E),e[103]=A,e[104]=f,e[105]=d,e[106]=o,e[107]=j}else j=e[107];let _;e[112]!==j?(_=r.jsx("div",{className:"flex flex-col gap-1",children:j}),e[112]=j,e[113]=_):_=e[113],w=_;break e}const N=al(i);if(N?.kind==="needs_again"){let j;e[114]!==i?.grants||e[115]!==f||e[116]!==d||e[117]!==o?(j=_=>r.jsx(y.Fragment,{children:f(_,tm(i?.grants??[],_)?.kind==="login"?o("spaces.group.access.loginNeedsAgain",{name:xa.get(_)??d(_)}):o("spaces.group.access.needsAgain",{provider:d(_)}))},_),e[114]=i?.grants,e[115]=f,e[116]=d,e[117]=o,e[118]=j):j=e[118],w=r.jsx("div",{className:"flex flex-col gap-1",children:N.providers.map(j)});break e}if(N?.kind==="no_model"){let j;e[119]!==f||e[120]!==o?(j=r.jsx("div",{className:"flex flex-col gap-1",children:f(null,o("spaces.group.access.noModel"))}),e[119]=f,e[120]=o,e[121]=j):j=e[121],w=j;break e}if(N?.kind==="unknown"){let j;e[122]!==o?(j=o("spaces.group.access.unknown"),e[122]=o,e[123]=j):j=e[123];let _;e[124]!==j?(_=r.jsx("div",{children:r.jsx(Yt,{icon:"alert",tone:"muted",children:j})}),e[124]=j,e[125]=_):_=e[125],w=_;break e}w=null}e[96]=i,e[97]=f,e[98]=d,e[99]=o,e[100]=w}else w=e[100];const S=w,I=i?.state==="running"?i.setup:null;let k;e[126]!==s||e[127]!==I?(k=r.jsx(M1,{spaceId:s,setup:I}),e[126]=s,e[127]=I,e[128]=k):k=e[128];const R=k;if(!S&&(!i?.setup||i.setup.state==="done"||i.setup.state==="queued"||i.state!=="running"))return null;let P;e[129]!==n?(P=ne("flex flex-col gap-1.5",n),e[129]=n,e[130]=P):P=e[130];let T;return e[131]!==S||e[132]!==R||e[133]!==P?(T=r.jsxs("div",{className:P,children:[R,S]}),e[131]=S,e[132]=R,e[133]=P,e[134]=T):T=e[134],T};function O1(t){return t.providers}const F1=t=>{const e=W.c(30),{item:s,settingsItem:n,onVisibleChange:o}=t,{t:a}=se();let i;e[0]!==s.id?(i={id:s.id},e[0]=s.id,e[1]=i):i=e[1];const{attributes:l,listeners:c,setNodeRef:d,setActivatorNodeRef:u,transform:f,transition:p,isDragging:g}=Hl(i);let h;e[2]!==f?(h=Yl.Translate.toString(f),e[2]=f,e[3]=h):h=e[3];let x;e[4]!==h||e[5]!==p?(x={transform:h,transition:p},e[4]=h,e[5]=p,e[6]=x):x=e[6];const m=g&&"z-10 opacity-60";let b;e[7]!==m?(b=ne("relative flex items-center gap-2",m),e[7]=m,e[8]=b):b=e[8];let v;e[9]!==s.label||e[10]!==a?(v=a("contextRail.configure.reorder",{label:s.label}),e[9]=s.label,e[10]=a,e[11]=v):v=e[11];let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=r.jsx(B,{name:"draggable",className:"size-4"}),e[12]=w):w=e[12];let S;e[13]!==l||e[14]!==c||e[15]!==u||e[16]!==v?(S=r.jsx(Q,{ref:u,variant:"ghost",size:"icon",...l,...c,"aria-label":v,className:"shrink-0 touch-none select-none cursor-grab text-muted-foreground hover:bg-transparent active:cursor-grabbing",children:w}),e[13]=l,e[14]=c,e[15]=u,e[16]=v,e[17]=S):S=e[17];let I;e[18]!==s.label||e[19]!==s.locked||e[20]!==s.visible||e[21]!==o||e[22]!==n?(I=r.jsx(yr,{settingsItem:n,checked:s.visible,onChange:o,disabled:s.locked,label:s.label,ariaLabel:s.label,className:"min-w-0 flex-1"}),e[18]=s.label,e[19]=s.locked,e[20]=s.visible,e[21]=o,e[22]=n,e[23]=I):I=e[23];let k;return e[24]!==d||e[25]!==x||e[26]!==b||e[27]!==S||e[28]!==I?(k=r.jsxs("div",{ref:d,style:x,className:b,children:[S,I]}),e[24]=d,e[25]=x,e[26]=b,e[27]=S,e[28]=I,e[29]=k):k=e[29],k},Uw=t=>{const e=W.c(50),{items:s,onVisibleChange:n,onReorder:o,settingsItemPrefix:a,dragInstructions:i,onDraggingChange:l}=t,{t:c}=se();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={activationConstraint:{distance:8}},e[0]=d):d=e[0];let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={activationConstraint:{delay:200,tolerance:6}},e[1]=u):u=e[1];let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f={coordinateGetter:zm},e[2]=f):f=e[2];const p=Ul(mr(Vm,d),mr(Bm,u),mr(Fm,f));let g;e[3]!==s||e[4]!==l||e[5]!==o?(g=L=>{const{active:$,over:M}=L;if(l?.(!1),!M||$.id===M.id)return;const C=s.findIndex(z=>z.id===$.id),O=s.findIndex(z=>z.id===M.id);C<0||O<0||o(Gl(s,C,O).map(B1))},e[3]=s,e[4]=l,e[5]=o,e[6]=g):g=e[6];const h=g;let x;e[7]!==s||e[8]!==c?(x=(L,$)=>{const M=$===void 0?L:$,C=s.find(O=>O.id===L);if(C)return c("contextRail.configure.position",{label:C.label,position:s.findIndex(O=>O.id===M)+1,count:s.length})},e[7]=s,e[8]=c,e[9]=x):x=e[9];const m=x;let b,v;e[10]!==m?(b=L=>{const{active:$}=L;return m($.id)},v=L=>{const{active:$,over:M}=L;return M?m($.id,M.id):void 0},e[10]=m,e[11]=b,e[12]=v):(b=e[11],v=e[12]);let w;e[13]!==m||e[14]!==c?(w=L=>{const{active:$,over:M}=L;return M?m($.id,M.id):c("contextRail.configure.dragCancelled")},e[13]=m,e[14]=c,e[15]=w):w=e[15];let S;e[16]!==c?(S=()=>c("contextRail.configure.dragCancelled"),e[16]=c,e[17]=S):S=e[17];let I;e[18]!==b||e[19]!==v||e[20]!==w||e[21]!==S?(I={onDragStart:b,onDragOver:v,onDragEnd:w,onDragCancel:S},e[18]=b,e[19]=v,e[20]=w,e[21]=S,e[22]=I):I=e[22];const k=I;let R;e[23]!==i?(R={draggable:i},e[23]=i,e[24]=R):R=e[24];let P;e[25]!==k||e[26]!==R?(P={screenReaderInstructions:R,announcements:k},e[25]=k,e[26]=R,e[27]=P):P=e[27];const T=P;let D,A;e[28]!==l?(D=()=>l?.(!0),A=()=>l?.(!1),e[28]=l,e[29]=D,e[30]=A):(D=e[29],A=e[30]);let N;if(e[31]!==s||e[32]!==n||e[33]!==a){let L;e[35]!==n||e[36]!==a?(L=$=>r.jsx(F1,{item:$,settingsItem:`${a}${$.id}`,onVisibleChange:M=>n($.id,M)},$.id),e[35]=n,e[36]=a,e[37]=L):L=e[37],N=s.map(L),e[31]=s,e[32]=n,e[33]=a,e[34]=N}else N=e[34];let j;e[38]!==N?(j=r.jsx("div",{className:"flex flex-col",children:N}),e[38]=N,e[39]=j):j=e[39];let _;e[40]!==s||e[41]!==j?(_=r.jsx(Wl,{items:s,strategy:ql,children:j}),e[40]=s,e[41]=j,e[42]=_):_=e[42];let E;return e[43]!==T||e[44]!==h||e[45]!==p||e[46]!==D||e[47]!==A||e[48]!==_?(E=r.jsx(zl,{sensors:p,collisionDetection:Kl,onDragStart:D,onDragCancel:A,onDragEnd:h,accessibility:T,children:_}),e[43]=T,e[44]=h,e[45]=p,e[46]=D,e[47]=A,e[48]=_,e[49]=E):E=e[49],E};function B1(t){return t.id}const V1=()=>Ce.getState().isolatedSpacesEnabled,U1=[{slug:"home",title:"Settings",group:"general",kind:"single",description:"Search and jump to common pages.",keywords:["search","settings"]},{slug:"general",title:"General",group:"general",kind:"single",keywords:["general","startup","launch at login","autostart","tray","password","passkey","security","privacy","telemetry","transport","network","lan","binary","cli"]},{slug:"projects",title:"Projects",group:"projects",kind:"split",keywords:["project","projects","worktree","worktrees","repo","repository","directory"]},{slug:"remote-instances",title:"Remote Instances",group:"projects",kind:"single",keywords:["ssh","remote","instances","tunnels","forwarding","connection"],isAvailable:t=>!t.isVSCode},{slug:"providers",title:"Providers",group:"opencode",kind:"single",keywords:["provider","providers","models","model","api key","api keys","openai","anthropic","ollama","credentials"]},{slug:"web-search",title:"Web search",group:"opencode",kind:"single",keywords:["web search","websearch","search","internet","exa","tavily","firecrawl","parallel","tinyfish"]},{slug:"usage",title:"Usage",group:"general",kind:"split",keywords:["quota","billing","tokens","usage","limits"]},{slug:"agents",title:"Agents",group:"opencode",kind:"split",keywords:["agent","agents","prompts","tools","permissions"]},{slug:"behavior",title:"Behavior",group:"opencode",kind:"single",keywords:["behavior","agents.md","system prompt","global rules","instructions","override"]},{slug:"commands",title:"Commands",group:"opencode",kind:"split",keywords:["command","commands","slash","macros","automation"]},{slug:"mcp",title:"MCP",group:"opencode",kind:"single",keywords:["mcp","model context protocol","servers","tools","remote","stdio"]},{slug:"plugins",title:"Plugins",group:"opencode",kind:"single",keywords:["plugin","plugins","addons","npm","opencode-wakatime"]},{slug:"skills.installed",title:"Skills",group:"content",kind:"split",keywords:["skill","skills","instructions","install","catalog"]},{slug:"skills.catalog",title:"Skills Catalog",group:"content",kind:"single",keywords:["install","catalog","external","repository","skills catalog"]},{slug:"git",title:"Git",group:"projects",kind:"single",keywords:["git","github","gitlab","identity","identities","ssh","profiles","credentials","keys","commit","gitmoji","oauth","prs","issues"],isAvailable:t=>!t.isVSCode},{slug:"appearance",title:"Appearance",group:"general",kind:"single",keywords:["theme","font","spacing","padding","corner radius","radius","input bar","keyboard","viewport","mobile","terminal","pwa","install name","app shortcuts"]},{slug:"chat",title:"Chat",group:"general",kind:"single",keywords:["tools","diff","reasoning","dotfiles","draft","queue","output","copy","image","split messages","message actions"]},{slug:"shortcuts",title:"Shortcuts",group:"general",kind:"single",keywords:["keyboard","hotkeys","shortcuts","bindings"],isAvailable:t=>!t.isVSCode},{slug:"sessions",title:"Sessions",group:"general",kind:"single",keywords:["defaults","default agent","default model","retention","memory","limits","zen"]},{slug:"routing",title:"Routing",group:"general",kind:"single",description:"Pick the right model for each message automatically, and get asked before risky actions in auto-accepted sessions.",keywords:["routing","auto","jev","typesafe","model routing","categories","safety net","auto-accept","fallback"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{slug:"magic-prompts",title:"Magic Prompts",group:"content",kind:"split",keywords:["prompts","templates","git","github","review","commit","pull request"],isAvailable:t=>!t.isVSCode},{slug:"snippets",title:"Snippets",group:"content",kind:"split",keywords:["prompt","templates","multi-run","strategy","approach"]},{slug:"notifications",title:"Notifications",group:"general",kind:"single",keywords:["alerts","native","summary","summarization"]},{slug:"voice",title:"Voice",group:"general",kind:"single",keywords:["tts","speech","voice"],isAvailable:t=>!t.isVSCode},{slug:"tunnel",title:"External Tunnel",group:"projects",kind:"single",keywords:["tunnel","external","cloudflare","qr","remote","mobile","share"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{slug:"isolated-spaces",title:"Isolated spaces",group:"projects",kind:"single",keywords:["isolated","space","spaces","container","docker","colima","sandbox","disk","clean up","image"],isAvailable:t=>!t.isVSCode&&V1()},{slug:"about",title:"About",group:"general",kind:"single",keywords:["about","version","updates","release","changelog"],isAvailable:t=>t.isMobile&&!t.isVSCode},{slug:"integrations",title:"Integrations",group:"general",kind:"single",keywords:["integration","connect","oauth","github","linear","extension","claude","plugin"],isAvailable:t=>!t.isVSCode},{slug:"extensions",title:"Extensions",group:"general",kind:"single",keywords:["extension","extensions","guest","panel","rail","folder","zip","git","url"],isAvailable:t=>!t.isVSCode&&!t.isMobile}],z1={sessions:"sessions",agents:"agents",commands:"commands",mcp:"mcp",skills:"skills.installed",providers:"providers",usage:"usage","git-identities":"git",settings:"home"};function K1(t){const e=t.trim().toLowerCase();return U1.find(s=>s.slug===e)??null}function G1(t){const e=(t??"").trim().toLowerCase();if(!e)return"home";const s=z1[e];if(s)return s;const n=K1(e);return n?n.slug:"home"}function zw(t){switch(t){case"general":return"settings-3";case"projects":return"folders";case"remote-instances":return"computer";case"appearance":return"palette";case"chat":return"chat-ai-3";case"magic-prompts":return"ai-generate-2";case"snippets":return"chat-thread";case"notifications":return"notification-3";case"shortcuts":return"command";case"sessions":return"chat-history";case"routing":return"signpost";case"providers":return"cloud";case"web-search":return"global";case"agents":return"ai-agent";case"behavior":return"brain";case"commands":return"slash-commands-2";case"mcp":return null;case"plugins":return"plug-2";case"skills.installed":return"book-open";case"skills.catalog":return"book";case"git":return"git-branch";case"integrations":return"plug";case"extensions":return"puzzle";case"usage":return"bar-chart-2";case"voice":return"mic";case"tunnel":return"home-office";case"isolated-spaces":return"box-3";case"about":return"information";case"home":return null;default:return"robot-2"}}const Ir=t=>Ct(_e.getState().getWorktreeMetadata(t.id)?.projectDirectory??t.directory);function $c(){const t=W.c(7),e=ls(W1),s=bu();let n,o;if(t[0]!==e||t[1]!==s){n=new Map;for(const i of e)n.set(i.id,i);for(const i of s)n.set(i.id,i);o=yu(n.values(),Ir),t[0]=e,t[1]=s,t[2]=n,t[3]=o}else n=t[2],o=t[3];let a;return t[4]!==n||t[5]!==o?(a={index:o,sessionById:n},t[4]=n,t[5]=o,t[6]=a):a=t[6],a}function W1(t){return t.activeSessions}const ko=t=>!t.time?.archived&&!t.parentID;function Kw(t){const e=W.c(2);let s;return e[0]!==t?(s=n=>{if(!t)return null;let o=null,a=0;for(const i of n.activeSessions){if(!ko(i))continue;const l=mo(i,Ir(i));l?.key===t&&(a=a+1,o=l.title??o??l.groupSlug)}return a>=2?o:null},e[0]=t,e[1]=s):s=e[1],ls(s)}function Gw(t){const e=W.c(4);let s;e[0]!==t?(s=a=>{if(!t)return"";const i=a.activeSessions.find(d=>d.id===t),l=i&&ko(i)?mo(i,Ir(i))?.key:void 0;if(!l)return"";const c=a.activeSessions.filter(d=>ko(d)&&mo(d,Ir(d))?.key===l).map(q1);return c.length>=2?c.join(`
|
|
4
4
|
`):""},e[0]=t,e[1]=s):s=e[1];const n=ls(s);let o;return e[2]!==n?(o=n?n.split(`
|
|
5
5
|
`):[],e[2]=n,e[3]=o):o=e[3],o}function q1(t){return t.id}function Ww(t){const e=W.c(6),{index:s,sessionById:n}=$c();let o;e[0]!==s||e[1]!==t?(o=t?s.runs.get(t)??null:null,e[0]=s,e[1]=t,e[2]=o):o=e[2];let a;return e[3]!==n||e[4]!==o?(a={run:o,sessionById:n},e[3]=n,e[4]=o,e[5]=a):a=e[5],a}class Mc extends Error{constructor(){super("No assistant outputs to fuse"),this.name="NoFusionOutputsError"}}const H1=.1,Y1=12,J1=t=>t.length>0&&t.every(e=>e.hasWorktree)&&t.some(e=>(e.diff?.files??0)>0)?"code":"answers",X1=(t,e)=>e!==void 0&&e>0&&t*Y1<=e*H1,Q1=(t,e)=>{const s=e>1?` · ${il(t.runGroup)}`:"",n=t.index&&t.index>1?` #${t.index}`:"";return`${t.providerID}/${t.modelID}${n}${s}`};async function Z1(t,e,s,n){return(await Promise.all(e.map(async a=>{const i=s.get(a);if(!i)throw new Error("Fusion source membership changed");const l=await At.getSession(a,i.directory);n();const c=await Du(l,t);n();const d=Pu(l,c?.project.path??l.directory);if(!d||d.key!==t.key||d.role!=="run")throw new Error("Fusion source membership changed");const u=await Au(a,l.directory);return n(),u?{session:l,identity:d,label:Q1(d,t.variants.length),reply:u,location:c}:null}))).filter(a=>a!==null)}async function ex(t,e){const s=new Map;for(const o of t){const a=il(o.identity.runGroup);s.has(a)||s.set(a,o)}const n=new Map;for(const[o,a]of s){const i=await _u(a.session.id,a.session.directory);e(),i?.text&&n.set(o,i.text)}return n}const si=t=>Array.from(t,([e,s])=>t.size>1?`
|
|
@@ -62,7 +62,7 @@ ${e.map(n=>dy(n,s)).join(`
|
|
|
62
62
|
`).trim();return{title:n,rest:o}},Ty=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),od=(t,e=new Date)=>{const s=new Date(t),n=Oi();return Ty(s,e)?s.toLocaleTimeString(n,{hour:"numeric",minute:"2-digit"}):s.toLocaleDateString(n,s.getFullYear()===e.getFullYear()?{month:"short",day:"numeric"}:{year:"numeric",month:"short",day:"numeric"})},Ry=400,Ey=y.lazy(()=>Es(()=>import("./NoteEditor-CTAjn_F2.js"),__vite__mapDeps([116,20,21,45,46,47,48,49,50,51,52,53,54,55,66,59,67,64,65,58,62,63,56,57])).then(t=>({default:t.NoteEditor}))),Dy=180,Py=4,Ci="linear-gradient(to bottom, black 55%, transparent)",Ay={maskImage:Ci,WebkitMaskImage:Ci},ad=t=>{const e=W.c(21),{note:s,pinned:n}=t,{t:o}=se();let a;e[0]!==s.source||e[1]!==o?(a=s.source==="selection"?o("rightSidebar.contextNotesTodo.notes.source.selection"):s.source==="agent"?o("rightSidebar.contextNotesTodo.notes.source.agent"):null,e[0]=s.source,e[1]=o,e[2]=a):a=e[2];const i=a,l=s.origin;let c;e[3]!==l||e[4]!==i||e[5]!==o?(c=i&&l?r.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),Mo(l.sessionId,l.messageId??null)},className:"text-muted-foreground/80 underline decoration-dotted underline-offset-2 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",title:o("rightSidebar.contextNotesTodo.notes.source.open"),children:i}):i?r.jsx("span",{children:i}):null,e[3]=l,e[4]=i,e[5]=o,e[6]=c):c=e[6];let d;e[7]!==i?(d=i?r.jsx("span",{"aria-hidden":"true",children:"·"}):null,e[7]=i,e[8]=d):d=e[8];const u=s.updatedAt||s.createdAt;let f;e[9]!==u?(f=od(u),e[9]=u,e[10]=f):f=e[10];let p;e[11]!==f?(p=r.jsx("span",{children:f}),e[11]=f,e[12]=p):p=e[12];let g;e[13]!==n||e[14]!==o?(g=n?r.jsxs(r.Fragment,{children:[r.jsx("span",{"aria-hidden":"true",children:"·"}),r.jsx("span",{className:"text-primary",children:o("rightSidebar.contextNotesTodo.pin.attached")})]}):null,e[13]=n,e[14]=o,e[15]=g):g=e[15];let h;return e[16]!==c||e[17]!==d||e[18]!==p||e[19]!==g?(h=r.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1.5 typography-micro text-muted-foreground",children:[c,d,p,g]}),e[16]=c,e[17]=d,e[18]=p,e[19]=g,e[20]=h):h=e[20],h},_y=t=>{const e=W.c(35),{note:s,pinned:n,onOpen:o,onTogglePinned:a,onDelete:i,selected:l}=t,{t:c}=se();let d;e[0]!==s.body?(d=Iy(s.body),e[0]=s.body,e[1]=d):d=e[1];const{title:u,rest:f}=d;let p;e[2]!==f?(p=f.length>Dy||f.split(`
|
|
63
63
|
`).length>Py,e[2]=f,e[3]=p):p=e[3];const g=p,h=s.id;let x;e[4]!==c||e[5]!==u?(x=u||c("rightSidebar.contextNotesTodo.notes.actions.expand"),e[4]=c,e[5]=u,e[6]=x):x=e[6];let m;e[7]!==u?(m=r.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",dir:"auto",title:u,children:u}),e[7]=u,e[8]=m):m=e[8];let b;e[9]!==a||e[10]!==n?(b=r.jsx(na,{pinned:n,onToggle:a}),e[9]=a,e[10]=n,e[11]=b):b=e[11];let v;e[12]!==c?(v=c("rightSidebar.contextNotesTodo.notes.actions.delete"),e[12]=c,e[13]=v):v=e[13];let w;e[14]!==i||e[15]!==v?(w=r.jsx(Sn,{items:[{id:"delete",label:v,destructive:!0,onSelect:i}]}),e[14]=i,e[15]=v,e[16]=w):w=e[16];let S;e[17]!==b||e[18]!==w?(S=r.jsxs(r.Fragment,{children:[b,w]}),e[17]=b,e[18]=w,e[19]=S):S=e[19];let I;e[20]!==s||e[21]!==n?(I=r.jsx(ad,{note:s,pinned:n}),e[20]=s,e[21]=n,e[22]=I):I=e[22];let k;e[23]!==g||e[24]!==f?(k=f?r.jsx("div",{className:"max-h-[4.5lh] overflow-hidden typography-meta text-muted-foreground",style:g?Ay:void 0,onClick:My,children:r.jsx(lo,{content:f,className:"typography-meta",enableFileReferences:!1})}):null,e[23]=g,e[24]=f,e[25]=k):k=e[25];let R;return e[26]!==s.id||e[27]!==o||e[28]!==l||e[29]!==I||e[30]!==k||e[31]!==x||e[32]!==m||e[33]!==S?(R=r.jsx(ed,{selected:l,entryId:h,onOpen:o,label:x,header:m,actions:S,footer:I,children:k}),e[26]=s.id,e[27]=o,e[28]=l,e[29]=I,e[30]=k,e[31]=x,e[32]=m,e[33]=S,e[34]=R):R=e[34],R},Ly=({note:t,pinned:e,onSaveBody:s,onTogglePinned:n,onDelete:o,onClose:a,showBack:i})=>{const{t:l}=se(),[c,d]=y.useState(t.body),u=y.useRef(t.body),f=y.useRef(null),p=y.useCallback(()=>{f.current!==null&&(window.clearTimeout(f.current),f.current=null)},[]);y.useEffect(()=>{t.body!==u.current&&c===u.current&&(u.current=t.body,d(t.body))},[c,t.body]),y.useEffect(()=>{if(c!==u.current)return f.current=window.setTimeout(()=>{f.current=null,c.trim()&&(u.current=c,s(t.id,c))},Ry),p},[p,c,t.id,s]);const g=y.useRef(()=>{});return g.current=()=>{if(p(),c!==u.current){if(!c.trim()){d(u.current);return}u.current=c,s(t.id,c)}},y.useEffect(()=>()=>g.current(),[]),r.jsx(sd,{showBack:i,backLabel:l("rightSidebar.contextNotesTodo.notes.actions.back"),onClose:a,meta:r.jsx(ad,{note:t,pinned:e}),actions:r.jsxs(r.Fragment,{children:[r.jsx(na,{alwaysVisible:!0,pinned:e,onToggle:n}),r.jsx(Sn,{alwaysVisible:!0,items:[{id:"delete",label:l("rightSidebar.contextNotesTodo.notes.actions.delete"),destructive:!0,onSelect:o}]})]}),children:r.jsx(y.Suspense,{fallback:null,children:r.jsx(Ey,{value:c,onChange:d,onBlur:()=>g.current(),ariaLabel:l("rightSidebar.contextNotesTodo.notes.editorLabel"),maxLength:Nl})})})},$y=t=>{const e=W.c(76),{projectRef:s,notes:n,disabled:o,query:a,pinnedNoteIds:i,onTogglePinned:l,openNoteId:c,onOpenNote:d,split:u}=t,{t:f}=se(),p=Pt(Oy),g=Pt(Fy),h=Pt(By),x=$r();let m;if(e[0]!==n||e[1]!==x||e[2]!==s||e[3]!==a){let K;e[5]!==x||e[6]!==s||e[7]!==a?(K=X=>!x.has(Ro(s,X.id))&&bs([X.body],a),e[5]=x,e[6]=s,e[7]=a,e[8]=K):K=e[8],m=n.filter(K),e[0]=n,e[1]=x,e[2]=s,e[3]=a,e[4]=m}else m=e[4];const b=m;let v;e[9]!==n||e[10]!==c?(v=c?n.find(K=>K.id===c)??null:null,e[9]=n,e[10]=c,e[11]=v):v=e[11];const w=v;let S,I;e[12]!==d||e[13]!==w||e[14]!==c?(S=()=>{c&&!w&&d(null)},I=[d,w,c],e[12]=d,e[13]=w,e[14]=c,e[15]=S,e[16]=I):(S=e[15],I=e[16]),y.useEffect(S,I);let k;e[17]!==s?(k=K=>{const X=Pt.getState().getEntry(s).error;Y.error(K,X?{description:X}:void 0)},e[17]=s,e[18]=k):k=e[18];const R=k;let P;e[19]!==p||e[20]!==s||e[21]!==R||e[22]!==f?(P=async K=>await p(s,{body:K})?!0:(R(f("rightSidebar.contextNotesTodo.toast.createNoteFailed")),!1),e[19]=p,e[20]=s,e[21]=R,e[22]=f,e[23]=P):P=e[23];const T=P;let D;e[24]!==h||e[25]!==d||e[26]!==c||e[27]!==s||e[28]!==R||e[29]!==f?(D=K=>{c===K&&d(null),oa({key:Ro(s,K),message:f("rightSidebar.contextNotesTodo.deleted.note"),undoLabel:f("rightSidebar.contextNotesTodo.undo"),run:()=>h(s,K),onFailure:()=>R(f("rightSidebar.contextNotesTodo.toast.deleteNoteFailed"))})},e[24]=h,e[25]=d,e[26]=c,e[27]=s,e[28]=R,e[29]=f,e[30]=D):D=e[30];const A=D;let N;e[31]!==l||e[32]!==R||e[33]!==f?(N=async(K,X)=>{await l(K,X)||R(f("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))},e[31]=l,e[32]=R,e[33]=f,e[34]=N):N=e[34];const j=N;let _;e[35]!==s||e[36]!==R||e[37]!==g||e[38]!==f?(_=(K,X)=>{g(s,K,X).then(re=>{re||R(f("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[35]=s,e[36]=R,e[37]=g,e[38]=f,e[39]=_):_=e[39];const E=_;let L;e[40]!==A||e[41]!==E||e[42]!==j||e[43]!==d||e[44]!==w||e[45]!==i||e[46]!==u?(L=w?r.jsx(Ly,{note:w,pinned:i.has(w.id),onSaveBody:E,onTogglePinned:()=>{j(w.id,!i.has(w.id))},onDelete:()=>A(w.id),showBack:!u,onClose:()=>d(null)},w.id):null,e[40]=A,e[41]=E,e[42]=j,e[43]=d,e[44]=w,e[45]=i,e[46]=u,e[47]=L):L=e[47];const $=L;let M;e[48]!==f?(M=f("rightSidebar.contextNotesTodo.notes.placeholder"),e[48]=f,e[49]=M):M=e[49];let C;e[50]!==f?(C=f("rightSidebar.contextNotesTodo.notes.addAria"),e[50]=f,e[51]=C):C=e[51];let O;e[52]!==o||e[53]!==T||e[54]!==M||e[55]!==C?(O=r.jsx(aa,{multiline:!0,placeholder:M,addLabel:C,maxLength:Nl,disabled:o,onSubmit:T}),e[52]=o,e[53]=T,e[54]=M,e[55]=C,e[56]=O):O=e[56];let z;e[57]!==A||e[58]!==j||e[59]!==d||e[60]!==c||e[61]!==i||e[62]!==a||e[63]!==u||e[64]!==f||e[65]!==b?(z=b.length===0?a.trim()?r.jsx("p",{className:"px-1 typography-meta text-muted-foreground",children:f("rightSidebar.contextNotesTodo.search.noResults",{query:a.trim()})}):null:r.jsx("ul",{className:"flex flex-col gap-1.5",children:b.map(K=>r.jsx(_y,{selected:u&&K.id===c,note:K,pinned:i.has(K.id),onOpen:()=>d(K.id),onTogglePinned:()=>{j(K.id,!i.has(K.id))},onDelete:()=>A(K.id)},K.id))}),e[57]=A,e[58]=j,e[59]=d,e[60]=c,e[61]=i,e[62]=a,e[63]=u,e[64]=f,e[65]=b,e[66]=z):z=e[66];let G;e[67]!==O||e[68]!==z?(G=r.jsxs("div",{className:"space-y-2",children:[O,z]}),e[67]=O,e[68]=z,e[69]=G):G=e[69];const U=G;if(u){let K;e[70]!==f?(K=f("rightSidebar.contextNotesTodo.notes.selectHint"),e[70]=f,e[71]=K):K=e[71];let X;return e[72]!==U||e[73]!==$||e[74]!==K?(X=r.jsx(sa,{list:U,detail:$,emptyLabel:K}),e[72]=U,e[73]=$,e[74]=K,e[75]=X):X=e[75],X}return $??U};function My(t){t.target instanceof Element&&t.target.closest("a")&&t.stopPropagation()}function Oy(t){return t.createNote}function Fy(t){return t.saveNoteBody}function By(t){return t.deleteNote}const Vy=1e4,Uy=t=>{const e=W.c(11),{progress:s}=t,{t:n}=se();if(s.done>=s.total){let l;e[0]!==n?(l=n("rightSidebar.contextNotesTodo.plans.progress.done"),e[0]=n,e[1]=l):l=e[1];let c;return e[2]!==l?(c=r.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-success)] bg-[var(--status-success)]/15",children:l}),e[2]=l,e[3]=c):c=e[3],c}let o;e[4]!==s.done||e[5]!==s.total||e[6]!==n?(o=n("rightSidebar.contextNotesTodo.plans.progress.title",{done:s.done,total:s.total}),e[4]=s.done,e[5]=s.total,e[6]=n,e[7]=o):o=e[7];const a=`${s.done}/${s.total}`;let i;return e[8]!==o||e[9]!==a?(i=r.jsx("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",title:o,children:a}),e[8]=o,e[9]=a,e[10]=i):i=e[10],i},zy=({projectRef:t,plans:e,query:s,onOpenPlan:n,pinnedPlanIds:o,onTogglePinned:a,selectedPlanId:i})=>{const{t:l}=se(),c=y.useRef(null),[d,u]=y.useState(!1),f=Pt(N=>N.createPlan),p=Pt(N=>N.deletePlan),g=Pt(N=>N.movePlan),[h,x]=y.useState(null),m=$r(),b=Pt(N=>N.load);y.useEffect(()=>{const N=window.setInterval(()=>{document.visibilityState==="visible"&&b(t,{force:!0})},Vy);return()=>window.clearInterval(N)},[b,t]);const v=y.useCallback(async N=>{if(h)return;const j=N.source==="shared"?"unshare":"share";x(N.id);try{if(!await g(t,N.id,j)){const E=Pt.getState().getEntry(t).error;Y.error(l("rightSidebar.contextNotesTodo.toast.movePlanFailed"),E?{description:E}:void 0)}}finally{x(null)}},[g,h,t,l]),w=y.useCallback(N=>{oa({key:Eo(t,N),message:l("rightSidebar.contextNotesTodo.deleted.plan"),undoLabel:l("rightSidebar.contextNotesTodo.undo"),run:()=>p(t,N),onFailure:()=>Y.error(l("rightSidebar.contextNotesTodo.toast.deletePlanFailed"))})},[t,p,l]),S=y.useCallback(async(N,j)=>{if(!N.trim()){Y.error(l("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const _=Wf(N,j||l("rightSidebar.contextNotesTodo.plan.defaultTitle"));if(!await f(t,{title:_.title,body:_.body})){Y.error(l("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}Y.success(l("rightSidebar.contextNotesTodo.toast.planImported"))},[f,t,l]),I=y.useCallback(async()=>{if(d)return;const N=await um({defaultPath:t.path,filters:[{name:"Plan files",extensions:["md","markdown","txt"]},{name:"All files",extensions:["*"]}]});if(N.success&&N.path){u(!0);try{const j=new URLSearchParams({path:N.path,allowOutsideWorkspace:"true"});N.outsideFileGrant&&j.set("outsideFileGrant",N.outsideFileGrant);const _=await wt(`/api/fs/read?${j.toString()}`,{cache:"no-store"});if(!_.ok){Y.error(l("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"));return}const E=await _.text(),L=N.path.split("/").pop()?.replace(/\.(md|markdown|txt)$/i,"").trim()||"";await S(E,L)}catch(j){const _=j instanceof Error?j.message:void 0;Y.error(l("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),_?{description:_}:void 0)}finally{u(!1)}return}N.error==="Native file picker not available"&&c.current?.click()},[S,d,t.path,l]),k=y.useCallback(async N=>{if(N){u(!0);try{const j=await N.text(),_=N.name.replace(/\.(md|markdown|txt)$/i,"").trim();await S(j,_)}catch(j){const _=j instanceof Error?j.message:void 0;Y.error(l("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),_?{description:_}:void 0)}finally{u(!1)}}},[S,l]),R=y.useCallback(async(N,j)=>{if(!await a(N,j)){const E=Pt.getState().getEntry(t).error;Y.error(l("rightSidebar.contextNotesTodo.toast.updatePlanFailed"),E?{description:E}:void 0)}},[a,t,l]),P=y.useMemo(()=>e.filter(N=>!m.has(Eo(t,N.id))&&bs([N.title],s)),[m,e,t,s]),T=y.useCallback(N=>n({id:N.id,title:N.title,projectRef:t}),[n,t]),D=y.useRef(ys(t));y.useEffect(()=>(D.current=ys(t),()=>{D.current=null}),[t]);const A=y.useCallback(async N=>{const j=ys(t),_=await f(t,{title:N,body:""});if(!_){const E=Pt.getState().getEntry(t).error;return Y.error(l("rightSidebar.contextNotesTodo.toast.createPlanFailed"),E?{description:E}:void 0),!1}return D.current===j&&T(_),!0},[f,T,t,l]);return r.jsxs("div",{className:"space-y-2",children:[r.jsx("input",{ref:c,type:"file",accept:".md,.markdown,.txt,text/markdown,text/plain",className:"hidden",onChange:N=>{const j=N.target.files?.[0]??null;k(j),N.currentTarget.value=""}}),r.jsx(aa,{placeholder:l("rightSidebar.contextNotesTodo.plans.newPlaceholder"),addLabel:l("rightSidebar.contextNotesTodo.plans.create"),maxLength:qf,dictation:!1,onSubmit:A,extraActions:r.jsx("button",{type:"button",onClick:I,disabled:d,className:Ls,"aria-label":l("rightSidebar.contextNotesTodo.plans.importFromFile"),title:l("rightSidebar.contextNotesTodo.plans.importFromFile"),children:r.jsx(B,{name:"upload-2",className:"h-3.5 w-3.5"})})}),r.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:P.length===0?r.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:s.trim()?l("rightSidebar.contextNotesTodo.search.noResults",{query:s.trim()}):l("rightSidebar.contextNotesTodo.plans.empty")}):r.jsx("ul",{className:"divide-y divide-border/50",children:P.map(N=>{const j=o.has(N.id),_=N.source==="shared",E=N.session?.sessionId;return r.jsxs("li",{"data-knowledge-entry-id":N.id,"aria-current":N.id===i?"true":void 0,className:ne("group/knowledge flex items-center gap-1 py-1 pe-1.5 ps-1",N.id===i&&"bg-interactive-selection/40"),children:[r.jsxs("button",{type:"button",onClick:()=>T(N),className:"flex min-w-0 flex-1 items-center gap-2 rounded-md px-1.5 py-1 text-start text-foreground/85 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[r.jsx("span",{className:"min-w-0 truncate typography-ui-label",dir:"auto",children:N.title}),_?r.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:l("rightSidebar.contextNotesTodo.plans.sharedBadge")}):null,N.progress?r.jsx(Uy,{progress:N.progress}):null,r.jsx("span",{className:"ms-auto flex-shrink-0 typography-micro text-muted-foreground",children:od(N.createdAt)})]}),E?r.jsx("button",{type:"button",onClick:()=>{Mo(E,null)},className:Ls,"aria-label":l("rightSidebar.contextNotesTodo.plans.session.open"),title:l("rightSidebar.contextNotesTodo.plans.session.open"),children:r.jsx(B,{name:"chat-3",className:"h-3.5 w-3.5"})}):null,r.jsx(na,{pinned:j,onToggle:()=>{R(N.id,!j)}}),r.jsx(Sn,{disabled:h===N.id,items:[{id:"move",label:l(_?"rightSidebar.contextNotesTodo.plans.menu.makePersonal":"rightSidebar.contextNotesTodo.plans.menu.share"),hint:l(_?"rightSidebar.contextNotesTodo.plans.makePersonal":"rightSidebar.contextNotesTodo.plans.share"),onSelect:()=>{v(N)}},{id:"delete",label:l("rightSidebar.contextNotesTodo.plans.deletePlan"),destructive:!0,onSelect:()=>w(N.id)}]})]},N.id)})})})]})},Ky=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`todo_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,Gy=t=>[...t.filter(e=>!e.completed),...t.filter(e=>e.completed)],Ii=(t,e)=>{const s=t.findIndex(n=>n.completed);return s===-1?[...t,e]:[...t.slice(0,s),e,...t.slice(s)]},Wy=t=>{const e=W.c(20),{id:s,children:n}=t;let o;e[0]!==s?(o={id:s},e[0]=s,e[1]=o):o=e[1];const{attributes:a,listeners:i,setNodeRef:l,setActivatorNodeRef:c,transform:d,transition:u,isDragging:f}=Hl(o);let p;e[2]!==d?(p=Yl.Transform.toString(d),e[2]=d,e[3]=p):p=e[3];let g;e[4]!==p||e[5]!==u?(g={transform:p,transition:u},e[4]=p,e[5]=u,e[6]=g):g=e[6];const h=f&&"opacity-60";let x;e[7]!==h?(x=ne(h),e[7]=h,e[8]=x):x=e[8];let m;e[9]!==a||e[10]!==n||e[11]!==f||e[12]!==i||e[13]!==c?(m=n({attributes:a,listeners:i,setActivatorNodeRef:c,isDragging:f}),e[9]=a,e[10]=n,e[11]=f,e[12]=i,e[13]=c,e[14]=m):m=e[14];let b;return e[15]!==l||e[16]!==g||e[17]!==x||e[18]!==m?(b=r.jsx("li",{ref:l,style:g,className:x,children:m}),e[15]=l,e[16]=g,e[17]=x,e[18]=m,e[19]=b):b=e[19],b},qy=t=>{const e=W.c(55),{todos:s,query:n,disabled:o,canCreateWorktree:a,sendingTodoId:i,onPersistTodos:l,onSendToCurrentSession:c,onSendToNewSession:d,onSendToNewWorktreeSession:u}=t,{t:f}=se(),[p,g]=y.useState(Hy),h=ta();let x;e[0]!==l||e[1]!==s?(x=G=>{const U=Ky(),K=G.slice(0,ja);return l(Ii(s,{id:U,text:K,completed:!1,createdAt:Date.now()}),{kind:"create",id:U,text:K}),!0},e[0]=l,e[1]=s,e[2]=x):x=e[2];const m=x;let b;e[3]===Symbol.for("react.memo_cache_sentinel")?(b=G=>{g(U=>{const K=new Set(U);return K.has(G)?K.delete(G):K.add(G),K})},e[3]=b):b=e[3];const v=b;let w;e[4]!==l||e[5]!==s?(w=(G,U)=>{const K=s.find(ee=>ee.id===G);if(!K||K.completed===U)return;const X=s.filter(ee=>ee.id!==G),re={...K,completed:U};l(U?[...X,re]:Ii(X,re),{kind:"complete",id:G,completed:U})},e[4]=l,e[5]=s,e[6]=w):w=e[6];const S=w;let I;e[7]!==l||e[8]!==s?(I=G=>{l(s.filter(U=>U.id!==G),{kind:"delete",id:G})},e[7]=l,e[8]=s,e[9]=I):I=e[9];const k=I;let R;e[10]!==l||e[11]!==s?(R=()=>{const G=s.filter(Yy);G.length!==s.length&&l(G)},e[10]=l,e[11]=s,e[12]=R):R=e[12];const P=R;let T;e[13]!==l||e[14]!==s?(T=G=>{const{active:U,over:K}=G;if(!K||U.id===K.id)return;const X=s.findIndex(ee=>ee.id===U.id),re=s.findIndex(ee=>ee.id===K.id);X===-1||re===-1||l(Gy(Gl(s,X,re)))},e[13]=l,e[14]=s,e[15]=T):T=e[15];const D=T;let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A={activationConstraint:{distance:8}},e[16]=A):A=e[16];const N=Ul(mr(Um,A)),j=s.reduce(Jy,0);let _;if(e[17]!==n||e[18]!==s){let G;e[20]!==n?(G=U=>bs([U.text],n),e[20]=n,e[21]=G):G=e[21],_=s.filter(G),e[17]=n,e[18]=s,e[19]=_}else _=e[19];const E=_;let L;e[22]!==f?(L=f("rightSidebar.contextNotesTodo.todo.inputPlaceholder"),e[22]=f,e[23]=L):L=e[23];let $;e[24]!==f?($=f("rightSidebar.contextNotesTodo.todo.addAria"),e[24]=f,e[25]=$):$=e[25];let M;e[26]!==o||e[27]!==m||e[28]!==$||e[29]!==L?(M=r.jsx(aa,{placeholder:L,addLabel:$,maxLength:ja,disabled:o,onSubmit:m}),e[26]=o,e[27]=m,e[28]=$,e[29]=L,e[30]=M):M=e[30];let C;e[31]!==a||e[32]!==p||e[33]!==k||e[34]!==D||e[35]!==S||e[36]!==c||e[37]!==d||e[38]!==u||e[39]!==n||e[40]!==h||e[41]!==i||e[42]!==f||e[43]!==N||e[44]!==E?(C=r.jsx("div",{className:"rounded-lg border border-border/60 bg-background/40",children:E.length===0?r.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:n.trim()?f("rightSidebar.contextNotesTodo.search.noResults",{query:n.trim()}):f("rightSidebar.contextNotesTodo.todo.empty")}):r.jsx(zl,{sensors:N,collisionDetection:Kl,onDragEnd:D,children:r.jsx(Wl,{items:E.map(Xy),strategy:ql,children:r.jsx("ul",{className:"divide-y divide-border/50",children:E.map(G=>{const U=p.has(G.id);return r.jsx(Wy,{id:G.id,children:K=>r.jsxs("div",{className:ne("group/knowledge flex gap-1.5 px-2.5 py-1.5",U?"items-start":"items-center"),children:[r.jsx("button",{type:"button",ref:K.setActivatorNodeRef,...K.attributes,...K.listeners,onClick:Qy,className:ne("flex h-6 w-4 flex-shrink-0 touch-none items-center justify-center text-muted-foreground hover:text-foreground",h),"aria-label":f("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:G.text}),title:f("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:G.text}),children:r.jsx(B,{name:"draggable",className:"h-3.5 w-3.5"})}),r.jsx("div",{className:"flex h-6 items-center",children:r.jsx(zi,{checked:G.completed,onChange:X=>S(G.id,X),ariaLabel:f("rightSidebar.contextNotesTodo.todo.actions.markComplete",{text:G.text})})}),r.jsx("button",{type:"button",onClick:()=>v(G.id),className:ne("block min-h-6 min-w-0 flex-1 bg-transparent p-0 text-start typography-ui-label leading-normal text-foreground",U?"whitespace-normal break-words":"overflow-hidden text-ellipsis whitespace-nowrap","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",G.completed&&"text-muted-foreground line-through"),title:U?void 0:G.text,"aria-label":U?f("rightSidebar.contextNotesTodo.todo.actions.collapse",{text:G.text}):f("rightSidebar.contextNotesTodo.todo.actions.expand",{text:G.text}),children:G.text}),r.jsxs("div",{className:"-me-1 flex h-6 items-center gap-0.5",children:[r.jsxs(Ut,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx("button",{type:"button",disabled:i===G.id,className:ne(Ls,h),"aria-label":f("rightSidebar.contextNotesTodo.todo.actions.send",{text:G.text}),title:f("rightSidebar.contextNotesTodo.todo.actions.send",{text:G.text}),children:r.jsx(B,{name:"send-plane",className:"h-3.5 w-3.5"})})}),r.jsxs(Vt,{align:"end",className:"w-56",children:[r.jsx(lt,{onClick:()=>c(G.text),children:f("rightSidebar.contextNotesTodo.todo.sendMenu.currentSession")}),r.jsx(lt,{onClick:()=>d(G.id,G.text),children:f("rightSidebar.contextNotesTodo.todo.sendMenu.newSession")}),r.jsx(lt,{onClick:()=>u(G.id,G.text),disabled:!a,children:f("rightSidebar.contextNotesTodo.todo.sendMenu.newWorktreeSession")})]})]}),r.jsx(Sn,{items:[{id:"delete",label:f("rightSidebar.contextNotesTodo.todo.menu.delete"),destructive:!0,onSelect:()=>k(G.id)}]})]})]})},G.id)})})})})}),e[31]=a,e[32]=p,e[33]=k,e[34]=D,e[35]=S,e[36]=c,e[37]=d,e[38]=u,e[39]=n,e[40]=h,e[41]=i,e[42]=f,e[43]=N,e[44]=E,e[45]=C):C=e[45];let O;e[46]!==j||e[47]!==o||e[48]!==P||e[49]!==f?(O=j>0?r.jsx("button",{type:"button",onClick:P,disabled:o,className:"px-1 typography-meta text-muted-foreground/80 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:f("rightSidebar.contextNotesTodo.todo.clearCompleted")}):null,e[46]=j,e[47]=o,e[48]=P,e[49]=f,e[50]=O):O=e[50];let z;return e[51]!==M||e[52]!==C||e[53]!==O?(z=r.jsxs("div",{className:"space-y-2",children:[M,C,O]}),e[51]=M,e[52]=C,e[53]=O,e[54]=z):z=e[54],z};function Hy(){return new Set}function Yy(t){return!t.completed}function Jy(t,e){return t+(e.completed?1:0)}function Xy(t){return t.id}function Qy(t){t.preventDefault(),t.stopPropagation()}const Zy=t=>{const{projectRef:e,canCreateWorktree:s,onActionComplete:n}=t,{t:o}=se(),[a,i]=y.useState(null),[l,c]=y.useState(!1),[d,u]=y.useState(null),f=_e(P=>P.currentSessionId),p=_e(P=>P.createSession),g=_e(P=>P.initializeNewOpenChamberSession),h=_e(P=>P.sendMessage),x=_e(P=>P.setCurrentSession),m=Hf(P=>P.setPendingInputText),b=Ce(P=>P.setSessionSwitcherOpen),v=y.useCallback(()=>{b(!1)},[b]),w=y.useCallback(P=>{if(!f){Y.error(o("rightSidebar.contextNotesTodo.toast.noActiveSession"));return}v();const T=`\`\`\`md
|
|
64
64
|
${P}
|
|
65
|
-
\`\`\``;m(T,"append"),Y.success(o("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),n?.()},[f,n,v,m,o]),S=y.useCallback((P,T)=>{!e||d||i({kind:"session",todoId:P,todoText:T})},[e,d]),I=y.useCallback((P,T)=>{if(!(!e||d)){if(!s){Y.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}i({kind:"worktree",todoId:P,todoText:T})}},[s,e,d,o]),k=y.useCallback(async P=>{if(!e||!a)return;const T=await Vs("plan.todo.visible",{todo_text:a.todoText}),A=[{synthetic:!0,text:await Vs("plan.todo.instructions",{todo_text:a.todoText})}];c(!0),u(a.todoId);try{v();let N=null,j=e.path;if(a.kind==="worktree"){if(!s){Y.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const E=await Yf(e.path,Jf());if(!E?.id)return;N=E.id,j=E.directory}else{const E=await p(void 0,e.path,void 0,{model:{providerID:P.providerID,id:P.modelID,variant:P.variant||void 0},agent:P.agent.trim()||void 0});if(!E?.id){Y.error(o("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}N=E.id,j=E.directory??e.path,g(E.id,Ot.getState().agents??[])}if(!N)return;const _=Xf.getState();_.saveSessionModelSelection(N,P.providerID,P.modelID),P.agent.trim()&&(_.saveSessionAgentSelection(N,P.agent),_.saveAgentModelForSession(N,P.agent,P.providerID,P.modelID),_.saveAgentModelVariantForSession(N,P.agent,P.providerID,P.modelID,P.variant||void 0)),x(N,j),await h(T,P.providerID,P.modelID,P.agent.trim()||void 0,void 0,void 0,A,P.variant||void 0),Y.success(a.kind==="worktree"?o("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):o("rightSidebar.contextNotesTodo.toast.sentToNewSession")),i(null),n?.()}catch(N){const j=N instanceof Error?N.message:void 0;Y.error(o("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),j?{description:j}:void 0)}finally{c(!1),u(null)}},[s,p,g,n,a,e,v,h,x,o]),R=y.useCallback(()=>{l||i(null)},[l]);return{pendingSendTarget:a,isSubmitting:l,sendingTodoId:d,sendToCurrentSession:w,sendToNewSession:S,sendToNewWorktreeSession:I,confirmSend:k,closeDialog:R}},e2=t=>{const e=W.c(26),{query:s,onQueryChange:n,placeholder:o,nothingFound:a,focusRequest:i,onClose:l}=t,{t:c}=se(),d=y.useRef(null);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current?.focus(),d.current?.select()},e[0]=u):u=e[0];let f;e[1]!==i?(f=[i],e[1]=i,e[2]=f):f=e[2],y.useEffect(u,f);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(B,{name:"search",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e[3]=p):p=e[3];let g;e[4]!==n?(g=I=>n(I.target.value),e[4]=n,e[5]=g):g=e[5];let h;e[6]!==l?(h=I=>{I.key==="Escape"&&!I.nativeEvent.isComposing&&(I.preventDefault(),l())},e[6]=l,e[7]=h):h=e[7];let x;e[8]!==o||e[9]!==s||e[10]!==g||e[11]!==h?(x=r.jsx("input",{ref:d,value:s,onChange:g,onKeyDown:h,placeholder:o,"aria-label":o,className:"h-7 w-48 min-w-0 bg-transparent typography-meta text-foreground outline-none placeholder:text-muted-foreground"}),e[8]=o,e[9]=s,e[10]=g,e[11]=h,e[12]=x):x=e[12];let m;e[13]!==a||e[14]!==c?(m=a?r.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",role:"status","aria-live":"polite",children:c("chat.search.noResults")}):null,e[13]=a,e[14]=c,e[15]=m):m=e[15];let b;e[16]!==c?(b=c("chat.search.close"),e[16]=c,e[17]=b):b=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(B,{name:"close",className:"h-4 w-4"}),e[18]=v):v=e[18];let w;e[19]!==l||e[20]!==b?(w=r.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:l,"aria-label":b,children:v}),e[19]=l,e[20]=b,e[21]=w):w=e[21];let S;return e[22]!==w||e[23]!==x||e[24]!==m?(S=r.jsxs("div",{role:"search",className:"pointer-events-auto flex items-center gap-1 rounded-lg border border-border bg-[var(--surface-elevated)] py-1 ps-2.5 pe-1 shadow-md",children:[p,x,m,w]}),e[22]=w,e[23]=x,e[24]=m,e[25]=S):S=e[25],S},t2=y.lazy(()=>Es(()=>import("./PlanView-dx70wKWR.js"),__vite__mapDeps([117,20,21,118,46,47,48,49,50,51,45,52,53,54,55,119,120,121,19,22,23,2,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,122,123])).then(t=>({default:t.PlanView}))),Ti=["notes","todos","plans","memory"],s2=900,n2=t=>[...t.filter(e=>!e.completed),...t.filter(e=>e.completed)],r2=t=>{const e=W.c(273),{projectRef:s,visible:n,projectLabel:o,canCreateWorktree:a,onActionComplete:i,onOpenPlan:l,className:c}=t,d=n===void 0?!0:n,u=a===void 0?!1:a,f=Uo(),{t:p}=se();let g;e[0]!==s?(g=ys(s),e[0]=s,e[1]=g):g=e[1];const h=g;let x;e[2]!==h?(x=Z=>(h?Z.entries[h]:void 0)??Qf,e[2]=h,e[3]=x):x=e[3];const m=Pt(x),b=Pt(o2),v=_e(a2),w=_e(i2),S=_e(l2),I=_e(c2);let k;e[4]===Symbol.for("react.memo_cache_sentinel")?(k={notes:[],plans:[]},e[4]=k):k=e[4];const[R,P]=y.useState(k);let T,D;e[5]!==w||e[6]!==v||e[7]!==S.open||e[8]!==S.projectContextPins?(T=()=>{if(S.open){P(S.projectContextPins??{notes:[],plans:[]});return}let Z=!1;return Zf(w,v).then(De=>{Z||P({notes:De.notes.map(d2),plans:De.plans.map(u2)})}),()=>{Z=!0}},D=[w,v,S.open,S.projectContextPins],e[5]=w,e[6]=v,e[7]=S.open,e[8]=S.projectContextPins,e[9]=T,e[10]=D):(T=e[9],D=e[10]),y.useEffect(T,D);let A;e[11]!==w||e[12]!==v||e[13]!==S.open||e[14]!==I?(A=async(Z,De,bt)=>{if(S.open)return I(Z,De,bt),!0;if(!v||!w)return!1;const es=await ep(w,v,Z,De,bt);return es?(P(es),!0):!1},e[11]=w,e[12]=v,e[13]=S.open,e[14]=I,e[15]=A):A=e[15];const N=A;let j;e[16]!==R.notes?(j=new Set(R.notes),e[16]=R.notes,e[17]=j):j=e[17];const _=j;let E;e[18]!==R.plans?(E=new Set(R.plans),e[18]=R.plans,e[19]=E):E=e[19];const L=E,$=Ce(f2),M=Dt(p2),C=$&&!M,O=Dt(m2);let z;e[20]!==s?.path?(z=Z=>jl(Z,s?.path??null),e[20]=s?.path,e[21]=z):z=e[21];const G=Dt(z),U=Ce(h2),[K,X]=y.useState(null),[re,ee]=y.useState(0);let xe,ce;e[22]!==K?(xe=()=>{const Z=K;if(!Z)return;ee(Z.getBoundingClientRect().width);const De=new ResizeObserver(bt=>{const es=bt[bt.length-1];es&&ee(es.contentRect.width)});return De.observe(Z),()=>De.disconnect()},ce=[K],e[22]=K,e[23]=xe,e[24]=ce):(xe=e[23],ce=e[24]),y.useLayoutEffect(xe,ce);const he=!U&&re>=s2,ie=Ce(g2),pe=Ce(x2);let le;e[25]!==ie?(le=Ti.includes(ie)?ie:"notes",e[25]=ie,e[26]=le):le=e[26];const de=le,te=de==="memory"&&!C?"notes":de,J=he&&te!=="todos",[q,oe]=y.useState(""),[ue,Ie]=y.useState(!1),[Le,we]=y.useState(0);let $e;e[27]===Symbol.for("react.memo_cache_sentinel")?($e=()=>{Ie(!1),oe("")},e[27]=$e):$e=e[27];const ke=$e;let Te;e[28]!==ue?(Te=()=>{if(ue){ke();return}Ie(!0),we(b2)},e[28]=ue,e[29]=Te):Te=e[29];const ae=Te,[fe,ge]=y.useState(null);let Oe;e[30]!==te||e[31]!==fe?(Oe=Z=>fe?.section===Z&&te===Z?fe.id:null,e[30]=te,e[31]=fe,e[32]=Oe):Oe=e[32];const Be=Oe;let Xe;e[33]!==Be?(Xe=Be("plans"),e[33]=Be,e[34]=Xe):Xe=e[34];const Ue=Xe,Ye=y.useRef(null),ze=y.useRef(null);let Me;e[35]===Symbol.for("react.memo_cache_sentinel")?(Me=(Z,De)=>{De&&(ze.current={section:Z,id:De,scrollTop:Ye.current?.scrollTop??0}),ge(De?{section:Z,id:De}:null)},e[35]=Me):Me=e[35];const Pe=Me;let Ge;e[36]===Symbol.for("react.memo_cache_sentinel")?(Ge=Z=>Pe("notes",Z),e[36]=Ge):Ge=e[36];const et=Ge;let tt;e[37]===Symbol.for("react.memo_cache_sentinel")?(tt=Z=>Pe("memory",Z),e[37]=tt):tt=e[37];const Ae=tt;let Re;e[38]===Symbol.for("react.memo_cache_sentinel")?(Re=Z=>Pe("plans",Z.id),e[38]=Re):Re=e[38];const at=Re;let Ne;e[39]!==q?(Ne=q.trim().toLowerCase(),e[39]=q,e[40]=Ne):Ne=e[40];const Fe=Ne;let pt;e[41]!==m.todos?(pt=n2(m.todos),e[41]=m.todos,e[42]=pt):pt=e[42];const rt=pt,it=m.loading&&!m.loaded,We=$r();let Je;if(e[43]!==m.notes||e[44]!==We||e[45]!==s||e[46]!==q){let Z;e[48]!==We||e[49]!==s||e[50]!==q?(Z=De=>!(s&&We.has(Ro(s,De.id)))&&bs([De.body],q),e[48]=We,e[49]=s,e[50]=q,e[51]=Z):Z=e[51],Je=m.notes.filter(Z),e[43]=m.notes,e[44]=We,e[45]=s,e[46]=q,e[47]=Je}else Je=e[47];const Tt=Je.length;let St;if(e[52]!==q||e[53]!==rt){let Z;e[55]!==q?(Z=De=>bs([De.text],q),e[55]=q,e[56]=Z):Z=e[56],St=rt.filter(Z),e[52]=q,e[53]=rt,e[54]=St}else St=e[54];const mt=St.length;let Ve;if(e[57]!==m.plans||e[58]!==We||e[59]!==s||e[60]!==q){let Z;e[62]!==We||e[63]!==s||e[64]!==q?(Z=De=>!(s&&We.has(Eo(s,De.id)))&&bs([De.title],q),e[62]=We,e[63]=s,e[64]=q,e[65]=Z):Z=e[65],Ve=m.plans.filter(Z),e[57]=m.plans,e[58]=We,e[59]=s,e[60]=q,e[61]=Ve}else Ve=e[61];const jt=Ve.length;let Ke;e[66]!==O||e[67]!==We||e[68]!==G||e[69]!==q?(Ke=[...O.filter(Z=>!We.has(Rr("global",Z.id))),...G.filter(Z=>!We.has(Rr("project",Z.id)))].filter(Z=>bs([Z.title,Z.body],q)),e[66]=O,e[67]=We,e[68]=G,e[69]=q,e[70]=Ke):Ke=e[70];let ht;e[71]!==Je.length||e[72]!==St.length||e[73]!==Ve.length||e[74]!==Ke.length?(ht={notes:Tt,todos:mt,plans:jt,memory:Ke.length},e[71]=Je.length,e[72]=St.length,e[73]=Ve.length,e[74]=Ke.length,e[75]=ht):ht=e[75];const Qe=ht,ut=Ce(y2);let _t;e[76]!==s?.path?(_t=Z=>Z.agentMemoryViewedAt[ea("project",s?.path??null)]??0,e[76]=s?.path,e[77]=_t):_t=e[77];const Nn=Ce(_t),ss=ji(O,ut)+ji(G,Nn);let Rt;e[78]!==u||e[79]!==i||e[80]!==s?(Rt={projectRef:s,canCreateWorktree:u,onActionComplete:i},e[78]=u,e[79]=i,e[80]=s,e[81]=Rt):Rt=e[81];const st=Zy(Rt);let ws,Kt;e[82]!==s||e[83]!==d?(ws=()=>{if(!(!s||!d))return _h(s)},Kt=[s,d],e[82]=s,e[83]=d,e[84]=ws,e[85]=Kt):(ws=e[84],Kt=e[85]),y.useEffect(ws,Kt);const Ss=y.useRef(null);let Gt,Zt;e[86]!==m.error||e[87]!==m.loaded||e[88]!==p?(Gt=()=>{if(!m.error){Ss.current=null;return}Ss.current!==m.error&&(Ss.current=m.error,m.loaded||Y.error(p("rightSidebar.contextNotesTodo.toast.loadNotesFailed")))},Zt=[m.error,m.loaded,p],e[86]=m.error,e[87]=m.loaded,e[88]=p,e[89]=Gt,e[90]=Zt):(Gt=e[89],Zt=e[90]),y.useEffect(Gt,Zt);const fs=fe===null||fe.section!==te;let js,Wt;e[91]!==te||e[92]!==fs?(js=()=>{const Z=ze.current;if(!Z||!fs||(ze.current=null,Z.section!==te))return;const De=Ye.current;if(!De)return;De.scrollTop=Z.scrollTop;const bt=Array.from(De.querySelectorAll("[data-knowledge-entry-id]")).find(pd=>pd.dataset.knowledgeEntryId===Z.id);(bt&&bt.tabIndex>=0?bt:bt?.querySelector("button"))?.focus({preventScroll:!0})},Wt=[te,fs],e[91]=te,e[92]=fs,e[93]=js,e[94]=Wt):(js=e[93],Wt=e[94]),y.useLayoutEffect(js,Wt);let ps;e[95]===Symbol.for("react.memo_cache_sentinel")?(ps=()=>{ge(null)},e[95]=ps):ps=e[95];let Ns;e[96]!==h?(Ns=[h],e[96]=h,e[97]=Ns):Ns=e[97],y.useEffect(ps,Ns);let Xt,ms;e[98]!==te?(Xt=()=>{ge(Z=>Z&&Z.section!==te?null:Z)},ms=[te],e[98]=te,e[99]=Xt,e[100]=ms):(Xt=e[99],ms=e[100]),y.useEffect(Xt,ms);const ns=Ce(v2);let rs,V;e[101]!==te||e[102]!==ns||e[103]!==h?(rs=()=>{!ns||ns.projectContextId!==h||te!=="plans"||(Ce.getState().clearProjectKnowledgePlanRequest(),Pe("plans",ns.planId))},V=[te,Pe,ns,h],e[101]=te,e[102]=ns,e[103]=h,e[104]=rs,e[105]=V):(rs=e[104],V=e[105]),y.useEffect(rs,V);let me;e[106]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{ke()},e[106]=me):me=e[106];let qe;e[107]!==h?(qe=[ke,h],e[107]=h,e[108]=qe):qe=e[108],y.useEffect(me,qe);const He=y.useRef("");let Et,qt;e[109]!==te||e[110]!==Qe||e[111]!==pe||e[112]!==Fe?(Et=()=>{if(Fe===He.current||(He.current=Fe,!Fe||Qe[te]>0))return;const Z=Ti.find(De=>Qe[De]>0);Z&&pe(Z)},qt=[te,Qe,pe,Fe],e[109]=te,e[110]=Qe,e[111]=pe,e[112]=Fe,e[113]=Et,e[114]=qt):(Et=e[113],qt=e[114]),y.useEffect(Et,qt);let ft;e[115]!==s||e[116]!==b||e[117]!==p?(ft=(Z,De)=>{s&&b(s,Z,De).then(bt=>{bt||Y.error(p("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[115]=s,e[116]=b,e[117]=p,e[118]=ft):ft=e[118];const Lt=ft;let Nt;e[119]!==p?(Nt=p("rightSidebar.contextNotesTodo.tabs.notes"),e[119]=p,e[120]=Nt):Nt=e[120];let gt;e[121]!==Qe.notes||e[122]!==Nt?(gt={id:"notes",icon:"sticky-note",label:Nt,count:Qe.notes,unseen:0},e[121]=Qe.notes,e[122]=Nt,e[123]=gt):gt=e[123];let kt;e[124]!==p?(kt=p("rightSidebar.contextNotesTodo.tabs.todos"),e[124]=p,e[125]=kt):kt=e[125];let xt;e[126]!==Qe.todos||e[127]!==kt?(xt={id:"todos",icon:"checkbox-circle",label:kt,count:Qe.todos,unseen:0},e[126]=Qe.todos,e[127]=kt,e[128]=xt):xt=e[128];let Qt;e[129]!==p?(Qt=p("rightSidebar.contextNotesTodo.tabs.plans"),e[129]=p,e[130]=Qt):Qt=e[130];let F;e[131]!==Qe.plans||e[132]!==Qt?(F={id:"plans",icon:"file-text",label:Qt,count:Qe.plans,unseen:0},e[131]=Qe.plans,e[132]=Qt,e[133]=F):F=e[133];let H;e[134]!==Qe.memory||e[135]!==ss||e[136]!==C||e[137]!==p?(H=C?[{id:"memory",icon:"brain-4",label:p("rightSidebar.contextNotesTodo.tabs.memory"),count:Qe.memory,unseen:ss}]:[],e[134]=Qe.memory,e[135]=ss,e[136]=C,e[137]=p,e[138]=H):H=e[138];let ye;e[139]!==gt||e[140]!==xt||e[141]!==F||e[142]!==H?(ye=[gt,xt,F,...H],e[139]=gt,e[140]=xt,e[141]=F,e[142]=H,e[143]=ye):ye=e[143];const Ee=ye;if(!s){let Z;e[144]!==c?(Z=ne("w-full min-w-0 p-3",c),e[144]=c,e[145]=Z):Z=e[145];let De;e[146]!==p?(De=p("rightSidebar.contextNotesTodo.empty.selectProject"),e[146]=p,e[147]=De):De=e[147];let bt;e[148]!==De?(bt=r.jsx("p",{className:"typography-meta text-muted-foreground",children:De}),e[148]=De,e[149]=bt):bt=e[149];let es;return e[150]!==Z||e[151]!==bt?(es=r.jsx("div",{className:Z,children:bt}),e[150]=Z,e[151]=bt,e[152]=es):es=e[152],es}let ve;e[153]!==te||e[154]!==Be?(ve=Be(te),e[153]=te,e[154]=Be,e[155]=ve):ve=e[155];const Se=ve!==null,ot=ue&&(J||!Se);let dt;if(e[156]!==o||e[157]!==s.path||e[158]!==p){const Z=o?.trim()||s.path.split("/").filter(Boolean).pop()||s.path;dt=p("rightSidebar.contextNotesTodo.search.placeholderInProject",{project:Z}),e[156]=o,e[157]=s.path,e[158]=p,e[159]=dt}else dt=e[159];const vt=dt;let $t;e[160]!==Ee||e[161]!==Fe.length?($t=Fe.length>0&&Ee.every(w2),e[160]=Ee,e[161]=Fe.length,e[162]=$t):$t=e[162];const Mt=$t;let hs;e[163]!==p?(hs=p("rightSidebar.contextNotesTodo.sections.label"),e[163]=p,e[164]=hs):hs=e[164];let ks;e[165]!==te||e[166]!==U||e[167]!==Ee||e[168]!==pe||e[169]!==p?(ks=Ee.map(Z=>{const De=te===Z.id;return r.jsxs("button",{type:"button",onClick:()=>pe(Z.id),"aria-current":De?"page":void 0,title:Z.label,className:ne("flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",De?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground"),children:[r.jsx(B,{name:Z.icon,className:"h-3.5 w-3.5 flex-shrink-0"}),r.jsx("span",{className:ne("whitespace-nowrap typography-meta",!De&&(U?"hidden":"hidden @[22rem]/knowledge-sections:inline")),children:Z.label}),r.jsx("span",{className:"typography-micro opacity-70",children:Z.count}),Z.unseen>0?r.jsx("span",{className:"rounded-full bg-[var(--status-success)]/15 px-1 typography-micro font-medium leading-4 text-[var(--status-success-text)]",title:p("rightSidebar.contextNotesTodo.memory.unseenTitle",{count:Z.unseen}),"aria-label":p("rightSidebar.contextNotesTodo.memory.unseenTitle",{count:Z.unseen}),children:`+${Z.unseen}`}):null]},Z.id)}),e[165]=te,e[166]=U,e[167]=Ee,e[168]=pe,e[169]=p,e[170]=ks):ks=e[170];let Hs;e[171]!==hs||e[172]!==ks?(Hs=r.jsx("nav",{className:"@container/knowledge-sections flex min-w-0 flex-1 items-center gap-1 overflow-x-auto","aria-label":hs,children:ks}),e[171]=hs,e[172]=ks,e[173]=Hs):Hs=e[173];const Fr=ue&&"bg-interactive-selection text-interactive-selection-foreground";let Ys;e[174]!==Fr?(Ys=ne("h-7 w-7 flex-shrink-0 p-0",Fr),e[174]=Fr,e[175]=Ys):Ys=e[175];let Gn;e[176]===Symbol.for("react.memo_cache_sentinel")?(Gn=r.jsx(B,{name:"search",className:"h-3.5 w-3.5"}),e[176]=Gn):Gn=e[176];let Js;e[177]!==vt||e[178]!==ue||e[179]!==Ys||e[180]!==ae?(Js=r.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:ae,"aria-pressed":ue,className:Ys,title:vt,"aria-label":vt,children:Gn}),e[177]=vt,e[178]=ue,e[179]=Ys,e[180]=ae,e[181]=Js):Js=e[181];let Wn;e[182]!==Hs||e[183]!==Js?(Wn=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 pe-1",children:[Hs,Js]}),e[182]=Hs,e[183]=Js,e[184]=Wn):Wn=e[184];const qn=Wn;let Xs;e[185]!==N?(Xs=(Z,De)=>N("plan",Z,De),e[185]=N,e[186]=Xs):Xs=e[186];const Br=J?Ue:null,Vr=l??at;let Hn;e[187]!==m.plans||e[188]!==L||e[189]!==s||e[190]!==q||e[191]!==Xs||e[192]!==Br||e[193]!==Vr?(Hn=r.jsx(zy,{projectRef:s,plans:m.plans,query:q,pinnedPlanIds:L,onTogglePinned:Xs,selectedPlanId:Br,onOpenPlan:Vr}),e[187]=m.plans,e[188]=L,e[189]=s,e[190]=q,e[191]=Xs,e[192]=Br,e[193]=Vr,e[194]=Hn):Hn=e[194];const Yn=Hn;let Jn;e[195]!==s||e[196]!==p||e[197]!==d?(Jn=(Z,De)=>r.jsx(y.Suspense,{fallback:null,children:r.jsx(qh,{value:null,children:r.jsx(t2,{visible:d,leading:De?r.jsx(td,{label:p("rightSidebar.contextNotesTodo.plans.actions.back"),onClick:()=>ge(null)}):null,savedProjectPlan:{projectRef:s,planId:Z},onNavigatedToChat:()=>ge(null)})})}),e[195]=s,e[196]=p,e[197]=d,e[198]=Jn):Jn=e[198];const Xn=Jn;let Qs;e[199]!==c?(Qs=ne("flex h-full min-h-0 w-full min-w-0 flex-col",c),e[199]=c,e[200]=Qs):Qs=e[200];let Zs;e[201]!==f||e[202]!==qn?(Zs=f?r.jsx(zo,{children:qn}):r.jsx("div",{className:"flex flex-shrink-0 px-3 pt-2",children:qn}),e[201]=f,e[202]=qn,e[203]=Zs):Zs=e[203];let en;e[204]!==Mt||e[205]!==q||e[206]!==Le||e[207]!==vt||e[208]!==ot||e[209]!==J?(en=ot?r.jsx("div",{className:ne("pointer-events-none absolute top-2 z-20",J?"inset-s-3":"inset-e-3"),children:r.jsx(e2,{query:q,onQueryChange:oe,placeholder:vt,nothingFound:Mt,focusRequest:Le,onClose:ke})}):null,e[204]=Mt,e[205]=q,e[206]=Le,e[207]=vt,e[208]=ot,e[209]=J,e[210]=en):en=e[210];let tn;e[211]!==Se||e[212]!==J?(tn=ne("h-full min-w-0",J?"overflow-hidden":ne("p-3",Se?"overflow-hidden":"overflow-y-auto")),e[211]=Se,e[212]=J,e[213]=tn):tn=e[213];let sn;e[214]!==te||e[215]!==m.notes||e[216]!==it||e[217]!==Be||e[218]!==_||e[219]!==s||e[220]!==q||e[221]!==J||e[222]!==N?(sn=te==="notes"?r.jsx($y,{projectRef:s,notes:m.notes,disabled:it,query:q,pinnedNoteIds:_,onTogglePinned:(Z,De)=>N("note",Z,De),openNoteId:Be("notes"),onOpenNote:et,split:J}):null,e[214]=te,e[215]=m.notes,e[216]=it,e[217]=Be,e[218]=_,e[219]=s,e[220]=q,e[221]=J,e[222]=N,e[223]=sn):sn=e[223];let nn;e[224]!==te||e[225]!==u||e[226]!==Lt||e[227]!==it||e[228]!==q||e[229]!==st.sendToCurrentSession||e[230]!==st.sendToNewSession||e[231]!==st.sendToNewWorktreeSession||e[232]!==st.sendingTodoId||e[233]!==rt||e[234]!==he?(nn=te==="todos"?r.jsx("div",{className:ne(he&&"mx-auto max-w-3xl"),children:r.jsx(qy,{todos:rt,query:q,disabled:it,canCreateWorktree:u,sendingTodoId:st.sendingTodoId,onPersistTodos:Lt,onSendToCurrentSession:st.sendToCurrentSession,onSendToNewSession:st.sendToNewSession,onSendToNewWorktreeSession:st.sendToNewWorktreeSession})}):null,e[224]=te,e[225]=u,e[226]=Lt,e[227]=it,e[228]=q,e[229]=st.sendToCurrentSession,e[230]=st.sendToNewSession,e[231]=st.sendToNewWorktreeSession,e[232]=st.sendingTodoId,e[233]=rt,e[234]=he,e[235]=nn):nn=e[235];let rn;e[236]!==te||e[237]!==C||e[238]!==Be||e[239]!==s.path||e[240]!==q||e[241]!==J?(rn=te==="memory"&&C?r.jsx(gy,{projectPath:s.path,query:q,openMemoryId:Be("memory"),onOpenMemory:Ae,split:J}):null,e[236]=te,e[237]=C,e[238]=Be,e[239]=s.path,e[240]=q,e[241]=J,e[242]=rn):rn=e[242];let on;e[243]!==te||e[244]!==Ue||e[245]!==Xn||e[246]!==Yn||e[247]!==J||e[248]!==p?(on=te==="plans"?J?r.jsx(sa,{list:Yn,detail:Ue?Xn(Ue,!1):null,emptyLabel:p("rightSidebar.contextNotesTodo.plans.selectHint")}):Ue?Xn(Ue,!0):Yn:null,e[243]=te,e[244]=Ue,e[245]=Xn,e[246]=Yn,e[247]=J,e[248]=p,e[249]=on):on=e[249];let an;e[250]!==tn||e[251]!==sn||e[252]!==nn||e[253]!==rn||e[254]!==on?(an=r.jsxs("div",{ref:Ye,className:tn,children:[sn,nn,rn,on]}),e[250]=tn,e[251]=sn,e[252]=nn,e[253]=rn,e[254]=on,e[255]=an):an=e[255];let ln;e[256]!==en||e[257]!==an?(ln=r.jsxs("div",{className:"relative min-h-0 min-w-0 flex-1",children:[en,an]}),e[256]=en,e[257]=an,e[258]=ln):ln=e[258];const Ur=st.pendingSendTarget!==null;let cn;e[259]!==st?(cn=Z=>{Z||st.closeDialog()},e[259]=st,e[260]=cn):cn=e[260];const zr=st.pendingSendTarget?.kind??"session";let dn;e[261]!==s.path||e[262]!==st.confirmSend||e[263]!==st.isSubmitting||e[264]!==Ur||e[265]!==cn||e[266]!==zr?(dn=r.jsx(Lh,{open:Ur,onOpenChange:cn,target:zr,projectDirectory:s.path,submitting:st.isSubmitting,onConfirm:st.confirmSend}),e[261]=s.path,e[262]=st.confirmSend,e[263]=st.isSubmitting,e[264]=Ur,e[265]=cn,e[266]=zr,e[267]=dn):dn=e[267];let Qn;return e[268]!==Qs||e[269]!==Zs||e[270]!==ln||e[271]!==dn?(Qn=r.jsxs("div",{ref:X,className:Qs,children:[Zs,ln,dn]}),e[268]=Qs,e[269]=Zs,e[270]=ln,e[271]=dn,e[272]=Qn):Qn=e[272],Qn};function o2(t){return t.saveTodos}function a2(t){return t.currentSessionId}function i2(t){return t.currentSessionDirectory}function l2(t){return t.newSessionDraft}function c2(t){return t.setDraftProjectContextPin}function d2(t){return t.id}function u2(t){return t.id}function f2(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function p2(t){return t.disabled}function m2(t){return t.global}function h2(t){return t.isMobile}function g2(t){return t.projectContextTab}function x2(t){return t.setProjectContextTab}function b2(t){return t+1}function y2(t){return t.agentMemoryViewedAt[ea("global",null)]??0}function v2(t){return t.projectKnowledgePlanRequest}function w2(t){return t.count===0}const $0=t=>{const e=W.c(19),{visible:s,onActionComplete:n,onOpenPlan:o}=t,a=s===void 0?!0:s,i=Ar(S2),{t:l}=se(),c=Ln(j2),d=_e(N2),u=Vc(d),f=Jt(k2);let p;e[0]!==u||e[1]!==f?(p=u?f.find(w=>w.id===u.id)??null:null,e[0]=u,e[1]=f,e[2]=p):p=e[2];const g=p;let h;e:{if(!u){h=null;break e}if(u.id===xo){let S;e[3]!==l?(S=l("sessions.sidebar.activity.chatsTitle"),e[3]=l,e[4]=S):S=e[4],h=S;break e}let w;e[5]!==i||e[6]!==g?.label||e[7]!==u.path?(w=g?.label?.trim()||ho(u.path,i)||u.path,e[5]=i,e[6]=g?.label,e[7]=u.path,e[8]=w):w=e[8],h=w}const x=h;let m;e:{if(!u||u.id===xo){m=!1;break e}let w;e[9]!==c||e[10]!==u.path?(w=c.get(u.path)?.isGitRepo,e[9]=c,e[10]=u.path,e[11]=w):w=e[11],m=w===!0}const b=m;let v;return e[12]!==b||e[13]!==n||e[14]!==o||e[15]!==x||e[16]!==u||e[17]!==a?(v=r.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:r.jsx(r2,{projectRef:u,visible:a,projectLabel:x,canCreateWorktree:b,onActionComplete:n,onOpenPlan:o})}),e[12]=b,e[13]=n,e[14]=o,e[15]=x,e[16]=u,e[17]=a,e[18]=v):v=e[18],v};function S2(t){return t.homeDirectory}function j2(t){return t.directories}function N2(t){return t.currentSessionDirectory}function k2(t){return t.projects}const C2=()=>{const t=W.c(2),e=_e(I2);let s;return t[0]!==e?(s=n=>tp(e,n.journey),t[0]=e,t[1]=s):s=t[1],ct(Lm(s))};function I2(t){return t.currentSessionId===null&&t.newSessionDraft?.open?t.newSessionDraft.pendingWorktreeRequestId??null:null}const T2=()=>{const t=W.c(5),{t:e}=se();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Ft,{className:"h-4 w-4"}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("spaces.draft.preparing"),t[1]=e,t[2]=n):n=t[2];let o;return t[3]!==n?(o=r.jsxs("div",{className:"flex h-full items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[s,r.jsx("span",{children:n})]}),t[3]=n,t[4]=o):o=t[4],o};function R2(t,e=t.colors.surface.background){const{colors:s}=t,n=s.syntax.base;return{background:e,foreground:n.foreground,cursor:s.interactive.cursor,cursorAccent:e,selectionBackground:s.interactive.selection,selectionForeground:s.interactive.selectionForeground,selectionInactiveBackground:sp(s.interactive.selection,.31),black:s.surface.muted,red:s.status.error,green:s.status.success,yellow:s.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:s.status.error,brightGreen:s.status.success,brightYellow:s.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:s.surface.elevatedForeground}}const E2=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],dr=t=>{const e=t.trim(),s=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e)?.[1];if(s){const l=s.length<=4?s.slice(0,3).split("").map(c=>c+c).join(""):s.slice(0,6);return{r:Number.parseInt(l.slice(0,2),16),g:Number.parseInt(l.slice(2,4),16),b:Number.parseInt(l.slice(4,6),16)}}const n=/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})(?:\s*[,/]\s*[\d.]+)?\s*\)$/i.exec(e);if(!n)return null;const[o,a,i]=n.slice(1,4).map(Number);return[o,a,i].some(l=>l===void 0||l<0||l>255)?null:{r:o??0,g:a??0,b:i??0}};function Ri(t){const e=dr(t.background)??{r:0,g:0,b:0},s=dr(t.foreground)??{r:255,g:255,b:255};return{background:e,foreground:s,cursor:dr(t.cursor)??s,palette:E2.map(n=>dr(t[n])??s),selectionBackground:t.selectionBackground}}function D2(t,e){if(t.length===0)return{reset:e!==null,replay:!1,pending:[]};if(e===null)return{reset:!1,replay:!0,pending:t};let s=-1;for(let n=t.length-1;n>=0;n-=1){const o=t[n].id;if(o===e){s=n;break}if(o<e)break}return s<0?{reset:!0,replay:!0,pending:t}:{reset:!1,replay:!1,pending:t.slice(s+1)}}const P2=async(t,e)=>{const{GhosttyTerminalSurface:s}=await Es(async()=>{const{GhosttyTerminalSurface:n}=await import("./surface-B62hJ9SM.js");return{GhosttyTerminalSurface:n}},[]);return s.create(t,e)},A2=2e3,_2=t=>new Promise(e=>{const s=setTimeout(e,A2);rp(t).finally(()=>{clearTimeout(s),e()})}),Ei=4,L2=(t,e,s)=>{const n=t.ownerDocument.createElement("canvas").getContext("2d");if(!n||t.clientWidth<24||t.clientHeight<24)return null;n.font=`${s}px ${e}`;const o=n.measureText("M"),a=o.width,i=(o.actualBoundingBoxAscent||s*.8)+(o.actualBoundingBoxDescent||s*.2),l=Math.max(1,Math.round(s*1.35),Math.ceil(i));return a<1||l<1?null:{cols:Math.max(2,Math.floor((t.clientWidth-Ei*2)/a)),rows:Math.max(1,Math.floor((t.clientHeight-Ei*2)/l))}},id=y.forwardRef(({sessionKey:t,chunks:e,onInput:s,onResize:n,onProvisionalSize:o,theme:a,monoFont:i,fontFamily:l,fontSize:c,className:d,enableTouchScroll:u=!1,autoFocus:f=!0,isVisible:p=!0,createSurface:g=P2},h)=>{const{t:x}=se(),m=y.useRef(null),b=y.useRef(null),v=y.useRef(s),w=y.useRef(n),S=y.useRef(o),I=y.useRef(null),k=y.useRef(p),R=y.useRef({input:"",scrollbar:""}),[P,T]=y.useState(0),D=y.useRef(null),A=y.useRef(0),N=y.useRef(!1),[j,_]=y.useState(!1),[E,L]=y.useState("");v.current=s,w.current=n,S.current=o,k.current=p,R.current={input:x("terminalView.viewport.inputAria"),scrollbar:x("terminalView.viewport.scrollbarAria")},y.useLayoutEffect(()=>{const C=m.current;if(!C)return;const O=L2(C,l,c);O&&(S.current??w.current)(O.cols,O.rows)},[l,c]),y.useEffect(()=>{const C=m.current;if(!C)return;let O=!1,z=null;const G=a,U={family:l,size:c},K=i,X=!u;return(async()=>{if(await _2(K),O)return;let re;try{re=await g(C,{theme:Ri(G),font:U,get visible(){return k.current},labels:R.current,handleTouchPointer:X,onData:ee=>v.current(ee),onResize:(ee,xe)=>w.current(ee,xe),onLinkActivate:ee=>{Er(ee)},onContextMenu:ee=>{D.current=ee,L(z?.getSelection()??"")}})}catch(ee){console.error("[terminal] failed to initialize the terminal renderer",ee);return}if(O){re.dispose();return}z=re,b.current=re,re.setVisible(k.current),T(ee=>ee+1)})(),()=>{O=!0;const re=document.activeElement;re instanceof HTMLElement&&C.contains(re)&&(re.blur(),window.Capacitor?.getPlatform?.()==="android"&&Es(async()=>{const{Keyboard:xe}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:xe}},__vite__mapDeps([124,72])).then(({Keyboard:xe})=>xe.hide()).catch(()=>{})),z?.dispose(),z=null,b.current=null,I.current=null}},[g]),y.useEffect(()=>{b.current?.setTheme(Ri(a))},[a,P]),y.useEffect(()=>{b.current?.setFont({family:l,size:c})},[l,c,P]),y.useEffect(()=>{b.current?.setVisible(p)},[p,P]),y.useEffect(()=>(_(!1),D.current=null,A.current+=1,()=>{A.current+=1}),[t,p,P]);const $=async()=>{if(E)try{(await Lo(E)).ok||hr.error(x("terminalView.toast.copyFailed"))}catch{hr.error(x("terminalView.toast.copyFailed"))}},M=y.useCallback(async C=>{const O=b.current;if(!O||!k.current)return;const z=A.current,G=()=>b.current===O&&k.current&&A.current===z;try{await O.pasteFromClipboard(np,G)}catch{G()&&hr.error(C)}},[]);return y.useEffect(()=>{const C=b.current;if(!C)return;const{reset:O,replay:z,pending:G}=D2(e,I.current);if(z){const[U,...K]=G;C.resetAndWrite(U?U.replayData??U.data:"",U?.size);const X=K.map(re=>re.replayData??re.data).join("");X&&C.write(X)}else O?C.resetAndWrite(""):G.length>0&&C.write(G.map(U=>U.data).join(""));I.current=e.at(-1)?.id??null},[e,P]),y.useEffect(()=>{if(!f||!p)return;const C=requestAnimationFrame(()=>b.current?.focus());return()=>cancelAnimationFrame(C)},[f,p,P,t]),y.useEffect(()=>{const C=m.current,O=b.current;if(!u||!C||!O)return;let z=null,G=null,U="idle",K=0,X=0,re=0,ee=0;const xe=Math.max(12,Math.round(c*1.35)),ce=()=>{window.Capacitor?.getPlatform?.()==="android"&&Es(async()=>{const{Keyboard:q}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:q}},__vite__mapDeps([124,72])).then(({Keyboard:q})=>q.show()).catch(()=>{})},he=()=>{G&&(clearTimeout(G),G=null)},ie=J=>{J.pointerType!=="touch"||z!==null||(z=J.pointerId,U="pending",K=J.clientX,X=J.clientY,re=J.clientY,ee=0,C.setPointerCapture(J.pointerId),G=setTimeout(()=>{G=null,!(z!==J.pointerId||U!=="pending")&&O.selectWordAt(K,X)&&(U="selecting")},350))},pe=J=>{if(z!==J.pointerId)return;if(U==="selecting"){O.extendSelectionTo(J.clientX,J.clientY),J.cancelable&&J.preventDefault();return}if(U==="pending"){if(Math.hypot(J.clientX-K,J.clientY-X)<8)return;he(),U="scrolling"}if(U!=="scrolling")return;const q=re-J.clientY;re=J.clientY,ee+=q;const oe=Math.trunc(ee/xe);oe&&(O.scrollLines(oe),ee-=oe*xe),J.cancelable&&J.preventDefault()},le=(J,q)=>{if(z!==J.pointerId)return;const oe=q&&U==="pending";he(),C.hasPointerCapture(J.pointerId)&&C.releasePointerCapture(J.pointerId),z=null,U="idle",oe&&(O.focus(),ce())},de=J=>le(J,!0),te=J=>le(J,!1);return C.addEventListener("pointerdown",ie),C.addEventListener("pointermove",pe,{passive:!1}),C.addEventListener("pointerup",de),C.addEventListener("pointercancel",te),()=>{he(),C.removeEventListener("pointerdown",ie),C.removeEventListener("pointermove",pe),C.removeEventListener("pointerup",de),C.removeEventListener("pointercancel",te)}},[u,c,P]),y.useImperativeHandle(h,()=>({focus:()=>b.current?.focus(),fit:()=>{const C=b.current;C&&(C.fit(),C.refresh())},getSelection:()=>{const C=b.current,O=C?.getSelectionPosition(),z=C?.getSelection()??"";return!O||!z.trim()?null:{text:z,startLine:O.start.y+1,endLine:O.end.y+1}},pasteClipboard:()=>M(x("terminalView.toast.pasteFailedTouch"))}),[M,x]),r.jsxs(qi,{disabled:u||!p,open:j&&p,onOpenChange:(C,O)=>{N.current=!C&&(O.reason==="item-press"||O.reason==="escape-key"),_(C)},children:[r.jsx(Gi,{onContextMenu:C=>{C.nativeEvent!==D.current&&C.preventBaseUIHandler(),D.current=null},onTouchStart:C=>C.preventBaseUIHandler(),render:r.jsx("div",{ref:m,"data-terminal-owner":"main",className:ne("terminal-viewport-container relative h-full w-full overflow-hidden touch-none",d)})}),r.jsxs(Wi,{finalFocus:()=>(N.current&&k.current&&b.current?.focus(),!1),children:[r.jsx(yn,{disabled:!E,onClick:()=>{$()},children:x("terminalView.actions.copy")}),r.jsx(yn,{onClick:()=>{M(x("terminalView.toast.pasteFailed"))},children:x("terminalView.actions.paste")})]})]})});id.displayName="TerminalViewport";const $2=t=>{const e=W.c(46),{currentLabel:s,onRename:n,onClose:o}=t,{t:a}=se(),[i,l]=y.useState("");let c,d;e[0]!==s?(c=()=>{s!==null&&l(s)},d=[s],e[0]=s,e[1]=c,e[2]=d):(c=e[1],d=e[2]),y.useEffect(c,d);let u;e[3]!==o||e[4]!==n||e[5]!==i?(u=()=>{const j=i.trim();j&&n(j),o()},e[3]=o,e[4]=n,e[5]=i,e[6]=u):u=e[6];const f=u,p=s!==null;let g;e[7]!==o?(g=j=>{j||o()},e[7]=o,e[8]=g):g=e[8];let h;e[9]!==a?(h=a("terminalView.tabs.renameDialog.title"),e[9]=a,e[10]=h):h=e[10];let x;e[11]!==h?(x=r.jsx(vs,{children:r.jsx(us,{children:h})}),e[11]=h,e[12]=x):x=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=j=>l(j.target.value),e[13]=m):m=e[13];let b;e[14]!==a?(b=a("terminalView.tabs.renameDialog.placeholder"),e[14]=a,e[15]=b):b=e[15];let v;e[16]!==f?(v=j=>{j.key==="Enter"&&!Vn(j)&&(j.preventDefault(),f())},e[16]=f,e[17]=v):v=e[17];let w;e[18]!==v||e[19]!==b||e[20]!==i?(w=r.jsx(It,{autoFocus:!0,value:i,onChange:m,onFocus:M2,placeholder:b,onKeyDown:v}),e[18]=v,e[19]=b,e[20]=i,e[21]=w):w=e[21];let S;e[22]!==a?(S=a("terminalView.tabs.renameDialog.cancel"),e[22]=a,e[23]=S):S=e[23];let I;e[24]!==o||e[25]!==S?(I=r.jsx(Q,{size:"sm",variant:"ghost",onClick:o,children:S}),e[24]=o,e[25]=S,e[26]=I):I=e[26];let k;e[27]!==i?(k=i.trim(),e[27]=i,e[28]=k):k=e[28];const R=!k;let P;e[29]!==a?(P=a("terminalView.tabs.renameDialog.save"),e[29]=a,e[30]=P):P=e[30];let T;e[31]!==f||e[32]!==R||e[33]!==P?(T=r.jsx(Q,{size:"sm",onClick:f,disabled:R,children:P}),e[31]=f,e[32]=R,e[33]=P,e[34]=T):T=e[34];let D;e[35]!==I||e[36]!==T?(D=r.jsxs(Gs,{children:[I,T]}),e[35]=I,e[36]=T,e[37]=D):D=e[37];let A;e[38]!==w||e[39]!==D||e[40]!==x?(A=r.jsxs(ds,{className:"max-w-sm",children:[x,w,D]}),e[38]=w,e[39]=D,e[40]=x,e[41]=A):A=e[41];let N;return e[42]!==A||e[43]!==p||e[44]!==g?(N=r.jsx(cs,{open:p,onOpenChange:g,children:A}),e[42]=A,e[43]=p,e[44]=g,e[45]=N):N=e[45],N};function M2(t){return t.currentTarget.select()}const O2="\x1B",ia=new RegExp(`${O2}\\[[0-9;?]*[ -/]*[@-~]`,"g"),F2=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,B2=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,V2=/Serving HTTP on .*? port (\d{2,5})/i,U2=/^--\s+Using port (\d{2,5})\b/,z2=/^\s*->\s+(https?:\/\/[^\s<>'"`]+)\s*$/,la=new Set(["localhost","127.0.0.1","0.0.0.0","::1","::","[::1]","[::]"]),K2=new Set([".",",",";",":","!","?"]),ca=t=>{let e=t;for(;e.length>0;){const s=e[e.length-1];if(s===")"||s==="]"||s==="}"||s===">"){const n=s===")"?"(":s==="]"?"[":s==="}"?"{":"<",o=e.slice(0,-1),a=(o.match(new RegExp(`\\${n}`,"g"))||[]).length,i=(o.match(new RegExp(`\\${s}`,"g"))||[]).length;if(a>i)break;e=o;continue}if(K2.has(s)){e=e.slice(0,-1);continue}break}return e},Do=t=>{let e=ca(t);return e=e.replace("0.0.0.0","127.0.0.1"),e=e.replace("[::1]","127.0.0.1"),e=e.replace("[::]","127.0.0.1"),e},ld=t=>{try{const e=new URL(t);if(!la.has(e.hostname.toLowerCase()))return null;const s=Number.parseInt(e.port,10);return Number.isFinite(s)?s:null}catch{return null}},G2=t=>{try{return la.has(new URL(t).hostname.toLowerCase())}catch{return!1}},cd=t=>{const e=[];for(const s of t.replace(ia,"").split(`
|
|
65
|
+
\`\`\``;m(T,"append"),Y.success(o("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),n?.()},[f,n,v,m,o]),S=y.useCallback((P,T)=>{!e||d||i({kind:"session",todoId:P,todoText:T})},[e,d]),I=y.useCallback((P,T)=>{if(!(!e||d)){if(!s){Y.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}i({kind:"worktree",todoId:P,todoText:T})}},[s,e,d,o]),k=y.useCallback(async P=>{if(!e||!a)return;const T=await Vs("plan.todo.visible",{todo_text:a.todoText}),A=[{synthetic:!0,text:await Vs("plan.todo.instructions",{todo_text:a.todoText})}];c(!0),u(a.todoId);try{v();let N=null,j=e.path;if(a.kind==="worktree"){if(!s){Y.error(o("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const E=await Yf(e.path,Jf());if(!E?.id)return;N=E.id,j=E.directory}else{const E=await p(void 0,e.path,void 0,{model:{providerID:P.providerID,id:P.modelID,variant:P.variant||void 0},agent:P.agent.trim()||void 0});if(!E?.id){Y.error(o("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}N=E.id,j=E.directory??e.path,g(E.id,Ot.getState().agents??[])}if(!N)return;const _=Xf.getState();_.saveSessionModelSelection(N,P.providerID,P.modelID),P.agent.trim()&&(_.saveSessionAgentSelection(N,P.agent),_.saveAgentModelForSession(N,P.agent,P.providerID,P.modelID),_.saveAgentModelVariantForSession(N,P.agent,P.providerID,P.modelID,P.variant||void 0)),x(N,j),await h(T,P.providerID,P.modelID,P.agent.trim()||void 0,void 0,void 0,A,P.variant||void 0),Y.success(a.kind==="worktree"?o("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):o("rightSidebar.contextNotesTodo.toast.sentToNewSession")),i(null),n?.()}catch(N){const j=N instanceof Error?N.message:void 0;Y.error(o("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),j?{description:j}:void 0)}finally{c(!1),u(null)}},[s,p,g,n,a,e,v,h,x,o]),R=y.useCallback(()=>{l||i(null)},[l]);return{pendingSendTarget:a,isSubmitting:l,sendingTodoId:d,sendToCurrentSession:w,sendToNewSession:S,sendToNewWorktreeSession:I,confirmSend:k,closeDialog:R}},e2=t=>{const e=W.c(26),{query:s,onQueryChange:n,placeholder:o,nothingFound:a,focusRequest:i,onClose:l}=t,{t:c}=se(),d=y.useRef(null);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current?.focus(),d.current?.select()},e[0]=u):u=e[0];let f;e[1]!==i?(f=[i],e[1]=i,e[2]=f):f=e[2],y.useEffect(u,f);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=r.jsx(B,{name:"search",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e[3]=p):p=e[3];let g;e[4]!==n?(g=I=>n(I.target.value),e[4]=n,e[5]=g):g=e[5];let h;e[6]!==l?(h=I=>{I.key==="Escape"&&!I.nativeEvent.isComposing&&(I.preventDefault(),l())},e[6]=l,e[7]=h):h=e[7];let x;e[8]!==o||e[9]!==s||e[10]!==g||e[11]!==h?(x=r.jsx("input",{ref:d,value:s,onChange:g,onKeyDown:h,placeholder:o,"aria-label":o,className:"h-7 w-48 min-w-0 bg-transparent typography-meta text-foreground outline-none placeholder:text-muted-foreground"}),e[8]=o,e[9]=s,e[10]=g,e[11]=h,e[12]=x):x=e[12];let m;e[13]!==a||e[14]!==c?(m=a?r.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",role:"status","aria-live":"polite",children:c("chat.search.noResults")}):null,e[13]=a,e[14]=c,e[15]=m):m=e[15];let b;e[16]!==c?(b=c("chat.search.close"),e[16]=c,e[17]=b):b=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=r.jsx(B,{name:"close",className:"h-4 w-4"}),e[18]=v):v=e[18];let w;e[19]!==l||e[20]!==b?(w=r.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:l,"aria-label":b,children:v}),e[19]=l,e[20]=b,e[21]=w):w=e[21];let S;return e[22]!==w||e[23]!==x||e[24]!==m?(S=r.jsxs("div",{role:"search",className:"pointer-events-auto flex items-center gap-1 rounded-lg border border-border bg-[var(--surface-elevated)] py-1 ps-2.5 pe-1 shadow-md",children:[p,x,m,w]}),e[22]=w,e[23]=x,e[24]=m,e[25]=S):S=e[25],S},t2=y.lazy(()=>Es(()=>import("./PlanView-D7wshtfZ.js"),__vite__mapDeps([117,20,21,118,46,47,48,49,50,51,45,52,53,54,55,119,120,121,19,22,23,2,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,122,123])).then(t=>({default:t.PlanView}))),Ti=["notes","todos","plans","memory"],s2=900,n2=t=>[...t.filter(e=>!e.completed),...t.filter(e=>e.completed)],r2=t=>{const e=W.c(273),{projectRef:s,visible:n,projectLabel:o,canCreateWorktree:a,onActionComplete:i,onOpenPlan:l,className:c}=t,d=n===void 0?!0:n,u=a===void 0?!1:a,f=Uo(),{t:p}=se();let g;e[0]!==s?(g=ys(s),e[0]=s,e[1]=g):g=e[1];const h=g;let x;e[2]!==h?(x=Z=>(h?Z.entries[h]:void 0)??Qf,e[2]=h,e[3]=x):x=e[3];const m=Pt(x),b=Pt(o2),v=_e(a2),w=_e(i2),S=_e(l2),I=_e(c2);let k;e[4]===Symbol.for("react.memo_cache_sentinel")?(k={notes:[],plans:[]},e[4]=k):k=e[4];const[R,P]=y.useState(k);let T,D;e[5]!==w||e[6]!==v||e[7]!==S.open||e[8]!==S.projectContextPins?(T=()=>{if(S.open){P(S.projectContextPins??{notes:[],plans:[]});return}let Z=!1;return Zf(w,v).then(De=>{Z||P({notes:De.notes.map(d2),plans:De.plans.map(u2)})}),()=>{Z=!0}},D=[w,v,S.open,S.projectContextPins],e[5]=w,e[6]=v,e[7]=S.open,e[8]=S.projectContextPins,e[9]=T,e[10]=D):(T=e[9],D=e[10]),y.useEffect(T,D);let A;e[11]!==w||e[12]!==v||e[13]!==S.open||e[14]!==I?(A=async(Z,De,bt)=>{if(S.open)return I(Z,De,bt),!0;if(!v||!w)return!1;const es=await ep(w,v,Z,De,bt);return es?(P(es),!0):!1},e[11]=w,e[12]=v,e[13]=S.open,e[14]=I,e[15]=A):A=e[15];const N=A;let j;e[16]!==R.notes?(j=new Set(R.notes),e[16]=R.notes,e[17]=j):j=e[17];const _=j;let E;e[18]!==R.plans?(E=new Set(R.plans),e[18]=R.plans,e[19]=E):E=e[19];const L=E,$=Ce(f2),M=Dt(p2),C=$&&!M,O=Dt(m2);let z;e[20]!==s?.path?(z=Z=>jl(Z,s?.path??null),e[20]=s?.path,e[21]=z):z=e[21];const G=Dt(z),U=Ce(h2),[K,X]=y.useState(null),[re,ee]=y.useState(0);let xe,ce;e[22]!==K?(xe=()=>{const Z=K;if(!Z)return;ee(Z.getBoundingClientRect().width);const De=new ResizeObserver(bt=>{const es=bt[bt.length-1];es&&ee(es.contentRect.width)});return De.observe(Z),()=>De.disconnect()},ce=[K],e[22]=K,e[23]=xe,e[24]=ce):(xe=e[23],ce=e[24]),y.useLayoutEffect(xe,ce);const he=!U&&re>=s2,ie=Ce(g2),pe=Ce(x2);let le;e[25]!==ie?(le=Ti.includes(ie)?ie:"notes",e[25]=ie,e[26]=le):le=e[26];const de=le,te=de==="memory"&&!C?"notes":de,J=he&&te!=="todos",[q,oe]=y.useState(""),[ue,Ie]=y.useState(!1),[Le,we]=y.useState(0);let $e;e[27]===Symbol.for("react.memo_cache_sentinel")?($e=()=>{Ie(!1),oe("")},e[27]=$e):$e=e[27];const ke=$e;let Te;e[28]!==ue?(Te=()=>{if(ue){ke();return}Ie(!0),we(b2)},e[28]=ue,e[29]=Te):Te=e[29];const ae=Te,[fe,ge]=y.useState(null);let Oe;e[30]!==te||e[31]!==fe?(Oe=Z=>fe?.section===Z&&te===Z?fe.id:null,e[30]=te,e[31]=fe,e[32]=Oe):Oe=e[32];const Be=Oe;let Xe;e[33]!==Be?(Xe=Be("plans"),e[33]=Be,e[34]=Xe):Xe=e[34];const Ue=Xe,Ye=y.useRef(null),ze=y.useRef(null);let Me;e[35]===Symbol.for("react.memo_cache_sentinel")?(Me=(Z,De)=>{De&&(ze.current={section:Z,id:De,scrollTop:Ye.current?.scrollTop??0}),ge(De?{section:Z,id:De}:null)},e[35]=Me):Me=e[35];const Pe=Me;let Ge;e[36]===Symbol.for("react.memo_cache_sentinel")?(Ge=Z=>Pe("notes",Z),e[36]=Ge):Ge=e[36];const et=Ge;let tt;e[37]===Symbol.for("react.memo_cache_sentinel")?(tt=Z=>Pe("memory",Z),e[37]=tt):tt=e[37];const Ae=tt;let Re;e[38]===Symbol.for("react.memo_cache_sentinel")?(Re=Z=>Pe("plans",Z.id),e[38]=Re):Re=e[38];const at=Re;let Ne;e[39]!==q?(Ne=q.trim().toLowerCase(),e[39]=q,e[40]=Ne):Ne=e[40];const Fe=Ne;let pt;e[41]!==m.todos?(pt=n2(m.todos),e[41]=m.todos,e[42]=pt):pt=e[42];const rt=pt,it=m.loading&&!m.loaded,We=$r();let Je;if(e[43]!==m.notes||e[44]!==We||e[45]!==s||e[46]!==q){let Z;e[48]!==We||e[49]!==s||e[50]!==q?(Z=De=>!(s&&We.has(Ro(s,De.id)))&&bs([De.body],q),e[48]=We,e[49]=s,e[50]=q,e[51]=Z):Z=e[51],Je=m.notes.filter(Z),e[43]=m.notes,e[44]=We,e[45]=s,e[46]=q,e[47]=Je}else Je=e[47];const Tt=Je.length;let St;if(e[52]!==q||e[53]!==rt){let Z;e[55]!==q?(Z=De=>bs([De.text],q),e[55]=q,e[56]=Z):Z=e[56],St=rt.filter(Z),e[52]=q,e[53]=rt,e[54]=St}else St=e[54];const mt=St.length;let Ve;if(e[57]!==m.plans||e[58]!==We||e[59]!==s||e[60]!==q){let Z;e[62]!==We||e[63]!==s||e[64]!==q?(Z=De=>!(s&&We.has(Eo(s,De.id)))&&bs([De.title],q),e[62]=We,e[63]=s,e[64]=q,e[65]=Z):Z=e[65],Ve=m.plans.filter(Z),e[57]=m.plans,e[58]=We,e[59]=s,e[60]=q,e[61]=Ve}else Ve=e[61];const jt=Ve.length;let Ke;e[66]!==O||e[67]!==We||e[68]!==G||e[69]!==q?(Ke=[...O.filter(Z=>!We.has(Rr("global",Z.id))),...G.filter(Z=>!We.has(Rr("project",Z.id)))].filter(Z=>bs([Z.title,Z.body],q)),e[66]=O,e[67]=We,e[68]=G,e[69]=q,e[70]=Ke):Ke=e[70];let ht;e[71]!==Je.length||e[72]!==St.length||e[73]!==Ve.length||e[74]!==Ke.length?(ht={notes:Tt,todos:mt,plans:jt,memory:Ke.length},e[71]=Je.length,e[72]=St.length,e[73]=Ve.length,e[74]=Ke.length,e[75]=ht):ht=e[75];const Qe=ht,ut=Ce(y2);let _t;e[76]!==s?.path?(_t=Z=>Z.agentMemoryViewedAt[ea("project",s?.path??null)]??0,e[76]=s?.path,e[77]=_t):_t=e[77];const Nn=Ce(_t),ss=ji(O,ut)+ji(G,Nn);let Rt;e[78]!==u||e[79]!==i||e[80]!==s?(Rt={projectRef:s,canCreateWorktree:u,onActionComplete:i},e[78]=u,e[79]=i,e[80]=s,e[81]=Rt):Rt=e[81];const st=Zy(Rt);let ws,Kt;e[82]!==s||e[83]!==d?(ws=()=>{if(!(!s||!d))return _h(s)},Kt=[s,d],e[82]=s,e[83]=d,e[84]=ws,e[85]=Kt):(ws=e[84],Kt=e[85]),y.useEffect(ws,Kt);const Ss=y.useRef(null);let Gt,Zt;e[86]!==m.error||e[87]!==m.loaded||e[88]!==p?(Gt=()=>{if(!m.error){Ss.current=null;return}Ss.current!==m.error&&(Ss.current=m.error,m.loaded||Y.error(p("rightSidebar.contextNotesTodo.toast.loadNotesFailed")))},Zt=[m.error,m.loaded,p],e[86]=m.error,e[87]=m.loaded,e[88]=p,e[89]=Gt,e[90]=Zt):(Gt=e[89],Zt=e[90]),y.useEffect(Gt,Zt);const fs=fe===null||fe.section!==te;let js,Wt;e[91]!==te||e[92]!==fs?(js=()=>{const Z=ze.current;if(!Z||!fs||(ze.current=null,Z.section!==te))return;const De=Ye.current;if(!De)return;De.scrollTop=Z.scrollTop;const bt=Array.from(De.querySelectorAll("[data-knowledge-entry-id]")).find(pd=>pd.dataset.knowledgeEntryId===Z.id);(bt&&bt.tabIndex>=0?bt:bt?.querySelector("button"))?.focus({preventScroll:!0})},Wt=[te,fs],e[91]=te,e[92]=fs,e[93]=js,e[94]=Wt):(js=e[93],Wt=e[94]),y.useLayoutEffect(js,Wt);let ps;e[95]===Symbol.for("react.memo_cache_sentinel")?(ps=()=>{ge(null)},e[95]=ps):ps=e[95];let Ns;e[96]!==h?(Ns=[h],e[96]=h,e[97]=Ns):Ns=e[97],y.useEffect(ps,Ns);let Xt,ms;e[98]!==te?(Xt=()=>{ge(Z=>Z&&Z.section!==te?null:Z)},ms=[te],e[98]=te,e[99]=Xt,e[100]=ms):(Xt=e[99],ms=e[100]),y.useEffect(Xt,ms);const ns=Ce(v2);let rs,V;e[101]!==te||e[102]!==ns||e[103]!==h?(rs=()=>{!ns||ns.projectContextId!==h||te!=="plans"||(Ce.getState().clearProjectKnowledgePlanRequest(),Pe("plans",ns.planId))},V=[te,Pe,ns,h],e[101]=te,e[102]=ns,e[103]=h,e[104]=rs,e[105]=V):(rs=e[104],V=e[105]),y.useEffect(rs,V);let me;e[106]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{ke()},e[106]=me):me=e[106];let qe;e[107]!==h?(qe=[ke,h],e[107]=h,e[108]=qe):qe=e[108],y.useEffect(me,qe);const He=y.useRef("");let Et,qt;e[109]!==te||e[110]!==Qe||e[111]!==pe||e[112]!==Fe?(Et=()=>{if(Fe===He.current||(He.current=Fe,!Fe||Qe[te]>0))return;const Z=Ti.find(De=>Qe[De]>0);Z&&pe(Z)},qt=[te,Qe,pe,Fe],e[109]=te,e[110]=Qe,e[111]=pe,e[112]=Fe,e[113]=Et,e[114]=qt):(Et=e[113],qt=e[114]),y.useEffect(Et,qt);let ft;e[115]!==s||e[116]!==b||e[117]!==p?(ft=(Z,De)=>{s&&b(s,Z,De).then(bt=>{bt||Y.error(p("rightSidebar.contextNotesTodo.toast.saveNotesFailed"))})},e[115]=s,e[116]=b,e[117]=p,e[118]=ft):ft=e[118];const Lt=ft;let Nt;e[119]!==p?(Nt=p("rightSidebar.contextNotesTodo.tabs.notes"),e[119]=p,e[120]=Nt):Nt=e[120];let gt;e[121]!==Qe.notes||e[122]!==Nt?(gt={id:"notes",icon:"sticky-note",label:Nt,count:Qe.notes,unseen:0},e[121]=Qe.notes,e[122]=Nt,e[123]=gt):gt=e[123];let kt;e[124]!==p?(kt=p("rightSidebar.contextNotesTodo.tabs.todos"),e[124]=p,e[125]=kt):kt=e[125];let xt;e[126]!==Qe.todos||e[127]!==kt?(xt={id:"todos",icon:"checkbox-circle",label:kt,count:Qe.todos,unseen:0},e[126]=Qe.todos,e[127]=kt,e[128]=xt):xt=e[128];let Qt;e[129]!==p?(Qt=p("rightSidebar.contextNotesTodo.tabs.plans"),e[129]=p,e[130]=Qt):Qt=e[130];let F;e[131]!==Qe.plans||e[132]!==Qt?(F={id:"plans",icon:"file-text",label:Qt,count:Qe.plans,unseen:0},e[131]=Qe.plans,e[132]=Qt,e[133]=F):F=e[133];let H;e[134]!==Qe.memory||e[135]!==ss||e[136]!==C||e[137]!==p?(H=C?[{id:"memory",icon:"brain-4",label:p("rightSidebar.contextNotesTodo.tabs.memory"),count:Qe.memory,unseen:ss}]:[],e[134]=Qe.memory,e[135]=ss,e[136]=C,e[137]=p,e[138]=H):H=e[138];let ye;e[139]!==gt||e[140]!==xt||e[141]!==F||e[142]!==H?(ye=[gt,xt,F,...H],e[139]=gt,e[140]=xt,e[141]=F,e[142]=H,e[143]=ye):ye=e[143];const Ee=ye;if(!s){let Z;e[144]!==c?(Z=ne("w-full min-w-0 p-3",c),e[144]=c,e[145]=Z):Z=e[145];let De;e[146]!==p?(De=p("rightSidebar.contextNotesTodo.empty.selectProject"),e[146]=p,e[147]=De):De=e[147];let bt;e[148]!==De?(bt=r.jsx("p",{className:"typography-meta text-muted-foreground",children:De}),e[148]=De,e[149]=bt):bt=e[149];let es;return e[150]!==Z||e[151]!==bt?(es=r.jsx("div",{className:Z,children:bt}),e[150]=Z,e[151]=bt,e[152]=es):es=e[152],es}let ve;e[153]!==te||e[154]!==Be?(ve=Be(te),e[153]=te,e[154]=Be,e[155]=ve):ve=e[155];const Se=ve!==null,ot=ue&&(J||!Se);let dt;if(e[156]!==o||e[157]!==s.path||e[158]!==p){const Z=o?.trim()||s.path.split("/").filter(Boolean).pop()||s.path;dt=p("rightSidebar.contextNotesTodo.search.placeholderInProject",{project:Z}),e[156]=o,e[157]=s.path,e[158]=p,e[159]=dt}else dt=e[159];const vt=dt;let $t;e[160]!==Ee||e[161]!==Fe.length?($t=Fe.length>0&&Ee.every(w2),e[160]=Ee,e[161]=Fe.length,e[162]=$t):$t=e[162];const Mt=$t;let hs;e[163]!==p?(hs=p("rightSidebar.contextNotesTodo.sections.label"),e[163]=p,e[164]=hs):hs=e[164];let ks;e[165]!==te||e[166]!==U||e[167]!==Ee||e[168]!==pe||e[169]!==p?(ks=Ee.map(Z=>{const De=te===Z.id;return r.jsxs("button",{type:"button",onClick:()=>pe(Z.id),"aria-current":De?"page":void 0,title:Z.label,className:ne("flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",De?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:text-foreground"),children:[r.jsx(B,{name:Z.icon,className:"h-3.5 w-3.5 flex-shrink-0"}),r.jsx("span",{className:ne("whitespace-nowrap typography-meta",!De&&(U?"hidden":"hidden @[22rem]/knowledge-sections:inline")),children:Z.label}),r.jsx("span",{className:"typography-micro opacity-70",children:Z.count}),Z.unseen>0?r.jsx("span",{className:"rounded-full bg-[var(--status-success)]/15 px-1 typography-micro font-medium leading-4 text-[var(--status-success-text)]",title:p("rightSidebar.contextNotesTodo.memory.unseenTitle",{count:Z.unseen}),"aria-label":p("rightSidebar.contextNotesTodo.memory.unseenTitle",{count:Z.unseen}),children:`+${Z.unseen}`}):null]},Z.id)}),e[165]=te,e[166]=U,e[167]=Ee,e[168]=pe,e[169]=p,e[170]=ks):ks=e[170];let Hs;e[171]!==hs||e[172]!==ks?(Hs=r.jsx("nav",{className:"@container/knowledge-sections flex min-w-0 flex-1 items-center gap-1 overflow-x-auto","aria-label":hs,children:ks}),e[171]=hs,e[172]=ks,e[173]=Hs):Hs=e[173];const Fr=ue&&"bg-interactive-selection text-interactive-selection-foreground";let Ys;e[174]!==Fr?(Ys=ne("h-7 w-7 flex-shrink-0 p-0",Fr),e[174]=Fr,e[175]=Ys):Ys=e[175];let Gn;e[176]===Symbol.for("react.memo_cache_sentinel")?(Gn=r.jsx(B,{name:"search",className:"h-3.5 w-3.5"}),e[176]=Gn):Gn=e[176];let Js;e[177]!==vt||e[178]!==ue||e[179]!==Ys||e[180]!==ae?(Js=r.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:ae,"aria-pressed":ue,className:Ys,title:vt,"aria-label":vt,children:Gn}),e[177]=vt,e[178]=ue,e[179]=Ys,e[180]=ae,e[181]=Js):Js=e[181];let Wn;e[182]!==Hs||e[183]!==Js?(Wn=r.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 pe-1",children:[Hs,Js]}),e[182]=Hs,e[183]=Js,e[184]=Wn):Wn=e[184];const qn=Wn;let Xs;e[185]!==N?(Xs=(Z,De)=>N("plan",Z,De),e[185]=N,e[186]=Xs):Xs=e[186];const Br=J?Ue:null,Vr=l??at;let Hn;e[187]!==m.plans||e[188]!==L||e[189]!==s||e[190]!==q||e[191]!==Xs||e[192]!==Br||e[193]!==Vr?(Hn=r.jsx(zy,{projectRef:s,plans:m.plans,query:q,pinnedPlanIds:L,onTogglePinned:Xs,selectedPlanId:Br,onOpenPlan:Vr}),e[187]=m.plans,e[188]=L,e[189]=s,e[190]=q,e[191]=Xs,e[192]=Br,e[193]=Vr,e[194]=Hn):Hn=e[194];const Yn=Hn;let Jn;e[195]!==s||e[196]!==p||e[197]!==d?(Jn=(Z,De)=>r.jsx(y.Suspense,{fallback:null,children:r.jsx(qh,{value:null,children:r.jsx(t2,{visible:d,leading:De?r.jsx(td,{label:p("rightSidebar.contextNotesTodo.plans.actions.back"),onClick:()=>ge(null)}):null,savedProjectPlan:{projectRef:s,planId:Z},onNavigatedToChat:()=>ge(null)})})}),e[195]=s,e[196]=p,e[197]=d,e[198]=Jn):Jn=e[198];const Xn=Jn;let Qs;e[199]!==c?(Qs=ne("flex h-full min-h-0 w-full min-w-0 flex-col",c),e[199]=c,e[200]=Qs):Qs=e[200];let Zs;e[201]!==f||e[202]!==qn?(Zs=f?r.jsx(zo,{children:qn}):r.jsx("div",{className:"flex flex-shrink-0 px-3 pt-2",children:qn}),e[201]=f,e[202]=qn,e[203]=Zs):Zs=e[203];let en;e[204]!==Mt||e[205]!==q||e[206]!==Le||e[207]!==vt||e[208]!==ot||e[209]!==J?(en=ot?r.jsx("div",{className:ne("pointer-events-none absolute top-2 z-20",J?"inset-s-3":"inset-e-3"),children:r.jsx(e2,{query:q,onQueryChange:oe,placeholder:vt,nothingFound:Mt,focusRequest:Le,onClose:ke})}):null,e[204]=Mt,e[205]=q,e[206]=Le,e[207]=vt,e[208]=ot,e[209]=J,e[210]=en):en=e[210];let tn;e[211]!==Se||e[212]!==J?(tn=ne("h-full min-w-0",J?"overflow-hidden":ne("p-3",Se?"overflow-hidden":"overflow-y-auto")),e[211]=Se,e[212]=J,e[213]=tn):tn=e[213];let sn;e[214]!==te||e[215]!==m.notes||e[216]!==it||e[217]!==Be||e[218]!==_||e[219]!==s||e[220]!==q||e[221]!==J||e[222]!==N?(sn=te==="notes"?r.jsx($y,{projectRef:s,notes:m.notes,disabled:it,query:q,pinnedNoteIds:_,onTogglePinned:(Z,De)=>N("note",Z,De),openNoteId:Be("notes"),onOpenNote:et,split:J}):null,e[214]=te,e[215]=m.notes,e[216]=it,e[217]=Be,e[218]=_,e[219]=s,e[220]=q,e[221]=J,e[222]=N,e[223]=sn):sn=e[223];let nn;e[224]!==te||e[225]!==u||e[226]!==Lt||e[227]!==it||e[228]!==q||e[229]!==st.sendToCurrentSession||e[230]!==st.sendToNewSession||e[231]!==st.sendToNewWorktreeSession||e[232]!==st.sendingTodoId||e[233]!==rt||e[234]!==he?(nn=te==="todos"?r.jsx("div",{className:ne(he&&"mx-auto max-w-3xl"),children:r.jsx(qy,{todos:rt,query:q,disabled:it,canCreateWorktree:u,sendingTodoId:st.sendingTodoId,onPersistTodos:Lt,onSendToCurrentSession:st.sendToCurrentSession,onSendToNewSession:st.sendToNewSession,onSendToNewWorktreeSession:st.sendToNewWorktreeSession})}):null,e[224]=te,e[225]=u,e[226]=Lt,e[227]=it,e[228]=q,e[229]=st.sendToCurrentSession,e[230]=st.sendToNewSession,e[231]=st.sendToNewWorktreeSession,e[232]=st.sendingTodoId,e[233]=rt,e[234]=he,e[235]=nn):nn=e[235];let rn;e[236]!==te||e[237]!==C||e[238]!==Be||e[239]!==s.path||e[240]!==q||e[241]!==J?(rn=te==="memory"&&C?r.jsx(gy,{projectPath:s.path,query:q,openMemoryId:Be("memory"),onOpenMemory:Ae,split:J}):null,e[236]=te,e[237]=C,e[238]=Be,e[239]=s.path,e[240]=q,e[241]=J,e[242]=rn):rn=e[242];let on;e[243]!==te||e[244]!==Ue||e[245]!==Xn||e[246]!==Yn||e[247]!==J||e[248]!==p?(on=te==="plans"?J?r.jsx(sa,{list:Yn,detail:Ue?Xn(Ue,!1):null,emptyLabel:p("rightSidebar.contextNotesTodo.plans.selectHint")}):Ue?Xn(Ue,!0):Yn:null,e[243]=te,e[244]=Ue,e[245]=Xn,e[246]=Yn,e[247]=J,e[248]=p,e[249]=on):on=e[249];let an;e[250]!==tn||e[251]!==sn||e[252]!==nn||e[253]!==rn||e[254]!==on?(an=r.jsxs("div",{ref:Ye,className:tn,children:[sn,nn,rn,on]}),e[250]=tn,e[251]=sn,e[252]=nn,e[253]=rn,e[254]=on,e[255]=an):an=e[255];let ln;e[256]!==en||e[257]!==an?(ln=r.jsxs("div",{className:"relative min-h-0 min-w-0 flex-1",children:[en,an]}),e[256]=en,e[257]=an,e[258]=ln):ln=e[258];const Ur=st.pendingSendTarget!==null;let cn;e[259]!==st?(cn=Z=>{Z||st.closeDialog()},e[259]=st,e[260]=cn):cn=e[260];const zr=st.pendingSendTarget?.kind??"session";let dn;e[261]!==s.path||e[262]!==st.confirmSend||e[263]!==st.isSubmitting||e[264]!==Ur||e[265]!==cn||e[266]!==zr?(dn=r.jsx(Lh,{open:Ur,onOpenChange:cn,target:zr,projectDirectory:s.path,submitting:st.isSubmitting,onConfirm:st.confirmSend}),e[261]=s.path,e[262]=st.confirmSend,e[263]=st.isSubmitting,e[264]=Ur,e[265]=cn,e[266]=zr,e[267]=dn):dn=e[267];let Qn;return e[268]!==Qs||e[269]!==Zs||e[270]!==ln||e[271]!==dn?(Qn=r.jsxs("div",{ref:X,className:Qs,children:[Zs,ln,dn]}),e[268]=Qs,e[269]=Zs,e[270]=ln,e[271]=dn,e[272]=Qn):Qn=e[272],Qn};function o2(t){return t.saveTodos}function a2(t){return t.currentSessionId}function i2(t){return t.currentSessionDirectory}function l2(t){return t.newSessionDraft}function c2(t){return t.setDraftProjectContextPin}function d2(t){return t.id}function u2(t){return t.id}function f2(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function p2(t){return t.disabled}function m2(t){return t.global}function h2(t){return t.isMobile}function g2(t){return t.projectContextTab}function x2(t){return t.setProjectContextTab}function b2(t){return t+1}function y2(t){return t.agentMemoryViewedAt[ea("global",null)]??0}function v2(t){return t.projectKnowledgePlanRequest}function w2(t){return t.count===0}const $0=t=>{const e=W.c(19),{visible:s,onActionComplete:n,onOpenPlan:o}=t,a=s===void 0?!0:s,i=Ar(S2),{t:l}=se(),c=Ln(j2),d=_e(N2),u=Vc(d),f=Jt(k2);let p;e[0]!==u||e[1]!==f?(p=u?f.find(w=>w.id===u.id)??null:null,e[0]=u,e[1]=f,e[2]=p):p=e[2];const g=p;let h;e:{if(!u){h=null;break e}if(u.id===xo){let S;e[3]!==l?(S=l("sessions.sidebar.activity.chatsTitle"),e[3]=l,e[4]=S):S=e[4],h=S;break e}let w;e[5]!==i||e[6]!==g?.label||e[7]!==u.path?(w=g?.label?.trim()||ho(u.path,i)||u.path,e[5]=i,e[6]=g?.label,e[7]=u.path,e[8]=w):w=e[8],h=w}const x=h;let m;e:{if(!u||u.id===xo){m=!1;break e}let w;e[9]!==c||e[10]!==u.path?(w=c.get(u.path)?.isGitRepo,e[9]=c,e[10]=u.path,e[11]=w):w=e[11],m=w===!0}const b=m;let v;return e[12]!==b||e[13]!==n||e[14]!==o||e[15]!==x||e[16]!==u||e[17]!==a?(v=r.jsx("div",{className:"h-full min-h-0 overflow-hidden bg-background",children:r.jsx(r2,{projectRef:u,visible:a,projectLabel:x,canCreateWorktree:b,onActionComplete:n,onOpenPlan:o})}),e[12]=b,e[13]=n,e[14]=o,e[15]=x,e[16]=u,e[17]=a,e[18]=v):v=e[18],v};function S2(t){return t.homeDirectory}function j2(t){return t.directories}function N2(t){return t.currentSessionDirectory}function k2(t){return t.projects}const C2=()=>{const t=W.c(2),e=_e(I2);let s;return t[0]!==e?(s=n=>tp(e,n.journey),t[0]=e,t[1]=s):s=t[1],ct(Lm(s))};function I2(t){return t.currentSessionId===null&&t.newSessionDraft?.open?t.newSessionDraft.pendingWorktreeRequestId??null:null}const T2=()=>{const t=W.c(5),{t:e}=se();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(Ft,{className:"h-4 w-4"}),t[0]=s):s=t[0];let n;t[1]!==e?(n=e("spaces.draft.preparing"),t[1]=e,t[2]=n):n=t[2];let o;return t[3]!==n?(o=r.jsxs("div",{className:"flex h-full items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[s,r.jsx("span",{children:n})]}),t[3]=n,t[4]=o):o=t[4],o};function R2(t,e=t.colors.surface.background){const{colors:s}=t,n=s.syntax.base;return{background:e,foreground:n.foreground,cursor:s.interactive.cursor,cursorAccent:e,selectionBackground:s.interactive.selection,selectionForeground:s.interactive.selectionForeground,selectionInactiveBackground:sp(s.interactive.selection,.31),black:s.surface.muted,red:s.status.error,green:s.status.success,yellow:s.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:s.status.error,brightGreen:s.status.success,brightYellow:s.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:s.surface.elevatedForeground}}const E2=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],dr=t=>{const e=t.trim(),s=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e)?.[1];if(s){const l=s.length<=4?s.slice(0,3).split("").map(c=>c+c).join(""):s.slice(0,6);return{r:Number.parseInt(l.slice(0,2),16),g:Number.parseInt(l.slice(2,4),16),b:Number.parseInt(l.slice(4,6),16)}}const n=/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})(?:\s*[,/]\s*[\d.]+)?\s*\)$/i.exec(e);if(!n)return null;const[o,a,i]=n.slice(1,4).map(Number);return[o,a,i].some(l=>l===void 0||l<0||l>255)?null:{r:o??0,g:a??0,b:i??0}};function Ri(t){const e=dr(t.background)??{r:0,g:0,b:0},s=dr(t.foreground)??{r:255,g:255,b:255};return{background:e,foreground:s,cursor:dr(t.cursor)??s,palette:E2.map(n=>dr(t[n])??s),selectionBackground:t.selectionBackground}}function D2(t,e){if(t.length===0)return{reset:e!==null,replay:!1,pending:[]};if(e===null)return{reset:!1,replay:!0,pending:t};let s=-1;for(let n=t.length-1;n>=0;n-=1){const o=t[n].id;if(o===e){s=n;break}if(o<e)break}return s<0?{reset:!0,replay:!0,pending:t}:{reset:!1,replay:!1,pending:t.slice(s+1)}}const P2=async(t,e)=>{const{GhosttyTerminalSurface:s}=await Es(async()=>{const{GhosttyTerminalSurface:n}=await import("./surface-B62hJ9SM.js");return{GhosttyTerminalSurface:n}},[]);return s.create(t,e)},A2=2e3,_2=t=>new Promise(e=>{const s=setTimeout(e,A2);rp(t).finally(()=>{clearTimeout(s),e()})}),Ei=4,L2=(t,e,s)=>{const n=t.ownerDocument.createElement("canvas").getContext("2d");if(!n||t.clientWidth<24||t.clientHeight<24)return null;n.font=`${s}px ${e}`;const o=n.measureText("M"),a=o.width,i=(o.actualBoundingBoxAscent||s*.8)+(o.actualBoundingBoxDescent||s*.2),l=Math.max(1,Math.round(s*1.35),Math.ceil(i));return a<1||l<1?null:{cols:Math.max(2,Math.floor((t.clientWidth-Ei*2)/a)),rows:Math.max(1,Math.floor((t.clientHeight-Ei*2)/l))}},id=y.forwardRef(({sessionKey:t,chunks:e,onInput:s,onResize:n,onProvisionalSize:o,theme:a,monoFont:i,fontFamily:l,fontSize:c,className:d,enableTouchScroll:u=!1,autoFocus:f=!0,isVisible:p=!0,createSurface:g=P2},h)=>{const{t:x}=se(),m=y.useRef(null),b=y.useRef(null),v=y.useRef(s),w=y.useRef(n),S=y.useRef(o),I=y.useRef(null),k=y.useRef(p),R=y.useRef({input:"",scrollbar:""}),[P,T]=y.useState(0),D=y.useRef(null),A=y.useRef(0),N=y.useRef(!1),[j,_]=y.useState(!1),[E,L]=y.useState("");v.current=s,w.current=n,S.current=o,k.current=p,R.current={input:x("terminalView.viewport.inputAria"),scrollbar:x("terminalView.viewport.scrollbarAria")},y.useLayoutEffect(()=>{const C=m.current;if(!C)return;const O=L2(C,l,c);O&&(S.current??w.current)(O.cols,O.rows)},[l,c]),y.useEffect(()=>{const C=m.current;if(!C)return;let O=!1,z=null;const G=a,U={family:l,size:c},K=i,X=!u;return(async()=>{if(await _2(K),O)return;let re;try{re=await g(C,{theme:Ri(G),font:U,get visible(){return k.current},labels:R.current,handleTouchPointer:X,onData:ee=>v.current(ee),onResize:(ee,xe)=>w.current(ee,xe),onLinkActivate:ee=>{Er(ee)},onContextMenu:ee=>{D.current=ee,L(z?.getSelection()??"")}})}catch(ee){console.error("[terminal] failed to initialize the terminal renderer",ee);return}if(O){re.dispose();return}z=re,b.current=re,re.setVisible(k.current),T(ee=>ee+1)})(),()=>{O=!0;const re=document.activeElement;re instanceof HTMLElement&&C.contains(re)&&(re.blur(),window.Capacitor?.getPlatform?.()==="android"&&Es(async()=>{const{Keyboard:xe}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:xe}},__vite__mapDeps([124,72])).then(({Keyboard:xe})=>xe.hide()).catch(()=>{})),z?.dispose(),z=null,b.current=null,I.current=null}},[g]),y.useEffect(()=>{b.current?.setTheme(Ri(a))},[a,P]),y.useEffect(()=>{b.current?.setFont({family:l,size:c})},[l,c,P]),y.useEffect(()=>{b.current?.setVisible(p)},[p,P]),y.useEffect(()=>(_(!1),D.current=null,A.current+=1,()=>{A.current+=1}),[t,p,P]);const $=async()=>{if(E)try{(await Lo(E)).ok||hr.error(x("terminalView.toast.copyFailed"))}catch{hr.error(x("terminalView.toast.copyFailed"))}},M=y.useCallback(async C=>{const O=b.current;if(!O||!k.current)return;const z=A.current,G=()=>b.current===O&&k.current&&A.current===z;try{await O.pasteFromClipboard(np,G)}catch{G()&&hr.error(C)}},[]);return y.useEffect(()=>{const C=b.current;if(!C)return;const{reset:O,replay:z,pending:G}=D2(e,I.current);if(z){const[U,...K]=G;C.resetAndWrite(U?U.replayData??U.data:"",U?.size);const X=K.map(re=>re.replayData??re.data).join("");X&&C.write(X)}else O?C.resetAndWrite(""):G.length>0&&C.write(G.map(U=>U.data).join(""));I.current=e.at(-1)?.id??null},[e,P]),y.useEffect(()=>{if(!f||!p)return;const C=requestAnimationFrame(()=>b.current?.focus());return()=>cancelAnimationFrame(C)},[f,p,P,t]),y.useEffect(()=>{const C=m.current,O=b.current;if(!u||!C||!O)return;let z=null,G=null,U="idle",K=0,X=0,re=0,ee=0;const xe=Math.max(12,Math.round(c*1.35)),ce=()=>{window.Capacitor?.getPlatform?.()==="android"&&Es(async()=>{const{Keyboard:q}=await import("./vendor-capacitor-keyboard-CYccoJjr.js");return{Keyboard:q}},__vite__mapDeps([124,72])).then(({Keyboard:q})=>q.show()).catch(()=>{})},he=()=>{G&&(clearTimeout(G),G=null)},ie=J=>{J.pointerType!=="touch"||z!==null||(z=J.pointerId,U="pending",K=J.clientX,X=J.clientY,re=J.clientY,ee=0,C.setPointerCapture(J.pointerId),G=setTimeout(()=>{G=null,!(z!==J.pointerId||U!=="pending")&&O.selectWordAt(K,X)&&(U="selecting")},350))},pe=J=>{if(z!==J.pointerId)return;if(U==="selecting"){O.extendSelectionTo(J.clientX,J.clientY),J.cancelable&&J.preventDefault();return}if(U==="pending"){if(Math.hypot(J.clientX-K,J.clientY-X)<8)return;he(),U="scrolling"}if(U!=="scrolling")return;const q=re-J.clientY;re=J.clientY,ee+=q;const oe=Math.trunc(ee/xe);oe&&(O.scrollLines(oe),ee-=oe*xe),J.cancelable&&J.preventDefault()},le=(J,q)=>{if(z!==J.pointerId)return;const oe=q&&U==="pending";he(),C.hasPointerCapture(J.pointerId)&&C.releasePointerCapture(J.pointerId),z=null,U="idle",oe&&(O.focus(),ce())},de=J=>le(J,!0),te=J=>le(J,!1);return C.addEventListener("pointerdown",ie),C.addEventListener("pointermove",pe,{passive:!1}),C.addEventListener("pointerup",de),C.addEventListener("pointercancel",te),()=>{he(),C.removeEventListener("pointerdown",ie),C.removeEventListener("pointermove",pe),C.removeEventListener("pointerup",de),C.removeEventListener("pointercancel",te)}},[u,c,P]),y.useImperativeHandle(h,()=>({focus:()=>b.current?.focus(),fit:()=>{const C=b.current;C&&(C.fit(),C.refresh())},getSelection:()=>{const C=b.current,O=C?.getSelectionPosition(),z=C?.getSelection()??"";return!O||!z.trim()?null:{text:z,startLine:O.start.y+1,endLine:O.end.y+1}},pasteClipboard:()=>M(x("terminalView.toast.pasteFailedTouch"))}),[M,x]),r.jsxs(qi,{disabled:u||!p,open:j&&p,onOpenChange:(C,O)=>{N.current=!C&&(O.reason==="item-press"||O.reason==="escape-key"),_(C)},children:[r.jsx(Gi,{onContextMenu:C=>{C.nativeEvent!==D.current&&C.preventBaseUIHandler(),D.current=null},onTouchStart:C=>C.preventBaseUIHandler(),render:r.jsx("div",{ref:m,"data-terminal-owner":"main",className:ne("terminal-viewport-container relative h-full w-full overflow-hidden touch-none",d)})}),r.jsxs(Wi,{finalFocus:()=>(N.current&&k.current&&b.current?.focus(),!1),children:[r.jsx(yn,{disabled:!E,onClick:()=>{$()},children:x("terminalView.actions.copy")}),r.jsx(yn,{onClick:()=>{M(x("terminalView.toast.pasteFailed"))},children:x("terminalView.actions.paste")})]})]})});id.displayName="TerminalViewport";const $2=t=>{const e=W.c(46),{currentLabel:s,onRename:n,onClose:o}=t,{t:a}=se(),[i,l]=y.useState("");let c,d;e[0]!==s?(c=()=>{s!==null&&l(s)},d=[s],e[0]=s,e[1]=c,e[2]=d):(c=e[1],d=e[2]),y.useEffect(c,d);let u;e[3]!==o||e[4]!==n||e[5]!==i?(u=()=>{const j=i.trim();j&&n(j),o()},e[3]=o,e[4]=n,e[5]=i,e[6]=u):u=e[6];const f=u,p=s!==null;let g;e[7]!==o?(g=j=>{j||o()},e[7]=o,e[8]=g):g=e[8];let h;e[9]!==a?(h=a("terminalView.tabs.renameDialog.title"),e[9]=a,e[10]=h):h=e[10];let x;e[11]!==h?(x=r.jsx(vs,{children:r.jsx(us,{children:h})}),e[11]=h,e[12]=x):x=e[12];let m;e[13]===Symbol.for("react.memo_cache_sentinel")?(m=j=>l(j.target.value),e[13]=m):m=e[13];let b;e[14]!==a?(b=a("terminalView.tabs.renameDialog.placeholder"),e[14]=a,e[15]=b):b=e[15];let v;e[16]!==f?(v=j=>{j.key==="Enter"&&!Vn(j)&&(j.preventDefault(),f())},e[16]=f,e[17]=v):v=e[17];let w;e[18]!==v||e[19]!==b||e[20]!==i?(w=r.jsx(It,{autoFocus:!0,value:i,onChange:m,onFocus:M2,placeholder:b,onKeyDown:v}),e[18]=v,e[19]=b,e[20]=i,e[21]=w):w=e[21];let S;e[22]!==a?(S=a("terminalView.tabs.renameDialog.cancel"),e[22]=a,e[23]=S):S=e[23];let I;e[24]!==o||e[25]!==S?(I=r.jsx(Q,{size:"sm",variant:"ghost",onClick:o,children:S}),e[24]=o,e[25]=S,e[26]=I):I=e[26];let k;e[27]!==i?(k=i.trim(),e[27]=i,e[28]=k):k=e[28];const R=!k;let P;e[29]!==a?(P=a("terminalView.tabs.renameDialog.save"),e[29]=a,e[30]=P):P=e[30];let T;e[31]!==f||e[32]!==R||e[33]!==P?(T=r.jsx(Q,{size:"sm",onClick:f,disabled:R,children:P}),e[31]=f,e[32]=R,e[33]=P,e[34]=T):T=e[34];let D;e[35]!==I||e[36]!==T?(D=r.jsxs(Gs,{children:[I,T]}),e[35]=I,e[36]=T,e[37]=D):D=e[37];let A;e[38]!==w||e[39]!==D||e[40]!==x?(A=r.jsxs(ds,{className:"max-w-sm",children:[x,w,D]}),e[38]=w,e[39]=D,e[40]=x,e[41]=A):A=e[41];let N;return e[42]!==A||e[43]!==p||e[44]!==g?(N=r.jsx(cs,{open:p,onOpenChange:g,children:A}),e[42]=A,e[43]=p,e[44]=g,e[45]=N):N=e[45],N};function M2(t){return t.currentTarget.select()}const O2="\x1B",ia=new RegExp(`${O2}\\[[0-9;?]*[ -/]*[@-~]`,"g"),F2=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,B2=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,V2=/Serving HTTP on .*? port (\d{2,5})/i,U2=/^--\s+Using port (\d{2,5})\b/,z2=/^\s*->\s+(https?:\/\/[^\s<>'"`]+)\s*$/,la=new Set(["localhost","127.0.0.1","0.0.0.0","::1","::","[::1]","[::]"]),K2=new Set([".",",",";",":","!","?"]),ca=t=>{let e=t;for(;e.length>0;){const s=e[e.length-1];if(s===")"||s==="]"||s==="}"||s===">"){const n=s===")"?"(":s==="]"?"[":s==="}"?"{":"<",o=e.slice(0,-1),a=(o.match(new RegExp(`\\${n}`,"g"))||[]).length,i=(o.match(new RegExp(`\\${s}`,"g"))||[]).length;if(a>i)break;e=o;continue}if(K2.has(s)){e=e.slice(0,-1);continue}break}return e},Do=t=>{let e=ca(t);return e=e.replace("0.0.0.0","127.0.0.1"),e=e.replace("[::1]","127.0.0.1"),e=e.replace("[::]","127.0.0.1"),e},ld=t=>{try{const e=new URL(t);if(!la.has(e.hostname.toLowerCase()))return null;const s=Number.parseInt(e.port,10);return Number.isFinite(s)?s:null}catch{return null}},G2=t=>{try{return la.has(new URL(t).hostname.toLowerCase())}catch{return!1}},cd=t=>{const e=[];for(const s of t.replace(ia,"").split(`
|
|
66
66
|
`)){const n=Number.parseInt(U2.exec(s.trim())?.[1]??"",10);Number.isFinite(n)&&n>0&&n<=65535&&!e.includes(n)&&e.push(n)}return e},W2=(t,{proxiedPorts:e=[],namedAddressesReachable:s=!0}={})=>{if(!t)return[];const n=t.replace(ia,""),o=new Set(s?[...e,...cd(n)]:[]),a=[],i=new Set,l=d=>{if(i.has(d))return;const u=ld(d);u!==null&&o.has(u)||(i.add(d),a.push(d))},c=n.match(V2);if(c?.[1]){const d=Number.parseInt(c[1],10);Number.isFinite(d)&&d>0&&d<=65535&&l(`http://127.0.0.1:${d}/`)}for(const d of n.split(`
|
|
67
67
|
`)){const u=z2.exec(d)?.[1];if(u){s&&l(ca(u));continue}if(!B2.test(d))continue;const f=Array.from(d.matchAll(F2));if(f.length===0)continue;const p=f.find(g=>{try{return!!new URL(Do(g[1])).port}catch{return!1}});l(Do((p??f[0])[1]))}return a},dd=(t,e={})=>W2(t,e)[0]??null,q2=async(t,e=1500)=>{if(!t||typeof window>"u")return!1;let s;try{s=new URL(t)}catch{return!1}if(s.protocol!=="http:"&&s.protocol!=="https:")return!1;if(!G2(s.toString()))return!0;const n=new AbortController,o=window.setTimeout(()=>n.abort(),e);try{const a=await wt("/api/system/probe-url",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:s.toString()}),cache:"no-store",signal:n.signal});return a.ok?(await a.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(o)}},H2=/https?:\/\/[^\s<>'"`]+/gi,Y2=/^(?:10\.\d+|172\.(?:1[6-9]|2\d|3[01])|192\.168|169\.254)\.\d+\.\d+$/,J2=t=>{const e=t.toLowerCase().replace(/^\[|\]$/g,"");return la.has(e)||e.endsWith(".localhost")||e.endsWith(".local")||Y2.test(e)||/^f[cd][0-9a-f]{2}:/.test(e)||e.startsWith("fe80:")},M0=(t,{requireAnnounced:e=!1,...s}={})=>{const n=dd(t,s),o=s.namedAddressesReachable===!1?[]:s.proxiedPorts??[];if(n)return n;if(e)return null;const a=String(t||"").replace(ia,""),i=[];for(const d of a.match(H2)??[])try{const u=new URL(ca(d)),f=ld(u.toString());if(!J2(u.hostname))continue;u.port&&!(f!==null&&o.includes(f))&&i.push(u)}catch{}if(i.length===0)return null;const l=d=>{const u=d.hostname.toLowerCase();return(u==="localhost"||u==="127.0.0.1"||u==="0.0.0.0"||u==="::1"?50:0)-(d.search||d.hash?10:0)};let c=i[0];for(const d of i.slice(1))l(d)>l(c)&&(c=d);return Do(c.toString())},Po=new Map,Mr=new Map,Us=new Map,zs=new Set,X2=(t,e)=>t?`/api/dev-tunnel?port=${e}&directory=${encodeURIComponent(gm(t))}`:`/api/dev-tunnel?port=${e}`,Q2=async(t,e,s)=>{if(!Ea()){zs.delete(t),mn(t,{type:"close"});return}if(await pm(Ks()),!zs.has(t)||!Ea())return;const n=mm().websocket(X2(s,e)),o=hm(n);Us.set(t,o),o.binaryType="arraybuffer",o.onopen=()=>mn(t,{type:"ready"}),o.onmessage=a=>mn(t,{type:"data",data:a.data instanceof ArrayBuffer?a.data:new TextEncoder().encode(a.data)}),o.onerror=()=>mn(t,{type:"close"}),o.onclose=()=>{zs.delete(t),Us.delete(t),mn(t,{type:"close"})}};op(({connectionId:t,remotePort:e,spaceId:s,message:n})=>{switch(n.type){case"data":{const o=Us.get(t);o&&n.data&&o.send(n.data);return}case"close":zs.delete(t),Us.get(t)?.close(),Us.delete(t);return;case"connect":zs.add(t),Q2(t,e,s).catch(()=>{zs.delete(t),mn(t,{type:"close"})})}});const jn=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Z2=()=>globalThis.window?.__OPENCHAMBER_LOCAL_ORIGIN__??"",Or=t=>{if(!t)return!1;try{const e=new URL(t,typeof window<"u"?window.location.href:void 0),s=typeof window<"u"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"";return s&&e.origin===s?!1:jn()&&fm()?!0:!Lr(e.toString())}catch{return!1}},ev=(t,e)=>!t||jn()||!Lr(t)||!globalThis.window?!1:wn(e)!==null?!0:Or(Ks()||globalThis.window.location.href),O0=t=>wn(t)!==null&&!jn(),F0=(t,e)=>ev(t,e)?"":t,tv=()=>jn()&&Or(Ks()),ud=t=>{try{const e=new URL(t),s=Number.parseInt(e.port||(e.protocol==="https:"?"443":"80"),10);return Number.isInteger(s)&&s>0?s:0}catch{return 0}},Di=(t,e)=>{try{const s=new URL(t);return s.protocol="http:",s.hostname=Ll,s.port=String(e),s.toString()}catch{return t}},Pi=(t,e)=>{try{Mr.set(e,new URL(t).origin)}catch{}};class ro extends Error{constructor(e){super(e),this.name="DevTunnelUnavailableError"}}const B0=async(t,e)=>{if(!t||!jn()||!Lr(t))return t;const s=wn(e),n=Ks()||(s!==null?Z2():"");if(s===null&&!Or(n))return t;const o=ud(t);if(!o)return t;const a=`${n}|${s??""}|${o}`,i=Po.get(a);if(i)return Pi(t,i),Di(t,i);try{const l=await kl("desktop_dev_tunnel_open",{baseUrl:n,port:o,spaceId:s,relay:ym(),targetKey:be(),clientToken:bm(),requestHeaders:xm()});if(!l||!Number.isInteger(l.localPort)||l.localPort<=0)throw new ro(t);return Po.set(a,l.localPort),Pi(t,l.localPort),Di(t,l.localPort)}catch(l){throw l instanceof ro?l:new ro(t)}},V0=(t,e)=>{if(!t||!jn()||!Lr(t)||wn(e)===null&&!Or(Ks()))return!1;const s=ud(t);return s>0&&!Mr.has(s)},U0=t=>{if(!t)return t;try{const e=new URL(t);if(e.hostname!==Ll&&e.hostname!=="127.0.0.1")return t;const s=Mr.get(Number.parseInt(e.port||"0",10));return s?`${s}${e.pathname}${e.search}${e.hash}`:t}catch{return t}},sv=()=>{Po.clear(),Mr.clear(),zs.clear();for(const t of Us.values())t.close();Us.clear(),kl("desktop_relay_dev_tunnel_close_all").catch(()=>{})};typeof window<"u"&&$s(sv);const nv={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},rv=(t,e)=>{if(e&&t.startsWith("arrow-")){const s=e==="ctrl"?"5":"3",n={"arrow-up":"A","arrow-down":"B","arrow-right":"C","arrow-left":"D"}[t];return`\x1B[1;${s}${n}`}return nv[t]},fd=t=>{const e=t[0]?.toUpperCase();return!e||e<"A"||e>"Z"?null:String.fromCharCode(e.charCodeAt(0)&31)},ov=(t,e)=>t&&(e==="ctrl"?fd(t)??t:t.length===1&&t!=="\x1B"?`\x1B${t}`:t),av="COMMAND_MODE_UNSUPPORTED",iv="PROJECT_ACTION_RUN_CANCELLED",lv="PROJECT_ACTION_PURPOSE_UNSUPPORTED",cv=t=>new Error(t),dv=async(t,e)=>{try{await t.close(e)}catch{}},oo=async(t,e,s,n)=>{throw e.sessionId===s&&await dv(t,e.sessionId),cv(n)},uv=t=>{const e=t.trim().replace(/\r\n|\r/g,`
|
|
68
68
|
`);let s="";for(let n=0;n<e.length;n+=1){const o=e.charCodeAt(n);o>=0&&o<=8||o===11||o===12||o>=14&&o<=31||o===127||(s+=e[n])}return s},fv=t=>t.mode==="command",pv=t=>t?.type==="project-action",mv=(t,e)=>pv(t)&&t.actionId===e&&t.executionId.trim().length>0,z0=async({terminal:t,createOptions:e,command:s,isRunStillExpected:n,purpose:o})=>{const a=await t.createSession({...e,sessionId:o.executionId,mode:"command",command:uv(s),purpose:o});return fv(a)||await oo(t,a,o.executionId,av),mv(a.purpose,o.actionId)||await oo(t,a,o.executionId,lv),n()||await oo(t,a,o.executionId,iv),a},hv=(t,e,s)=>new Promise(n=>{let o=!1,a=null,i=null;const l=c=>{o||(o=!0,i&&clearTimeout(i),a?.close(),n(c))};a=t.connect(e,{onEvent:c=>{(c.type==="exit"||c.type==="snapshot"&&c.status==="exited")&&l(!0)},onError:(c,d)=>{d&&l(!0)}}),o?a.close():i=setTimeout(()=>l(!1),s)}),K0=async({terminal:t,sessionId:e,isExecutionStillCurrent:s,markStopping:n,restoreRunning:o,clearSession:a,finalizeExit:i,timeoutMs:l=1e3})=>{n();const c=hv(t,e,l);try{s()&&await t.sendInput(e,"")}catch{}const d=await c;if(s()){if(!d){let u=!1;if(t.forceKill)try{s()&&await t.forceKill({sessionId:e})}catch{u=!0}else try{s()&&await t.close(e)}catch{u=!0}if(!s())return;if(u){o();return}a()}s()&&i()}},ao=new WeakMap,gv=(t,e,s={})=>{if(!t.listSessions)return Promise.resolve(null);const n=Fo(e),o=be(),a=`${o}\0${n}`;let i=ao.get(t);i||(i=new Map,ao.set(t,i));const l=i.get(a);if(l)return l;const c=s.captureStartedActionMutationRevisions?.(n)??new Map,d=t.listSessions(n).then(u=>o===be()?{sessions:u,startedActionMutationRevisions:c}:null).catch(()=>null).finally(()=>{i.get(a)===d&&(i.delete(a),i.size===0&&ao.delete(t))});return i.set(a,d),d},xv=t=>{const e=new Map;for(const s of t){const n=Fo(s.cwd),o=e.get(n);o?o.push(s):e.set(n,[s])}return e},bv=5e3,io=new WeakMap,yv=(t,e,s,n)=>{if(!t.listSessions)return()=>{};const o=Fo(e);let a=io.get(t);if(!a){const l=new Map;let c=!1,d=!1,u=!1,f=!1,p=null,g=0;const h=()=>document.visibilityState!=="hidden"&&navigator.onLine!==!1,x=()=>{p!==null&&clearTimeout(p),p=null},m=()=>{if(x(),!(c||!h())){if(d){u=!0;return}f||(f=!0,queueMicrotask(()=>{if(f=!1,c||!h())return;d=!0,u=!1;const w=g,S=be(),I=new Map(l);gv(t,"",{captureStartedActionMutationRevisions:()=>{const k=new Map;for(const[R,P]of I)for(const[T,D]of P.capture(R))k.set(T,D);return k}}).then(k=>{if(c||g!==w||S!==be()||!k)return;const R=xv(k.sessions);for(const[P,T]of I){if(l.get(P)!==T)continue;const D=P?R.get(P)??[]:k.sessions;for(const A of T.listeners)A({...k,sessions:D})}}).finally(()=>{d=!1,!(c||!h())&&(u?m():p=setTimeout(m,bv))})}))}},b=()=>{g+=1,m()};window.addEventListener("focus",m),window.addEventListener("online",m),window.addEventListener("offline",x),document.addEventListener("visibilitychange",m);const v=$s(b);a={scopes:l,refresh:m,close:()=>{c=!0,x(),window.removeEventListener("focus",m),window.removeEventListener("online",m),window.removeEventListener("offline",x),document.removeEventListener("visibilitychange",m),v()}},io.set(t,a)}let i=a.scopes.get(o);return i||(i={listeners:new Set,capture:s},a.scopes.set(o,i),a.refresh()),i.listeners.add(n),()=>{i.listeners.delete(n),!(i.listeners.size>0)&&(a.scopes.delete(o),!(a.scopes.size>0)&&(a.close(),io.delete(t)))}},vv=y.createContext(null),wv=()=>y.useContext(vv),Sv=y.createContext(!0),jv=()=>y.useContext(Sv),Nv=t=>t==="file",G0=(t,e,s)=>e||t&&Nv(s),kv=[{zone:"left",icon:"layout-left",labelKey:"contextPanel.zone.moveLeft"},{zone:"bottom",icon:"layout-bottom",labelKey:"contextPanel.zone.moveBottom"},{zone:"right",icon:"layout-right",labelKey:"contextPanel.zone.moveRight"}],Cv=t=>{const e=W.c(15),{mode:s}=t,{t:n}=se();let o;e[0]!==s?(o=d=>vm(d.contextSurfaceZones,s),e[0]=s,e[1]=o):o=e[1];const a=Ce(o),i=Ce(Iv);let l;if(e[2]!==a||e[3]!==s||e[4]!==i||e[5]!==n){let d;e[7]!==a?(d=f=>f.zone!==a,e[7]=a,e[8]=d):d=e[8];let u;e[9]!==s||e[10]!==i||e[11]!==n?(u=f=>r.jsxs(yn,{onClick:()=>i(s,f.zone),children:[r.jsx(B,{name:f.icon,className:"me-2 size-4"}),n(f.labelKey)]},f.zone),e[9]=s,e[10]=i,e[11]=n,e[12]=u):u=e[12],l=kv.filter(d).map(u),e[2]=a,e[3]=s,e[4]=i,e[5]=n,e[6]=l}else l=e[6];let c;return e[13]!==l?(c=r.jsx(r.Fragment,{children:l}),e[13]=l,e[14]=c):c=e[14],c};function Iv(t){return t.moveContextSurfaceToZone}const Ai={cols:80,rows:24},Tv=t=>{const e=W.c(25),{directory:s,tabId:n,isActive:o,isTerminalVisible:a,registerController:i,onInput:l,onResize:c,onProvisionalSize:d,theme:u,monoFont:f,fontFamily:p,fontSize:g,enableTouchScroll:h}=t;let x;e[0]!==s||e[1]!==n?(x=T=>T.getBuffer(s,n).chunks,e[0]=s,e[1]=n,e[2]=x):x=e[2];const m=Ze(x),b=`${s}::${n}`,v=!o&&"hidden";let w;e[3]!==v?(w=ne("h-full w-full",v),e[3]=v,e[4]=w):w=e[4];let S;e[5]!==i||e[6]!==n?(S=T=>i(n,T),e[5]=i,e[6]=n,e[7]=S):S=e[7];const I=a&&o,k=a&&o;let R;e[8]!==m||e[9]!==h||e[10]!==p||e[11]!==g||e[12]!==f||e[13]!==l||e[14]!==d||e[15]!==c||e[16]!==S||e[17]!==I||e[18]!==k||e[19]!==u||e[20]!==b?(R=r.jsx(id,{ref:S,sessionKey:b,chunks:m,onInput:l,onResize:c,onProvisionalSize:d,theme:u,monoFont:f,fontFamily:p,fontSize:g,enableTouchScroll:h,autoFocus:I,isVisible:k}),e[8]=m,e[9]=h,e[10]=p,e[11]=g,e[12]=f,e[13]=l,e[14]=d,e[15]=c,e[16]=S,e[17]=I,e[18]=k,e[19]=u,e[20]=b,e[21]=R):R=e[21];let P;return e[22]!==w||e[23]!==R?(P=r.jsx("div",{className:w,children:R}),e[22]=w,e[23]=R,e[24]=P):P=e[24],P},Rv=t=>Hi.find(s=>s.key===t)?.Icon??"terminal",Ev=t=>{const e=W.c(3),{iconName:s,active:n}=t;let o;return e[0]!==n||e[1]!==s?(o=n?r.jsx(Ft,{className:"h-4 w-4 text-muted-foreground"}):r.jsx(B,{name:s,className:"h-4 w-4"}),e[0]=n,e[1]=s,e[2]=o):o=e[2],o},W0=({visible:t,directory:e,onLastTabClosed:s})=>{const{t:n}=se(),{terminal:o,runtime:a}=yt(),{currentTheme:i}=Qi(),l=ap().background,c=y.useRef({themeMode:"dark",terminalBackground:"",terminalForeground:""});c.current={themeMode:i.metadata.variant==="light"?"light":"dark",terminalBackground:l,terminalForeground:i.colors.syntax.base.foreground};const{monoFont:d}=ip(),u=Ce(F=>F.terminalFontSize),f=Ce(F=>F.terminalShell),p=Ce(F=>F.terminalLoginShells.includes(F.terminalShell)),{isMobile:g,isTablet:h,hasTouchOnlyPointer:x}=On(),m=g||h,b=Uo(),v=(m||x)&&a.platform==="web",w=a.platform!=="vscode",S=Ce(F=>F.showTerminalQuickKeysOnDesktop),I=m||S,k=_e(F=>F.currentSessionId),R=_e(F=>F.newSessionDraft),P=k!==null||R?.open===!0,T=vl()??null,D=C2(),A=lp(D,T),N=e??null,j=N||A,_=N!==null,E=Ze(F=>j?F.getDirectoryState(j):void 0),L=Ze(F=>F.hasHydrated),$=Ze(F=>F.ensureDirectory),M=Ze(F=>F.createTab),C=Ze(F=>F.setActiveTab),O=Ze(F=>F.closeTab),z=Ze(F=>F.setTabLabel),G=Ze(F=>F.moveTab),U=Ze(F=>F.setTabSessionId),K=Ze(F=>F.reconcileServerSessions),X=Ze(F=>F.captureStartedActionMutationRevisions),re=Ze(F=>F.setTabLifecycle),ee=Ze(F=>F.setConnecting),xe=Ze(F=>F.appendToBuffer),ce=Ze(F=>F.replaceBuffer),he=Ze(F=>F.setTabPreviewUrl),ie=wl(F=>F.addDraft),pe=Ce(F=>F.openContextPreview),le=y.useMemo(()=>E?w?E.activeTabId??E.tabs[0]?.id??null:E.tabs[0]?.id??null:null,[E,w]),de=y.useMemo(()=>{if(E)return le?E.tabs.find(F=>F.id===le)??E.tabs[0]:E.tabs[0]},[E,le]),te=y.useMemo(()=>(E?.tabs??[]).map(F=>({icon:r.jsx(Ev,{iconName:Rv(F.iconKey),active:F.purpose.type==="project-action"&&wm.has(F.lifecycle)}),id:F.id,label:F.label,title:F.label,closeLabel:n("terminalView.tabs.closeTabTitle")})),[E?.tabs,n]),J=de?.terminalSessionId??null,q=de?.lifecycle??"idle",oe=de?.purpose.type==="project-action",ue=de?.isConnecting??!1,Ie=de?.previewUrl??null,[Le,we]=y.useState(null),[$e,ke]=y.useState(!1),[Te,ae]=y.useState(!1),[fe,ge]=y.useState(null),[Oe,Be]=y.useState(!1),Xe=y.useRef(null),Ue=y.useRef(null),Ye=y.useRef(le),ze=y.useRef(J),Me=y.useRef(j),Pe=y.useRef(null),Ge=y.useRef(new Map),et=y.useRef(null),tt=y.useRef(null),Ae=y.useRef(!1),Re=y.useRef(new Set),at=y.useRef(""),Ne=y.useRef(new Set),Fe=y.useRef(0),pt=y.useRef([]),rt=y.useCallback(()=>{at.current="",pt.current=[],Ne.current.clear(),Fe.current+=1},[]),it=y.useCallback(()=>{v||typeof document<"u"&&!document.hasFocus()||Pe.current?.focus()},[v]),We=y.useCallback(()=>{v||Pe.current?.focus()},[v]),Je=t??!1;Ae.current=Je;const[Tt,St]=y.useState(Je);y.useEffect(()=>{Je&&St(!0)},[Je]),y.useEffect(()=>{ze.current=J},[J]),y.useEffect(()=>{!J||!o.updateAppearance||o.updateAppearance(J,c.current,j).catch(()=>{})},[l,i.colors.syntax.base.foreground,i.metadata.variant,o,j,J]),y.useEffect(()=>{Ye.current=le,rt()},[le,rt]),y.useLayoutEffect(()=>{Pe.current=le?Ge.current.get(le)??null:null},[le]);const mt=y.useCallback((F,H)=>{H?Ge.current.set(F,H):Ge.current.delete(F),F===Ye.current&&(Pe.current=H)},[]);y.useEffect(()=>{Me.current=j},[j]),y.useEffect(()=>{if(!(!L||!j||!Je))return yv(o,j,X,F=>{K(j,F.sessions,{startedActionMutationRevisions:F.startedActionMutationRevisions})})},[X,Je,L,j,o,K]),y.useEffect(()=>{!I&&fe!==null&&ge(null)},[I,fe,ge]),y.useEffect(()=>{!J&&fe!==null&&ge(null)},[J,fe,ge]);const Ve=y.useCallback(()=>{Xe.current?.(),Xe.current=null,Ue.current=null,ae(!1)},[]);y.useEffect(()=>()=>{Ve(),ze.current=null},[Ve]);const jt=y.useCallback((F,H,ye)=>{if(!ye)return;const Ee=`${at.current}${ye}`.replace(/\r\n|\r/g,`
|