@vantran-se/openchamber-web 1.24.3 → 1.24.4
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/{CodeMirrorCommentWidgets-BjJHrzmU.js → CodeMirrorCommentWidgets-B4a0JkUz.js} +1 -1
- package/dist/assets/{DiffView-COVQhWGd.js → DiffView-B2CD9wC8.js} +1 -1
- package/dist/assets/{FilesView-B1V5JxFX.js → FilesView-C4vMFclc.js} +1 -1
- package/dist/assets/{GitView-CDOJy5Ay.js → GitView-Byu2DY7s.js} +1 -1
- package/dist/assets/{GuestAttachDialog-D3S0Rjic.js → GuestAttachDialog-B808E0-d.js} +1 -1
- package/dist/assets/{JsonTreeView-D0C9nU7K.js → JsonTreeView-VW_7czo3.js} +1 -1
- package/dist/assets/{LinearIssuesView-D7FKg1XJ.js → LinearIssuesView-EzGNCGrd.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-BrFjAVEf.js → MarkdownImageGallery-B2YUDFaB.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DWepTafh.js → MarkdownRendererImpl-B4ikIzR3.js} +1 -1
- package/dist/assets/{OnboardingScreen-Dyxxiqdt.js → OnboardingScreen-CQHBSTEi.js} +1 -1
- package/dist/assets/{PatchDiff-DnEhjXcC.js → PatchDiff-DCjGhlYV.js} +1 -1
- package/dist/assets/{PierreDiffViewer-DyxZVVVR.js → PierreDiffViewer-CEDZNkU2.js} +1 -1
- package/dist/assets/{PlanView-LW2z_EAP.js → PlanView-D3x-pTkZ.js} +1 -1
- package/dist/assets/{PluginPane-B4tKno2h.js → PluginPane-DEcgDQ9h.js} +1 -1
- package/dist/assets/{SettingsView-DEaMulN9.js → SettingsView-CSinuH-1.js} +1 -1
- package/dist/assets/{SettingsWindow-FLDJXOgQ.js → SettingsWindow-B5CHoJFZ.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-CvVwD-Vi.js → SubmoduleDiffSummary-oxeACCWs.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BiP0x2Rw.js → ToolOutputDialog-tLNWmfcW.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-CkR4msKP.js → ToolPartDiffPreview-CflzmK-x.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-0pyr_mHY.js → VirtualizedFileDiff-NU0FHFhT.js} +1 -1
- package/dist/assets/{WalkthroughView-yNj4nOP5.js → WalkthroughView-BZyjhqHv.js} +1 -1
- package/dist/assets/{appThemeRegistry-BuUKhbYQ.js → appThemeRegistry-DLicw4dH.js} +1 -1
- package/dist/assets/{commitAndPush-DvJKa3Ks.js → commitAndPush-BDftrjr6.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DxTBMuu-.js → computeVirtualFileMetrics-DlWlEM3x.js} +1 -1
- package/dist/assets/{de-DgxgFyGG.js → de-Bro6_zyl.js} +1 -1
- package/dist/assets/{es-BFsZj5F_.js → es-Bb9XQZvd.js} +1 -1
- package/dist/assets/{fr-jdZ5KKQi.js → fr-Dgfzn-IL.js} +1 -1
- package/dist/assets/{index-CKHjPKbq.js → index-CtQNmqUL.js} +1 -1
- package/dist/assets/{index-Cbci4i1W.js → index-Dqc6USl3.js} +1 -1
- package/dist/assets/{isDiffPlainText-D7FkBMP6.js → isDiffPlainText-CO4e5J_S.js} +1 -1
- package/dist/assets/{isFilePlainText-CL2vsrIZ.js → isFilePlainText-ue6kCou7.js} +1 -1
- package/dist/assets/{ja-C5kKrhO4.js → ja-BYsakGFh.js} +1 -1
- package/dist/assets/{ko-DXDTT_0O.js → ko-BSaQz9aN.js} +1 -1
- package/dist/assets/{main-CgXMBNvG.js → main-B62_pjL5.js} +2 -2
- package/dist/assets/{main-CZALtVek.js → main-BEdcOI2P.js} +4 -4
- package/dist/assets/{markdownCore-Dh7WEsdM.js → markdownCore-CK48LG0z.js} +1 -1
- package/dist/assets/{miniChat-CwTmDixi.js → miniChat-LT8Rqofr.js} +2 -2
- package/dist/assets/{mobile-CLf2vCtO.js → mobile-CqarEynh.js} +2 -2
- package/dist/assets/{patchFileDiff-Bsba8KFp.js → patchFileDiff-D7QVlovD.js} +1 -1
- package/dist/assets/{pl-D-7x4Y8Q.js → pl-OIviPdoj.js} +1 -1
- package/dist/assets/{pt-BR-CSBZrHa8.js → pt-BR-Cltg-E6s.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-C5gAFBk0.js → renderElectronMiniChatApp-COyLTtZx.js} +2 -2
- package/dist/assets/{renderMobileApp-V4hYd32H.js → renderMobileApp-BC1MHg6g.js} +3 -3
- package/dist/assets/{runtimeEndpointReset-DhlHCn-2.js → runtimeEndpointReset-DdrazOVH.js} +3 -3
- package/dist/assets/{scheduledTasksApi-DzjbLd8P.js → scheduledTasksApi-B2SWMGEU.js} +1 -1
- package/dist/assets/{shikiHighlight-8_3csmr6.js → shikiHighlight-BPu3JiQs.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-CHo2fCgW.js → textMateThemeFromAppTheme-DWqRPo9A.js} +1 -1
- package/dist/assets/{tr-Dr-oJ22L.js → tr-CQI-KPre.js} +1 -1
- package/dist/assets/{uk-9Nx83UcI.js → uk-CqW7R4DA.js} +1 -1
- package/dist/assets/{useAppFontEffects-khZXpFL_.js → useAppFontEffects-ne84JBVL.js} +9 -9
- package/dist/assets/{useInlineCommentController-DkQ_gqpn.js → useInlineCommentController-CgS0fnw_.js} +1 -1
- package/dist/assets/{useRootScrollLock-DdvHf9Pt.js → useRootScrollLock-Cpf1qoGp.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-CdzUmUyZ.js → vendor-codemirror-language-data-Bx2EHc1O.js} +2 -2
- package/dist/assets/{web-components-B8IcVQAA.js → web-components-DxX8bZ1o.js} +1 -1
- package/dist/assets/{zh-CN-Bxy_Hj3r.js → zh-CN-CVZG_o_J.js} +1 -1
- package/dist/assets/{zh-TW-0BB4gpHM.js → zh-TW-D5ZxzCZp.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-
|
|
2
|
-
import{f as Ze,R as c,j as s,r as mt,c as Rm,h as Mm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{E as xn,F as Vo,H as Om,I as Bm,h as ls,x as Id,u as Pe,J as Ot,K as ll,a as qt,A as Qr,o as ht,L as Gs,N as Ur,O as $n,P as Td,Q as Fm,R as _m,S as Lm,T as $m,U as Ed,n as ns,V as _n,W as Hr,e as Pn,X as zm,Y as Wm,Z as Km,_ as Vm,$ as Rd,v as hn,B as Cn,a0 as Um,a1 as Hm,a2 as cl,a3 as Gm,a4 as ya,a5 as qm,a6 as Md,f as Ym,a7 as Zn,a8 as Ai,a9 as Qm,aa as Di,ab as cr,ac as wa,d as Do,t as Br,q as us,ad as Od,ae as Xm,af as Jm,ag as Pi,ah as Bd,ai as Fd,i as Zm,aj as bo,ak as yo,al as eh,am as dl,an as th,ao as sh,ap as nh,aq as rh,ar as ul,as as fl,at as ml,au as hl,av as oh,z as pl,aw as ih,ax as ah,ay as lh,C as ch,D as dh}from"./index-Cbci4i1W.js";import{_ as En}from"./vendor-vite-runtime-DD1OZmLC.js";import{v as gl,w as ai,x as cn,y as Ii,z as xl,E as uh,F as fh,G as mh,H as hh,I as ph,J as gh,K as xh,L as bh,M as va,b as yh,c as _d,U as Ld,h as Ti,j as $d,Q as wh,i as vh,f as Sh,R as zd,V as Ei,W as Qn,X as Wd,Y as Kd,P as jh,T as kh,Z as Ch,_ as Nh,$ as Ah,a as Vd,a0 as Dh,a1 as Ud,a2 as Po,a3 as Ph,a4 as Ih,a5 as Th,S as bl,a6 as Eh,r as Rh,a7 as Mh,a8 as Oh,a9 as Bh,aa as yl,u as zr,s as Fh,N as _h,D as Lh,ab as $h,ac as wl,ad as zh,ae as li,o as Wh,m as Kh,q as Hd,t as Vh,af as Uh,ag as Hh,ah as Gh,l as qh,n as Yh,O as Gd,A as Qh,C as Xh}from"./runtimeEndpointReset-DhlHCn-2.js";import{f as jt,h as Oe,be as Kt,I as M,g as gn,t as Le,aq as zs,bf as Os,as as Ws,ap as Ks,S as or,Z as vn,af as ir,bg as zn,o as Uo,bh as vl,bi as Jh,bj as Zh,aa as Nt,ab as At,ac as Dt,b as Ht,z as tt,H as ep,bk as qd,bl as no,u as $s,C as Sa,r as Ds,D as Yd,bm as Ri,bn as tp,bo as Qd,bp as Xd,bq as sp,br as np,bs as Sl,bt as jl,bu as ja,bv as Jd,bw as Zd,bx as rp,by as kl,bz as op,bA as ip,bB as ka,bC as Mi,bD as ap,bE as lp,Q as eu,bF as cp,bG as dp,n as ur,bH as tu,bI as up,bJ as fp,p as mp,bK as su,bL as hp,bM as pp,bN as gp,bO as nu,bP as ru,bQ as Cl,bR as ou,bS as iu,bT as au,bU as lu,bV as cu,bW as du,bX as Xr,bY as uu,aF as Ca,bZ as er,b_ as Jr,b$ as xp,c0 as ys,c1 as ws,c2 as Vs,c3 as Ps,c4 as Is,c5 as bn,B as dt,c6 as yn,ay as As,c7 as bp,c8 as yp,aD as In,c9 as Fr,ca as Hs,cb as Ho,cc as fu,cd as Oi,ce as Bi,cf as Fi,cg as wp,ch as Bs,ci as Fs,cj as ks,ck as _s,cl as ss,W as An,cm as fr,cn as Nl,co as pr,cp as mu,R as Go,ag as vp,ah as Na,ai as hu,J as pu,K as Tn,cq as Aa,a5 as Da,cr as Sp,cs as jp,aw as kp,ct as Cp,cu as gu,cv as Np,cw as Ap,ax as Pa,cx as Dp,cy as xu,cz as gr,cA as bu,cB as Pp,l as Gt,s as Ip,cC as Tp,cD as Zr,cE as Ep,aL as eo,cF as Rp,cG as dr,O as yu,cH as Mp,cI as Op,cJ as Wn,cK as Bp,cL as Fp,aA as _p,cM as ci,cN as wu,cO as Ia,cP as Lp,cQ as vu,cR as $p,aE as _i,cS as Li,cT as Al,cU as zp,cV as Dl,cW as _r,c as Gr,d as Ta,a1 as Wp,cX as Su,cY as Ar,cZ as Lr,c_ as Kp,c$ as Vp,d0 as Up,_ as Ea,az as Hp,d1 as Gp,d2 as qp,d3 as Yp,d4 as Qp,d5 as ju,d6 as fn,d7 as Xp,d8 as ku,d9 as Jp,da as $i,db as Zp,dc as Cu,dd as fs,de as eg,df as tg,dg as sg,dh as Nu,di as ng,dj as Ra,dk as Au,a3 as Io,dl as zi,dm as qo,a as Ma,dn as Oa,a2 as rg,dp as Pl,dq as og,dr as Wi,ds as Du,dt as ig,ar as Pu,du as ag,P as Ki,L as lg,dv as Il,dw as cg,dx as dg,dy as Jt,dz as ug,dA as Ln,dB as Ba,dC as Iu,dD as fg,dE as Tu,dF as Eu,dG as mg,E as hg,dH as pg,dI as gg,dJ as xg,dK as Tl,dL as bg,dM as yg,dN as Ru,F as wg,dO as vg,dP as Sg,dQ as wo,dR as jg,dS as kg,dT as Cg,dU as Ng,e as Fa,U as _a,T as La,V as $a,dV as Yo,dW as Ag,dX as qr,a0 as Dg,dY as Pg,dZ as El,d_ as Ig,d$ as Tg,e0 as Eg,aY as Rl,a7 as Ml,a6 as Ol,e1 as Rg,aT as Vi,e2 as Mg,M as Og,N as di,e3 as Bg,e4 as Fg,e5 as Mu,e6 as Ou,e7 as Bu,e8 as _g,G as za,e9 as Lg,a4 as $g,aj as zg,ea as Wg,eb as Bl,ec as Kg,ed as Vg,ee as Ug,ef as Hg,eg as To,eh as Gg,ei as Fl,ej as qg,ek as Yg,el as Qg,em as Xg,en as Ui,eo as Jg,ep as vo,eq as Zg,i as ex,er as tx,es as sx,et as nx,eu as rx,ev as ox,ew as ix,a8 as ax,ex as lx,ey as cx,ez as dx,eA as ux,eB as _l,eC as fx,aM as mx,aN as hx,aP as px,aO as gx,aR as Ll,aS as $l,aV as zl,aW as Wl,aU as Fu,aX as _u,eD as xx,b9 as bx,ba as yx,bb as wx,bc as vx,bd as Sx,b3 as jx,b5 as kx,b6 as Cx,b7 as Nx,b8 as Ax}from"./useAppFontEffects-khZXpFL_.js";import{u as Lu,S as Kl,C as Dx,t as Px,W as $u,f as Ix,G as Tx,a as Ex}from"./useRootScrollLock-DdvHf9Pt.js";import{u as Un,O as Vl,D as Rx,a as Mx,b as Ox,n as Bx,f as Fx,c as Ul,s as _x,d as Lx,e as $x,r as zx}from"./scheduledTasksApi-DzjbLd8P.js";import{f as Qo,h as Dn,T as Xo,M as Jo,D as Zo,j as ei,d as Wx,b as Kx,k as Vx,i as Ux}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as ti,S as Wa,h as Hx,a as zu,v as Wu,s as Gx}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as si}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Ku,M as Vu,C as Uu,a as Hi,b as Gi,c as qi,d as Hu,e as qx,f as Yx}from"./vendor-base-ui-CsXYnR5c.js";import{c as to,u as rr,d as Qx,p as Xx}from"./vendor-zustand-BAGL70zf.js";import{g as Jx,a as Zx,E as Gu,b as eb,c as tb,d as sb,e as nb,i as rb}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as ob}from"./PluginPane-B4tKno2h.js";import{a as Ka,s as jr,r as qu}from"./vendor-zod-CgAdXWZO.js";import{u as ib}from"./vendor-tanstack-react-virtual-ClYN8CzB.js";import{d as ab}from"./vendor-tanstack-virtual-core-BewVQryB.js";import{d as Yu}from"./vendor-cron-parser-CUcP7OfX.js";const lb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",cb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",ui=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?lb:t.id==="terminal"?cb:void 0}),Hl=t=>{const e=Ze.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=()=>l(!0),e[2]=x):x=e[2];let b;return e[3]!==u?(b=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:x}),e[3]=u,e[4]=b):b=e[4],b}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Oe("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:h,children:d}),e[6]=d,e[7]=f):f=e[7],f},db=t=>{const e=Ze.c(75),{directory:n,className:r}=t,{t:i}=jt(),o=Un(ub),l=Un(fb),a=Un(mb),d=Un(hb),u=Un(pb),h=Un(gb),f=Un(xb);let x,b;e[0]!==u?(x=()=>{u()},b=[u],e[0]=u,e[1]=x,e[2]=b):(x=e[1],b=e[2]),c.useEffect(x,b);const w=xn()&&Vo();let v;e:{let we;e[3]!==l||e[4]!==o?(we=l.find(pe=>pe.id===o)??l.find(bb)??l[0]??Vl[0],e[3]=l,e[4]=o,e[5]=we):we=e[5];const ye=we;if(ye){let pe;e[6]!==ye?(pe=ui(ye),e[6]=ye,e[7]=pe):pe=e[7],v=pe;break e}let Ae;e[8]===Symbol.for("react.memo_cache_sentinel")?(Ae=ui(Vl[0]),e[8]=Ae):Ae=e[8],v=Ae}const y=v;if(!w||!n||l.length===0)return null;let m;e[9]!==n?(m=async we=>{await Om(n,we.id,we.appName)||await Bm(n,we.appName)},e[9]=n,e[10]=m):m=e[10];const p=m;let S;e[11]!==p||e[12]!==f?(S=async we=>{await f(we.id),await p(we)},e[11]=p,e[12]=f,e[13]=S):S=e[13];const g=S;let C;e[14]!==n||e[15]!==i?(C=async()=>{(await gn(n)).ok&&Le.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=C):C=e[16];const k=C;let j;e[17]!==r?(j=Oe("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=j):j=e[18];let D;e[19]!==p||e[20]!==y?(D=()=>{p(y)},e[19]=p,e[20]=y,e[21]=D):D=e[21];const I=d&&"animate-pulse";let A;e[22]!==I?(A=Oe("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",I),e[22]=I,e[23]=A):A=e[23];let P;e[24]!==y.label||e[25]!==i?(P=i("openInApp.actions.openInAria",{app:y.label}),e[24]=y.label,e[25]=i,e[26]=P):P=e[26];let T;e[27]!==y.fallbackIconDataUrl||e[28]!==y.iconDataUrl||e[29]!==y.label?(T=s.jsx(Hl,{label:y.label,iconDataUrl:y.iconDataUrl,fallbackIconDataUrl:y.fallbackIconDataUrl}),e[27]=y.fallbackIconDataUrl,e[28]=y.iconDataUrl,e[29]=y.label,e[30]=T):T=e[30];let L;e[31]!==A||e[32]!==P||e[33]!==T||e[34]!==D?(L=s.jsx("button",{type:"button",onClick:D,className:A,"aria-label":P,children:T}),e[31]=A,e[32]=P,e[33]=T,e[34]=D,e[35]=L):L=e[35];let $;e[36]===Symbol.for("react.memo_cache_sentinel")?($=Oe("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=$):$=e[36];let K;e[37]!==i?(K=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=K):K=e[38];let F;e[39]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(M,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=F):F=e[39];let W;e[40]!==K?(W=s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:$,"aria-label":K,children:F})}),e[40]=K,e[41]=W):W=e[41];let N;e[42]!==k?(N=()=>{k()},e[42]=k,e[43]=N):N=e[43];let R;e[44]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(M,{name:"file-copy",className:"h-4 w-4"}),e[44]=R):R=e[44];let E;e[45]!==i?(E=i("openInApp.actions.copyPath"),e[45]=i,e[46]=E):E=e[46];let X;e[47]!==E?(X=s.jsx("span",{className:"typography-ui-label text-foreground",children:E}),e[47]=E,e[48]=X):X=e[48];let J;e[49]!==N||e[50]!==X?(J=s.jsxs(Kt,{className:"flex items-center gap-2",onClick:N,children:[R,X]}),e[49]=N,e[50]=X,e[51]=J):J=e[51];let re;e[52]===Symbol.for("react.memo_cache_sentinel")?(re=s.jsx(Os,{}),e[52]=re):re=e[52];let fe;if(e[53]!==l||e[54]!==g||e[55]!==y.id){let we;e[57]!==g||e[58]!==y.id?(we=ye=>{const Ae=ui(ye);return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{g(ye)},children:[s.jsx(Hl,{label:ye.label,iconDataUrl:ye.iconDataUrl,fallbackIconDataUrl:Ae.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:ye.label}),y.id===ye.id?s.jsx(M,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},ye.id)},e[57]=g,e[58]=y.id,e[59]=we):we=e[59],fe=l.map(we),e[53]=l,e[54]=g,e[55]=y.id,e[56]=fe}else fe=e[56];let ne;e[60]!==a||e[61]!==h||e[62]!==i?(ne=a?s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(M,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=h,e[62]=i,e[63]=ne):ne=e[63];let te;e[64]!==J||e[65]!==fe||e[66]!==ne?(te=s.jsxs(Ws,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[J,re,fe,ne]}),e[64]=J,e[65]=fe,e[66]=ne,e[67]=te):te=e[67];let ue;e[68]!==W||e[69]!==te?(ue=s.jsxs(Ks,{children:[W,te]}),e[68]=W,e[69]=te,e[70]=ue):ue=e[70];let Se;return e[71]!==L||e[72]!==ue||e[73]!==j?(Se=s.jsxs("div",{className:j,children:[L,ue]}),e[71]=L,e[72]=ue,e[73]=j,e[74]=Se):Se=e[74],Se};function ub(t){return t.selectedAppId}function fb(t){return t.availableApps}function mb(t){return t.isCacheStale}function hb(t){return t.isScanning}function pb(t){return t.initialize}function gb(t){return t.loadInstalledApps}function xb(t){return t.selectApp}function bb(t){return t.id===Rx}const Eo=new Map,Yi=new Set,Qu=()=>{for(const t of Yi)t()},fi=(t,e)=>{const n=t.trim();n&&(e.length===0?Eo.delete(n):Eo.set(n,[...e]),Qu())},yb=t=>{Eo.delete(t.trim())&&Qu()},Xu=[],wb=t=>Eo.get(t.trim())??Xu,vb=t=>(Yi.add(t),()=>{Yi.delete(t)}),Sb=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=()=>wb(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(vb,n,jb)};function jb(){return Xu}const kb=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Cb=["dev","start","preview","serve"];async function Nb(t,e,n){if(!t)return null;const r=Pb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Ib(n);if(i){const o=await Tb(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await Ab(t)){const i=await Db(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function Ab(t){const e=`${t}/index.html`,n=await Ro(e,t);return typeof n=="string"&&n.trim().length>0}async function Db(){try{const t=await ls("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Pb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Cb.some(i=>n.includes(i)))return e}return null}function Ib(t){for(const{pattern:e}of kb)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Tb(t){const e=await Ro(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await Ro(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Ro(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ls(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Id()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await ls(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Eb(t){try{const e=await Ro(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const un="__openchamber_auto_discover_preview__",Rb=15e3,Mb=3e3,mi=t=>t.id===un?"scan-2":bh.find(n=>n.key===t.icon)?.Icon??"play",Ob=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Bb=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=jt(),{currentTheme:l}=or(),{terminal:a,runtime:d}=vn(),u=ir(),{isMobile:h}=zn(),f=c.useMemo(()=>xn(),[]),x=gl(G=>G.instances),b=gl(G=>G.load),w=Pe(G=>G.terminalShell),v=Pe(G=>G.terminalLoginShells.includes(G.terminalShell)),y=Pe(G=>G.setSettingsPage),m=Pe(G=>G.setSettingsDialogOpen),p=Pe(G=>G.setSettingsProjectsSelectedId),S=Pe(G=>G.openContextPreview),g=Ot(G=>G.ensureDirectory),C=Ot(G=>G.reconcileServerSessions),k=Ot(G=>G.setTabLabel),j=Ot(G=>G.setTabIconKey),D=Ot(G=>G.setActiveTab),I=Ot(G=>G.setConnecting),A=Ot(G=>G.setTabSessionId),P=Ot(G=>G.setTabPurpose),T=Ot(G=>G.allocateActionExecution),L=Ot(G=>G.setTabLifecycle),$=Ot(G=>G.setTabPreviewUrl),K=Ot(G=>G.matchesActionExecution),F=Ot(G=>G.captureStartedActionMutationRevisions),[W,N]=c.useState([]),R=c.useRef(null),[E,X]=c.useState(null),[J,re]=c.useState(!1),fe=c.useRef({}),ne=c.useRef({}),te=c.useRef({}),ue=c.useRef(new Set),Se=c.useRef(0),[we,ye]=c.useState({}),Ae=t?.id??null,pe=t?.path??"",O=c.useMemo(()=>Ae?{id:Ae,path:pe}:null,[Ae,pe]);c.useEffect(()=>{f&&b().catch(()=>{})},[f,b]);const Q=c.useCallback(async G=>{await Uo(G)},[]),le=c.useCallback(async()=>{if(!O)return;const G=Se.current+1;Se.current=G,re(!0);try{const Z=await vl(O);if(Se.current!==G)return;R.current=Z;const je=Z.projectActions;N(je),X(Ie=>Ie===un||Ie&&je.some(Ve=>Ve.id===Ie)?Ie:null)}catch{if(Se.current!==G)return}finally{Se.current===G&&re(!1)}},[O]),H=c.useMemo(()=>ai(e||O?.path||""),[e,O?.path]),me=c.useMemo(()=>ai(O?.path||""),[O?.path]),ge=c.useMemo(()=>ai(u||"")||H,[u,H]),oe=c.useRef(ge);c.useEffect(()=>{oe.current=ge},[ge]);const de=Ot(G=>H?G.getDirectoryState(H):void 0),_=Ot(G=>me&&me!==H?G.getDirectoryState(me):void 0),B=c.useMemo(()=>{const G=H?[{directory:H,state:de}]:[];return me&&me!==H&&G.push({directory:me,state:_}),G},[de,H,me,_]),he=c.useMemo(()=>{const G=H?[H]:[];return me&&me!==H&&G.push(me),G},[H,me]),ve=c.useCallback(G=>G.id!==un&&G.runIn==="parent"&&me||H,[H,me]),Re=c.useCallback((G,Z,je)=>`${G}::${Z}::${je}`,[]),ce=c.useCallback((G,Z,je=Ot.getState())=>G?je.getDirectoryState(G)?.tabs.find(Ie=>Ie.purpose.type==="project-action"&&Ie.purpose.actionId===Z)??null:null,[]),se=c.useMemo(()=>{const G={};for(const{directory:Z,state:je}of B)for(const Ie of je?.tabs??[]){if(Ie.purpose.type!=="project-action"||!Ie.purpose.executionId||!Ie.terminalSessionId||Ie.lifecycle==="idle"||Ie.lifecycle==="exited")continue;const Ve=cn(Z,Ie.purpose.actionId),Je=Re(Z,Ie.purpose.actionId,Ie.purpose.executionId);G[Ve]={directory:Z,actionId:Ie.purpose.actionId,tabId:Ie.id,sessionId:Ie.terminalSessionId,executionId:Ie.purpose.executionId,status:Ie.lifecycle==="stopping"?"stopping":we[Je]?"waiting-for-preview":"running"}}return G},[Re,we,B]),q=c.useCallback((G,Z,je)=>{const Ie=cn(G,Z),Ve=Re(G,Z,je),it=fe.current[Ie]?.executionId===je,at=globalThis.window,Ye=vt=>{at?.clearTimeout(te.current[vt]),delete te.current[vt]};it&&(delete fe.current[Ie],Ye(Ie)),ne.current[Ve]?.(),delete ne.current[Ve],Ye(Ve),ye(vt=>{if(!vt[Ve])return vt;const Ue={...vt};return delete Ue[Ve],Ue})},[Re]),z=c.useCallback(G=>{ne.current[G]?.(),delete ne.current[G]},[]),ee=c.useCallback(G=>{window.clearTimeout(te.current[G]),delete te.current[G]},[]);c.useEffect(()=>{const G=ne.current,Z=te.current;return()=>{for(const je of Object.keys(G))z(je);for(const je of Object.keys(Z))ee(je)}},[ee,z]),c.useEffect(()=>{const G=new Set(he);for(const Z of Object.values(fe.current))G.has(Z.directory)||q(Z.directory,Z.actionId,Z.executionId);for(const Z of Object.keys(ne.current)){const je=Z.split("::",1)[0]??"";G.has(je)||z(Z)}},[q,z,he]);const ae=c.useCallback((G,Z)=>{Pe.getState().openContextPanelTab(G,{mode:"terminal",targetDirectory:Z===G?null:Z})},[]),Ne=c.useMemo(()=>E?W.find(G=>G.id===E)??null:null,[W,E]),Ce=c.useMemo(()=>({id:un,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),We=!h,Ee=c.useMemo(()=>We?[Ce,...W]:W,[W,Ce,We]);c.useEffect(()=>{le()},[le]),c.useEffect(()=>{const G=he.map(Z=>Ii(a,Z,F,je=>C(Z,je.sessions,{startedActionMutationRevisions:je.startedActionMutationRevisions})));return()=>{for(const Z of G)Z()}},[F,C,a,he]),c.useEffect(()=>{for(const{directory:G,state:Z}of B)if(G)for(const je of Z?.tabs??[]){if(je.purpose.type!=="project-action")continue;const Ie=je.purpose.actionId,Ve=Ee.find(at=>at.id===Ie),Je=Ve?.name??Ie,it=Ve?.icon||"play";je.label!==Je&&k(G,je.id,Je),je.iconKey!==it&&j(G,je.id,it)}},[Ee,j,k,B]),c.useEffect(()=>{const G=globalThis.window;if(!G)return;const Z=je=>{const Ie=je.detail;Ae&&(Ie?.projectId&&Ie.projectId!==Ae||le())};return G.addEventListener(xl,Z),()=>{G.removeEventListener(xl,Z)}},[le,Ae]),c.useEffect(()=>{E&&(E===un&&We||W.some(G=>G.id===E)||X(null))},[W,We,E]),c.useEffect(()=>{const G=je=>{delete te.current[je];const Ie=fe.current[je];if(!Ie||Ie.openedUrl)return;const Ve=Re(Ie.directory,Ie.actionId,Ie.executionId),Je=Ie.announced;if(Je.length!==0){if(window.clearTimeout(te.current[Ve]),delete te.current[Ve],Ie.openedUrl=!0,ye(it=>{if(!it[Ve])return it;const at={...it};return delete at[Ve],at}),Je.length===1){fi(Ie.directory,[]),$(Ie.directory,Ie.tabId,Je[0],{locked:!1,autoOpened:!0}),S(Ie.directory,Je[0]);return}Ie.offering=!0,fi(Ie.directory,Je),Pe.getState().openContextSurface(Ie.directory,"browser"),Le.info(o("projectActions.toast.multipleServers"))}},Z=()=>{const je=Ot.getState(),Ie=je.sessions,Ve=se;for(const[Je,it]of Object.entries(Ve)){const Ye=Ie.get(it.directory)?.tabs.find(ft=>ft.id===it.tabId);if(!Ye||Ye.terminalSessionId!==it.sessionId){q(it.directory,it.actionId,it.executionId);continue}const vt=fe.current[Je],Ue=vt?.executionId===it.executionId?vt:{hostDirectory:oe.current||it.directory,directory:it.directory,tabId:it.tabId,actionId:it.actionId,executionId:it.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};fe.current[Je]=Ue;const Pt=Ee.find(ft=>ft.id===it.actionId),ke=je.getBuffer(it.directory,it.tabId).chunks;if(!Pt||ke.length===0)continue;const xt=ke.filter(ft=>Ue.lastSeenChunkId===null||ft.id>Ue.lastSeenChunkId);if(xt.length===0)continue;const Ct=xt.map(ft=>ft.data).join(""),Tt=`${Ue.tail}${Ct}`;if(Ue.openInPreview&&(!Ue.openedUrl||Ue.offering)){const ft=gh(Tt),Be=Ue.announced.length;for(const He of ft)Ue.announced.includes(He)||Ue.announced.push(He);const Ke=Ue.announced.length-Be;Ue.offering&&Ke>0?fi(it.directory,Ue.announced):!Ue.openedUrl&&Be===0&&Ue.announced.length>0&&(window.clearTimeout(te.current[Je]),te.current[Je]=window.setTimeout(()=>G(Je),Mb))}const qe=!Ue.openedUrl&&Pt.autoOpenUrl===!0&&!Ue.openInPreview?xh(Tt):null,ze=xt[xt.length-1]?.id??Ue.lastSeenChunkId;if(Ue.lastSeenChunkId=ze,Ue.tail=Tt.slice(-512),qe)if(Ue.openedUrl=!0,Ue.openInPreview){const ft=Ve[Je];ft&&($(ft.directory,ft.tabId,qe,{locked:!1,autoOpened:!1,expectedExecutionId:ft.executionId}),ft.status==="waiting-for-preview"&&ye(Be=>{const Ke=Re(ft.directory,ft.actionId,ft.executionId);if(!Be[Ke])return Be;const He={...Be};return delete He[Ke],He}),window.clearTimeout(te.current[Je]),delete te.current[Je],S(ft.directory,qe))}else Q(qe),Le.success(o("projectActions.toast.openedUrlFromOutput"));fe.current[Je]=Ue}for(const Je of Object.keys(fe.current))if(!Ve[Je]){const it=fe.current[Je],at=it?Ie.get(it.directory)?.tabs.find(vt=>vt.id===it.tabId):void 0;if(at?.purpose.type==="project-action"&&at.purpose.executionId===it?.executionId&&!!at.terminalSessionId&&at.lifecycle!=="idle"&&at.lifecycle!=="exited")continue;delete fe.current[Je],window.clearTimeout(te.current[Je]),delete te.current[Je]}};return Z(),Ot.subscribe((je,Ie)=>{(je.sessions!==Ie.sessions||je.buffers!==Ie.buffers)&&Z()})},[q,oe,Ee,Re,S,Q,se,$,o]),c.useEffect(()=>{for(const{directory:G,state:Z}of B)for(const je of Z?.tabs??[]){if(je.purpose.type!=="project-action"||!je.purpose.executionId||!je.terminalSessionId||je.lifecycle!=="running")continue;const Ie=je.purpose.actionId,Ve=je.purpose.executionId,Je=Re(G,Ie,Ve);if(ne.current[Je])continue;const it=a.connect(je.terminalSessionId,{onEvent:at=>{if(!K(G,je.id,Ve))return;at.type==="snapshot"&&(Ot.getState().replaceBuffer(G,je.id,at.data??"",at.sequence??0,ll(at)),at.status==="running"&&Ot.getState().setTabLifecycle(G,je.id,"running",{expectedExecutionId:Ve}),at.status==="exited"&&(Ot.getState().setTabLifecycle(G,je.id,"exited",{expectedExecutionId:Ve}),Ot.getState().setTabPurpose(G,je.id,{type:"project-action",actionId:Ie,executionId:null}),q(G,Ie,Ve)));const Ye=at.type==="data"?at.data??"":"";Ye&&Ot.getState().appendToBuffer(G,je.id,Ye,at.sequence,at.replayData),at.type==="exit"&&(Ot.getState().setTabLifecycle(G,je.id,"exited",{expectedExecutionId:Ve}),Ot.getState().setTabPurpose(G,je.id,{type:"project-action",actionId:Ie,executionId:null}),q(G,Ie,Ve))},onError:(at,Ye)=>{!Ye||!K(G,je.id,Ve)||(Ot.getState().setTabLifecycle(G,je.id,"exited",{expectedExecutionId:Ve}),Ot.getState().setTabSessionId(G,je.id,null,{expectedExecutionId:Ve}),Ot.getState().setTabPurpose(G,je.id,{type:"project-action",actionId:Ie,executionId:null}),q(G,Ie,Ve))}});ne.current[Je]=it.close}},[q,Re,K,a,B]);const xe=c.useCallback(async G=>{const Z=ve(G);if(!Z)throw new Error(o("projectActions.error.noActiveDirectory"));const je=cn(Z,G.id);g(Z);const Ie=Ot.getState(),Ve=ce(Z,G.id,Ie),Je=Ve?.id??Ie.createTab(Z);k(Z,Je,G.name),j(Z,Je,G.icon||"play"),Ve||P(Z,Je,{type:"project-action",actionId:G.id,executionId:null}),D(Z,Je);const at=Ot.getState().getDirectoryState(Z)?.tabs.find(Ye=>Ye.id===Je);return{executionDirectory:Z,key:je,tabId:Je,sessionId:at?.terminalSessionId??null,executionId:at?.purpose.type==="project-action"?at.purpose.executionId:null}},[g,ve,ce,D,j,k,P,o]),$e=c.useCallback(async G=>{if(d.isVSCode||!i&&h)return;if(!H){Le.error(o("projectActions.error.noActiveDirectoryForAction"));return}const Z=cn(ve(G),G.id),je=se[Z];if(je&&je.status==="running"||ue.current.has(Z))return;ue.current.add(Z);let Ie=null;try{const Ve=G.id===un?await(async()=>{const[Ke,He]=await Promise.all([Jh({id:O?.id??"",path:H}),Eb(H)]),nt=await Nb(H,Ke.actions,He);if(!nt)throw new Error(o("contextPanel.preview.noDevServer"));return{id:un,name:o("projectActions.actions.autoDiscover"),command:nt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:nt.previewUrlHint||""}})():G,Je=Ve.autoOpenUrl===!0&&(Ve.openUrl||"").trim().length>0,it=!Je&&G.id!==un,at=oe.current||H,{executionDirectory:Ye,key:vt,tabId:Ue}=await xe(Ve),Pt=uh(Ve.command);if(!Pt)throw new Error(o("projectActions.error.failedToRunAction"));const ke=Ve.autoOpenUrl===!0&&f&&(Ve.desktopOpenSshForward||"").trim().length>0,xt=Ve.autoOpenUrl?Ob(Ve.openUrl):null,Ct=Ve.autoOpenUrl&&f?fh(Ve.desktopOpenSshForward,x):null;if(a.listSessions){const Ke=ce(Ye,Ve.id);if(Ke?.purpose.type==="project-action"&&Ke.purpose.executionId===null){const He=await mh(a,Ye,{captureStartedActionMutationRevisions:F});He&&C(Ye,He.sessions,{startedActionMutationRevisions:He.startedActionMutationRevisions})}}const Tt=ce(Ye,Ve.id);let qe,ze;if(Tt?.lifecycle==="running"&&Tt.terminalSessionId&&Tt.purpose.type==="project-action"&&Tt.purpose.executionId)qe=Tt.terminalSessionId,ze=Tt.purpose.executionId;else{const Ke=Tt?.purpose.type==="project-action"?Tt.purpose.executionId:null;Ke&&q(Ye,Ve.id,Ke);const He=T(Ye,Ue,Ve.id);if(!He)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));Ie={directory:Ye,tabId:Ue,id:He},I(Ye,Ue,!0,{expectedExecutionId:He});const nt=await hh({terminal:a,createOptions:{cwd:Ye,shell:w,loginShell:v,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Pt,isRunStillExpected:()=>K(Ye,Ue,He),purpose:{type:"project-action",actionId:Ve.id,executionId:He}});if(!K(Ye,Ue,He)){nt.sessionId===He&&await a.close(nt.sessionId).catch(()=>{});return}ze=nt.purpose?.type==="project-action"?nt.purpose.executionId:He,qe=nt.sessionId,P(Ye,Ue,{type:"project-action",actionId:Ve.id,executionId:ze}),A(Ye,Ue,qe,{expectedExecutionId:ze}),I(Ye,Ue,!1,{expectedExecutionId:ze})}it&&at&&ae(at,Ye),fe.current[vt]={hostDirectory:at,directory:Ye,tabId:Ue,actionId:Ve.id,executionId:ze,lastSeenChunkId:null,openedUrl:!!Ct||!!xt||Je,tail:"",openInPreview:Ve.id===un,announced:[],offering:!1};const ft=Re(Ye,Ve.id,ze);I(Ye,Ue,!0,{expectedExecutionId:ze});const Be=a.connect(qe,{onEvent:Ke=>{if(!K(Ye,Ue,ze)||Ke.purpose?.type==="project-action"&&Ke.purpose.executionId!==ze)return;Ke.type==="snapshot"&&(Ot.getState().replaceBuffer(Ye,Ue,Ke.data??"",Ke.sequence??0,ll(Ke)),Ot.getState().setConnecting(Ye,Ue,!1,{expectedExecutionId:ze}),Ke.purpose?.type==="project-action"&&Ot.getState().setTabPurpose(Ye,Ue,{type:"project-action",actionId:Ke.purpose.actionId,executionId:Ke.purpose.executionId}),Ke.status==="running"&&Ot.getState().setTabLifecycle(Ye,Ue,"running",{expectedExecutionId:ze}),Ke.status==="exited"&&(Ot.getState().setTabLifecycle(Ye,Ue,"exited",{expectedExecutionId:ze}),Ot.getState().setTabPurpose(Ye,Ue,{type:"project-action",actionId:Ve.id,executionId:null}),q(Ye,Ve.id,ze)));const He=Ke.type==="data"?Ke.data??"":"";He&&Ot.getState().appendToBuffer(Ye,Ue,He,Ke.sequence,Ke.replayData),Ke.type==="exit"&&(Ot.getState().setTabLifecycle(Ye,Ue,"exited",{expectedExecutionId:ze}),Ot.getState().setConnecting(Ye,Ue,!1,{expectedExecutionId:ze}),Ot.getState().setTabPurpose(Ye,Ue,{type:"project-action",actionId:Ve.id,executionId:null}),q(Ye,Ve.id,ze))},onError:(Ke,He)=>{K(Ye,Ue,ze)&&(Ot.getState().setConnecting(Ye,Ue,!1,{expectedExecutionId:ze}),He&&(Ot.getState().setTabLifecycle(Ye,Ue,"exited",{expectedExecutionId:ze}),Ot.getState().setTabSessionId(Ye,Ue,null,{expectedExecutionId:ze}),Ot.getState().setTabPurpose(Ye,Ue,{type:"project-action",actionId:Ve.id,executionId:null}),q(Ye,Ve.id,ze)))}});if(!K(Ye,Ue,ze)){Be.close();return}ne.current[ft]?.(),ne.current[ft]=Be.close,window.clearTimeout(te.current[ft]),delete te.current[ft],Ve.id===un&&!xt&&(ye(Ke=>({...Ke,[ft]:!0})),te.current[ft]=window.setTimeout(()=>{delete te.current[ft];const Ke=fe.current[vt];!Ke||Ke.executionId!==ze||Ke.openedUrl||Ke.offering||K(Ye,Ue,ze)&&(ye(He=>{if(!He[ft])return He;const nt={...He};return delete nt[ft],nt}),Ot.getState().setActiveTab(Ye,Ue),ae(Ke.hostDirectory,Ye))},Rb)),Ct?($(Ye,Ue,null,{locked:!0,expectedExecutionId:ze}),Q(Ct),Le.success(o("projectActions.toast.openedForwardedUrl"))):xt?($(Ye,Ue,xt,{locked:!0,autoOpened:!0,expectedExecutionId:ze}),S(at,xt),Le.success(o("projectActions.toast.openedActionUrl"))):Je?($(Ye,Ue,null,{locked:!0,expectedExecutionId:ze}),Le.error(o("projectActions.error.invalidCustomUrlFormat"))):ke?($(Ye,Ue,null,{locked:!0,expectedExecutionId:ze}),Le.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):$(Ye,Ue,null,{locked:!1,autoOpened:!1,expectedExecutionId:ze})}catch(Ve){if(Ie&&K(Ie.directory,Ie.tabId,Ie.id)){const{directory:Je,tabId:it,id:at}=Ie;q(Je,G.id,at),L(Je,it,"exited",{expectedExecutionId:at}),P(Je,it,{type:"project-action",actionId:G.id,executionId:null})}if(Ve instanceof Error&&Ve.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Ve instanceof Error&&(Ve.message==="COMMAND_MODE_UNSUPPORTED"||Ve.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Le.error(o("projectActions.error.failedToCreateTerminalSession"));return}Le.error(Ve instanceof Error?Ve.message:o("projectActions.error.failedToRunAction"))}finally{ue.current.delete(Z)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,oe,x,xe,i,h,f,H,v,w,Q,S,se,ae,d.isVSCode,ve,K,q,Re,ce,C,T,F,I,L,P,$,A,O?.id,o,a]),V=c.useCallback(async G=>{const Z=cn(ve(G),G.id),je=se[Z];je&&await ph({terminal:a,sessionId:je.sessionId,isExecutionStillCurrent:()=>K(je.directory,je.tabId,je.executionId),markStopping:()=>{L(je.directory,je.tabId,"stopping",{expectedExecutionId:je.executionId})},restoreRunning:()=>{L(je.directory,je.tabId,"running",{expectedExecutionId:je.executionId})},clearSession:()=>{A(je.directory,je.tabId,null,{expectedExecutionId:je.executionId})},finalizeExit:()=>{L(je.directory,je.tabId,"exited",{expectedExecutionId:je.executionId}),P(je.directory,je.tabId,{type:"project-action",actionId:je.actionId,executionId:null}),q(je.directory,je.actionId,je.executionId)}})},[q,ve,K,se,L,P,A,a]),De=c.useCallback(()=>{const G=Ne??Ee[0];if(!G)return;const Z=cn(ve(G),G.id),je=se[Z];if(je?.status!=="stopping"){if(je){V(G);return}$e(G)}},[Ee,ve,$e,se,Ne,V]),Fe=c.useCallback(async G=>{if(G.source==="shared"&&O){const Z=R.current?.trust.trusted?R.current:await vl(O);if(R.current=Z,!await Zh(O,Z))return;R.current={...Z,trust:{...Z.trust,trusted:!0}}}await $e(G)},[$e,O]),_e=c.useCallback((G,Z=!1)=>{if(X(G.id),!Z){Fe(G);return}const je=cn(ve(G),G.id),Ie=se[je];if(Ie?.status!=="stopping"){if(Ie){V(G);return}Fe(G)}},[ve,Fe,se,V]),rt=c.useCallback(()=>{O?.id&&(p(O.id),y("projects"),m(!0))},[m,y,p,O?.id]),ct=Ne??Ee[0]??null,et=ct?se[cn(ve(ct),ct.id)]:null,pt=Ot(G=>et?G.getDirectoryState(et.directory)?.tabs.find(Z=>Z.id===et.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&h||!O||!H)return null;const kt=Ne??Ee[0]??null;if(!kt)return null;const wt=mi(kt),Xe=cn(ve(kt),kt.id),yt=se[Xe],Rt=yt?.status==="stopping",be=yt?.status==="waiting-for-preview",Ge=!!(yt&&pt),ut=()=>{!yt||!pt||S(yt.directory,pt)},Y=kt.id===un;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",disabled:J||Rt,className:Oe("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed",n),onClick:De,"aria-label":yt?o("projectActions.actions.stopNamedAria",{name:kt.name}):o("projectActions.actions.runNamedAria",{name:kt.name}),children:Rt||be?s.jsx(M,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):yt?s.jsx(M,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(M,{name:wt,className:"h-5 w-5"})})}),Y?s.jsx(Dt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Ge?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.openPreview"),onClick:ut,children:s.jsx(M,{name:"global",className:"h-4 w-4"})})}),s.jsx(Dt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Ws,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:rt,children:[s.jsx(M,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),Ee.map(G=>{const Z=mi(G),je=cn(ve(G),G.id),Ie=se[je],Ve=!!Ie,Je=Ie?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{_e(G,!0)},children:[s.jsx(M,{name:Z,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:G.name}),G.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Je||Ie?.status==="waiting-for-preview"?s.jsx(M,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ve?s.jsx(M,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},G.id)})]})]})]}):s.jsxs("div",{className:Oe("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:De,disabled:J||Rt,className:Oe("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed"),"aria-label":yt?o("projectActions.actions.stopNamedAria",{name:kt.name}):o("projectActions.actions.runNamedAria",{name:kt.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:Rt||be?s.jsx(M,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):yt?s.jsx(M,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(M,{name:wt,className:"h-4 w-4"})})})}),Y?s.jsx(Dt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Ge?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ut,className:Oe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(M,{name:"global",className:"h-4 w-4"})})}),s.jsx(Dt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(M,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Ws,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:rt,children:[s.jsx(M,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),Ee.map(G=>{const Z=mi(G),je=cn(ve(G),G.id),Ie=se[je],Ve=!!Ie,Je=Ie?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{_e(G,!0)},children:[s.jsx(M,{name:Z,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:G.name}),G.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Je||Ie?.status==="waiting-for-preview"?s.jsx(M,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ve?s.jsx(M,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},G.id)})]})]})]})},$r=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Fb=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=$r(n??"");if(i){const o=qd(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function _b(){const t=Ht(w=>w.projects),e=Ht(w=>w.activeProjectId),n=tt(w=>w.availableWorktreesByProject),r=tt(w=>w.currentSessionId),i=ep(r??null),o=tt(w=>r?w.worktreeMetadata.get(r)?.path??"":""),l=tt(w=>w.newSessionDraft?.open?$r(w.newSessionDraft.bootstrapPendingDirectory??w.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>$r(o||""),[o]),d=c.useMemo(()=>{const w=typeof i?.directory=="string"?i.directory:"";return $r(w||"")},[i?.directory]),u=a||d||l,h=c.useMemo(()=>Fb({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>$r(u||h?.path||""),[u,h?.path]),x=c.useMemo(()=>h?{id:h.id,path:h.path}:null,[h]),b=c.useRef(null);return c.useEffect(()=>{x&&f&&(b.current={projectRef:x,directory:f})},[f,x]),c.useMemo(()=>x&&f?{projectRef:x,directory:f}:b.current,[x,f])}const Lb=({transform:t})=>({...t,y:0}),$b={Item:Kt,Separator:Os},zb={Item:({className:t,...e})=>s.jsx(Vu,{className:Oe(Xd,t),...e}),Separator:({className:t,...e})=>s.jsx(Ku,{className:Oe(Qd,t),...e})},Wb=t=>{const e=Ze.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:h}=t,{t:f}=jt(),[x,b]=c.useState(!1),[w,v]=c.useState(!1),[y,m]=c.useState(!1);let p;e[0]!==n.id?(p={id:n.id},e[0]=n.id,e[1]=p):p=e[1];const{attributes:S,listeners:g,setNodeRef:C,transform:k,transition:j,isDragging:D}=ti(p);let I;e[2]!==f||e[3]!==n.session.title?(I=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=I):I=e[4];const A=I,P=!i&&(x||w),T=Sa(n.id),L=n.id;let $;e[5]!==n.session?($=Ds(n.session),e[5]=n.session,e[6]=$):$=e[6];const K=va(L,$),F=T?.type==="busy"||T?.type==="retry",N=Yd(n.id)>0&&!r&&!F,R=F||N;let E;e[7]!==F||e[8]!==f?(E=f(F?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=F,e[8]=f,e[9]=E):E=e[9];const X=E;let J;e[10]!==d||e[11]!==y||e[12]!==r||e[13]!==x||e[14]!==o||e[15]!==n?(J=ge=>({session:n.session,open:x||y,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:ge}),e[10]=d,e[11]=y,e[12]=r,e[13]=x,e[14]=o,e[15]=n,e[16]=J):J=e[16];const re=J;let fe;e[17]!==k?(fe=si.Translate.toString(k),e[17]=k,e[18]=fe):fe=e[18];let ne;e[19]!==fe||e[20]!==j?(ne={transform:fe,transition:j},e[19]=fe,e[20]=j,e[21]=ne):ne=e[21];const te=D&&"z-10 opacity-60";let ue;e[22]!==te?(ue=Oe("session-tab-slot flex h-7 w-44 shrink-0 touch-none",te),e[22]=te,e[23]=ue):ue=e[23];const Se=r?"true":"false";let we;e[24]!==r?(we=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=we):we=e[25];let ye;e[26]!==u?(ye=ge=>u?.(ge),e[26]=u,e[27]=ye):ye=e[27];let Ae;e[28]!==h||e[29]!==X||e[30]!==r||e[31]!==K||e[32]!==F||e[33]!==re||e[34]!==x||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==P||e[39]!==a||e[40]!==R||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==A?(Ae=s.jsx(Uu,{render:ge=>s.jsxs("div",{...ge,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:oe=>{(oe.key==="Enter"||oe.key===" ")&&(oe.preventDefault(),o(n))},onAuxClick:oe=>{oe.button===1&&(oe.preventDefault(),l(n.id))},"data-controls-open":P?"true":"false",className:Oe("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection text-interactive-selection-foreground":Oe("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",P&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Oe("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",P&&"pr-10"),children:[s.jsx("div",{className:Oe("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:A})})}),K?s.jsx(M,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):R?s.jsx("span",{className:Oe("ml-1.5 h-1.5 w-1.5 shrink-0 rounded-full",F?"bg-primary":"bg-[var(--status-info)]",!i&&"group-hover/session-tab:opacity-0",P&&"opacity-0"),"aria-label":X}):null]}),i?null:s.jsxs("div",{onClick:Vb,onPointerDown:Ub,className:Oe("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",P&&"flex opacity-100"),children:[s.jsxs(Ks,{open:x,onOpenChange:oe=>{b(oe),oe&&v(!0)},onOpenChangeComplete:oe=>{oe||v(!1),u?.(oe)},children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"more",className:"size-4"})})}),s.jsx(Ws,{align:"start",className:"min-w-[190px]",children:a(re($b))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]})]})}),e[28]=h,e[29]=X,e[30]=r,e[31]=K,e[32]=F,e[33]=re,e[34]=x,e[35]=l,e[36]=u,e[37]=o,e[38]=P,e[39]=a,e[40]=R,e[41]=i,e[42]=f,e[43]=n,e[44]=A,e[45]=Ae):Ae=e[45];let pe,O;e[46]===Symbol.for("react.memo_cache_sentinel")?(pe={color:"var(--surface-elevated-foreground)"},O=Oe(Ri,"min-w-[190px]"),e[46]=pe,e[47]=O):(pe=e[46],O=e[47]);let Q;e[48]!==re||e[49]!==a?(Q=a(re(zb)),e[48]=re,e[49]=a,e[50]=Q):Q=e[50];let le;e[51]!==Q?(le=s.jsx(Hi,{children:s.jsx(Gi,{className:"app-region-no-drag z-50",children:s.jsx(qi,{"data-slot":"dropdown-menu-content",style:pe,className:O,children:Q})})}),e[51]=Q,e[52]=le):le=e[52];let H;e[53]!==y||e[54]!==ye||e[55]!==Ae||e[56]!==le?(H=s.jsxs(Hu,{open:y,onOpenChange:m,onOpenChangeComplete:ye,children:[Ae,le]}),e[53]=y,e[54]=ye,e[55]=Ae,e[56]=le,e[57]=H):H=e[57];let me;return e[58]!==S||e[59]!==g||e[60]!==C||e[61]!==ue||e[62]!==Se||e[63]!==we||e[64]!==H||e[65]!==ne?(me=s.jsx("div",{ref:C,style:ne,className:ue,"data-active":Se,...we,...S,...g,children:H}),e[58]=S,e[59]=g,e[60]=C,e[61]=ue,e[62]=Se,e[63]=we,e[64]=H,e[65]=ne,e[66]=me):me=e[66],me},Kb=t=>{const e=Ze.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=jt(),d=no(Hb),u=no(Gb),h=no(qb),f=no(Yb),x=tt(Qb),b=tt(Xb),w=$s(Jb);let v,y;e[0]!==x||e[1]!==u?(v=()=>{x&&u(x)},y=[x,u],e[0]=x,e[1]=u,e[2]=v,e[3]=y):(v=e[2],y=e[3]),c.useEffect(v,y);let m;if(e[4]!==w){m=new Map;for(const oe of w)m.set(oe.id,oe);e[4]=w,e[5]=m}else m=e[5];const p=m;let S;if(e[6]!==p||e[7]!==d){S=[];for(const oe of d){const de=p.get(oe);de&&S.push({id:oe,session:de})}e[6]=p,e[7]=d,e[8]=S}else S=e[8];const g=S;let C;e[9]!==b?(C=oe=>{b(oe.id,Ds(oe.session))},e[9]=b,e[10]=C):C=e[10];const k=C,j=Zb;let D;e[11]!==h||e[12]!==x||e[13]!==k||e[14]!==g?(D=oe=>{if(h(oe),x&&x!==oe){const de=g.find(_=>_.id===oe);de&&k(de)}},e[11]=h,e[12]=x,e[13]=k,e[14]=g,e[15]=D):D=e[15];const I=D;let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A={activationConstraint:{distance:8}},e[16]=A):A=e[16];let P;e[17]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{delay:200,tolerance:6}},e[17]=P):P=e[17];const T=Qo(Dn(Jo,A),Dn(Xo,P));let L;e[18]!==f?(L=oe=>{const{active:de,over:_}=oe;_&&de.id!==_.id&&f(String(de.id),String(_.id))},e[18]=f,e[19]=L):L=e[19];const $=L,K=c.useRef(null);let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F={left:!1,right:!1},e[20]=F):F=e[20];const[W,N]=c.useState(F);let R;e[21]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const oe=K.current;if(!oe)return;const de=oe.scrollLeft>2,_=oe.scrollLeft+oe.clientWidth<oe.scrollWidth-2;N(B=>B.left===de&&B.right===_?B:{left:de,right:_})},e[21]=R):R=e[21];const E=R;let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{E();const oe=K.current;if(!oe||!globalThis.ResizeObserver)return;const de=new ResizeObserver(E);return de.observe(oe),()=>de.disconnect()},e[22]=X):X=e[22];let J;e[23]!==g.length?(J=[E,g.length],e[23]=g.length,e[24]=J):J=e[24],c.useEffect(X,J);let re;e[25]===Symbol.for("react.memo_cache_sentinel")?(re=()=>{K.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=re):re=e[25];let fe;e[26]!==x?(fe=[x],e[26]=x,e[27]=fe):fe=e[27],c.useEffect(re,fe);const ne=W.left&&W.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":W.left?"linear-gradient(to right, transparent, black 24px)":W.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let te;e[28]!==g?(te=g.map(ey),e[28]=g,e[29]=te):te=e[29];const ue=te;let Se;e[30]!==x||e[31]!==g?(Se=!x||!g.some(oe=>oe.id===x),e[30]=x,e[31]=g,e[32]=Se):Se=e[32];const we=Se;let ye;e[33]!==a?(ye=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=ye):ye=e[34];let Ae;e[35]!==ne?(Ae=ne?{maskImage:ne,WebkitMaskImage:ne}:void 0,e[35]=ne,e[36]=Ae):Ae=e[36];let pe;e[37]===Symbol.for("react.memo_cache_sentinel")?(pe=[Lb],e[37]=pe):pe=e[37];let O;e[38]!==o||e[39]!==x||e[40]!==I||e[41]!==k||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==g?(O=g.map(oe=>s.jsx(Wb,{tab:oe,isActive:oe.id===x,suppressControls:oe.id===x&&l,onSelect:k,onClose:j,renderMenu:n,closeOtherTabs:I,onMenuOpenChangeComplete:r,children:oe.id===x?o:null},oe.id)),e[38]=o,e[39]=x,e[40]=I,e[41]=k,e[42]=r,e[43]=n,e[44]=l,e[45]=g,e[46]=O):O=e[46];let Q;e[47]!==O||e[48]!==ue?(Q=s.jsx(Wa,{items:ue,strategy:Hx,children:O}),e[47]=O,e[48]=ue,e[49]=Q):Q=e[49];let le;e[50]!==$||e[51]!==T||e[52]!==Q?(le=s.jsx(Zo,{sensors:T,collisionDetection:ei,modifiers:pe,onDragEnd:$,children:Q}),e[50]=$,e[51]=T,e[52]=Q,e[53]=le):le=e[53];let H;e[54]!==o||e[55]!==we?(H=we?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[54]=o,e[55]=we,e[56]=H):H=e[56];let me;e[57]!==Ae||e[58]!==le||e[59]!==H?(me=s.jsxs("div",{ref:K,onScroll:E,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Ae,children:[le,H]}),e[57]=Ae,e[58]=le,e[59]=H,e[60]=me):me=e[60];let ge;return e[61]!==ye||e[62]!==me?(ge=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":ye,children:me}),e[61]=ye,e[62]=me,e[63]=ge):ge=e[63],ge};function Vb(t){return t.stopPropagation()}function Ub(t){return t.stopPropagation()}function Hb(t){return t.tabIds}function Gb(t){return t.ensureTab}function qb(t){return t.closeOtherTabs}function Yb(t){return t.reorderTabs}function Qb(t){return t.currentSessionId}function Xb(t){return t.setCurrentSession}function Jb(t){return t.activeSessions}function Zb(t){tp(t)}function ey(t){return t.id}const Ju=async t=>{const{entry:e,session:n}=t,r=qt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(sp(e.action)&&np(e.guest,"conversation"))){await Sl(e,jl(e.action.id,i),t.t,r);return}let l=!1;const a=Qr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Sl(e,jl(e.action.id,i,d),t.t,r)}};function Qi(t){const e=Ze.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=jt(),{pending:a,disabled:d,hint:u,run:h}=yh(n,r,i),f=a?"loader-4":"ai-generate-2",x=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let b;e[0]!==f||e[1]!==x?(b=s.jsx(M,{name:f,className:x}),e[0]=f,e[1]=x,e[2]=b):b=e[2];let w;e[3]!==l?(w=l("sessions.aiRename.action"),e[3]=l,e[4]=w):w=e[4];let v;e[5]!==o||e[6]!==d||e[7]!==h||e[8]!==b||e[9]!==w?(v=s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:h,className:"w-full",children:[b,w]})})}),e[5]=o,e[6]=d,e[7]=h,e[8]=b,e[9]=w,e[10]=v):v=e[10];let y;e[11]!==u?(y=s.jsx(Dt,{side:"right",children:u}),e[11]=u,e[12]=y):y=e[12];let m;return e[13]!==v||e[14]!==y?(m=s.jsxs(Nt,{children:[v,y]}),e[13]=v,e[14]=y,e[15]=m):m=e[15],m}const Xi=(t,e)=>({success:t(e.success),failure:t(e.failure),sourceVerificationFailed:t("sessions.sidebar.session.moveToWorktree.sourceVerificationFailed"),applyChangesFailed:t("sessions.sidebar.session.moveToWorktree.applyChangesFailed"),changesMayBeInDestination:t("sessions.sidebar.session.moveToWorktree.changesMayBeInDestination")}),Kn=to(()=>({pendingSessionIds:new Set,requestingSessionIds:new Set,confirmation:null})),Zu=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t)||r.requestingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],Kn(n)},ty=()=>Kn(uy),ef=()=>Kn.getState().confirmation,Va=t=>{Kn.setState(e=>e.confirmation===t?e:{...e,confirmation:t})},Gl=(t,e)=>{Kn.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},mr=(t,e)=>{Kn.setState(n=>{if(n.requestingSessionIds.has(t)===e)return n;const r=new Set(n.requestingSessionIds);return e?r.add(t):r.delete(t),{...n,requestingSessionIds:r}})},sy="Unable to apply your changes in the destination directory",ny=t=>t.status===400&&t.message.includes(sy),ry=async(t,e)=>{try{const d=(await Jd(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=ht(t),r=ht(e)??e,i=tt.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>ht(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},ql=t=>{for(const e of t){const n=op(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class tf extends Error{changesMayBeInDestination;constructor(e,n,r){super(e,{cause:n}),this.name="IncompleteRollbackError",this.changesMayBeInDestination=r}}const oy=(t,e,n)=>{const r=e.map(({sessionId:i,error:o})=>`${i}: ${o.message}`).join(", ");return new tf(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${r}`,{moveError:t,rollbackFailures:e},n)},iy=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(ip(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await Zd(o,n,e,!1),tt.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i};class sf extends Error{constructor(e){super(e.message,{cause:e}),this.name="ChangesMayBeInDestinationError"}}const Yl=async(t,e,n)=>{try{await eu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},Ql=async(t,e)=>{const n=e?[t,e]:[t];try{await ka(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},nf=async(t,e)=>{if(Kn.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Gl(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,tt.getState().getWorktreeMetadata(a.id)]));ql(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){ql(n.slice(a));const u=d.id===t.root.id&&t.moveChanges;try{await Zd(d,t.sourceDirectory,i.directory,u)}catch(h){throw u&&rp(h)&&(l=!0),h}o.push(d),d.id!==t.root.id&&tt.getState().setWorktreeMetadata(d.id,kl(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await iy(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await Ql(t.sourceDirectory,i?.directory),u.length>0)throw oy(d,u,l);if(l)throw new sf(d);if(i?.onMoveFailure)return i.onMoveFailure(d);throw d}return tt.getState().setWorktreeMetadata(t.root.id,kl(i.metadata)),await Ql(t.sourceDirectory,i.directory),i.directory}finally{Gl(t.root.id,!1)}},ay=async t=>{const e=ht(t.sourceDirectory)??t.sourceDirectory,n=ht(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return nf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},ly=async t=>nf(t,async()=>{const e=Mi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await ja(t.sourceDirectory)?await ry(t.sourceDirectory,e.path):null,r=await ap(e,n?{startRef:n}:{});try{await lp(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return Yl(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>Yl(e,r,i)}}),cy=(t,e,n)=>e instanceof sf?t.changesMayBeInDestination:e instanceof tf&&e.changesMayBeInDestination?`${e.message} ${t.changesMayBeInDestination}`:n&&ny(e)?t.applyChangesFailed:e.message,Ji=(t,e)=>{(t.kind==="existing"?ay({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination,moveChanges:e}):ly({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,moveChanges:e})).then(()=>Le.success(t.messages.success)).catch(r=>{const i=r instanceof Error?r:new Error(String(r));Le.error(t.messages.failure,{description:cy(t.messages,i,e)})})},dy=()=>{const t=ef();t&&(mr(t.intent.root.id,!1),Va(null))},rf=t=>{const e=ef();if(!e)return;const{intent:n}=e;Va(null),mr(n.root.id,!1),Ji(n,t)},Zi=t=>{const e=Kn.getState();e.confirmation||e.pendingSessionIds.has(t.root.id)||e.requestingSessionIds.has(t.root.id)||(mr(t.root.id,!0),(async()=>{try{if(!await ja(t.sourceDirectory)){mr(t.root.id,!1),Ji(t,!1);return}const r=await Jd(t.sourceDirectory);if(r.isClean){mr(t.root.id,!1),Ji(t,!1);return}const i=r.files.filter(o=>{const l=o.index.trim();return l!==""&&l!=="?"}).length;Va({intent:t,dirtyFileCount:r.files.length,stagedFileCount:i})}catch{Le.error(t.messages.failure,{description:t.messages.sourceVerificationFailed}),mr(t.root.id,!1)}})())};function uy(t){return t.confirmation}const Mo="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",fy=c.memo(function(e){const n=Ze.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:h}=e,f=r===void 0?!0:r,x=h===void 0?!1:h;if(!f)return null;const b=a??Mo,w=x&&"bg-interactive-selection text-interactive-selection-foreground";let v;n[0]!==b||n[1]!==w?(v=Oe(b,w),n[0]=b,n[1]=w,n[2]=v):v=n[2];const y=u??"h-[18px] w-[18px]";let m;n[3]!==d||n[4]!==y?(m=s.jsx(M,{name:d,className:y}),n[3]=d,n[4]=y,n[5]=m):m=n[5];let p;n[6]!==o||n[7]!==l||n[8]!==x||n[9]!==v||n[10]!==m?(p=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":x,className:v,children:m})}),n[6]=o,n[7]=l,n[8]=x,n[9]=v,n[10]=m,n[11]=p):p=n[11];let S;n[12]!==i?(S=s.jsx(Dt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=S):S=n[13];let g;return n[14]!==p||n[15]!==S?(g=s.jsxs(Nt,{children:[p,S]}),n[14]=p,n[15]=S,n[16]=g):g=n[16],g}),my=c.memo(function(e){const n=Ze.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:h,remoteUpdateChecking:f,remoteUpdateError:x,onOpenRemoteUpdate:b}=e,{t:w}=jt();let v;n[0]!==d||n[1]!==a?(v=T=>{a(T),T&&d()},n[0]=d,n[1]=a,n[2]=v):v=n[2];let y;n[3]!==i||n[4]!==r||n[5]!==w?(y=r?w("header.services.openWithCurrent",{current:i}):w("header.services.open"),n[3]=i,n[4]=r,n[5]=w,n[6]=y):y=n[6];const m=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let p;n[7]!==m?(p=Oe(Mo,m),n[7]=m,n[8]=p):p=n[8];let S;n[9]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(M,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=S):S=n[9];let g;n[10]!==i||n[11]!==r?(g=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=g):g=n[12];let C;n[13]!==y||n[14]!==p||n[15]!==g?(C=s.jsx(At,{asChild:!0,children:s.jsx(zs,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":y,className:p,children:[S,g]})})}),n[13]=y,n[14]=p,n[15]=g,n[16]=C):C=n[16];let k;n[17]!==i||n[18]!==u||n[19]!==w?(k=w("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=w,n[20]=k):k=n[20];let j;n[21]!==k?(j=s.jsx(Dt,{children:s.jsx("p",{children:k})}),n[21]=k,n[22]=j):j=n[22];let D;n[23]!==C||n[24]!==j?(D=s.jsxs(Nt,{children:[C,j]}),n[23]=C,n[24]=j,n[25]=D):D=n[25];let I;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==b||n[30]!==f||n[31]!==x||n[32]!==h||n[33]!==a||n[34]!==w?(I=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:w("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:h?.available?w("header.services.remoteUpdate.available",{version:h.version||""}):f?w("header.services.remoteUpdate.checking"):x||w("header.services.remoteUpdate.upToDate")})]}),h?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:b,children:w("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(cp,{embedded:!0,open:l,onOpenChange:py,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=b,n[30]=f,n[31]=x,n[32]=h,n[33]=a,n[34]=w,n[35]=I):I=n[35];let A;n[36]!==I?(A=s.jsx(Ws,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:I}),n[36]=I,n[37]=A):A=n[37];let P;return n[38]!==l||n[39]!==v||n[40]!==D||n[41]!==A?(P=s.jsxs(Ks,{open:l,onOpenChange:v,children:[D,A]}),n[38]=l,n[39]=v,n[40]=D,n[41]=A,n[42]=P):P=n[42],P}),jn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Xl=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,hy=()=>{Gs("ui.header.render");const{t}=jt(),e=Pe(U=>U.isSidebarOpen),n=Pe(U=>U.openContextOverview),r=Pe(U=>U.closeContextPanel),i=Pe(U=>U.shortcutOverrides),o=Pe(U=>U.sessionTabsEnabled),l=tt(U=>U.getContextUsage),a=tt(U=>!!U.newSessionDraft?.open),d=tt(U=>U.currentSessionId),u=dp(d??""),h=Sa(d??""),f=Zu(d??""),x=$s(rr(c.useCallback(U=>{if(!d)return null;const Te=[...U.activeSessions,...U.archivedSessions].find(Et=>Et.id===d);if(!Te)return null;const ot=Te;return{title:Te.title??null,directory:ot.directory??null,created:Te.time?.created??null,slug:ot.slug??null,shareUrl:Te.share?.url??null,parentId:Te.parentID??null}},[d]))),b=Ht(rr(U=>{if(!U.activeProjectId)return null;const Te=U.projects.find(ot=>ot.id===U.activeProjectId);return Te?{id:Te.id,path:Te.path,label:Te.label}:null})),w=c.useMemo(()=>{if(!b)return null;const U=b.label?.trim();if(U)return U;const Te=b.path.split(/[\\/]/).filter(Boolean);return Te[Te.length-1]??null},[b]),v=ur(U=>U.loadSettings),{isMobile:y}=zn(),m=c.useRef(null),[p,S]=c.useState(()=>typeof window>"u"?!1:xn()),g=c.useMemo(()=>Ur(),[]),C=tu(),[k,j]=c.useState(!1),D=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:I,side:A}=Lu(),P=c.useMemo(()=>{if(typeof window>"u")return null;const U=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof U=="number"&&Number.isFinite(U)&&U>0)return U;if(typeof navigator>"u")return null;const Te=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Te)return null;const ot=Number.parseInt(Te[1],10),Et=Number.parseInt(Te[2],10);return Number.isNaN(ot)?null:ot===10?Et:ot},[]);mt.useEffect(()=>{typeof window>"u"||S(xn())},[]);const{context:T,output:L}=up(d),$=l(T,L),[K,F]=c.useState(null),W=!d||u;mt.useEffect(()=>{if(!d){F(U=>U===null?U:null);return}if($){F(U=>fp(U,$)?U:$);return}W&&F(U=>U===null?U:null)},[$,d,W]);const[N,R]=c.useState(!1),[E,X]=c.useState("Local"),[J,re]=c.useState(!0),[fe,ne]=c.useState(!1),[te,ue]=c.useState(null),[Se,we]=c.useState(!1),[ye,Ae]=c.useState(null),pe=c.useMemo(()=>$n(),[]),O=Pe(U=>U.workStatusPanelVisible),Q=Pe(U=>U.workStatusPanelEnabled),le=Pe(U=>U.setWorkStatusPanelEnabled),H=Pe(U=>U.workStatusPanelFits),me=Pe(U=>U.workStatusOverlayOpen),ge=Pe(U=>U.setWorkStatusOverlayOpen),de=Q&&H||me,_=c.useCallback(()=>{if(Q&&!H){ge(!me);return}le(!Q)},[ge,le,me,Q,H]),B=!pe&&!O&&!!K,he=c.useCallback(async()=>{if(!(typeof window>"u"||!p))try{if(Vo()){X("Local"),re(!0);return}re(!1);const U=await Td(),Te=Fm(),ot=_m([Lm(Te),...U.hosts]);if(ot.id===$m){X("Local"),re(!0);return}X(Ed(ot.label.trim()||"Instance"))}catch{X("Local"),re(!0)}},[p]);mt.useEffect(()=>(he(),Qr(()=>{he()})),[he]);const ve=c.useCallback(async()=>{if(J){ue(null),Ae(null);return}we(!0),Ae(null);try{const U=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),Te=await ls(`/api/openchamber/update-check?${U.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!Te.ok)throw new Error(`Server responded with ${Te.status}`);const ot=await Te.json();ue({available:ot.available??!1,version:ot.version,currentVersion:ot.currentVersion??"unknown",body:ot.body,nextSuggestedCheckInSec:typeof ot.nextSuggestedCheckInSec=="number"?ot.nextSuggestedCheckInSec:void 0,packageManager:ot.packageManager,updateCommand:ot.updateCommand})}catch(U){ue(null),Ae(U instanceof Error?U.message:t("header.services.remoteUpdate.error"))}finally{we(!1)}},[J,t]);c.useEffect(()=>{ue(null),Ae(null),ne(!1)},[J,E]),c.useEffect(()=>{if(!p||J)return;const U=3e3,Te=3600*1e3;let ot=!1,Et=null;const Mt=$t=>{Et=window.setTimeout(()=>{if(ot||typeof document<"u"&&document.visibilityState!=="visible"){Mt(Te);return}ve().finally(()=>{ot||Mt(Te)})},$t)};return Mt(U),()=>{ot=!0,Et!==null&&window.clearTimeout(Et)}},[ve,J,E,p]);const Re=c.useCallback(()=>{if(te?.available){ne(!0);return}ve()},[ve,te?.available]);mp(),c.useEffect(()=>{v()},[v]);const ce=d?x??null:null,se=c.useRef(null),[q,z]=c.useState(0);c.useEffect(()=>{if(!d){se.current&&(se.current=null,z(Et=>Et+1));return}if(ce){se.current={sessionId:d,session:ce,expiresAt:Date.now()+2e3};return}const U=se.current;if(!U||U.sessionId!==d)return;const Te=U.expiresAt-Date.now();if(Te<=0){se.current=null,z(Et=>Et+1);return}const ot=window.setTimeout(()=>{se.current?.sessionId===d&&(se.current=null),z(Et=>Et+1)},Te);return()=>{window.clearTimeout(ot)}},[d,ce]);const ee=(()=>{if(ce)return ce;if(!d)return null;const U=se.current;return U&&U.sessionId===d&&U.expiresAt>Date.now()?U.session:null})(),ae=tt(U=>d?U.worktreeMetadata.get(d)?.path??"":""),Ne=tt(U=>d?U.worktreeMetadata.get(d)?.branch?.trim()??null:null),Ce=su(U=>d?U.getAttachment(d):void 0),We=c.useMemo(()=>Ce?hp(Ce,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,Ce]),Ee=c.useMemo(()=>Ce?Ce.legacy?"legacy":Ce.degraded?"degraded":Ce.worktreeStatus==="pending"?"pending":Ce.worktreeStatus==="missing"?"missing":Ce.worktreeStatus==="invalid"?"invalid":Ce.attentionReason?"attention":null:null,[Ce]),xe=c.useMemo(()=>jn(ae||""),[ae]),$e=c.useMemo(()=>{const U=typeof ee?.directory=="string"?ee.directory:"";return jn(U||"")},[ee?.directory]),V=va(d??"",$e),De=tt(U=>U.newSessionDraft?.open?jn(U.newSessionDraft.bootstrapPendingDirectory??U.newSessionDraft.directoryOverride??""):""),Fe=tt(U=>U.newSessionDraft.target),_e=tt(U=>U.newSessionDraft.selectedProjectId),rt=tt(U=>U.currentSessionDirectory),ct=ns(U=>U.homeDirectory),et=c.useMemo(()=>xe||$e||De,[De,$e,xe]),pt=Pe(c.useCallback(U=>{const Te=jn(et||"");return Te?Xl(U.contextPanelByDirectory[Te]):null},[et])),kt=tt(U=>{const Te=jn(xe||$e||"");if(!Te)return null;for(const ot of U.availableWorktreesByProject.values()){const Mt=ot.find($t=>jn($t.path)===Te)?.branch?.trim();if(Mt)return Mt}return null}),Xe=pp(et||null)||Ne||kt,yt=a?Fe==="chat":gp($e||rt,ct),Rt=!yt&&!O&&!!(w||Xe||!a&&Ee),be=c.useMemo(()=>{if(!d)return w??"OpenChamber";const U=ee?.title?.trim();return U&&U.length>0?U:"Untitled Session"},[w,ee?.title,d]),Ge=nu(et||void 0,{bootstrap:!1}),ut=ru(),Y=tt(U=>U.updateSessionTitle),G=tt(U=>U.shareSession),Z=tt(U=>U.unshareSession),je=tt(U=>U.archiveSessions),Ie=tt(U=>U.deleteSessions),[Ve,Je]=c.useState(!1),[it,at]=c.useState(!1),Ye=c.useRef(null),[vt,Ue]=c.useState(""),[Pt,ke]=c.useState(null),xt=c.useRef(null),Ct=c.useCallback(()=>{d&&(Ue(ee?.title?.trim()||be),Je(!0))},[ee?.title,d,be]),Tt=c.useRef(Ct);Tt.current=Ct;const qe=c.useCallback(U=>{U&&(U.focus(),U.select())},[]);c.useEffect(()=>{if(at(!1),ke(null),d&&Ye.current===d){Ye.current=null,Tt.current();return}Je(!1),Ue("")},[d]);const ze=c.useCallback(async()=>{if(!d)return;const U=vt.trim();U&&U!==ee?.title?.trim()&&await Y(d,U),Je(!1)},[ee?.title,d,vt,Y]);c.useEffect(()=>{if(!Ve)return;const U=Te=>{const ot=Te.target;(!ot||!xt.current?.contains(ot))&&ze()};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[Ve,ze]);const ft=c.useCallback(U=>{U&&gn(U).then(Te=>{Le[Te.ok?"success":"error"](t(Te.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(t("sessions.sidebar.session.copyId.error")))},[t]),Be=c.useCallback(async U=>{if(!U)return;const Te=await G(U);if(Te?.share?.url){const ot=await gn(Te.share.url);Le[ot.ok?"success":"warning"](t("sessions.sidebar.session.share.successTitle"),{description:t(ot.ok?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")});return}Le.error(t("sessions.sidebar.session.share.error"))},[G,t]),Ke=c.useCallback(U=>{U&&gn(U).then(Te=>{Le[Te.ok?"success":"error"](t(Te.ok?"sessions.sidebar.session.menu.copied":"sessions.sidebar.session.share.copyUrlError"))}).catch(()=>Le.error(t("sessions.sidebar.session.share.copyUrlError")))},[t]),He=c.useCallback(async U=>{if(!U)return;const Te=await Z(U);Le[Te?"success":"error"](t(Te?"sessions.sidebar.session.unshare.success":"sessions.sidebar.session.unshare.error"))},[t,Z]),nt=c.useCallback(async()=>{if(!d||!et){Le.error(t("sessions.sidebar.session.export.nothingToExport"));return}try{await ut.loadCompleteHistory(d,et)}catch{Le.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}const U=Cl(Ge.getState(),d).list;if(U.length===0){Le.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Te=ou(U,ee?.title??null),ot=iu(ee?.title??null);await au(Te,ot)||lu(Te,ot),Le.success(t("sessions.sidebar.session.export.success"))},[ee?.title,d,Ge,et,ut,t]),St=cu(),Lt=c.useMemo(()=>du(St),[St]),Ut=c.useCallback(U=>{d&&Ju({entry:U,t,session:{id:d,title:ee?.title,directory:$e??et},loadRecords:async()=>{if(!et)return null;try{await ut.loadCompleteHistory(d,et)}catch{return null}return Cl(Ge.getState(),d).list},onLoadFailed:()=>Le.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[ee?.title,d,Ge,et,$e,ut,t]),Bt=c.useCallback(U=>Lt.map(Te=>s.jsxs(U,{onClick:()=>Ut(Te),children:[s.jsx(Xr,{icon:Te.icon,iconSrc:Te.iconSrc,className:"mr-1 size-4"}),Te.action.label]},`${Te.guest.id}:${Te.action.id}`)),[Lt,Ut]),zt=h?.type==="busy"||h?.type==="retry",_t=c.useCallback(()=>{if(!d||!$e||zt||f)return;const U=$s.getState().activeSessions,Te=U.find(Mt=>Mt.id===d);if(!Te)return;const ot=[],Et=[d];for(let Mt=0;Mt<Et.length;Mt+=1){const $t=Et[Mt];for(const Wt of U)Wt.parentID===$t&&(ot.push(Wt),Et.push(Wt.id))}Zi({kind:"quick",root:Te,descendants:ot,sourceDirectory:$e,messages:Xi(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,zt,f,$e,t]),Yt=c.useCallback(async()=>{if(!Pt)return;const U=Pt.action,Te=[Pt.sessionId,..._d(Pt.sessionId,[],U==="delete")];if(ke(null),(U==="archive"?await je(Te):await Ie(Te)).failedIds.length>0){Le.error(t(U==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Le.success(t(U==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[je,Ie,Pt,t]),Zt=Pe(U=>U.openGuestPageId),es=uu(U=>U.guests.find(Te=>Te.id===Zt)),Vt=Pe(U=>U.isScheduledTasksDialogOpen),It=Pe(U=>U.isArchivePageOpen),bt=Pe(U=>U.worktreesPageProjectId),cs=Pe(U=>U.isMultiRunLauncherOpen),ms=Ht(U=>{if(!bt)return null;const Te=U.projects.find(ot=>ot.id===bt);return Te?.label?.trim()||Te?.path?.split("/").pop()||null}),hs=c.useMemo(()=>es?{title:es.pageTitle??es.name,subtitle:null}:Vt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:It?{title:t("sessions.archivePage.title"),subtitle:null}:bt?{title:t("sessions.worktreesPage.title",{project:ms??""}),subtitle:null}:cs?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[es,It,cs,Vt,t,bt,ms]),ds=c.useMemo(()=>jn(et||b?.path||""),[b?.path,et]),nn=_b(),Ts=Ca(U=>U.planModeEnabled),rn=tt(U=>U.isSessionPlanAvailable),os=Ts&&d?rn(d):!1,qs=c.useRef("");c.useEffect(()=>{if(!Ts||!d)return;const U=`${d||"none"}:${$e||"none"}:${ee?.created||0}:${ee?.slug||"none"}`;qs.current!==U&&(qs.current=U)},[Ts,os,ee?.slug,ee?.created,d,$e]);const Ys=c.useCallback(()=>{_n("desktop_open_draft_mini_chat_window",{directory:yt?"":De,projectId:yt?null:_e,apiBaseUrl:Pn(),clientToken:Hr()}).catch(U=>{console.warn("[header] failed to open draft mini chat window",U)})},[De,_e,yt]),Cs=c.useCallback(()=>{if(a){Ys();return}d&&_n("desktop_open_session_mini_chat_window",{sessionId:d,directory:$e||jn(rt||"")||xe,apiBaseUrl:Pn(),clientToken:Hr()}).catch(U=>{console.warn("[header] failed to open session mini chat window",U)})},[d,Ys,a,rt,$e,xe]),Ns=c.useCallback(()=>{const U=jn(et||"");if(!U)return;const Te=Pe.getState().contextPanelByDirectory[U];if(Xl(Te)==="context"){r(U);return}n(U)},[r,n,et]),mn=pt==="context",Es=Mo,Rs=c.useMemo(()=>p&&D&&!k?"88px":C?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!p||I)&&!pe?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[p,k,D,C,pe,I]);mt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",Rs)},[Rs]);const Qs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",on=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";mt.useEffect(()=>{if(!p||!D){j(!1);return}let U=!1;const Te=async()=>{try{const Et=await _n("desktop_is_window_fullscreen");U||j(Et===!0)}catch{U||j(!1)}},ot=()=>{Te()};return Te(),window.addEventListener("openchamber:window-resized",ot),()=>{U=!0,window.removeEventListener("openchamber:window-resized",ot)}},[p,D]);const an=c.useMemo(()=>!p||!D||P===null?"":P>=26?"h-12":P<=15?"h-14":"",[p,D,P]),ps=c.useMemo(()=>{if(!(p&&!I||pe)&&!(I&&A==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[p,pe,I,A]),vs=c.useCallback(()=>{if(typeof document>"u")return;const U=m.current?.getBoundingClientRect().height;U&&document.documentElement.style.setProperty("--oc-header-height",`${U}px`)},[]);mt.useEffect(()=>{if(typeof window>"u")return;vs();const U=m.current;if(!U||typeof ResizeObserver>"u")return()=>{};let Te=0;const ot=()=>{Te||(Te=requestAnimationFrame(()=>{Te=0,vs()}))},Et=new ResizeObserver(ot);return Et.observe(U),window.addEventListener("resize",ot),window.addEventListener("orientationchange",ot),()=>{Te&&cancelAnimationFrame(Te),Et.disconnect(),window.removeEventListener("resize",ot),window.removeEventListener("orientationchange",ot)}},[vs]),mt.useEffect(()=>{vs()},[vs,y,an]);const ln=c.useCallback(async U=>{const Te=U.target;Te.closest(".app-region-no-drag")||Te.closest("button, a, input, select, textarea")||U.button===0&&p&&await zm()},[p]),Sn=c.useCallback(U=>er(Jr(U,i)),[i]);xp({rename_current_session:()=>{if(!d||y)return!1;Ct()},toggle_services_menu:()=>{if(N){R(!1);return}R(!0),he()}});const ie=s.jsxs(s.Fragment,{children:[nn?s.jsx(Bb,{projectRef:nn.projectRef,directory:nn.directory,className:"mr-2"}):null,s.jsx(db,{directory:ds,className:"mr-1"}),p?s.jsx(my,{isDesktopApp:p,currentInstanceLabel:E,currentInstanceIsLocal:J,isDesktopServicesOpen:N,setIsDesktopServicesOpen:R,refreshCurrentInstanceLabel:he,shortcutLabel:Sn,remoteUpdateInfo:te,remoteUpdateChecking:Se,remoteUpdateError:ye,onOpenRemoteUpdate:Re}):null]}),Qe=g&&(a||!!d),lt=c.useCallback(({session:U,open:Te,isActive:ot,select:Et,closeOtherTabs:Mt,components:$t})=>{const{Item:Wt,Separator:Ss}=$t,is=U.share?.url??null,Vn=ot&&!pe&&!yt&&ee&&!ee.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(Wt,{onClick:()=>{ot||Et(),Ye.current=U.id},children:[s.jsx(M,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(Qi,{sessionID:U.id,directory:U.directory,open:Te,Item:Wt}),s.jsxs(Wt,{onClick:()=>ft(U.id),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Ss,{}),is?s.jsxs(s.Fragment,{children:[s.jsxs(Wt,{onClick:()=>Ke(is),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Wt,{onClick:()=>{He(U.id)},children:[s.jsx(M,{name:"link-unlink-m",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Wt,{onClick:()=>{Be(U.id)},children:[s.jsx(M,{name:"share-2",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.share")]}),ot?s.jsxs(Wt,{onClick:()=>{nt()},children:[s.jsx(M,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,ot?Bt(Wt):null,Vn?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Wt,{disabled:!$e||zt||f,onClick:_t,className:"w-full",children:[s.jsx(M,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(Dt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":zt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Ss,{}),s.jsxs(Wt,{onClick:Mt,children:[s.jsx(M,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(Ss,{}),s.jsxs(Wt,{onClick:()=>ke({action:"archive",sessionId:U.id}),children:[s.jsx(M,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Wt,{className:"text-destructive focus:text-destructive",onClick:()=>ke({action:"delete",sessionId:U.id}),children:[s.jsx(M,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[ft,Ke,ee,nt,yt,zt,f,pe,_t,Bt,$e,Be,t,He]),st=()=>s.jsxs("div",{onMouseDown:ln,className:Oe("app-region-drag relative flex h-12 select-none items-center",I&&A==="right"?"pr-0":"pr-3",an),style:ps,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Qs}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:on}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[hs?s.jsxs(s.Fragment,{children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>Pe.getState().closeMainSurfaces(),children:s.jsx(M,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(Dt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:hs.title}),hs.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:hs.subtitle}):null]})]}):pe||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[V?s.jsx(M,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(Kl,{align:"start",children:s.jsx("button",{type:"button",className:Es,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(M,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[Ve?s.jsxs("form",{ref:xt,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:U=>U.stopPropagation(),onSubmit:U=>{U.preventDefault(),ze()},children:[s.jsx("input",{ref:qe,value:vt,onChange:U=>Ue(U.target.value),onKeyDown:U=>Ti(U,()=>Je(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Je(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):be}),Rt?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[w?s.jsx("span",{className:"truncate",children:w}):null,Xe?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(M,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:Xe})]}):null,!a&&Ee?s.jsxs("span",{className:Oe("inline-flex min-w-0 items-center gap-0.5",Ee==="attention"||Ee==="invalid"||Ee==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(M,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:We})]}):null]}):null]}),s.jsx("div",{className:Oe("flex h-[18px] shrink-0 items-center justify-center",Rt?"self-start":"self-center"),children:d&&!a&&!Ve?s.jsxs(Ks,{open:it,onOpenChange:at,onOpenChangeComplete:U=>{!U&&Ye.current&&Ye.current===d&&(Ye.current=null,Ct())},children:[s.jsx(zs,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(M,{name:"more",className:"size-4"})})}),s.jsxs(Ws,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Kt,{onClick:()=>{Ye.current=d},children:[s.jsx(M,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(Qi,{sessionID:d,directory:$e,open:it,Item:Kt}),s.jsxs(Kt,{onClick:()=>d&&ft(d),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Os,{}),ee?.shareUrl?s.jsxs(s.Fragment,{children:[s.jsxs(Kt,{onClick:()=>Ke(ee?.shareUrl),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Kt,{onClick:()=>{d&&He(d)},children:[s.jsx(M,{name:"link-unlink-m",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Kt,{onClick:()=>{d&&Be(d)},children:[s.jsx(M,{name:"share-2",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.share")]}),s.jsxs(Kt,{onClick:()=>{nt()},children:[s.jsx(M,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),Bt(Kt),!pe&&!yt&&ee&&!ee.parentId?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Kt,{disabled:!$e||zt||f,onClick:_t,className:"w-full",children:[s.jsx(M,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(Dt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":zt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Os,{}),s.jsxs(Kt,{onClick:()=>{d&&ke({action:"archive",sessionId:d})},children:[s.jsx(M,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Kt,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&ke({action:"delete",sessionId:d})},children:[s.jsx(M,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(Kl,{align:"start",children:s.jsx("button",{type:"button",className:Es,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(M,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Kb,{renderMenu:lt,suppressActiveTabControls:Ve,onMenuOpenChangeComplete:U=>{!U&&Ye.current&&Ye.current===d&&(Ye.current=null,Ct())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:Ve?s.jsxs("form",{ref:xt,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:U=>U.stopPropagation(),onSubmit:U=>{U.preventDefault(),ze()},children:[s.jsx("input",{ref:qe,value:vt,onChange:U=>Ue(U.target.value),onKeyDown:U=>Ti(U,()=>Je(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Je(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):be})})})]}),hs||pe||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[B&&K?s.jsx(Dx,{reading:Px(K),contextLimit:K.contextLimit,outputLimit:K.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Ns,pressed:mn,className:Qe?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(fy,{visible:Qe,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Cs,className:Oe(Es,"mr-1"),Icon:"picture-in-picture-2"}),pe?null:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":de,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:_,className:Oe(Mo,"mr-1",de?"text-foreground":"text-muted-foreground/50"),children:s.jsx(M,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(Dt,{side:"bottom",children:t(Q&&!H?me?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":Q?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ie,s.jsx($u,{visible:I&&A==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:m,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:st()}),s.jsx(ys,{open:Pt!==null,onOpenChange:U=>{U||ke(null)},children:s.jsxs(ws,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Vs,{children:[s.jsx(Ps,{children:Pt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Is,{children:Pt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:be}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:be})})]}),s.jsxs(bn,{children:[s.jsx(dt,{variant:"outline",size:"sm",onClick:()=>ke(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",size:"sm",onClick:()=>{Yt()},children:Pt?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Ld,{open:fe,onOpenChange:ne,info:te,downloading:!1,downloaded:!1,progress:null,error:ye,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function py(){}const Jl=280,Zl=168,ec=500,gy=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=jt(),l=Pe(j=>j.sidebarWidth),a=Pe(j=>j.setSidebarWidth),[d,u]=c.useState(!1),h=c.useRef(0),f=c.useRef(l||Jl),x=c.useRef(null),b=c.useRef(null),w=c.useRef(null),v=c.useCallback(j=>Math.min(ec,Math.max(Zl,j)),[]),y=c.useCallback(j=>{const D=w.current;D&&(D.style.width=`${j}px`,D.style.minWidth=`${j}px`,D.style.maxWidth=`${j}px`,D.style.setProperty("--oc-left-sidebar-width",`${j}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(x.current=null,b.current=null)},[d]),e)return null;const m=Math.min(ec,Math.max(Zl,l||Jl)),p=t?m:0,S=j=>{if(t){try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}b.current=j.pointerId,u(!0),h.current=j.clientX,f.current=p,x.current=p,y(p),j.preventDefault()}},g=j=>{if(e||!d||b.current!==j.pointerId)return;const D=j.clientX-h.current,I=v(f.current+D);x.current!==I&&(x.current=I,y(I))},C=j=>{if(b.current!==j.pointerId||e)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const D=v(x.current??p);b.current=null,x.current=null,u(!1),a(D)},k=d?x.current??p:p;return s.jsxs("aside",{ref:w,className:Oe("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${k}px`,minWidth:`${k}px`,maxWidth:`${k}px`,"--oc-left-sidebar-width":`${d?k:m}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||p===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:Oe("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:S,onPointerMove:g,onPointerUp:C,onPointerCancel:C,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Oe("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(yn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(As,{children:n})})]})]})},xy=()=>{const t=Ze.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},tc="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:bg-interactive-hover transition-colors",by=()=>{const t=Ze.c(32),{t:e}=jt(),n=Pe(yy),r=Pe(wy),i=c.useRef(null),o=er(Jr("toggle_sidebar",r)),{usesFramelessChrome:l,side:a}=Lu(),d=Sy;let u,h;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{if(typeof document>"u")return;const T=i.current;if(!T)return;const L=()=>{const K=Math.max(T.getBoundingClientRect().width,T.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(K)}px`)};if(L(),typeof ResizeObserver>"u")return;const $=new ResizeObserver(L);return $.observe(T),()=>{$.disconnect()}},h=[],t[0]=u,t[1]=h):(u=t[0],h=t[1]),c.useEffect(u,h);const f="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let x;t[2]===Symbol.for("react.memo_cache_sentinel")?(x={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=x):x=t[2];const b="flex items-center gap-2";let w;t[3]!==l||t[4]!==a?(w=l&&a==="left"?s.jsx($u,{visible:!0,position:"left"}):null,t[3]=l,t[4]=a,t[5]=w):w=t[5];let v;t[6]!==e||t[7]!==l?(v=l?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,"aria-label":e("header.actions.openAppMenuAria"),className:Oe(tc,"shrink-0"),children:s.jsx(M,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(Dt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=l,t[8]=v):v=t[8];const y=Nt;let m;t[9]!==e?(m=e("header.actions.openSessionsAria"),t[9]=e,t[10]=m):m=t[10];let p,S;t[11]===Symbol.for("react.memo_cache_sentinel")?(p=Oe(tc,"shrink-0"),S=s.jsx(M,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=p,t[12]=S):(p=t[11],S=t[12]);let g;t[13]!==m||t[14]!==n?(g=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":m,className:p,children:S})}),t[13]=m,t[14]=n,t[15]=g):g=t[15];const C=Dt,k=e("header.actions.openSessionsWithShortcut",{shortcut:o});let j;t[16]!==k?(j=s.jsx("p",{children:k}),t[16]=k,t[17]=j):j=t[17];let D;t[18]!==C||t[19]!==j?(D=s.jsx(C,{children:j}),t[18]=C,t[19]=j,t[20]=D):D=t[20];let I;t[21]!==y||t[22]!==g||t[23]!==D?(I=s.jsxs(y,{children:[g,D]}),t[21]=y,t[22]=g,t[23]=D,t[24]=I):I=t[24];let A;t[25]!==I||t[26]!==w||t[27]!==v?(A=s.jsxs("div",{ref:i,className:b,children:[w,v,I]}),t[25]=I,t[26]=w,t[27]=v,t[28]=A):A=t[28];let P;return t[29]!==A||t[30]!==x?(P=s.jsx("div",{className:f,style:x,children:A}),t[29]=A,t[30]=x,t[31]=P):P=t[31],P};function yy(t){return t.toggleSidebar}function wy(t){return t.shortcutOverrides}function vy(t){console.warn("[titlebar] failed to open app menu",t)}function Sy(t){const e=t.currentTarget.getBoundingClientRect();_n("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(vy)}function of(t){const e=Ze.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(M,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const sc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function jy(t,e,n){const r=Ze.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,h]=await Promise.all([bp(t),yp(t)]).catch(ky);if(d)return;const f=sc(u),x=sc(h);if(!f||!x||x===f)return;const b=n||"",w=x.split("/").filter(Boolean).pop()||x;o({source:"sdk",path:x,projectDirectory:f,branch:b,label:b||w,name:w,worktreeRoot:x,worktreeStatus:"ready",headState:b?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function ky(){return["",""]}const nc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Cy=async(t,e)=>{if(t)return t.authActivate(e);const n=await ls("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},rc=({className:t})=>{const{t:e}=jt(),{github:n}=vn(),r=In(b=>b.status),i=In(b=>b.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async b=>{if(!(!b||o)){l(!0);try{i(await Cy(n,b))}catch(w){console.error("Failed to switch GitHub account:",w)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,h=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),x=u?s.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(M,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return h.length<=1?s.jsx("div",{className:Oe(nc,t),title:f,children:x}):s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe(nc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:x})}),s.jsxs(Ws,{align:"end",className:"w-64",children:[s.jsx(Fr,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(Os,{}),h.map(b=>{const w=b.user,v=!!b.current,y=b.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(Kt,{className:"gap-2",disabled:o,onSelect:()=>{v||a(b.id)},children:[w?.avatarUrl?s.jsx("img",{src:w.avatarUrl,alt:w.login?e("header.github.avatarWithLogin",{login:w.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(M,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:w?.name?.trim()||w?.login||"GitHub"}),w?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:w.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:y})]}):null]}),v?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},b.id)})]})]})};class ni extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const ri="/api/walkthrough",af=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),lf=()=>new ni("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Ny=t=>!af(t)&&(t.ok||t.status===404),Ua=async(t,e)=>{if(Ny(t))throw lf();const n=await t.json().catch(()=>null);throw new ni(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},cf=async t=>{if(!af(t))throw lf();try{return await t.json()}catch{throw new ni("The server returned a malformed walkthrough response")}};async function Ay(t,e,n={}){const r=await ls(ri,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?cf(r):Ua(r,"Failed to load walkthrough")}async function Dy(t,e,n={}){const r=await ls(`${ri}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?cf(r):Ua(r,"Failed to generate walkthrough")}async function Py(t,e){const n=await ls(`${ri}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Ua(n,"Failed to cancel walkthrough generation")}async function Iy(t,e,n){const r=await ls(`${ri}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const Dr={status:"idle",stage:null,result:null,readiness:null,error:null},Ty=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,Rn=(t,e)=>`${qt()}\0${t}\0${Ty(e)}`,oc=t=>t instanceof ni?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},Zs=new Map,Pr=new Map,Ey=1e3,Ry=to()(Qx((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=Rn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[Rn(n,r)],selectModel:(n,r,i)=>{const o=Rn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[Rn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[Rn(n,r)]??Dr,load:async(n,r,i={})=>{if(!n)return;const o=Rn(n,r);if(e().entries[o]?.status==="generating")return;Zs.get(o)?.abort();const a=new AbortController;Zs.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Dr,status:"loading",error:null}}}));try{const d=await Ay(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Dr,status:"error",stage:null,error:oc(d)}}}))}finally{Zs.get(o)===a&&Zs.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=Rn(n,r);Zs.get(o)?.abort();const l=new AbortController;Zs.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Dr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Pr.get(o);d!==void 0&&(clearInterval(d),Pr.delete(o))};a(),Pr.set(o,setInterval(()=>{Iy(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const h=u.entries[o];return!h||h.status!=="generating"||h.stage===d?u:{entries:{...u.entries,[o]:{...h,stage:d}}}})}).catch(()=>{})},Ey));try{const d=await Dy(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Dr,status:"error",stage:null,error:oc(d)}}}))}finally{a(),Zs.get(o)===l&&Zs.delete(o)}},cancel:(n,r)=>{const i=Rn(n,r);Py(n,r).catch(()=>{}),Zs.get(i)?.abort(),Zs.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of Zs.values())n.abort();Zs.clear();for(const n of Pr.values())clearInterval(n);Pr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),My="border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]",Oy=3e4,ic=20,df=(t,e)=>JSON.stringify([qt(),t,e]),By=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},ac=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),ro=new Map,Fy=t=>{const e=Object.entries(t);return e.length<=ic?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,ic))},lc=to()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=df(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<Oy&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const h=`${l}::${a?"details":"plain"}`,x=ro.get(`${l}::details`)??(a?null:ro.get(h));if(x&&!o?.force)return x;const b=(async()=>{t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??ac(),isLoading:!0,error:null}}}));try{const w=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(v=>({entries:Fy({...v.entries,[l]:{result:w,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),w}catch(w){const v=w instanceof Error?w.message:"Failed to load pull request context";return t(y=>({entries:{...y.entries,[l]:{...y.entries[l]??ac(),isLoading:!1,error:v}}})),null}finally{ro.delete(h)}})();return ro.set(h,b),b},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=By(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),_y=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},Ly=35e3,hi=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},pi=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},cc=t=>{switch(t){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},$y=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},zy=[2e3,5e3],Wy=600,dc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),On=t=>{let e=t.trim();return e?(e.startsWith("refs/heads/")&&(e=e.slice(11)),e.startsWith("heads/")&&(e=e.slice(6)),e.startsWith("remotes/")&&(e=e.slice(8)),e):""},Ky=(t,e)=>{const n=On(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},Vy=(t,e)=>`${t}::${e}`,Ha=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},gi=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=Ha(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},Uy=t=>t.startsWith("pr-"),Hy=(t,e)=>{const n=Ha(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!Uy(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Ir=new Map,oo=Uo;function Gy(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const qy=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=jt(),d=Pe(ie=>ie.timeFormatPreference),{github:u}=vn(),h=In(ie=>ie.status),f=In(ie=>ie.hasChecked),x=Pe(ie=>ie.setSettingsDialogOpen),b=Pe(ie=>ie.setSettingsPage),w=tt(ie=>ie.currentSessionId),v=tt(ie=>!!ie.newSessionDraft?.open),{isMobile:y,hasTouchInput:m,screenWidth:p}=zn(),S=Pe(ie=>ie.openContextSurface),g=Ry(ie=>ie.requestSource),C=!y&&p>=768&&!$n(),k=c.useCallback(()=>{b("integrations"),x(!0)},[x,b]),j=c.useMemo(()=>Vy(t,e),[t,e]),D=c.useMemo(()=>Ir.get(j)??null,[j]),I=Hs(ie=>ie.ensureEntry),A=Hs(ie=>ie.setParams),P=Hs(ie=>ie.startWatching),T=Hs(ie=>ie.stopWatching),L=Hs(ie=>ie.refresh),$=Hs(ie=>ie.updateStatus),[K,F]=c.useState(()=>D?.title??dc(e)),[W,N]=c.useState(()=>D?.body??""),[R,E]=c.useState(()=>D?.draft??!1),[X,J]=c.useState(()=>D?.additionalContext??""),[re,fe]=c.useState(()=>{const ie=typeof D?.targetBaseBranch=="string"?On(D.targetBaseBranch):"";return ie||On(n)}),[ne,te]=c.useState("squash"),[ue,Se]=c.useState(!1),[we,ye]=c.useState(!1),[Ae,pe]=c.useState(!1),[O,Q]=c.useState(!1),[le,H]=c.useState(!1),[me,ge]=c.useState(!1),[oe,de]=c.useState(null),[_,B]=c.useState(""),[he,ve]=c.useState(""),[Re,ce]=c.useState(!1),[se,q]=c.useState(!1),[z,ee]=c.useState(()=>gi(i,{selectedRemoteName:D?.selectedRemoteName,trackingBranch:r})),[ae,Ne]=c.useState(!1),{detectedUpstream:Ce,upstreamBranches:We}=Gy(t,u);c.useEffect(()=>{Ne(!1)},[t]);const Ee=i.some(ie=>ie.name==="upstream"),$e=!!(t&&e&&n&&(e!==n||(Ee||Ce!==null))),V=c.useMemo(()=>Ho(t,e,z?.name??null),[t,e,z?.name]),De=Hs(ie=>ie.entries[V]),Fe=De?.isLoading??!1,_e=De?.status??null,rt=De?.error??null,ct=De?.isInitialStatusResolved??!1,et=c.useMemo(()=>{const ie=ae?null:z?.name?.trim()||null,Qe=new Set;for(const gt of o){const U=Ky(gt,ie);!U||U==="HEAD"||Qe.add(U)}if(ae)for(const gt of We)gt&>!=="HEAD"&&Qe.add(gt);const lt=On(n);lt&<!=="HEAD"&&Qe.add(lt);const st=On(re);return st&&st!=="HEAD"&&Qe.add(st),Array.from(Qe).sort((gt,U)=>gt.localeCompare(U))},[n,o,z?.name,re,We,ae]);c.useEffect(()=>{if(i.length===0){z&&ee(null);return}(!z||!i.some(ie=>ie.name===z.name))&&ee(gi(i,{selectedRemoteName:D?.selectedRemoteName,trackingBranch:r}))},[D?.selectedRemoteName,i,z,r]),c.useEffect(()=>{const ie=On(n);if(!re&&ie){fe(ie);return}if(et.length!==0&&!et.includes(re)){const Qe=et.includes(ie)?ie:et[0];Qe&&fe(Qe)}},[et,n,re]);const[pt,kt]=c.useState(()=>D?.activeSegment??"overview"),[wt,Xe]=c.useState(new Set),[yt,Rt]=c.useState(new Set),be=c.useRef(new Set),Ge=c.useRef(null),ut=c.useRef(!1),Y=c.useRef(new Set),G=c.useRef([]);c.useEffect(()=>{Ce&&!Ee&&Ne(!0)},[Ce,Ee]),c.useEffect(()=>{ae&&Ce?.defaultBranch&&fe(Ce.defaultBranch)},[ae,Ce?.defaultBranch]);const Z=_e?.pr??null,je=Z?.state==="merged"||Z?.state==="closed",Ie=je?null:Z,Ve=Ie?df(t,Ie.number):null,Je=lc(ie=>Ve?ie.entries[Ve]:void 0),it=lc(ie=>ie.ensure),at=Je?.result??null,Ye=Je?.isLoading??!1,vt=c.useCallback(ie=>{kt(ie);const Qe=Ir.get(j);Qe&&Ir.set(j,{...Qe,activeSegment:ie})},[j]);c.useEffect(()=>{!Ie||!u?.prContext||pt==="overview"||it(u,t,Ie.number,{includeCheckDetails:pt==="checks",sourceRepo:_e?.repo??null})},[pt,t,it,u,Ie,_e?.repo]);const Ue=_e?.checks??null,Pt=(Ue?.pending??0)>0,ke=at?.checkRuns??null,xt=at?.fetchedAt;c.useEffect(()=>{if(!ke||ke.length===0)return;const ie=_y(ke);$(V,Qe=>{if(!Qe?.pr||typeof xt=="number"&&typeof Qe.fetchedAt=="number"&&xt<Qe.fetchedAt)return Qe;const lt=Qe.checks;return lt&<.state===ie.state&<.total===ie.total&<.success===ie.success&<.failure===ie.failure&<.pending===ie.pending&<.inProgress===ie.inProgress&<.queued===ie.queued&<.startedAt===ie.startedAt?Qe:{...Qe,checks:ie,...typeof xt=="number"?{fetchedAt:xt}:{}}})},[ke,xt,V,$]),c.useEffect(()=>{if(pt!=="checks"||!Pt||!Z||!u?.prContext)return;const ie=window.setInterval(()=>{it(u,t,Z.number,{includeCheckDetails:!0,sourceRepo:_e?.repo??null,force:!0})},Ly);return()=>window.clearInterval(ie)},[pt,Pt,t,it,u,Z,_e?.repo]);const[Ct,Tt]=c.useState(()=>Date.now());c.useEffect(()=>{if(!Pt)return;Tt(Date.now());const ie=window.setInterval(()=>Tt(Date.now()),3e4);return()=>window.clearInterval(ie)},[Pt]);const qe=Z?`${t}#${Z.number}`:null,ze=!!(qe&&oe===qe);c.useEffect(()=>{if(!u?.prContext||!Z||typeof Z.body=="string"&&Z.body.length>0)return;const ie=`${t}#${Z.number}`;if(be.current.has(ie))return;be.current.add(ie),de(ie);let Qe=!1;return it(u,t,Z.number,{sourceRepo:_e?.repo??null}).then(lt=>{if(Qe)return;const st=lt?.pr;st&&$(V,gt=>!gt?.pr||gt.pr.number!==Z.number?gt:{...gt,pr:{...gt.pr,body:st.body||""}})}).catch(()=>{}).finally(()=>{Qe||de(lt=>lt===ie?null:lt)}),()=>{Qe=!0}},[t,it,u,Z,V,_e?.repo,$]),c.useEffect(()=>{if(!Z){ge(!1),B(""),ve(""),Ge.current=null;return}const ie=Ge.current!==null&&Ge.current!==Z.number;ie&&ge(!1),(!me||ie)&&(B(Z.title||""),ve(Z.body||"")),Ge.current=Z.number},[me,Z]);const ft=c.useCallback(ie=>{if(!ie)return"";const Qe=Date.parse(ie);return Number.isFinite(Qe)?fu(Qe,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):ie},[d]),Be=c.useMemo(()=>{const ie=h?.user?.login;return typeof ie=="string"?ie.trim():""},[h]),Ke=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),He=c.useCallback(ie=>{const Qe=Be.toLowerCase(),lt=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return ie.replace(lt,(st,gt,U)=>{const Te=`@${U}`,ot=U.toLowerCase();return`${gt}[${Te}](https://github.com/${ot}${Qe&&ot===Qe?"?oc-self-mention=1":""})`})},[Be]),nt=c.useMemo(()=>{const ie=(at?.issueComments??[]).map(st=>({id:`issue-${st.id}`,body:st.body||"",authorName:st.author?.name||st.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:st.author?.login||null,avatarUrl:st.author?.avatarUrl||null,createdAt:st.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),Qe=(at?.reviewComments??[]).map(st=>({id:`review-${st.id}`,body:st.body||"",authorName:st.author?.name||st.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:st.author?.login||null,avatarUrl:st.author?.avatarUrl||null,createdAt:st.createdAt,context:a("gitView.pr.comments.reviewContext"),path:st.path||null,line:st.line??null})),lt=[...ie,...Qe];return lt.sort((st,gt)=>{const U=st.createdAt?Date.parse(st.createdAt):0,Te=gt.createdAt?Date.parse(gt.createdAt):0,ot=Number.isFinite(U)?U:0,Et=Number.isFinite(Te)?Te:0;return ot-Et}),lt},[at,a]),St=c.useCallback(()=>{const ie=w??(v?"draft":null);return ie?{directory:t,sessionKey:ie}:(Le.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[w,t,v,a]),Lt=c.useCallback((ie,Qe)=>{const lt=Qe.authorLogin?`@${Qe.authorLogin}`:Qe.authorName,st=Qe.path?` · ${Qe.path}${Qe.line?`:${Qe.line}`:""}`:"";Oi.getState().addDraft(ie,{source:"pr-comment",fileLabel:`PR #${Z?.number??""} ${lt}${st}`,startLine:Qe.line??0,endLine:Qe.line??0,code:Qe.body,language:"markdown",text:""})},[Z?.number]),Ut=c.useCallback((ie,Qe)=>{const lt=ie.status||"unknown",st=ie.conclusion??void 0,gt=st?`${lt} / ${st}`:lt,U=ie.app?.name||ie.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:Qe?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[Qe?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:ie.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:U?`${U} · ${gt}`:gt})]}),ie.detailsUrl?s.jsx(dt,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:ie.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(M,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),ie.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:ie.output.title}):null,ie.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:ie.output.summary}):null,ie.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:ie.output.text}):null,Array.isArray(ie.annotations)&&ie.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",ie.annotations.length>20?` (showing 20/${ie.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:ie.annotations.slice(0,20).map((Te,ot)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[Te.title||Te.level||"Issue",Te.path?` · ${Te.path}`:"",typeof Te.startLine=="number"?`:${Te.startLine}`:"",typeof Te.endLine=="number"&&Te.endLine!==Te.startLine?`-${Te.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:Te.message}),Te.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:Te.rawDetails}):null]},`${Te.path||"file"}:${Te.startLine||ot}:${ot}`))})]}):null,ie.job?.steps&&ie.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:ie.job.steps.map((Te,ot)=>{const Et=(Te.conclusion||"").toLowerCase(),Mt=Et&&!["success","neutral","skipped"].includes(Et),$t=`${ie.id??"run"}:${ie.job?.jobId??"job"}:${Te.number??ot}:${Te.name}`,Wt=wt.has($t);return Mt?s.jsxs(Bi,{open:Wt,children:[s.jsxs("button",{type:"button",onClick:()=>{Xe(Ss=>{const is=new Set(Ss);return is.has($t)?is.delete($t):is.add($t),is})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(Mt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[Wt?s.jsx(M,{name:"arrow-down-s",className:"size-4"}):s.jsx(M,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:Te.name}),Te.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Te.conclusion}):null]}),s.jsx(Fi,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof Te.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",Te.number]}):null,Te.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",Te.status]}):null,Te.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",Te.conclusion]}):null,Te.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",ft(Te.startedAt)]}):null,Te.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",ft(Te.completedAt)]}):null]})})]},$t):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:Te.name}),Te.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Te.conclusion}):null]},$t)})})]}):null]})},[wt,ft,a]),[Bt,zt]=c.useState(!1),[_t,Yt]=c.useState(!1),Zt=c.useCallback(async()=>{if(!u?.prContext){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!Z)return;const ie=St();if(ie){zt(!0);try{const Qe=await it(u,t,Z.number,{includeCheckDetails:!0,sourceRepo:_e?.repo??null});if(!Qe){Le.error(a("gitView.pr.toast.loadChecksFailed"));return}const st=(Qe.checkRuns??[]).filter(U=>pi(U.conclusion));if(st.length===0){Le.message(a("gitView.pr.toast.noFailedChecks"));return}const gt=Oi.getState();for(const U of st){const Te=(U.annotations??[]).map(Mt=>[[Mt.level,Mt.title].filter(Boolean).join(" "),Mt.path?`${Mt.path}${typeof Mt.startLine=="number"?`:${Mt.startLine}`:""}`:null,Mt.message,Mt.rawDetails].filter(Boolean).join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-BZyjhqHv.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-ne84JBVL.js","assets/index-Dqc6USl3.js","assets/vendor-zod-CgAdXWZO.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-DqaMWNrC.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-CsXYnR5c.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.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-framer-motion-Bq3iTZ6r.js","assets/vendor-motion-dom-DcCgeG69.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-ClYN8CzB.js","assets/vendor-tanstack-virtual-core-BewVQryB.js","assets/contextPanelEmbeddedChat-CirXEPJq.js","assets/vendor-sonner-DFyL3AvE.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-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-Bx2EHc1O.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/patchFileDiff-D7QVlovD.js","assets/runtimeEndpointReset-DdrazOVH.js","assets/GuestAttachDialog-B808E0-d.js","assets/PluginPane-DEcgDQ9h.js","assets/VirtualizedFileDiff-NU0FHFhT.js","assets/web-components-DxX8bZ1o.js","assets/computeVirtualFileMetrics-DlWlEM3x.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/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.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/isDiffPlainText-CO4e5J_S.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-CEDZNkU2.js","assets/Virtualizer-D_a8gKmg.js","assets/useInlineCommentController-CgS0fnw_.js","assets/appThemeRegistry-DLicw4dH.js","assets/textMateThemeFromAppTheme-DWqRPo9A.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/useRootScrollLock-Cpf1qoGp.js","assets/scheduledTasksApi-B2SWMGEU.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-B2CD9wC8.js","assets/SubmoduleDiffSummary-oxeACCWs.js","assets/FilesView-C4vMFclc.js","assets/shikiHighlight-BPu3JiQs.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-VW_7czo3.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-ue6kCou7.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-B4a0JkUz.js","assets/GitView-Byu2DY7s.js","assets/commitAndPush-BDftrjr6.js","assets/LinearIssuesView-EzGNCGrd.js","assets/PlanView-D3x-pTkZ.js","assets/SettingsWindow-B5CHoJFZ.js","assets/SettingsView-CSinuH-1.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-strip-json-comments-5dJlOkP1.js","assets/OnboardingScreen-CQHBSTEi.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as Ze,R as c,j as s,r as mt,c as Rm,h as Mm}from"./vendor-react-BUCujlKS.js";import"./vendor-katex-CHD9BdDO.js";import{E as xn,F as Vo,H as Om,I as Bm,h as ls,x as Id,u as Pe,J as Ot,K as ll,a as qt,A as Qr,o as ht,L as Gs,N as Ur,O as $n,P as Td,Q as Fm,R as _m,S as Lm,T as $m,U as Ed,n as ns,V as _n,W as Hr,e as Pn,X as zm,Y as Wm,Z as Km,_ as Vm,$ as Rd,v as hn,B as Cn,a0 as Um,a1 as Hm,a2 as cl,a3 as Gm,a4 as ya,a5 as qm,a6 as Md,f as Ym,a7 as Zn,a8 as Ai,a9 as Qm,aa as Di,ab as cr,ac as wa,d as Do,t as Br,q as us,ad as Od,ae as Xm,af as Jm,ag as Pi,ah as Bd,ai as Fd,i as Zm,aj as bo,ak as yo,al as eh,am as dl,an as th,ao as sh,ap as nh,aq as rh,ar as ul,as as fl,at as ml,au as hl,av as oh,z as pl,aw as ih,ax as ah,ay as lh,C as ch,D as dh}from"./index-Dqc6USl3.js";import{_ as En}from"./vendor-vite-runtime-DD1OZmLC.js";import{v as gl,w as ai,x as cn,y as Ii,z as xl,E as uh,F as fh,G as mh,H as hh,I as ph,J as gh,K as xh,L as bh,M as va,b as yh,c as _d,U as Ld,h as Ti,j as $d,Q as wh,i as vh,f as Sh,R as zd,V as Ei,W as Qn,X as Wd,Y as Kd,P as jh,T as kh,Z as Ch,_ as Nh,$ as Ah,a as Vd,a0 as Dh,a1 as Ud,a2 as Po,a3 as Ph,a4 as Ih,a5 as Th,S as bl,a6 as Eh,r as Rh,a7 as Mh,a8 as Oh,a9 as Bh,aa as yl,u as zr,s as Fh,N as _h,D as Lh,ab as $h,ac as wl,ad as zh,ae as li,o as Wh,m as Kh,q as Hd,t as Vh,af as Uh,ag as Hh,ah as Gh,l as qh,n as Yh,O as Gd,A as Qh,C as Xh}from"./runtimeEndpointReset-DdrazOVH.js";import{f as jt,h as Oe,be as Kt,I as M,g as gn,t as Le,aq as zs,bf as Os,as as Ws,ap as Ks,S as or,Z as vn,af as ir,bg as zn,o as Uo,bh as vl,bi as Jh,bj as Zh,aa as Nt,ab as At,ac as Dt,b as Ht,z as tt,H as ep,bk as qd,bl as no,u as $s,C as Sa,r as Ds,D as Yd,bm as Ri,bn as tp,bo as Qd,bp as Xd,bq as sp,br as np,bs as Sl,bt as jl,bu as ja,bv as Jd,bw as Zd,bx as rp,by as kl,bz as op,bA as ip,bB as ka,bC as Mi,bD as ap,bE as lp,Q as eu,bF as cp,bG as dp,n as ur,bH as tu,bI as up,bJ as fp,p as mp,bK as su,bL as hp,bM as pp,bN as gp,bO as nu,bP as ru,bQ as Cl,bR as ou,bS as iu,bT as au,bU as lu,bV as cu,bW as du,bX as Xr,bY as uu,aF as Ca,bZ as er,b_ as Jr,b$ as xp,c0 as ys,c1 as ws,c2 as Vs,c3 as Ps,c4 as Is,c5 as bn,B as dt,c6 as yn,ay as As,c7 as bp,c8 as yp,aD as In,c9 as Fr,ca as Hs,cb as Ho,cc as fu,cd as Oi,ce as Bi,cf as Fi,cg as wp,ch as Bs,ci as Fs,cj as ks,ck as _s,cl as ss,W as An,cm as fr,cn as Nl,co as pr,cp as mu,R as Go,ag as vp,ah as Na,ai as hu,J as pu,K as Tn,cq as Aa,a5 as Da,cr as Sp,cs as jp,aw as kp,ct as Cp,cu as gu,cv as Np,cw as Ap,ax as Pa,cx as Dp,cy as xu,cz as gr,cA as bu,cB as Pp,l as Gt,s as Ip,cC as Tp,cD as Zr,cE as Ep,aL as eo,cF as Rp,cG as dr,O as yu,cH as Mp,cI as Op,cJ as Wn,cK as Bp,cL as Fp,aA as _p,cM as ci,cN as wu,cO as Ia,cP as Lp,cQ as vu,cR as $p,aE as _i,cS as Li,cT as Al,cU as zp,cV as Dl,cW as _r,c as Gr,d as Ta,a1 as Wp,cX as Su,cY as Ar,cZ as Lr,c_ as Kp,c$ as Vp,d0 as Up,_ as Ea,az as Hp,d1 as Gp,d2 as qp,d3 as Yp,d4 as Qp,d5 as ju,d6 as fn,d7 as Xp,d8 as ku,d9 as Jp,da as $i,db as Zp,dc as Cu,dd as fs,de as eg,df as tg,dg as sg,dh as Nu,di as ng,dj as Ra,dk as Au,a3 as Io,dl as zi,dm as qo,a as Ma,dn as Oa,a2 as rg,dp as Pl,dq as og,dr as Wi,ds as Du,dt as ig,ar as Pu,du as ag,P as Ki,L as lg,dv as Il,dw as cg,dx as dg,dy as Jt,dz as ug,dA as Ln,dB as Ba,dC as Iu,dD as fg,dE as Tu,dF as Eu,dG as mg,E as hg,dH as pg,dI as gg,dJ as xg,dK as Tl,dL as bg,dM as yg,dN as Ru,F as wg,dO as vg,dP as Sg,dQ as wo,dR as jg,dS as kg,dT as Cg,dU as Ng,e as Fa,U as _a,T as La,V as $a,dV as Yo,dW as Ag,dX as qr,a0 as Dg,dY as Pg,dZ as El,d_ as Ig,d$ as Tg,e0 as Eg,aY as Rl,a7 as Ml,a6 as Ol,e1 as Rg,aT as Vi,e2 as Mg,M as Og,N as di,e3 as Bg,e4 as Fg,e5 as Mu,e6 as Ou,e7 as Bu,e8 as _g,G as za,e9 as Lg,a4 as $g,aj as zg,ea as Wg,eb as Bl,ec as Kg,ed as Vg,ee as Ug,ef as Hg,eg as To,eh as Gg,ei as Fl,ej as qg,ek as Yg,el as Qg,em as Xg,en as Ui,eo as Jg,ep as vo,eq as Zg,i as ex,er as tx,es as sx,et as nx,eu as rx,ev as ox,ew as ix,a8 as ax,ex as lx,ey as cx,ez as dx,eA as ux,eB as _l,eC as fx,aM as mx,aN as hx,aP as px,aO as gx,aR as Ll,aS as $l,aV as zl,aW as Wl,aU as Fu,aX as _u,eD as xx,b9 as bx,ba as yx,bb as wx,bc as vx,bd as Sx,b3 as jx,b5 as kx,b6 as Cx,b7 as Nx,b8 as Ax}from"./useAppFontEffects-ne84JBVL.js";import{u as Lu,S as Kl,C as Dx,t as Px,W as $u,f as Ix,G as Tx,a as Ex}from"./useRootScrollLock-Cpf1qoGp.js";import{u as Un,O as Vl,D as Rx,a as Mx,b as Ox,n as Bx,f as Fx,c as Ul,s as _x,d as Lx,e as $x,r as zx}from"./scheduledTasksApi-B2SWMGEU.js";import{f as Qo,h as Dn,T as Xo,M as Jo,D as Zo,j as ei,d as Wx,b as Kx,k as Vx,i as Ux}from"./vendor-dnd-kit-core-BZknOX2w.js";import{u as ti,S as Wa,h as Hx,a as zu,v as Wu,s as Gx}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as si}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{S as Ku,M as Vu,C as Uu,a as Hi,b as Gi,c as qi,d as Hu,e as qx,f as Yx}from"./vendor-base-ui-CsXYnR5c.js";import{c as to,u as rr,d as Qx,p as Xx}from"./vendor-zustand-BAGL70zf.js";import{g as Jx,a as Zx,E as Gu,b as eb,c as tb,d as sb,e as nb,i as rb}from"./contextPanelEmbeddedChat-CirXEPJq.js";import{P as ob}from"./PluginPane-DEcgDQ9h.js";import{a as Ka,s as jr,r as qu}from"./vendor-zod-CgAdXWZO.js";import{u as ib}from"./vendor-tanstack-react-virtual-ClYN8CzB.js";import{d as ab}from"./vendor-tanstack-virtual-core-BewVQryB.js";import{d as Yu}from"./vendor-cron-parser-CUcP7OfX.js";const lb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",cb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",ui=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?lb:t.id==="terminal"?cb:void 0}),Hl=t=>{const e=Ze.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=t,[o,l]=c.useState(!1);let a;e[0]!==n?(a=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=a):a=e[1];const d=a,u=r||i;if(u&&!o){let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=()=>l(!0),e[2]=x):x=e[2];let b;return e[3]!==u?(b=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:x}),e[3]=u,e[4]=b):b=e[4],b}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=Oe("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:h,children:d}),e[6]=d,e[7]=f):f=e[7],f},db=t=>{const e=Ze.c(75),{directory:n,className:r}=t,{t:i}=jt(),o=Un(ub),l=Un(fb),a=Un(mb),d=Un(hb),u=Un(pb),h=Un(gb),f=Un(xb);let x,b;e[0]!==u?(x=()=>{u()},b=[u],e[0]=u,e[1]=x,e[2]=b):(x=e[1],b=e[2]),c.useEffect(x,b);const w=xn()&&Vo();let v;e:{let we;e[3]!==l||e[4]!==o?(we=l.find(pe=>pe.id===o)??l.find(bb)??l[0]??Vl[0],e[3]=l,e[4]=o,e[5]=we):we=e[5];const ye=we;if(ye){let pe;e[6]!==ye?(pe=ui(ye),e[6]=ye,e[7]=pe):pe=e[7],v=pe;break e}let Ae;e[8]===Symbol.for("react.memo_cache_sentinel")?(Ae=ui(Vl[0]),e[8]=Ae):Ae=e[8],v=Ae}const y=v;if(!w||!n||l.length===0)return null;let m;e[9]!==n?(m=async we=>{await Om(n,we.id,we.appName)||await Bm(n,we.appName)},e[9]=n,e[10]=m):m=e[10];const p=m;let S;e[11]!==p||e[12]!==f?(S=async we=>{await f(we.id),await p(we)},e[11]=p,e[12]=f,e[13]=S):S=e[13];const g=S;let C;e[14]!==n||e[15]!==i?(C=async()=>{(await gn(n)).ok&&Le.success(i("openInApp.toast.pathCopied"))},e[14]=n,e[15]=i,e[16]=C):C=e[16];const k=C;let j;e[17]!==r?(j=Oe("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=j):j=e[18];let D;e[19]!==p||e[20]!==y?(D=()=>{p(y)},e[19]=p,e[20]=y,e[21]=D):D=e[21];const I=d&&"animate-pulse";let A;e[22]!==I?(A=Oe("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",I),e[22]=I,e[23]=A):A=e[23];let P;e[24]!==y.label||e[25]!==i?(P=i("openInApp.actions.openInAria",{app:y.label}),e[24]=y.label,e[25]=i,e[26]=P):P=e[26];let T;e[27]!==y.fallbackIconDataUrl||e[28]!==y.iconDataUrl||e[29]!==y.label?(T=s.jsx(Hl,{label:y.label,iconDataUrl:y.iconDataUrl,fallbackIconDataUrl:y.fallbackIconDataUrl}),e[27]=y.fallbackIconDataUrl,e[28]=y.iconDataUrl,e[29]=y.label,e[30]=T):T=e[30];let L;e[31]!==A||e[32]!==P||e[33]!==T||e[34]!==D?(L=s.jsx("button",{type:"button",onClick:D,className:A,"aria-label":P,children:T}),e[31]=A,e[32]=P,e[33]=T,e[34]=D,e[35]=L):L=e[35];let $;e[36]===Symbol.for("react.memo_cache_sentinel")?($=Oe("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=$):$=e[36];let K;e[37]!==i?(K=i("openInApp.actions.chooseAppAria"),e[37]=i,e[38]=K):K=e[38];let F;e[39]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(M,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=F):F=e[39];let W;e[40]!==K?(W=s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:$,"aria-label":K,children:F})}),e[40]=K,e[41]=W):W=e[41];let N;e[42]!==k?(N=()=>{k()},e[42]=k,e[43]=N):N=e[43];let R;e[44]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(M,{name:"file-copy",className:"h-4 w-4"}),e[44]=R):R=e[44];let E;e[45]!==i?(E=i("openInApp.actions.copyPath"),e[45]=i,e[46]=E):E=e[46];let X;e[47]!==E?(X=s.jsx("span",{className:"typography-ui-label text-foreground",children:E}),e[47]=E,e[48]=X):X=e[48];let J;e[49]!==N||e[50]!==X?(J=s.jsxs(Kt,{className:"flex items-center gap-2",onClick:N,children:[R,X]}),e[49]=N,e[50]=X,e[51]=J):J=e[51];let re;e[52]===Symbol.for("react.memo_cache_sentinel")?(re=s.jsx(Os,{}),e[52]=re):re=e[52];let fe;if(e[53]!==l||e[54]!==g||e[55]!==y.id){let we;e[57]!==g||e[58]!==y.id?(we=ye=>{const Ae=ui(ye);return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{g(ye)},children:[s.jsx(Hl,{label:ye.label,iconDataUrl:ye.iconDataUrl,fallbackIconDataUrl:Ae.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:ye.label}),y.id===ye.id?s.jsx(M,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},ye.id)},e[57]=g,e[58]=y.id,e[59]=we):we=e[59],fe=l.map(we),e[53]=l,e[54]=g,e[55]=y.id,e[56]=fe}else fe=e[56];let ne;e[60]!==a||e[61]!==h||e[62]!==i?(ne=a?s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(M,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=h,e[62]=i,e[63]=ne):ne=e[63];let te;e[64]!==J||e[65]!==fe||e[66]!==ne?(te=s.jsxs(Ws,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[J,re,fe,ne]}),e[64]=J,e[65]=fe,e[66]=ne,e[67]=te):te=e[67];let ue;e[68]!==W||e[69]!==te?(ue=s.jsxs(Ks,{children:[W,te]}),e[68]=W,e[69]=te,e[70]=ue):ue=e[70];let Se;return e[71]!==L||e[72]!==ue||e[73]!==j?(Se=s.jsxs("div",{className:j,children:[L,ue]}),e[71]=L,e[72]=ue,e[73]=j,e[74]=Se):Se=e[74],Se};function ub(t){return t.selectedAppId}function fb(t){return t.availableApps}function mb(t){return t.isCacheStale}function hb(t){return t.isScanning}function pb(t){return t.initialize}function gb(t){return t.loadInstalledApps}function xb(t){return t.selectApp}function bb(t){return t.id===Rx}const Eo=new Map,Yi=new Set,Qu=()=>{for(const t of Yi)t()},fi=(t,e)=>{const n=t.trim();n&&(e.length===0?Eo.delete(n):Eo.set(n,[...e]),Qu())},yb=t=>{Eo.delete(t.trim())&&Qu()},Xu=[],wb=t=>Eo.get(t.trim())??Xu,vb=t=>(Yi.add(t),()=>{Yi.delete(t)}),Sb=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=()=>wb(t),e[0]=t,e[1]=n):n=e[1],c.useSyncExternalStore(vb,n,jb)};function jb(){return Xu}const kb=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Cb=["dev","start","preview","serve"];async function Nb(t,e,n){if(!t)return null;const r=Pb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const i=Ib(n);if(i){const o=await Tb(t);return{command:`${o==="npm"?"npm run":o==="yarn"?"yarn":o==="pnpm"?"pnpm":o==="bun"?"bun run --shell=bun":"npm run"} ${i}`,label:`Start (${i})`}}}if(await Ab(t)){const i=await Db(),o=typeof i=="number"&&Number.isFinite(i)&&i>0?i:8e3;return{command:`python3 -m http.server ${o}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${o}/`}}return null}async function Ab(t){const e=`${t}/index.html`,n=await Ro(e,t);return typeof n=="string"&&n.trim().length>0}async function Db(){try{const t=await ls("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Pb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Cb.some(i=>n.includes(i)))return e}return null}function Ib(t){for(const{pattern:e}of kb)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Tb(t){const e=await Ro(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),i=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(i.startsWith("bun@"))return"bun";if(i.startsWith("pnpm@"))return"pnpm";if(i.startsWith("yarn@"))return"yarn";if(i.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,i]of n){const o=await Ro(`${t}/${r}`,t);if(typeof o=="string"&&o.trim().length>0)return i}return"npm"}async function Ro(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),i=await ls(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(i.ok)return i.text()}catch{}const n=Id()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await ls(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Eb(t){try{const e=await Ro(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const un="__openchamber_auto_discover_preview__",Rb=15e3,Mb=3e3,mi=t=>t.id===un?"scan-2":bh.find(n=>n.key===t.icon)?.Icon??"play",Ob=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Bb=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:i=!1})=>{const{t:o}=jt(),{currentTheme:l}=or(),{terminal:a,runtime:d}=vn(),u=ir(),{isMobile:h}=zn(),f=c.useMemo(()=>xn(),[]),x=gl(G=>G.instances),b=gl(G=>G.load),w=Pe(G=>G.terminalShell),v=Pe(G=>G.terminalLoginShells.includes(G.terminalShell)),y=Pe(G=>G.setSettingsPage),m=Pe(G=>G.setSettingsDialogOpen),p=Pe(G=>G.setSettingsProjectsSelectedId),S=Pe(G=>G.openContextPreview),g=Ot(G=>G.ensureDirectory),C=Ot(G=>G.reconcileServerSessions),k=Ot(G=>G.setTabLabel),j=Ot(G=>G.setTabIconKey),D=Ot(G=>G.setActiveTab),I=Ot(G=>G.setConnecting),A=Ot(G=>G.setTabSessionId),P=Ot(G=>G.setTabPurpose),T=Ot(G=>G.allocateActionExecution),L=Ot(G=>G.setTabLifecycle),$=Ot(G=>G.setTabPreviewUrl),K=Ot(G=>G.matchesActionExecution),F=Ot(G=>G.captureStartedActionMutationRevisions),[W,N]=c.useState([]),R=c.useRef(null),[E,X]=c.useState(null),[J,re]=c.useState(!1),fe=c.useRef({}),ne=c.useRef({}),te=c.useRef({}),ue=c.useRef(new Set),Se=c.useRef(0),[we,ye]=c.useState({}),Ae=t?.id??null,pe=t?.path??"",O=c.useMemo(()=>Ae?{id:Ae,path:pe}:null,[Ae,pe]);c.useEffect(()=>{f&&b().catch(()=>{})},[f,b]);const Q=c.useCallback(async G=>{await Uo(G)},[]),le=c.useCallback(async()=>{if(!O)return;const G=Se.current+1;Se.current=G,re(!0);try{const Z=await vl(O);if(Se.current!==G)return;R.current=Z;const je=Z.projectActions;N(je),X(Ie=>Ie===un||Ie&&je.some(Ve=>Ve.id===Ie)?Ie:null)}catch{if(Se.current!==G)return}finally{Se.current===G&&re(!1)}},[O]),H=c.useMemo(()=>ai(e||O?.path||""),[e,O?.path]),me=c.useMemo(()=>ai(O?.path||""),[O?.path]),ge=c.useMemo(()=>ai(u||"")||H,[u,H]),oe=c.useRef(ge);c.useEffect(()=>{oe.current=ge},[ge]);const de=Ot(G=>H?G.getDirectoryState(H):void 0),_=Ot(G=>me&&me!==H?G.getDirectoryState(me):void 0),B=c.useMemo(()=>{const G=H?[{directory:H,state:de}]:[];return me&&me!==H&&G.push({directory:me,state:_}),G},[de,H,me,_]),he=c.useMemo(()=>{const G=H?[H]:[];return me&&me!==H&&G.push(me),G},[H,me]),ve=c.useCallback(G=>G.id!==un&&G.runIn==="parent"&&me||H,[H,me]),Re=c.useCallback((G,Z,je)=>`${G}::${Z}::${je}`,[]),ce=c.useCallback((G,Z,je=Ot.getState())=>G?je.getDirectoryState(G)?.tabs.find(Ie=>Ie.purpose.type==="project-action"&&Ie.purpose.actionId===Z)??null:null,[]),se=c.useMemo(()=>{const G={};for(const{directory:Z,state:je}of B)for(const Ie of je?.tabs??[]){if(Ie.purpose.type!=="project-action"||!Ie.purpose.executionId||!Ie.terminalSessionId||Ie.lifecycle==="idle"||Ie.lifecycle==="exited")continue;const Ve=cn(Z,Ie.purpose.actionId),Je=Re(Z,Ie.purpose.actionId,Ie.purpose.executionId);G[Ve]={directory:Z,actionId:Ie.purpose.actionId,tabId:Ie.id,sessionId:Ie.terminalSessionId,executionId:Ie.purpose.executionId,status:Ie.lifecycle==="stopping"?"stopping":we[Je]?"waiting-for-preview":"running"}}return G},[Re,we,B]),q=c.useCallback((G,Z,je)=>{const Ie=cn(G,Z),Ve=Re(G,Z,je),it=fe.current[Ie]?.executionId===je,at=globalThis.window,Ye=vt=>{at?.clearTimeout(te.current[vt]),delete te.current[vt]};it&&(delete fe.current[Ie],Ye(Ie)),ne.current[Ve]?.(),delete ne.current[Ve],Ye(Ve),ye(vt=>{if(!vt[Ve])return vt;const Ue={...vt};return delete Ue[Ve],Ue})},[Re]),z=c.useCallback(G=>{ne.current[G]?.(),delete ne.current[G]},[]),ee=c.useCallback(G=>{window.clearTimeout(te.current[G]),delete te.current[G]},[]);c.useEffect(()=>{const G=ne.current,Z=te.current;return()=>{for(const je of Object.keys(G))z(je);for(const je of Object.keys(Z))ee(je)}},[ee,z]),c.useEffect(()=>{const G=new Set(he);for(const Z of Object.values(fe.current))G.has(Z.directory)||q(Z.directory,Z.actionId,Z.executionId);for(const Z of Object.keys(ne.current)){const je=Z.split("::",1)[0]??"";G.has(je)||z(Z)}},[q,z,he]);const ae=c.useCallback((G,Z)=>{Pe.getState().openContextPanelTab(G,{mode:"terminal",targetDirectory:Z===G?null:Z})},[]),Ne=c.useMemo(()=>E?W.find(G=>G.id===E)??null:null,[W,E]),Ce=c.useMemo(()=>({id:un,name:o("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[o]),We=!h,Ee=c.useMemo(()=>We?[Ce,...W]:W,[W,Ce,We]);c.useEffect(()=>{le()},[le]),c.useEffect(()=>{const G=he.map(Z=>Ii(a,Z,F,je=>C(Z,je.sessions,{startedActionMutationRevisions:je.startedActionMutationRevisions})));return()=>{for(const Z of G)Z()}},[F,C,a,he]),c.useEffect(()=>{for(const{directory:G,state:Z}of B)if(G)for(const je of Z?.tabs??[]){if(je.purpose.type!=="project-action")continue;const Ie=je.purpose.actionId,Ve=Ee.find(at=>at.id===Ie),Je=Ve?.name??Ie,it=Ve?.icon||"play";je.label!==Je&&k(G,je.id,Je),je.iconKey!==it&&j(G,je.id,it)}},[Ee,j,k,B]),c.useEffect(()=>{const G=globalThis.window;if(!G)return;const Z=je=>{const Ie=je.detail;Ae&&(Ie?.projectId&&Ie.projectId!==Ae||le())};return G.addEventListener(xl,Z),()=>{G.removeEventListener(xl,Z)}},[le,Ae]),c.useEffect(()=>{E&&(E===un&&We||W.some(G=>G.id===E)||X(null))},[W,We,E]),c.useEffect(()=>{const G=je=>{delete te.current[je];const Ie=fe.current[je];if(!Ie||Ie.openedUrl)return;const Ve=Re(Ie.directory,Ie.actionId,Ie.executionId),Je=Ie.announced;if(Je.length!==0){if(window.clearTimeout(te.current[Ve]),delete te.current[Ve],Ie.openedUrl=!0,ye(it=>{if(!it[Ve])return it;const at={...it};return delete at[Ve],at}),Je.length===1){fi(Ie.directory,[]),$(Ie.directory,Ie.tabId,Je[0],{locked:!1,autoOpened:!0}),S(Ie.directory,Je[0]);return}Ie.offering=!0,fi(Ie.directory,Je),Pe.getState().openContextSurface(Ie.directory,"browser"),Le.info(o("projectActions.toast.multipleServers"))}},Z=()=>{const je=Ot.getState(),Ie=je.sessions,Ve=se;for(const[Je,it]of Object.entries(Ve)){const Ye=Ie.get(it.directory)?.tabs.find(ft=>ft.id===it.tabId);if(!Ye||Ye.terminalSessionId!==it.sessionId){q(it.directory,it.actionId,it.executionId);continue}const vt=fe.current[Je],Ue=vt?.executionId===it.executionId?vt:{hostDirectory:oe.current||it.directory,directory:it.directory,tabId:it.tabId,actionId:it.actionId,executionId:it.executionId,lastSeenChunkId:null,openedUrl:!0,tail:"",openInPreview:!1,announced:[],offering:!1};fe.current[Je]=Ue;const Pt=Ee.find(ft=>ft.id===it.actionId),ke=je.getBuffer(it.directory,it.tabId).chunks;if(!Pt||ke.length===0)continue;const xt=ke.filter(ft=>Ue.lastSeenChunkId===null||ft.id>Ue.lastSeenChunkId);if(xt.length===0)continue;const Ct=xt.map(ft=>ft.data).join(""),Tt=`${Ue.tail}${Ct}`;if(Ue.openInPreview&&(!Ue.openedUrl||Ue.offering)){const ft=gh(Tt),Be=Ue.announced.length;for(const He of ft)Ue.announced.includes(He)||Ue.announced.push(He);const Ke=Ue.announced.length-Be;Ue.offering&&Ke>0?fi(it.directory,Ue.announced):!Ue.openedUrl&&Be===0&&Ue.announced.length>0&&(window.clearTimeout(te.current[Je]),te.current[Je]=window.setTimeout(()=>G(Je),Mb))}const qe=!Ue.openedUrl&&Pt.autoOpenUrl===!0&&!Ue.openInPreview?xh(Tt):null,ze=xt[xt.length-1]?.id??Ue.lastSeenChunkId;if(Ue.lastSeenChunkId=ze,Ue.tail=Tt.slice(-512),qe)if(Ue.openedUrl=!0,Ue.openInPreview){const ft=Ve[Je];ft&&($(ft.directory,ft.tabId,qe,{locked:!1,autoOpened:!1,expectedExecutionId:ft.executionId}),ft.status==="waiting-for-preview"&&ye(Be=>{const Ke=Re(ft.directory,ft.actionId,ft.executionId);if(!Be[Ke])return Be;const He={...Be};return delete He[Ke],He}),window.clearTimeout(te.current[Je]),delete te.current[Je],S(ft.directory,qe))}else Q(qe),Le.success(o("projectActions.toast.openedUrlFromOutput"));fe.current[Je]=Ue}for(const Je of Object.keys(fe.current))if(!Ve[Je]){const it=fe.current[Je],at=it?Ie.get(it.directory)?.tabs.find(vt=>vt.id===it.tabId):void 0;if(at?.purpose.type==="project-action"&&at.purpose.executionId===it?.executionId&&!!at.terminalSessionId&&at.lifecycle!=="idle"&&at.lifecycle!=="exited")continue;delete fe.current[Je],window.clearTimeout(te.current[Je]),delete te.current[Je]}};return Z(),Ot.subscribe((je,Ie)=>{(je.sessions!==Ie.sessions||je.buffers!==Ie.buffers)&&Z()})},[q,oe,Ee,Re,S,Q,se,$,o]),c.useEffect(()=>{for(const{directory:G,state:Z}of B)for(const je of Z?.tabs??[]){if(je.purpose.type!=="project-action"||!je.purpose.executionId||!je.terminalSessionId||je.lifecycle!=="running")continue;const Ie=je.purpose.actionId,Ve=je.purpose.executionId,Je=Re(G,Ie,Ve);if(ne.current[Je])continue;const it=a.connect(je.terminalSessionId,{onEvent:at=>{if(!K(G,je.id,Ve))return;at.type==="snapshot"&&(Ot.getState().replaceBuffer(G,je.id,at.data??"",at.sequence??0,ll(at)),at.status==="running"&&Ot.getState().setTabLifecycle(G,je.id,"running",{expectedExecutionId:Ve}),at.status==="exited"&&(Ot.getState().setTabLifecycle(G,je.id,"exited",{expectedExecutionId:Ve}),Ot.getState().setTabPurpose(G,je.id,{type:"project-action",actionId:Ie,executionId:null}),q(G,Ie,Ve)));const Ye=at.type==="data"?at.data??"":"";Ye&&Ot.getState().appendToBuffer(G,je.id,Ye,at.sequence,at.replayData),at.type==="exit"&&(Ot.getState().setTabLifecycle(G,je.id,"exited",{expectedExecutionId:Ve}),Ot.getState().setTabPurpose(G,je.id,{type:"project-action",actionId:Ie,executionId:null}),q(G,Ie,Ve))},onError:(at,Ye)=>{!Ye||!K(G,je.id,Ve)||(Ot.getState().setTabLifecycle(G,je.id,"exited",{expectedExecutionId:Ve}),Ot.getState().setTabSessionId(G,je.id,null,{expectedExecutionId:Ve}),Ot.getState().setTabPurpose(G,je.id,{type:"project-action",actionId:Ie,executionId:null}),q(G,Ie,Ve))}});ne.current[Je]=it.close}},[q,Re,K,a,B]);const xe=c.useCallback(async G=>{const Z=ve(G);if(!Z)throw new Error(o("projectActions.error.noActiveDirectory"));const je=cn(Z,G.id);g(Z);const Ie=Ot.getState(),Ve=ce(Z,G.id,Ie),Je=Ve?.id??Ie.createTab(Z);k(Z,Je,G.name),j(Z,Je,G.icon||"play"),Ve||P(Z,Je,{type:"project-action",actionId:G.id,executionId:null}),D(Z,Je);const at=Ot.getState().getDirectoryState(Z)?.tabs.find(Ye=>Ye.id===Je);return{executionDirectory:Z,key:je,tabId:Je,sessionId:at?.terminalSessionId??null,executionId:at?.purpose.type==="project-action"?at.purpose.executionId:null}},[g,ve,ce,D,j,k,P,o]),$e=c.useCallback(async G=>{if(d.isVSCode||!i&&h)return;if(!H){Le.error(o("projectActions.error.noActiveDirectoryForAction"));return}const Z=cn(ve(G),G.id),je=se[Z];if(je&&je.status==="running"||ue.current.has(Z))return;ue.current.add(Z);let Ie=null;try{const Ve=G.id===un?await(async()=>{const[Ke,He]=await Promise.all([Jh({id:O?.id??"",path:H}),Eb(H)]),nt=await Nb(H,Ke.actions,He);if(!nt)throw new Error(o("contextPanel.preview.noDevServer"));return{id:un,name:o("projectActions.actions.autoDiscover"),command:nt.command,icon:"scan-2",autoOpenUrl:!0,openUrl:nt.previewUrlHint||""}})():G,Je=Ve.autoOpenUrl===!0&&(Ve.openUrl||"").trim().length>0,it=!Je&&G.id!==un,at=oe.current||H,{executionDirectory:Ye,key:vt,tabId:Ue}=await xe(Ve),Pt=uh(Ve.command);if(!Pt)throw new Error(o("projectActions.error.failedToRunAction"));const ke=Ve.autoOpenUrl===!0&&f&&(Ve.desktopOpenSshForward||"").trim().length>0,xt=Ve.autoOpenUrl?Ob(Ve.openUrl):null,Ct=Ve.autoOpenUrl&&f?fh(Ve.desktopOpenSshForward,x):null;if(a.listSessions){const Ke=ce(Ye,Ve.id);if(Ke?.purpose.type==="project-action"&&Ke.purpose.executionId===null){const He=await mh(a,Ye,{captureStartedActionMutationRevisions:F});He&&C(Ye,He.sessions,{startedActionMutationRevisions:He.startedActionMutationRevisions})}}const Tt=ce(Ye,Ve.id);let qe,ze;if(Tt?.lifecycle==="running"&&Tt.terminalSessionId&&Tt.purpose.type==="project-action"&&Tt.purpose.executionId)qe=Tt.terminalSessionId,ze=Tt.purpose.executionId;else{const Ke=Tt?.purpose.type==="project-action"?Tt.purpose.executionId:null;Ke&&q(Ye,Ve.id,Ke);const He=T(Ye,Ue,Ve.id);if(!He)throw new Error(o("projectActions.error.failedToCreateTerminalSession"));Ie={directory:Ye,tabId:Ue,id:He},I(Ye,Ue,!0,{expectedExecutionId:He});const nt=await hh({terminal:a,createOptions:{cwd:Ye,shell:w,loginShell:v,themeMode:l.metadata.variant==="light"?"light":"dark",terminalBackground:l.colors.surface.background,terminalForeground:l.colors.syntax.base.foreground},command:Pt,isRunStillExpected:()=>K(Ye,Ue,He),purpose:{type:"project-action",actionId:Ve.id,executionId:He}});if(!K(Ye,Ue,He)){nt.sessionId===He&&await a.close(nt.sessionId).catch(()=>{});return}ze=nt.purpose?.type==="project-action"?nt.purpose.executionId:He,qe=nt.sessionId,P(Ye,Ue,{type:"project-action",actionId:Ve.id,executionId:ze}),A(Ye,Ue,qe,{expectedExecutionId:ze}),I(Ye,Ue,!1,{expectedExecutionId:ze})}it&&at&&ae(at,Ye),fe.current[vt]={hostDirectory:at,directory:Ye,tabId:Ue,actionId:Ve.id,executionId:ze,lastSeenChunkId:null,openedUrl:!!Ct||!!xt||Je,tail:"",openInPreview:Ve.id===un,announced:[],offering:!1};const ft=Re(Ye,Ve.id,ze);I(Ye,Ue,!0,{expectedExecutionId:ze});const Be=a.connect(qe,{onEvent:Ke=>{if(!K(Ye,Ue,ze)||Ke.purpose?.type==="project-action"&&Ke.purpose.executionId!==ze)return;Ke.type==="snapshot"&&(Ot.getState().replaceBuffer(Ye,Ue,Ke.data??"",Ke.sequence??0,ll(Ke)),Ot.getState().setConnecting(Ye,Ue,!1,{expectedExecutionId:ze}),Ke.purpose?.type==="project-action"&&Ot.getState().setTabPurpose(Ye,Ue,{type:"project-action",actionId:Ke.purpose.actionId,executionId:Ke.purpose.executionId}),Ke.status==="running"&&Ot.getState().setTabLifecycle(Ye,Ue,"running",{expectedExecutionId:ze}),Ke.status==="exited"&&(Ot.getState().setTabLifecycle(Ye,Ue,"exited",{expectedExecutionId:ze}),Ot.getState().setTabPurpose(Ye,Ue,{type:"project-action",actionId:Ve.id,executionId:null}),q(Ye,Ve.id,ze)));const He=Ke.type==="data"?Ke.data??"":"";He&&Ot.getState().appendToBuffer(Ye,Ue,He,Ke.sequence,Ke.replayData),Ke.type==="exit"&&(Ot.getState().setTabLifecycle(Ye,Ue,"exited",{expectedExecutionId:ze}),Ot.getState().setConnecting(Ye,Ue,!1,{expectedExecutionId:ze}),Ot.getState().setTabPurpose(Ye,Ue,{type:"project-action",actionId:Ve.id,executionId:null}),q(Ye,Ve.id,ze))},onError:(Ke,He)=>{K(Ye,Ue,ze)&&(Ot.getState().setConnecting(Ye,Ue,!1,{expectedExecutionId:ze}),He&&(Ot.getState().setTabLifecycle(Ye,Ue,"exited",{expectedExecutionId:ze}),Ot.getState().setTabSessionId(Ye,Ue,null,{expectedExecutionId:ze}),Ot.getState().setTabPurpose(Ye,Ue,{type:"project-action",actionId:Ve.id,executionId:null}),q(Ye,Ve.id,ze)))}});if(!K(Ye,Ue,ze)){Be.close();return}ne.current[ft]?.(),ne.current[ft]=Be.close,window.clearTimeout(te.current[ft]),delete te.current[ft],Ve.id===un&&!xt&&(ye(Ke=>({...Ke,[ft]:!0})),te.current[ft]=window.setTimeout(()=>{delete te.current[ft];const Ke=fe.current[vt];!Ke||Ke.executionId!==ze||Ke.openedUrl||Ke.offering||K(Ye,Ue,ze)&&(ye(He=>{if(!He[ft])return He;const nt={...He};return delete nt[ft],nt}),Ot.getState().setActiveTab(Ye,Ue),ae(Ke.hostDirectory,Ye))},Rb)),Ct?($(Ye,Ue,null,{locked:!0,expectedExecutionId:ze}),Q(Ct),Le.success(o("projectActions.toast.openedForwardedUrl"))):xt?($(Ye,Ue,xt,{locked:!0,autoOpened:!0,expectedExecutionId:ze}),S(at,xt),Le.success(o("projectActions.toast.openedActionUrl"))):Je?($(Ye,Ue,null,{locked:!0,expectedExecutionId:ze}),Le.error(o("projectActions.error.invalidCustomUrlFormat"))):ke?($(Ye,Ue,null,{locked:!0,expectedExecutionId:ze}),Le.error(o("projectActions.error.selectedDesktopSshForwardUnavailable"))):$(Ye,Ue,null,{locked:!1,autoOpened:!1,expectedExecutionId:ze})}catch(Ve){if(Ie&&K(Ie.directory,Ie.tabId,Ie.id)){const{directory:Je,tabId:it,id:at}=Ie;q(Je,G.id,at),L(Je,it,"exited",{expectedExecutionId:at}),P(Je,it,{type:"project-action",actionId:G.id,executionId:null})}if(Ve instanceof Error&&Ve.message==="PROJECT_ACTION_RUN_CANCELLED")return;if(Ve instanceof Error&&(Ve.message==="COMMAND_MODE_UNSUPPORTED"||Ve.message==="PROJECT_ACTION_PURPOSE_UNSUPPORTED")){Le.error(o("projectActions.error.failedToCreateTerminalSession"));return}Le.error(Ve instanceof Error?Ve.message:o("projectActions.error.failedToRunAction"))}finally{ue.current.delete(Z)}},[l.colors.surface.background,l.colors.syntax.base.foreground,l.metadata.variant,oe,x,xe,i,h,f,H,v,w,Q,S,se,ae,d.isVSCode,ve,K,q,Re,ce,C,T,F,I,L,P,$,A,O?.id,o,a]),V=c.useCallback(async G=>{const Z=cn(ve(G),G.id),je=se[Z];je&&await ph({terminal:a,sessionId:je.sessionId,isExecutionStillCurrent:()=>K(je.directory,je.tabId,je.executionId),markStopping:()=>{L(je.directory,je.tabId,"stopping",{expectedExecutionId:je.executionId})},restoreRunning:()=>{L(je.directory,je.tabId,"running",{expectedExecutionId:je.executionId})},clearSession:()=>{A(je.directory,je.tabId,null,{expectedExecutionId:je.executionId})},finalizeExit:()=>{L(je.directory,je.tabId,"exited",{expectedExecutionId:je.executionId}),P(je.directory,je.tabId,{type:"project-action",actionId:je.actionId,executionId:null}),q(je.directory,je.actionId,je.executionId)}})},[q,ve,K,se,L,P,A,a]),De=c.useCallback(()=>{const G=Ne??Ee[0];if(!G)return;const Z=cn(ve(G),G.id),je=se[Z];if(je?.status!=="stopping"){if(je){V(G);return}$e(G)}},[Ee,ve,$e,se,Ne,V]),Fe=c.useCallback(async G=>{if(G.source==="shared"&&O){const Z=R.current?.trust.trusted?R.current:await vl(O);if(R.current=Z,!await Zh(O,Z))return;R.current={...Z,trust:{...Z.trust,trusted:!0}}}await $e(G)},[$e,O]),_e=c.useCallback((G,Z=!1)=>{if(X(G.id),!Z){Fe(G);return}const je=cn(ve(G),G.id),Ie=se[je];if(Ie?.status!=="stopping"){if(Ie){V(G);return}Fe(G)}},[ve,Fe,se,V]),rt=c.useCallback(()=>{O?.id&&(p(O.id),y("projects"),m(!0))},[m,y,p,O?.id]),ct=Ne??Ee[0]??null,et=ct?se[cn(ve(ct),ct.id)]:null,pt=Ot(G=>et?G.getDirectoryState(et.directory)?.tabs.find(Z=>Z.id===et.tabId)?.previewUrl??null:null);if(d.isVSCode||!i&&h||!O||!H)return null;const kt=Ne??Ee[0]??null;if(!kt)return null;const wt=mi(kt),Xe=cn(ve(kt),kt.id),yt=se[Xe],Rt=yt?.status==="stopping",be=yt?.status==="waiting-for-preview",Ge=!!(yt&&pt),ut=()=>{!yt||!pt||S(yt.directory,pt)},Y=kt.id===un;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",disabled:J||Rt,className:Oe("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed",n),onClick:De,"aria-label":yt?o("projectActions.actions.stopNamedAria",{name:kt.name}):o("projectActions.actions.runNamedAria",{name:kt.name}),children:Rt||be?s.jsx(M,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):yt?s.jsx(M,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(M,{name:wt,className:"h-5 w-5"})})}),Y?s.jsx(Dt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Ge?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.openPreview"),onClick:ut,children:s.jsx(M,{name:"global",className:"h-4 w-4"})})}),s.jsx(Dt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(Ws,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:rt,children:[s.jsx(M,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),Ee.map(G=>{const Z=mi(G),je=cn(ve(G),G.id),Ie=se[je],Ve=!!Ie,Je=Ie?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{_e(G,!0)},children:[s.jsx(M,{name:Z,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:G.name}),G.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Je||Ie?.status==="waiting-for-preview"?s.jsx(M,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ve?s.jsx(M,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},G.id)})]})]})]}):s.jsxs("div",{className:Oe("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:De,disabled:J||Rt,className:Oe("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed"),"aria-label":yt?o("projectActions.actions.stopNamedAria",{name:kt.name}):o("projectActions.actions.runNamedAria",{name:kt.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:Rt||be?s.jsx(M,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):yt?s.jsx(M,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(M,{name:wt,className:"h-4 w-4"})})})}),Y?s.jsx(Dt,{sideOffset:6,children:o("projectActions.actions.autoDiscoverTooltip")}):null]}),Ge?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ut,className:Oe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.openPreview"),children:s.jsx(M,{name:"global",className:"h-4 w-4"})})}),s.jsx(Dt,{sideOffset:6,children:o("projectActions.actions.openPreview")})]}):null,s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":o("projectActions.actions.chooseActionAria"),children:s.jsx(M,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(Ws,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Kt,{className:"flex items-center gap-2",onClick:rt,children:[s.jsx(M,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("projectActions.actions.addNewAction")})]}),s.jsx(Os,{}),Ee.map(G=>{const Z=mi(G),je=cn(ve(G),G.id),Ie=se[je],Ve=!!Ie,Je=Ie?.status==="stopping";return s.jsxs(Kt,{className:"flex items-center gap-2",onClick:()=>{_e(G,!0)},children:[s.jsx(M,{name:Z,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:G.name}),G.source==="shared"?s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-muted-foreground bg-[var(--surface-subtle)]",children:o("projectActions.menu.sharedBadge")}):null,Je||Ie?.status==="waiting-for-preview"?s.jsx(M,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ve?s.jsx(M,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},G.id)})]})]})]})},$r=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Fb=({projects:t,worktreesByProject:e,directory:n,activeProjectId:r})=>{const i=$r(n??"");if(i){const o=qd(t,e,i);if(o)return o}return t.find(o=>o.id===r)??null};function _b(){const t=Ht(w=>w.projects),e=Ht(w=>w.activeProjectId),n=tt(w=>w.availableWorktreesByProject),r=tt(w=>w.currentSessionId),i=ep(r??null),o=tt(w=>r?w.worktreeMetadata.get(r)?.path??"":""),l=tt(w=>w.newSessionDraft?.open?$r(w.newSessionDraft.bootstrapPendingDirectory??w.newSessionDraft.directoryOverride??""):""),a=c.useMemo(()=>$r(o||""),[o]),d=c.useMemo(()=>{const w=typeof i?.directory=="string"?i.directory:"";return $r(w||"")},[i?.directory]),u=a||d||l,h=c.useMemo(()=>Fb({projects:t,worktreesByProject:n,directory:u,activeProjectId:e}),[e,u,t,n]),f=c.useMemo(()=>$r(u||h?.path||""),[u,h?.path]),x=c.useMemo(()=>h?{id:h.id,path:h.path}:null,[h]),b=c.useRef(null);return c.useEffect(()=>{x&&f&&(b.current={projectRef:x,directory:f})},[f,x]),c.useMemo(()=>x&&f?{projectRef:x,directory:f}:b.current,[x,f])}const Lb=({transform:t})=>({...t,y:0}),$b={Item:Kt,Separator:Os},zb={Item:({className:t,...e})=>s.jsx(Vu,{className:Oe(Xd,t),...e}),Separator:({className:t,...e})=>s.jsx(Ku,{className:Oe(Qd,t),...e})},Wb=t=>{const e=Ze.c(67),{tab:n,isActive:r,suppressControls:i,onSelect:o,onClose:l,renderMenu:a,closeOtherTabs:d,onMenuOpenChangeComplete:u,children:h}=t,{t:f}=jt(),[x,b]=c.useState(!1),[w,v]=c.useState(!1),[y,m]=c.useState(!1);let p;e[0]!==n.id?(p={id:n.id},e[0]=n.id,e[1]=p):p=e[1];const{attributes:S,listeners:g,setNodeRef:C,transform:k,transition:j,isDragging:D}=ti(p);let I;e[2]!==f||e[3]!==n.session.title?(I=n.session.title?.trim()||f("sessions.sidebar.session.untitled"),e[2]=f,e[3]=n.session.title,e[4]=I):I=e[4];const A=I,P=!i&&(x||w),T=Sa(n.id),L=n.id;let $;e[5]!==n.session?($=Ds(n.session),e[5]=n.session,e[6]=$):$=e[6];const K=va(L,$),F=T?.type==="busy"||T?.type==="retry",N=Yd(n.id)>0&&!r&&!F,R=F||N;let E;e[7]!==F||e[8]!==f?(E=f(F?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[7]=F,e[8]=f,e[9]=E):E=e[9];const X=E;let J;e[10]!==d||e[11]!==y||e[12]!==r||e[13]!==x||e[14]!==o||e[15]!==n?(J=ge=>({session:n.session,open:x||y,isActive:r,select:()=>o(n),closeOtherTabs:()=>d(n.id),components:ge}),e[10]=d,e[11]=y,e[12]=r,e[13]=x,e[14]=o,e[15]=n,e[16]=J):J=e[16];const re=J;let fe;e[17]!==k?(fe=si.Translate.toString(k),e[17]=k,e[18]=fe):fe=e[18];let ne;e[19]!==fe||e[20]!==j?(ne={transform:fe,transition:j},e[19]=fe,e[20]=j,e[21]=ne):ne=e[21];const te=D&&"z-10 opacity-60";let ue;e[22]!==te?(ue=Oe("session-tab-slot flex h-7 w-44 shrink-0 touch-none",te),e[22]=te,e[23]=ue):ue=e[23];const Se=r?"true":"false";let we;e[24]!==r?(we=r?{"data-active-session-tab":!0}:{},e[24]=r,e[25]=we):we=e[25];let ye;e[26]!==u?(ye=ge=>u?.(ge),e[26]=u,e[27]=ye):ye=e[27];let Ae;e[28]!==h||e[29]!==X||e[30]!==r||e[31]!==K||e[32]!==F||e[33]!==re||e[34]!==x||e[35]!==l||e[36]!==u||e[37]!==o||e[38]!==P||e[39]!==a||e[40]!==R||e[41]!==i||e[42]!==f||e[43]!==n||e[44]!==A?(Ae=s.jsx(Uu,{render:ge=>s.jsxs("div",{...ge,role:"tab","aria-selected":r,tabIndex:r?void 0:0,onClick:r?void 0:()=>o(n),onKeyDown:r?void 0:oe=>{(oe.key==="Enter"||oe.key===" ")&&(oe.preventDefault(),o(n))},onAuxClick:oe=>{oe.button===1&&(oe.preventDefault(),l(n.id))},"data-controls-open":P?"true":"false",className:Oe("session-tab group/session-tab relative flex h-7 w-full min-w-0 select-none items-center rounded-md px-2",r?"bg-interactive-selection text-interactive-selection-foreground":Oe("cursor-pointer text-muted-foreground hover:bg-interactive-hover hover:text-foreground",P&&"bg-interactive-hover text-foreground")),children:[s.jsxs("div",{className:Oe("flex min-w-0 flex-1 items-center",!i&&"group-hover/session-tab:pr-10",P&&"pr-10"),children:[s.jsx("div",{className:Oe("min-w-0 flex-1 overflow-hidden whitespace-nowrap",!i&&"session-tab-title"),children:r?h:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:s.jsx("span",{className:"block max-w-full overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4",children:A})})}),K?s.jsx(M,{name:"loader-4",className:"ml-1.5 size-3 shrink-0 animate-spin text-primary","aria-label":f("sessions.aiRename.generating")}):R?s.jsx("span",{className:Oe("ml-1.5 h-1.5 w-1.5 shrink-0 rounded-full",F?"bg-primary":"bg-[var(--status-info)]",!i&&"group-hover/session-tab:opacity-0",P&&"opacity-0"),"aria-label":X}):null]}),i?null:s.jsxs("div",{onClick:Vb,onPointerDown:Ub,className:Oe("absolute right-1 top-1/2 hidden -translate-y-1/2 items-center gap-0.5","opacity-0 transition-opacity duration-150","group-hover/session-tab:flex group-hover/session-tab:opacity-100",P&&"flex opacity-100"),children:[s.jsxs(Ks,{open:x,onOpenChange:oe=>{b(oe),oe&&v(!0)},onOpenChangeComplete:oe=>{oe||v(!1),u?.(oe)},children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.tabMenuAria"),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"more",className:"size-4"})})}),s.jsx(Ws,{align:"start",className:"min-w-[190px]",children:a(re($b))})]}),s.jsx("button",{type:"button","aria-label":f("header.sessionTabs.closeTab"),onClick:()=>l(n.id),className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]})]})}),e[28]=h,e[29]=X,e[30]=r,e[31]=K,e[32]=F,e[33]=re,e[34]=x,e[35]=l,e[36]=u,e[37]=o,e[38]=P,e[39]=a,e[40]=R,e[41]=i,e[42]=f,e[43]=n,e[44]=A,e[45]=Ae):Ae=e[45];let pe,O;e[46]===Symbol.for("react.memo_cache_sentinel")?(pe={color:"var(--surface-elevated-foreground)"},O=Oe(Ri,"min-w-[190px]"),e[46]=pe,e[47]=O):(pe=e[46],O=e[47]);let Q;e[48]!==re||e[49]!==a?(Q=a(re(zb)),e[48]=re,e[49]=a,e[50]=Q):Q=e[50];let le;e[51]!==Q?(le=s.jsx(Hi,{children:s.jsx(Gi,{className:"app-region-no-drag z-50",children:s.jsx(qi,{"data-slot":"dropdown-menu-content",style:pe,className:O,children:Q})})}),e[51]=Q,e[52]=le):le=e[52];let H;e[53]!==y||e[54]!==ye||e[55]!==Ae||e[56]!==le?(H=s.jsxs(Hu,{open:y,onOpenChange:m,onOpenChangeComplete:ye,children:[Ae,le]}),e[53]=y,e[54]=ye,e[55]=Ae,e[56]=le,e[57]=H):H=e[57];let me;return e[58]!==S||e[59]!==g||e[60]!==C||e[61]!==ue||e[62]!==Se||e[63]!==we||e[64]!==H||e[65]!==ne?(me=s.jsx("div",{ref:C,style:ne,className:ue,"data-active":Se,...we,...S,...g,children:H}),e[58]=S,e[59]=g,e[60]=C,e[61]=ue,e[62]=Se,e[63]=we,e[64]=H,e[65]=ne,e[66]=me):me=e[66],me},Kb=t=>{const e=Ze.c(64),{renderMenu:n,onMenuOpenChangeComplete:r,suppressActiveTabControls:i,children:o}=t,l=i===void 0?!1:i,{t:a}=jt(),d=no(Hb),u=no(Gb),h=no(qb),f=no(Yb),x=tt(Qb),b=tt(Xb),w=$s(Jb);let v,y;e[0]!==x||e[1]!==u?(v=()=>{x&&u(x)},y=[x,u],e[0]=x,e[1]=u,e[2]=v,e[3]=y):(v=e[2],y=e[3]),c.useEffect(v,y);let m;if(e[4]!==w){m=new Map;for(const oe of w)m.set(oe.id,oe);e[4]=w,e[5]=m}else m=e[5];const p=m;let S;if(e[6]!==p||e[7]!==d){S=[];for(const oe of d){const de=p.get(oe);de&&S.push({id:oe,session:de})}e[6]=p,e[7]=d,e[8]=S}else S=e[8];const g=S;let C;e[9]!==b?(C=oe=>{b(oe.id,Ds(oe.session))},e[9]=b,e[10]=C):C=e[10];const k=C,j=Zb;let D;e[11]!==h||e[12]!==x||e[13]!==k||e[14]!==g?(D=oe=>{if(h(oe),x&&x!==oe){const de=g.find(_=>_.id===oe);de&&k(de)}},e[11]=h,e[12]=x,e[13]=k,e[14]=g,e[15]=D):D=e[15];const I=D;let A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A={activationConstraint:{distance:8}},e[16]=A):A=e[16];let P;e[17]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{delay:200,tolerance:6}},e[17]=P):P=e[17];const T=Qo(Dn(Jo,A),Dn(Xo,P));let L;e[18]!==f?(L=oe=>{const{active:de,over:_}=oe;_&&de.id!==_.id&&f(String(de.id),String(_.id))},e[18]=f,e[19]=L):L=e[19];const $=L,K=c.useRef(null);let F;e[20]===Symbol.for("react.memo_cache_sentinel")?(F={left:!1,right:!1},e[20]=F):F=e[20];const[W,N]=c.useState(F);let R;e[21]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{const oe=K.current;if(!oe)return;const de=oe.scrollLeft>2,_=oe.scrollLeft+oe.clientWidth<oe.scrollWidth-2;N(B=>B.left===de&&B.right===_?B:{left:de,right:_})},e[21]=R):R=e[21];const E=R;let X;e[22]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{E();const oe=K.current;if(!oe||!globalThis.ResizeObserver)return;const de=new ResizeObserver(E);return de.observe(oe),()=>de.disconnect()},e[22]=X):X=e[22];let J;e[23]!==g.length?(J=[E,g.length],e[23]=g.length,e[24]=J):J=e[24],c.useEffect(X,J);let re;e[25]===Symbol.for("react.memo_cache_sentinel")?(re=()=>{K.current?.querySelector("[data-active-session-tab]")?.scrollIntoView({block:"nearest",inline:"nearest"})},e[25]=re):re=e[25];let fe;e[26]!==x?(fe=[x],e[26]=x,e[27]=fe):fe=e[27],c.useEffect(re,fe);const ne=W.left&&W.right?"linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent)":W.left?"linear-gradient(to right, transparent, black 24px)":W.right?"linear-gradient(to right, black calc(100% - 24px), transparent)":void 0;let te;e[28]!==g?(te=g.map(ey),e[28]=g,e[29]=te):te=e[29];const ue=te;let Se;e[30]!==x||e[31]!==g?(Se=!x||!g.some(oe=>oe.id===x),e[30]=x,e[31]=g,e[32]=Se):Se=e[32];const we=Se;let ye;e[33]!==a?(ye=a("header.sessionTabs.stripAria"),e[33]=a,e[34]=ye):ye=e[34];let Ae;e[35]!==ne?(Ae=ne?{maskImage:ne,WebkitMaskImage:ne}:void 0,e[35]=ne,e[36]=Ae):Ae=e[36];let pe;e[37]===Symbol.for("react.memo_cache_sentinel")?(pe=[Lb],e[37]=pe):pe=e[37];let O;e[38]!==o||e[39]!==x||e[40]!==I||e[41]!==k||e[42]!==r||e[43]!==n||e[44]!==l||e[45]!==g?(O=g.map(oe=>s.jsx(Wb,{tab:oe,isActive:oe.id===x,suppressControls:oe.id===x&&l,onSelect:k,onClose:j,renderMenu:n,closeOtherTabs:I,onMenuOpenChangeComplete:r,children:oe.id===x?o:null},oe.id)),e[38]=o,e[39]=x,e[40]=I,e[41]=k,e[42]=r,e[43]=n,e[44]=l,e[45]=g,e[46]=O):O=e[46];let Q;e[47]!==O||e[48]!==ue?(Q=s.jsx(Wa,{items:ue,strategy:Hx,children:O}),e[47]=O,e[48]=ue,e[49]=Q):Q=e[49];let le;e[50]!==$||e[51]!==T||e[52]!==Q?(le=s.jsx(Zo,{sensors:T,collisionDetection:ei,modifiers:pe,onDragEnd:$,children:Q}),e[50]=$,e[51]=T,e[52]=Q,e[53]=le):le=e[53];let H;e[54]!==o||e[55]!==we?(H=we?s.jsx("div",{role:"tab","aria-selected":!0,className:"session-tab-slot flex h-7 w-44 shrink-0 items-center rounded-md bg-interactive-selection px-2","data-active":"true",children:s.jsx("div",{className:"min-w-0 flex-1",children:o})}):null,e[54]=o,e[55]=we,e[56]=H):H=e[56];let me;e[57]!==Ae||e[58]!==le||e[59]!==H?(me=s.jsxs("div",{ref:K,onScroll:E,className:"session-tabs-scroll flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto overscroll-x-contain",style:Ae,children:[le,H]}),e[57]=Ae,e[58]=le,e[59]=H,e[60]=me):me=e[60];let ge;return e[61]!==ye||e[62]!==me?(ge=s.jsx("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center",role:"tablist","aria-label":ye,children:me}),e[61]=ye,e[62]=me,e[63]=ge):ge=e[63],ge};function Vb(t){return t.stopPropagation()}function Ub(t){return t.stopPropagation()}function Hb(t){return t.tabIds}function Gb(t){return t.ensureTab}function qb(t){return t.closeOtherTabs}function Yb(t){return t.reorderTabs}function Qb(t){return t.currentSessionId}function Xb(t){return t.setCurrentSession}function Jb(t){return t.activeSessions}function Zb(t){tp(t)}function ey(t){return t.id}const Ju=async t=>{const{entry:e,session:n}=t,r=qt(),i={sessionId:n.id,sessionTitle:n.title,directory:n.directory};if(!(sp(e.action)&&np(e.guest,"conversation"))){await Sl(e,jl(e.action.id,i),t.t,r);return}let l=!1;const a=Qr(()=>{l=!0});let d;try{d=await t.loadRecords()}finally{a()}if(!l){if(!d){t.onLoadFailed();return}await Sl(e,jl(e.action.id,i,d),t.t,r)}};function Qi(t){const e=Ze.c(16),{sessionID:n,directory:r,open:i,Item:o}=t,{t:l}=jt(),{pending:a,disabled:d,hint:u,run:h}=yh(n,r,i),f=a?"loader-4":"ai-generate-2",x=a?"mr-1 size-4 animate-spin":"mr-1 size-[15px]";let b;e[0]!==f||e[1]!==x?(b=s.jsx(M,{name:f,className:x}),e[0]=f,e[1]=x,e[2]=b):b=e[2];let w;e[3]!==l?(w=l("sessions.aiRename.action"),e[3]=l,e[4]=w):w=e[4];let v;e[5]!==o||e[6]!==d||e[7]!==h||e[8]!==b||e[9]!==w?(v=s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(o,{disabled:d,onClick:h,className:"w-full",children:[b,w]})})}),e[5]=o,e[6]=d,e[7]=h,e[8]=b,e[9]=w,e[10]=v):v=e[10];let y;e[11]!==u?(y=s.jsx(Dt,{side:"right",children:u}),e[11]=u,e[12]=y):y=e[12];let m;return e[13]!==v||e[14]!==y?(m=s.jsxs(Nt,{children:[v,y]}),e[13]=v,e[14]=y,e[15]=m):m=e[15],m}const Xi=(t,e)=>({success:t(e.success),failure:t(e.failure),sourceVerificationFailed:t("sessions.sidebar.session.moveToWorktree.sourceVerificationFailed"),applyChangesFailed:t("sessions.sidebar.session.moveToWorktree.applyChangesFailed"),changesMayBeInDestination:t("sessions.sidebar.session.moveToWorktree.changesMayBeInDestination")}),Kn=to(()=>({pendingSessionIds:new Set,requestingSessionIds:new Set,confirmation:null})),Zu=t=>{const e=Ze.c(2);let n;return e[0]!==t?(n=r=>r.pendingSessionIds.has(t)||r.requestingSessionIds.has(t),e[0]=t,e[1]=n):n=e[1],Kn(n)},ty=()=>Kn(uy),ef=()=>Kn.getState().confirmation,Va=t=>{Kn.setState(e=>e.confirmation===t?e:{...e,confirmation:t})},Gl=(t,e)=>{Kn.setState(n=>{if(n.pendingSessionIds.has(t)===e)return n;const r=new Set(n.pendingSessionIds);return e?r.add(t):r.delete(t),{...n,pendingSessionIds:r}})},mr=(t,e)=>{Kn.setState(n=>{if(n.requestingSessionIds.has(t)===e)return n;const r=new Set(n.requestingSessionIds);return e?r.add(t):r.delete(t),{...n,requestingSessionIds:r}})},sy="Unable to apply your changes in the destination directory",ny=t=>t.status===400&&t.message.includes(sy),ry=async(t,e)=>{try{const d=(await Jd(t,{mode:"light"})).current?.trim();if(d)return d}catch{}const n=ht(t),r=ht(e)??e,i=tt.getState().availableWorktreesByProject,l=(i.get(r)??i.get(e)??[]).find(a=>ht(a.path)===n)?.branch?.trim();if(l)return l;throw new Error("Unable to determine the current branch")},ql=t=>{for(const e of t){const n=op(e.id);if(n==="unknown")throw new Error("Session status is unavailable");if(n==="active")throw new Error("Session is not idle")}};class tf extends Error{changesMayBeInDestination;constructor(e,n,r){super(e,{cause:n}),this.name="IncompleteRollbackError",this.changesMayBeInDestination=r}}const oy=(t,e,n)=>{const r=e.map(({sessionId:i,error:o})=>`${i}: ${o.message}`).join(", ");return new tf(`Session move partially failed and could not be fully rolled back: ${t.message}. Rollback failures: ${r}`,{moveError:t,rollbackFailures:e},n)},iy=async(t,e,n,r)=>{const i=[];for(const o of[...t].reverse()){if(ip(o.id)){i.push({sessionId:o.id,error:new Error("Session is not idle")});continue}try{await Zd(o,n,e,!1),tt.getState().setWorktreeMetadata(o.id,r.get(o.id)??null)}catch(l){i.push({sessionId:o.id,error:l instanceof Error?l:new Error(String(l))})}}return i};class sf extends Error{constructor(e){super(e.message,{cause:e}),this.name="ChangesMayBeInDestinationError"}}const Yl=async(t,e,n)=>{try{await eu(t,e,{deleteLocalBranch:!0})}catch{throw new Error(`Session move failed and the new worktree could not be removed: ${n.message}`)}throw n},Ql=async(t,e)=>{const n=e?[t,e]:[t];try{await ka(n)}catch(r){console.warn("[session-worktree-move] Failed to refresh moved sessions",r)}},nf=async(t,e)=>{if(Kn.getState().pendingSessionIds.has(t.root.id))throw new Error("Session move already in progress");Gl(t.root.id,!0);try{const n=[...t.descendants,t.root],r=new Map(n.map(a=>[a.id,tt.getState().getWorktreeMetadata(a.id)]));ql(n);let i=null;const o=[];let l=!1;try{i=await e();for(const[a,d]of n.entries()){ql(n.slice(a));const u=d.id===t.root.id&&t.moveChanges;try{await Zd(d,t.sourceDirectory,i.directory,u)}catch(h){throw u&&rp(h)&&(l=!0),h}o.push(d),d.id!==t.root.id&&tt.getState().setWorktreeMetadata(d.id,kl(i.metadata))}}catch(a){const d=a instanceof Error?a:new Error(String(a)),u=await iy(o,t.sourceDirectory,i?.directory??t.sourceDirectory,r);if(l&&await Ql(t.sourceDirectory,i?.directory),u.length>0)throw oy(d,u,l);if(l)throw new sf(d);if(i?.onMoveFailure)return i.onMoveFailure(d);throw d}return tt.getState().setWorktreeMetadata(t.root.id,kl(i.metadata)),await Ql(t.sourceDirectory,i.directory),i.directory}finally{Gl(t.root.id,!1)}},ay=async t=>{const e=ht(t.sourceDirectory)??t.sourceDirectory,n=ht(t.destination.path)??t.destination.path;if(e===n)throw new Error("Source and destination are the same");if(t.destination.worktreeStatus!=="ready")throw new Error("Destination worktree is not ready");return nf(t,async()=>({directory:t.destination.path,metadata:t.destination}))},ly=async t=>nf(t,async()=>{const e=Mi(t.sourceDirectory);if(!e)throw new Error("Unable to find the project for this session");const n=await ja(t.sourceDirectory)?await ry(t.sourceDirectory,e.path):null,r=await ap(e,n?{startRef:n}:{});try{await lp(r.path)}catch(i){const o=i instanceof Error?i:new Error(String(i));return Yl(e,r,o)}return{directory:r.path,metadata:r,onMoveFailure:async i=>Yl(e,r,i)}}),cy=(t,e,n)=>e instanceof sf?t.changesMayBeInDestination:e instanceof tf&&e.changesMayBeInDestination?`${e.message} ${t.changesMayBeInDestination}`:n&&ny(e)?t.applyChangesFailed:e.message,Ji=(t,e)=>{(t.kind==="existing"?ay({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,destination:t.destination,moveChanges:e}):ly({root:t.root,descendants:t.descendants,sourceDirectory:t.sourceDirectory,moveChanges:e})).then(()=>Le.success(t.messages.success)).catch(r=>{const i=r instanceof Error?r:new Error(String(r));Le.error(t.messages.failure,{description:cy(t.messages,i,e)})})},dy=()=>{const t=ef();t&&(mr(t.intent.root.id,!1),Va(null))},rf=t=>{const e=ef();if(!e)return;const{intent:n}=e;Va(null),mr(n.root.id,!1),Ji(n,t)},Zi=t=>{const e=Kn.getState();e.confirmation||e.pendingSessionIds.has(t.root.id)||e.requestingSessionIds.has(t.root.id)||(mr(t.root.id,!0),(async()=>{try{if(!await ja(t.sourceDirectory)){mr(t.root.id,!1),Ji(t,!1);return}const r=await Jd(t.sourceDirectory);if(r.isClean){mr(t.root.id,!1),Ji(t,!1);return}const i=r.files.filter(o=>{const l=o.index.trim();return l!==""&&l!=="?"}).length;Va({intent:t,dirtyFileCount:r.files.length,stagedFileCount:i})}catch{Le.error(t.messages.failure,{description:t.messages.sourceVerificationFailed}),mr(t.root.id,!1)}})())};function uy(t){return t.confirmation}const Mo="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",fy=c.memo(function(e){const n=Ze.c(17),{visible:r,title:i,ariaLabel:o,onClick:l,className:a,Icon:d,iconClassName:u,pressed:h}=e,f=r===void 0?!0:r,x=h===void 0?!1:h;if(!f)return null;const b=a??Mo,w=x&&"bg-interactive-selection text-interactive-selection-foreground";let v;n[0]!==b||n[1]!==w?(v=Oe(b,w),n[0]=b,n[1]=w,n[2]=v):v=n[2];const y=u??"h-[18px] w-[18px]";let m;n[3]!==d||n[4]!==y?(m=s.jsx(M,{name:d,className:y}),n[3]=d,n[4]=y,n[5]=m):m=n[5];let p;n[6]!==o||n[7]!==l||n[8]!==x||n[9]!==v||n[10]!==m?(p=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:l,"aria-label":o,"aria-pressed":x,className:v,children:m})}),n[6]=o,n[7]=l,n[8]=x,n[9]=v,n[10]=m,n[11]=p):p=n[11];let S;n[12]!==i?(S=s.jsx(Dt,{children:s.jsx("p",{children:i})}),n[12]=i,n[13]=S):S=n[13];let g;return n[14]!==p||n[15]!==S?(g=s.jsxs(Nt,{children:[p,S]}),n[14]=p,n[15]=S,n[16]=g):g=n[16],g}),my=c.memo(function(e){const n=Ze.c(43),{isDesktopApp:r,currentInstanceLabel:i,currentInstanceIsLocal:o,isDesktopServicesOpen:l,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:d,shortcutLabel:u,remoteUpdateInfo:h,remoteUpdateChecking:f,remoteUpdateError:x,onOpenRemoteUpdate:b}=e,{t:w}=jt();let v;n[0]!==d||n[1]!==a?(v=T=>{a(T),T&&d()},n[0]=d,n[1]=a,n[2]=v):v=n[2];let y;n[3]!==i||n[4]!==r||n[5]!==w?(y=r?w("header.services.openWithCurrent",{current:i}):w("header.services.open"),n[3]=i,n[4]=r,n[5]=w,n[6]=y):y=n[6];const m=r?"w-auto max-w-[20rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let p;n[7]!==m?(p=Oe(Mo,m),n[7]=m,n[8]=p):p=n[8];let S;n[9]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(M,{name:"server",className:"h-[18px] w-[18px]"}),n[9]=S):S=n[9];let g;n[10]!==i||n[11]!==r?(g=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:i}):null,n[10]=i,n[11]=r,n[12]=g):g=n[12];let C;n[13]!==y||n[14]!==p||n[15]!==g?(C=s.jsx(At,{asChild:!0,children:s.jsx(zs,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":y,className:p,children:[S,g]})})}),n[13]=y,n[14]=p,n[15]=g,n[16]=C):C=n[16];let k;n[17]!==i||n[18]!==u||n[19]!==w?(k=w("header.services.tooltip.currentInstance",{current:i,toggle:u("toggle_services_menu")}),n[17]=i,n[18]=u,n[19]=w,n[20]=k):k=n[20];let j;n[21]!==k?(j=s.jsx(Dt,{children:s.jsx("p",{children:k})}),n[21]=k,n[22]=j):j=n[22];let D;n[23]!==C||n[24]!==j?(D=s.jsxs(Nt,{children:[C,j]}),n[23]=C,n[24]=j,n[25]=D):D=n[25];let I;n[26]!==o||n[27]!==r||n[28]!==l||n[29]!==b||n[30]!==f||n[31]!==x||n[32]!==h||n[33]!==a||n[34]!==w?(I=r?s.jsxs("div",{children:[o?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:w("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:h?.available?w("header.services.remoteUpdate.available",{version:h.version||""}):f?w("header.services.remoteUpdate.checking"):x||w("header.services.remoteUpdate.upToDate")})]}),h?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:b,children:w("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(cp,{embedded:!0,open:l,onOpenChange:py,onHostSwitched:()=>a(!1)})]}):null,n[26]=o,n[27]=r,n[28]=l,n[29]=b,n[30]=f,n[31]=x,n[32]=h,n[33]=a,n[34]=w,n[35]=I):I=n[35];let A;n[36]!==I?(A=s.jsx(Ws,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto p-0",children:I}),n[36]=I,n[37]=A):A=n[37];let P;return n[38]!==l||n[39]!==v||n[40]!==D||n[41]!==A?(P=s.jsxs(Ks,{open:l,onOpenChange:v,children:[D,A]}),n[38]=l,n[39]=v,n[40]=D,n[41]=A,n[42]=P):P=n[42],P}),jn=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},Xl=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,hy=()=>{Gs("ui.header.render");const{t}=jt(),e=Pe(U=>U.isSidebarOpen),n=Pe(U=>U.openContextOverview),r=Pe(U=>U.closeContextPanel),i=Pe(U=>U.shortcutOverrides),o=Pe(U=>U.sessionTabsEnabled),l=tt(U=>U.getContextUsage),a=tt(U=>!!U.newSessionDraft?.open),d=tt(U=>U.currentSessionId),u=dp(d??""),h=Sa(d??""),f=Zu(d??""),x=$s(rr(c.useCallback(U=>{if(!d)return null;const Te=[...U.activeSessions,...U.archivedSessions].find(Et=>Et.id===d);if(!Te)return null;const ot=Te;return{title:Te.title??null,directory:ot.directory??null,created:Te.time?.created??null,slug:ot.slug??null,shareUrl:Te.share?.url??null,parentId:Te.parentID??null}},[d]))),b=Ht(rr(U=>{if(!U.activeProjectId)return null;const Te=U.projects.find(ot=>ot.id===U.activeProjectId);return Te?{id:Te.id,path:Te.path,label:Te.label}:null})),w=c.useMemo(()=>{if(!b)return null;const U=b.label?.trim();if(U)return U;const Te=b.path.split(/[\\/]/).filter(Boolean);return Te[Te.length-1]??null},[b]),v=ur(U=>U.loadSettings),{isMobile:y}=zn(),m=c.useRef(null),[p,S]=c.useState(()=>typeof window>"u"?!1:xn()),g=c.useMemo(()=>Ur(),[]),C=tu(),[k,j]=c.useState(!1),D=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),{usesFramelessChrome:I,side:A}=Lu(),P=c.useMemo(()=>{if(typeof window>"u")return null;const U=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof U=="number"&&Number.isFinite(U)&&U>0)return U;if(typeof navigator>"u")return null;const Te=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!Te)return null;const ot=Number.parseInt(Te[1],10),Et=Number.parseInt(Te[2],10);return Number.isNaN(ot)?null:ot===10?Et:ot},[]);mt.useEffect(()=>{typeof window>"u"||S(xn())},[]);const{context:T,output:L}=up(d),$=l(T,L),[K,F]=c.useState(null),W=!d||u;mt.useEffect(()=>{if(!d){F(U=>U===null?U:null);return}if($){F(U=>fp(U,$)?U:$);return}W&&F(U=>U===null?U:null)},[$,d,W]);const[N,R]=c.useState(!1),[E,X]=c.useState("Local"),[J,re]=c.useState(!0),[fe,ne]=c.useState(!1),[te,ue]=c.useState(null),[Se,we]=c.useState(!1),[ye,Ae]=c.useState(null),pe=c.useMemo(()=>$n(),[]),O=Pe(U=>U.workStatusPanelVisible),Q=Pe(U=>U.workStatusPanelEnabled),le=Pe(U=>U.setWorkStatusPanelEnabled),H=Pe(U=>U.workStatusPanelFits),me=Pe(U=>U.workStatusOverlayOpen),ge=Pe(U=>U.setWorkStatusOverlayOpen),de=Q&&H||me,_=c.useCallback(()=>{if(Q&&!H){ge(!me);return}le(!Q)},[ge,le,me,Q,H]),B=!pe&&!O&&!!K,he=c.useCallback(async()=>{if(!(typeof window>"u"||!p))try{if(Vo()){X("Local"),re(!0);return}re(!1);const U=await Td(),Te=Fm(),ot=_m([Lm(Te),...U.hosts]);if(ot.id===$m){X("Local"),re(!0);return}X(Ed(ot.label.trim()||"Instance"))}catch{X("Local"),re(!0)}},[p]);mt.useEffect(()=>(he(),Qr(()=>{he()})),[he]);const ve=c.useCallback(async()=>{if(J){ue(null),Ae(null);return}we(!0),Ae(null);try{const U=new URLSearchParams({appType:"web",instanceMode:"remote",reportUsage:"false"}),Te=await ls(`/api/openchamber/update-check?${U.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!Te.ok)throw new Error(`Server responded with ${Te.status}`);const ot=await Te.json();ue({available:ot.available??!1,version:ot.version,currentVersion:ot.currentVersion??"unknown",body:ot.body,nextSuggestedCheckInSec:typeof ot.nextSuggestedCheckInSec=="number"?ot.nextSuggestedCheckInSec:void 0,packageManager:ot.packageManager,updateCommand:ot.updateCommand})}catch(U){ue(null),Ae(U instanceof Error?U.message:t("header.services.remoteUpdate.error"))}finally{we(!1)}},[J,t]);c.useEffect(()=>{ue(null),Ae(null),ne(!1)},[J,E]),c.useEffect(()=>{if(!p||J)return;const U=3e3,Te=3600*1e3;let ot=!1,Et=null;const Mt=$t=>{Et=window.setTimeout(()=>{if(ot||typeof document<"u"&&document.visibilityState!=="visible"){Mt(Te);return}ve().finally(()=>{ot||Mt(Te)})},$t)};return Mt(U),()=>{ot=!0,Et!==null&&window.clearTimeout(Et)}},[ve,J,E,p]);const Re=c.useCallback(()=>{if(te?.available){ne(!0);return}ve()},[ve,te?.available]);mp(),c.useEffect(()=>{v()},[v]);const ce=d?x??null:null,se=c.useRef(null),[q,z]=c.useState(0);c.useEffect(()=>{if(!d){se.current&&(se.current=null,z(Et=>Et+1));return}if(ce){se.current={sessionId:d,session:ce,expiresAt:Date.now()+2e3};return}const U=se.current;if(!U||U.sessionId!==d)return;const Te=U.expiresAt-Date.now();if(Te<=0){se.current=null,z(Et=>Et+1);return}const ot=window.setTimeout(()=>{se.current?.sessionId===d&&(se.current=null),z(Et=>Et+1)},Te);return()=>{window.clearTimeout(ot)}},[d,ce]);const ee=(()=>{if(ce)return ce;if(!d)return null;const U=se.current;return U&&U.sessionId===d&&U.expiresAt>Date.now()?U.session:null})(),ae=tt(U=>d?U.worktreeMetadata.get(d)?.path??"":""),Ne=tt(U=>d?U.worktreeMetadata.get(d)?.branch?.trim()??null:null),Ce=su(U=>d?U.getAttachment(d):void 0),We=c.useMemo(()=>Ce?hp(Ce,{pending:t("gitView.empty.worktreeSetupInProgress"),missing:t("sessions.sidebar.group.worktreeMissing")}):null,[t,Ce]),Ee=c.useMemo(()=>Ce?Ce.legacy?"legacy":Ce.degraded?"degraded":Ce.worktreeStatus==="pending"?"pending":Ce.worktreeStatus==="missing"?"missing":Ce.worktreeStatus==="invalid"?"invalid":Ce.attentionReason?"attention":null:null,[Ce]),xe=c.useMemo(()=>jn(ae||""),[ae]),$e=c.useMemo(()=>{const U=typeof ee?.directory=="string"?ee.directory:"";return jn(U||"")},[ee?.directory]),V=va(d??"",$e),De=tt(U=>U.newSessionDraft?.open?jn(U.newSessionDraft.bootstrapPendingDirectory??U.newSessionDraft.directoryOverride??""):""),Fe=tt(U=>U.newSessionDraft.target),_e=tt(U=>U.newSessionDraft.selectedProjectId),rt=tt(U=>U.currentSessionDirectory),ct=ns(U=>U.homeDirectory),et=c.useMemo(()=>xe||$e||De,[De,$e,xe]),pt=Pe(c.useCallback(U=>{const Te=jn(et||"");return Te?Xl(U.contextPanelByDirectory[Te]):null},[et])),kt=tt(U=>{const Te=jn(xe||$e||"");if(!Te)return null;for(const ot of U.availableWorktreesByProject.values()){const Mt=ot.find($t=>jn($t.path)===Te)?.branch?.trim();if(Mt)return Mt}return null}),Xe=pp(et||null)||Ne||kt,yt=a?Fe==="chat":gp($e||rt,ct),Rt=!yt&&!O&&!!(w||Xe||!a&&Ee),be=c.useMemo(()=>{if(!d)return w??"OpenChamber";const U=ee?.title?.trim();return U&&U.length>0?U:"Untitled Session"},[w,ee?.title,d]),Ge=nu(et||void 0,{bootstrap:!1}),ut=ru(),Y=tt(U=>U.updateSessionTitle),G=tt(U=>U.shareSession),Z=tt(U=>U.unshareSession),je=tt(U=>U.archiveSessions),Ie=tt(U=>U.deleteSessions),[Ve,Je]=c.useState(!1),[it,at]=c.useState(!1),Ye=c.useRef(null),[vt,Ue]=c.useState(""),[Pt,ke]=c.useState(null),xt=c.useRef(null),Ct=c.useCallback(()=>{d&&(Ue(ee?.title?.trim()||be),Je(!0))},[ee?.title,d,be]),Tt=c.useRef(Ct);Tt.current=Ct;const qe=c.useCallback(U=>{U&&(U.focus(),U.select())},[]);c.useEffect(()=>{if(at(!1),ke(null),d&&Ye.current===d){Ye.current=null,Tt.current();return}Je(!1),Ue("")},[d]);const ze=c.useCallback(async()=>{if(!d)return;const U=vt.trim();U&&U!==ee?.title?.trim()&&await Y(d,U),Je(!1)},[ee?.title,d,vt,Y]);c.useEffect(()=>{if(!Ve)return;const U=Te=>{const ot=Te.target;(!ot||!xt.current?.contains(ot))&&ze()};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[Ve,ze]);const ft=c.useCallback(U=>{U&&gn(U).then(Te=>{Le[Te.ok?"success":"error"](t(Te.ok?"sessions.sidebar.session.copyId.success":"sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(t("sessions.sidebar.session.copyId.error")))},[t]),Be=c.useCallback(async U=>{if(!U)return;const Te=await G(U);if(Te?.share?.url){const ot=await gn(Te.share.url);Le[ot.ok?"success":"warning"](t("sessions.sidebar.session.share.successTitle"),{description:t(ot.ok?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")});return}Le.error(t("sessions.sidebar.session.share.error"))},[G,t]),Ke=c.useCallback(U=>{U&&gn(U).then(Te=>{Le[Te.ok?"success":"error"](t(Te.ok?"sessions.sidebar.session.menu.copied":"sessions.sidebar.session.share.copyUrlError"))}).catch(()=>Le.error(t("sessions.sidebar.session.share.copyUrlError")))},[t]),He=c.useCallback(async U=>{if(!U)return;const Te=await Z(U);Le[Te?"success":"error"](t(Te?"sessions.sidebar.session.unshare.success":"sessions.sidebar.session.unshare.error"))},[t,Z]),nt=c.useCallback(async()=>{if(!d||!et){Le.error(t("sessions.sidebar.session.export.nothingToExport"));return}try{await ut.loadCompleteHistory(d,et)}catch{Le.error(t("sessions.sidebar.session.export.failedLoadHistory"));return}const U=Cl(Ge.getState(),d).list;if(U.length===0){Le.error(t("sessions.sidebar.session.export.nothingToExport"));return}const Te=ou(U,ee?.title??null),ot=iu(ee?.title??null);await au(Te,ot)||lu(Te,ot),Le.success(t("sessions.sidebar.session.export.success"))},[ee?.title,d,Ge,et,ut,t]),St=cu(),Lt=c.useMemo(()=>du(St),[St]),Ut=c.useCallback(U=>{d&&Ju({entry:U,t,session:{id:d,title:ee?.title,directory:$e??et},loadRecords:async()=>{if(!et)return null;try{await ut.loadCompleteHistory(d,et)}catch{return null}return Cl(Ge.getState(),d).list},onLoadFailed:()=>Le.error(t("sessions.sidebar.session.export.failedLoadHistory"))})},[ee?.title,d,Ge,et,$e,ut,t]),Bt=c.useCallback(U=>Lt.map(Te=>s.jsxs(U,{onClick:()=>Ut(Te),children:[s.jsx(Xr,{icon:Te.icon,iconSrc:Te.iconSrc,className:"mr-1 size-4"}),Te.action.label]},`${Te.guest.id}:${Te.action.id}`)),[Lt,Ut]),zt=h?.type==="busy"||h?.type==="retry",_t=c.useCallback(()=>{if(!d||!$e||zt||f)return;const U=$s.getState().activeSessions,Te=U.find(Mt=>Mt.id===d);if(!Te)return;const ot=[],Et=[d];for(let Mt=0;Mt<Et.length;Mt+=1){const $t=Et[Mt];for(const Wt of U)Wt.parentID===$t&&(ot.push(Wt),Et.push(Wt.id))}Zi({kind:"quick",root:Te,descendants:ot,sourceDirectory:$e,messages:Xi(t,{success:"sessions.sidebar.session.moveToWorktree.success",failure:"sessions.sidebar.session.moveToWorktree.failed"})})},[d,zt,f,$e,t]),Yt=c.useCallback(async()=>{if(!Pt)return;const U=Pt.action,Te=[Pt.sessionId,..._d(Pt.sessionId,[],U==="delete")];if(ke(null),(U==="archive"?await je(Te):await Ie(Te)).failedIds.length>0){Le.error(t(U==="archive"?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error"));return}Le.success(t(U==="archive"?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"))},[je,Ie,Pt,t]),Zt=Pe(U=>U.openGuestPageId),es=uu(U=>U.guests.find(Te=>Te.id===Zt)),Vt=Pe(U=>U.isScheduledTasksDialogOpen),It=Pe(U=>U.isArchivePageOpen),bt=Pe(U=>U.worktreesPageProjectId),cs=Pe(U=>U.isMultiRunLauncherOpen),ms=Ht(U=>{if(!bt)return null;const Te=U.projects.find(ot=>ot.id===bt);return Te?.label?.trim()||Te?.path?.split("/").pop()||null}),hs=c.useMemo(()=>es?{title:es.pageTitle??es.name,subtitle:null}:Vt?{title:t("sessions.scheduledTasks.dialog.title"),subtitle:null}:It?{title:t("sessions.archivePage.title"),subtitle:null}:bt?{title:t("sessions.worktreesPage.title",{project:ms??""}),subtitle:null}:cs?{title:t("sessions.sidebar.header.actions.newMultiRun"),subtitle:null}:null,[es,It,cs,Vt,t,bt,ms]),ds=c.useMemo(()=>jn(et||b?.path||""),[b?.path,et]),nn=_b(),Ts=Ca(U=>U.planModeEnabled),rn=tt(U=>U.isSessionPlanAvailable),os=Ts&&d?rn(d):!1,qs=c.useRef("");c.useEffect(()=>{if(!Ts||!d)return;const U=`${d||"none"}:${$e||"none"}:${ee?.created||0}:${ee?.slug||"none"}`;qs.current!==U&&(qs.current=U)},[Ts,os,ee?.slug,ee?.created,d,$e]);const Ys=c.useCallback(()=>{_n("desktop_open_draft_mini_chat_window",{directory:yt?"":De,projectId:yt?null:_e,apiBaseUrl:Pn(),clientToken:Hr()}).catch(U=>{console.warn("[header] failed to open draft mini chat window",U)})},[De,_e,yt]),Cs=c.useCallback(()=>{if(a){Ys();return}d&&_n("desktop_open_session_mini_chat_window",{sessionId:d,directory:$e||jn(rt||"")||xe,apiBaseUrl:Pn(),clientToken:Hr()}).catch(U=>{console.warn("[header] failed to open session mini chat window",U)})},[d,Ys,a,rt,$e,xe]),Ns=c.useCallback(()=>{const U=jn(et||"");if(!U)return;const Te=Pe.getState().contextPanelByDirectory[U];if(Xl(Te)==="context"){r(U);return}n(U)},[r,n,et]),mn=pt==="context",Es=Mo,Rs=c.useMemo(()=>p&&D&&!k?"88px":C?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!p||I)&&!pe?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[p,k,D,C,pe,I]);mt.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",Rs)},[Rs]);const Qs=e?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",on=e?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";mt.useEffect(()=>{if(!p||!D){j(!1);return}let U=!1;const Te=async()=>{try{const Et=await _n("desktop_is_window_fullscreen");U||j(Et===!0)}catch{U||j(!1)}},ot=()=>{Te()};return Te(),window.addEventListener("openchamber:window-resized",ot),()=>{U=!0,window.removeEventListener("openchamber:window-resized",ot)}},[p,D]);const an=c.useMemo(()=>!p||!D||P===null?"":P>=26?"h-12":P<=15?"h-14":"",[p,D,P]),ps=c.useMemo(()=>{if(!(p&&!I||pe)&&!(I&&A==="right"))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[p,pe,I,A]),vs=c.useCallback(()=>{if(typeof document>"u")return;const U=m.current?.getBoundingClientRect().height;U&&document.documentElement.style.setProperty("--oc-header-height",`${U}px`)},[]);mt.useEffect(()=>{if(typeof window>"u")return;vs();const U=m.current;if(!U||typeof ResizeObserver>"u")return()=>{};let Te=0;const ot=()=>{Te||(Te=requestAnimationFrame(()=>{Te=0,vs()}))},Et=new ResizeObserver(ot);return Et.observe(U),window.addEventListener("resize",ot),window.addEventListener("orientationchange",ot),()=>{Te&&cancelAnimationFrame(Te),Et.disconnect(),window.removeEventListener("resize",ot),window.removeEventListener("orientationchange",ot)}},[vs]),mt.useEffect(()=>{vs()},[vs,y,an]);const ln=c.useCallback(async U=>{const Te=U.target;Te.closest(".app-region-no-drag")||Te.closest("button, a, input, select, textarea")||U.button===0&&p&&await zm()},[p]),Sn=c.useCallback(U=>er(Jr(U,i)),[i]);xp({rename_current_session:()=>{if(!d||y)return!1;Ct()},toggle_services_menu:()=>{if(N){R(!1);return}R(!0),he()}});const ie=s.jsxs(s.Fragment,{children:[nn?s.jsx(Bb,{projectRef:nn.projectRef,directory:nn.directory,className:"mr-2"}):null,s.jsx(db,{directory:ds,className:"mr-1"}),p?s.jsx(my,{isDesktopApp:p,currentInstanceLabel:E,currentInstanceIsLocal:J,isDesktopServicesOpen:N,setIsDesktopServicesOpen:R,refreshCurrentInstanceLabel:he,shortcutLabel:Sn,remoteUpdateInfo:te,remoteUpdateChecking:Se,remoteUpdateError:ye,onOpenRemoteUpdate:Re}):null]}),Qe=g&&(a||!!d),lt=c.useCallback(({session:U,open:Te,isActive:ot,select:Et,closeOtherTabs:Mt,components:$t})=>{const{Item:Wt,Separator:Ss}=$t,is=U.share?.url??null,Vn=ot&&!pe&&!yt&&ee&&!ee.parentId;return s.jsxs(s.Fragment,{children:[s.jsxs(Wt,{onClick:()=>{ot||Et(),Ye.current=U.id},children:[s.jsx(M,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(Qi,{sessionID:U.id,directory:U.directory,open:Te,Item:Wt}),s.jsxs(Wt,{onClick:()=>ft(U.id),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Ss,{}),is?s.jsxs(s.Fragment,{children:[s.jsxs(Wt,{onClick:()=>Ke(is),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Wt,{onClick:()=>{He(U.id)},children:[s.jsx(M,{name:"link-unlink-m",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Wt,{onClick:()=>{Be(U.id)},children:[s.jsx(M,{name:"share-2",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.share")]}),ot?s.jsxs(Wt,{onClick:()=>{nt()},children:[s.jsx(M,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}):null,ot?Bt(Wt):null,Vn?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Wt,{disabled:!$e||zt||f,onClick:_t,className:"w-full",children:[s.jsx(M,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(Dt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":zt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Ss,{}),s.jsxs(Wt,{onClick:Mt,children:[s.jsx(M,{name:"close-circle",className:"mr-1 size-4"}),t("header.sessionTabs.closeOtherTabs")]}),s.jsx(Ss,{}),s.jsxs(Wt,{onClick:()=>ke({action:"archive",sessionId:U.id}),children:[s.jsx(M,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Wt,{className:"text-destructive focus:text-destructive",onClick:()=>ke({action:"delete",sessionId:U.id}),children:[s.jsx(M,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})},[ft,Ke,ee,nt,yt,zt,f,pe,_t,Bt,$e,Be,t,He]),st=()=>s.jsxs("div",{onMouseDown:ln,className:Oe("app-region-drag relative flex h-12 select-none items-center",I&&A==="right"?"pr-0":"pr-3",an),style:ps,role:"tablist","aria-label":t("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Qs}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:on}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[hs?s.jsxs(s.Fragment,{children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"icon",className:"app-region-no-drag mr-1 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.mainSurface.backToChat"),onClick:()=>Pe.getState().closeMainSurfaces(),children:s.jsx(M,{name:"arrow-left",className:"size-[18px]"})})}),s.jsx(Dt,{side:"bottom",children:t("header.mainSurface.backToChat")})]}),s.jsxs("div",{className:"mr-3 flex min-w-0 flex-col items-start px-1 py-0.5 -my-0.5 text-left",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:hs.title}),hs.subtitle?s.jsx("span",{className:"truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75 max-w-full",children:hs.subtitle}):null]})]}):pe||!o?s.jsxs("div",{className:"app-region-no-drag mr-3 flex min-w-0 max-w-full items-center gap-0.5 py-0.5 -my-0.5 text-left",children:[V?s.jsx(M,{name:"loader-4",className:"mr-1 size-3 shrink-0 animate-spin text-primary","aria-label":t("sessions.aiRename.generating")}):null,e?null:s.jsx(Kl,{align:"start",children:s.jsx("button",{type:"button",className:Es,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(M,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsxs("div",{className:"flex min-w-0 flex-col justify-center px-1",children:[Ve?s.jsxs("form",{ref:xt,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:U=>U.stopPropagation(),onSubmit:U=>{U.preventDefault(),ze()},children:[s.jsx("input",{ref:qe,value:vt,onChange:U=>Ue(U.target.value),onKeyDown:U=>Ti(U,()=>Je(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent typography-ui-label text-[14px] font-normal leading-tight outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Je(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):be}),Rt?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[w?s.jsx("span",{className:"truncate",children:w}):null,Xe?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(M,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:Xe})]}):null,!a&&Ee?s.jsxs("span",{className:Oe("inline-flex min-w-0 items-center gap-0.5",Ee==="attention"||Ee==="invalid"||Ee==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(M,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:We})]}):null]}):null]}),s.jsx("div",{className:Oe("flex h-[18px] shrink-0 items-center justify-center",Rt?"self-start":"self-center"),children:d&&!a&&!Ve?s.jsxs(Ks,{open:it,onOpenChange:at,onOpenChangeComplete:U=>{!U&&Ye.current&&Ye.current===d&&(Ye.current=null,Ct())},children:[s.jsx(zs,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"xs",className:"h-[18px] w-6 px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-label":t("header.sessionActions.openAria"),children:s.jsx(M,{name:"more",className:"size-4"})})}),s.jsxs(Ws,{align:"end",className:"min-w-[190px]",children:[s.jsxs(Kt,{onClick:()=>{Ye.current=d},children:[s.jsx(M,{name:"pencil-ai",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.rename")]}),s.jsx(Qi,{sessionID:d,directory:$e,open:it,Item:Kt}),s.jsxs(Kt,{onClick:()=>d&&ft(d),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyId")]}),s.jsx(Os,{}),ee?.shareUrl?s.jsxs(s.Fragment,{children:[s.jsxs(Kt,{onClick:()=>Ke(ee?.shareUrl),children:[s.jsx(M,{name:"file-copy",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.copyLink")]}),s.jsxs(Kt,{onClick:()=>{d&&He(d)},children:[s.jsx(M,{name:"link-unlink-m",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(Kt,{onClick:()=>{d&&Be(d)},children:[s.jsx(M,{name:"share-2",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.share")]}),s.jsxs(Kt,{onClick:()=>{nt()},children:[s.jsx(M,{name:"download",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.exportMarkdown")]}),Bt(Kt),!pe&&!yt&&ee&&!ee.parentId?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:"block",children:s.jsxs(Kt,{disabled:!$e||zt||f,onClick:_t,className:"w-full",children:[s.jsx(M,{name:"folder-shared",className:"mr-1 size-4"}),t("sessions.sidebar.session.menu.moveToWorktree")]})})}),s.jsx(Dt,{side:"right",className:"max-w-72",children:t(f?"sessions.sidebar.session.moveToWorktree.tooltipMoving":zt?"sessions.sidebar.session.moveToWorktree.tooltipBusy":"sessions.sidebar.session.moveToWorktree.tooltip")})]}):null,s.jsx(Os,{}),s.jsxs(Kt,{onClick:()=>{d&&ke({action:"archive",sessionId:d})},children:[s.jsx(M,{name:"inbox-archive",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.archive")]}),s.jsxs(Kt,{className:"text-destructive focus:text-destructive",onClick:()=>{d&&ke({action:"delete",sessionId:d})},children:[s.jsx(M,{name:"delete-bin",className:"mr-1 size-4"}),t("sessions.sidebar.bulkActions.delete")]})]})]}):null})]}):s.jsxs("div",{className:"app-region-no-drag flex h-full min-w-0 flex-1 items-center gap-0.5 text-left",children:[e?null:s.jsx(Kl,{align:"start",children:s.jsx("button",{type:"button",className:Es,"aria-label":t("sessions.switcher.openAria"),children:s.jsx(M,{name:"history",className:"h-[18px] w-[18px]"})})}),s.jsx(Kb,{renderMenu:lt,suppressActiveTabControls:Ve,onMenuOpenChangeComplete:U=>{!U&&Ye.current&&Ye.current===d&&(Ye.current=null,Ct())},children:s.jsx("div",{className:"flex min-w-0 flex-col justify-center",children:Ve?s.jsxs("form",{ref:xt,className:"flex w-full min-w-0 items-center gap-2 leading-tight",onPointerDown:U=>U.stopPropagation(),onSubmit:U=>{U.preventDefault(),ze()},children:[s.jsx("input",{ref:qe,value:vt,onChange:U=>Ue(U.target.value),onKeyDown:U=>Ti(U,()=>Je(!1)),placeholder:t("sessions.sidebar.session.menu.rename"),className:"min-w-0 flex-1 bg-transparent text-[13px] font-medium leading-4 outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"submit","aria-label":t("sessions.sidebar.session.rename.save"),title:t("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:()=>Je(!1),"aria-label":t("sessions.sidebar.session.rename.cancel"),title:t("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]}):s.jsx("span",{className:"block overflow-hidden whitespace-nowrap text-[13px] font-medium leading-4 text-foreground max-w-full",children:a?t("sessions.switcher.draftTitle"):be})})})]}),hs||pe||!o?s.jsx("div",{className:"flex-1"}):null,s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[B&&K?s.jsx(Dx,{reading:Px(K),contextLimit:K.contextLimit,outputLimit:K.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Ns,pressed:mn,className:Qe?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,s.jsx(fy,{visible:Qe,title:t(a?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:t(a?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:Cs,className:Oe(Es,"mr-1"),Icon:"picture-in-picture-2"}),pe?null:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button","data-work-status-toggle":"true","aria-pressed":de,"aria-label":t("header.workStatusPanel.toggleAria"),onClick:_,className:Oe(Mo,"mr-1",de?"text-foreground":"text-muted-foreground/50"),children:s.jsx(M,{name:"list-indefinite",className:"h-[18px] w-[18px]"})})}),s.jsx(Dt,{side:"bottom",children:t(Q&&!H?me?"header.workStatusPanel.hide":"header.workStatusPanel.showOverlay":Q?"header.workStatusPanel.hide":"header.workStatusPanel.show")})]}),ie,s.jsx($u,{visible:I&&A==="right",position:"right"})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:m,className:"header-safe-area relative z-10 bg-background",style:{"--padding-scale":"1"},children:st()}),s.jsx(ys,{open:Pt!==null,onOpenChange:U=>{U||ke(null)},children:s.jsxs(ws,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Vs,{children:[s.jsx(Ps,{children:Pt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.title"):t("sessions.sidebar.dialogs.archiveSession.title")}),s.jsx(Is,{children:Pt?.action==="delete"?t("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:be}):t("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:be})})]}),s.jsxs(bn,{children:[s.jsx(dt,{variant:"outline",size:"sm",onClick:()=>ke(null),children:t("sessions.sidebar.dialogs.cancel")}),s.jsx(dt,{variant:"destructive",size:"sm",onClick:()=>{Yt()},children:Pt?.action==="delete"?t("sessions.sidebar.bulkActions.delete"):t("sessions.sidebar.bulkActions.archive")})]})]})}),s.jsx(Ld,{open:fe,onOpenChange:ne,info:te,downloading:!1,downloaded:!1,progress:null,error:ye,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function py(){}const Jl=280,Zl=168,ec=500,gy=({isOpen:t,isMobile:e,children:n,className:r,topBar:i})=>{const{t:o}=jt(),l=Pe(j=>j.sidebarWidth),a=Pe(j=>j.setSidebarWidth),[d,u]=c.useState(!1),h=c.useRef(0),f=c.useRef(l||Jl),x=c.useRef(null),b=c.useRef(null),w=c.useRef(null),v=c.useCallback(j=>Math.min(ec,Math.max(Zl,j)),[]),y=c.useCallback(j=>{const D=w.current;D&&(D.style.width=`${j}px`,D.style.minWidth=`${j}px`,D.style.maxWidth=`${j}px`,D.style.setProperty("--oc-left-sidebar-width",`${j}px`))},[]);if(c.useEffect(()=>{e&&d&&u(!1)},[e,d]),c.useEffect(()=>{d||(x.current=null,b.current=null)},[d]),e)return null;const m=Math.min(ec,Math.max(Zl,l||Jl)),p=t?m:0,S=j=>{if(t){try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}b.current=j.pointerId,u(!0),h.current=j.clientX,f.current=p,x.current=p,y(p),j.preventDefault()}},g=j=>{if(e||!d||b.current!==j.pointerId)return;const D=j.clientX-h.current,I=v(f.current+D);x.current!==I&&(x.current=I,y(I))},C=j=>{if(b.current!==j.pointerId||e)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const D=v(x.current??p);b.current=null,x.current=null,u(!1),a(D)},k=d?x.current??p:p;return s.jsxs("aside",{ref:w,className:Oe("relative flex h-full overflow-hidden border-r border-border will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",r),style:{width:`${k}px`,minWidth:`${k}px`,maxWidth:`${k}px`,"--oc-left-sidebar-width":`${d?k:m}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||p===0,children:[t&&s.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&s.jsx("div",{className:Oe("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:S,onPointerMove:g,onPointerUp:C,onPointerCancel:C,role:"separator","aria-orientation":"vertical","aria-label":o("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Oe("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,s.jsx(yn,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx(As,{children:n})})]})]})},xy=()=>{const t=Ze.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},tc="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:bg-interactive-hover transition-colors",by=()=>{const t=Ze.c(32),{t:e}=jt(),n=Pe(yy),r=Pe(wy),i=c.useRef(null),o=er(Jr("toggle_sidebar",r)),{usesFramelessChrome:l,side:a}=Lu(),d=Sy;let u,h;t[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{if(typeof document>"u")return;const T=i.current;if(!T)return;const L=()=>{const K=Math.max(T.getBoundingClientRect().width,T.scrollWidth);document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round(K)}px`)};if(L(),typeof ResizeObserver>"u")return;const $=new ResizeObserver(L);return $.observe(T),()=>{$.disconnect()}},h=[],t[0]=u,t[1]=h):(u=t[0],h=t[1]),c.useEffect(u,h);const f="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let x;t[2]===Symbol.for("react.memo_cache_sentinel")?(x={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=x):x=t[2];const b="flex items-center gap-2";let w;t[3]!==l||t[4]!==a?(w=l&&a==="left"?s.jsx($u,{visible:!0,position:"left"}):null,t[3]=l,t[4]=a,t[5]=w):w=t[5];let v;t[6]!==e||t[7]!==l?(v=l?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,"aria-label":e("header.actions.openAppMenuAria"),className:Oe(tc,"shrink-0"),children:s.jsx(M,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(Dt,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[6]=e,t[7]=l,t[8]=v):v=t[8];const y=Nt;let m;t[9]!==e?(m=e("header.actions.openSessionsAria"),t[9]=e,t[10]=m):m=t[10];let p,S;t[11]===Symbol.for("react.memo_cache_sentinel")?(p=Oe(tc,"shrink-0"),S=s.jsx(M,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[11]=p,t[12]=S):(p=t[11],S=t[12]);let g;t[13]!==m||t[14]!==n?(g=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":m,className:p,children:S})}),t[13]=m,t[14]=n,t[15]=g):g=t[15];const C=Dt,k=e("header.actions.openSessionsWithShortcut",{shortcut:o});let j;t[16]!==k?(j=s.jsx("p",{children:k}),t[16]=k,t[17]=j):j=t[17];let D;t[18]!==C||t[19]!==j?(D=s.jsx(C,{children:j}),t[18]=C,t[19]=j,t[20]=D):D=t[20];let I;t[21]!==y||t[22]!==g||t[23]!==D?(I=s.jsxs(y,{children:[g,D]}),t[21]=y,t[22]=g,t[23]=D,t[24]=I):I=t[24];let A;t[25]!==I||t[26]!==w||t[27]!==v?(A=s.jsxs("div",{ref:i,className:b,children:[w,v,I]}),t[25]=I,t[26]=w,t[27]=v,t[28]=A):A=t[28];let P;return t[29]!==A||t[30]!==x?(P=s.jsx("div",{className:f,style:x,children:A}),t[29]=A,t[30]=x,t[31]=P):P=t[31],P};function yy(t){return t.toggleSidebar}function wy(t){return t.shortcutOverrides}function vy(t){console.warn("[titlebar] failed to open app menu",t)}function Sy(t){const e=t.currentTarget.getBoundingClientRect();_n("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(vy)}function of(t){const e=Ze.c(5),{className:n}=t,i=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let o,l,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),l=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(M,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=o,e[1]=l,e[2]=a):(o=e[0],l=e[1],a=e[2]);let d;return e[3]!==i?(d=s.jsxs("span",{"aria-hidden":"true",className:i,children:[o,l,a]}),e[3]=i,e[4]=d):d=e[4],d}const sc=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function jy(t,e,n){const r=Ze.c(5),[i,o]=c.useState();let l,a;return r[0]!==n||r[1]!==t||r[2]!==e?(l=()=>{if(e){o(void 0);return}if(!t){o(void 0);return}o(void 0);let d=!1;return(async()=>{const[u,h]=await Promise.all([bp(t),yp(t)]).catch(ky);if(d)return;const f=sc(u),x=sc(h);if(!f||!x||x===f)return;const b=n||"",w=x.split("/").filter(Boolean).pop()||x;o({source:"sdk",path:x,projectDirectory:f,branch:b,label:b||w,name:w,worktreeRoot:x,worktreeStatus:"ready",headState:b?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},a=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=l,r[4]=a):(l=r[3],a=r[4]),c.useEffect(l,a),e??i}function ky(){return["",""]}const nc="flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",Cy=async(t,e)=>{if(t)return t.authActivate(e);const n=await ls("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await n.json().catch(()=>null);if(!n.ok||!r)throw new Error(r?.error||n.statusText);return r},rc=({className:t})=>{const{t:e}=jt(),{github:n}=vn(),r=In(b=>b.status),i=In(b=>b.setStatus),[o,l]=c.useState(!1),a=c.useCallback(async b=>{if(!(!b||o)){l(!0);try{i(await Cy(n,b))}catch(w){console.error("Failed to switch GitHub account:",w)}finally{l(!1)}}},[n,o,i]);if(!r?.connected)return null;const d=r.user?.login??null,u=r.user?.avatarUrl??null,h=r.accounts??[],f=d?e("header.github.connectedWithLogin",{login:d}):e("header.github.connected"),x=u?s.jsx("img",{src:u,alt:d?e("header.github.avatarWithLogin",{login:d}):e("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(M,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"});return h.length<=1?s.jsx("div",{className:Oe(nc,t),title:f,children:x}):s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe(nc,"p-0 hover:ring-2 hover:ring-primary/40 disabled:opacity-50",t),title:f,disabled:o,children:x})}),s.jsxs(Ws,{align:"end",className:"w-64",children:[s.jsx(Fr,{className:"typography-ui-header font-semibold text-foreground",children:e("header.github.accountsTitle")}),s.jsx(Os,{}),h.map(b=>{const w=b.user,v=!!b.current,y=b.source==="gh-cli"?e("header.github.accountSource.cli"):e("header.github.accountSource.oauth");return s.jsxs(Kt,{className:"gap-2",disabled:o,onSelect:()=>{v||a(b.id)},children:[w?.avatarUrl?s.jsx("img",{src:w.avatarUrl,alt:w.login?e("header.github.avatarWithLogin",{login:w.login}):e("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(M,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:w?.name?.trim()||w?.login||"GitHub"}),w?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:w.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:y})]}):null]}),v?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},b.id)})]})]})};class ni extends Error{code;model;requiredChars;availableChars;constructor(e,n={}){super(e),this.name="WalkthroughError",this.code=n.code,this.model=n.model,this.requiredChars=n.requiredChars,this.availableChars=n.availableChars}}const ri="/api/walkthrough",af=t=>/^application\/(?:[\w.+-]+\+)?json\b/i.test(t.headers.get("content-type")??""),lf=()=>new ni("This OpenChamber server has no walkthrough API",{code:"server-unsupported"}),Ny=t=>!af(t)&&(t.ok||t.status===404),Ua=async(t,e)=>{if(Ny(t))throw lf();const n=await t.json().catch(()=>null);throw new ni(typeof n?.error=="string"?n.error:e,{code:typeof n?.code=="string"?n.code:void 0,model:n?.model??void 0,requiredChars:typeof n?.requiredChars=="number"?n.requiredChars:void 0,availableChars:typeof n?.availableChars=="number"?n.availableChars:void 0})},cf=async t=>{if(!af(t))throw lf();try{return await t.json()}catch{throw new ni("The server returned a malformed walkthrough response")}};async function Ay(t,e,n={}){const r=await ls(ri,{query:{directory:t,source:JSON.stringify(e),...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}},signal:n.signal});return r.ok?cf(r):Ua(r,"Failed to load walkthrough")}async function Dy(t,e,n={}){const r=await ls(`${ri}/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e,force:n.force===!0,...n.model?{model:n.model}:{},...n.language?{language:n.language}:{}}),signal:n.signal});return r.ok?cf(r):Ua(r,"Failed to generate walkthrough")}async function Py(t,e){const n=await ls(`${ri}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:t,source:e})});n.ok||await Ua(n,"Failed to cancel walkthrough generation")}async function Iy(t,e,n){const r=await ls(`${ri}/progress`,{query:{directory:t,source:JSON.stringify(e)},signal:n});if(!r.ok)return null;const i=await r.json().catch(()=>null);return typeof i?.stage=="string"?i.stage:null}const Dr={status:"idle",stage:null,result:null,readiness:null,error:null},Ty=t=>t.kind==="working-tree"?`working-tree:${t.scope}`:t.kind==="branch"?`branch:${t.baseRef}...${t.headRef}`:t.kind==="commit"?`commit:${t.hash}`:t.sourceRepo?`pr:${t.sourceRepo.owner}/${t.sourceRepo.repo}:${t.number}`:`pr:${t.number}`,Rn=(t,e)=>`${qt()}\0${t}\0${Ty(e)}`,oc=t=>t instanceof ni?{message:t.message,code:t.code,model:t.model,requiredChars:t.requiredChars,availableChars:t.availableChars}:{message:t instanceof Error?t.message:"Something went wrong"},Zs=new Map,Pr=new Map,Ey=1e3,Ry=to()(Qx((t,e)=>({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{},selectLanguage:(n,r,i)=>{const o=Rn(n,r);t(l=>{const a={...l.selectedLanguage};return i?a[o]=i:delete a[o],{selectedLanguage:a}})},getSelectedLanguage:(n,r)=>e().selectedLanguage[Rn(n,r)],selectModel:(n,r,i)=>{const o=Rn(n,r);t(l=>{const a={...l.selectedModel};return i?a[o]=i:delete a[o],{selectedModel:a}})},getSelectedModel:(n,r)=>e().selectedModel[Rn(n,r)],requestSource:(n,r)=>{t(i=>({requestedSource:{...i.requestedSource,[n]:r}}))},clearRequestedSource:n=>{t(r=>{if(!r.requestedSource[n])return r;const i={...r.requestedSource};return delete i[n],{requestedSource:i}})},getEntry:(n,r)=>e().entries[Rn(n,r)]??Dr,load:async(n,r,i={})=>{if(!n)return;const o=Rn(n,r);if(e().entries[o]?.status==="generating")return;Zs.get(o)?.abort();const a=new AbortController;Zs.set(o,a),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Dr,status:"loading",error:null}}}));try{const d=await Ay(n,r,{model:e().selectedModel[o],language:i.language,signal:a.signal});if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:d.readiness??null,error:null}}})),d.generating&&e().generate(n,r,{language:i.language})}catch(d){if(a.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Dr,status:"error",stage:null,error:oc(d)}}}))}finally{Zs.get(o)===a&&Zs.delete(o)}},generate:async(n,r,i={})=>{if(!n)return;const o=Rn(n,r);Zs.get(o)?.abort();const l=new AbortController;Zs.set(o,l),t(d=>({entries:{...d.entries,[o]:{...d.entries[o]??Dr,status:"generating",stage:"collecting",error:null}}}));const a=()=>{const d=Pr.get(o);d!==void 0&&(clearInterval(d),Pr.delete(o))};a(),Pr.set(o,setInterval(()=>{Iy(n,r).then(d=>{!d||l.signal.aborted||t(u=>{const h=u.entries[o];return!h||h.status!=="generating"||h.stage===d?u:{entries:{...u.entries,[o]:{...h,stage:d}}}})}).catch(()=>{})},Ey));try{const d=await Dy(n,r,{force:i.force,model:e().selectedModel[o],language:i.language,signal:l.signal});if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{status:"ready",stage:null,result:d,readiness:u.entries[o]?.readiness??null,error:null}}}))}catch(d){if(l.signal.aborted)return;t(u=>({entries:{...u.entries,[o]:{...u.entries[o]??Dr,status:"error",stage:null,error:oc(d)}}}))}finally{a(),Zs.get(o)===l&&Zs.delete(o)}},cancel:(n,r)=>{const i=Rn(n,r);Py(n,r).catch(()=>{}),Zs.get(i)?.abort(),Zs.delete(i),t(o=>{const l=o.entries[i];return l?{entries:{...o.entries,[i]:{...l,status:l.result?"ready":"idle",stage:null,error:null}}}:o})},reset:()=>{for(const n of Zs.values())n.abort();Zs.clear();for(const n of Pr.values())clearInterval(n);Pr.clear(),t({entries:{},requestedSource:{},selectedModel:{},selectedLanguage:{}})}}),{name:"walkthrough-store"})),My="border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)] hover:text-[var(--status-info)]",Oy=3e4,ic=20,df=(t,e)=>JSON.stringify([qt(),t,e]),By=t=>{try{const e=JSON.parse(t);if(!Array.isArray(e)||e.length!==3)return null;const[n,r,i]=e;return typeof n!="string"||typeof r!="string"||typeof i!="number"?null:{runtimeKey:n,directory:r,number:i}}catch{return null}},ac=()=>({result:null,hasCheckDetails:!1,fetchedAt:0,isLoading:!1,error:null}),ro=new Map,Fy=t=>{const e=Object.entries(t);return e.length<=ic?t:Object.fromEntries(e.sort(([,n],[,r])=>r.fetchedAt-n.fetchedAt).slice(0,ic))},lc=to()((t,e)=>({entries:{},ensure:async(n,r,i,o)=>{const l=df(r,i),a=o?.includeCheckDetails??!1,d=e().entries[l],u=d&&d.result&&Date.now()-d.fetchedAt<Oy&&(d.hasCheckDetails||!a);if(!o?.force&&u)return d.result;const h=`${l}::${a?"details":"plain"}`,x=ro.get(`${l}::details`)??(a?null:ro.get(h));if(x&&!o?.force)return x;const b=(async()=>{t(w=>({entries:{...w.entries,[l]:{...w.entries[l]??ac(),isLoading:!0,error:null}}}));try{const w=await n.prContext(r,i,{includeDiff:!1,includeCheckDetails:a,sourceRepo:o?.sourceRepo??null});return t(v=>({entries:Fy({...v.entries,[l]:{result:w,hasCheckDetails:a,fetchedAt:Date.now(),isLoading:!1,error:null}})})),w}catch(w){const v=w instanceof Error?w.message:"Failed to load pull request context";return t(y=>({entries:{...y.entries,[l]:{...y.entries[l]??ac(),isLoading:!1,error:v}}})),null}finally{ro.delete(h)}})();return ro.set(h,b),b},invalidate:(n,r)=>{t(i=>{const o={};for(const[l,a]of Object.entries(i.entries)){const d=By(l);d&&d.directory===n&&(r==null||d.number===r)||(o[l]=a)}return{entries:o}})}})),_y=t=>{const e={success:0,failure:0,pending:0,inProgress:0,queued:0};let n;for(const o of t){if(o.status==="in_progress"){e.pending+=1,e.inProgress+=1,o.startedAt&&(!n||o.startedAt<n)&&(n=o.startedAt);continue}if(o.status==="queued"){e.pending+=1,e.queued+=1;continue}const l=typeof o.conclusion=="string"?o.conclusion.toLowerCase():"";if(!l){e.pending+=1;continue}l==="success"||l==="neutral"||l==="skipped"?e.success+=1:e.failure+=1}const r=e.success+e.failure+e.pending;return{state:e.failure>0?"failure":e.pending>0?"pending":r>0?"success":"unknown",total:r,...e,...n?{startedAt:n}:{}}},Ly=35e3,hi=(t,e,n)=>{if(!t)return null;const r=Date.parse(t);if(!Number.isFinite(r))return null;const i=e?Date.parse(e):n??Date.now();if(!Number.isFinite(i)||i<=r)return null;const o=Math.floor((i-r)/6e4);if(o<1)return"<1m";if(o<60)return`${o}m`;const l=Math.floor(o/60),a=o%60;return a>0?`${l}h ${a}m`:`${l}h`},pi=t=>{const e=typeof t=="string"?t.toLowerCase():"";return!!e&&!["success","neutral","skipped"].includes(e)},cc=t=>{switch(t){case"success":return"bg-[color:var(--status-success)]";case"failure":return"bg-[color:var(--status-error)]";case"pending":return"bg-[color:var(--status-warning)]";default:return"bg-muted-foreground/40"}},$y=t=>{const e=t?.pr;if(!e)return null;if(e.state==="merged")return"merged";if(e.state==="closed")return"closed";if(e.draft)return"draft";const n=t?.checks?.state==="failure",r=typeof e.mergeableState=="string"?e.mergeableState:"",i=e.mergeable===!1||r==="blocked"||r==="dirty";return n||i?"blocked":"open"},zy=[2e3,5e3],Wy=600,dc=t=>t.replace(/^refs\/heads\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()),On=t=>{let e=t.trim();return e?(e.startsWith("refs/heads/")&&(e=e.slice(11)),e.startsWith("heads/")&&(e=e.slice(6)),e.startsWith("remotes/")&&(e=e.slice(8)),e):""},Ky=(t,e)=>{const n=On(t);if(!n||n.includes("->"))return"";if(e){const i=`${e}/`;return n.startsWith(i)?n.slice(i.length).trim():""}const r=n.indexOf("/");return r>0?n.slice(r+1).trim():n},Vy=(t,e)=>`${t}::${e}`,Ha=t=>{const e=String(t||"").trim();if(!e)return"";const n=e.indexOf("/");return n<=0?"":e.slice(0,n).trim()},gi=(t,e)=>{if(t.length===0)return null;const n=String(e.selectedRemoteName||"").trim();if(n){const o=t.find(l=>l.name===n);if(o)return o}const r=Ha(e.trackingBranch);if(r){const o=r==="origin"?t.find(a=>a.name==="upstream"):null;if(o)return o;const l=t.find(a=>a.name===r);if(l)return l}const i=t.find(o=>o.name==="origin");return i||(t[0]??null)},Uy=t=>t.startsWith("pr-"),Hy=(t,e)=>{const n=Ha(e),r=new Map(t.map(l=>[l.name,l])),i=[],o=l=>{l&&(i.some(a=>a.name===l.name)||i.push(l))};return n&&o(r.get(n)),o(r.get("upstream")),o(r.get("origin")),t.filter(l=>!Uy(l.name)).forEach(l=>o(l)),t.forEach(l=>o(l)),i},Ir=new Map,oo=Uo;function Gy(t,e){const[n,r]=c.useState(null),[i,o]=c.useState([]),l=c.useRef(null);return c.useEffect(()=>{r(null),o([])},[t]),c.useEffect(()=>{if(!t||!e?.repoUpstream||l.current===t)return;l.current=t;let a=!1;return(async()=>{try{const d=await e.repoUpstream(t);if(a||!d?.isFork||!d.upstream||(r(d.upstream),!e.repoBranches))return;try{const u=await e.repoBranches(d.upstream.owner,d.upstream.repo);a||o(u)}catch{}}catch{}})(),()=>{a=!0}},[t,e]),{detectedUpstream:n,upstreamBranches:i}}const qy=({directory:t,branch:e,baseBranch:n,trackingBranch:r,remotes:i=[],remoteBranches:o=[],onGeneratedDescription:l})=>{const{t:a}=jt(),d=Pe(ie=>ie.timeFormatPreference),{github:u}=vn(),h=In(ie=>ie.status),f=In(ie=>ie.hasChecked),x=Pe(ie=>ie.setSettingsDialogOpen),b=Pe(ie=>ie.setSettingsPage),w=tt(ie=>ie.currentSessionId),v=tt(ie=>!!ie.newSessionDraft?.open),{isMobile:y,hasTouchInput:m,screenWidth:p}=zn(),S=Pe(ie=>ie.openContextSurface),g=Ry(ie=>ie.requestSource),C=!y&&p>=768&&!$n(),k=c.useCallback(()=>{b("integrations"),x(!0)},[x,b]),j=c.useMemo(()=>Vy(t,e),[t,e]),D=c.useMemo(()=>Ir.get(j)??null,[j]),I=Hs(ie=>ie.ensureEntry),A=Hs(ie=>ie.setParams),P=Hs(ie=>ie.startWatching),T=Hs(ie=>ie.stopWatching),L=Hs(ie=>ie.refresh),$=Hs(ie=>ie.updateStatus),[K,F]=c.useState(()=>D?.title??dc(e)),[W,N]=c.useState(()=>D?.body??""),[R,E]=c.useState(()=>D?.draft??!1),[X,J]=c.useState(()=>D?.additionalContext??""),[re,fe]=c.useState(()=>{const ie=typeof D?.targetBaseBranch=="string"?On(D.targetBaseBranch):"";return ie||On(n)}),[ne,te]=c.useState("squash"),[ue,Se]=c.useState(!1),[we,ye]=c.useState(!1),[Ae,pe]=c.useState(!1),[O,Q]=c.useState(!1),[le,H]=c.useState(!1),[me,ge]=c.useState(!1),[oe,de]=c.useState(null),[_,B]=c.useState(""),[he,ve]=c.useState(""),[Re,ce]=c.useState(!1),[se,q]=c.useState(!1),[z,ee]=c.useState(()=>gi(i,{selectedRemoteName:D?.selectedRemoteName,trackingBranch:r})),[ae,Ne]=c.useState(!1),{detectedUpstream:Ce,upstreamBranches:We}=Gy(t,u);c.useEffect(()=>{Ne(!1)},[t]);const Ee=i.some(ie=>ie.name==="upstream"),$e=!!(t&&e&&n&&(e!==n||(Ee||Ce!==null))),V=c.useMemo(()=>Ho(t,e,z?.name??null),[t,e,z?.name]),De=Hs(ie=>ie.entries[V]),Fe=De?.isLoading??!1,_e=De?.status??null,rt=De?.error??null,ct=De?.isInitialStatusResolved??!1,et=c.useMemo(()=>{const ie=ae?null:z?.name?.trim()||null,Qe=new Set;for(const gt of o){const U=Ky(gt,ie);!U||U==="HEAD"||Qe.add(U)}if(ae)for(const gt of We)gt&>!=="HEAD"&&Qe.add(gt);const lt=On(n);lt&<!=="HEAD"&&Qe.add(lt);const st=On(re);return st&&st!=="HEAD"&&Qe.add(st),Array.from(Qe).sort((gt,U)=>gt.localeCompare(U))},[n,o,z?.name,re,We,ae]);c.useEffect(()=>{if(i.length===0){z&&ee(null);return}(!z||!i.some(ie=>ie.name===z.name))&&ee(gi(i,{selectedRemoteName:D?.selectedRemoteName,trackingBranch:r}))},[D?.selectedRemoteName,i,z,r]),c.useEffect(()=>{const ie=On(n);if(!re&&ie){fe(ie);return}if(et.length!==0&&!et.includes(re)){const Qe=et.includes(ie)?ie:et[0];Qe&&fe(Qe)}},[et,n,re]);const[pt,kt]=c.useState(()=>D?.activeSegment??"overview"),[wt,Xe]=c.useState(new Set),[yt,Rt]=c.useState(new Set),be=c.useRef(new Set),Ge=c.useRef(null),ut=c.useRef(!1),Y=c.useRef(new Set),G=c.useRef([]);c.useEffect(()=>{Ce&&!Ee&&Ne(!0)},[Ce,Ee]),c.useEffect(()=>{ae&&Ce?.defaultBranch&&fe(Ce.defaultBranch)},[ae,Ce?.defaultBranch]);const Z=_e?.pr??null,je=Z?.state==="merged"||Z?.state==="closed",Ie=je?null:Z,Ve=Ie?df(t,Ie.number):null,Je=lc(ie=>Ve?ie.entries[Ve]:void 0),it=lc(ie=>ie.ensure),at=Je?.result??null,Ye=Je?.isLoading??!1,vt=c.useCallback(ie=>{kt(ie);const Qe=Ir.get(j);Qe&&Ir.set(j,{...Qe,activeSegment:ie})},[j]);c.useEffect(()=>{!Ie||!u?.prContext||pt==="overview"||it(u,t,Ie.number,{includeCheckDetails:pt==="checks",sourceRepo:_e?.repo??null})},[pt,t,it,u,Ie,_e?.repo]);const Ue=_e?.checks??null,Pt=(Ue?.pending??0)>0,ke=at?.checkRuns??null,xt=at?.fetchedAt;c.useEffect(()=>{if(!ke||ke.length===0)return;const ie=_y(ke);$(V,Qe=>{if(!Qe?.pr||typeof xt=="number"&&typeof Qe.fetchedAt=="number"&&xt<Qe.fetchedAt)return Qe;const lt=Qe.checks;return lt&<.state===ie.state&<.total===ie.total&<.success===ie.success&<.failure===ie.failure&<.pending===ie.pending&<.inProgress===ie.inProgress&<.queued===ie.queued&<.startedAt===ie.startedAt?Qe:{...Qe,checks:ie,...typeof xt=="number"?{fetchedAt:xt}:{}}})},[ke,xt,V,$]),c.useEffect(()=>{if(pt!=="checks"||!Pt||!Z||!u?.prContext)return;const ie=window.setInterval(()=>{it(u,t,Z.number,{includeCheckDetails:!0,sourceRepo:_e?.repo??null,force:!0})},Ly);return()=>window.clearInterval(ie)},[pt,Pt,t,it,u,Z,_e?.repo]);const[Ct,Tt]=c.useState(()=>Date.now());c.useEffect(()=>{if(!Pt)return;Tt(Date.now());const ie=window.setInterval(()=>Tt(Date.now()),3e4);return()=>window.clearInterval(ie)},[Pt]);const qe=Z?`${t}#${Z.number}`:null,ze=!!(qe&&oe===qe);c.useEffect(()=>{if(!u?.prContext||!Z||typeof Z.body=="string"&&Z.body.length>0)return;const ie=`${t}#${Z.number}`;if(be.current.has(ie))return;be.current.add(ie),de(ie);let Qe=!1;return it(u,t,Z.number,{sourceRepo:_e?.repo??null}).then(lt=>{if(Qe)return;const st=lt?.pr;st&&$(V,gt=>!gt?.pr||gt.pr.number!==Z.number?gt:{...gt,pr:{...gt.pr,body:st.body||""}})}).catch(()=>{}).finally(()=>{Qe||de(lt=>lt===ie?null:lt)}),()=>{Qe=!0}},[t,it,u,Z,V,_e?.repo,$]),c.useEffect(()=>{if(!Z){ge(!1),B(""),ve(""),Ge.current=null;return}const ie=Ge.current!==null&&Ge.current!==Z.number;ie&&ge(!1),(!me||ie)&&(B(Z.title||""),ve(Z.body||"")),Ge.current=Z.number},[me,Z]);const ft=c.useCallback(ie=>{if(!ie)return"";const Qe=Date.parse(ie);return Number.isFinite(Qe)?fu(Qe,d,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):ie},[d]),Be=c.useMemo(()=>{const ie=h?.user?.login;return typeof ie=="string"?ie.trim():""},[h]),Ke=c.useMemo(()=>"[&_a[href*='oc-self-mention=1']]:!text-[var(--primary-base)] [&_a[href*='oc-self-mention=1']]:font-semibold [&_a[href*='oc-self-mention=1']]:!no-underline [&_a[href*='oc-self-mention=1']:hover]:!text-[var(--primary-hover)]",[]),He=c.useCallback(ie=>{const Qe=Be.toLowerCase(),lt=/(^|[^\w`])@([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,38}))/g;return ie.replace(lt,(st,gt,U)=>{const Te=`@${U}`,ot=U.toLowerCase();return`${gt}[${Te}](https://github.com/${ot}${Qe&&ot===Qe?"?oc-self-mention=1":""})`})},[Be]),nt=c.useMemo(()=>{const ie=(at?.issueComments??[]).map(st=>({id:`issue-${st.id}`,body:st.body||"",authorName:st.author?.name||st.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:st.author?.login||null,avatarUrl:st.author?.avatarUrl||null,createdAt:st.createdAt,context:a("gitView.pr.comments.generalContext"),path:null,line:null})),Qe=(at?.reviewComments??[]).map(st=>({id:`review-${st.id}`,body:st.body||"",authorName:st.author?.name||st.author?.login||a("gitView.pr.comments.unknownAuthor"),authorLogin:st.author?.login||null,avatarUrl:st.author?.avatarUrl||null,createdAt:st.createdAt,context:a("gitView.pr.comments.reviewContext"),path:st.path||null,line:st.line??null})),lt=[...ie,...Qe];return lt.sort((st,gt)=>{const U=st.createdAt?Date.parse(st.createdAt):0,Te=gt.createdAt?Date.parse(gt.createdAt):0,ot=Number.isFinite(U)?U:0,Et=Number.isFinite(Te)?Te:0;return ot-Et}),lt},[at,a]),St=c.useCallback(()=>{const ie=w??(v?"draft":null);return ie?{directory:t,sessionKey:ie}:(Le.error(a("gitView.pr.toast.noActiveSession"),{description:a("gitView.pr.toast.noActiveSessionDescription")}),null)},[w,t,v,a]),Lt=c.useCallback((ie,Qe)=>{const lt=Qe.authorLogin?`@${Qe.authorLogin}`:Qe.authorName,st=Qe.path?` · ${Qe.path}${Qe.line?`:${Qe.line}`:""}`:"";Oi.getState().addDraft(ie,{source:"pr-comment",fileLabel:`PR #${Z?.number??""} ${lt}${st}`,startLine:Qe.line??0,endLine:Qe.line??0,code:Qe.body,language:"markdown",text:""})},[Z?.number]),Ut=c.useCallback((ie,Qe)=>{const lt=ie.status||"unknown",st=ie.conclusion??void 0,gt=st?`${lt} / ${st}`:lt,U=ie.app?.name||ie.app?.slug;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:Qe?.hideHeader?"flex items-start justify-end gap-3":"flex items-start justify-between gap-3",children:[Qe?.hideHeader?null:s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:ie.name}),s.jsx("div",{className:"typography-micro text-muted-foreground truncate",children:U?`${U} · ${gt}`:gt})]}),ie.detailsUrl?s.jsx(dt,{variant:"outline",size:"sm",asChild:!0,className:"flex-shrink-0",children:s.jsxs("a",{href:ie.detailsUrl,target:"_blank",rel:"noopener noreferrer",children:[s.jsx(M,{name:"external-link",className:"size-4"}),"Open"]})}):null]}),ie.output?.title?s.jsx("div",{className:"typography-micro text-foreground",children:ie.output.title}):null,ie.output?.summary?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words",children:ie.output.summary}):null,ie.output?.text?s.jsx("div",{className:"rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:ie.output.text}):null,Array.isArray(ie.annotations)&&ie.annotations.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"typography-micro text-muted-foreground",children:["Failed annotations",ie.annotations.length>20?` (showing 20/${ie.annotations.length})`:""]}),s.jsx("div",{className:"space-y-1",children:ie.annotations.slice(0,20).map((Te,ot)=>s.jsxs("div",{className:"rounded border border-[var(--status-error-border)] bg-[var(--status-error-background)]/40 px-2 py-2",children:[s.jsxs("div",{className:"typography-micro break-words text-[var(--status-error)]",children:[Te.title||Te.level||"Issue",Te.path?` · ${Te.path}`:"",typeof Te.startLine=="number"?`:${Te.startLine}`:"",typeof Te.endLine=="number"&&Te.endLine!==Te.startLine?`-${Te.endLine}`:""]}),s.jsx("div",{className:"typography-micro text-foreground whitespace-pre-wrap break-words mt-1",children:Te.message}),Te.rawDetails?s.jsx("div",{className:"typography-micro text-muted-foreground whitespace-pre-wrap break-words mt-1",children:Te.rawDetails}):null]},`${Te.path||"file"}:${Te.startLine||ot}:${ot}`))})]}):null,ie.job?.steps&&ie.job.steps.length>0?s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:a("gitView.pr.checks.steps")}),s.jsx("div",{className:"space-y-1",children:ie.job.steps.map((Te,ot)=>{const Et=(Te.conclusion||"").toLowerCase(),Mt=Et&&!["success","neutral","skipped"].includes(Et),$t=`${ie.id??"run"}:${ie.job?.jobId??"job"}:${Te.number??ot}:${Te.name}`,Wt=wt.has($t);return Mt?s.jsxs(Bi,{open:Wt,children:[s.jsxs("button",{type:"button",onClick:()=>{Xe(Ss=>{const is=new Set(Ss);return is.has($t)?is.delete($t):is.add($t),is})},className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-left "+(Mt?"bg-destructive/10 text-destructive":"text-muted-foreground"),children:[Wt?s.jsx(M,{name:"arrow-down-s",className:"size-4"}):s.jsx(M,{name:"arrow-right-s",className:"size-4"}),s.jsx("span",{className:"truncate",children:Te.name}),Te.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Te.conclusion}):null]}),s.jsx(Fi,{children:s.jsxs("div",{className:"ml-6 mt-1 rounded border border-border/40 bg-transparent px-2 py-2 typography-micro text-muted-foreground space-y-1",children:[typeof Te.number=="number"?s.jsxs("div",{children:[a("gitView.pr.checks.stepLabel"),": ",Te.number]}):null,Te.status?s.jsxs("div",{children:[a("gitView.pr.checks.statusLabel"),": ",Te.status]}):null,Te.conclusion?s.jsxs("div",{children:[a("gitView.pr.checks.conclusionLabel"),": ",Te.conclusion]}):null,Te.startedAt?s.jsxs("div",{children:[a("gitView.pr.checks.startedLabel"),": ",ft(Te.startedAt)]}):null,Te.completedAt?s.jsxs("div",{children:[a("gitView.pr.checks.completedLabel"),": ",ft(Te.completedAt)]}):null]})})]},$t):s.jsxs("div",{className:"typography-micro flex w-full items-center gap-2 rounded px-2 py-1 text-muted-foreground",children:[s.jsx("span",{className:"truncate",children:Te.name}),Te.conclusion?s.jsx("span",{className:"ml-auto flex-shrink-0",children:Te.conclusion}):null]},$t)})})]}):null]})},[wt,ft,a]),[Bt,zt]=c.useState(!1),[_t,Yt]=c.useState(!1),Zt=c.useCallback(async()=>{if(!u?.prContext){Le.error(a("gitView.pr.toast.githubApiUnavailable"));return}if(!t||!Z)return;const ie=St();if(ie){zt(!0);try{const Qe=await it(u,t,Z.number,{includeCheckDetails:!0,sourceRepo:_e?.repo??null});if(!Qe){Le.error(a("gitView.pr.toast.loadChecksFailed"));return}const st=(Qe.checkRuns??[]).filter(U=>pi(U.conclusion));if(st.length===0){Le.message(a("gitView.pr.toast.noFailedChecks"));return}const gt=Oi.getState();for(const U of st){const Te=(U.annotations??[]).map(Mt=>[[Mt.level,Mt.title].filter(Boolean).join(" "),Mt.path?`${Mt.path}${typeof Mt.startLine=="number"?`:${Mt.startLine}`:""}`:null,Mt.message,Mt.rawDetails].filter(Boolean).join(`
|
|
3
3
|
`)),ot=(U.job?.steps??[]).filter(Mt=>pi(Mt.conclusion)).map(Mt=>`step ${Mt.number??"?"}: ${Mt.name} → ${Mt.conclusion}`),Et=[`check: ${U.job?.workflowName?`${U.job.workflowName} / ${U.name}`:U.name}`,`status: ${U.status??"unknown"} / ${U.conclusion??"unknown"}`,U.detailsUrl?`url: ${U.detailsUrl}`:null,U.output?.title?`title: ${U.output.title}`:null,U.output?.summary?`summary:
|
|
4
4
|
${U.output.summary}`:null,ot.length>0?`failed steps:
|
|
5
5
|
${ot.join(`
|
|
@@ -875,7 +875,7 @@ ${t}
|
|
|
875
875
|
styles: styles
|
|
876
876
|
};
|
|
877
877
|
`),Jw=t=>{const e=Ze.c(18),{entries:n,activeIndex:r,onSelect:i,onForget:o,onHighlight:l}=t,{t:a}=jt();if(n.length===0)return null;let d;e[0]!==a?(d=a("contextPanel.browser.history.label"),e[0]=a,e[1]=d):d=e[1];let u;if(e[2]!==r||e[3]!==n||e[4]!==o||e[5]!==l||e[6]!==i||e[7]!==a){let f;e[9]!==r||e[10]!==o||e[11]!==l||e[12]!==i||e[13]!==a?(f=(x,b)=>s.jsxs("div",{role:"option","aria-selected":b===r,className:Oe("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",b===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:w=>{w.preventDefault(),i(x.url)},onPointerEnter:()=>l(b),children:[s.jsx(M,{name:"global",className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate typography-micro text-foreground",children:x.title||Qa(x.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:x.url})]}),s.jsx("button",{type:"button",className:Oe("shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity","hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"),"aria-label":a("contextPanel.browser.history.forget"),title:a("contextPanel.browser.history.forget"),onPointerDown:w=>{w.preventDefault(),w.stopPropagation(),o(x.url)},children:s.jsx(M,{name:"close",className:"size-3","aria-hidden":"true"})})]},x.url),e[9]=r,e[10]=o,e[11]=l,e[12]=i,e[13]=a,e[14]=f):f=e[14],u=n.map(f),e[2]=r,e[3]=n,e[4]=o,e[5]=l,e[6]=i,e[7]=a,e[8]=u}else u=e[8];let h;return e[15]!==d||e[16]!==u?(h=s.jsx("div",{className:"oc-glass-popover oc-glass-floating absolute inset-x-0 top-full z-50 mt-1 overflow-hidden rounded-xl p-1",role:"listbox","aria-label":d,children:u}),e[15]=d,e[16]=u,e[17]=h):h=e[17],h},tn=t=>{const e=Ze.c(17),{icon:n,label:r,onClick:i,disabled:o,pressed:l}=t,a=l?"secondary":"ghost",d=l&&"text-foreground";let u;e[0]!==d?(u=Oe("w-6 shrink-0 rounded-full px-0 text-muted-foreground","hover:text-foreground",d),e[0]=d,e[1]=u):u=e[1];let h;e[2]!==n?(h=s.jsx(M,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=h):h=e[3];let f;e[4]!==o||e[5]!==r||e[6]!==i||e[7]!==l||e[8]!==a||e[9]!==u||e[10]!==h?(f=s.jsx(At,{asChild:!0,children:s.jsx(dt,{type:"button",variant:a,size:"xs",className:u,onClick:i,disabled:o,"aria-label":r,"aria-pressed":l,children:h})}),e[4]=o,e[5]=r,e[6]=i,e[7]=l,e[8]=a,e[9]=u,e[10]=h,e[11]=f):f=e[11];let x;e[12]!==r?(x=s.jsx(Dt,{sideOffset:6,children:r}),e[12]=r,e[13]=x):x=e[13];let b;return e[14]!==f||e[15]!==x?(b=s.jsxs(Nt,{children:[f,x]}),e[14]=f,e[15]=x,e[16]=b):b=e[16],b},Af=t=>{const e=Ze.c(104),{address:n,suggestions:r,onForgetSuggestion:i,onAddressChange:o,onSubmit:l,onBack:a,onForward:d,onReload:u,onOpenExternal:h,canGoBack:f,canGoForward:x,isLoading:b,onAnnotate:w,onOpenDevTools:v,isAnnotating:y,onHardReload:m,onZoomIn:p,onZoomOut:S,onZoomReset:g,zoomPercent:C,onClearCookies:k,onClearCache:j,onToggleDeviceBar:D,isDeviceBarOpen:I}=t;let A;e[0]!==r?(A=r===void 0?[]:r,e[0]=r,e[1]=A):A=e[1];const P=A,T=C===void 0?100:C,{t:L}=jt(),[$,K]=c.useState(!1),[F,W]=c.useState(-1);let N;e[2]!==$||e[3]!==P?(N=$?P:[],e[2]=$,e[3]=P,e[4]=N):N=e[4];const R=N;let E;e[5]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{W(-1)},e[5]=E):E=e[5];let X;e[6]!==n||e[7]!==$?(X=[n,$],e[6]=n,e[7]=$,e[8]=X):X=e[8],c.useEffect(E,X);let J;e[9]!==l?(J=Ee=>{K(!1),W(-1),l(Ee)},e[9]=l,e[10]=J):J=e[10];const re=J;let fe;e[11]!==F||e[12]!==re||e[13]!==R?(fe=Ee=>{if(R.length!==0){if(Ee.key==="ArrowDown"||Ee.key==="ArrowUp"){Ee.preventDefault();const xe=Ee.key==="ArrowDown"?1:-1,$e=R.length;W(V=>{const De=V+xe;return De<-1?$e-1:De>=$e?-1:De});return}if(Ee.key==="Escape"&&F>=0){Ee.preventDefault(),W(-1);return}if(Ee.key==="Enter"&&F>=0){Ee.preventDefault();const xe=R[F];xe&&re(xe.url)}}},e[11]=F,e[12]=re,e[13]=R,e[14]=fe):fe=e[14];const ne=fe;let te;e[15]!==L?(te=L("contextPanel.browser.back"),e[15]=L,e[16]=te):te=e[16];const ue=!f;let Se;e[17]!==a||e[18]!==ue||e[19]!==te?(Se=s.jsx(tn,{icon:"arrow-left",label:te,onClick:a,disabled:ue}),e[17]=a,e[18]=ue,e[19]=te,e[20]=Se):Se=e[20];let we;e[21]!==L?(we=L("contextPanel.browser.forward"),e[21]=L,e[22]=we):we=e[22];const ye=!x;let Ae;e[23]!==d||e[24]!==we||e[25]!==ye?(Ae=s.jsx(tn,{icon:"arrow-right",label:we,onClick:d,disabled:ye}),e[23]=d,e[24]=we,e[25]=ye,e[26]=Ae):Ae=e[26];let pe;e[27]!==b||e[28]!==L?(pe=L(b?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=b,e[28]=L,e[29]=pe):pe=e[29];let O;e[30]!==u||e[31]!==pe?(O=s.jsx(tn,{icon:"refresh",label:pe,onClick:u}),e[30]=u,e[31]=pe,e[32]=O):O=e[32];let Q;e[33]!==m||e[34]!==L?(Q=m?s.jsx(tn,{icon:"restart",label:L("contextPanel.browser.hardReload"),onClick:m}):null,e[33]=m,e[34]=L,e[35]=Q):Q=e[35];let le;e[36]!==n||e[37]!==re?(le=Ee=>{Ee.preventDefault(),re(n)},e[36]=n,e[37]=re,e[38]=le):le=e[38];let H;e[39]!==o?(H=Ee=>o(Ee.target.value),e[39]=o,e[40]=H):H=e[40];let me,ge;e[41]===Symbol.for("react.memo_cache_sentinel")?(me=()=>K(!0),ge=()=>K(!1),e[41]=me,e[42]=ge):(me=e[41],ge=e[42]);const oe=R.length>0;let de;e[43]===Symbol.for("react.memo_cache_sentinel")?(de=Oe("h-6 w-full rounded-full border border-border/50 bg-[var(--surface-elevated)] px-3","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[43]=de):de=e[43];let _;e[44]!==L?(_=L("contextPanel.browser.addressAria"),e[44]=L,e[45]=_):_=e[45];let B;e[46]!==n||e[47]!==ne||e[48]!==H||e[49]!==oe||e[50]!==_?(B=s.jsx("input",{value:n,onChange:H,onFocus:me,onBlur:ge,onKeyDown:ne,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":oe,"aria-controls":"openchamber-browser-address-suggestions",className:de,"aria-label":_}),e[46]=n,e[47]=ne,e[48]=H,e[49]=oe,e[50]=_,e[51]=B):B=e[51];let he;e[52]!==i?(he=Ee=>i?.(Ee),e[52]=i,e[53]=he):he=e[53];let ve;e[54]!==F||e[55]!==re||e[56]!==he||e[57]!==R?(ve=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(Jw,{entries:R,activeIndex:F,onSelect:re,onForget:he,onHighlight:W})}),e[54]=F,e[55]=re,e[56]=he,e[57]=R,e[58]=ve):ve=e[58];let Re;e[59]!==le||e[60]!==B||e[61]!==ve?(Re=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:le,children:[B,ve]}),e[59]=le,e[60]=B,e[61]=ve,e[62]=Re):Re=e[62];let ce;e[63]!==p||e[64]!==S||e[65]!==g||e[66]!==L||e[67]!==T?(ce=S&&p?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(tn,{icon:"subtract",label:L("contextPanel.browser.zoomOut"),onClick:S}),T!==100&&g?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsxs(dt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:g,"aria-label":L("contextPanel.browser.zoomReset"),children:[T,"%"]})}),s.jsx(Dt,{sideOffset:6,children:L("contextPanel.browser.zoomReset")})]}):null,s.jsx(tn,{icon:"add",label:L("contextPanel.browser.zoomIn"),onClick:p})]}):null,e[63]=p,e[64]=S,e[65]=g,e[66]=L,e[67]=T,e[68]=ce):ce=e[68];let se;e[69]!==k||e[70]!==L?(se=k?s.jsx(tn,{icon:"delete-bin",label:L("contextPanel.browser.clearCookies"),onClick:k}):null,e[69]=k,e[70]=L,e[71]=se):se=e[71];let q;e[72]!==j||e[73]!==L?(q=j?s.jsx(tn,{icon:"database-2",label:L("contextPanel.browser.clearCache"),onClick:j}):null,e[72]=j,e[73]=L,e[74]=q):q=e[74];let z;e[75]!==I||e[76]!==D||e[77]!==L?(z=D?s.jsx(tn,{icon:"smartphone",label:L("contextPanel.browser.deviceToolbar"),onClick:D,pressed:I}):null,e[75]=I,e[76]=D,e[77]=L,e[78]=z):z=e[78];let ee;e[79]!==y||e[80]!==w||e[81]!==L?(ee=w?s.jsx(tn,{icon:"markup",label:L("contextPanel.browser.annotate.toggle"),onClick:w,pressed:y}):null,e[79]=y,e[80]=w,e[81]=L,e[82]=ee):ee=e[82];let ae;e[83]!==v||e[84]!==L?(ae=v?s.jsx(tn,{icon:"terminal-box",label:L("contextPanel.browser.devTools"),onClick:v}):null,e[83]=v,e[84]=L,e[85]=ae):ae=e[85];let Ne;e[86]!==L?(Ne=L("contextPanel.browser.openExternal"),e[86]=L,e[87]=Ne):Ne=e[87];let Ce;e[88]!==h||e[89]!==Ne?(Ce=s.jsx(tn,{icon:"external-link",label:Ne,onClick:h}),e[88]=h,e[89]=Ne,e[90]=Ce):Ce=e[90];let We;return e[91]!==Se||e[92]!==Ae||e[93]!==O||e[94]!==Q||e[95]!==Re||e[96]!==ce||e[97]!==se||e[98]!==q||e[99]!==z||e[100]!==ee||e[101]!==ae||e[102]!==Ce?(We=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[Se,Ae,O,Q,Re,ce,se,q,z,ee,ae,Ce]}),e[91]=Se,e[92]=Ae,e[93]=O,e[94]=Q,e[95]=Re,e[96]=ce,e[97]=se,e[98]=q,e[99]=z,e[100]=ee,e[101]=ae,e[102]=Ce,e[103]=We):We=e[103],We},Oo={kind:"fill"},kc=240,Zw=3840,Df=[{id:"iphone-se",label:"iPhone SE",width:375,height:667},{id:"iphone-14",label:"iPhone 14",width:390,height:844},{id:"iphone-14-pro-max",label:"iPhone 14 Pro Max",width:430,height:932},{id:"pixel-7",label:"Pixel 7",width:412,height:915},{id:"ipad-mini",label:"iPad mini",width:768,height:1024},{id:"ipad-pro",label:"iPad Pro",width:1024,height:1366},{id:"laptop",label:"Laptop",width:1280,height:800},{id:"desktop",label:"Desktop",width:1440,height:900}],Cc=t=>Number.isFinite(t)?Math.round(Math.min(Zw,Math.max(kc,t))):kc,Bo=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Pf=t=>{const e=Df.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},ev=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},tv=(t,e)=>{const n=Bo(t);if(!n)return null;const r=Math.max(1,e.width),i=Math.max(1,e.height),o=Math.min(1,r/n.width,i/n.height);return{width:n.width,height:n.height,scale:o}},sv=["mobile","tablet","desktop","fill"],nv={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Nc=t=>typeof t=="string"&&sv.includes(t),ia=t=>t==="fill"?Oo:Pf(nv[t])??Oo,co=t=>{const e=Bo(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=ia(n),i=Bo(r);if(i&&i.width===e.width&&i.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},rv=t=>{const e=Ze.c(70),{viewport:n,onViewportChange:r,colorScheme:i,onColorSchemeChange:o,scale:l}=t,{t:a}=jt();let d;e[0]!==n?(d=Bo(n),e[0]=n,e[1]=d):d=e[1];const u=d,h=n.kind==="preset"?n.id:"";let f;e[2]!==r||e[3]!==u?(f=(ue,Se)=>{const we=Number.parseInt(Se,10);if(!Number.isFinite(we))return;const ye=u??{width:1280,height:800};r({kind:"custom",width:Cc(ue==="width"?we:ye.width),height:Cc(ue==="height"?we:ye.height)})},e[2]=r,e[3]=u,e[4]=f):f=e[4];const x=f;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=Oe("h-6 w-14 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2 text-center","typography-micro tabular-nums text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[5]=b):b=e[5];const w=b;let v;e[6]!==r?(v=ue=>{const Se=Pf(ue.target.value);r(Se??Oo)},e[6]=r,e[7]=v):v=e[7];let y;e[8]!==a?(y=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=y):y=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=Oe("h-6 shrink-0 rounded-full border border-border/50 bg-[var(--surface-elevated)] px-2","typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]"),e[10]=m):m=e[10];let p;e[11]!==a?(p=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=p):p=e[12];let S;e[13]!==p?(S=s.jsx("option",{value:"",children:p}),e[13]=p,e[14]=S):S=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=Df.map(ov),e[15]=g):g=e[15];let C;e[16]!==h||e[17]!==v||e[18]!==y||e[19]!==S?(C=s.jsxs("select",{value:h,onChange:v,"aria-label":y,className:m,children:[S,g]}),e[16]=h,e[17]=v,e[18]=y,e[19]=S,e[20]=C):C=e[20];const k=u?String(u.width):"";let j;e[21]!==x?(j=ue=>x("width",ue.target.value),e[21]=x,e[22]=j):j=e[22];let D;e[23]!==a?(D=a("contextPanel.browser.device.width"),e[23]=a,e[24]=D):D=e[24];let I;e[25]!==k||e[26]!==j||e[27]!==D?(I=s.jsx("input",{value:k,onChange:j,placeholder:"—",inputMode:"numeric","aria-label":D,className:w}),e[25]=k,e[26]=j,e[27]=D,e[28]=I):I=e[28];let A;e[29]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=A):A=e[29];const P=u?String(u.height):"";let T;e[30]!==x?(T=ue=>x("height",ue.target.value),e[30]=x,e[31]=T):T=e[31];let L;e[32]!==a?(L=a("contextPanel.browser.device.height"),e[32]=a,e[33]=L):L=e[33];let $;e[34]!==P||e[35]!==T||e[36]!==L?($=s.jsx("input",{value:P,onChange:T,placeholder:"—",inputMode:"numeric","aria-label":L,className:w}),e[34]=P,e[35]=T,e[36]=L,e[37]=$):$=e[37];let K;e[38]!==r||e[39]!==n?(K=()=>r(ev(n)),e[38]=r,e[39]=n,e[40]=K):K=e[40];const F=!u;let W;e[41]!==a?(W=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=W):W=e[42];let N;e[43]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(M,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=N):N=e[43];let R;e[44]!==K||e[45]!==F||e[46]!==W?(R=s.jsx(At,{asChild:!0,children:s.jsx(dt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:K,disabled:F,"aria-label":W,children:N})}),e[44]=K,e[45]=F,e[46]=W,e[47]=R):R=e[47];let E;e[48]!==a?(E=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=E):E=e[49];let X;e[50]!==E?(X=s.jsx(Dt,{sideOffset:6,children:E}),e[50]=E,e[51]=X):X=e[51];let J;e[52]!==R||e[53]!==X?(J=s.jsxs(Nt,{children:[R,X]}),e[52]=R,e[53]=X,e[54]=J):J=e[54];let re;e[55]!==l||e[56]!==u?(re=u&&l<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(l*100),"%"]}):null,e[55]=l,e[56]=u,e[57]=re):re=e[57];let fe;e[58]===Symbol.for("react.memo_cache_sentinel")?(fe=["system","light","dark"],e[58]=fe):fe=e[58];let ne;e[59]!==i||e[60]!==o||e[61]!==a?(ne=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:fe.map(ue=>s.jsx(dt,{type:"button",variant:i===ue?"secondary":"ghost",size:"xs",className:Oe("shrink-0 rounded-full px-2.5 typography-micro",i===ue?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>o(ue),"aria-pressed":i===ue,children:a(ue==="system"?"contextPanel.browser.device.schemeSystem":ue==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},ue))}),e[59]=i,e[60]=o,e[61]=a,e[62]=ne):ne=e[62];let te;return e[63]!==C||e[64]!==I||e[65]!==$||e[66]!==J||e[67]!==re||e[68]!==ne?(te=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[C,I,A,$,J,re,ne]}),e[63]=C,e[64]=I,e[65]=$,e[66]=J,e[67]=re,e[68]=ne,e[69]=te):te=e[69],te};function ov(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const iv=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},av=2e3,lv=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=Pn();if(!t)return!1;try{return!kr(new URL(t,window.location.href).toString())}catch{return!1}},If=t=>{const e=Ze.c(33),{onOpen:n,directory:r}=t,i=r===void 0?"":r,{t:o}=jt();let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={kind:"loading"},e[0]=l):l=e[0];const[a,d]=c.useState(l),u=Sb(i),[h]=c.useState(lv);let f,x;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let I=!0,A=null;const P=new AbortController,T=()=>{rw(P.signal).then(L=>{I&&(d(L),A=setTimeout(T,av))})};return T(),()=>{I=!1,A&&clearTimeout(A),P.abort()}},x=[],e[1]=f,e[2]=x):(f=e[1],x=e[2]),c.useEffect(f,x);const b=a.kind==="ready"?a.servers:null;let w;e[3]!==u||e[4]!==b?(w=aw({announced:u,discovered:b}),e[3]=u,e[4]=b,e[5]=w):w=e[5];const v=w;let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(yu,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=y):y=e[6];let m;e[7]!==o?(m=o("contextPanel.browser.empty"),e[7]=o,e[8]=m):m=e[8];let p;e[9]!==m?(p=s.jsx("span",{className:"typography-ui-header text-foreground",children:m}),e[9]=m,e[10]=p):p=e[10];let S;e[11]!==o?(S=o("contextPanel.browser.emptyHint"),e[11]=o,e[12]=S):S=e[12];let g;e[13]!==S?(g=s.jsx("span",{className:"typography-micro text-muted-foreground",children:S}),e[13]=S,e[14]=g):g=e[14];let C;e[15]!==g||e[16]!==p?(C=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[p,g]}),e[15]=g,e[16]=p,e[17]=C):C=e[17];let k;e[18]!==u||e[19]!==v||e[20]!==i||e[21]!==n||e[22]!==h||e[23]!==o?(k=v.length>0?s.jsxs("div",{className:"flex min-h-0 w-full max-w-sm flex-col gap-1",children:[s.jsx("span",{className:"shrink-0 typography-micro text-left text-muted-foreground",children:u.length>0?o("contextPanel.browser.devServers.justStarted"):o("contextPanel.browser.devServers.title")}),h?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.remoteOnly")}):null,s.jsx("div",{className:"flex min-h-0 flex-col gap-1 overflow-y-auto pr-0.5",children:v.map(I=>s.jsxs(dt,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{yb(i),n(I.url)},children:[s.jsx(M,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:Qa(I.url)||I.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:iv(I.url)})]},I.port))})]}):null,e[18]=u,e[19]=v,e[20]=i,e[21]=n,e[22]=h,e[23]=o,e[24]=k):k=e[24];let j;e[25]!==v.length||e[26]!==a.kind||e[27]!==o?(j=v.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("contextPanel.browser.devServers.unavailable")}):null,e[25]=v.length,e[26]=a.kind,e[27]=o,e[28]=j):j=e[28];let D;return e[29]!==C||e[30]!==k||e[31]!==j?(D=s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-5 overflow-hidden bg-background p-6 text-center",children:[y,C,k,j]}),e[29]=C,e[30]=k,e[31]=j,e[32]=D):D=e[32],D},Ls=t=>Math.round(t),cv=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),i=t.ancestry.map(a=>a.selectorPart).join(" > "),o=t.computedStyle,l=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,i?`- Ancestry: ${i}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${Ls(l.x)}, y=${Ls(l.y)}, width=${Ls(l.width)}, height=${Ls(l.height)}`,`- Styles: display=${o.display??""}; position=${o.position??""}; font=${o.fontWeight??""} ${o.fontSize??""} / ${o.lineHeight??""} ${o.fontFamily??""}; color=${o.color??""}; background=${o.backgroundColor??""}`].filter(a=>typeof a=="string")},dv=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${Ls(n.x)}, y=${Ls(n.y)}, width=${Ls(n.width)}, height=${Ls(n.height)}`},uv=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${Ls(n.x)}, y=${Ls(n.y)}, width=${Ls(n.width)}, height=${Ls(n.height)}`},fv=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),i=t.comment.trim(),o=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${Ls(t.viewport.width)}x${Ls(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,i?`Comment: ${i}`:null];for(const[l,a]of t.elements.entries())o.push("",...cv(a.element,l));return t.regions.length>0&&(o.push(""),t.regions.forEach((l,a)=>o.push(dv(l,a)))),t.strokes.length>0&&(o.push(""),t.strokes.forEach((l,a)=>o.push(uv(l,a)))),o.filter(l=>typeof l=="string").join(`
|
|
878
|
-
`)},mv=t=>{const e=Ze.c(7),{t:n}=jt(),r=tt(pv),i=tt(gv),o=Oi(xv),l=Mp(bv);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){Le.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(d.screenshot)try{await l(d.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:fv({payload:d.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Le.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},hv=()=>{const t=Ze.c(16),{t:e}=jt();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function pv(t){return t.currentSessionId}function gv(t){return t.newSessionDraft?.open}function xv(t){return t.addDraft}function bv(t){return t.addAttachedFile}const yv=3e4,wv=3,vv=250,Sv={attempts:0,windowStartedAt:null},jv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=yv,r=n?0:t.attempts;return r>=wv?null:{delayMs:vv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},kv=-3,uo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",hr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Cv=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:dw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,h]=c.useState(!1),[f,x]=c.useState(!1),b=c.useRef(n);b.current=n;const w=c.useRef(Sv);return c.useEffect(()=>{if(!t)return;const v=()=>{try{const A=t.getURL();return uo(A)?A:""}catch{return""}},y=()=>{try{h(t.canGoBack()),x(t.canGoForward())}catch{}},m=A=>{uo(A)&&(l(A),b.current(A))},p=()=>{const A=v();i({kind:"loading",url:A})},S=()=>{const A=v();let P="";try{P=t.getTitle()||""}catch{P=""}d(P),m(A),y(),i(T=>T.kind==="failed"&&T.url===A?T:{kind:"ready",url:A,title:P})},g=A=>{const P=hr(A);uo(P.url)&&(m(P.url),y())},C=A=>{const P=hr(A),T=Array.isArray(P.favicons)?P.favicons.find(Boolean):"",L=v();T&&L&&gf.getState().resolve(L,T)},k=A=>{const P=hr(A);typeof P.title=="string"&&d(P.title)},j=A=>{const P=hr(A);if(P.isMainFrame===!1)return;const T=typeof P.errorCode=="number"?P.errorCode:0;T!==kv&&i({kind:"failed",url:uo(P.validatedURL)?P.validatedURL:v(),code:T,description:typeof P.errorDescription=="string"?P.errorDescription:""})};let D=null;const I=()=>{const A=v(),P=jv(w.current,Date.now());if(!P){i({kind:"failed",url:A,code:0,description:"",crashed:!0});return}w.current=P.state,i({kind:"loading",url:A}),D=setTimeout(()=>{D=null;try{t.reload()}catch{i({kind:"failed",url:A,code:0,description:"",crashed:!0})}},P.delayMs)};t.addEventListener("did-start-loading",p),t.addEventListener("did-stop-loading",S),t.addEventListener("did-navigate",g),t.addEventListener("did-navigate-in-page",g),t.addEventListener("page-title-updated",k),t.addEventListener("page-favicon-updated",C),t.addEventListener("did-fail-load",j),t.addEventListener("render-process-gone",I),t.addEventListener("crashed",I);try{!t.isLoading()&&v()&&S()}catch{}return()=>{D!==null&&clearTimeout(D),t.removeEventListener("render-process-gone",I),t.removeEventListener("crashed",I),t.removeEventListener("did-start-loading",p),t.removeEventListener("did-stop-loading",S),t.removeEventListener("did-navigate",g),t.removeEventListener("did-navigate-in-page",g),t.removeEventListener("page-title-updated",k),t.removeEventListener("page-favicon-updated",C),t.removeEventListener("did-fail-load",j)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},Nv=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Av=4e4,fo=.5,Dv=-3,Pv=4,Iv="persist:openchamber-browser",Ac=20,Tv=600,Ev=2e4,Rv=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=jt(),{currentTheme:i}=or(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(ce=>{o.current=ce,a(ce)},[]),u=Pe(ce=>ce.setContextPanelTabTargetPath),h=c.useRef(br(t)),f=h.current!==sn?h.current:"",[x,b]=c.useState(f?null:sn),[w,v]=c.useState(f),[y,m]=c.useState(!1),[p,S]=c.useState(!1),[g,C]=c.useState(0),k=c.useRef(0),[j,D]=c.useState(!1),[I,A]=c.useState(Oo),P=c.useRef(I);P.current=I;const T=c.useRef([]),[L,$]=c.useState("system"),[K,F]=c.useState({width:0,height:0}),W=c.useRef(null),N=c.useRef(null),R=c.useRef(!1),E=c.useRef(Date.now()),X=c.useCallback(ce=>{!ce||ce===sn||!e||!n||u(e,n,ce)},[e,n,u]),J=Cv(l,{initialUrl:f,onUrlChange:c.useCallback(ce=>{const se=Tr(ce);v(se),X(se)},[X])}),[re,fe]=c.useState(null),ne=mv(e),te=hv(),ue=J.status.kind==="loading",Se=wr(jf(e)),we=wr(ce=>ce.recordVisit),ye=wr(ce=>ce.forget);c.useEffect(()=>{J.status.kind==="ready"&&we(e,{url:Tr(J.status.url),title:J.status.title})},[e,J.status,we]);const Ae=c.useMemo(()=>Sf(Se,w),[Se,w]),pe=c.useCallback(ce=>{const se=br(ce);se!==sn&&(v(se),fe(null),vc(se).then(q=>{const z=o.current;if(!z){b(q);return}try{z.loadURL(q)}catch{b(q)}}).catch(q=>{q instanceof Kr&&fe(se)}))},[]);c.useEffect(()=>{if(!f)return;let ce=!0;return vc(f).then(se=>{ce&&b(se)}).catch(se=>{if(ce){if(se instanceof Kr){fe(f),b(sn);return}b(f)}}),()=>{ce=!1}},[]);const O=c.useMemo(()=>({executeJavaScript:async(ce,se)=>{const q=o.current;if(!q)throw new Error("Browser view is not available");return q.executeJavaScript(ce,se)},capturePage:async()=>{const ce=o.current;if(!ce)return null;const se=ce.getWebContentsId();return Number.isFinite(se)?await gr("desktop_browser_capture_page",{webContentsId:se}):null}}),[]),Q=c.useCallback(()=>{if(y){m(!1),jo(O);return}if(!J.url){Le.error(r("contextPanel.browser.annotate.noPage"));return}const ce=kw(i.metadata.variant==="light"?"light":"dark");m(!0),Sw({host:O,theme:ce,labels:te}).then(async se=>{m(!1),se&&await ne(se)}).catch(()=>{m(!1),Le.error(r("contextPanel.browser.annotate.failed"))})},[O,ne,i,y,J.url,te,r]);c.useEffect(()=>{if(!y)return;const ce=se=>{Op(se)||se.key!=="Escape"||(se.preventDefault(),se.stopImmediatePropagation(),m(!1),jo(O))};return window.addEventListener("keydown",ce,!0),()=>window.removeEventListener("keydown",ce,!0)},[O,y]);const le=c.useCallback(async(ce=8e3)=>{const se=Date.now();for(;;){const q=o.current;if(!q)return!1;let z=!1;try{z=q.isLoading()}catch{return!1}if(!z)return!0;if(Date.now()-se>ce)return!1;await new Promise(ee=>setTimeout(ee,120))}},[]),H=c.useCallback(async(ce,se)=>{const q=o.current;if(!q)throw new Error("The browser panel is not ready");const z=()=>{Nc(se.viewport)&&(A(ia(se.viewport)),D(!0))};if(ce==="browser.back"||ce==="browser.forward"){const Ee=ce==="browser.back";if(!(Ee?q.canGoBack():q.canGoForward()))throw new Error(Ee?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Ee?q.goBack():q.goForward(),await new Promise(V=>setTimeout(V,150)),await le();let $e="";try{$e=q.getTitle()||""}catch{$e=""}return{url:Tr(q.getURL()),title:$e}}if(ce==="browser.capture"){Pe.getState().openContextBrowser(e,q.getURL());const Ee=Date.now()+1200;let xe=0,$e=0;for(;$e<2&&Date.now()<Ee;){const Fe=q.getBoundingClientRect().width;$e=Fe>=2&&Math.abs(Fe-xe)<.5?$e+1:0,xe=Fe,await new Promise(_e=>setTimeout(_e,50))}await new Promise(Fe=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Fe()))}),await le();const V=await O.capturePage();if(!V)throw new Error("The page could not be captured");let De="";try{De=q.getTitle()||""}catch{De=""}return{...V,url:Tr(q.getURL()),title:De,viewport:co(P.current)}}if(ce==="browser.resize"){if(!Nc(se.viewport))throw new Error("viewport is required");return z(),await new Promise(Ee=>setTimeout(Ee,200)),await le(),{viewport:co(ia(se.viewport))}}if(ce==="browser.open"){const Ee=typeof se.url=="string"?se.url:"";if(!Ee)throw new Error("url is required");z(),pe(Ee),await new Promise(V=>setTimeout(V,150));const xe=await le(25e3);let $e="";try{$e=q.getTitle()||""}catch{$e=""}return{url:br(Ee),title:$e,opened:!0,settled:xe,viewport:co(P.current)}}await le();const ee=Ee=>typeof Ee=="string"&&Ee?Ee:void 0,Ne=(()=>{switch(ce){case"browser.snapshot":return Hw({selector:ee(se.selector)});case"browser.click":return Gw({selector:ee(se.selector),text:ee(se.text)});case"browser.type":return qw({selector:String(se.selector??""),value:String(se.value??""),submit:se.submit===!0});case"browser.inspect":return Xw({selector:String(se.selector??"")});case"browser.scroll":return Yw({selector:ee(se.selector),direction:ee(se.direction)});default:return null}})();if(!Ne)throw new Error(`Unsupported browser action: ${ce}`);const Ce=await q.executeJavaScript(Ne,!0);if(!Ce||typeof Ce!="object")throw new Error("The page returned no result");const We=Ce;if(We.ok!==!0)throw new Error(typeof We.error=="string"&&We.error?We.error:"Browser action failed");if(ce==="browser.snapshot"){const Ee=T.current;return{...We,viewport:co(P.current),...Ee.length>0?{consoleProblems:[...Ee]}:{}}}return(ce==="browser.click"||ce==="browser.type"&&se.submit===!0)&&(await new Promise(Ee=>setTimeout(Ee,150)),await le()),Ce},[O,e,pe,le]);c.useEffect(()=>Iw({run:H}),[H]),c.useEffect(()=>{const ce=O;return()=>{jo(ce)}},[O]),c.useEffect(()=>{if(!l)return;const ce=q=>{const z=q;if(typeof z.level!="number"||z.level<2)return;const ee=z.sourceId?`${z.sourceId}${z.line?`:${z.line}`:""}`:"";T.current.push({level:z.level>=3?"error":"warning",message:String(z.message??"").slice(0,400),source:ee}),T.current.length>Ac&&T.current.splice(0,T.current.length-Ac)},se=()=>{T.current=[]};return l.addEventListener("console-message",ce),l.addEventListener("did-start-loading",se),()=>{l.removeEventListener("console-message",ce),l.removeEventListener("did-start-loading",se)}},[l]);const me=c.useRef(new Set),ge=c.useCallback(ce=>{me.current.clear(),pe(ce)},[pe]);c.useEffect(()=>{if(!l)return;const ce=q=>{const z=hr(q),ee=typeof z.url=="string"?z.url:"";!ee||!Sc(ee)||(q.preventDefault(),pe(ee))},se=q=>{const z=hr(q);if(z.isMainFrame===!1||z.errorCode===-3)return;const ee=typeof z.validatedURL=="string"?z.validatedURL:"";!ee||!Sc(ee)||me.current.has(ee)||(me.current.add(ee),pe(ee))};return l.addEventListener("will-navigate",ce),l.addEventListener("did-fail-load",se),()=>{l.removeEventListener("will-navigate",ce),l.removeEventListener("did-fail-load",se)}},[pe,l]),c.useEffect(()=>{if(!l)return;const ce=se=>{const q=se.detail;se.preventDefault(),q?.url&&pe(q.url)};return l.addEventListener("new-window",ce),()=>l.removeEventListener("new-window",ce)},[pe,l]);const oe=c.useCallback(ce=>{const se=Math.min(Pv,Math.max(Dv,ce));k.current=se,C(se);try{o.current?.setZoomLevel(se)}catch{}},[]);c.useEffect(()=>{const ce=se=>{if(!(se instanceof CustomEvent))return;const q=se.detail,z=o.current;!z||document.activeElement!==z||(q==="zoom-in"?oe(k.current+fo):q==="zoom-out"?oe(k.current-fo):q==="zoom-reset"&&oe(0))};return window.addEventListener("openchamber:zoom",ce),()=>window.removeEventListener("openchamber:zoom",ce)},[oe]);const de=c.useCallback(ce=>{gr("desktop_browser_clear_data",{partition:Iv,cookies:ce==="cookies",cache:ce==="cache"}).then(()=>{Le.success(r(ce==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Le.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const ce=W.current;if(!ce||typeof ResizeObserver>"u")return;const se=new ResizeObserver(q=>{const z=q[0]?.contentRect;z&&F({width:z.width,height:z.height})});return se.observe(ce),()=>se.disconnect()},[]);const _=c.useCallback(ce=>{$(ce);const se=o.current;if(!se)return;let q=-1;try{q=se.getWebContentsId()}catch{return}gr("desktop_browser_set_color_scheme",{webContentsId:q,scheme:ce}).catch(z=>{$("system"),Le.error(z instanceof Error?z.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),B=c.useCallback(()=>{try{ue?o.current?.stop():o.current?.reload()}catch{}},[ue]),he=J.status;c.useEffect(()=>{const ce=()=>{S(!0);const z=setTimeout(()=>{try{o.current?.reload()}catch{}},Tv);return()=>clearTimeout(z)};if(he.kind==="failed"){if(!sw(he.code,he.url)){S(!1);return}const z=Date.now(),ee=N.current?.url===he.url?N.current:{url:he.url,startedAt:z};if(N.current=ee,z-ee.startedAt>Av){S(!1);return}return ce()}if(he.kind==="loading")return;if(N.current=null,he.kind!=="ready"||!he.url||!kr(he.url)){R.current=!0,S(!1);return}if(R.current||Date.now()-E.current>Ev){R.current=!0,S(!1);return}let se=!1,q=null;return ow(Tr(he.url)).then(z=>{if(!se){if(z===null||z<500){R.current=!0,S(!1);return}q=ce()}}),()=>{se=!0,q?.()}},[he]);const ve=J.status.kind==="failed"&&!p?J.status:null,Re=tv(I,K);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Af,{address:w,onAddressChange:v,onSubmit:ge,suggestions:Ae,onForgetSuggestion:ce=>ye(e,ce),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:B,onOpenExternal:()=>{Uo(J.url||w)},canGoBack:J.canGoBack,canGoForward:J.canGoForward,isLoading:ue,onAnnotate:Q,isAnnotating:y,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>oe(g+fo),onZoomOut:()=>oe(g-fo),onZoomReset:()=>oe(0),zoomPercent:Math.round(Math.pow(1.2,g)*100),onClearCookies:()=>de("cookies"),onClearCache:()=>de("cache"),onToggleDeviceBar:()=>D(ce=>!ce),isDeviceBarOpen:j}),j?s.jsx(rv,{viewport:I,onViewportChange:A,colorScheme:L,onColorSchemeChange:_,scale:Re?.scale??1}):null,s.jsxs("div",{ref:W,className:Oe("relative min-h-0 flex-1 bg-background",Re&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[x!==null?s.jsx("webview",{ref:d,src:x,partition:"persist:openchamber-browser",allowpopups:!0,style:Re?{width:`${Re.width}px`,height:`${Re.height}px`,transform:`scale(${Re.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,x!==null&&!f&&!J.url&&!ue?s.jsx(If,{onOpen:ge,directory:e}):null,p?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,re?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:re})})]}):null,ve&&!re?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:ve.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ve.crashed?r("contextPanel.browser.crashedHint"):ve.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ue?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},Mv=t=>{const e=Ze.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=jt(),l=Pe(Bv);let a;e[0]!==n?(a=br(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==sn?d:"",[h,f]=c.useState(u),[x,b]=c.useState(u);let w;e[2]!==u?(w=u?[u]:[],e[2]=u,e[3]=w):w=e[3];const[v,y]=c.useState(w),[m,p]=c.useState(u?0:-1),[S,g]=c.useReducer(Fv,0);let C;e[4]!==r||e[5]!==l||e[6]!==i?(C=te=>{!te||te===sn||!r||!i||l(r,i,te)},e[4]=r,e[5]=l,e[6]=i,e[7]=C):C=e[7];const k=C;let j;e[8]!==r?(j=jf(r),e[8]=r,e[9]=j):j=e[9];const D=wr(j),I=wr(_v),A=wr(Lv);let P;e[10]!==h||e[11]!==D?(P=Sf(D,h),e[10]=h,e[11]=D,e[12]=P):P=e[12];const T=P;let L;e[13]!==r||e[14]!==m||e[15]!==k||e[16]!==I?(L=te=>{const ue=br(te);ue!==sn&&(f(ue),b(ue),k(ue),I(r,{url:ue}),y(Se=>{const we=m>=0?Se.slice(0,m+1):[];return we[we.length-1]===ue?(p(we.length-1),we):(p(we.length),[...we,ue])}))},e[13]=r,e[14]=m,e[15]=k,e[16]=I,e[17]=L):L=e[17];const $=L;let K;e[18]!==v||e[19]!==k?(K=te=>{const ue=v[te];ue&&(p(te),f(ue),b(ue),k(ue))},e[18]=v,e[19]=k,e[20]=K):K=e[20];const F=K;let W;e[21]!==r||e[22]!==A?(W=te=>A(r,te),e[21]=r,e[22]=A,e[23]=W):W=e[23];let N,R;e[24]!==F||e[25]!==m?(R=()=>F(m-1),N=()=>F(m+1),e[24]=F,e[25]=m,e[26]=N,e[27]=R):(N=e[26],R=e[27]);let E;e[28]!==h||e[29]!==x?(E=()=>{Uo(x||h)},e[28]=h,e[29]=x,e[30]=E):E=e[30];const X=m>0,J=m>=0&&m<v.length-1;let re;e[31]!==h||e[32]!==$||e[33]!==T||e[34]!==N||e[35]!==E||e[36]!==X||e[37]!==J||e[38]!==W||e[39]!==R?(re=s.jsx(Af,{address:h,onAddressChange:f,onSubmit:$,suggestions:T,onForgetSuggestion:W,onBack:R,onForward:N,onReload:g,onOpenExternal:E,canGoBack:X,canGoForward:J,isLoading:!1}),e[31]=h,e[32]=$,e[33]=T,e[34]=N,e[35]=E,e[36]=X,e[37]=J,e[38]=W,e[39]=R,e[40]=re):re=e[40];let fe;e[41]!==x||e[42]!==$||e[43]!==S||e[44]!==o?(fe=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:x?s.jsx("iframe",{src:x,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${x}|${S}`):s.jsx(If,{onOpen:$})}),e[41]=x,e[42]=$,e[43]=S,e[44]=o,e[45]=fe):fe=e[45];let ne;return e[46]!==re||e[47]!==fe?(ne=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[re,fe]}),e[46]=re,e[47]=fe,e[48]=ne):ne=e[48],ne},Ov=t=>{const e=Ze.c(3),[n]=c.useState(Nv);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Rv,{...t}):s.jsx(Mv,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function Bv(t){return t.setContextPanelTabTargetPath}function Fv(t){return t+1}function _v(t){return t.recordVisit}function Lv(t){return t.forget}const $v=Wn(()=>En(()=>import("./WalkthroughView-yNj4nOP5.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,114,115,116,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.WalkthroughView}))),zv=Wn(()=>En(()=>import("./DiffView-COVQhWGd.js"),__vite__mapDeps([128,1,2,4,5,6,7,8,9,83,3,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,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,114,115,116,129,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.DiffView}))),Wv=Wn(()=>En(()=>import("./FilesView-B1V5JxFX.js"),__vite__mapDeps([130,1,2,4,5,6,7,8,9,3,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,84,85,86,131,132,133,134,135,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,114,136,137,120,121,118,125,138,119,139])).then(t=>({default:t.FilesView}))),Kv=Wn(()=>En(()=>import("./GitView-CDOJy5Ay.js"),__vite__mapDeps([140,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,84,85,86,141,117,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,114,87,115,116,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.GitView}))),Vv=Wn(()=>En(()=>import("./LinearIssuesView-D7FKg1XJ.js"),__vite__mapDeps([142,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])).then(t=>({default:t.LinearIssuesView}))),Uv=Wn(()=>En(()=>import("./PlanView-LW2z_EAP.js"),__vite__mapDeps([143,1,2,4,5,6,7,8,9,131,57,58,59,60,61,62,79,55,56,63,132,133,134,3,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,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,119,139,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,84,85,86])).then(t=>({default:t.PlanView}))),Hv=c.lazy(()=>En(()=>import("./PluginPane-B4tKno2h.js").then(t=>t.k),__vite__mapDeps([86,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])).then(t=>({default:t.PluginPane}))),Tf=320,Ja=600,Gv=400,qv=100,Yv=24,Fo=new Map,Qv=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Dc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Tf,Math.round(t))):Ja,Pc=t=>{const e=t??(typeof window<"u"?window.innerWidth:Ja*2);return Math.max(Tf,e-Gv)},Xv=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},Jv=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Ef=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):Zn(t)?uu.getState().guests.find(r=>r.id===Di(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),Zv=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},eS=(t,e,n)=>{if(t.mode==="chat"){const r=aa(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?Qa(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Zv(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Ef(t.mode,n)},tS=t=>{const e=Ze.c(8),{mode:n}=t,r=Ia();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=h=>h.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??Lp,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(Xr,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Ic=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Pa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(of,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(M,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(M,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(M,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(M,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(M,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(M,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(M,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(M,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(M,{name:"chat-4",className:"h-3.5 w-3.5"});if(Zn(t.mode))return s.jsx(tS,{mode:t.mode});if(t.mode==="browser"){const n=sS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(M,{name:"global",className:"h-3.5 w-3.5"})}},sS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},nS=({visible:t,active:e,fill:n=!1})=>{const{t:r}=jt(),i=Pe(p=>p.contextEditorTreeWidth),o=Pe(p=>p.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),h=c.useRef(null),f=c.useRef(null),x=c.useRef(null),b=c.useCallback(p=>{const S=x.current;S&&(S.style.width=`${p}px`,S.style.setProperty("--oc-editor-tree-width",`${p}px`))},[]),w=p=>{if(t){try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}f.current=p.pointerId,a(!0),d.current=p.clientX,u.current=i,h.current=i,p.preventDefault()}},v=p=>{if(!l||f.current!==p.pointerId)return;const S=d.current-p.clientX,g=Ai(u.current+S);h.current!==g&&(h.current=g,b(g))},y=p=>{if(f.current!==p.pointerId)return;try{p.currentTarget.releasePointerCapture(p.pointerId)}catch{}const S=Ai(h.current??i);f.current=null,h.current=null,a(!1),o(S)},m=t?i:0;return s.jsxs("div",{ref:x,className:Oe("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?h.current??m:m}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?h.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Oe("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:w,onPointerMove:v,onPointerUp:y,onPointerCancel:y,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Oe("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(S1,{visible:t&&e})})]})},aa=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,rS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},oS=(t,e)=>{if(e.length===0)return Fo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Fo:r},iS=(t,e)=>{const n=nu(t),r=c.useRef(Fo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=oS(n.getState().session,i.current);return rS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Fo)},aS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,lS=()=>{const{t}=jt(),e=ir()??"",n=c.useMemo(()=>Qv(e),[e]),r=Pe(Y=>n?Y.contextPanelByDirectory[n]:void 0),i=Pe(Y=>Y.closeContextPanel),o=Pe(Y=>Y.closeContextPanelTab),l=Pe(Y=>Y.openContextPanelTab),a=Pe(Y=>Y.toggleContextPanelExpanded),d=Pe(Y=>Y.setContextPanelWidth),u=Pe(Y=>Y.setActiveContextPanelTab),h=Pe(Y=>Y.openContextBrowser);c.useEffect(()=>{if(e)return Tw(Y=>h(e,Y))},[e,h]);const f=Pe(Y=>Y.reorderContextPanelTabs),x=hn(Y=>Y.setSelectedPath),b=Pe(Y=>Y.contextEditorTreeVisible),w=Pe(Y=>Y.contextEditorTreeWidth),v=Pe(Y=>Y.setContextEditorTreeWidth),y=Pe(Y=>Y.toggleContextEditorTree),m=Pe(Y=>Y.contextEditorVisible),p=Pe(Y=>Y.toggleContextEditor),S=Pe(Y=>Y.openNewContextBrowserTab),g=gf(Y=>Y.byOrigin),C=Pe(Y=>Y.allowPromptingSubagentSessions),{themeMode:k,setThemeMode:j,lightThemeId:D,darkThemeId:I,currentTheme:A}=or(),P=c.useMemo(()=>r?.tabs??[],[r?.tabs]),T=P.find(Y=>Y.id===r?.activeTabId)??P[P.length-1]??null,L=!!(r?.isOpen&&T),[$,K]=c.useState(null),F=c.useMemo(()=>P.some(Y=>Y.mode==="file"&&Y.targetPath),[P]),W=F&&(m||!b),N=T?.mode??null,R=N==="file"&&!W,E=!!(L&&r?.expanded&&!R),X=N?r?.widthByMode?.[N]:void 0,J=N?r?.widthFractionByMode?.[N]:void 0,re=N?Bp(N):.5,fe=$??(typeof window<"u"?window.innerWidth:Ja*2),ne=J!=null&&$!=null?Math.round(J*$):X,te=R?w:Dc(ne??Math.round(re*fe),Pc($??fe));c.useEffect(()=>{!n||!N||R||J!=null||X==null||$==null||d(n,N,X,$)},[N,$,n,R,X,J,d]);const ue=c.useMemo(()=>{const Y=[];for(const G of P){if(G.mode!=="chat")continue;const Z=aa(G.dedupeKey);Z&&!Y.includes(Z)&&Y.push(Z)}return Y},[P]),Se=iS(n||void 0,ue),[we,ye]=c.useState(!1),Ae=c.useRef(0),pe=c.useRef(te),O=c.useRef(null),Q=c.useRef(null),le=c.useRef(null),H=c.useRef(new Map),me=c.useRef(new Map),ge=c.useRef(!1);c.useLayoutEffect(()=>{const Y=le.current?.parentElement;if(!Y||typeof ResizeObserver>"u")return;const G=new ResizeObserver(()=>{K(Y.clientWidth||null)});return G.observe(Y),K(Y.clientWidth||null),()=>G.disconnect()},[]),c.useEffect(()=>{if(!L||ge.current){ge.current=L;return}const Y=window.requestAnimationFrame(()=>{le.current?.focus({preventScroll:!0})});return ge.current=!0,()=>window.cancelAnimationFrame(Y)},[L]);const oe=c.useRef(null),de=c.useRef(null),_=c.useCallback(()=>{de.current=null;const Y=le.current,G=O.current;!Y||G===null||Y.style.setProperty("--oc-context-panel-width",`${G}px`)},[]);c.useEffect(()=>()=>{de.current!==null&&clearTimeout(de.current)},[]);const B=c.useCallback(Y=>{const G=oe.current,Z=R?Ai(Y):Dc(Y,Pc(G));return G===null?Z:Math.min(Z,Math.max(1,G))},[R]),he=c.useCallback(Y=>{!L||E||!n||(Q.current=Y.pointerId,ye(!0),Ae.current=Y.clientX,pe.current=te,O.current=te,oe.current=Xv(le.current),document.documentElement.style.cursor="col-resize",Y.preventDefault())},[n,E,L,te]),ve=c.useCallback(()=>{const Y=B(O.current??te),G=oe.current;O.current=null,oe.current=null,de.current!==null&&(clearTimeout(de.current),de.current=null),document.documentElement.style.cursor="",R?v(Y):n&&N&&d(n,N,Y,G??void 0),ye(!1),Q.current=null},[N,B,n,R,v,d,te]);c.useEffect(()=>{if(!we)return;const Y=je=>{if(Q.current!==je.pointerId)return;const Ie=Ae.current-je.clientX,Ve=B(pe.current+Ie);O.current!==Ve&&(O.current=Ve,de.current===null&&(de.current=setTimeout(_,qv)))},G=je=>{Q.current===je.pointerId&&ve()},Z=()=>{ve()};return window.addEventListener("pointermove",Y),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G),window.addEventListener("blur",Z),()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G),window.removeEventListener("blur",Z)}},[_,B,ve,we]),c.useEffect(()=>{we||(O.current=null,document.documentElement.style.cursor="")},[we]);const Re=c.useCallback(()=>{n&&i(n)},[i,n]),ce=c.useCallback(()=>{n&&a(n)},[n,a]),se=c.useCallback(Y=>{Y.key==="Escape"&&(Y.target instanceof Node&&!Y.currentTarget.contains(Y.target)||Fp(Y.target)||_p(Y.target)||(Y.preventDefault(),Y.stopPropagation(),Re()))},[Re]);c.useEffect(()=>{if(!(!n||!T)&&T.mode==="file"&&T.targetPath){x(n,T.targetPath,{allowOutsideRoot:!0});return}},[T,n,x]);const q=c.useMemo(()=>P.filter(Y=>Y.mode==="chat"),[P]),z=L&&T?.mode==="chat"?T.id:null,ee=L&&T?.mode==="chat"?aa(T.dedupeKey):null,ae=Jx(q,z);c.useEffect(()=>{if(!L||!n||!ee||typeof window>"u")return;const Y=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ci(n,ee,!1);return}wu(ee),ci(n,ee,!0)};Y();const G=window.setInterval(Y,1e4);return window.addEventListener("focus",Y),window.addEventListener("blur",Y),document.addEventListener("visibilitychange",Y),()=>{window.clearInterval(G),window.removeEventListener("focus",Y),window.removeEventListener("blur",Y),document.removeEventListener("visibilitychange",Y),ci(n,ee,!1)}},[ee,n,L]);const Ne=c.useCallback((Y,G,Z)=>Zx(me.current,Y,G,n||null,Z,{mode:k,lightThemeId:D,darkThemeId:I,currentTheme:A},{allowPromptingSubagentSessions:C}),[C,A,I,n,D,k]),Ce=ae&&ee?Ne(ae.id,ee,ae.readOnly):null;c.useEffect(()=>{const Y=new Set(P.map(G=>G.id));for(const G of me.current.keys())Y.has(G)||me.current.delete(G)},[P]);const We=c.useCallback(Y=>{!n||T?.mode!=="diff"||l(n,{mode:"diff",targetPath:T.targetPath,stagedDiff:Y==="staged",diffScope:Y})},[T,n,l]),Ee=c.useCallback(()=>{if(typeof window>"u")return;const Y={themeMode:k,lightThemeId:D,darkThemeId:I,currentTheme:A};for(const G of H.current.values()){const Z=G.contentWindow;Z&&Z.postMessage({type:"openchamber:theme-sync",payload:Y},window.location.origin)}},[A,I,D,k]),xe=c.useCallback(()=>{if(typeof window>"u")return;const Y={allowPromptingSubagentSessions:C};for(const G of H.current.values()){const Z=G.contentWindow;Z&&Z.postMessage({type:"openchamber:chat-settings-sync",payload:Y},window.location.origin)}},[C]),$e=c.useCallback((Y,G,Z)=>{const je=G.contentWindow;je&&je.postMessage({type:Gu,payload:{visible:z===Y}},Z)},[z]),V=c.useCallback(()=>{if(!(typeof window>"u"))for(const[Y,G]of H.current.entries())$e(Y,G,window.location.origin)},[$e]);c.useEffect(()=>{if(typeof window>"u")return;const Y=G=>{if(G.origin!==window.location.origin)return;const Z=Array.from(H.current.entries()).find(([,it])=>it.contentWindow===G.source);if(!Z)return;const je=G.data;if(je?.type===eb){const[it,at]=Z;$e(it,at,G.origin);return}if(je?.type===tb){if(typeof je.requestId!="string"||!je.requestId)return;const it=qt(),at={apiBaseUrl:Pn(),clientToken:Hr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:Md(),relayHostId:it.startsWith("host:")?it.slice(5):"",relay:Qm()??void 0};G.source?.postMessage({type:sb,requestId:je.requestId,payload:at},G.origin);return}if(je?.type==="openchamber:theme-sync-request"){Ee();return}if(je?.type==="openchamber:chat-settings-request"){xe();return}if(je?.type!=="openchamber:cycle-theme-request")return;const Ie=["light","dark","system"],Je=(Ie.indexOf(k)+1)%Ie.length;j(Ie[Je])};return window.addEventListener("message",Y),()=>window.removeEventListener("message",Y)},[xe,$e,Ee,j,k]),c.useLayoutEffect(()=>{P.some(G=>G.mode==="chat")&&(Ee(),xe(),V())},[I,D,xe,V,Ee,P,k]);const De=T?.mode==="file"||T?.mode==="chat"||T?.mode==="browser",Fe=c.useMemo(()=>T?P.filter(Y=>Y.mode===T.mode):[],[T,P]),_e=c.useMemo(()=>Fe.map(Y=>{const G=eS(Y,Se,t),Z=aS(G,Yv),je=Jv(Y.targetPath,e);return{id:Y.id,label:Z,icon:Ic(Y,g),title:je?`${G}: ${je}`:G,closeLabel:t("contextPanel.tab.closeTabAria",{label:Z})}}),[Fe,e,g,Se,t]),rt=T?.mode==="context"?s.jsx(z1,{}):T?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Kv,{isActive:L})}):T?.mode==="pr"?s.jsx(Yy,{}):T?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Vv,{})}):T?.mode==="notes"?s.jsx(jh,{}):T?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Uv,{targetPath:T.targetPath,savedProjectPlan:T.projectPlanId&&T.projectPlanRef?{projectRef:T.projectPlanRef,planId:T.projectPlanId}:null})}):null,ct=c.useMemo(()=>P.filter(Y=>Y.mode==="browser"),[P]),et=c.useMemo(()=>P.filter(Y=>Y.mode==="diff"),[P]),pt=c.useMemo(()=>P.find(Y=>Y.mode==="terminal")??null,[P]),kt=c.useMemo(()=>P.some(Y=>Y.mode==="walkthrough"),[P]),wt=c.useMemo(()=>P.filter(Y=>Zn(Y.mode)),[P]),Xe=c.useMemo(()=>P.some(Y=>Y.mode==="file"),[P]),yt=T?.mode==="file",Rt=Pe(Y=>Y.closeContextPanelTabs),be=c.useCallback(Y=>{if(!n)return null;const{id:G,index:Z,allIds:je,close:Ie}=Y,Ve=()=>Rt(n,je.filter(Pt=>Pt!==G)),Je=()=>Rt(n,je.slice(0,Z)),it=()=>Rt(n,je.slice(Z+1)),at=()=>Rt(n,je),Ye=je.length>1,vt=Z===0,Ue=Z===je.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Qn,{onClick:Ie,children:[s.jsx(M,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Ei,{}),s.jsxs(Qn,{onClick:Ve,disabled:!Ye,children:[s.jsx(M,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Qn,{onClick:Je,disabled:vt,children:[s.jsx(M,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Qn,{onClick:it,disabled:Ue,children:[s.jsx(M,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Ei,{}),s.jsxs(Qn,{onClick:at,disabled:!Ye,children:[s.jsx(M,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[Rt,n,t]),Ge=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[De?s.jsx($d,{items:_e,activeId:T?.id??null,onSelect:Y=>{n&&u(n,Y)},onClose:Y=>{n&&o(n,Y)},onReorder:(Y,G)=>{n&&f(n,Y,G)},layoutMode:"scrollable",variant:"default",tabContextMenu:be}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[T?Ic(T,g):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:T?Ef(T.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[T?.mode==="browser"?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&S(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(M,{name:"add",className:"h-3.5 w-3.5"})}):null,yt&&F?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:p,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":W,children:s.jsx(M,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,yt?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:y,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(M,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,R?null:s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:ce,className:"h-7 w-7 p-0",title:t(E?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(E?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:E?s.jsx(M,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(M,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:Re,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]})]}),ut=L?E?{"--oc-context-panel-width":$!==null?`${$}px`:"100%",width:$!==null?`${$}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${te}px`}:{"--oc-context-panel-width":`${te}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:le,"data-context-panel":"true",tabIndex:-1,inert:!L||void 0,className:Oe("flex min-h-0 flex-col overflow-hidden bg-background",E?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!L&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:se,style:ut,children:[L&&!E&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),L&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!E&&s.jsx("div",{className:Oe("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",we&&"bg-[var(--interactive-border)]"),onPointerDown:he,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Oe("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!L&&"pointer-events-none select-none opacity-0"),style:{width:E?$!==null?`${$}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!L,children:[Ge,s.jsxs("div",{className:Oe("relative min-h-0 flex-1 overflow-hidden",we&&"pointer-events-none"),children:[Xe?s.jsxs("div",{className:Oe("absolute inset-0 flex",yt?"flex":"hidden"),children:[F||!b?s.jsx("div",{className:Oe("h-full min-w-0 flex-1",F&&!W&&"hidden"),children:F?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Wv,{mode:"editor-only",visible:L&&yt&&W})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(M,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,s.jsx(nS,{visible:b,active:L&&yt,fill:!W})]}):null,ae&&ee&&Ce?s.jsx("iframe",{ref:Y=>{if(!Y){H.current.delete(ae.id);return}H.current.set(ae.id,Y)},src:Ce,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:ee}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Ee(),xe(),V()}},ae.id):null,ct.map(Y=>s.jsx("div",{className:Oe("absolute inset-0",T?.id!==Y.id&&"hidden"),children:s.jsx(Ov,{initialUrl:Y.targetPath??"",directory:n,tabID:Y.id})},Y.id)),et.map(Y=>s.jsx("div",{className:Oe("absolute inset-0",T?.id!==Y.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(zv,{visible:L&&T?.id===Y.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:Y.diffScope??(Y.stagedDiff?"staged":"working"),onDiffScopeChange:We,targetFilePath:Y.targetPath,flushContent:!0})})},Y.id)),pt?s.jsx("div",{className:Oe("absolute inset-0",T?.mode==="terminal"?"block":"hidden"),children:s.jsx(kh,{visible:L&&T?.mode==="terminal",directory:pt.targetDirectory})}):null,kt?s.jsx("div",{className:Oe("absolute inset-0",T?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx($v,{directory:e,visible:L&&T?.mode==="walkthrough"})})}):null,wt.map(Y=>Zn(Y.mode)?s.jsx("div",{className:Oe("absolute inset-0",T?.id===Y.id?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Hv,{mode:Y.mode})})},Y.id):null),T?.mode!=="chat"&&!yt&&T?.mode!=="browser"&&T?.mode!=="diff"&&T?.mode!=="terminal"&&T?.mode!=="walkthrough"&&!(T&&Zn(T.mode))?rt:null]})]})]})},cS=t=>{const e=Ze.c(43),{open:n,onOpenChange:r}=t,{t:i}=jt(),o=Pe(dS),l=Pe(uS),a=Pe(fS),d=Pe(mS),u=Ia();let h;e[0]!==o||e[1]!==u?(h=vu(o,u),e[0]=o,e[1]=u,e[2]=h):h=e[2];const f=h,x=l.length===0;let b;if(e[3]!==l||e[4]!==f){let I;e[6]!==l?(I=A=>l.includes(A.id),e[6]=l,e[7]=I):I=e[7],b=f.every(I),e[3]=l,e[4]=f,e[5]=b}else b=e[5];const w=b;let v;e[8]!==i?(v=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=v):v=e[9];let y;e[10]!==v?(y=s.jsx(Ps,{children:v}),e[10]=v,e[11]=y):y=e[11];let m;e[12]!==i?(m=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=m):m=e[13];let p;e[14]!==m?(p=s.jsx(Is,{children:m}),e[14]=m,e[15]=p):p=e[15];let S;e[16]!==y||e[17]!==p?(S=s.jsxs(Vs,{children:[y,p]}),e[16]=y,e[17]=p,e[18]=S):S=e[18];let g;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let I;e[24]!==l||e[25]!==a||e[26]!==i?(I=A=>s.jsx($p,{settingsItem:`layout.context-rail.surface.${A.id}`,checked:!l.includes(A.id),onChange:P=>a(A.id,P),label:A.label??i(A.labelKey),ariaLabel:A.label??i(A.labelKey)},A.id),e[24]=l,e[25]=a,e[26]=i,e[27]=I):I=e[27],g=f.map(I),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=g}else g=e[23];let C;e[28]!==g?(C=s.jsx("div",{className:"flex flex-col",children:g}),e[28]=g,e[29]=C):C=e[29];let k;e[30]!==x||e[31]!==w||e[32]!==d||e[33]!==i?(k=x?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[w?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(dt,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=x,e[31]=w,e[32]=d,e[33]=i,e[34]=k):k=e[34];let j;e[35]!==k||e[36]!==S||e[37]!==C?(j=s.jsxs(ws,{className:"max-w-md",children:[S,C,k]}),e[35]=k,e[36]=S,e[37]=C,e[38]=j):j=e[38];let D;return e[39]!==r||e[40]!==n||e[41]!==j?(D=s.jsx(ys,{open:n,onOpenChange:r,children:j}),e[39]=r,e[40]=n,e[41]=j,e[42]=D):D=e[42],D};function dS(t){return t.contextRailOrder}function uS(t){return t.contextRailHiddenSurfaces}function fS(t){return t.setContextRailSurfaceVisible}function mS(t){return t.setContextRailHiddenSurfaces}const Rf=150,hS=500,pS=[],gS=t=>t>99?"99+":String(t),xS=t=>{const e=Ze.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:h,showOrderNumber:f,onSelect:x}=t;let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:w,listeners:v,setNodeRef:y,transform:m,transition:p,isDragging:S}=ti(b);let g;e[2]!==a?(g=a!=null&&a>0?gS(a):null,e[2]=a,e[3]=g):g=e[3];const C=g;let k;e[4]!==m?(k=si.Translate.toString(m),e[4]=m,e[5]=k):k=e[5];let j;e[6]!==k||e[7]!==p?(j={transform:k,transition:p},e[6]=k,e[7]=p,e[8]=j):j=e[8];const D=S&&"z-10 opacity-70";let I;e[9]!==D?(I=Oe("relative",D),e[9]=D,e[10]=I):I=e[10];let A;e[11]!==x||e[12]!==n?(A=()=>x(n),e[11]=x,e[12]=n,e[13]=A):A=e[13];const P=d??o,T=r?"text-primary":"text-muted-foreground hover:text-foreground";let L;e[14]!==T?(L=Oe("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",T),e[14]=T,e[15]=L):L=e[15];let $;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?($=n.id==="diff"?s.jsx(of,{className:"h-[18px] w-[18px]"}):s.jsx(Xr,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=$):$=e[19];let K;e[20]!==C||e[21]!==h||e[22]!==i||e[23]!==f?(K=f&&h!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):C?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:C}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[20]=C,e[21]=h,e[22]=i,e[23]=f,e[24]=K):K=e[24];let F;e[25]!==w||e[26]!==r||e[27]!==v||e[28]!==L||e[29]!==$||e[30]!==K||e[31]!==A||e[32]!==P?(F=s.jsx(At,{asChild:!0,children:s.jsxs("button",{type:"button",...w,...v,onClick:A,"aria-label":P,"aria-pressed":r,className:L,children:[$,K]})}),e[25]=w,e[26]=r,e[27]=v,e[28]=L,e[29]=$,e[30]=K,e[31]=A,e[32]=P,e[33]=F):F=e[33];let W;e[34]!==o?(W=s.jsx("span",{children:o}),e[34]=o,e[35]=W):W=e[35];let N;e[36]!==l?(N=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=N):N=e[37];let R;e[38]!==u?(R=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=R):R=e[39];let E;e[40]!==W||e[41]!==N||e[42]!==R?(E=s.jsx(Dt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[W,N,R]})}),e[40]=W,e[41]=N,e[42]=R,e[43]=E):E=e[43];let X;e[44]!==F||e[45]!==E?(X=s.jsxs(Nt,{delayDuration:Rf,children:[F,E]}),e[44]=F,e[45]=E,e[46]=X):X=e[46];let J;return e[47]!==y||e[48]!==X||e[49]!==j||e[50]!==I?(J=s.jsx("div",{ref:y,style:j,className:I,children:X}),e[47]=y,e[48]=X,e[49]=j,e[50]=I,e[51]=J):J=e[51],J},bS=()=>{const t=Ze.c(92),{t:e}=jt(),n=ir();let r;t[0]!==n?(r=n?cr(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=ce=>i?ce.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Pe(o),a=Pe(yS),d=Pe(wS),u=Pe(vS),h=Pe(SS),f=Pe(jS),x=Pe(kS),b=Pe(CS),w=Ca(NS),v=_i(AS),y=_i(DS),m=In(PS),p=In(IS),{screenWidth:S}=zn(),g=Na(i||null);let C;t[4]!==b?(C=Li("switch_context_surface",b),t[4]=b,t[5]=C):C=t[5];const k=C,[j,D]=c.useState(!1);let I,A;t[6]!==k?(I=()=>{const ce=new Set;let se=null,q=!1;const z=TS,ee=()=>{Dl(k,ce)?!q&&se===null&&(se=setTimeout(()=>D(!0),hS)):(q=!1,se!==null&&(clearTimeout(se),se=null),D(!1))},ae=We=>{if(ce.add(We.key.toLowerCase()),z(We.key)&&Dl(k,ce)){q=!0,se!==null&&(clearTimeout(se),se=null),D(!1);return}ee()},Ne=We=>{ce.delete(We.key.toLowerCase()),ee()},Ce=()=>{ce.clear(),q=!1,se!==null&&(clearTimeout(se),se=null),D(!1)};return window.addEventListener("keydown",ae,!0),window.addEventListener("keyup",Ne,!0),window.addEventListener("blur",Ce),()=>{window.removeEventListener("keydown",ae,!0),window.removeEventListener("keyup",Ne,!0),window.removeEventListener("blur",Ce),se!==null&&clearTimeout(se)}},A=[k],t[6]=k,t[7]=I,t[8]=A):(I=t[7],A=t[8]),c.useEffect(I,A);let P;t[9]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{distance:8}},t[9]=P):P=t[9];let T;t[10]===Symbol.for("react.memo_cache_sentinel")?(T={activationConstraint:{delay:200,tolerance:6}},t[10]=T):T=t[10];const L=Qo(Dn(Jo,P),Dn(Xo,T)),$=Ia(),K=Al(ES),F=Al(RS),W=l?.tabs??pS;let N;t[11]!==l?.activeTabId||t[12]!==W?(N=W.find(ce=>ce.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=W,t[13]=N):N=t[13];const R=N,E=l?.isOpen?R?.mode??null:null,X=g?.files.length??0;let J;t[14]!==u||t[15]!==d||t[16]!==p||t[17]!==$||t[18]!==y||t[19]!==w||t[20]!==S||t[21]!==W?(J=zp({railOrder:d,hiddenSurfaces:u,planModeEnabled:w,isVSCode:$n(),screenWidth:S,tabs:W,linearConnected:y,githubConnected:p,extras:$}),t[14]=u,t[15]=d,t[16]=p,t[17]=$,t[18]=y,t[19]=w,t[20]=S,t[21]=W,t[22]=J):J=t[22];const re=J;let fe,ne;t[23]!==E||t[24]!==x||t[25]!==i||t[26]!==v||t[27]!==y?(ne=()=>{!i||!v||y||E!=="linear"||x(i)},fe=[E,x,i,v,y],t[23]=E,t[24]=x,t[25]=i,t[26]=v,t[27]=y,t[28]=fe,t[29]=ne):(fe=t[28],ne=t[29]),c.useEffect(ne,fe);let te,ue;t[30]!==E||t[31]!==x||t[32]!==i||t[33]!==m||t[34]!==p?(te=()=>{!i||!m||p||E!=="pr"||x(i)},ue=[E,x,i,m,p],t[30]=E,t[31]=x,t[32]=i,t[33]=m,t[34]=p,t[35]=te,t[36]=ue):(te=t[35],ue=t[36]),c.useEffect(te,ue);const[Se,we]=c.useState(!1);let ye;t[37]!==$||t[38]!==h?(ye=ce=>{const{active:se,over:q}=ce;if(!q||se.id===q.id)return;const z=vu(Pe.getState().contextRailOrder,$).map(MS),ee=z.indexOf(se.id),ae=z.indexOf(q.id);ee===-1||ae===-1||h(zu(z,ee,ae))},t[37]=$,t[38]=h,t[39]=ye):ye=t[39];const Ae=ye;if(!i)return null;let pe;t[40]!==e?(pe=e("contextRail.aria.rail"),t[40]=e,t[41]=pe):pe=t[41];let O;t[42]!==re?(O=re.map(OS),t[42]=re,t[43]=O):O=t[43];let Q;if(t[44]!==E||t[45]!==X||t[46]!==F||t[47]!==i||t[48]!==K||t[49]!==f||t[50]!==j||t[51]!==re||t[52]!==e||t[53]!==a){let ce;t[55]!==E||t[56]!==X||t[57]!==F||t[58]!==i||t[59]!==K||t[60]!==f||t[61]!==j||t[62]!==e||t[63]!==a?(ce=(se,q)=>{const z=se.label??e(se.labelKey),ee=se.id==="git"&&!a?X:0,ae=Zn(se.mode)&&E!==se.mode?K[Di(se.mode)]??0:0,Ne=ee>0?ee:ae>0?ae:null,Ce=Ne!==null&&ee===0;return s.jsx(xS,{surface:se,isActive:E===se.mode,showActivityDot:!1,label:z,description:e(se.descriptionKey),badgeCount:Ne,badgeAriaLabel:Ne!==null?e(Ce?Ne===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":Ne===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:z,count:Ne}):null,badgeDescription:Ne!==null?e(Ce?Ne===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":Ne===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:Ne}):null,orderNumber:q+1,showOrderNumber:j,onSelect:We=>{Zn(We.mode)&&F(Di(We.mode)),f(i,We.mode)}},se.id)},t[55]=E,t[56]=X,t[57]=F,t[58]=i,t[59]=K,t[60]=f,t[61]=j,t[62]=e,t[63]=a,t[64]=ce):ce=t[64],Q=re.map(ce),t[44]=E,t[45]=X,t[46]=F,t[47]=i,t[48]=K,t[49]=f,t[50]=j,t[51]=re,t[52]=e,t[53]=a,t[54]=Q}else Q=t[54];let le;t[65]!==O||t[66]!==Q?(le=s.jsx(Wa,{items:O,strategy:Wu,children:Q}),t[65]=O,t[66]=Q,t[67]=le):le=t[67];let H;t[68]!==Ae||t[69]!==L||t[70]!==le?(H=s.jsx(Zo,{sensors:L,collisionDetection:ei,onDragEnd:Ae,children:le}),t[68]=Ae,t[69]=L,t[70]=le,t[71]=H):H=t[71];let me;t[72]!==e?(me=e("contextRail.configure.open"),t[72]=e,t[73]=me):me=t[73];let ge;t[74]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>we(!0),t[74]=ge):ge=t[74];let oe;t[75]===Symbol.for("react.memo_cache_sentinel")?(oe=s.jsx(M,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=oe):oe=t[75];let de;t[76]!==me?(de=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":me,onClick:ge,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:oe})}),t[76]=me,t[77]=de):de=t[77];let _;t[78]!==e?(_=e("contextRail.configure.open"),t[78]=e,t[79]=_):_=t[79];let B;t[80]!==_?(B=s.jsx(Dt,{side:"left",sideOffset:8,children:_}),t[80]=_,t[81]=B):B=t[81];let he;t[82]!==de||t[83]!==B?(he=s.jsxs(Nt,{delayDuration:Rf,children:[de,B]}),t[82]=de,t[83]=B,t[84]=he):he=t[84];let ve;t[85]!==Se?(ve=s.jsx(cS,{open:Se,onOpenChange:we}),t[85]=Se,t[86]=ve):ve=t[86];let Re;return t[87]!==pe||t[88]!==H||t[89]!==he||t[90]!==ve?(Re=s.jsxs("nav",{"aria-label":pe,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[H,he,ve]}),t[87]=pe,t[88]=H,t[89]=he,t[90]=ve,t[91]=Re):Re=t[91],Re};function yS(t){return t.workStatusPanelVisible}function wS(t){return t.contextRailOrder}function vS(t){return t.contextRailHiddenSurfaces}function SS(t){return t.setContextRailOrder}function jS(t){return t.openContextSurface}function kS(t){return t.closeContextPanel}function CS(t){return t.shortcutOverrides}function NS(t){return t.planModeEnabled}function AS(t){return t.hasChecked}function DS(t){return t.status?.connected===!0}function PS(t){return t.hasChecked}function IS(t){return t.status?.connected===!0}function TS(t){return t.length===1&&t>="0"&&t<="9"}function ES(t){return t.countByGuest}function RS(t){return t.clearBadge}function MS(t){return t.id}function OS(t){return t.id}const BS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),FS=(t,e,n,r)=>!n||r!==n||t.length===0?[]:_r(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),_S=new Set,LS=[],la=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},$S=()=>{const t=Ze.c(183),{t:e}=jt(),n=Pe(zS),r=Pe(WS),i=Pe(KS),o=Pe(VS),l=Pe(US),a=Pe(HS),d=Pe(GS),u=Pe(qS),h=Pe(YS),f=Pe(QS),x=Pe(XS),b=Pe(JS),w=Pe(ZS),v=tt(e0),y=tt(t0),m=tt(s0),p=Gr(n0);let S;t[0]!==n?(S=qe=>n?qe.activeSessions:LS,t[0]=n,t[1]=S):S=t[1];const g=$s(S);let C;t[2]!==n?(C=qe=>n?qe.ids:_S,t[2]=n,t[3]=C):C=t[3];const k=Gr(C);let j;t[4]!==n?(j=qe=>n?qe.rankById:Ea,t[4]=n,t[5]=j):j=t[5];const D=Ta(j),I=ns(r0),A=Ht(o0),P=Ht(i0),T=ir(),L=Rd(a0),{files:$,git:K}=vn(),F=Tn(l0),{isMobile:W}=zn();let N;t[6]!==T?(N=T?la(T):null,t[6]=T,t[7]=N):N=t[7];const R=N,[E,X]=c.useState(""),re=xu(E,200).trim();let fe;t[8]!==E?(fe=E.trim(),t[8]=E,t[9]=fe):fe=t[9];const ne=fe;let te,ue;t[10]!==n?(te=()=>{n&&X("")},ue=[n],t[10]=n,t[11]=te,t[12]=ue):(te=t[11],ue=t[12]),c.useEffect(te,ue);let Se,we;t[13]!==g||t[14]!==F||t[15]!==K||t[16]!==n?(Se=()=>{if(!n||!K)return;const qe=setTimeout(()=>{const ze=new Set;for(const ft of g){const Be=Ds(ft);!Be||ze.has(Be)||(ze.add(Be),F(Be,K))}},0);return()=>clearTimeout(qe)},we=[n,g,K,F],t[13]=g,t[14]=F,t[15]=K,t[16]=n,t[17]=Se,t[18]=we):(Se=t[17],we=t[18]),c.useEffect(Se,we);let ye;t[19]!==r?(ye=()=>r(!1),t[19]=r,t[20]=ye):ye=t[20];const Ae=ye;let pe;t[21]!==Ae?(pe=qe=>()=>{Ae(),qe()},t[21]=Ae,t[22]=pe):pe=t[22];const O=pe;let Q;t[23]!==A?.id||t[24]!==A?.path||t[25]!==I||t[26]!==m||t[27]!==W||t[28]!==d||t[29]!==u||t[30]!==x||t[31]!==v||t[32]!==O||t[33]!==b||t[34]!==w||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==p||t[39]!==a?(Q=()=>{const qe=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(M,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:O(()=>{l(!1),v()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(M,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:O(c0)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(M,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:O(d0)},{id:"toggle-sidebar",title:e(W?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(M,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(W?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:O(()=>{if(W){const{isSessionSwitcherOpen:ze}=Pe.getState();l(!ze)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(M,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:O(()=>{I&&u(I,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(M,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:O(()=>{I&&d(I)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(M,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:O(u0)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(M,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:O(f0)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(M,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:O(()=>i(!0))}];return qe.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(M,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:O(()=>{m&&I&&p({directory:I,sessionId:m})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(M,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:O(()=>{m&&gn(m).then(ze=>{if(ze.ok){Le.success(e("sessions.sidebar.session.copyId.success"));return}Le.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(M,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:O(()=>{l(!1),x()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(M,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:O(()=>{l(!1),b(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(M,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:O(()=>{I&&(w("notes"),u(I,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(M,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:O(()=>{I&&(w("todos"),u(I,"notes"))})}),qe.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(M,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:O(m0)}),Ur()&&qe.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(M,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:O(()=>{_n("desktop_open_draft_mini_chat_window",{directory:la(I||A?.path||""),projectId:A?.id??null}).catch(h0)})}),qe},t[23]=A?.id,t[24]=A?.path,t[25]=I,t[26]=m,t[27]=W,t[28]=d,t[29]=u,t[30]=x,t[31]=v,t[32]=O,t[33]=b,t[34]=w,t[35]=l,t[36]=i,t[37]=e,t[38]=p,t[39]=a,t[40]=Q):Q=t[40],A?.id,A?.path;let le;t[41]!==Q?(le=Q(),t[41]=Q,t[42]=le):le=t[42];const H=le,me=Pe(p0);let ge;t[43]===Symbol.for("react.memo_cache_sentinel")?(ge=xn(),t[43]=ge):ge=t[43];const oe=ge;let de,_;t[44]===Symbol.for("react.memo_cache_sentinel")?(de=$n(),_=!oe&&wa(),t[44]=de,t[45]=_):(de=t[44],_=t[45]);let B;t[46]!==W||t[47]!==me?(B={isVSCode:de,isWeb:_,isDesktop:oe,isMobile:W,routingAvailable:me},t[46]=W,t[47]=me,t[48]=B):B=t[48];const he=B;let ve;if(t[49]!==O||t[50]!==i||t[51]!==o||t[52]!==he){let qe;t[54]!==he?(qe=ft=>ft.isAvailable?ft.isAvailable(he):!0,t[54]=he,t[55]=qe):qe=t[55];let ze;t[56]!==O||t[57]!==i||t[58]!==o?(ze=ft=>{const Be=Nh(ft.slug)??"settings-3",Ke=(ft.keywords??[]).join(" ");return{id:`settings:${ft.slug}`,title:ft.title,icon:ft.slug==="mcp"?s.jsx(Hp,{className:"mr-2 h-4 w-4"}):s.jsx(M,{name:Be,className:"mr-2 h-4 w-4"}),searchText:`${ft.title} ${ft.group} ${Ke}`,onSelect:O(()=>{o(ft.slug),i(!0)})}},t[56]=O,t[57]=i,t[58]=o,t[59]=ze):ze=t[59],ve=Ch.filter(g0).filter(qe).map(ze),t[49]=O,t[50]=i,t[51]=o,t[52]=he,t[53]=ve}else ve=t[53];const Re=ve;let ce;if(t[60]!==g||t[61]!==k||t[62]!==D){const qe=g.filter(x0);ce=Wp(qe,k,D),t[60]=g,t[61]=k,t[62]=D,t[63]=ce}else ce=t[63];const se=ce,q=Su(),z=tt(b0);let ee;t[64]!==q||t[65]!==z?(ee=(qe,ze)=>{const ft=z.get(qe);return ft?.branch?ft.branch.trim()||null:ze&&q.get(ze)?.trim()||null},t[64]=q,t[65]=z,t[66]=ee):ee=t[66];const ae=ee;let Ne;t[67]===Symbol.for("react.memo_cache_sentinel")?(Ne=[],t[67]=Ne):Ne=t[67];const[Ce,We]=c.useState(Ne),[Ee,xe]=c.useState(""),$e=BS(R,re);let V;t[68]!==R||t[69]!==$e||t[70]!==n||t[71]!==L||t[72]!==We||t[73]!==xe||t[74]!==re?(V=()=>{if(!n){We([]),xe("");return}if(!$e){We([]),xe("");return}if(!R){We([]),xe("");return}let qe=!1;return L(R,re,40,{type:"file"}).then(ze=>{qe||(We(ze.map(y0)),xe($e))}).catch(()=>{qe||(We([]),xe($e))}),()=>{qe=!0}},t[68]=R,t[69]=$e,t[70]=n,t[71]=L,t[72]=We,t[73]=xe,t[74]=re,t[75]=V):V=t[75];let De;t[76]!==R||t[77]!==$e||t[78]!==n||t[79]!==L||t[80]!==re?(De=[n,R,re,$e,L],t[76]=R,t[77]=$e,t[78]=n,t[79]=L,t[80]=re,t[81]=De):De=t[81],c.useEffect(V,De);const Fe=ne.length>0;let _e;e:{if(!Fe){let ze;t[82]!==H?(ze=H.filter(w0).map(v0),t[82]=H,t[83]=ze):ze=t[83],_e=ze;break e}let qe;t[84]!==H||t[85]!==ne?(qe=_r(H,ne,S0,{limit:7,noFuzzy:!0}),t[84]=H,t[85]=ne,t[86]=qe):qe=t[86],_e=qe}const rt=_e;let ct;e:{if(!Fe){let ze;t[87]===Symbol.for("react.memo_cache_sentinel")?(ze=[],t[87]=ze):ze=t[87],ct=ze;break e}let qe;t[88]!==ne||t[89]!==Re?(qe=_r(Re,ne,j0,{limit:7,noFuzzy:!0}),t[88]=ne,t[89]=Re,t[90]=qe):qe=t[90],ct=qe}const et=ct;let pt;e:{if(!Fe){let ze;t[91]!==se?(ze=se.slice(0,5).map(k0),t[91]=se,t[92]=ze):ze=t[92],pt=ze;break e}let qe;t[93]!==ne||t[94]!==se?(qe=_r(se,ne,C0,{limit:7,threshold:.2}),t[93]=ne,t[94]=se,t[95]=qe):qe=t[95],pt=qe}const kt=pt;let wt;e:{if(!n){let ze;t[96]===Symbol.for("react.memo_cache_sentinel")?(ze=[],t[96]=ze):ze=t[96],wt=ze;break e}let qe;t[97]!==Ce||t[98]!==Ee||t[99]!==$e||t[100]!==re?(qe=FS(Ce,re,$e,Ee),t[97]=Ce,t[98]=Ee,t[99]=$e,t[100]=re,t[101]=qe):qe=t[101],wt=qe}const Xe=wt,yt=n&&$e.length>0&&Ee!==$e;let Rt;e:{if(!Fe){let ze;t[102]===Symbol.for("react.memo_cache_sentinel")?(ze=[],t[102]=ze):ze=t[102],Rt=ze;break e}let qe;if(t[103]!==ne||t[104]!==P){const ze=P.map(N0);qe=_r(ze,ne,A0,{limit:7,threshold:.4}),t[103]=ne,t[104]=P,t[105]=qe}else qe=t[105];Rt=qe}const be=Rt;let Ge,ut,Y,G,Z,je,Ie,Ve,Je,it,at,Ye,vt,Ue;if(t[106]!==ae||t[107]!==Ae||t[108]!==R||t[109]!==$||t[110]!==Fe||t[111]!==n||t[112]!==h||t[113]!==v||t[114]!==E||t[115]!==rt||t[116]!==Xe||t[117]!==be||t[118]!==kt||t[119]!==et||t[120]!==r||t[121]!==y||t[122]!==f||t[123]!==e){const qe=rt.map(D0),ze=et.map(P0),ft=kt.map(I0),Be=Fe?Xe.map(T0):[],Ke=Fe?be.map(E0):[];let He;e:{if(!Fe){He=["commands","sessions"];break e}const It=R0,bt=[{key:"commands",score:It(rt)},{key:"settings",score:It(et)},{key:"sessions",score:It(kt)},{key:"files",score:It(Xe)},{key:"projects",score:It(be)}];bt.sort(M0),He=bt.map(O0)}const nt=He,St=It=>{Ae(),y(It.id,Ds(It))},Lt=async It=>{if(!R)return;const bt=await uf($,It,{directory:R});if(!bt.ok){Le.error(ff(bt.reason));return}h(R,It),Ae()},Ut=(It,bt)=>{Ae(),v({selectedProjectId:It,directoryOverride:bt})},Bt=It=>er(Jr(It,f));G=ys,Ye=n,vt=r;let zt;t[138]!==e?(zt=e("commandPalette.title"),t[138]=e,t[139]=zt):zt=t[139];let _t;t[140]!==zt?(_t=s.jsx(Ps,{children:zt}),t[140]=zt,t[141]=_t):_t=t[141];let Yt;t[142]!==e?(Yt=e("commandPalette.description"),t[142]=e,t[143]=Yt):Yt=t[143];let Zt;t[144]!==Yt?(Zt=s.jsx(Is,{children:Yt}),t[144]=Yt,t[145]=Zt):Zt=t[145],t[146]!==_t||t[147]!==Zt?(Ue=s.jsxs(Vs,{className:"sr-only",children:[_t,Zt]}),t[146]=_t,t[147]=Zt,t[148]=Ue):Ue=t[148],Y=ws,it="overflow-hidden p-0",at=!0,ut=Gp,Ie=!1,Ve="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let es;t[149]!==e?(es=e("commandPalette.input.placeholder"),t[149]=e,t[150]=es):es=t[150],t[151]!==E||t[152]!==es?(Je=s.jsx(qp,{value:E,onValueChange:X,placeholder:es}),t[151]=E,t[152]=es,t[153]=Je):Je=t[153],Ge=Yp;let Vt;t[154]!==e?(Vt=e("commandPalette.empty.noResults"),t[154]=e,t[155]=Vt):Vt=t[155],t[156]!==Vt?(Z=s.jsx(Qp,{children:Vt}),t[156]=Vt,t[157]=Z):Z=t[157],je=nt.map(It=>It==="commands"&&qe.length>0?s.jsx(Ar,{children:qe.map(bt=>s.jsxs(Lr,{value:bt.id,onSelect:bt.onSelect,children:[bt.icon,s.jsx("span",{children:bt.title}),bt.shortcutId?s.jsx(Kp,{children:Bt(bt.shortcutId)}):null]},bt.id))},"commands"):It==="settings"&&ze.length>0?s.jsx(Ar,{children:ze.map(B0)},"settings"):It==="sessions"&&ft.length>0?s.jsx(Ar,{children:ft.map(bt=>{const cs=bt.title||e("commandPalette.session.untitled"),ms=Ds(bt),hs=ae(bt.id,ms);return s.jsxs(Lr,{value:`session:${bt.id}`,onSelect:()=>St(bt),children:[s.jsx(M,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:cs}),hs?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(M,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:hs})]}):null]},bt.id)})},"sessions"):It==="files"&&Be.length>0?s.jsx(Ar,{children:Be.map(bt=>{const cs=Vp(bt.relativePath||bt.name,{maxLength:80});return s.jsxs(Lr,{value:`file:${bt.path}`,onSelect:()=>{Lt(bt.path)},children:[s.jsx(Pa,{filePath:bt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":bt.relativePath,children:cs})]},`file:${bt.path}`)})},"files"):It==="projects"&&Ke.length>0?s.jsx(Ar,{children:Ke.map(bt=>{const cs=bt.displayName;return s.jsxs(Lr,{value:`project:${bt.id}`,onSelect:()=>Ut(bt.id,bt.path),children:[s.jsx(M,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:cs}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:bt.path})]},`project:${bt.id}`)})},"projects"):null),t[106]=ae,t[107]=Ae,t[108]=R,t[109]=$,t[110]=Fe,t[111]=n,t[112]=h,t[113]=v,t[114]=E,t[115]=rt,t[116]=Xe,t[117]=be,t[118]=kt,t[119]=et,t[120]=r,t[121]=y,t[122]=f,t[123]=e,t[124]=Ge,t[125]=ut,t[126]=Y,t[127]=G,t[128]=Z,t[129]=je,t[130]=Ie,t[131]=Ve,t[132]=Je,t[133]=it,t[134]=at,t[135]=Ye,t[136]=vt,t[137]=Ue}else Ge=t[124],ut=t[125],Y=t[126],G=t[127],Z=t[128],je=t[129],Ie=t[130],Ve=t[131],Je=t[132],it=t[133],at=t[134],Ye=t[135],vt=t[136],Ue=t[137];let Pt;t[158]!==yt||t[159]!==e?(Pt=yt?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[158]=yt,t[159]=e,t[160]=Pt):Pt=t[160];let ke;t[161]!==Ge||t[162]!==Z||t[163]!==je||t[164]!==Pt?(ke=s.jsxs(Ge,{children:[Z,je,Pt]}),t[161]=Ge,t[162]=Z,t[163]=je,t[164]=Pt,t[165]=ke):ke=t[165];let xt;t[166]!==ut||t[167]!==Ie||t[168]!==Ve||t[169]!==Je||t[170]!==ke?(xt=s.jsxs(ut,{shouldFilter:Ie,className:Ve,children:[Je,ke]}),t[166]=ut,t[167]=Ie,t[168]=Ve,t[169]=Je,t[170]=ke,t[171]=xt):xt=t[171];let Ct;t[172]!==Y||t[173]!==it||t[174]!==at||t[175]!==xt?(Ct=s.jsx(Y,{className:it,showCloseButton:at,children:xt}),t[172]=Y,t[173]=it,t[174]=at,t[175]=xt,t[176]=Ct):Ct=t[176];let Tt;return t[177]!==G||t[178]!==Ye||t[179]!==vt||t[180]!==Ue||t[181]!==Ct?(Tt=s.jsxs(G,{open:Ye,onOpenChange:vt,children:[Ue,Ct]}),t[177]=G,t[178]=Ye,t[179]=vt,t[180]=Ue,t[181]=Ct,t[182]=Tt):Tt=t[182],Tt};function zS(t){return t.isCommandPaletteOpen}function WS(t){return t.setCommandPaletteOpen}function KS(t){return t.setSettingsDialogOpen}function VS(t){return t.setSettingsPage}function US(t){return t.setSessionSwitcherOpen}function HS(t){return t.toggleSidebar}function GS(t){return t.openContextOverview}function qS(t){return t.openContextSurface}function YS(t){return t.openContextFile}function QS(t){return t.shortcutOverrides}function XS(t){return t.openMultiRunLauncher}function JS(t){return t.setArchivePageOpen}function ZS(t){return t.setProjectContextTab}function e0(t){return t.openNewSessionDraft}function t0(t){return t.setCurrentSession}function s0(t){return t.currentSessionId}function n0(t){return t.toggle}function r0(t){return t.currentDirectory}function o0(t){return t.getActiveProject()}function i0(t){return t.projects}function a0(t){return t.searchFiles}function l0(t){return t.ensureStatus}function c0(){ju()}function d0(){fn.requestDirectoryDialog()}function u0(){Xp.invoke("cycle_theme")}function f0(){ku()}function m0(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function h0(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function p0(t){return t.routingFeatureAvailable}function g0(t){return t.slug!=="home"}function x0(t){return!Up(t)}function b0(t){return t.worktreeMetadata}function y0(t){return{path:la(t.path),name:t.name,relativePath:t.relativePath}}function w0(t){return!t.secondary}function v0(t){return{item:t,score:0}}function S0(t){return t.searchText}function j0(t){return t.searchText}function k0(t){return{item:t,score:0}}function C0(t){return t.title||""}function N0(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function A0(t){return t.searchText}function D0(t){return t.item}function P0(t){return t.item}function I0(t){return t.item}function T0(t){return t.item}function E0(t){return t.item}function R0(t){return t.length?t[0].score:1/0}function M0(t,e){return t.score-e.score}function O0(t){return t.key}function B0(t){return s.jsxs(Lr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const Tc=(t,e,n)=>er(Jr(t,e),n),F0=()=>{const t=Ze.c(74),{t:e}=jt(),n=Pe(_0),r=Pe(L0),i=Pe($0);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=$n(),t[0]=o):o=t[0];const l=o;let a,d,u,h,f,x,b,w,v,y,m,p;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const N=[{categoryKey:"helpDialog.section.navigationCommands",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[er("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${er(Li("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${er(Li("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];u=ys,m=n,p=r,d=ws,v="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let R;t[17]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(M,{name:"command",className:"h-5 w-5"}),t[17]=R):R=t[17];let E;t[18]!==e?(E=e("helpDialog.title"),t[18]=e,t[19]=E):E=t[19];let X;t[20]!==E?(X=s.jsxs(Ps,{className:"flex items-center gap-2",children:[R,E]}),t[20]=E,t[21]=X):X=t[21];let J;t[22]!==e?(J=e("helpDialog.description"),t[22]=e,t[23]=J):J=t[23];let re;t[24]!==J?(re=s.jsx(Is,{children:J}),t[24]=J,t[25]=re):re=t[25],t[26]!==X||t[27]!==re?(y=s.jsxs(Vs,{children:[X,re]}),t[26]=X,t[27]=re,t[28]=y):y=t[28],a=yn,x="flex-1 min-h-0 mt-3",b="pr-1",w=!0,h="space-y-4",f=N.map(fe=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(fe.categoryKey)}),s.jsx("div",{className:"space-y-1",children:fe.items.filter(ne=>!(l&&ne.id==="toggle_prompt_navigator")).map(ne=>{const te=ne.id?Jp(ne.id):void 0,ue=ne.descriptionKey??(te?.customizable?te.settingsLabelKey:void 0);if(!ue||ne.id&&!Jr(ne.id,i))return null;const Se=ne.id?Tc(ne.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(ne.keys)?ne.keys:ne.keys.split(" / ");return s.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[ne.icon&&s.jsx(M,{name:ne.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(ue)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(Se)?Se:[Se]).map((we,ye)=>s.jsxs(c.Fragment,{children:[ye>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:we})]},`${we}-${ye}`))})]},ne.id||ue)})})]},fe.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=d,t[7]=u,t[8]=h,t[9]=f,t[10]=x,t[11]=b,t[12]=w,t[13]=v,t[14]=y,t[15]=m,t[16]=p}else a=t[5],d=t[6],u=t[7],h=t[8],f=t[9],x=t[10],b=t[11],w=t[12],v=t[13],y=t[14],m=t[15],p=t[16];let S;t[29]!==h||t[30]!==f?(S=s.jsx("div",{className:h,children:f}),t[29]=h,t[30]=f,t[31]=S):S=t[31];let g;t[32]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(M,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[32]=g):g=t[32];let C;t[33]!==e?(C=e("helpDialog.proTips.title"),t[33]=e,t[34]=C):C=t[34];let k;t[35]!==C?(k=s.jsx("p",{className:"font-medium mb-1",children:C}),t[35]=C,t[36]=k):k=t[36];let j;t[37]!==i||t[38]!==e?(j=e("helpDialog.proTips.commandPalette",{shortcut:Tc("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[37]=i,t[38]=e,t[39]=j):j=t[39];let D;t[40]!==j?(D=s.jsxs("li",{children:["• ",j]}),t[40]=j,t[41]=D):D=t[41];let I;t[42]!==e?(I=e("helpDialog.proTips.recentSessions"),t[42]=e,t[43]=I):I=t[43];let A;t[44]!==I?(A=s.jsxs("li",{children:["• ",I]}),t[44]=I,t[45]=A):A=t[45];let P;t[46]!==e?(P=e("helpDialog.proTips.leaderSequences"),t[46]=e,t[47]=P):P=t[47];let T;t[48]!==P?(T=s.jsxs("li",{children:["• ",P]}),t[48]=P,t[49]=T):T=t[49];let L;t[50]!==D||t[51]!==A||t[52]!==T?(L=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[D,A,T]}),t[50]=D,t[51]=A,t[52]=T,t[53]=L):L=t[53];let $;t[54]!==k||t[55]!==L?($=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[g,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[k,L]})]})}),t[54]=k,t[55]=L,t[56]=$):$=t[56];let K;t[57]!==a||t[58]!==S||t[59]!==$||t[60]!==x||t[61]!==b||t[62]!==w?(K=s.jsxs(a,{outerClassName:x,className:b,disableHorizontal:w,children:[S,$]}),t[57]=a,t[58]=S,t[59]=$,t[60]=x,t[61]=b,t[62]=w,t[63]=K):K=t[63];let F;t[64]!==d||t[65]!==K||t[66]!==v||t[67]!==y?(F=s.jsxs(d,{className:v,children:[y,K]}),t[64]=d,t[65]=K,t[66]=v,t[67]=y,t[68]=F):F=t[68];let W;return t[69]!==u||t[70]!==F||t[71]!==m||t[72]!==p?(W=s.jsx(u,{open:m,onOpenChange:p,children:F}),t[69]=u,t[70]=F,t[71]=m,t[72]=p,t[73]=W):W=t[73],W};function _0(t){return t.isHelpDialogOpen}function L0(t){return t.setHelpDialogOpen}function $0(t){return t.shortcutOverrides}const z0=()=>{const t=Ze.c(32),{t:e}=jt(),n=Pe(W0),r=Pe(K0),i=Pe(V0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await gn(i)).ok){Le.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Le.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Ps,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let h;t[9]!==u?(h=s.jsx(Is,{children:u}),t[9]=u,t[10]=h):h=t[10];let f;t[11]!==d||t[12]!==h?(f=s.jsxs(Vs,{children:[d,h]}),t[11]=d,t[12]=h,t[13]=f):f=t[13];let x;t[14]!==e?(x=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=x):x=t[15];let b;t[16]!==l||t[17]!==x?(b=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:x})}),t[16]=l,t[17]=x,t[18]=b):b=t[18];let w;t[19]!==i||t[20]!==e?(w=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=w):w=t[21];let v;t[22]!==w?(v=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:w}),t[22]=w,t[23]=v):v=t[23];let y;t[24]!==f||t[25]!==b||t[26]!==v?(y=s.jsxs(ws,{className:"max-w-2xl",children:[f,b,v]}),t[24]=f,t[25]=b,t[26]=v,t[27]=y):y=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==y?(m=s.jsx(ys,{open:n,onOpenChange:r,children:y}),t[28]=n,t[29]=r,t[30]=y,t[31]=m):m=t[31],m};function W0(t){return t.isOpenCodeStatusDialogOpen}function K0(t){return t.setOpenCodeStatusDialogOpen}function V0(t){return t.openCodeStatusText}const U0=t=>{const e=Ze.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const w=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(w)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let h,f;e[5]!==a||e[6]!==o||e[7]!==i?(h=()=>{if(!a||typeof window>"u")return;const w=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",w),()=>window.removeEventListener("openchamber:sidebar-session-search",w)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=h,e[9]=f):(h=e[8],f=e[9]),c.useEffect(h,f);let x,b;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(x=()=>{if(!a||!r||typeof document>"u")return;const w=v=>{l.current&&(l.current.contains(v.target)||i(!1))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},b=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=x,e[15]=b):(x=e[14],b=e[15]),c.useEffect(x,b)},H0=t=>{const e=Ze.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(G0)),u=[];a.forEach(x=>{const b=d.get(x);b&&(u.push(b),d.delete(x))});const h=[],f=[];return l.forEach(x=>{d.has(x.id)&&(x.isArchivedBucket?f.push(x):h.push(x))}),[...h,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function G0(t){return[t.id,t]}const mo="oc.sessions.projectCollapse",Ec="oc.sessions.groupOrder",Rc="oc.sessions.groupCollapse",Mc=t=>{if(!t)return new Set;try{const e=Ka(jr()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},q0=t=>{if(!t)return new Map;try{const e=qu(jr(),Ka(jr())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},Y0=t=>{const e=Ze.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Do(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>Mc(o.getItem(mo)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>Mc(o.getItem(Rc)),e[2]=u):u=e[2];const[h,f]=c.useState(u);let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=()=>q0(o.getItem(Ec)),e[3]=x):x=e[3];const[b,w]=c.useState(x),v=c.useRef(0),y=c.useRef(!1),m=c.useRef(!1),p=c.useRef(null),S=c.useRef(null);let g;e[4]!==n?(g=()=>{if(n)return;const ye=S.current;if(S.current=null,p.current=null,!ye)return;const{projects:Ae}=Ht.getState(),pe=Ae.map(O=>({...O,sidebarCollapsed:ye.has(O.id)}));Br({projects:pe}).catch(Q0)},e[4]=n,e[5]=g):g=e[5];const C=g;let k;e[6]!==C||e[7]!==n?(k=ye=>{!globalThis.window||n||(S.current=ye,p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{C()},700))},e[6]=C,e[7]=n,e[8]=k):k=e[8];const j=k;let D,I;e[9]===Symbol.for("react.memo_cache_sentinel")?(D=()=>()=>{globalThis.window&&p.current!==null&&window.clearTimeout(p.current),p.current=null,S.current=null},I=[],e[9]=D,e[10]=I):(D=e[9],I=e[10]),c.useEffect(D,I);let A,P;e[11]!==b?(P=()=>{if(m.current)try{o.setItem(Ec,JSON.stringify(Object.fromEntries(b.entries())))}catch{}},A=[b,o],e[11]=b,e[12]=A,e[13]=P):(A=e[12],P=e[13]),c.useEffect(P,A);let T,L;e[14]!==h?(T=()=>{if(y.current)try{o.setItem(Rc,JSON.stringify(Array.from(h)))}catch{}},L=[h,o],e[14]=h,e[15]=T,e[16]=L):(T=e[15],L=e[16]),c.useEffect(T,L);let $;e[17]!==r||e[18]!==j?($=()=>{v.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const ye=new Set(r.map(X0));try{o.setItem(mo,JSON.stringify(Array.from(ye)))}catch{}return j(ye),ye})},e[17]=r,e[18]=j,e[19]=$):$=e[19];const K=$;let F;e[20]!==j?(F=()=>{v.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const ye=new Set;try{o.setItem(mo,JSON.stringify([]))}catch{}return j(ye),ye})},e[20]=j,e[21]=F):F=e[21];const W=F;let N;e[22]!==j?(N=ye=>{v.current=Date.now()+150,d(Ae=>{const pe=new Set(Ae);pe.has(ye)?pe.delete(ye):pe.add(ye);try{o.setItem(mo,JSON.stringify(Array.from(pe)))}catch{}return j(pe),pe})},e[22]=j,e[23]=N):N=e[23];const R=N;let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=ye=>{y.current=!0,f(Ae=>{const pe=new Set(Ae);return pe.has(ye)?pe.delete(ye):pe.add(ye),pe})},e[24]=E):E=e[24];const X=E;let J;e[25]===Symbol.for("react.memo_cache_sentinel")?(J=ye=>{m.current=!0,w(ye)},e[25]=J):J=e[25];const re=J,{getOrderedGroups:fe}=H0(b);let ne;e[26]!==h||e[27]!==a||e[28]!==b?(ne={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:b},e[26]=h,e[27]=a,e[28]=b,e[29]=ne):ne=e[29];const te=ne;let ue;e[30]!==K||e[31]!==W||e[32]!==fe||e[33]!==j||e[34]!==R?(ue={setCollapsedProjects:d,toggleProject:R,collapseAllProjects:K,expandAllProjects:W,scheduleCollapsedProjectsPersist:j,setCollapsedGroups:f,toggleGroup:X,setGroupOrderByProject:re,getOrderedGroups:fe},e[30]=K,e[31]=W,e[32]=fe,e[33]=j,e[34]=R,e[35]=ue):ue=e[35];const Se=ue;let we;return e[36]!==Se||e[37]!==te?(we={state:te,actions:Se},e[36]=Se,e[37]=te,e[38]=we):we=e[38],we};function Q0(){}function X0(t){return t.id}const J0=5*6e4,Z0=t=>{const e=Ze.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=vn(),u=Tn(e2);let h,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(k=>{$i(()=>u(k.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=h,e[6]=f):(h=e[5],f=e[6]),c.useEffect(h,f);let x,b;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(x=()=>{if(!a)return;const k=new Map;n.forEach(j=>{k.set(j.id,i.get(j.normalizedPath)?.isGitRepo??null)}),o(k)},b=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=x,e[12]=b):(x=e[11],b=e[12]),c.useEffect(x,b);let w;if(e[13]!==i||e[14]!==n){let k;e[16]!==i?(k=j=>{const D=i.get(j.normalizedPath)?.branch??"";return`${j.id}:${D}`},e[16]=i,e[17]=k):k=e[17],w=n.map(k).join("|"),e[13]=i,e[14]=n,e[15]=w}else w=e[15];const v=w;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=new Map,e[18]=y):y=e[18];const m=c.useRef(y);let p;e[19]===Symbol.for("react.memo_cache_sentinel")?(p=new Map,e[19]=p):p=e[19];const S=c.useRef(p);let g;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(g=()=>{if(!a)return;let k=!1;const j=setTimeout(()=>{(async()=>{const I=new Set(n.map(t2));for(const K of m.current.keys())I.has(K)||(m.current.delete(K),S.current.delete(K));const A=Date.now(),P=n.filter(K=>{const F=i.get(K.normalizedPath);if(F?.isGitRepo===!1)return m.current.delete(K.id),S.current.delete(K.id),!1;if(F?.isGitRepo!==!0||F.branch===null)return!1;const W=F.branch.trim(),N=`${K.normalizedPath}\0${W}`,R=m.current.get(K.id);if(R===N){const E=S.current.get(K.id);return E&&(E.at=A),!1}return!(R!==void 0&&A-(S.current.get(K.id)?.at??0)<J0)});if(P.length===0)return;const T=await Zp(P,2,async K=>{const F=i.get(K.normalizedPath)?.branch?.trim()??"",W=`${K.normalizedPath}\0${F}`,N=await $i(()=>Aa(K.normalizedPath,F?{knownBranch:F}:void 0)).catch(s2);return{id:K.id,inputKey:W,branch:N}});if(k)return;const L=T.filter(n2);if(L.length===0)return;const $=Date.now();l(K=>{const F=new Map(K);return L.forEach(W=>{const{id:N,branch:R}=W;R&&F.set(N,R)}),F}),L.forEach(K=>{const{id:F,inputKey:W,branch:N}=K;m.current.set(F,W),N&&S.current.set(F,{branch:N,at:$})})})()},150);return()=>{k=!0,clearTimeout(j)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=g):g=e[24];let C;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==v||e[29]!==l?(C=[a,n,v,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=v,e[29]=l,e[30]=C):C=e[30],c.useEffect(g,C)};function e2(t){return t.ensureStatus}function t2(t){return t.id}function s2(){return null}function n2(t){return t.branch}const r2=t=>{const e=Ze.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(Ah,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(ws,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(yn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(ys,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function o2(t){const e=Ze.c(218),{t:n}=jt(),r=Cu(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenMultiRun:u,canOpenMultiRun:h,onOpenArchive:f,headerActionIconClass:x,headerActionButtonClass:b,isSessionSearchOpen:w,setIsSessionSearchOpen:v,sessionSearchInputRef:y,sessionSearchQuery:m,setSessionSearchQuery:p,hasSessionSearchQuery:S,searchMatchCount:g,collapseAllProjects:C,expandAllProjects:k}=t,j=fs(y2),D=fs(b2),I=us(x2),A=us(g2),P=us(p2),T=us(h2),L=us(m2),$=us(f2),K=us(u2),F=us(d2),W=us(c2),N=us(l2),R=o&&W==="single";if(i)return null;let E;e[0]!==b?(E=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=b,e[1]=E):E=e[1];let X;e[2]!==n?(X=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=X):X=e[3];let J;e[4]!==x?(J=s.jsx(M,{name:"folder-add",className:x}),e[4]=x,e[5]=J):J=e[5];let re;e[6]!==a||e[7]!==E||e[8]!==X||e[9]!==J?(re=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:E,"aria-label":X,children:J})}),e[6]=a,e[7]=E,e[8]=X,e[9]=J,e[10]=re):re=e[10];let fe;e[11]!==n?(fe=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=fe):fe=e[12];let ne;e[13]!==fe?(ne=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:fe})}),e[13]=fe,e[14]=ne):ne=e[14];let te;e[15]!==re||e[16]!==ne?(te=s.jsxs(Nt,{children:[re,ne]}),e[15]=re,e[16]=ne,e[17]=te):te=e[17];let ue;e[18]!==b?(ue=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=b,e[19]=ue):ue=e[19];let Se;e[20]!==n?(Se=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=Se):Se=e[21];let we;e[22]!==x?(we=s.jsx(M,{name:"calendar-schedule",className:x}),e[22]=x,e[23]=we):we=e[23];let ye;e[24]!==d||e[25]!==ue||e[26]!==Se||e[27]!==we?(ye=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:ue,"aria-label":Se,children:we})}),e[24]=d,e[25]=ue,e[26]=Se,e[27]=we,e[28]=ye):ye=e[28];let Ae;e[29]!==n?(Ae=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=Ae):Ae=e[30];let pe;e[31]!==Ae?(pe=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ae})}),e[31]=Ae,e[32]=pe):pe=e[32];let O;e[33]!==ye||e[34]!==pe?(O=s.jsxs(Nt,{children:[ye,pe]}),e[33]=ye,e[34]=pe,e[35]=O):O=e[35];let Q;e[36]!==b?(Q=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=b,e[37]=Q):Q=e[37];let le;e[38]!==n?(le=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=le):le=e[39];const H=!h;let me;e[40]!==x?(me=s.jsx(sg,{className:x}),e[40]=x,e[41]=me):me=e[41];let ge;e[42]!==u||e[43]!==Q||e[44]!==le||e[45]!==H||e[46]!==me?(ge=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:Q,"aria-label":le,disabled:H,children:me})}),e[42]=u,e[43]=Q,e[44]=le,e[45]=H,e[46]=me,e[47]=ge):ge=e[47];let oe;e[48]!==n?(oe=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=oe):oe=e[49];let de;e[50]!==oe?(de=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:oe})}),e[50]=oe,e[51]=de):de=e[51];let _;e[52]!==ge||e[53]!==de?(_=s.jsxs(Nt,{children:[ge,de]}),e[52]=ge,e[53]=de,e[54]=_):_=e[54];let B;e[55]!==b?(B=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=b,e[56]=B):B=e[56];let he;e[57]!==n?(he=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=he):he=e[58];let ve;e[59]!==x?(ve=s.jsx(M,{name:"archive",className:x}),e[59]=x,e[60]=ve):ve=e[60];let Re;e[61]!==f||e[62]!==B||e[63]!==he||e[64]!==ve?(Re=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:B,"aria-label":he,children:ve})}),e[61]=f,e[62]=B,e[63]=he,e[64]=ve,e[65]=Re):Re=e[65];let ce;e[66]!==n?(ce=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=ce):ce=e[67];let se;e[68]!==ce?(se=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ce})}),e[68]=ce,e[69]=se):se=e[69];let q;e[70]!==Re||e[71]!==se?(q=s.jsxs(Nt,{children:[Re,se]}),e[70]=Re,e[71]=se,e[72]=q):q=e[72];let z;e[73]!==r||e[74]!==x||e[75]!==n?(z=r.length>0&&s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(M,{name:"apps",className:x})})}),s.jsxs(Ws,{align:"start",children:[s.jsx(Fr,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(a2)]})]}),e[73]=r,e[74]=x,e[75]=n,e[76]=z):z=e[76];let ee;e[77]!==O||e[78]!==_||e[79]!==q||e[80]!==z||e[81]!==te?(ee=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[te,O,_,q,z]}),e[77]=O,e[78]=_,e[79]=q,e[80]=z,e[81]=te,e[82]=ee):ee=e[82];let ae;e[83]!==v?(ae=()=>v(i2),e[83]=v,e[84]=ae):ae=e[84];let Ne;e[85]!==b?(Ne=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[85]=b,e[86]=Ne):Ne=e[86];let Ce;e[87]!==n?(Ce=n("sessions.sidebar.header.actions.searchSessions"),e[87]=n,e[88]=Ce):Ce=e[88];let We;e[89]!==x?(We=s.jsx(M,{name:"search",className:x}),e[89]=x,e[90]=We):We=e[90];let Ee;e[91]!==w||e[92]!==ae||e[93]!==Ne||e[94]!==Ce||e[95]!==We?(Ee=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ae,className:Ne,"aria-label":Ce,"aria-expanded":w,children:We})}),e[91]=w,e[92]=ae,e[93]=Ne,e[94]=Ce,e[95]=We,e[96]=Ee):Ee=e[96];let xe;e[97]!==n?(xe=n("sessions.sidebar.header.actions.searchSessions"),e[97]=n,e[98]=xe):xe=e[98];let $e;e[99]!==xe?($e=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:xe})}),e[99]=xe,e[100]=$e):$e=e[100];let V;e[101]!==Ee||e[102]!==$e?(V=s.jsxs(Nt,{children:[Ee,$e]}),e[101]=Ee,e[102]=$e,e[103]=V):V=e[103];const De=j&&"bg-interactive-hover text-primary";let Fe;e[104]!==b||e[105]!==De?(Fe=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent",De),e[104]=b,e[105]=De,e[106]=Fe):Fe=e[106];let _e;e[107]!==j||e[108]!==n?(_e=n(j?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[107]=j,e[108]=n,e[109]=_e):_e=e[109];let rt;e[110]!==x?(rt=s.jsx(M,{name:"checkbox-multiple",className:x}),e[110]=x,e[111]=rt):rt=e[111];let ct;e[112]!==j||e[113]!==Fe||e[114]!==_e||e[115]!==rt||e[116]!==D?(ct=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:D,className:Fe,"aria-label":_e,"aria-pressed":j,children:rt})}),e[112]=j,e[113]=Fe,e[114]=_e,e[115]=rt,e[116]=D,e[117]=ct):ct=e[117];let et;e[118]!==j||e[119]!==n?(et=n(j?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[118]=j,e[119]=n,e[120]=et):et=e[120];let pt;e[121]!==et?(pt=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:et})}),e[121]=et,e[122]=pt):pt=e[122];let kt;e[123]!==ct||e[124]!==pt?(kt=s.jsxs(Nt,{children:[ct,pt]}),e[123]=ct,e[124]=pt,e[125]=kt):kt=e[125];let wt;e[126]!==b?(wt=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[126]=b,e[127]=wt):wt=e[127];let Xe;e[128]!==n?(Xe=n("sessions.sidebar.header.displayMode.label"),e[128]=n,e[129]=Xe):Xe=e[129];let yt;e[130]!==x?(yt=s.jsx(M,{name:"equalizer-2",className:x}),e[130]=x,e[131]=yt):yt=e[131];let Rt;e[132]!==wt||e[133]!==Xe||e[134]!==yt?(Rt=s.jsx(At,{asChild:!0,children:s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:wt,"aria-label":Xe,children:yt})})}),e[132]=wt,e[133]=Xe,e[134]=yt,e[135]=Rt):Rt=e[135];let be;e[136]!==n?(be=n("sessions.sidebar.header.displayMode.label"),e[136]=n,e[137]=be):be=e[137];let Ge;e[138]!==be?(Ge=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:be})}),e[138]=be,e[139]=Ge):Ge=e[139];let ut;e[140]!==Rt||e[141]!==Ge?(ut=s.jsxs(Nt,{children:[Rt,Ge]}),e[140]=Rt,e[141]=Ge,e[142]=ut):ut=e[142];let Y;e[143]!==n?(Y=n("sessions.sidebar.header.actions.sortProjects"),e[143]=n,e[144]=Y):Y=e[144];let G;e[145]!==Y?(G=s.jsx(Fr,{children:Y}),e[145]=Y,e[146]=G):G=e[146];let Z;e[147]!==P||e[148]!==T||e[149]!==n?(Z=[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(Ke=>{const[He,nt]=Ke;return s.jsxs(Kt,{onClick:()=>{T(He),Br({sidebarProjectSortOrder:He})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(nt)}),P===He?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},He)}),e[147]=P,e[148]=T,e[149]=n,e[150]=Z):Z=e[150];let je;e[151]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx(Os,{}),e[151]=je):je=e[151];let Ie;e[152]!==W||e[153]!==N||e[154]!==o||e[155]!==n?(Ie=o?s.jsxs(s.Fragment,{children:[s.jsx(Fr,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(Ke=>{const[He,nt]=Ke;return s.jsxs(Kt,{onClick:()=>{N(He),Br({sidebarProjectDisplayMode:He})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(nt)}),W===He?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},He)}),s.jsx(Os,{})]}):null,e[152]=W,e[153]=N,e[154]=o,e[155]=n,e[156]=Ie):Ie=e[156];let Ve;e[157]!==n?(Ve=n("sessions.sidebar.header.grouping.label"),e[157]=n,e[158]=Ve):Ve=e[158];let Je;e[159]!==Ve?(Je=s.jsx(Fr,{children:Ve}),e[159]=Ve,e[160]=Je):Je=e[160];let it;e[161]!==L||e[162]!==$||e[163]!==n?(it=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(Ke=>{const[He,nt]=Ke;return s.jsxs(Kt,{onClick:()=>{$(He),Br({sidebarSessionGroupingMode:He})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(nt)}),L===He?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},He)}),e[161]=L,e[162]=$,e[163]=n,e[164]=it):it=e[164];let at;e[165]===Symbol.for("react.memo_cache_sentinel")?(at=s.jsx(Os,{}),e[165]=at):at=e[165];let Ye;e[166]!==R||e[167]!==l||e[168]!==I||e[169]!==n||e[170]!==A?(Ye=l&&!R?s.jsxs(Kt,{onClick:()=>{A(),Br({sidebarShowRecentSection:!I})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),I?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[166]=R,e[167]=l,e[168]=I,e[169]=n,e[170]=A,e[171]=Ye):Ye=e[171];let vt;e[172]!==n?(vt=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[172]=n,e[173]=vt):vt=e[173];let Ue;e[174]!==vt?(Ue=s.jsx("span",{children:vt}),e[174]=vt,e[175]=Ue):Ue=e[175];let Pt;e[176]!==K?(Pt=K?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null,e[176]=K,e[177]=Pt):Pt=e[177];let ke;e[178]!==Ue||e[179]!==Pt||e[180]!==F?(ke=s.jsxs(Kt,{onClick:F,className:"flex items-center justify-between",children:[Ue,Pt]}),e[178]=Ue,e[179]=Pt,e[180]=F,e[181]=ke):ke=e[181];let xt;e[182]!==C||e[183]!==k||e[184]!==R||e[185]!==n?(xt=R?null:s.jsxs(s.Fragment,{children:[s.jsx(Os,{}),s.jsxs(Kt,{onClick:C,className:"flex items-center gap-2",children:[s.jsx(M,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Kt,{onClick:k,className:"flex items-center gap-2",children:[s.jsx(M,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}),e[182]=C,e[183]=k,e[184]=R,e[185]=n,e[186]=xt):xt=e[186];let Ct;e[187]!==G||e[188]!==Z||e[189]!==Ie||e[190]!==Je||e[191]!==it||e[192]!==Ye||e[193]!==ke||e[194]!==xt?(Ct=s.jsxs(Ws,{align:"end",className:"min-w-[180px]",children:[G,Z,je,Ie,Je,it,at,Ye,ke,xt]}),e[187]=G,e[188]=Z,e[189]=Ie,e[190]=Je,e[191]=it,e[192]=Ye,e[193]=ke,e[194]=xt,e[195]=Ct):Ct=e[195];let Tt;e[196]!==ut||e[197]!==Ct?(Tt=s.jsxs(Ks,{children:[ut,Ct]}),e[196]=ut,e[197]=Ct,e[198]=Tt):Tt=e[198];let qe;e[199]!==V||e[200]!==kt||e[201]!==Tt?(qe=s.jsxs("div",{className:"flex items-center gap-1.5",children:[V,kt,Tt]}),e[199]=V,e[200]=kt,e[201]=Tt,e[202]=qe):qe=e[202];let ze;e[203]!==ee||e[204]!==qe?(ze=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[ee,qe]}),e[203]=ee,e[204]=qe,e[205]=ze):ze=e[205];let ft;e[206]!==S||e[207]!==w||e[208]!==g||e[209]!==y||e[210]!==m||e[211]!==v||e[212]!==p||e[213]!==n?(ft=w?s.jsxs("div",{className:"pb-1",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80",children:[S?s.jsx("span",{children:g===1?n("sessions.sidebar.header.search.matchCountSingle",{count:g}):n("sessions.sidebar.header.search.matchCountPlural",{count:g})}):s.jsx("span",{}),s.jsx("span",{children:n("sessions.sidebar.header.search.escapeHint")})]}),s.jsx(Vd,{inputRef:y,value:m,onSearch:p,onClose:()=>v(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear")})]}):null,e[206]=S,e[207]=w,e[208]=g,e[209]=y,e[210]=m,e[211]=v,e[212]=p,e[213]=n,e[214]=ft):ft=e[214];let Be;return e[215]!==ze||e[216]!==ft?(Be=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[ze,ft]})}),e[215]=ze,e[216]=ft,e[217]=Be):Be=e[217],Be}function i2(t){return!t}function a2(t){return s.jsxs(Kt,{onSelect:()=>Pe.getState().setOpenGuestPage(t.id),children:[s.jsx(Xr,{icon:tg(t.icon),iconSrc:eg(t.id,t.icon,ya().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function l2(t){return t.setProjectDisplayMode}function c2(t){return t.projectDisplayMode}function d2(t){return t.toggleStickyZoneHeaders}function u2(t){return t.stickyZoneHeaders}function f2(t){return t.setSessionGroupingMode}function m2(t){return t.sessionGroupingMode}function h2(t){return t.setProjectSortOrder}function p2(t){return t.projectSortOrder}function g2(t){return t.toggleRecentSection}function x2(t){return t.showRecentSection}function b2(t){return t.toggleMode}function y2(t){return t.enabled}function w2(t){const e=Ze.c(8),{t:n}=jt(),r=t.onNewSession;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(M,{name:"chat-new",className:"h-4 w-4 flex-shrink-0"}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("sessions.sidebar.header.actions.newSession"),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==o?(l=s.jsx("span",{className:"truncate",children:o}),e[3]=o,e[4]=l):l=e[4];let a;return e[5]!==t.onNewSession||e[6]!==l?(a=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 pt-1.5",children:s.jsxs("button",{type:"button",onClick:r,className:"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 text-left typography-ui-label font-normal text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[i,l]})}),e[5]=t.onNewSession,e[6]=l,e[7]=a):a=e[7],a}const wi="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";function v2(t){const e=Ze.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:i,onOpenUpdate:o,showRuntimeButtons:l,showUpdateButton:a}=t,d=l===void 0?!0:l,u=a===void 0?!0:a,{t:h}=jt();if(!d&&!u)return null;let f;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==d||e[4]!==h?(f=d?s.jsxs(s.Fragment,{children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:wi,"aria-label":h("sessions.sidebar.footer.actions.settings"),children:s.jsx(M,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:wi,"aria-label":h("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(M,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:wi,"aria-label":h("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(M,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=i,e[1]=n,e[2]=r,e[3]=d,e[4]=h,e[5]=f):f=e[5];let x;e[6]!==o||e[7]!==u||e[8]!==h?(x=u?s.jsx(dt,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:o,children:h("sessions.sidebar.footer.actions.update")}):null,e[6]=o,e[7]=u,e[8]=h,e[9]=x):x=e[9];let b;return e[10]!==f||e[11]!==x?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[f,x]}),e[10]=f,e[11]=x,e[12]=b):b=e[12],b}const S2=t=>{for(const e of t.sessions.values())if(e.tabs.some(Od))return!0;return!1},j2=()=>{const t=Ze.c(4),{terminal:e}=vn(),n=Ot(S2);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=k2,l=C2;if(n)return Ii(e,"",l,o);let a=N2;return a=Ii(e,"",l,d=>{o(d),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function k2(t){const e=Ot.getState(),n=Dh(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function C2(){return new Map(Ot.getState().actionMutationRevisions)}function N2(){}const A2=t=>{const e=Ze.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:h,addSessionToFolder:f}=t,x=r===void 0?!0:r;let b,w;e[0]!==f||e[1]!==h||e[2]!==x||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(b=()=>{!x||o||!l||a||n.forEach(v=>{if(d.has(v.normalizedPath))return;const y=Nu(v.normalizedPath),m=i.archivedSessionsByProject.get(v.id)??[],p=u[y]??[],S=new Map(p.map(D2));m.forEach(g=>{const C=ng(g,v.normalizedPath),k=C.toLowerCase();let j=S.get(k);j||(j=h(y,C),S.set(k,j)),j.sessionIds.includes(g.id)||f(y,j.id,g.id)})})},w=[n,x,i,o,l,a,d,u,h,f],e[0]=f,e[1]=h,e[2]=x,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=b,e[11]=w):(b=e[10],w=e[11]),c.useEffect(b,w)};function D2(t){return[t.name.toLowerCase(),t]}function P2({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([h,f])=>h!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const I2=t=>{const e=Ze.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:h,openNewSessionDraft:f,setSessionSwitcherOpen:x}=t;let b,w;if(e[0]!==n){w=new Map,b=new Map;const k=(j,D,I,A)=>{w.has(j)||w.set(j,new Map);const P=w.get(j);A.forEach(T=>{const L=ht(T.worktree?.path??T.session.directory??I??D);P.set(T.session.id,{directory:L}),b.has(j)||b.set(j,{id:T.session.id,directory:L}),T.children.length>0&&k(j,D,L,T.children)})};n.forEach(j=>{j.groups.forEach(D=>{k(j.project.id,j.project.normalizedPath,D.directory,D.sessions)})}),e[0]=n,e[1]=b,e[2]=w}else b=e[1],w=e[2];let v;e[3]!==b||e[4]!==w?(v={metaByProject:w,firstSessionByProject:b},e[3]=b,e[4]=w,e[5]=v):v=e[5];const y=v,m=c.useRef(null);let p,S;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==h||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==y||e[16]!==o||e[17]!==x?(p=()=>{if(!r||u||Pe.getState().isNewWorktreeDialogOpen||m.current===r)return;const k=n.find(A=>A.project.id===r);if(!k)return;const j=y.metaByProject.get(r);if(l&&j&&j.has(l)){m.current=r,o(A=>{if(A.get(r)===l)return A;const P=new Map(A);return P.set(r,l),P});return}const D=P2({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:j,metaByProject:y.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:y.firstSessionByProject.get(r)?.id??null});if(D.kind==="preserve-current"){a===r&&(m.current=r);return}if(m.current=r,D.kind==="open-draft"){h&&x(!1),f({selectedProjectId:k.project.id,directoryOverride:k.project.normalizedPath});return}if(D.kind!=="select-session")return;const I=j?.get(D.sessionId)?.directory??null;d(D.sessionId,I)},S=[r,i,l,a,d,u,h,f,n,y,x,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=h,e[12]=u,e[13]=f,e[14]=n,e[15]=y,e[16]=o,e[17]=x,e[18]=p,e[19]=S):(p=e[18],S=e[19]),c.useLayoutEffect(p,S);let g,C;e[20]!==r||e[21]!==l||e[22]!==y||e[23]!==o?(g=()=>{if(!r||!l)return;const k=y.metaByProject.get(r);!k||!k.has(l)||o(j=>{if(j.get(r)===l)return j;const D=new Map(j);return D.set(r,l),D})},C=[r,l,y,o],e[20]=r,e[21]=l,e[22]=y,e[23]=o,e[24]=g,e[25]=C):(g=e[24],C=e[25]),c.useEffect(g,C)},T2=t=>{const e=Ze.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=tt(E2),a=tt(R2);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let h;e[8]!==r?(h=()=>new Map(r),e[8]=r,e[9]=h):h=e[9];const[f,x]=c.useState(h);let b;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(b={...n,activeSessionByProject:f,setActiveSessionByProject:x,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=b):b=e[15],I2(b);let w,v;return e[16]!==f||e[17]!==i?(w=()=>{i(f)},v=[f,i],e[16]=f,e[17]=i,e[18]=w,e[19]=v):(w=e[18],v=e[19]),c.useEffect(w,v),null};function E2(t){return t.currentSessionId}function R2(t){return!!t.newSessionDraft?.open}const M2=(t,e)=>t?e.kind!==t.kind?e.kind==="project":e.projectRoot.length!==t.projectRoot.length?e.projectRoot.length>t.projectRoot.length:e.projectId.localeCompare(t.projectId)<0:!0,Oc=(t,e,n)=>{M2(t.get(e),n)&&t.set(e,n)},O2=t=>{const e=t;return ht(e.directory)??ht(e.project?.worktree)},B2=(t,e,n,r,i=[])=>{const o=new Map,l=new Map;for(const w of e){const v=ht(w.normalizedPath);if(!v)continue;const y=l.get(v);(!y||w.id.localeCompare(y.id)<0)&&l.set(v,w),Oc(o,v,{projectId:w.id,projectRoot:v,scopeDirectory:v,kind:"project"})}if(!r)for(const[w,v]of n){const y=ht(w),m=y?l.get(y):void 0;if(!(!m||!y))for(const p of v){const S=ht(p.path);S&&Oc(o,S,{projectId:m.id,projectRoot:y,scopeDirectory:S,kind:"worktree"})}}const a=new Map,d=new Map,u=new Map,h=new Map,f=new Map,x=w=>{if(!w)return null;if(a.has(w))return a.get(w)??null;if(r){const p=o.get(w)??null;return a.set(w,p),p}const v=[];let y=w,m=null;for(;y;){if(a.has(y)){m=a.get(y)??null;break}if(v.push(y),m=o.get(y)??null,m)break;y=Xm(y)}for(const p of v)a.set(p,m);return m},b=(w,v,y)=>{for(const m of w){const p=x(O2(m));if(!p)continue;d.set(m.id,p);const S=v.get(p.projectId);if(S?S.push(m):v.set(p.projectId,[m]),!y)continue;const g=y.get(p.scopeDirectory);g?g.add(m.id):y.set(p.scopeDirectory,new Set([m.id]))}};return b(t,u,f),b(i,h),{bySessionId:d,sessionsByProject:u,archivedSessionsByProject:h,sessionsByScope:f,directoryResolutions:a.size}},F2=t=>{const e=Ze.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},Yn=(t,e)=>`${t}\0${e}`,vr=(t,e)=>t??Ra(e)??ht(e??null),Yr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??ht(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},Za=t=>t.startsWith("__archived__:"),_2=(t,e)=>t.map(n=>{const r=ht(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
878
|
+
`)},mv=t=>{const e=Ze.c(7),{t:n}=jt(),r=tt(pv),i=tt(gv),o=Oi(xv),l=Mp(bv);let a;return e[0]!==l||e[1]!==o||e[2]!==r||e[3]!==t||e[4]!==i||e[5]!==n?(a=async d=>{const u=r??(i?"draft":null);if(!u){Le.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(d.screenshot)try{await l(d.screenshot),h=!0}catch{h=!1}o({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:fv({payload:d.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Le.success(n("contextPanel.browser.annotate.attached"))},e[0]=l,e[1]=o,e[2]=r,e[3]=t,e[4]=i,e[5]=n,e[6]=a):a=e[6],a},hv=()=>{const t=Ze.c(16),{t:e}=jt();let n;t[0]!==e?(n=e("contextPanel.browser.annotate.tool.element"),t[0]=e,t[1]=n):n=t[1];let r;t[2]!==e?(r=e("contextPanel.browser.annotate.tool.region"),t[2]=e,t[3]=r):r=t[3];let i;t[4]!==e?(i=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=i):i=t[5];let o;t[6]!==e?(o=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=o):o=t[7];let l;t[8]!==e?(l=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=l):l=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==l?(a={select:n,marquee:r,draw:i,commentPlaceholder:o,submit:l},t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=l,t[15]=a):a=t[15],a};function pv(t){return t.currentSessionId}function gv(t){return t.newSessionDraft?.open}function xv(t){return t.addDraft}function bv(t){return t.addAttachedFile}const yv=3e4,wv=3,vv=250,Sv={attempts:0,windowStartedAt:null},jv=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=yv,r=n?0:t.attempts;return r>=wv?null:{delayMs:vv*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},kv=-3,uo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",hr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},Cv=(t,{initialUrl:e,onUrlChange:n})=>{const[r,i]=c.useState(e?{kind:"loading",url:e}:dw),[o,l]=c.useState(e),[a,d]=c.useState(""),[u,h]=c.useState(!1),[f,x]=c.useState(!1),b=c.useRef(n);b.current=n;const w=c.useRef(Sv);return c.useEffect(()=>{if(!t)return;const v=()=>{try{const A=t.getURL();return uo(A)?A:""}catch{return""}},y=()=>{try{h(t.canGoBack()),x(t.canGoForward())}catch{}},m=A=>{uo(A)&&(l(A),b.current(A))},p=()=>{const A=v();i({kind:"loading",url:A})},S=()=>{const A=v();let P="";try{P=t.getTitle()||""}catch{P=""}d(P),m(A),y(),i(T=>T.kind==="failed"&&T.url===A?T:{kind:"ready",url:A,title:P})},g=A=>{const P=hr(A);uo(P.url)&&(m(P.url),y())},C=A=>{const P=hr(A),T=Array.isArray(P.favicons)?P.favicons.find(Boolean):"",L=v();T&&L&&gf.getState().resolve(L,T)},k=A=>{const P=hr(A);typeof P.title=="string"&&d(P.title)},j=A=>{const P=hr(A);if(P.isMainFrame===!1)return;const T=typeof P.errorCode=="number"?P.errorCode:0;T!==kv&&i({kind:"failed",url:uo(P.validatedURL)?P.validatedURL:v(),code:T,description:typeof P.errorDescription=="string"?P.errorDescription:""})};let D=null;const I=()=>{const A=v(),P=jv(w.current,Date.now());if(!P){i({kind:"failed",url:A,code:0,description:"",crashed:!0});return}w.current=P.state,i({kind:"loading",url:A}),D=setTimeout(()=>{D=null;try{t.reload()}catch{i({kind:"failed",url:A,code:0,description:"",crashed:!0})}},P.delayMs)};t.addEventListener("did-start-loading",p),t.addEventListener("did-stop-loading",S),t.addEventListener("did-navigate",g),t.addEventListener("did-navigate-in-page",g),t.addEventListener("page-title-updated",k),t.addEventListener("page-favicon-updated",C),t.addEventListener("did-fail-load",j),t.addEventListener("render-process-gone",I),t.addEventListener("crashed",I);try{!t.isLoading()&&v()&&S()}catch{}return()=>{D!==null&&clearTimeout(D),t.removeEventListener("render-process-gone",I),t.removeEventListener("crashed",I),t.removeEventListener("did-start-loading",p),t.removeEventListener("did-stop-loading",S),t.removeEventListener("did-navigate",g),t.removeEventListener("did-navigate-in-page",g),t.removeEventListener("page-title-updated",k),t.removeEventListener("page-favicon-updated",C),t.removeEventListener("did-fail-load",j)}},[t]),{status:r,url:o,title:a,canGoBack:u,canGoForward:f}},Nv=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,Av=4e4,fo=.5,Dv=-3,Pv=4,Iv="persist:openchamber-browser",Ac=20,Tv=600,Ev=2e4,Rv=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=jt(),{currentTheme:i}=or(),o=c.useRef(null),[l,a]=c.useState(null),d=c.useCallback(ce=>{o.current=ce,a(ce)},[]),u=Pe(ce=>ce.setContextPanelTabTargetPath),h=c.useRef(br(t)),f=h.current!==sn?h.current:"",[x,b]=c.useState(f?null:sn),[w,v]=c.useState(f),[y,m]=c.useState(!1),[p,S]=c.useState(!1),[g,C]=c.useState(0),k=c.useRef(0),[j,D]=c.useState(!1),[I,A]=c.useState(Oo),P=c.useRef(I);P.current=I;const T=c.useRef([]),[L,$]=c.useState("system"),[K,F]=c.useState({width:0,height:0}),W=c.useRef(null),N=c.useRef(null),R=c.useRef(!1),E=c.useRef(Date.now()),X=c.useCallback(ce=>{!ce||ce===sn||!e||!n||u(e,n,ce)},[e,n,u]),J=Cv(l,{initialUrl:f,onUrlChange:c.useCallback(ce=>{const se=Tr(ce);v(se),X(se)},[X])}),[re,fe]=c.useState(null),ne=mv(e),te=hv(),ue=J.status.kind==="loading",Se=wr(jf(e)),we=wr(ce=>ce.recordVisit),ye=wr(ce=>ce.forget);c.useEffect(()=>{J.status.kind==="ready"&&we(e,{url:Tr(J.status.url),title:J.status.title})},[e,J.status,we]);const Ae=c.useMemo(()=>Sf(Se,w),[Se,w]),pe=c.useCallback(ce=>{const se=br(ce);se!==sn&&(v(se),fe(null),vc(se).then(q=>{const z=o.current;if(!z){b(q);return}try{z.loadURL(q)}catch{b(q)}}).catch(q=>{q instanceof Kr&&fe(se)}))},[]);c.useEffect(()=>{if(!f)return;let ce=!0;return vc(f).then(se=>{ce&&b(se)}).catch(se=>{if(ce){if(se instanceof Kr){fe(f),b(sn);return}b(f)}}),()=>{ce=!1}},[]);const O=c.useMemo(()=>({executeJavaScript:async(ce,se)=>{const q=o.current;if(!q)throw new Error("Browser view is not available");return q.executeJavaScript(ce,se)},capturePage:async()=>{const ce=o.current;if(!ce)return null;const se=ce.getWebContentsId();return Number.isFinite(se)?await gr("desktop_browser_capture_page",{webContentsId:se}):null}}),[]),Q=c.useCallback(()=>{if(y){m(!1),jo(O);return}if(!J.url){Le.error(r("contextPanel.browser.annotate.noPage"));return}const ce=kw(i.metadata.variant==="light"?"light":"dark");m(!0),Sw({host:O,theme:ce,labels:te}).then(async se=>{m(!1),se&&await ne(se)}).catch(()=>{m(!1),Le.error(r("contextPanel.browser.annotate.failed"))})},[O,ne,i,y,J.url,te,r]);c.useEffect(()=>{if(!y)return;const ce=se=>{Op(se)||se.key!=="Escape"||(se.preventDefault(),se.stopImmediatePropagation(),m(!1),jo(O))};return window.addEventListener("keydown",ce,!0),()=>window.removeEventListener("keydown",ce,!0)},[O,y]);const le=c.useCallback(async(ce=8e3)=>{const se=Date.now();for(;;){const q=o.current;if(!q)return!1;let z=!1;try{z=q.isLoading()}catch{return!1}if(!z)return!0;if(Date.now()-se>ce)return!1;await new Promise(ee=>setTimeout(ee,120))}},[]),H=c.useCallback(async(ce,se)=>{const q=o.current;if(!q)throw new Error("The browser panel is not ready");const z=()=>{Nc(se.viewport)&&(A(ia(se.viewport)),D(!0))};if(ce==="browser.back"||ce==="browser.forward"){const Ee=ce==="browser.back";if(!(Ee?q.canGoBack():q.canGoForward()))throw new Error(Ee?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");Ee?q.goBack():q.goForward(),await new Promise(V=>setTimeout(V,150)),await le();let $e="";try{$e=q.getTitle()||""}catch{$e=""}return{url:Tr(q.getURL()),title:$e}}if(ce==="browser.capture"){Pe.getState().openContextBrowser(e,q.getURL());const Ee=Date.now()+1200;let xe=0,$e=0;for(;$e<2&&Date.now()<Ee;){const Fe=q.getBoundingClientRect().width;$e=Fe>=2&&Math.abs(Fe-xe)<.5?$e+1:0,xe=Fe,await new Promise(_e=>setTimeout(_e,50))}await new Promise(Fe=>{requestAnimationFrame(()=>requestAnimationFrame(()=>Fe()))}),await le();const V=await O.capturePage();if(!V)throw new Error("The page could not be captured");let De="";try{De=q.getTitle()||""}catch{De=""}return{...V,url:Tr(q.getURL()),title:De,viewport:co(P.current)}}if(ce==="browser.resize"){if(!Nc(se.viewport))throw new Error("viewport is required");return z(),await new Promise(Ee=>setTimeout(Ee,200)),await le(),{viewport:co(ia(se.viewport))}}if(ce==="browser.open"){const Ee=typeof se.url=="string"?se.url:"";if(!Ee)throw new Error("url is required");z(),pe(Ee),await new Promise(V=>setTimeout(V,150));const xe=await le(25e3);let $e="";try{$e=q.getTitle()||""}catch{$e=""}return{url:br(Ee),title:$e,opened:!0,settled:xe,viewport:co(P.current)}}await le();const ee=Ee=>typeof Ee=="string"&&Ee?Ee:void 0,Ne=(()=>{switch(ce){case"browser.snapshot":return Hw({selector:ee(se.selector)});case"browser.click":return Gw({selector:ee(se.selector),text:ee(se.text)});case"browser.type":return qw({selector:String(se.selector??""),value:String(se.value??""),submit:se.submit===!0});case"browser.inspect":return Xw({selector:String(se.selector??"")});case"browser.scroll":return Yw({selector:ee(se.selector),direction:ee(se.direction)});default:return null}})();if(!Ne)throw new Error(`Unsupported browser action: ${ce}`);const Ce=await q.executeJavaScript(Ne,!0);if(!Ce||typeof Ce!="object")throw new Error("The page returned no result");const We=Ce;if(We.ok!==!0)throw new Error(typeof We.error=="string"&&We.error?We.error:"Browser action failed");if(ce==="browser.snapshot"){const Ee=T.current;return{...We,viewport:co(P.current),...Ee.length>0?{consoleProblems:[...Ee]}:{}}}return(ce==="browser.click"||ce==="browser.type"&&se.submit===!0)&&(await new Promise(Ee=>setTimeout(Ee,150)),await le()),Ce},[O,e,pe,le]);c.useEffect(()=>Iw({run:H}),[H]),c.useEffect(()=>{const ce=O;return()=>{jo(ce)}},[O]),c.useEffect(()=>{if(!l)return;const ce=q=>{const z=q;if(typeof z.level!="number"||z.level<2)return;const ee=z.sourceId?`${z.sourceId}${z.line?`:${z.line}`:""}`:"";T.current.push({level:z.level>=3?"error":"warning",message:String(z.message??"").slice(0,400),source:ee}),T.current.length>Ac&&T.current.splice(0,T.current.length-Ac)},se=()=>{T.current=[]};return l.addEventListener("console-message",ce),l.addEventListener("did-start-loading",se),()=>{l.removeEventListener("console-message",ce),l.removeEventListener("did-start-loading",se)}},[l]);const me=c.useRef(new Set),ge=c.useCallback(ce=>{me.current.clear(),pe(ce)},[pe]);c.useEffect(()=>{if(!l)return;const ce=q=>{const z=hr(q),ee=typeof z.url=="string"?z.url:"";!ee||!Sc(ee)||(q.preventDefault(),pe(ee))},se=q=>{const z=hr(q);if(z.isMainFrame===!1||z.errorCode===-3)return;const ee=typeof z.validatedURL=="string"?z.validatedURL:"";!ee||!Sc(ee)||me.current.has(ee)||(me.current.add(ee),pe(ee))};return l.addEventListener("will-navigate",ce),l.addEventListener("did-fail-load",se),()=>{l.removeEventListener("will-navigate",ce),l.removeEventListener("did-fail-load",se)}},[pe,l]),c.useEffect(()=>{if(!l)return;const ce=se=>{const q=se.detail;se.preventDefault(),q?.url&&pe(q.url)};return l.addEventListener("new-window",ce),()=>l.removeEventListener("new-window",ce)},[pe,l]);const oe=c.useCallback(ce=>{const se=Math.min(Pv,Math.max(Dv,ce));k.current=se,C(se);try{o.current?.setZoomLevel(se)}catch{}},[]);c.useEffect(()=>{const ce=se=>{if(!(se instanceof CustomEvent))return;const q=se.detail,z=o.current;!z||document.activeElement!==z||(q==="zoom-in"?oe(k.current+fo):q==="zoom-out"?oe(k.current-fo):q==="zoom-reset"&&oe(0))};return window.addEventListener("openchamber:zoom",ce),()=>window.removeEventListener("openchamber:zoom",ce)},[oe]);const de=c.useCallback(ce=>{gr("desktop_browser_clear_data",{partition:Iv,cookies:ce==="cookies",cache:ce==="cache"}).then(()=>{Le.success(r(ce==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{o.current?.reloadIgnoringCache()}catch{}}).catch(()=>Le.error(r("contextPanel.browser.clearFailed")))},[r]);c.useEffect(()=>{const ce=W.current;if(!ce||typeof ResizeObserver>"u")return;const se=new ResizeObserver(q=>{const z=q[0]?.contentRect;z&&F({width:z.width,height:z.height})});return se.observe(ce),()=>se.disconnect()},[]);const _=c.useCallback(ce=>{$(ce);const se=o.current;if(!se)return;let q=-1;try{q=se.getWebContentsId()}catch{return}gr("desktop_browser_set_color_scheme",{webContentsId:q,scheme:ce}).catch(z=>{$("system"),Le.error(z instanceof Error?z.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),B=c.useCallback(()=>{try{ue?o.current?.stop():o.current?.reload()}catch{}},[ue]),he=J.status;c.useEffect(()=>{const ce=()=>{S(!0);const z=setTimeout(()=>{try{o.current?.reload()}catch{}},Tv);return()=>clearTimeout(z)};if(he.kind==="failed"){if(!sw(he.code,he.url)){S(!1);return}const z=Date.now(),ee=N.current?.url===he.url?N.current:{url:he.url,startedAt:z};if(N.current=ee,z-ee.startedAt>Av){S(!1);return}return ce()}if(he.kind==="loading")return;if(N.current=null,he.kind!=="ready"||!he.url||!kr(he.url)){R.current=!0,S(!1);return}if(R.current||Date.now()-E.current>Ev){R.current=!0,S(!1);return}let se=!1,q=null;return ow(Tr(he.url)).then(z=>{if(!se){if(z===null||z<500){R.current=!0,S(!1);return}q=ce()}}),()=>{se=!0,q?.()}},[he]);const ve=J.status.kind==="failed"&&!p?J.status:null,Re=tv(I,K);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(Af,{address:w,onAddressChange:v,onSubmit:ge,suggestions:Ae,onForgetSuggestion:ce=>ye(e,ce),onBack:()=>{try{o.current?.goBack()}catch{}},onForward:()=>{try{o.current?.goForward()}catch{}},onReload:B,onOpenExternal:()=>{Uo(J.url||w)},canGoBack:J.canGoBack,canGoForward:J.canGoForward,isLoading:ue,onAnnotate:Q,isAnnotating:y,onOpenDevTools:()=>{try{o.current?.openDevTools()}catch{}},onHardReload:()=>{try{o.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>oe(g+fo),onZoomOut:()=>oe(g-fo),onZoomReset:()=>oe(0),zoomPercent:Math.round(Math.pow(1.2,g)*100),onClearCookies:()=>de("cookies"),onClearCache:()=>de("cache"),onToggleDeviceBar:()=>D(ce=>!ce),isDeviceBarOpen:j}),j?s.jsx(rv,{viewport:I,onViewportChange:A,colorScheme:L,onColorSchemeChange:_,scale:Re?.scale??1}):null,s.jsxs("div",{ref:W,className:Oe("relative min-h-0 flex-1 bg-background",Re&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[x!==null?s.jsx("webview",{ref:d,src:x,partition:"persist:openchamber-browser",allowpopups:!0,style:Re?{width:`${Re.width}px`,height:`${Re.height}px`,transform:`scale(${Re.scale})`,border:"none",flex:"none",boxShadow:"0 2px 18px rgba(0,0,0,.28)"}:{width:"100%",height:"100%",border:"none"}}):null,x!==null&&!f&&!J.url&&!ue?s.jsx(If,{onOpen:ge,directory:e}):null,p?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.waitingForServer")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.waitingForServerHint")})]}):null,re?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:r("contextPanel.browser.tunnelFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:r("contextPanel.browser.tunnelFailedHint",{url:re})})]}):null,ve&&!re?s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[s.jsx("span",{className:"typography-ui-header text-foreground",children:ve.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ve.crashed?r("contextPanel.browser.crashedHint"):ve.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ue?s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 overflow-hidden",children:s.jsx("div",{className:"h-full w-1/3 animate-[browser-progress_1.1s_ease-in-out_infinite] bg-[var(--primary)]"})}):null]})]})},Mv=t=>{const e=Ze.c(49),{initialUrl:n,directory:r,tabID:i}=t,{t:o}=jt(),l=Pe(Bv);let a;e[0]!==n?(a=br(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==sn?d:"",[h,f]=c.useState(u),[x,b]=c.useState(u);let w;e[2]!==u?(w=u?[u]:[],e[2]=u,e[3]=w):w=e[3];const[v,y]=c.useState(w),[m,p]=c.useState(u?0:-1),[S,g]=c.useReducer(Fv,0);let C;e[4]!==r||e[5]!==l||e[6]!==i?(C=te=>{!te||te===sn||!r||!i||l(r,i,te)},e[4]=r,e[5]=l,e[6]=i,e[7]=C):C=e[7];const k=C;let j;e[8]!==r?(j=jf(r),e[8]=r,e[9]=j):j=e[9];const D=wr(j),I=wr(_v),A=wr(Lv);let P;e[10]!==h||e[11]!==D?(P=Sf(D,h),e[10]=h,e[11]=D,e[12]=P):P=e[12];const T=P;let L;e[13]!==r||e[14]!==m||e[15]!==k||e[16]!==I?(L=te=>{const ue=br(te);ue!==sn&&(f(ue),b(ue),k(ue),I(r,{url:ue}),y(Se=>{const we=m>=0?Se.slice(0,m+1):[];return we[we.length-1]===ue?(p(we.length-1),we):(p(we.length),[...we,ue])}))},e[13]=r,e[14]=m,e[15]=k,e[16]=I,e[17]=L):L=e[17];const $=L;let K;e[18]!==v||e[19]!==k?(K=te=>{const ue=v[te];ue&&(p(te),f(ue),b(ue),k(ue))},e[18]=v,e[19]=k,e[20]=K):K=e[20];const F=K;let W;e[21]!==r||e[22]!==A?(W=te=>A(r,te),e[21]=r,e[22]=A,e[23]=W):W=e[23];let N,R;e[24]!==F||e[25]!==m?(R=()=>F(m-1),N=()=>F(m+1),e[24]=F,e[25]=m,e[26]=N,e[27]=R):(N=e[26],R=e[27]);let E;e[28]!==h||e[29]!==x?(E=()=>{Uo(x||h)},e[28]=h,e[29]=x,e[30]=E):E=e[30];const X=m>0,J=m>=0&&m<v.length-1;let re;e[31]!==h||e[32]!==$||e[33]!==T||e[34]!==N||e[35]!==E||e[36]!==X||e[37]!==J||e[38]!==W||e[39]!==R?(re=s.jsx(Af,{address:h,onAddressChange:f,onSubmit:$,suggestions:T,onForgetSuggestion:W,onBack:R,onForward:N,onReload:g,onOpenExternal:E,canGoBack:X,canGoForward:J,isLoading:!1}),e[31]=h,e[32]=$,e[33]=T,e[34]=N,e[35]=E,e[36]=X,e[37]=J,e[38]=W,e[39]=R,e[40]=re):re=e[40];let fe;e[41]!==x||e[42]!==$||e[43]!==S||e[44]!==o?(fe=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:x?s.jsx("iframe",{src:x,title:o("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${x}|${S}`):s.jsx(If,{onOpen:$})}),e[41]=x,e[42]=$,e[43]=S,e[44]=o,e[45]=fe):fe=e[45];let ne;return e[46]!==re||e[47]!==fe?(ne=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[re,fe]}),e[46]=re,e[47]=fe,e[48]=ne):ne=e[48],ne},Ov=t=>{const e=Ze.c(3),[n]=c.useState(Nv);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(Rv,{...t}):s.jsx(Mv,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function Bv(t){return t.setContextPanelTabTargetPath}function Fv(t){return t+1}function _v(t){return t.recordVisit}function Lv(t){return t.forget}const $v=Wn(()=>En(()=>import("./WalkthroughView-BZyjhqHv.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,114,115,116,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.WalkthroughView}))),zv=Wn(()=>En(()=>import("./DiffView-B2CD9wC8.js"),__vite__mapDeps([128,1,2,4,5,6,7,8,9,83,3,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,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,114,115,116,129,117,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.DiffView}))),Wv=Wn(()=>En(()=>import("./FilesView-C4vMFclc.js"),__vite__mapDeps([130,1,2,4,5,6,7,8,9,3,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,84,85,86,131,132,133,134,135,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,114,136,137,120,121,118,125,138,119,139])).then(t=>({default:t.FilesView}))),Kv=Wn(()=>En(()=>import("./GitView-Byu2DY7s.js"),__vite__mapDeps([140,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,84,85,86,141,117,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,114,87,115,116,118,119,120,121,122,123,124,125,126,127])).then(t=>({default:t.GitView}))),Vv=Wn(()=>En(()=>import("./LinearIssuesView-EzGNCGrd.js"),__vite__mapDeps([142,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])).then(t=>({default:t.LinearIssuesView}))),Uv=Wn(()=>En(()=>import("./PlanView-D3x-pTkZ.js"),__vite__mapDeps([143,1,2,4,5,6,7,8,9,131,57,58,59,60,61,62,79,55,56,63,132,133,134,3,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,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,80,81,82,119,139,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,84,85,86])).then(t=>({default:t.PlanView}))),Hv=c.lazy(()=>En(()=>import("./PluginPane-DEcgDQ9h.js").then(t=>t.k),__vite__mapDeps([86,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])).then(t=>({default:t.PluginPane}))),Tf=320,Ja=600,Gv=400,qv=100,Yv=24,Fo=new Map,Qv=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+$/g,"");return r=r.replace(/\/+/g,"/"),n&&!r.startsWith("//")&&(r=`/${r}`),r===""?e.startsWith("/")?"/":"":r},Dc=(t,e)=>Number.isFinite(t)?Math.min(e,Math.max(Tf,Math.round(t))):Ja,Pc=t=>{const e=t??(typeof window<"u"?window.innerWidth:Ja*2);return Math.max(Tf,e-Gv)},Xv=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},Jv=(t,e)=>{if(!t)return"";const n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return r&&n.startsWith(r+"/")?n.slice(r.length+1):n},Ef=(t,e)=>t==="chat"?e("contextPanel.mode.chat"):t==="file"?e("contextPanel.mode.files"):t==="diff"?e("contextPanel.mode.diff"):t==="walkthrough"?e("contextPanel.mode.walkthrough"):t==="plan"?e("contextPanel.mode.plan"):t==="browser"?e("contextPanel.mode.browser"):t==="git"?e("layout.rightSidebar.git"):t==="pr"?e("contextPanel.mode.pr"):t==="linear"?e("contextPanel.mode.linear"):t==="notes"?e("contextRail.surface.notes"):t==="terminal"?e("layout.mainTab.terminal"):Zn(t)?uu.getState().guests.find(r=>r.id===Di(t))?.name??e("contextRail.surface.plugin"):e("contextPanel.mode.context"),Zv=t=>{if(!t)return null;const e=t.replace(/\\/g,"/").trim();if(!e)return null;const n=e.split("/").filter(Boolean);return n.length===0?e:n[n.length-1]||null},eS=(t,e,n)=>{if(t.mode==="chat"){const r=aa(t.dedupeKey);if(r){const o=e.get(r)?.trim();if(o)return o}const i=t.sessionTitleFallback?.trim();return i||n("contextPanel.mode.chat")}return t.mode==="browser"?Qa(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Zv(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Ef(t.mode,n)},tS=t=>{const e=Ze.c(8),{mode:n}=t,r=Ia();let i;if(e[0]!==n||e[1]!==r){let u;e[3]!==n?(u=h=>h.mode===n,e[3]=n,e[4]=u):u=e[4],i=r.find(u),e[0]=n,e[1]=r,e[2]=i}else i=e[2];const o=i,l=o?.icon??Lp,a=o?.iconSrc;let d;return e[5]!==l||e[6]!==a?(d=s.jsx(Xr,{icon:l,iconSrc:a,className:"h-3.5 w-3.5"}),e[5]=l,e[6]=a,e[7]=d):d=e[7],d},Ic=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(Pa,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(of,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(M,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(M,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(M,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="linear")return s.jsx(M,{name:"linear",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(M,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(M,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(M,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(M,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(M,{name:"chat-4",className:"h-3.5 w-3.5"});if(Zn(t.mode))return s.jsx(tS,{mode:t.mode});if(t.mode==="browser"){const n=sS(t.targetPath??"",e);return n?s.jsx("img",{src:n,alt:"","aria-hidden":"true",className:"h-3.5 w-3.5 rounded-[3px] object-contain"}):s.jsx(M,{name:"global",className:"h-3.5 w-3.5"})}},sS=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},nS=({visible:t,active:e,fill:n=!1})=>{const{t:r}=jt(),i=Pe(p=>p.contextEditorTreeWidth),o=Pe(p=>p.setContextEditorTreeWidth),[l,a]=c.useState(!1),d=c.useRef(0),u=c.useRef(i),h=c.useRef(null),f=c.useRef(null),x=c.useRef(null),b=c.useCallback(p=>{const S=x.current;S&&(S.style.width=`${p}px`,S.style.setProperty("--oc-editor-tree-width",`${p}px`))},[]),w=p=>{if(t){try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}f.current=p.pointerId,a(!0),d.current=p.clientX,u.current=i,h.current=i,p.preventDefault()}},v=p=>{if(!l||f.current!==p.pointerId)return;const S=d.current-p.clientX,g=Ai(u.current+S);h.current!==g&&(h.current=g,b(g))},y=p=>{if(f.current!==p.pointerId)return;try{p.currentTarget.releasePointerCapture(p.pointerId)}catch{}const S=Ai(h.current??i);f.current=null,h.current=null,a(!1),o(S)},m=t?i:0;return s.jsxs("div",{ref:x,className:Oe("relative h-full flex-shrink-0 overflow-hidden bg-background will-change-[width] motion-reduce:transition-none",n&&"ml-auto"),style:{width:`${l?h.current??m:m}px`,maxWidth:n?"100%":void 0,"--oc-editor-tree-width":`${l?h.current??i:i}px`,overflowX:"clip",transitionProperty:l?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&!n&&s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-20 w-px bg-border"}),t&&!n&&s.jsx("div",{className:Oe("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",l&&"bg-[var(--interactive-border)]"),onPointerDown:w,onPointerMove:v,onPointerUp:y,onPointerCancel:y,role:"separator","aria-orientation":"vertical","aria-label":r("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:Oe("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",l&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)",maxWidth:n?"100%":void 0},"aria-hidden":!t,children:s.jsx(S1,{visible:t&&e})})]})},aa=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,rS=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},oS=(t,e)=>{if(e.length===0)return Fo;const n=new Set(e),r=new Map;for(const i of t){if(!n.has(i.id))continue;const o=i.title?.trim();o&&r.set(i.id,o)}return r.size===0?Fo:r},iS=(t,e)=>{const n=nu(t),r=c.useRef(Fo),i=c.useRef(e);return i.current=e,c.useSyncExternalStore(n.subscribe,c.useCallback(()=>{const o=oS(n.getState().session,i.current);return rS(r.current,o)?r.current:(r.current=o,o)},[n]),()=>Fo)},aS=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,lS=()=>{const{t}=jt(),e=ir()??"",n=c.useMemo(()=>Qv(e),[e]),r=Pe(Y=>n?Y.contextPanelByDirectory[n]:void 0),i=Pe(Y=>Y.closeContextPanel),o=Pe(Y=>Y.closeContextPanelTab),l=Pe(Y=>Y.openContextPanelTab),a=Pe(Y=>Y.toggleContextPanelExpanded),d=Pe(Y=>Y.setContextPanelWidth),u=Pe(Y=>Y.setActiveContextPanelTab),h=Pe(Y=>Y.openContextBrowser);c.useEffect(()=>{if(e)return Tw(Y=>h(e,Y))},[e,h]);const f=Pe(Y=>Y.reorderContextPanelTabs),x=hn(Y=>Y.setSelectedPath),b=Pe(Y=>Y.contextEditorTreeVisible),w=Pe(Y=>Y.contextEditorTreeWidth),v=Pe(Y=>Y.setContextEditorTreeWidth),y=Pe(Y=>Y.toggleContextEditorTree),m=Pe(Y=>Y.contextEditorVisible),p=Pe(Y=>Y.toggleContextEditor),S=Pe(Y=>Y.openNewContextBrowserTab),g=gf(Y=>Y.byOrigin),C=Pe(Y=>Y.allowPromptingSubagentSessions),{themeMode:k,setThemeMode:j,lightThemeId:D,darkThemeId:I,currentTheme:A}=or(),P=c.useMemo(()=>r?.tabs??[],[r?.tabs]),T=P.find(Y=>Y.id===r?.activeTabId)??P[P.length-1]??null,L=!!(r?.isOpen&&T),[$,K]=c.useState(null),F=c.useMemo(()=>P.some(Y=>Y.mode==="file"&&Y.targetPath),[P]),W=F&&(m||!b),N=T?.mode??null,R=N==="file"&&!W,E=!!(L&&r?.expanded&&!R),X=N?r?.widthByMode?.[N]:void 0,J=N?r?.widthFractionByMode?.[N]:void 0,re=N?Bp(N):.5,fe=$??(typeof window<"u"?window.innerWidth:Ja*2),ne=J!=null&&$!=null?Math.round(J*$):X,te=R?w:Dc(ne??Math.round(re*fe),Pc($??fe));c.useEffect(()=>{!n||!N||R||J!=null||X==null||$==null||d(n,N,X,$)},[N,$,n,R,X,J,d]);const ue=c.useMemo(()=>{const Y=[];for(const G of P){if(G.mode!=="chat")continue;const Z=aa(G.dedupeKey);Z&&!Y.includes(Z)&&Y.push(Z)}return Y},[P]),Se=iS(n||void 0,ue),[we,ye]=c.useState(!1),Ae=c.useRef(0),pe=c.useRef(te),O=c.useRef(null),Q=c.useRef(null),le=c.useRef(null),H=c.useRef(new Map),me=c.useRef(new Map),ge=c.useRef(!1);c.useLayoutEffect(()=>{const Y=le.current?.parentElement;if(!Y||typeof ResizeObserver>"u")return;const G=new ResizeObserver(()=>{K(Y.clientWidth||null)});return G.observe(Y),K(Y.clientWidth||null),()=>G.disconnect()},[]),c.useEffect(()=>{if(!L||ge.current){ge.current=L;return}const Y=window.requestAnimationFrame(()=>{le.current?.focus({preventScroll:!0})});return ge.current=!0,()=>window.cancelAnimationFrame(Y)},[L]);const oe=c.useRef(null),de=c.useRef(null),_=c.useCallback(()=>{de.current=null;const Y=le.current,G=O.current;!Y||G===null||Y.style.setProperty("--oc-context-panel-width",`${G}px`)},[]);c.useEffect(()=>()=>{de.current!==null&&clearTimeout(de.current)},[]);const B=c.useCallback(Y=>{const G=oe.current,Z=R?Ai(Y):Dc(Y,Pc(G));return G===null?Z:Math.min(Z,Math.max(1,G))},[R]),he=c.useCallback(Y=>{!L||E||!n||(Q.current=Y.pointerId,ye(!0),Ae.current=Y.clientX,pe.current=te,O.current=te,oe.current=Xv(le.current),document.documentElement.style.cursor="col-resize",Y.preventDefault())},[n,E,L,te]),ve=c.useCallback(()=>{const Y=B(O.current??te),G=oe.current;O.current=null,oe.current=null,de.current!==null&&(clearTimeout(de.current),de.current=null),document.documentElement.style.cursor="",R?v(Y):n&&N&&d(n,N,Y,G??void 0),ye(!1),Q.current=null},[N,B,n,R,v,d,te]);c.useEffect(()=>{if(!we)return;const Y=je=>{if(Q.current!==je.pointerId)return;const Ie=Ae.current-je.clientX,Ve=B(pe.current+Ie);O.current!==Ve&&(O.current=Ve,de.current===null&&(de.current=setTimeout(_,qv)))},G=je=>{Q.current===je.pointerId&&ve()},Z=()=>{ve()};return window.addEventListener("pointermove",Y),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G),window.addEventListener("blur",Z),()=>{window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G),window.removeEventListener("blur",Z)}},[_,B,ve,we]),c.useEffect(()=>{we||(O.current=null,document.documentElement.style.cursor="")},[we]);const Re=c.useCallback(()=>{n&&i(n)},[i,n]),ce=c.useCallback(()=>{n&&a(n)},[n,a]),se=c.useCallback(Y=>{Y.key==="Escape"&&(Y.target instanceof Node&&!Y.currentTarget.contains(Y.target)||Fp(Y.target)||_p(Y.target)||(Y.preventDefault(),Y.stopPropagation(),Re()))},[Re]);c.useEffect(()=>{if(!(!n||!T)&&T.mode==="file"&&T.targetPath){x(n,T.targetPath,{allowOutsideRoot:!0});return}},[T,n,x]);const q=c.useMemo(()=>P.filter(Y=>Y.mode==="chat"),[P]),z=L&&T?.mode==="chat"?T.id:null,ee=L&&T?.mode==="chat"?aa(T.dedupeKey):null,ae=Jx(q,z);c.useEffect(()=>{if(!L||!n||!ee||typeof window>"u")return;const Y=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ci(n,ee,!1);return}wu(ee),ci(n,ee,!0)};Y();const G=window.setInterval(Y,1e4);return window.addEventListener("focus",Y),window.addEventListener("blur",Y),document.addEventListener("visibilitychange",Y),()=>{window.clearInterval(G),window.removeEventListener("focus",Y),window.removeEventListener("blur",Y),document.removeEventListener("visibilitychange",Y),ci(n,ee,!1)}},[ee,n,L]);const Ne=c.useCallback((Y,G,Z)=>Zx(me.current,Y,G,n||null,Z,{mode:k,lightThemeId:D,darkThemeId:I,currentTheme:A},{allowPromptingSubagentSessions:C}),[C,A,I,n,D,k]),Ce=ae&&ee?Ne(ae.id,ee,ae.readOnly):null;c.useEffect(()=>{const Y=new Set(P.map(G=>G.id));for(const G of me.current.keys())Y.has(G)||me.current.delete(G)},[P]);const We=c.useCallback(Y=>{!n||T?.mode!=="diff"||l(n,{mode:"diff",targetPath:T.targetPath,stagedDiff:Y==="staged",diffScope:Y})},[T,n,l]),Ee=c.useCallback(()=>{if(typeof window>"u")return;const Y={themeMode:k,lightThemeId:D,darkThemeId:I,currentTheme:A};for(const G of H.current.values()){const Z=G.contentWindow;Z&&Z.postMessage({type:"openchamber:theme-sync",payload:Y},window.location.origin)}},[A,I,D,k]),xe=c.useCallback(()=>{if(typeof window>"u")return;const Y={allowPromptingSubagentSessions:C};for(const G of H.current.values()){const Z=G.contentWindow;Z&&Z.postMessage({type:"openchamber:chat-settings-sync",payload:Y},window.location.origin)}},[C]),$e=c.useCallback((Y,G,Z)=>{const je=G.contentWindow;je&&je.postMessage({type:Gu,payload:{visible:z===Y}},Z)},[z]),V=c.useCallback(()=>{if(!(typeof window>"u"))for(const[Y,G]of H.current.entries())$e(Y,G,window.location.origin)},[$e]);c.useEffect(()=>{if(typeof window>"u")return;const Y=G=>{if(G.origin!==window.location.origin)return;const Z=Array.from(H.current.entries()).find(([,it])=>it.contentWindow===G.source);if(!Z)return;const je=G.data;if(je?.type===eb){const[it,at]=Z;$e(it,at,G.origin);return}if(je?.type===tb){if(typeof je.requestId!="string"||!je.requestId)return;const it=qt(),at={apiBaseUrl:Pn(),clientToken:Hr(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:Md(),relayHostId:it.startsWith("host:")?it.slice(5):"",relay:Qm()??void 0};G.source?.postMessage({type:sb,requestId:je.requestId,payload:at},G.origin);return}if(je?.type==="openchamber:theme-sync-request"){Ee();return}if(je?.type==="openchamber:chat-settings-request"){xe();return}if(je?.type!=="openchamber:cycle-theme-request")return;const Ie=["light","dark","system"],Je=(Ie.indexOf(k)+1)%Ie.length;j(Ie[Je])};return window.addEventListener("message",Y),()=>window.removeEventListener("message",Y)},[xe,$e,Ee,j,k]),c.useLayoutEffect(()=>{P.some(G=>G.mode==="chat")&&(Ee(),xe(),V())},[I,D,xe,V,Ee,P,k]);const De=T?.mode==="file"||T?.mode==="chat"||T?.mode==="browser",Fe=c.useMemo(()=>T?P.filter(Y=>Y.mode===T.mode):[],[T,P]),_e=c.useMemo(()=>Fe.map(Y=>{const G=eS(Y,Se,t),Z=aS(G,Yv),je=Jv(Y.targetPath,e);return{id:Y.id,label:Z,icon:Ic(Y,g),title:je?`${G}: ${je}`:G,closeLabel:t("contextPanel.tab.closeTabAria",{label:Z})}}),[Fe,e,g,Se,t]),rt=T?.mode==="context"?s.jsx(z1,{}):T?.mode==="git"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Kv,{isActive:L})}):T?.mode==="pr"?s.jsx(Yy,{}):T?.mode==="linear"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Vv,{})}):T?.mode==="notes"?s.jsx(jh,{}):T?.mode==="plan"?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Uv,{targetPath:T.targetPath,savedProjectPlan:T.projectPlanId&&T.projectPlanRef?{projectRef:T.projectPlanRef,planId:T.projectPlanId}:null})}):null,ct=c.useMemo(()=>P.filter(Y=>Y.mode==="browser"),[P]),et=c.useMemo(()=>P.filter(Y=>Y.mode==="diff"),[P]),pt=c.useMemo(()=>P.find(Y=>Y.mode==="terminal")??null,[P]),kt=c.useMemo(()=>P.some(Y=>Y.mode==="walkthrough"),[P]),wt=c.useMemo(()=>P.filter(Y=>Zn(Y.mode)),[P]),Xe=c.useMemo(()=>P.some(Y=>Y.mode==="file"),[P]),yt=T?.mode==="file",Rt=Pe(Y=>Y.closeContextPanelTabs),be=c.useCallback(Y=>{if(!n)return null;const{id:G,index:Z,allIds:je,close:Ie}=Y,Ve=()=>Rt(n,je.filter(Pt=>Pt!==G)),Je=()=>Rt(n,je.slice(0,Z)),it=()=>Rt(n,je.slice(Z+1)),at=()=>Rt(n,je),Ye=je.length>1,vt=Z===0,Ue=Z===je.length-1;return s.jsxs(s.Fragment,{children:[s.jsxs(Qn,{onClick:Ie,children:[s.jsx(M,{name:"close",className:"mr-2 size-4"}),t("contextPanel.tab.menu.close")]}),s.jsx(Ei,{}),s.jsxs(Qn,{onClick:Ve,disabled:!Ye,children:[s.jsx(M,{name:"expand-horizontal",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeOthers")]}),s.jsxs(Qn,{onClick:Je,disabled:vt,children:[s.jsx(M,{name:"expand-left",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToLeft")]}),s.jsxs(Qn,{onClick:it,disabled:Ue,children:[s.jsx(M,{name:"expand-right",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeToRight")]}),s.jsx(Ei,{}),s.jsxs(Qn,{onClick:at,disabled:!Ye,children:[s.jsx(M,{name:"close-circle",className:"mr-2 size-4"}),t("contextPanel.tab.menu.closeAll")]})]})},[Rt,n,t]),Ge=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[De?s.jsx($d,{items:_e,activeId:T?.id??null,onSelect:Y=>{n&&u(n,Y)},onClose:Y=>{n&&o(n,Y)},onReorder:(Y,G)=>{n&&f(n,Y,G)},layoutMode:"scrollable",variant:"default",tabContextMenu:be}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[T?Ic(T,g):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:T?Ef(T.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[T?.mode==="browser"?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&S(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(M,{name:"add",className:"h-3.5 w-3.5"})}):null,yt&&F?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:p,className:"h-7 w-7 p-0",title:t("contextRail.editor.toggle"),"aria-label":t("contextRail.editor.toggle"),"aria-pressed":W,children:s.jsx(M,{name:"layout-left",className:"h-3.5 w-3.5"})}):null,yt?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:y,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(M,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,R?null:s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:ce,className:"h-7 w-7 p-0",title:t(E?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(E?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:E?s.jsx(M,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(M,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:Re,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]})]}),ut=L?E?{"--oc-context-panel-width":$!==null?`${$}px`:"100%",width:$!==null?`${$}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${te}px`}:{"--oc-context-panel-width":`${te}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:le,"data-context-panel":"true",tabIndex:-1,inert:!L||void 0,className:Oe("flex min-h-0 flex-col overflow-hidden bg-background",E?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!L&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:se,style:ut,children:[L&&!E&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),L&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!E&&s.jsx("div",{className:Oe("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",we&&"bg-[var(--interactive-border)]"),onPointerDown:he,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:Oe("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!L&&"pointer-events-none select-none opacity-0"),style:{width:E?$!==null?`${$}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!L,children:[Ge,s.jsxs("div",{className:Oe("relative min-h-0 flex-1 overflow-hidden",we&&"pointer-events-none"),children:[Xe?s.jsxs("div",{className:Oe("absolute inset-0 flex",yt?"flex":"hidden"),children:[F||!b?s.jsx("div",{className:Oe("h-full min-w-0 flex-1",F&&!W&&"hidden"),children:F?s.jsx(c.Suspense,{fallback:null,children:s.jsx(Wv,{mode:"editor-only",visible:L&&yt&&W})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(M,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),s.jsx("div",{className:"typography-ui-header text-foreground",children:t("contextPanel.editorEmpty.title")}),s.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:t("contextPanel.editorEmpty.description")})]})}):null,s.jsx(nS,{visible:b,active:L&&yt,fill:!W})]}):null,ae&&ee&&Ce?s.jsx("iframe",{ref:Y=>{if(!Y){H.current.delete(ae.id);return}H.current.set(ae.id,Y)},src:Ce,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:ee}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{Ee(),xe(),V()}},ae.id):null,ct.map(Y=>s.jsx("div",{className:Oe("absolute inset-0",T?.id!==Y.id&&"hidden"),children:s.jsx(Ov,{initialUrl:Y.targetPath??"",directory:n,tabID:Y.id})},Y.id)),et.map(Y=>s.jsx("div",{className:Oe("absolute inset-0",T?.id!==Y.id&&"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(zv,{visible:L&&T?.id===Y.id,hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:Y.diffScope??(Y.stagedDiff?"staged":"working"),onDiffScopeChange:We,targetFilePath:Y.targetPath,flushContent:!0})})},Y.id)),pt?s.jsx("div",{className:Oe("absolute inset-0",T?.mode==="terminal"?"block":"hidden"),children:s.jsx(kh,{visible:L&&T?.mode==="terminal",directory:pt.targetDirectory})}):null,kt?s.jsx("div",{className:Oe("absolute inset-0",T?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx($v,{directory:e,visible:L&&T?.mode==="walkthrough"})})}):null,wt.map(Y=>Zn(Y.mode)?s.jsx("div",{className:Oe("absolute inset-0",T?.id===Y.id?"block":"hidden"),children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(Hv,{mode:Y.mode})})},Y.id):null),T?.mode!=="chat"&&!yt&&T?.mode!=="browser"&&T?.mode!=="diff"&&T?.mode!=="terminal"&&T?.mode!=="walkthrough"&&!(T&&Zn(T.mode))?rt:null]})]})]})},cS=t=>{const e=Ze.c(43),{open:n,onOpenChange:r}=t,{t:i}=jt(),o=Pe(dS),l=Pe(uS),a=Pe(fS),d=Pe(mS),u=Ia();let h;e[0]!==o||e[1]!==u?(h=vu(o,u),e[0]=o,e[1]=u,e[2]=h):h=e[2];const f=h,x=l.length===0;let b;if(e[3]!==l||e[4]!==f){let I;e[6]!==l?(I=A=>l.includes(A.id),e[6]=l,e[7]=I):I=e[7],b=f.every(I),e[3]=l,e[4]=f,e[5]=b}else b=e[5];const w=b;let v;e[8]!==i?(v=i("contextRail.configure.dialogTitle"),e[8]=i,e[9]=v):v=e[9];let y;e[10]!==v?(y=s.jsx(Ps,{children:v}),e[10]=v,e[11]=y):y=e[11];let m;e[12]!==i?(m=i("contextRail.configure.dialogDescription"),e[12]=i,e[13]=m):m=e[13];let p;e[14]!==m?(p=s.jsx(Is,{children:m}),e[14]=m,e[15]=p):p=e[15];let S;e[16]!==y||e[17]!==p?(S=s.jsxs(Vs,{children:[y,p]}),e[16]=y,e[17]=p,e[18]=S):S=e[18];let g;if(e[19]!==l||e[20]!==a||e[21]!==f||e[22]!==i){let I;e[24]!==l||e[25]!==a||e[26]!==i?(I=A=>s.jsx($p,{settingsItem:`layout.context-rail.surface.${A.id}`,checked:!l.includes(A.id),onChange:P=>a(A.id,P),label:A.label??i(A.labelKey),ariaLabel:A.label??i(A.labelKey)},A.id),e[24]=l,e[25]=a,e[26]=i,e[27]=I):I=e[27],g=f.map(I),e[19]=l,e[20]=a,e[21]=f,e[22]=i,e[23]=g}else g=e[23];let C;e[28]!==g?(C=s.jsx("div",{className:"flex flex-col",children:g}),e[28]=g,e[29]=C):C=e[29];let k;e[30]!==x||e[31]!==w||e[32]!==d||e[33]!==i?(k=x?null:s.jsxs("div",{className:"flex items-center justify-between border-t pt-3",children:[w?s.jsx("span",{className:"text-xs text-destructive",children:i("contextRail.configure.noneWarning")}):s.jsx("span",{}),s.jsx(dt,{variant:"link",size:"xs",onClick:()=>d([]),className:"normal-case text-muted-foreground hover:text-foreground",children:i("contextRail.configure.showAll")})]}),e[30]=x,e[31]=w,e[32]=d,e[33]=i,e[34]=k):k=e[34];let j;e[35]!==k||e[36]!==S||e[37]!==C?(j=s.jsxs(ws,{className:"max-w-md",children:[S,C,k]}),e[35]=k,e[36]=S,e[37]=C,e[38]=j):j=e[38];let D;return e[39]!==r||e[40]!==n||e[41]!==j?(D=s.jsx(ys,{open:n,onOpenChange:r,children:j}),e[39]=r,e[40]=n,e[41]=j,e[42]=D):D=e[42],D};function dS(t){return t.contextRailOrder}function uS(t){return t.contextRailHiddenSurfaces}function fS(t){return t.setContextRailSurfaceVisible}function mS(t){return t.setContextRailHiddenSurfaces}const Rf=150,hS=500,pS=[],gS=t=>t>99?"99+":String(t),xS=t=>{const e=Ze.c(52),{surface:n,isActive:r,showActivityDot:i,label:o,description:l,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:h,showOrderNumber:f,onSelect:x}=t;let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:w,listeners:v,setNodeRef:y,transform:m,transition:p,isDragging:S}=ti(b);let g;e[2]!==a?(g=a!=null&&a>0?gS(a):null,e[2]=a,e[3]=g):g=e[3];const C=g;let k;e[4]!==m?(k=si.Translate.toString(m),e[4]=m,e[5]=k):k=e[5];let j;e[6]!==k||e[7]!==p?(j={transform:k,transition:p},e[6]=k,e[7]=p,e[8]=j):j=e[8];const D=S&&"z-10 opacity-70";let I;e[9]!==D?(I=Oe("relative",D),e[9]=D,e[10]=I):I=e[10];let A;e[11]!==x||e[12]!==n?(A=()=>x(n),e[11]=x,e[12]=n,e[13]=A):A=e[13];const P=d??o,T=r?"text-primary":"text-muted-foreground hover:text-foreground";let L;e[14]!==T?(L=Oe("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",T),e[14]=T,e[15]=L):L=e[15];let $;e[16]!==n.icon||e[17]!==n.iconSrc||e[18]!==n.id?($=n.id==="diff"?s.jsx(of,{className:"h-[18px] w-[18px]"}):s.jsx(Xr,{icon:n.icon,iconSrc:n.iconSrc,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.iconSrc,e[18]=n.id,e[19]=$):$=e[19];let K;e[20]!==C||e[21]!==h||e[22]!==i||e[23]!==f?(K=f&&h!=null?s.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:h===10?"0":h}):C?s.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:C}):i?s.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null,e[20]=C,e[21]=h,e[22]=i,e[23]=f,e[24]=K):K=e[24];let F;e[25]!==w||e[26]!==r||e[27]!==v||e[28]!==L||e[29]!==$||e[30]!==K||e[31]!==A||e[32]!==P?(F=s.jsx(At,{asChild:!0,children:s.jsxs("button",{type:"button",...w,...v,onClick:A,"aria-label":P,"aria-pressed":r,className:L,children:[$,K]})}),e[25]=w,e[26]=r,e[27]=v,e[28]=L,e[29]=$,e[30]=K,e[31]=A,e[32]=P,e[33]=F):F=e[33];let W;e[34]!==o?(W=s.jsx("span",{children:o}),e[34]=o,e[35]=W):W=e[35];let N;e[36]!==l?(N=s.jsx("span",{className:"typography-micro text-muted-foreground",children:l}),e[36]=l,e[37]=N):N=e[37];let R;e[38]!==u?(R=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[38]=u,e[39]=R):R=e[39];let E;e[40]!==W||e[41]!==N||e[42]!==R?(E=s.jsx(Dt,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[W,N,R]})}),e[40]=W,e[41]=N,e[42]=R,e[43]=E):E=e[43];let X;e[44]!==F||e[45]!==E?(X=s.jsxs(Nt,{delayDuration:Rf,children:[F,E]}),e[44]=F,e[45]=E,e[46]=X):X=e[46];let J;return e[47]!==y||e[48]!==X||e[49]!==j||e[50]!==I?(J=s.jsx("div",{ref:y,style:j,className:I,children:X}),e[47]=y,e[48]=X,e[49]=j,e[50]=I,e[51]=J):J=e[51],J},bS=()=>{const t=Ze.c(92),{t:e}=jt(),n=ir();let r;t[0]!==n?(r=n?cr(n):"",t[0]=n,t[1]=r):r=t[1];const i=r;let o;t[2]!==i?(o=ce=>i?ce.contextPanelByDirectory[i]:void 0,t[2]=i,t[3]=o):o=t[3];const l=Pe(o),a=Pe(yS),d=Pe(wS),u=Pe(vS),h=Pe(SS),f=Pe(jS),x=Pe(kS),b=Pe(CS),w=Ca(NS),v=_i(AS),y=_i(DS),m=In(PS),p=In(IS),{screenWidth:S}=zn(),g=Na(i||null);let C;t[4]!==b?(C=Li("switch_context_surface",b),t[4]=b,t[5]=C):C=t[5];const k=C,[j,D]=c.useState(!1);let I,A;t[6]!==k?(I=()=>{const ce=new Set;let se=null,q=!1;const z=TS,ee=()=>{Dl(k,ce)?!q&&se===null&&(se=setTimeout(()=>D(!0),hS)):(q=!1,se!==null&&(clearTimeout(se),se=null),D(!1))},ae=We=>{if(ce.add(We.key.toLowerCase()),z(We.key)&&Dl(k,ce)){q=!0,se!==null&&(clearTimeout(se),se=null),D(!1);return}ee()},Ne=We=>{ce.delete(We.key.toLowerCase()),ee()},Ce=()=>{ce.clear(),q=!1,se!==null&&(clearTimeout(se),se=null),D(!1)};return window.addEventListener("keydown",ae,!0),window.addEventListener("keyup",Ne,!0),window.addEventListener("blur",Ce),()=>{window.removeEventListener("keydown",ae,!0),window.removeEventListener("keyup",Ne,!0),window.removeEventListener("blur",Ce),se!==null&&clearTimeout(se)}},A=[k],t[6]=k,t[7]=I,t[8]=A):(I=t[7],A=t[8]),c.useEffect(I,A);let P;t[9]===Symbol.for("react.memo_cache_sentinel")?(P={activationConstraint:{distance:8}},t[9]=P):P=t[9];let T;t[10]===Symbol.for("react.memo_cache_sentinel")?(T={activationConstraint:{delay:200,tolerance:6}},t[10]=T):T=t[10];const L=Qo(Dn(Jo,P),Dn(Xo,T)),$=Ia(),K=Al(ES),F=Al(RS),W=l?.tabs??pS;let N;t[11]!==l?.activeTabId||t[12]!==W?(N=W.find(ce=>ce.id===l?.activeTabId)??null,t[11]=l?.activeTabId,t[12]=W,t[13]=N):N=t[13];const R=N,E=l?.isOpen?R?.mode??null:null,X=g?.files.length??0;let J;t[14]!==u||t[15]!==d||t[16]!==p||t[17]!==$||t[18]!==y||t[19]!==w||t[20]!==S||t[21]!==W?(J=zp({railOrder:d,hiddenSurfaces:u,planModeEnabled:w,isVSCode:$n(),screenWidth:S,tabs:W,linearConnected:y,githubConnected:p,extras:$}),t[14]=u,t[15]=d,t[16]=p,t[17]=$,t[18]=y,t[19]=w,t[20]=S,t[21]=W,t[22]=J):J=t[22];const re=J;let fe,ne;t[23]!==E||t[24]!==x||t[25]!==i||t[26]!==v||t[27]!==y?(ne=()=>{!i||!v||y||E!=="linear"||x(i)},fe=[E,x,i,v,y],t[23]=E,t[24]=x,t[25]=i,t[26]=v,t[27]=y,t[28]=fe,t[29]=ne):(fe=t[28],ne=t[29]),c.useEffect(ne,fe);let te,ue;t[30]!==E||t[31]!==x||t[32]!==i||t[33]!==m||t[34]!==p?(te=()=>{!i||!m||p||E!=="pr"||x(i)},ue=[E,x,i,m,p],t[30]=E,t[31]=x,t[32]=i,t[33]=m,t[34]=p,t[35]=te,t[36]=ue):(te=t[35],ue=t[36]),c.useEffect(te,ue);const[Se,we]=c.useState(!1);let ye;t[37]!==$||t[38]!==h?(ye=ce=>{const{active:se,over:q}=ce;if(!q||se.id===q.id)return;const z=vu(Pe.getState().contextRailOrder,$).map(MS),ee=z.indexOf(se.id),ae=z.indexOf(q.id);ee===-1||ae===-1||h(zu(z,ee,ae))},t[37]=$,t[38]=h,t[39]=ye):ye=t[39];const Ae=ye;if(!i)return null;let pe;t[40]!==e?(pe=e("contextRail.aria.rail"),t[40]=e,t[41]=pe):pe=t[41];let O;t[42]!==re?(O=re.map(OS),t[42]=re,t[43]=O):O=t[43];let Q;if(t[44]!==E||t[45]!==X||t[46]!==F||t[47]!==i||t[48]!==K||t[49]!==f||t[50]!==j||t[51]!==re||t[52]!==e||t[53]!==a){let ce;t[55]!==E||t[56]!==X||t[57]!==F||t[58]!==i||t[59]!==K||t[60]!==f||t[61]!==j||t[62]!==e||t[63]!==a?(ce=(se,q)=>{const z=se.label??e(se.labelKey),ee=se.id==="git"&&!a?X:0,ae=Zn(se.mode)&&E!==se.mode?K[Di(se.mode)]??0:0,Ne=ee>0?ee:ae>0?ae:null,Ce=Ne!==null&&ee===0;return s.jsx(xS,{surface:se,isActive:E===se.mode,showActivityDot:!1,label:z,description:e(se.descriptionKey),badgeCount:Ne,badgeAriaLabel:Ne!==null?e(Ce?Ne===1?"contextRail.surface.plugin.badgeAriaSingle":"contextRail.surface.plugin.badgeAriaPlural":Ne===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:z,count:Ne}):null,badgeDescription:Ne!==null?e(Ce?Ne===1?"contextRail.surface.plugin.badgeTooltipSingle":"contextRail.surface.plugin.badgeTooltipPlural":Ne===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:Ne}):null,orderNumber:q+1,showOrderNumber:j,onSelect:We=>{Zn(We.mode)&&F(Di(We.mode)),f(i,We.mode)}},se.id)},t[55]=E,t[56]=X,t[57]=F,t[58]=i,t[59]=K,t[60]=f,t[61]=j,t[62]=e,t[63]=a,t[64]=ce):ce=t[64],Q=re.map(ce),t[44]=E,t[45]=X,t[46]=F,t[47]=i,t[48]=K,t[49]=f,t[50]=j,t[51]=re,t[52]=e,t[53]=a,t[54]=Q}else Q=t[54];let le;t[65]!==O||t[66]!==Q?(le=s.jsx(Wa,{items:O,strategy:Wu,children:Q}),t[65]=O,t[66]=Q,t[67]=le):le=t[67];let H;t[68]!==Ae||t[69]!==L||t[70]!==le?(H=s.jsx(Zo,{sensors:L,collisionDetection:ei,onDragEnd:Ae,children:le}),t[68]=Ae,t[69]=L,t[70]=le,t[71]=H):H=t[71];let me;t[72]!==e?(me=e("contextRail.configure.open"),t[72]=e,t[73]=me):me=t[73];let ge;t[74]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>we(!0),t[74]=ge):ge=t[74];let oe;t[75]===Symbol.for("react.memo_cache_sentinel")?(oe=s.jsx(M,{name:"equalizer-2",className:"h-[18px] w-[18px]"}),t[75]=oe):oe=t[75];let de;t[76]!==me?(de=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":me,onClick:ge,className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground",children:oe})}),t[76]=me,t[77]=de):de=t[77];let _;t[78]!==e?(_=e("contextRail.configure.open"),t[78]=e,t[79]=_):_=t[79];let B;t[80]!==_?(B=s.jsx(Dt,{side:"left",sideOffset:8,children:_}),t[80]=_,t[81]=B):B=t[81];let he;t[82]!==de||t[83]!==B?(he=s.jsxs(Nt,{delayDuration:Rf,children:[de,B]}),t[82]=de,t[83]=B,t[84]=he):he=t[84];let ve;t[85]!==Se?(ve=s.jsx(cS,{open:Se,onOpenChange:we}),t[85]=Se,t[86]=ve):ve=t[86];let Re;return t[87]!==pe||t[88]!==H||t[89]!==he||t[90]!==ve?(Re=s.jsxs("nav",{"aria-label":pe,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:[H,he,ve]}),t[87]=pe,t[88]=H,t[89]=he,t[90]=ve,t[91]=Re):Re=t[91],Re};function yS(t){return t.workStatusPanelVisible}function wS(t){return t.contextRailOrder}function vS(t){return t.contextRailHiddenSurfaces}function SS(t){return t.setContextRailOrder}function jS(t){return t.openContextSurface}function kS(t){return t.closeContextPanel}function CS(t){return t.shortcutOverrides}function NS(t){return t.planModeEnabled}function AS(t){return t.hasChecked}function DS(t){return t.status?.connected===!0}function PS(t){return t.hasChecked}function IS(t){return t.status?.connected===!0}function TS(t){return t.length===1&&t>="0"&&t<="9"}function ES(t){return t.countByGuest}function RS(t){return t.clearBadge}function MS(t){return t.id}function OS(t){return t.id}const BS=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),FS=(t,e,n,r)=>!n||r!==n||t.length===0?[]:_r(t,e,i=>i.relativePath||i.name,{limit:10,threshold:.4}),_S=new Set,LS=[],la=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const i=r==="/",o=/^[A-Za-z]:\/$/.test(r);return!i&&!o&&(r=r.replace(/\/+$/,"")),r},$S=()=>{const t=Ze.c(183),{t:e}=jt(),n=Pe(zS),r=Pe(WS),i=Pe(KS),o=Pe(VS),l=Pe(US),a=Pe(HS),d=Pe(GS),u=Pe(qS),h=Pe(YS),f=Pe(QS),x=Pe(XS),b=Pe(JS),w=Pe(ZS),v=tt(e0),y=tt(t0),m=tt(s0),p=Gr(n0);let S;t[0]!==n?(S=qe=>n?qe.activeSessions:LS,t[0]=n,t[1]=S):S=t[1];const g=$s(S);let C;t[2]!==n?(C=qe=>n?qe.ids:_S,t[2]=n,t[3]=C):C=t[3];const k=Gr(C);let j;t[4]!==n?(j=qe=>n?qe.rankById:Ea,t[4]=n,t[5]=j):j=t[5];const D=Ta(j),I=ns(r0),A=Ht(o0),P=Ht(i0),T=ir(),L=Rd(a0),{files:$,git:K}=vn(),F=Tn(l0),{isMobile:W}=zn();let N;t[6]!==T?(N=T?la(T):null,t[6]=T,t[7]=N):N=t[7];const R=N,[E,X]=c.useState(""),re=xu(E,200).trim();let fe;t[8]!==E?(fe=E.trim(),t[8]=E,t[9]=fe):fe=t[9];const ne=fe;let te,ue;t[10]!==n?(te=()=>{n&&X("")},ue=[n],t[10]=n,t[11]=te,t[12]=ue):(te=t[11],ue=t[12]),c.useEffect(te,ue);let Se,we;t[13]!==g||t[14]!==F||t[15]!==K||t[16]!==n?(Se=()=>{if(!n||!K)return;const qe=setTimeout(()=>{const ze=new Set;for(const ft of g){const Be=Ds(ft);!Be||ze.has(Be)||(ze.add(Be),F(Be,K))}},0);return()=>clearTimeout(qe)},we=[n,g,K,F],t[13]=g,t[14]=F,t[15]=K,t[16]=n,t[17]=Se,t[18]=we):(Se=t[17],we=t[18]),c.useEffect(Se,we);let ye;t[19]!==r?(ye=()=>r(!1),t[19]=r,t[20]=ye):ye=t[20];const Ae=ye;let pe;t[21]!==Ae?(pe=qe=>()=>{Ae(),qe()},t[21]=Ae,t[22]=pe):pe=t[22];const O=pe;let Q;t[23]!==A?.id||t[24]!==A?.path||t[25]!==I||t[26]!==m||t[27]!==W||t[28]!==d||t[29]!==u||t[30]!==x||t[31]!==v||t[32]!==O||t[33]!==b||t[34]!==w||t[35]!==l||t[36]!==i||t[37]!==e||t[38]!==p||t[39]!==a?(Q=()=>{const qe=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(M,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:O(()=>{l(!1),v()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(M,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:O(c0)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(M,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:O(d0)},{id:"toggle-sidebar",title:e(W?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(M,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(W?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:O(()=>{if(W){const{isSessionSwitcherOpen:ze}=Pe.getState();l(!ze)}else a()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(M,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:O(()=>{I&&u(I,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(M,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:O(()=>{I&&d(I)})},{id:"cycle-theme",secondary:!0,title:e("commandPalette.item.cycleTheme"),icon:s.jsx(M,{name:"palette",className:"mr-2 h-4 w-4"}),shortcutId:"cycle_theme",searchText:e("commandPalette.item.cycleTheme"),onSelect:O(u0)},{id:"open-status",secondary:!0,title:e("commandPalette.item.showOpenCodeStatus"),icon:s.jsx(M,{name:"pulse",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showOpenCodeStatus"),onSelect:O(f0)},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(M,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:O(()=>i(!0))}];return qe.push({id:"pin-session",secondary:!0,title:e("commandPalette.item.pinSession"),icon:s.jsx(M,{name:"pushpin",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.pinSession"),onSelect:O(()=>{m&&I&&p({directory:I,sessionId:m})})},{id:"copy-session-id",secondary:!0,title:e("commandPalette.item.copySessionId"),icon:s.jsx(M,{name:"file-copy",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.copySessionId"),onSelect:O(()=>{m&&gn(m).then(ze=>{if(ze.ok){Le.success(e("sessions.sidebar.session.copyId.success"));return}Le.error(e("sessions.sidebar.session.copyId.error"))}).catch(()=>Le.error(e("sessions.sidebar.session.copyId.error")))})},{id:"open-multi-run",secondary:!0,title:e("commandPalette.item.openMultiRun"),icon:s.jsx(M,{name:"checkbox-multiple",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openMultiRun"),onSelect:O(()=>{l(!1),x()})},{id:"open-archive",secondary:!0,title:e("commandPalette.item.openArchive"),icon:s.jsx(M,{name:"archive",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openArchive"),onSelect:O(()=>{l(!1),b(!0)})},{id:"open-notes",secondary:!0,title:e("commandPalette.item.openNotes"),icon:s.jsx(M,{name:"sticky-note",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openNotes"),onSelect:O(()=>{I&&(w("notes"),u(I,"notes"))})},{id:"open-todos",secondary:!0,title:e("commandPalette.item.openTodos"),icon:s.jsx(M,{name:"checkbox-circle",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.openTodos"),onSelect:O(()=>{I&&(w("todos"),u(I,"notes"))})}),qe.push({id:"toggle-memory-debug",secondary:!0,title:e("commandPalette.item.toggleMemoryDebug"),icon:s.jsx(M,{name:"bug",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.toggleMemoryDebug"),onSelect:O(m0)}),Ur()&&qe.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(M,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:O(()=>{_n("desktop_open_draft_mini_chat_window",{directory:la(I||A?.path||""),projectId:A?.id??null}).catch(h0)})}),qe},t[23]=A?.id,t[24]=A?.path,t[25]=I,t[26]=m,t[27]=W,t[28]=d,t[29]=u,t[30]=x,t[31]=v,t[32]=O,t[33]=b,t[34]=w,t[35]=l,t[36]=i,t[37]=e,t[38]=p,t[39]=a,t[40]=Q):Q=t[40],A?.id,A?.path;let le;t[41]!==Q?(le=Q(),t[41]=Q,t[42]=le):le=t[42];const H=le,me=Pe(p0);let ge;t[43]===Symbol.for("react.memo_cache_sentinel")?(ge=xn(),t[43]=ge):ge=t[43];const oe=ge;let de,_;t[44]===Symbol.for("react.memo_cache_sentinel")?(de=$n(),_=!oe&&wa(),t[44]=de,t[45]=_):(de=t[44],_=t[45]);let B;t[46]!==W||t[47]!==me?(B={isVSCode:de,isWeb:_,isDesktop:oe,isMobile:W,routingAvailable:me},t[46]=W,t[47]=me,t[48]=B):B=t[48];const he=B;let ve;if(t[49]!==O||t[50]!==i||t[51]!==o||t[52]!==he){let qe;t[54]!==he?(qe=ft=>ft.isAvailable?ft.isAvailable(he):!0,t[54]=he,t[55]=qe):qe=t[55];let ze;t[56]!==O||t[57]!==i||t[58]!==o?(ze=ft=>{const Be=Nh(ft.slug)??"settings-3",Ke=(ft.keywords??[]).join(" ");return{id:`settings:${ft.slug}`,title:ft.title,icon:ft.slug==="mcp"?s.jsx(Hp,{className:"mr-2 h-4 w-4"}):s.jsx(M,{name:Be,className:"mr-2 h-4 w-4"}),searchText:`${ft.title} ${ft.group} ${Ke}`,onSelect:O(()=>{o(ft.slug),i(!0)})}},t[56]=O,t[57]=i,t[58]=o,t[59]=ze):ze=t[59],ve=Ch.filter(g0).filter(qe).map(ze),t[49]=O,t[50]=i,t[51]=o,t[52]=he,t[53]=ve}else ve=t[53];const Re=ve;let ce;if(t[60]!==g||t[61]!==k||t[62]!==D){const qe=g.filter(x0);ce=Wp(qe,k,D),t[60]=g,t[61]=k,t[62]=D,t[63]=ce}else ce=t[63];const se=ce,q=Su(),z=tt(b0);let ee;t[64]!==q||t[65]!==z?(ee=(qe,ze)=>{const ft=z.get(qe);return ft?.branch?ft.branch.trim()||null:ze&&q.get(ze)?.trim()||null},t[64]=q,t[65]=z,t[66]=ee):ee=t[66];const ae=ee;let Ne;t[67]===Symbol.for("react.memo_cache_sentinel")?(Ne=[],t[67]=Ne):Ne=t[67];const[Ce,We]=c.useState(Ne),[Ee,xe]=c.useState(""),$e=BS(R,re);let V;t[68]!==R||t[69]!==$e||t[70]!==n||t[71]!==L||t[72]!==We||t[73]!==xe||t[74]!==re?(V=()=>{if(!n){We([]),xe("");return}if(!$e){We([]),xe("");return}if(!R){We([]),xe("");return}let qe=!1;return L(R,re,40,{type:"file"}).then(ze=>{qe||(We(ze.map(y0)),xe($e))}).catch(()=>{qe||(We([]),xe($e))}),()=>{qe=!0}},t[68]=R,t[69]=$e,t[70]=n,t[71]=L,t[72]=We,t[73]=xe,t[74]=re,t[75]=V):V=t[75];let De;t[76]!==R||t[77]!==$e||t[78]!==n||t[79]!==L||t[80]!==re?(De=[n,R,re,$e,L],t[76]=R,t[77]=$e,t[78]=n,t[79]=L,t[80]=re,t[81]=De):De=t[81],c.useEffect(V,De);const Fe=ne.length>0;let _e;e:{if(!Fe){let ze;t[82]!==H?(ze=H.filter(w0).map(v0),t[82]=H,t[83]=ze):ze=t[83],_e=ze;break e}let qe;t[84]!==H||t[85]!==ne?(qe=_r(H,ne,S0,{limit:7,noFuzzy:!0}),t[84]=H,t[85]=ne,t[86]=qe):qe=t[86],_e=qe}const rt=_e;let ct;e:{if(!Fe){let ze;t[87]===Symbol.for("react.memo_cache_sentinel")?(ze=[],t[87]=ze):ze=t[87],ct=ze;break e}let qe;t[88]!==ne||t[89]!==Re?(qe=_r(Re,ne,j0,{limit:7,noFuzzy:!0}),t[88]=ne,t[89]=Re,t[90]=qe):qe=t[90],ct=qe}const et=ct;let pt;e:{if(!Fe){let ze;t[91]!==se?(ze=se.slice(0,5).map(k0),t[91]=se,t[92]=ze):ze=t[92],pt=ze;break e}let qe;t[93]!==ne||t[94]!==se?(qe=_r(se,ne,C0,{limit:7,threshold:.2}),t[93]=ne,t[94]=se,t[95]=qe):qe=t[95],pt=qe}const kt=pt;let wt;e:{if(!n){let ze;t[96]===Symbol.for("react.memo_cache_sentinel")?(ze=[],t[96]=ze):ze=t[96],wt=ze;break e}let qe;t[97]!==Ce||t[98]!==Ee||t[99]!==$e||t[100]!==re?(qe=FS(Ce,re,$e,Ee),t[97]=Ce,t[98]=Ee,t[99]=$e,t[100]=re,t[101]=qe):qe=t[101],wt=qe}const Xe=wt,yt=n&&$e.length>0&&Ee!==$e;let Rt;e:{if(!Fe){let ze;t[102]===Symbol.for("react.memo_cache_sentinel")?(ze=[],t[102]=ze):ze=t[102],Rt=ze;break e}let qe;if(t[103]!==ne||t[104]!==P){const ze=P.map(N0);qe=_r(ze,ne,A0,{limit:7,threshold:.4}),t[103]=ne,t[104]=P,t[105]=qe}else qe=t[105];Rt=qe}const be=Rt;let Ge,ut,Y,G,Z,je,Ie,Ve,Je,it,at,Ye,vt,Ue;if(t[106]!==ae||t[107]!==Ae||t[108]!==R||t[109]!==$||t[110]!==Fe||t[111]!==n||t[112]!==h||t[113]!==v||t[114]!==E||t[115]!==rt||t[116]!==Xe||t[117]!==be||t[118]!==kt||t[119]!==et||t[120]!==r||t[121]!==y||t[122]!==f||t[123]!==e){const qe=rt.map(D0),ze=et.map(P0),ft=kt.map(I0),Be=Fe?Xe.map(T0):[],Ke=Fe?be.map(E0):[];let He;e:{if(!Fe){He=["commands","sessions"];break e}const It=R0,bt=[{key:"commands",score:It(rt)},{key:"settings",score:It(et)},{key:"sessions",score:It(kt)},{key:"files",score:It(Xe)},{key:"projects",score:It(be)}];bt.sort(M0),He=bt.map(O0)}const nt=He,St=It=>{Ae(),y(It.id,Ds(It))},Lt=async It=>{if(!R)return;const bt=await uf($,It,{directory:R});if(!bt.ok){Le.error(ff(bt.reason));return}h(R,It),Ae()},Ut=(It,bt)=>{Ae(),v({selectedProjectId:It,directoryOverride:bt})},Bt=It=>er(Jr(It,f));G=ys,Ye=n,vt=r;let zt;t[138]!==e?(zt=e("commandPalette.title"),t[138]=e,t[139]=zt):zt=t[139];let _t;t[140]!==zt?(_t=s.jsx(Ps,{children:zt}),t[140]=zt,t[141]=_t):_t=t[141];let Yt;t[142]!==e?(Yt=e("commandPalette.description"),t[142]=e,t[143]=Yt):Yt=t[143];let Zt;t[144]!==Yt?(Zt=s.jsx(Is,{children:Yt}),t[144]=Yt,t[145]=Zt):Zt=t[145],t[146]!==_t||t[147]!==Zt?(Ue=s.jsxs(Vs,{className:"sr-only",children:[_t,Zt]}),t[146]=_t,t[147]=Zt,t[148]=Ue):Ue=t[148],Y=ws,it="overflow-hidden p-0",at=!0,ut=Gp,Ie=!1,Ve="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta";let es;t[149]!==e?(es=e("commandPalette.input.placeholder"),t[149]=e,t[150]=es):es=t[150],t[151]!==E||t[152]!==es?(Je=s.jsx(qp,{value:E,onValueChange:X,placeholder:es}),t[151]=E,t[152]=es,t[153]=Je):Je=t[153],Ge=Yp;let Vt;t[154]!==e?(Vt=e("commandPalette.empty.noResults"),t[154]=e,t[155]=Vt):Vt=t[155],t[156]!==Vt?(Z=s.jsx(Qp,{children:Vt}),t[156]=Vt,t[157]=Z):Z=t[157],je=nt.map(It=>It==="commands"&&qe.length>0?s.jsx(Ar,{children:qe.map(bt=>s.jsxs(Lr,{value:bt.id,onSelect:bt.onSelect,children:[bt.icon,s.jsx("span",{children:bt.title}),bt.shortcutId?s.jsx(Kp,{children:Bt(bt.shortcutId)}):null]},bt.id))},"commands"):It==="settings"&&ze.length>0?s.jsx(Ar,{children:ze.map(B0)},"settings"):It==="sessions"&&ft.length>0?s.jsx(Ar,{children:ft.map(bt=>{const cs=bt.title||e("commandPalette.session.untitled"),ms=Ds(bt),hs=ae(bt.id,ms);return s.jsxs(Lr,{value:`session:${bt.id}`,onSelect:()=>St(bt),children:[s.jsx(M,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:cs}),hs?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(M,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:hs})]}):null]},bt.id)})},"sessions"):It==="files"&&Be.length>0?s.jsx(Ar,{children:Be.map(bt=>{const cs=Vp(bt.relativePath||bt.name,{maxLength:80});return s.jsxs(Lr,{value:`file:${bt.path}`,onSelect:()=>{Lt(bt.path)},children:[s.jsx(Pa,{filePath:bt.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":bt.relativePath,children:cs})]},`file:${bt.path}`)})},"files"):It==="projects"&&Ke.length>0?s.jsx(Ar,{children:Ke.map(bt=>{const cs=bt.displayName;return s.jsxs(Lr,{value:`project:${bt.id}`,onSelect:()=>Ut(bt.id,bt.path),children:[s.jsx(M,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:cs}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:bt.path})]},`project:${bt.id}`)})},"projects"):null),t[106]=ae,t[107]=Ae,t[108]=R,t[109]=$,t[110]=Fe,t[111]=n,t[112]=h,t[113]=v,t[114]=E,t[115]=rt,t[116]=Xe,t[117]=be,t[118]=kt,t[119]=et,t[120]=r,t[121]=y,t[122]=f,t[123]=e,t[124]=Ge,t[125]=ut,t[126]=Y,t[127]=G,t[128]=Z,t[129]=je,t[130]=Ie,t[131]=Ve,t[132]=Je,t[133]=it,t[134]=at,t[135]=Ye,t[136]=vt,t[137]=Ue}else Ge=t[124],ut=t[125],Y=t[126],G=t[127],Z=t[128],je=t[129],Ie=t[130],Ve=t[131],Je=t[132],it=t[133],at=t[134],Ye=t[135],vt=t[136],Ue=t[137];let Pt;t[158]!==yt||t[159]!==e?(Pt=yt?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[158]=yt,t[159]=e,t[160]=Pt):Pt=t[160];let ke;t[161]!==Ge||t[162]!==Z||t[163]!==je||t[164]!==Pt?(ke=s.jsxs(Ge,{children:[Z,je,Pt]}),t[161]=Ge,t[162]=Z,t[163]=je,t[164]=Pt,t[165]=ke):ke=t[165];let xt;t[166]!==ut||t[167]!==Ie||t[168]!==Ve||t[169]!==Je||t[170]!==ke?(xt=s.jsxs(ut,{shouldFilter:Ie,className:Ve,children:[Je,ke]}),t[166]=ut,t[167]=Ie,t[168]=Ve,t[169]=Je,t[170]=ke,t[171]=xt):xt=t[171];let Ct;t[172]!==Y||t[173]!==it||t[174]!==at||t[175]!==xt?(Ct=s.jsx(Y,{className:it,showCloseButton:at,children:xt}),t[172]=Y,t[173]=it,t[174]=at,t[175]=xt,t[176]=Ct):Ct=t[176];let Tt;return t[177]!==G||t[178]!==Ye||t[179]!==vt||t[180]!==Ue||t[181]!==Ct?(Tt=s.jsxs(G,{open:Ye,onOpenChange:vt,children:[Ue,Ct]}),t[177]=G,t[178]=Ye,t[179]=vt,t[180]=Ue,t[181]=Ct,t[182]=Tt):Tt=t[182],Tt};function zS(t){return t.isCommandPaletteOpen}function WS(t){return t.setCommandPaletteOpen}function KS(t){return t.setSettingsDialogOpen}function VS(t){return t.setSettingsPage}function US(t){return t.setSessionSwitcherOpen}function HS(t){return t.toggleSidebar}function GS(t){return t.openContextOverview}function qS(t){return t.openContextSurface}function YS(t){return t.openContextFile}function QS(t){return t.shortcutOverrides}function XS(t){return t.openMultiRunLauncher}function JS(t){return t.setArchivePageOpen}function ZS(t){return t.setProjectContextTab}function e0(t){return t.openNewSessionDraft}function t0(t){return t.setCurrentSession}function s0(t){return t.currentSessionId}function n0(t){return t.toggle}function r0(t){return t.currentDirectory}function o0(t){return t.getActiveProject()}function i0(t){return t.projects}function a0(t){return t.searchFiles}function l0(t){return t.ensureStatus}function c0(){ju()}function d0(){fn.requestDirectoryDialog()}function u0(){Xp.invoke("cycle_theme")}function f0(){ku()}function m0(){window.dispatchEvent(new CustomEvent("openchamber:memory-debug-toggle"))}function h0(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function p0(t){return t.routingFeatureAvailable}function g0(t){return t.slug!=="home"}function x0(t){return!Up(t)}function b0(t){return t.worktreeMetadata}function y0(t){return{path:la(t.path),name:t.name,relativePath:t.relativePath}}function w0(t){return!t.secondary}function v0(t){return{item:t,score:0}}function S0(t){return t.searchText}function j0(t){return t.searchText}function k0(t){return{item:t,score:0}}function C0(t){return t.title||""}function N0(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function A0(t){return t.searchText}function D0(t){return t.item}function P0(t){return t.item}function I0(t){return t.item}function T0(t){return t.item}function E0(t){return t.item}function R0(t){return t.length?t[0].score:1/0}function M0(t,e){return t.score-e.score}function O0(t){return t.key}function B0(t){return s.jsxs(Lr,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const Tc=(t,e,n)=>er(Jr(t,e),n),F0=()=>{const t=Ze.c(74),{t:e}=jt(),n=Pe(_0),r=Pe(L0),i=Pe($0);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=$n(),t[0]=o):o=t[0];const l=o;let a,d,u,h,f,x,b,w,v,y,m,p;if(t[1]!==n||t[2]!==r||t[3]!==i||t[4]!==e){const N=[{categoryKey:"helpDialog.section.navigationCommands",items:[{id:"open_command_palette",descriptionKey:"helpDialog.item.openCommandPalette",icon:"command",keys:""},{id:"open_help",descriptionKey:"helpDialog.item.showKeyboardShortcuts",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"helpDialog.item.toggleSessionSidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"helpDialog.item.addSelectionToChat",icon:"add",keys:""},{id:"cycle_agent",keys:"",descriptionKey:"helpDialog.item.cycleAgent",icon:"ai-agent"},{id:"open_model_selector",descriptionKey:"helpDialog.item.openModelSelector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"helpDialog.item.navigateModels",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"helpDialog.item.adjustThinkingMode",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"helpDialog.item.cycleThinkingVariant",icon:"brain-ai-3",keys:""},{keys:[er("mod+shift+alt+n")],descriptionKey:"helpDialog.item.newWindow",icon:"window"}]},{categoryKey:"helpDialog.section.sessionManagement",items:[{id:"new_chat",descriptionKey:"helpDialog.item.createNewSession",icon:"add",keys:""},{id:"new_chat_worktree",descriptionKey:"helpDialog.item.createNewWorktreeDraft",icon:"git-branch",keys:""},{id:"open_draft_project_picker",icon:"folder",keys:""},{id:"open_draft_worktree_picker",icon:"git-branch",keys:""},{id:"open_session_list",icon:"list-unordered",keys:""},{id:"focus_input",descriptionKey:"helpDialog.item.focusChatInput",icon:"text",keys:""},{id:"toggle_prompt_navigator",descriptionKey:"helpDialog.item.togglePromptNavigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"helpDialog.item.abortActiveRun",icon:"close-circle",keys:""}]},{categoryKey:"helpDialog.section.panels",items:[{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${er(Li("switch_context_surface",i))} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",icon:"layout-right"},{keys:[`${er(Li("switch_session_tab",i))} + 1...9`],descriptionKey:"helpDialog.item.switchSessionTab",icon:"layout-right"}]},{categoryKey:"helpDialog.section.interface",items:[{id:"cycle_theme",descriptionKey:"helpDialog.item.cycleTheme",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];u=ys,m=n,p=r,d=ws,v="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let R;t[17]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(M,{name:"command",className:"h-5 w-5"}),t[17]=R):R=t[17];let E;t[18]!==e?(E=e("helpDialog.title"),t[18]=e,t[19]=E):E=t[19];let X;t[20]!==E?(X=s.jsxs(Ps,{className:"flex items-center gap-2",children:[R,E]}),t[20]=E,t[21]=X):X=t[21];let J;t[22]!==e?(J=e("helpDialog.description"),t[22]=e,t[23]=J):J=t[23];let re;t[24]!==J?(re=s.jsx(Is,{children:J}),t[24]=J,t[25]=re):re=t[25],t[26]!==X||t[27]!==re?(y=s.jsxs(Vs,{children:[X,re]}),t[26]=X,t[27]=re,t[28]=y):y=t[28],a=yn,x="flex-1 min-h-0 mt-3",b="pr-1",w=!0,h="space-y-4",f=N.map(fe=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(fe.categoryKey)}),s.jsx("div",{className:"space-y-1",children:fe.items.filter(ne=>!(l&&ne.id==="toggle_prompt_navigator")).map(ne=>{const te=ne.id?Jp(ne.id):void 0,ue=ne.descriptionKey??(te?.customizable?te.settingsLabelKey:void 0);if(!ue||ne.id&&!Jr(ne.id,i))return null;const Se=ne.id?Tc(ne.id,i,e("settings.openchamber.keyboardShortcuts.unassigned")):Array.isArray(ne.keys)?ne.keys:ne.keys.split(" / ");return s.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[ne.icon&&s.jsx(M,{name:ne.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(ue)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(Se)?Se:[Se]).map((we,ye)=>s.jsxs(c.Fragment,{children:[ye>0&&s.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:e("helpDialog.keyCombiner.or")}),s.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:we})]},`${we}-${ye}`))})]},ne.id||ue)})})]},fe.categoryKey)),t[1]=n,t[2]=r,t[3]=i,t[4]=e,t[5]=a,t[6]=d,t[7]=u,t[8]=h,t[9]=f,t[10]=x,t[11]=b,t[12]=w,t[13]=v,t[14]=y,t[15]=m,t[16]=p}else a=t[5],d=t[6],u=t[7],h=t[8],f=t[9],x=t[10],b=t[11],w=t[12],v=t[13],y=t[14],m=t[15],p=t[16];let S;t[29]!==h||t[30]!==f?(S=s.jsx("div",{className:h,children:f}),t[29]=h,t[30]=f,t[31]=S):S=t[31];let g;t[32]===Symbol.for("react.memo_cache_sentinel")?(g=s.jsx(M,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[32]=g):g=t[32];let C;t[33]!==e?(C=e("helpDialog.proTips.title"),t[33]=e,t[34]=C):C=t[34];let k;t[35]!==C?(k=s.jsx("p",{className:"font-medium mb-1",children:C}),t[35]=C,t[36]=k):k=t[36];let j;t[37]!==i||t[38]!==e?(j=e("helpDialog.proTips.commandPalette",{shortcut:Tc("open_command_palette",i,e("settings.openchamber.keyboardShortcuts.unassigned"))}),t[37]=i,t[38]=e,t[39]=j):j=t[39];let D;t[40]!==j?(D=s.jsxs("li",{children:["• ",j]}),t[40]=j,t[41]=D):D=t[41];let I;t[42]!==e?(I=e("helpDialog.proTips.recentSessions"),t[42]=e,t[43]=I):I=t[43];let A;t[44]!==I?(A=s.jsxs("li",{children:["• ",I]}),t[44]=I,t[45]=A):A=t[45];let P;t[46]!==e?(P=e("helpDialog.proTips.leaderSequences"),t[46]=e,t[47]=P):P=t[47];let T;t[48]!==P?(T=s.jsxs("li",{children:["• ",P]}),t[48]=P,t[49]=T):T=t[49];let L;t[50]!==D||t[51]!==A||t[52]!==T?(L=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[D,A,T]}),t[50]=D,t[51]=A,t[52]=T,t[53]=L):L=t[53];let $;t[54]!==k||t[55]!==L?($=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[g,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[k,L]})]})}),t[54]=k,t[55]=L,t[56]=$):$=t[56];let K;t[57]!==a||t[58]!==S||t[59]!==$||t[60]!==x||t[61]!==b||t[62]!==w?(K=s.jsxs(a,{outerClassName:x,className:b,disableHorizontal:w,children:[S,$]}),t[57]=a,t[58]=S,t[59]=$,t[60]=x,t[61]=b,t[62]=w,t[63]=K):K=t[63];let F;t[64]!==d||t[65]!==K||t[66]!==v||t[67]!==y?(F=s.jsxs(d,{className:v,children:[y,K]}),t[64]=d,t[65]=K,t[66]=v,t[67]=y,t[68]=F):F=t[68];let W;return t[69]!==u||t[70]!==F||t[71]!==m||t[72]!==p?(W=s.jsx(u,{open:m,onOpenChange:p,children:F}),t[69]=u,t[70]=F,t[71]=m,t[72]=p,t[73]=W):W=t[73],W};function _0(t){return t.isHelpDialogOpen}function L0(t){return t.setHelpDialogOpen}function $0(t){return t.shortcutOverrides}const z0=()=>{const t=Ze.c(32),{t:e}=jt(),n=Pe(W0),r=Pe(K0),i=Pe(V0);let o;t[0]!==i||t[1]!==e?(o=async()=>{if(!i)return;if((await gn(i)).ok){Le.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Le.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=i,t[1]=e,t[2]=o):o=t[2];const l=o;let a;t[3]!==e?(a=e("openCodeStatusDialog.title"),t[3]=e,t[4]=a):a=t[4];let d;t[5]!==a?(d=s.jsx(Ps,{children:a}),t[5]=a,t[6]=d):d=t[6];let u;t[7]!==e?(u=e("openCodeStatusDialog.description"),t[7]=e,t[8]=u):u=t[8];let h;t[9]!==u?(h=s.jsx(Is,{children:u}),t[9]=u,t[10]=h):h=t[10];let f;t[11]!==d||t[12]!==h?(f=s.jsxs(Vs,{children:[d,h]}),t[11]=d,t[12]=h,t[13]=f):f=t[13];let x;t[14]!==e?(x=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=x):x=t[15];let b;t[16]!==l||t[17]!==x?(b=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:l,className:"app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:x})}),t[16]=l,t[17]=x,t[18]=b):b=t[18];let w;t[19]!==i||t[20]!==e?(w=i||e("openCodeStatusDialog.empty.noData"),t[19]=i,t[20]=e,t[21]=w):w=t[21];let v;t[22]!==w?(v=s.jsx("pre",{className:"max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap",children:w}),t[22]=w,t[23]=v):v=t[23];let y;t[24]!==f||t[25]!==b||t[26]!==v?(y=s.jsxs(ws,{className:"max-w-2xl",children:[f,b,v]}),t[24]=f,t[25]=b,t[26]=v,t[27]=y):y=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==y?(m=s.jsx(ys,{open:n,onOpenChange:r,children:y}),t[28]=n,t[29]=r,t[30]=y,t[31]=m):m=t[31],m};function W0(t){return t.isOpenCodeStatusDialogOpen}function K0(t){return t.setOpenCodeStatusDialogOpen}function V0(t){return t.openCodeStatusText}const U0=t=>{const e=Ze.c(16),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:i,sessionSearchInputRef:o,sessionSearchContainerRef:l}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==o?(d=()=>{if(!a||!r||typeof window>"u")return;const w=window.requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>window.cancelAnimationFrame(w)},u=[a,r,o],e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=u):(d=e[3],u=e[4]),c.useEffect(d,u);let h,f;e[5]!==a||e[6]!==o||e[7]!==i?(h=()=>{if(!a||typeof window>"u")return;const w=()=>{i(!0),o.current?.focus(),o.current?.select()};return window.addEventListener("openchamber:sidebar-session-search",w),()=>window.removeEventListener("openchamber:sidebar-session-search",w)},f=[a,i,o],e[5]=a,e[6]=o,e[7]=i,e[8]=h,e[9]=f):(h=e[8],f=e[9]),c.useEffect(h,f);let x,b;e[10]!==a||e[11]!==r||e[12]!==l||e[13]!==i?(x=()=>{if(!a||!r||typeof document>"u")return;const w=v=>{l.current&&(l.current.contains(v.target)||i(!1))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},b=[a,r,i,l],e[10]=a,e[11]=r,e[12]=l,e[13]=i,e[14]=x,e[15]=b):(x=e[14],b=e[15]),c.useEffect(x,b)},H0=t=>{const e=Ze.c(4);let n;e[0]!==t?(n=(o,l)=>{const a=t.get(o);if(!a||a.length===0)return l;const d=new Map(l.map(G0)),u=[];a.forEach(x=>{const b=d.get(x);b&&(u.push(b),d.delete(x))});const h=[],f=[];return l.forEach(x=>{d.has(x.id)&&(x.isArchivedBucket?f.push(x):h.push(x))}),[...h,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let i;return e[2]!==r?(i={getOrderedGroups:r},e[2]=r,e[3]=i):i=e[3],i};function G0(t){return[t.id,t]}const mo="oc.sessions.projectCollapse",Ec="oc.sessions.groupOrder",Rc="oc.sessions.groupCollapse",Mc=t=>{if(!t)return new Set;try{const e=Ka(jr()).safeParse(JSON.parse(t));return new Set(e.success?e.data:[])}catch{return new Set}},q0=t=>{if(!t)return new Map;try{const e=qu(jr(),Ka(jr())).safeParse(JSON.parse(t));if(!e.success)return new Map;const n=new Map;for(const[r,i]of Object.entries(e.data))n.set(r,i);return n}catch{return new Map}},Y0=t=>{const e=Ze.c(39),{isVSCode:n,projects:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Do(),e[0]=i):i=e[0];const o=i;let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>Mc(o.getItem(mo)),e[1]=l):l=e[1];const[a,d]=c.useState(l);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=()=>Mc(o.getItem(Rc)),e[2]=u):u=e[2];const[h,f]=c.useState(u);let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=()=>q0(o.getItem(Ec)),e[3]=x):x=e[3];const[b,w]=c.useState(x),v=c.useRef(0),y=c.useRef(!1),m=c.useRef(!1),p=c.useRef(null),S=c.useRef(null);let g;e[4]!==n?(g=()=>{if(n)return;const ye=S.current;if(S.current=null,p.current=null,!ye)return;const{projects:Ae}=Ht.getState(),pe=Ae.map(O=>({...O,sidebarCollapsed:ye.has(O.id)}));Br({projects:pe}).catch(Q0)},e[4]=n,e[5]=g):g=e[5];const C=g;let k;e[6]!==C||e[7]!==n?(k=ye=>{!globalThis.window||n||(S.current=ye,p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{C()},700))},e[6]=C,e[7]=n,e[8]=k):k=e[8];const j=k;let D,I;e[9]===Symbol.for("react.memo_cache_sentinel")?(D=()=>()=>{globalThis.window&&p.current!==null&&window.clearTimeout(p.current),p.current=null,S.current=null},I=[],e[9]=D,e[10]=I):(D=e[9],I=e[10]),c.useEffect(D,I);let A,P;e[11]!==b?(P=()=>{if(m.current)try{o.setItem(Ec,JSON.stringify(Object.fromEntries(b.entries())))}catch{}},A=[b,o],e[11]=b,e[12]=A,e[13]=P):(A=e[12],P=e[13]),c.useEffect(P,A);let T,L;e[14]!==h?(T=()=>{if(y.current)try{o.setItem(Rc,JSON.stringify(Array.from(h)))}catch{}},L=[h,o],e[14]=h,e[15]=T,e[16]=L):(T=e[15],L=e[16]),c.useEffect(T,L);let $;e[17]!==r||e[18]!==j?($=()=>{v.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const ye=new Set(r.map(X0));try{o.setItem(mo,JSON.stringify(Array.from(ye)))}catch{}return j(ye),ye})},e[17]=r,e[18]=j,e[19]=$):$=e[19];const K=$;let F;e[20]!==j?(F=()=>{v.current=Date.now()+150,y.current=!0,f(new Set),d(()=>{const ye=new Set;try{o.setItem(mo,JSON.stringify([]))}catch{}return j(ye),ye})},e[20]=j,e[21]=F):F=e[21];const W=F;let N;e[22]!==j?(N=ye=>{v.current=Date.now()+150,d(Ae=>{const pe=new Set(Ae);pe.has(ye)?pe.delete(ye):pe.add(ye);try{o.setItem(mo,JSON.stringify(Array.from(pe)))}catch{}return j(pe),pe})},e[22]=j,e[23]=N):N=e[23];const R=N;let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=ye=>{y.current=!0,f(Ae=>{const pe=new Set(Ae);return pe.has(ye)?pe.delete(ye):pe.add(ye),pe})},e[24]=E):E=e[24];const X=E;let J;e[25]===Symbol.for("react.memo_cache_sentinel")?(J=ye=>{m.current=!0,w(ye)},e[25]=J):J=e[25];const re=J,{getOrderedGroups:fe}=H0(b);let ne;e[26]!==h||e[27]!==a||e[28]!==b?(ne={collapsedProjects:a,collapsedGroups:h,groupOrderByProject:b},e[26]=h,e[27]=a,e[28]=b,e[29]=ne):ne=e[29];const te=ne;let ue;e[30]!==K||e[31]!==W||e[32]!==fe||e[33]!==j||e[34]!==R?(ue={setCollapsedProjects:d,toggleProject:R,collapseAllProjects:K,expandAllProjects:W,scheduleCollapsedProjectsPersist:j,setCollapsedGroups:f,toggleGroup:X,setGroupOrderByProject:re,getOrderedGroups:fe},e[30]=K,e[31]=W,e[32]=fe,e[33]=j,e[34]=R,e[35]=ue):ue=e[35];const Se=ue;let we;return e[36]!==Se||e[37]!==te?(we={state:te,actions:Se},e[36]=Se,e[37]=te,e[38]=we):we=e[38],we};function Q0(){}function X0(t){return t.id}const J0=5*6e4,Z0=t=>{const e=Ze.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:i,setProjectRepoStatus:o,setProjectRootBranches:l}=t,a=r===void 0?!0:r,{git:d}=vn(),u=Tn(e2);let h,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==o?(h=()=>{if(!a||!d||n.length===0){o(new Map);return}n.forEach(k=>{$i(()=>u(k.normalizedPath,d))})},f=[a,n,d,u,o],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=o,e[5]=h,e[6]=f):(h=e[5],f=e[6]),c.useEffect(h,f);let x,b;e[7]!==a||e[8]!==i||e[9]!==n||e[10]!==o?(x=()=>{if(!a)return;const k=new Map;n.forEach(j=>{k.set(j.id,i.get(j.normalizedPath)?.isGitRepo??null)}),o(k)},b=[a,n,i,o],e[7]=a,e[8]=i,e[9]=n,e[10]=o,e[11]=x,e[12]=b):(x=e[11],b=e[12]),c.useEffect(x,b);let w;if(e[13]!==i||e[14]!==n){let k;e[16]!==i?(k=j=>{const D=i.get(j.normalizedPath)?.branch??"";return`${j.id}:${D}`},e[16]=i,e[17]=k):k=e[17],w=n.map(k).join("|"),e[13]=i,e[14]=n,e[15]=w}else w=e[15];const v=w;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=new Map,e[18]=y):y=e[18];const m=c.useRef(y);let p;e[19]===Symbol.for("react.memo_cache_sentinel")?(p=new Map,e[19]=p):p=e[19];const S=c.useRef(p);let g;e[20]!==a||e[21]!==i||e[22]!==n||e[23]!==l?(g=()=>{if(!a)return;let k=!1;const j=setTimeout(()=>{(async()=>{const I=new Set(n.map(t2));for(const K of m.current.keys())I.has(K)||(m.current.delete(K),S.current.delete(K));const A=Date.now(),P=n.filter(K=>{const F=i.get(K.normalizedPath);if(F?.isGitRepo===!1)return m.current.delete(K.id),S.current.delete(K.id),!1;if(F?.isGitRepo!==!0||F.branch===null)return!1;const W=F.branch.trim(),N=`${K.normalizedPath}\0${W}`,R=m.current.get(K.id);if(R===N){const E=S.current.get(K.id);return E&&(E.at=A),!1}return!(R!==void 0&&A-(S.current.get(K.id)?.at??0)<J0)});if(P.length===0)return;const T=await Zp(P,2,async K=>{const F=i.get(K.normalizedPath)?.branch?.trim()??"",W=`${K.normalizedPath}\0${F}`,N=await $i(()=>Aa(K.normalizedPath,F?{knownBranch:F}:void 0)).catch(s2);return{id:K.id,inputKey:W,branch:N}});if(k)return;const L=T.filter(n2);if(L.length===0)return;const $=Date.now();l(K=>{const F=new Map(K);return L.forEach(W=>{const{id:N,branch:R}=W;R&&F.set(N,R)}),F}),L.forEach(K=>{const{id:F,inputKey:W,branch:N}=K;m.current.set(F,W),N&&S.current.set(F,{branch:N,at:$})})})()},150);return()=>{k=!0,clearTimeout(j)}},e[20]=a,e[21]=i,e[22]=n,e[23]=l,e[24]=g):g=e[24];let C;e[25]!==a||e[26]!==i||e[27]!==n||e[28]!==v||e[29]!==l?(C=[a,n,v,i,l],e[25]=a,e[26]=i,e[27]=n,e[28]=v,e[29]=l,e[30]=C):C=e[30],c.useEffect(g,C)};function e2(t){return t.ensureStatus}function t2(t){return t.id}function s2(){return null}function n2(t){return t.branch}const r2=t=>{const e=Ze.c(10),{open:n,onOpenChange:r,project:i,onSave:o}=t;let l;e[0]!==o||e[1]!==n||e[2]!==i?(l=n&&i?s.jsx(Ah,{project:i,onIdentitySave:o,showWorktrees:!1}):null,e[0]=o,e[1]=n,e[2]=i,e[3]=l):l=e[3];let a;e[4]!==l?(a=s.jsx(ws,{className:"w-full max-w-2xl gap-0 overflow-hidden p-0",children:s.jsx(yn,{outerClassName:"max-h-[min(90vh,48rem)]",className:"w-full bg-transparent",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:l})})}),e[4]=l,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(ys,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function o2(t){const e=Ze.c(218),{t:n}=jt(),r=Cu(),{hideDirectoryControls:i,showProjectDisplayControls:o,showRecentControls:l,handleOpenDirectoryDialog:a,onOpenScheduled:d,onOpenMultiRun:u,canOpenMultiRun:h,onOpenArchive:f,headerActionIconClass:x,headerActionButtonClass:b,isSessionSearchOpen:w,setIsSessionSearchOpen:v,sessionSearchInputRef:y,sessionSearchQuery:m,setSessionSearchQuery:p,hasSessionSearchQuery:S,searchMatchCount:g,collapseAllProjects:C,expandAllProjects:k}=t,j=fs(y2),D=fs(b2),I=us(x2),A=us(g2),P=us(p2),T=us(h2),L=us(m2),$=us(f2),K=us(u2),F=us(d2),W=us(c2),N=us(l2),R=o&&W==="single";if(i)return null;let E;e[0]!==b?(E=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=b,e[1]=E):E=e[1];let X;e[2]!==n?(X=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=X):X=e[3];let J;e[4]!==x?(J=s.jsx(M,{name:"folder-add",className:x}),e[4]=x,e[5]=J):J=e[5];let re;e[6]!==a||e[7]!==E||e[8]!==X||e[9]!==J?(re=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:E,"aria-label":X,children:J})}),e[6]=a,e[7]=E,e[8]=X,e[9]=J,e[10]=re):re=e[10];let fe;e[11]!==n?(fe=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=fe):fe=e[12];let ne;e[13]!==fe?(ne=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:fe})}),e[13]=fe,e[14]=ne):ne=e[14];let te;e[15]!==re||e[16]!==ne?(te=s.jsxs(Nt,{children:[re,ne]}),e[15]=re,e[16]=ne,e[17]=te):te=e[17];let ue;e[18]!==b?(ue=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=b,e[19]=ue):ue=e[19];let Se;e[20]!==n?(Se=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=Se):Se=e[21];let we;e[22]!==x?(we=s.jsx(M,{name:"calendar-schedule",className:x}),e[22]=x,e[23]=we):we=e[23];let ye;e[24]!==d||e[25]!==ue||e[26]!==Se||e[27]!==we?(ye=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:d,className:ue,"aria-label":Se,children:we})}),e[24]=d,e[25]=ue,e[26]=Se,e[27]=we,e[28]=ye):ye=e[28];let Ae;e[29]!==n?(Ae=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=Ae):Ae=e[30];let pe;e[31]!==Ae?(pe=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ae})}),e[31]=Ae,e[32]=pe):pe=e[32];let O;e[33]!==ye||e[34]!==pe?(O=s.jsxs(Nt,{children:[ye,pe]}),e[33]=ye,e[34]=pe,e[35]=O):O=e[35];let Q;e[36]!==b?(Q=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=b,e[37]=Q):Q=e[37];let le;e[38]!==n?(le=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=le):le=e[39];const H=!h;let me;e[40]!==x?(me=s.jsx(sg,{className:x}),e[40]=x,e[41]=me):me=e[41];let ge;e[42]!==u||e[43]!==Q||e[44]!==le||e[45]!==H||e[46]!==me?(ge=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:Q,"aria-label":le,disabled:H,children:me})}),e[42]=u,e[43]=Q,e[44]=le,e[45]=H,e[46]=me,e[47]=ge):ge=e[47];let oe;e[48]!==n?(oe=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=oe):oe=e[49];let de;e[50]!==oe?(de=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:oe})}),e[50]=oe,e[51]=de):de=e[51];let _;e[52]!==ge||e[53]!==de?(_=s.jsxs(Nt,{children:[ge,de]}),e[52]=ge,e[53]=de,e[54]=_):_=e[54];let B;e[55]!==b?(B=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=b,e[56]=B):B=e[56];let he;e[57]!==n?(he=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=he):he=e[58];let ve;e[59]!==x?(ve=s.jsx(M,{name:"archive",className:x}),e[59]=x,e[60]=ve):ve=e[60];let Re;e[61]!==f||e[62]!==B||e[63]!==he||e[64]!==ve?(Re=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:B,"aria-label":he,children:ve})}),e[61]=f,e[62]=B,e[63]=he,e[64]=ve,e[65]=Re):Re=e[65];let ce;e[66]!==n?(ce=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=ce):ce=e[67];let se;e[68]!==ce?(se=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ce})}),e[68]=ce,e[69]=se):se=e[69];let q;e[70]!==Re||e[71]!==se?(q=s.jsxs(Nt,{children:[Re,se]}),e[70]=Re,e[71]=se,e[72]=q):q=e[72];let z;e[73]!==r||e[74]!==x||e[75]!==n?(z=r.length>0&&s.jsxs(Ks,{children:[s.jsx(zs,{asChild:!0,children:s.jsx(dt,{variant:"ghost",size:"xs",className:"w-6 text-muted-foreground","aria-label":n("sessions.sidebar.header.actions.extensionPages"),children:s.jsx(M,{name:"apps",className:x})})}),s.jsxs(Ws,{align:"start",children:[s.jsx(Fr,{children:n("sessions.sidebar.header.actions.extensionPages")}),r.map(a2)]})]}),e[73]=r,e[74]=x,e[75]=n,e[76]=z):z=e[76];let ee;e[77]!==O||e[78]!==_||e[79]!==q||e[80]!==z||e[81]!==te?(ee=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[te,O,_,q,z]}),e[77]=O,e[78]=_,e[79]=q,e[80]=z,e[81]=te,e[82]=ee):ee=e[82];let ae;e[83]!==v?(ae=()=>v(i2),e[83]=v,e[84]=ae):ae=e[84];let Ne;e[85]!==b?(Ne=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[85]=b,e[86]=Ne):Ne=e[86];let Ce;e[87]!==n?(Ce=n("sessions.sidebar.header.actions.searchSessions"),e[87]=n,e[88]=Ce):Ce=e[88];let We;e[89]!==x?(We=s.jsx(M,{name:"search",className:x}),e[89]=x,e[90]=We):We=e[90];let Ee;e[91]!==w||e[92]!==ae||e[93]!==Ne||e[94]!==Ce||e[95]!==We?(Ee=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:ae,className:Ne,"aria-label":Ce,"aria-expanded":w,children:We})}),e[91]=w,e[92]=ae,e[93]=Ne,e[94]=Ce,e[95]=We,e[96]=Ee):Ee=e[96];let xe;e[97]!==n?(xe=n("sessions.sidebar.header.actions.searchSessions"),e[97]=n,e[98]=xe):xe=e[98];let $e;e[99]!==xe?($e=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:xe})}),e[99]=xe,e[100]=$e):$e=e[100];let V;e[101]!==Ee||e[102]!==$e?(V=s.jsxs(Nt,{children:[Ee,$e]}),e[101]=Ee,e[102]=$e,e[103]=V):V=e[103];const De=j&&"bg-interactive-hover text-primary";let Fe;e[104]!==b||e[105]!==De?(Fe=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent",De),e[104]=b,e[105]=De,e[106]=Fe):Fe=e[106];let _e;e[107]!==j||e[108]!==n?(_e=n(j?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[107]=j,e[108]=n,e[109]=_e):_e=e[109];let rt;e[110]!==x?(rt=s.jsx(M,{name:"checkbox-multiple",className:x}),e[110]=x,e[111]=rt):rt=e[111];let ct;e[112]!==j||e[113]!==Fe||e[114]!==_e||e[115]!==rt||e[116]!==D?(ct=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:D,className:Fe,"aria-label":_e,"aria-pressed":j,children:rt})}),e[112]=j,e[113]=Fe,e[114]=_e,e[115]=rt,e[116]=D,e[117]=ct):ct=e[117];let et;e[118]!==j||e[119]!==n?(et=n(j?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[118]=j,e[119]=n,e[120]=et):et=e[120];let pt;e[121]!==et?(pt=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:et})}),e[121]=et,e[122]=pt):pt=e[122];let kt;e[123]!==ct||e[124]!==pt?(kt=s.jsxs(Nt,{children:[ct,pt]}),e[123]=ct,e[124]=pt,e[125]=kt):kt=e[125];let wt;e[126]!==b?(wt=Oe(b,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[126]=b,e[127]=wt):wt=e[127];let Xe;e[128]!==n?(Xe=n("sessions.sidebar.header.displayMode.label"),e[128]=n,e[129]=Xe):Xe=e[129];let yt;e[130]!==x?(yt=s.jsx(M,{name:"equalizer-2",className:x}),e[130]=x,e[131]=yt):yt=e[131];let Rt;e[132]!==wt||e[133]!==Xe||e[134]!==yt?(Rt=s.jsx(At,{asChild:!0,children:s.jsx(zs,{asChild:!0,children:s.jsx("button",{type:"button",className:wt,"aria-label":Xe,children:yt})})}),e[132]=wt,e[133]=Xe,e[134]=yt,e[135]=Rt):Rt=e[135];let be;e[136]!==n?(be=n("sessions.sidebar.header.displayMode.label"),e[136]=n,e[137]=be):be=e[137];let Ge;e[138]!==be?(Ge=s.jsx(Dt,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:be})}),e[138]=be,e[139]=Ge):Ge=e[139];let ut;e[140]!==Rt||e[141]!==Ge?(ut=s.jsxs(Nt,{children:[Rt,Ge]}),e[140]=Rt,e[141]=Ge,e[142]=ut):ut=e[142];let Y;e[143]!==n?(Y=n("sessions.sidebar.header.actions.sortProjects"),e[143]=n,e[144]=Y):Y=e[144];let G;e[145]!==Y?(G=s.jsx(Fr,{children:Y}),e[145]=Y,e[146]=G):G=e[146];let Z;e[147]!==P||e[148]!==T||e[149]!==n?(Z=[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]].map(Ke=>{const[He,nt]=Ke;return s.jsxs(Kt,{onClick:()=>{T(He),Br({sidebarProjectSortOrder:He})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(nt)}),P===He?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},He)}),e[147]=P,e[148]=T,e[149]=n,e[150]=Z):Z=e[150];let je;e[151]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx(Os,{}),e[151]=je):je=e[151];let Ie;e[152]!==W||e[153]!==N||e[154]!==o||e[155]!==n?(Ie=o?s.jsxs(s.Fragment,{children:[s.jsx(Fr,{children:n("sessions.sidebar.header.projectDisplay.label")}),[["all","sessions.sidebar.header.projectDisplay.all"],["single","sessions.sidebar.header.projectDisplay.single"]].map(Ke=>{const[He,nt]=Ke;return s.jsxs(Kt,{onClick:()=>{N(He),Br({sidebarProjectDisplayMode:He})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(nt)}),W===He?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},He)}),s.jsx(Os,{})]}):null,e[152]=W,e[153]=N,e[154]=o,e[155]=n,e[156]=Ie):Ie=e[156];let Ve;e[157]!==n?(Ve=n("sessions.sidebar.header.grouping.label"),e[157]=n,e[158]=Ve):Ve=e[158];let Je;e[159]!==Ve?(Je=s.jsx(Fr,{children:Ve}),e[159]=Ve,e[160]=Je):Je=e[160];let it;e[161]!==L||e[162]!==$||e[163]!==n?(it=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(Ke=>{const[He,nt]=Ke;return s.jsxs(Kt,{onClick:()=>{$(He),Br({sidebarSessionGroupingMode:He})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n(nt)}),L===He?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]},He)}),e[161]=L,e[162]=$,e[163]=n,e[164]=it):it=e[164];let at;e[165]===Symbol.for("react.memo_cache_sentinel")?(at=s.jsx(Os,{}),e[165]=at):at=e[165];let Ye;e[166]!==R||e[167]!==l||e[168]!==I||e[169]!==n||e[170]!==A?(Ye=l&&!R?s.jsxs(Kt,{onClick:()=>{A(),Br({sidebarShowRecentSection:!I})},className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),I?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[166]=R,e[167]=l,e[168]=I,e[169]=n,e[170]=A,e[171]=Ye):Ye=e[171];let vt;e[172]!==n?(vt=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[172]=n,e[173]=vt):vt=e[173];let Ue;e[174]!==vt?(Ue=s.jsx("span",{children:vt}),e[174]=vt,e[175]=Ue):Ue=e[175];let Pt;e[176]!==K?(Pt=K?s.jsx(M,{name:"check",className:"h-4 w-4 text-primary"}):null,e[176]=K,e[177]=Pt):Pt=e[177];let ke;e[178]!==Ue||e[179]!==Pt||e[180]!==F?(ke=s.jsxs(Kt,{onClick:F,className:"flex items-center justify-between",children:[Ue,Pt]}),e[178]=Ue,e[179]=Pt,e[180]=F,e[181]=ke):ke=e[181];let xt;e[182]!==C||e[183]!==k||e[184]!==R||e[185]!==n?(xt=R?null:s.jsxs(s.Fragment,{children:[s.jsx(Os,{}),s.jsxs(Kt,{onClick:C,className:"flex items-center gap-2",children:[s.jsx(M,{name:"contract-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.collapseAll")})]}),s.jsxs(Kt,{onClick:k,className:"flex items-center gap-2",children:[s.jsx(M,{name:"expand-up-down",className:"h-4 w-4"}),s.jsx("span",{children:n("sessions.sidebar.header.displayMode.expandAll")})]})]}),e[182]=C,e[183]=k,e[184]=R,e[185]=n,e[186]=xt):xt=e[186];let Ct;e[187]!==G||e[188]!==Z||e[189]!==Ie||e[190]!==Je||e[191]!==it||e[192]!==Ye||e[193]!==ke||e[194]!==xt?(Ct=s.jsxs(Ws,{align:"end",className:"min-w-[180px]",children:[G,Z,je,Ie,Je,it,at,Ye,ke,xt]}),e[187]=G,e[188]=Z,e[189]=Ie,e[190]=Je,e[191]=it,e[192]=Ye,e[193]=ke,e[194]=xt,e[195]=Ct):Ct=e[195];let Tt;e[196]!==ut||e[197]!==Ct?(Tt=s.jsxs(Ks,{children:[ut,Ct]}),e[196]=ut,e[197]=Ct,e[198]=Tt):Tt=e[198];let qe;e[199]!==V||e[200]!==kt||e[201]!==Tt?(qe=s.jsxs("div",{className:"flex items-center gap-1.5",children:[V,kt,Tt]}),e[199]=V,e[200]=kt,e[201]=Tt,e[202]=qe):qe=e[202];let ze;e[203]!==ee||e[204]!==qe?(ze=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[ee,qe]}),e[203]=ee,e[204]=qe,e[205]=ze):ze=e[205];let ft;e[206]!==S||e[207]!==w||e[208]!==g||e[209]!==y||e[210]!==m||e[211]!==v||e[212]!==p||e[213]!==n?(ft=w?s.jsxs("div",{className:"pb-1",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80",children:[S?s.jsx("span",{children:g===1?n("sessions.sidebar.header.search.matchCountSingle",{count:g}):n("sessions.sidebar.header.search.matchCountPlural",{count:g})}):s.jsx("span",{}),s.jsx("span",{children:n("sessions.sidebar.header.search.escapeHint")})]}),s.jsx(Vd,{inputRef:y,value:m,onSearch:p,onClose:()=>v(!1),placeholder:n("sessions.sidebar.header.search.placeholder"),clearLabel:n("sessions.sidebar.header.search.clear")})]}):null,e[206]=S,e[207]=w,e[208]=g,e[209]=y,e[210]=m,e[211]=v,e[212]=p,e[213]=n,e[214]=ft):ft=e[214];let Be;return e[215]!==ze||e[216]!==ft?(Be=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 py-1",children:s.jsxs("div",{className:"flex h-auto min-h-8 flex-col gap-1",children:[ze,ft]})}),e[215]=ze,e[216]=ft,e[217]=Be):Be=e[217],Be}function i2(t){return!t}function a2(t){return s.jsxs(Kt,{onSelect:()=>Pe.getState().setOpenGuestPage(t.id),children:[s.jsx(Xr,{icon:tg(t.icon),iconSrc:eg(t.id,t.icon,ya().authenticatedAsset),className:"size-4"}),s.jsx("span",{children:t.pageTitle??t.name})]},t.id)}function l2(t){return t.setProjectDisplayMode}function c2(t){return t.projectDisplayMode}function d2(t){return t.toggleStickyZoneHeaders}function u2(t){return t.stickyZoneHeaders}function f2(t){return t.setSessionGroupingMode}function m2(t){return t.sessionGroupingMode}function h2(t){return t.setProjectSortOrder}function p2(t){return t.projectSortOrder}function g2(t){return t.toggleRecentSection}function x2(t){return t.showRecentSection}function b2(t){return t.toggleMode}function y2(t){return t.enabled}function w2(t){const e=Ze.c(8),{t:n}=jt(),r=t.onNewSession;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(M,{name:"chat-new",className:"h-4 w-4 flex-shrink-0"}),e[0]=i):i=e[0];let o;e[1]!==n?(o=n("sessions.sidebar.header.actions.newSession"),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==o?(l=s.jsx("span",{className:"truncate",children:o}),e[3]=o,e[4]=l):l=e[4];let a;return e[5]!==t.onNewSession||e[6]!==l?(a=s.jsx("div",{className:"select-none flex-shrink-0 px-2.5 pt-1.5",children:s.jsxs("button",{type:"button",onClick:r,className:"flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 text-left typography-ui-label font-normal text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[i,l]})}),e[5]=t.onNewSession,e[6]=l,e[7]=a):a=e[7],a}const wi="inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";function v2(t){const e=Ze.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:i,onOpenUpdate:o,showRuntimeButtons:l,showUpdateButton:a}=t,d=l===void 0?!0:l,u=a===void 0?!0:a,{t:h}=jt();if(!d&&!u)return null;let f;e[0]!==i||e[1]!==n||e[2]!==r||e[3]!==d||e[4]!==h?(f=d?s.jsxs(s.Fragment,{children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:wi,"aria-label":h("sessions.sidebar.footer.actions.settings"),children:s.jsx(M,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:wi,"aria-label":h("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(M,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:wi,"aria-label":h("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(M,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(Dt,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=i,e[1]=n,e[2]=r,e[3]=d,e[4]=h,e[5]=f):f=e[5];let x;e[6]!==o||e[7]!==u||e[8]!==h?(x=u?s.jsx(dt,{type:"button",variant:"default",size:"xs",className:"ml-auto border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)] hover:bg-[var(--status-info-background)]/80 hover:text-[var(--status-info)] dark:border-[var(--status-info-border)] dark:bg-[var(--status-info-background)] dark:hover:bg-[var(--status-info-background)]/80",onClick:o,children:h("sessions.sidebar.footer.actions.update")}):null,e[6]=o,e[7]=u,e[8]=h,e[9]=x):x=e[9];let b;return e[10]!==f||e[11]!==x?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[f,x]}),e[10]=f,e[11]=x,e[12]=b):b=e[12],b}const S2=t=>{for(const e of t.sessions.values())if(e.tabs.some(Od))return!0;return!1},j2=()=>{const t=Ze.c(4),{terminal:e}=vn(),n=Ot(S2);let r,i;return t[0]!==n||t[1]!==e?(r=()=>{const o=k2,l=C2;if(n)return Ii(e,"",l,o);let a=N2;return a=Ii(e,"",l,d=>{o(d),a()}),()=>a()},i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),c.useEffect(r,i),null};function k2(t){const e=Ot.getState(),n=Dh(t.sessions),r=new Set([...e.sessions.keys(),...n.keys()]);for(const i of r)e.reconcileServerSessions(i,n.get(i)??[],{startedActionMutationRevisions:t.startedActionMutationRevisions})}function C2(){return new Map(Ot.getState().actionMutationRevisions)}function N2(){}const A2=t=>{const e=Ze.c(12),{normalizedProjects:n,enabled:r,ownership:i,isSessionsLoading:o,hasAuthoritativeGlobalSessions:l,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:h,addSessionToFolder:f}=t,x=r===void 0?!0:r;let b,w;e[0]!==f||e[1]!==h||e[2]!==x||e[3]!==u||e[4]!==l||e[5]!==o||e[6]!==a||e[7]!==n||e[8]!==i||e[9]!==d?(b=()=>{!x||o||!l||a||n.forEach(v=>{if(d.has(v.normalizedPath))return;const y=Nu(v.normalizedPath),m=i.archivedSessionsByProject.get(v.id)??[],p=u[y]??[],S=new Map(p.map(D2));m.forEach(g=>{const C=ng(g,v.normalizedPath),k=C.toLowerCase();let j=S.get(k);j||(j=h(y,C),S.set(k,j)),j.sessionIds.includes(g.id)||f(y,j.id,g.id)})})},w=[n,x,i,o,l,a,d,u,h,f],e[0]=f,e[1]=h,e[2]=x,e[3]=u,e[4]=l,e[5]=o,e[6]=a,e[7]=n,e[8]=i,e[9]=d,e[10]=b,e[11]=w):(b=e[10],w=e[11]),c.useEffect(b,w)};function D2(t){return[t.name.toLowerCase(),t]}function P2({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:i,rememberedSessionId:o,fallbackSessionId:l}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(i.entries()).some(([h,f])=>h!==t&&f.has(e)));if(e&&r&&!u)return{kind:"preserve-current"}}if(!r||r.size===0)return{kind:"open-draft"};const d=(o&&r.has(o)?o:null)??l;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const I2=t=>{const e=Ze.c(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:o,currentSessionId:l,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:h,openNewSessionDraft:f,setSessionSwitcherOpen:x}=t;let b,w;if(e[0]!==n){w=new Map,b=new Map;const k=(j,D,I,A)=>{w.has(j)||w.set(j,new Map);const P=w.get(j);A.forEach(T=>{const L=ht(T.worktree?.path??T.session.directory??I??D);P.set(T.session.id,{directory:L}),b.has(j)||b.set(j,{id:T.session.id,directory:L}),T.children.length>0&&k(j,D,L,T.children)})};n.forEach(j=>{j.groups.forEach(D=>{k(j.project.id,j.project.normalizedPath,D.directory,D.sessions)})}),e[0]=n,e[1]=b,e[2]=w}else b=e[1],w=e[2];let v;e[3]!==b||e[4]!==w?(v={metaByProject:w,firstSessionByProject:b},e[3]=b,e[4]=w,e[5]=v):v=e[5];const y=v,m=c.useRef(null);let p,S;e[6]!==r||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==d||e[11]!==h||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==y||e[16]!==o||e[17]!==x?(p=()=>{if(!r||u||Pe.getState().isNewWorktreeDialogOpen||m.current===r)return;const k=n.find(A=>A.project.id===r);if(!k)return;const j=y.metaByProject.get(r);if(l&&j&&j.has(l)){m.current=r,o(A=>{if(A.get(r)===l)return A;const P=new Map(A);return P.set(r,l),P});return}const D=P2({activeProjectId:r,currentSessionId:l,currentSessionOwnerProjectId:a,projectMap:j,metaByProject:y.metaByProject,rememberedSessionId:i.get(r),fallbackSessionId:y.firstSessionByProject.get(r)?.id??null});if(D.kind==="preserve-current"){a===r&&(m.current=r);return}if(m.current=r,D.kind==="open-draft"){h&&x(!1),f({selectedProjectId:k.project.id,directoryOverride:k.project.normalizedPath});return}if(D.kind!=="select-session")return;const I=j?.get(D.sessionId)?.directory??null;d(D.sessionId,I)},S=[r,i,l,a,d,u,h,f,n,y,x,o],e[6]=r,e[7]=i,e[8]=l,e[9]=a,e[10]=d,e[11]=h,e[12]=u,e[13]=f,e[14]=n,e[15]=y,e[16]=o,e[17]=x,e[18]=p,e[19]=S):(p=e[18],S=e[19]),c.useLayoutEffect(p,S);let g,C;e[20]!==r||e[21]!==l||e[22]!==y||e[23]!==o?(g=()=>{if(!r||!l)return;const k=y.metaByProject.get(r);!k||!k.has(l)||o(j=>{if(j.get(r)===l)return j;const D=new Map(j);return D.set(r,l),D})},C=[r,l,y,o],e[20]=r,e[21]=l,e[22]=y,e[23]=o,e[24]=g,e[25]=C):(g=e[24],C=e[25]),c.useEffect(g,C)},T2=t=>{const e=Ze.c(20);let n,r,i,o;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:i,sessionOwnerBySessionId:o,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o):(n=e[1],r=e[2],i=e[3],o=e[4]);const l=tt(E2),a=tt(R2);let d;e[5]!==l||e[6]!==o?(d=l?o?.get(l)?.projectId??null:null,e[5]=l,e[6]=o,e[7]=d):d=e[7];const u=d;let h;e[8]!==r?(h=()=>new Map(r),e[8]=r,e[9]=h):h=e[9];const[f,x]=c.useState(h);let b;e[10]!==f||e[11]!==n||e[12]!==l||e[13]!==u||e[14]!==a?(b={...n,activeSessionByProject:f,setActiveSessionByProject:x,currentSessionId:l,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=l,e[13]=u,e[14]=a,e[15]=b):b=e[15],I2(b);let w,v;return e[16]!==f||e[17]!==i?(w=()=>{i(f)},v=[f,i],e[16]=f,e[17]=i,e[18]=w,e[19]=v):(w=e[18],v=e[19]),c.useEffect(w,v),null};function E2(t){return t.currentSessionId}function R2(t){return!!t.newSessionDraft?.open}const M2=(t,e)=>t?e.kind!==t.kind?e.kind==="project":e.projectRoot.length!==t.projectRoot.length?e.projectRoot.length>t.projectRoot.length:e.projectId.localeCompare(t.projectId)<0:!0,Oc=(t,e,n)=>{M2(t.get(e),n)&&t.set(e,n)},O2=t=>{const e=t;return ht(e.directory)??ht(e.project?.worktree)},B2=(t,e,n,r,i=[])=>{const o=new Map,l=new Map;for(const w of e){const v=ht(w.normalizedPath);if(!v)continue;const y=l.get(v);(!y||w.id.localeCompare(y.id)<0)&&l.set(v,w),Oc(o,v,{projectId:w.id,projectRoot:v,scopeDirectory:v,kind:"project"})}if(!r)for(const[w,v]of n){const y=ht(w),m=y?l.get(y):void 0;if(!(!m||!y))for(const p of v){const S=ht(p.path);S&&Oc(o,S,{projectId:m.id,projectRoot:y,scopeDirectory:S,kind:"worktree"})}}const a=new Map,d=new Map,u=new Map,h=new Map,f=new Map,x=w=>{if(!w)return null;if(a.has(w))return a.get(w)??null;if(r){const p=o.get(w)??null;return a.set(w,p),p}const v=[];let y=w,m=null;for(;y;){if(a.has(y)){m=a.get(y)??null;break}if(v.push(y),m=o.get(y)??null,m)break;y=Xm(y)}for(const p of v)a.set(p,m);return m},b=(w,v,y)=>{for(const m of w){const p=x(O2(m));if(!p)continue;d.set(m.id,p);const S=v.get(p.projectId);if(S?S.push(m):v.set(p.projectId,[m]),!y)continue;const g=y.get(p.scopeDirectory);g?g.add(m.id):y.set(p.scopeDirectory,new Set([m.id]))}};return b(t,u,f),b(i,h),{bySessionId:d,sessionsByProject:u,archivedSessionsByProject:h,sessionsByScope:f,directoryResolutions:a.size}},F2=t=>{const e=Ze.c(7),{ownership:n}=t;let r;e[0]!==n?(r=d=>n.sessionsByProject.get(d)??[],e[0]=n,e[1]=r):r=e[1];const i=r;let o;e[2]!==n?(o=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=o):o=e[3];const l=o;let a;return e[4]!==l||e[5]!==i?(a={getSessionsForProject:i,getArchivedSessionsForProject:l},e[4]=l,e[5]=i,e[6]=a):a=e[6],a},Yn=(t,e)=>`${t}\0${e}`,vr=(t,e)=>t??Ra(e)??ht(e??null),Yr=t=>{if(t.folderScopes&&t.folderScopes.length>0)return t.folderScopes;const e=t.folderScopeKey??ht(t.directory??null);return e?[{scopeKey:e,directory:t.directory}]:[]},Za=t=>t.startsWith("__archived__:"),_2=(t,e)=>t.map(n=>{const r=ht(n.path)??n.path;return`${r}=${e.get(r)??""}`}).join(`
|
|
879
879
|
`),L2=[],$2=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:o,projectRootBranches:l,gitBranches:a,lastRepoStatus:d,buildGroupedSessions:u,hasSessionSearchQuery:h,normalizedSessionSearchQuery:f,filterSessionNodesForSearch:x,buildGroupSearchText:b,foldersMap:w,standaloneGroups:v}=t,y=c.useRef(new Map),m=c.useMemo(()=>{const I=y.current,A=new Map;let P=0,T=0;const L=(K,F)=>K.length===F.length&&K.every((W,N)=>W===F[N]),$=e.map(K=>{const F=n(K.id),W=r(K.id),N=i.get(K.normalizedPath)??L2,R=o.has(K.id)?!!o.get(K.id):d,E=l.get(K.id)??null,X=_2(N,a),J=I.get(K.id);if(J&&J.project===K&&L(J.activeSessions,F)&&L(J.archivedSessions,W)&&J.availableWorktrees===N&&J.rootBranch===E&&J.worktreeBranchesKey===X&&J.isRepo===R&&J.buildGroupedSessions===u)return P+=1,A.set(K.id,J),J.section;if(T+=1,J){const te=J.project!==K?"project":L(J.activeSessions,F)?L(J.archivedSessions,W)?J.availableWorktrees!==N?"worktrees":J.rootBranch!==E?"branch":J.worktreeBranchesKey!==X?"worktreeBranches":J.isRepo!==R?"repo":"builder":"archived":"sessions";Gs(`ui.sidebar.project_section.rebuilt_reason.${te}`)}const re=Au([...F,...W]),fe=u(re,K.normalizedPath,N,E,R),ne={project:K,groups:fe};return A.set(K.id,{project:K,activeSessions:F,archivedSessions:W,availableWorktrees:N,rootBranch:E,worktreeBranchesKey:X,isRepo:R,buildGroupedSessions:u,section:ne}),ne});return y.current=A,P>0&&Gs("ui.sidebar.project_section.reused",P),T>0&&Gs("ui.sidebar.project_section.rebuilt",T),$},[e,n,r,i,o,d,u,l,a]),p=c.useMemo(()=>m,[m]),S=c.useMemo(()=>{const I=new WeakMap;if(!h)return I;const A=f.trim().toLowerCase(),P=A.startsWith("ses_"),T=$=>$.reduce((K,F)=>K+(!P||F.session.id.toLowerCase()===A?1:0)+T(F.children),0),L=$=>{const K=x($.sessions,f),F=T(K),W=!P&&Io([b($)],f),N=Yr($).flatMap(({scopeKey:E})=>w[E]??[]),R=P?0:N.filter(E=>Io([E.name],f)).length;I.set($,{filteredNodes:K,matchedSessionCount:F,folderNameMatchCount:R,groupMatches:W,hasMatch:W||F>0||R>0})};return p.forEach($=>{$.groups.forEach(L)}),v.forEach(L),I},[h,p,v,x,f,b,w]),g=c.useMemo(()=>h?p.map(I=>({...I,groups:I.groups.filter(A=>S.get(A)?.hasMatch===!0)})).filter(I=>I.groups.length>0):p,[h,p,S]),C=h?g:p,k=c.useRef(new WeakMap),j=c.useMemo(()=>{const I=k.current;return C.map(A=>{const P=I.get(A);if(P&&P.query===f)return P.section;const T=A.groups.filter(R=>!R.isArchivedBucket),L=A.groups.filter(R=>R.isArchivedBucket),$=T.flatMap(R=>h?S.get(R)?.filteredNodes??[]:R.sessions),K=T.map(R=>({scopeKey:R.folderScopeKey??ht(R.directory??null),directory:R.directory??null})).filter(R=>!!R.scopeKey),F=T.find(R=>R.isMain)??null,W={id:"flat",label:F?.label??"",branch:F?.branch??null,description:F?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:F?.directory??A.project.normalizedPath,folderScopeKey:F?.folderScopeKey??A.project.normalizedPath,folderScopes:K,sessions:$};if(h){const R=T.map(E=>S.get(E)).filter(E=>!!E);S.set(W,{filteredNodes:$,matchedSessionCount:R.reduce((E,X)=>E+X.matchedSessionCount,0),folderNameMatchCount:R.reduce((E,X)=>E+X.folderNameMatchCount,0),groupMatches:R.some(E=>E.groupMatches),hasMatch:R.some(E=>E.hasMatch)})}const N={project:A.project,groups:[W,...L]};return I.set(A,{query:f,section:N}),N})},[S,h,f,C]),D=c.useMemo(()=>{if(!h)return 0;const I=(P,T)=>{const L=S.get(T);if(!L)return P;const $=L.folderNameMatchCount+(L.groupMatches?1:0);return P+L.matchedSessionCount+$},A=C.reduce((P,T)=>T.groups.reduce(I,P),0);return v.reduce(I,A)},[h,C,v,S]);return{projectSections:m,visibleProjectSections:p,groupSearchDataByGroup:S,searchableProjectSections:g,sectionsForRender:C,flatSectionsForRender:j,searchMatchCount:D}},z2=180,Bc=150,W2=2,K2=8,Fc=[-1,1,-2,2],vi=t=>`${t.directory}
|
|
880
880
|
${t.sessionId}`,V2=t=>t?.directory?.trim()||null,U2=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:i})=>{const o=c.useRef(new Map),l=c.useRef([]),a=c.useRef(new Set),d=c.useRef(0),u=c.useMemo(()=>$n(),[]),h=c.useCallback(()=>{d.current+=1,l.current=[],o.current.forEach(b=>window.clearTimeout(b)),o.current.clear()},[]),f=c.useCallback(()=>{if(!(!t||u))for(;a.current.size<W2&&l.current.length>0;){const b=l.current.shift();if(!b)break;if(b.generation!==d.current||tt.getState().currentSessionId===b.sessionId||zi(b.sessionId,b.directory).renderable)continue;const v=vi(b);a.current.add(v),i({directory:b.directory,sessionID:b.sessionId}).catch(()=>{}).finally(()=>{a.current.delete(v),f()})}},[t,u,i]),x=c.useCallback(b=>{const w=b?.id,v=V2(b);if(!t||u||!w||!v||w===e)return;const y={sessionId:w,directory:v,generation:d.current},m=vi(y);if(zi(w,v).renderable||a.current.has(m)||l.current.some(g=>vi(g)===m))return;const p=o.current.get(m);p!==void 0&&window.clearTimeout(p);const S=window.setTimeout(()=>{if(o.current.delete(m),y.generation!==d.current)return;const g=l.current;g.length>=K2&&g.shift(),g.push(y),f()},z2);o.current.set(m,S)},[e,t,u,f]);c.useEffect(()=>{h()},[h,e,t,u]),c.useEffect(()=>{if(!t||u||!e||n.length===0)return;const b=window.setTimeout(()=>{const w=n.findIndex(v=>v.id===e);if(!(w<0))for(const v of Fc)x(n[w+v])},Bc);return()=>window.clearTimeout(b)},[e,t,u,x,n]),c.useEffect(()=>{if(!t||u||!e||r.length===0)return;const b=window.setTimeout(()=>{const w=r.findIndex(v=>v.id===e);if(!(w<0))for(const v of Fc)x(r[w+v])},Bc);return()=>window.clearTimeout(b)},[e,t,u,r,x]),c.useEffect(()=>h,[h])},H2=t=>{const e=Ze.c(3),n=tt(G2);let r;return e[0]!==t||e[1]!==n?(r={...t,currentSessionId:n},e[0]=t,e[1]=n,e[2]=r):r=e[2],U2(r),null};function G2(t){return t.currentSessionId}const q2=(t,e)=>{const n=new Set,r=new Set,i=(o,l)=>{n.add(o.session.id),(!l||e)&&r.add(o.session.id),o.children.forEach(a=>i(a,!0))};return t.forEach(o=>i(o,!1)),{active:n,unread:r}},el=t=>{const e=Ze.c(15),{nodes:n,includeUnreadSubtasks:r,enabled:i}=t,o=i===void 0?!0:i;let l;e[0]!==o||e[1]!==n?(l=o?n:[],e[0]=o,e[1]=n,e[2]=l):l=e[2];let a;e[3]!==r||e[4]!==l?(a=q2(l,r),e[3]=r,e[4]=l,e[5]=a):a=e[5];const d=a;let u;e[6]!==o||e[7]!==d.active?(u=v=>{if(!o)return null;for(const y of d.active){const m=v.statusById.get(y)?.status.type;if(m==="busy"||m==="retry")return"active"}return null},e[6]=o,e[7]=d.active,e[8]=u):u=e[8];const h=qo(u);let f;e[9]!==o||e[10]!==d.unread?(f=v=>{if(!o)return null;for(const y of d.unread)if((v.index.session.unseenCount[y]??0)>0)return"unread";return null},e[9]=o,e[10]=d.unread,e[11]=f):f=e[11];const x=Ma(f);let b;return e[12]!==o||e[13]!==d.active?(b=v=>{if(!o)return null;let y=null;for(const m of d.active){const p=v.bySession.get(m);if(p){if(p.permissions.length>0)return"permission";p.questions.length>0&&(y="question")}}return y},e[12]=o,e[13]=d.active,e[14]=b):b=e[14],Oa(b)??h??x};function Mf(t){const e=Ze.c(21),{state:n,className:r}=t,{t:i}=jt();if(n==="permission"||n==="question"){let h;e[0]!==n||e[1]!==i?(h=i(n==="permission"?"sessions.sidebar.session.status.permissionRequired":"sessions.sidebar.session.status.questionPending"),e[0]=n,e[1]=i,e[2]=h):h=e[2];const f=h,x=n==="permission"?"text-destructive":"text-status-info";let b;e[3]!==r||e[4]!==x?(b=Oe("inline-flex shrink-0 items-center",x,r),e[3]=r,e[4]=x,e[5]=b):b=e[5];const w=n==="permission"?"shield":"question";let v;e[6]!==w?(v=s.jsx(M,{name:w,className:"h-3 w-3"}),e[6]=w,e[7]=v):v=e[7];let y;return e[8]!==f||e[9]!==b||e[10]!==v?(y=s.jsx("span",{className:b,"aria-label":f,title:f,children:v}),e[8]=f,e[9]=b,e[10]=v,e[11]=y):y=e[11],y}let o;e[12]!==n||e[13]!==i?(o=i(n==="active"?"sessions.sidebar.session.status.active":"sessions.sidebar.session.status.unread"),e[12]=n,e[13]=i,e[14]=o):o=e[14];const l=o,a=n==="active"?"bg-primary":"bg-[var(--status-info)]";let d;e[15]!==r||e[16]!==a?(d=Oe("h-1.5 w-1.5 shrink-0 rounded-full",a,r),e[15]=r,e[16]=a,e[17]=d):d=e[17];let u;return e[18]!==l||e[19]!==d?(u=s.jsx("span",{className:d,"aria-label":l,title:l}),e[18]=l,e[19]=d,e[20]=u):u=e[20],u}const Y2=t=>{const e=Ze.c(5),{nodes:n,includeUnreadSubtasks:r}=t;let i;e[0]!==r||e[1]!==n?(i={nodes:n,includeUnreadSubtasks:r},e[0]=r,e[1]=n,e[2]=i):i=e[2];const o=el(i);if(!o)return null;let l;return e[3]!==o?(l=s.jsx(Mf,{state:o}),e[3]=o,e[4]=l):l=e[4],l},Q2=t=>{const e=Ze.c(83),{folder:n,displayName:r,sessions:i,subFolderItems:o,isCollapsed:l,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:h,children:f,renderBody:x,mobileVariant:b,alwaysShowActions:w,isRenaming:v,renameDraft:y,onRenameDraftChange:m,onRenameSave:p,onRenameCancel:S,droppableRef:g,isDropTarget:C,onNewSession:k,depth:j,hideActions:D,archivedBucket:I}=t,A=a===void 0?null:a,P=x===void 0?!0:x,L=w===void 0?b===void 0?!1:b:w,$=v===void 0?!1:v,K=y===void 0?"":y,F=C===void 0?!1:C,W=D===void 0?!1:D,N=I===void 0?!1:I,{t:R}=jt(),[E,X]=c.useState(!1),[J,re]=c.useState(""),fe=c.useRef(null),ne=$||E,te=$?K:J;let ue;e[0]!==n.name?(ue=()=>{re(n.name),X(!0)},e[0]=n.name,e[1]=ue):ue=e[1];const Se=ue;let we;e[2]!==te||e[3]!==n.name||e[4]!==$||e[5]!==u||e[6]!==p?(we=()=>{const xe=te.trim();xe&&xe!==n.name&&u(xe),$&&p&&p(),X(!1),re("")},e[2]=te,e[3]=n.name,e[4]=$,e[5]=u,e[6]=p,e[7]=we):we=e[7];const ye=we;let Ae;e[8]!==$||e[9]!==S?(Ae=()=>{$&&S&&S(),X(!1),re("")},e[8]=$,e[9]=S,e[10]=Ae):Ae=e[10];const pe=Ae;let O;e[11]!==$||e[12]!==m?(O=xe=>{$&&m?m(xe):re(xe)},e[11]=$,e[12]=m,e[13]=O):O=e[13];const Q=O;let le,H;e[14]!==$?(le=()=>{if(!$)return;const xe=()=>{const De=fe.current;De&&(De.focus(),De.select())},$e=requestAnimationFrame(xe),V=window.setTimeout(xe,0);return()=>{cancelAnimationFrame($e),window.clearTimeout(V)}},H=[$],e[14]=$,e[15]=le,e[16]=H):(le=e[15],H=e[16]),c.useEffect(le,H);const me=l?"folder":"folder-open",ge=F&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let oe;e[17]!==ge?(oe=Oe("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",ge),e[17]=ge,e[18]=oe):oe=e[18];let de;e[19]!==d||e[20]!==ne?(de=ne?void 0:xe=>{xe.currentTarget.blur(),d()},e[19]=d,e[20]=ne,e[21]=de):de=e[21];const _=ne?void 0:"button",B=ne?void 0:0;let he;e[22]!==d||e[23]!==ne?(he=ne?void 0:xe=>{(xe.key==="Enter"||xe.key===" ")&&(xe.preventDefault(),d())},e[22]=d,e[23]=ne,e[24]=he):he=e[24];let ve;e[25]!==n.name||e[26]!==l||e[27]!==R?(ve=l?R("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):R("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=l,e[27]=R,e[28]=ve):ve=e[28];const Re=N?L?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":L?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let ce;e[29]!==Re?(ce=Oe("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",Re),e[29]=Re,e[30]=ce):ce=e[30];const se=F?"text-primary":"text-muted-foreground";let q;e[31]!==se?(q=Oe("h-3.5 w-3.5 flex-shrink-0",se),e[31]=se,e[32]=q):q=e[32];let z;e[33]!==me||e[34]!==q?(z=s.jsx(M,{name:me,className:q}),e[33]=me,e[34]=q,e[35]=z):z=e[35];let ee;e[36]!==A||e[37]!==r||e[38]!==te||e[39]!==n.name||e[40]!==pe||e[41]!==Q||e[42]!==ye||e[43]!==l||e[44]!==F||e[45]!==ne||e[46]!==i||e[47]!==R?(ee=ne?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:X2,onMouseDown:J2,onSubmit:xe=>{xe.preventDefault(),ye()},children:[s.jsx("input",{ref:fe,value:te,onChange:xe=>Q(xe.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:R("sessions.sidebar.folderItem.namePlaceholder"),onClick:Z2,onPointerDown:ej,onMouseDown:tj,onKeyDown:xe=>{if(xe.key==="Escape"){xe.stopPropagation(),pe();return}(xe.key===" "||xe.key==="Enter")&&xe.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:sj,onPointerDown:nj,onMouseDown:rj,children:s.jsx(M,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),pe()},onPointerDown:oj,onMouseDown:ij,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(M,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("span",{className:Oe("typography-ui-label font-semibold truncate",F?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(Dt,{side:"right",sideOffset:8,className:"max-w-xs",children:r??n.name})]}),s.jsxs("span",{className:"typography-micro text-muted-foreground/70 flex-shrink-0",children:["• ",i.length]}),A?s.jsx(Mf,{state:A}):null,l?s.jsx(M,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(M,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=A,e[37]=r,e[38]=te,e[39]=n.name,e[40]=pe,e[41]=Q,e[42]=ye,e[43]=l,e[44]=F,e[45]=ne,e[46]=i,e[47]=R,e[48]=ee):ee=e[48];let ae;e[49]!==ce||e[50]!==z||e[51]!==ee?(ae=s.jsxs("div",{className:ce,children:[z,ee]}),e[49]=ce,e[50]=z,e[51]=ee,e[52]=ae):ae=e[52];let Ne;e[53]!==L||e[54]!==N||e[55]!==n.name||e[56]!==Se||e[57]!==W||e[58]!==h||e[59]!==k||e[60]!==ne||e[61]!==R?(Ne=!ne&&(!W||N)?s.jsx("div",{className:Oe("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",L?"opacity-100":"opacity-0 pointer-events-none group-hover/folder:opacity-100 group-hover/folder:pointer-events-auto group-focus-within/folder:opacity-100 group-focus-within/folder:pointer-events-auto"),children:s.jsxs("div",{className:"flex items-center gap-0.5",children:[!N&&k?s.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),k()},className:"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","aria-label":R("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:R("sessions.sidebar.project.actions.newSession"),children:s.jsx(M,{name:"add",className:"h-3.5 w-3.5"})}):null,N?null:s.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),Se()},className:"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","aria-label":R("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(M,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:xe=>{xe.stopPropagation(),h()},className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":N?R("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):R("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=L,e[54]=N,e[55]=n.name,e[56]=Se,e[57]=W,e[58]=h,e[59]=k,e[60]=ne,e[61]=R,e[62]=Ne):Ne=e[62];let Ce;e[63]!==g||e[64]!==oe||e[65]!==de||e[66]!==_||e[67]!==B||e[68]!==he||e[69]!==ve||e[70]!==ae||e[71]!==Ne?(Ce=s.jsxs("div",{ref:g,className:oe,onClick:de,role:_,tabIndex:B,onKeyDown:he,"aria-label":ve,children:[ae,Ne]}),e[63]=g,e[64]=oe,e[65]=de,e[66]=_,e[67]=B,e[68]=he,e[69]=ve,e[70]=ae,e[71]=Ne,e[72]=Ce):Ce=e[72];let We;e[73]!==f||e[74]!==l||e[75]!==P||e[76]!==i||e[77]!==o||e[78]!==R?(We=!l&&P?s.jsxs("div",{className:"pb-1",children:[o,i.length>0?f:o?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:R("sessions.sidebar.folderItem.emptyFolder")})]}):null,e[73]=f,e[74]=l,e[75]=P,e[76]=i,e[77]=o,e[78]=R,e[79]=We):We=e[79];let Ee;return e[80]!==Ce||e[81]!==We?(Ee=s.jsxs("div",{className:"oc-folder",children:[Ce,We]}),e[80]=Ce,e[81]=We,e[82]=Ee):Ee=e[82],Ee},Of=c.memo(Q2);function X2(t){return t.stopPropagation()}function J2(t){return t.stopPropagation()}function Z2(t){return t.stopPropagation()}function ej(t){return t.stopPropagation()}function tj(t){return t.stopPropagation()}function sj(t){return t.stopPropagation()}function nj(t){return t.stopPropagation()}function rj(t){return t.stopPropagation()}function oj(t){return t.stopPropagation()}function ij(t){return t.stopPropagation()}function aj(t){const e=Ze.c(11);let n,r,i;e[0]!==t?({notifyOnSubtasks:r,activityNodes:n,...i}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=i):(n=e[1],r=e[2],i=e[3]);const o=i.isCollapsed&&!i.archivedBucket;let l;e[4]!==n||e[5]!==r||e[6]!==o?(l={nodes:n,includeUnreadSubtasks:r,enabled:o},e[4]=n,e[5]=r,e[6]=o,e[7]=l):l=e[7];const a=el(l);let d;return e[8]!==a||e[9]!==i?(d=s.jsx(Of,{...i,collapsedActivityState:a}),e[8]=a,e[9]=i,e[10]=d):d=e[10],d}const _o=t=>{const e=Ze.c(13),{directory:n,className:r}=t,{t:i}=jt();let o;e[0]!==n?(o=Jm(n),e[0]=n,e[1]=o):o=e[1];const l=o;let a;if(e[2]!==l?(a=v=>v.sessions.get(l),e[2]=l,e[3]=a):a=e[3],!Ot(a)?.tabs.some(Od))return null;let h;e[4]!==i?(h=i("sessions.sidebar.projectAction.active"),e[4]=i,e[5]=h):h=e[5];const f=h;let x;e[6]!==r?(x=Oe("inline-flex shrink-0 items-center text-status-info",r),e[6]=r,e[7]=x):x=e[7];let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(M,{name:"pulse",className:"size-3.5"}),e[8]=b):b=e[8];let w;return e[9]!==l||e[10]!==f||e[11]!==x?(w=s.jsx("span",{className:x,role:"img","aria-label":f,title:f,"data-action-directory":l,children:b}),e[9]=l,e[10]=f,e[11]=x,e[12]=w):w=e[12],w},lj=t=>{const e=Ze.c(19),{sessionId:n,dragKey:r,ownerKey:i,sessionDirectory:o,sessionTitle:l,archivedBucket:a,children:d}=t,u=i===void 0?null:i,h=a===void 0?!1:a,f=`session-drag:${r??n}`;let x;e[0]!==h||e[1]!==u||e[2]!==o||e[3]!==n||e[4]!==l?(x={type:"session",sessionId:n,ownerKey:u,sessionDirectory:o,sessionTitle:l,archivedBucket:h},e[0]=h,e[1]=u,e[2]=o,e[3]=n,e[4]=l,e[5]=x):x=e[5];let b;e[6]!==h||e[7]!==f||e[8]!==x?(b={id:f,disabled:h,data:x},e[6]=h,e[7]=f,e[8]=x,e[9]=b):b=e[9];const{attributes:w,listeners:v,setNodeRef:y,isDragging:m}=Wx(b);let p;e[10]!==v?(p=k=>{k.stopPropagation(),v?.onPointerDown&&v.onPointerDown(k)},e[10]=v,e[11]=p):p=e[11];const S=p,g=`touch-pan-y select-none${m?" opacity-30":""}`;let C;return e[12]!==w||e[13]!==d||e[14]!==S||e[15]!==v||e[16]!==y||e[17]!==g?(C=s.jsx("div",{ref:y,...w,...v,onPointerDown:S,className:g,children:d}),e[12]=w,e[13]=d,e[14]=S,e[15]=v,e[16]=y,e[17]=g,e[18]=C):C=e[18],C},Bf=t=>{const e=Ze.c(20),{folderId:n,scopeKey:r,ownerKey:i,disabled:o,children:l}=t,a=o===void 0?!1:o;let d;e[0]!==n||e[1]!==r?(d=Yn(r,n),e[0]=n,e[1]=r,e[2]=d):d=e[2];const u=`folder-drop:${d}`;let h;e[3]!==a||e[4]!==r?(h=a||Za(r),e[3]=a,e[4]=r,e[5]=h):h=e[5];let f;e[6]!==n||e[7]!==i||e[8]!==r?(f={type:"folder",folderId:n,scopeKey:r,ownerKey:i},e[6]=n,e[7]=i,e[8]=r,e[9]=f):f=e[9];let x;e[10]!==u||e[11]!==h||e[12]!==f?(x={id:u,disabled:h,data:f},e[10]=u,e[11]=h,e[12]=f,e[13]=x):x=e[13];const{setNodeRef:b,isOver:w}=Kx(x);let v;e[14]!==l||e[15]!==w||e[16]!==b?(v=l(b,w),e[14]=l,e[15]=w,e[16]=b,e[17]=v):v=e[17];let y;return e[18]!==v?(y=s.jsx(s.Fragment,{children:v}),e[18]=v,e[19]=y):y=e[19],y},cj=t=>{const e=Ze.c(22),{scopeKey:n,ownerKey:r,hasFolders:i,onSessionDroppedOnFolder:o,children:l}=t,a=r===void 0?null:r;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];const h=Qo(Dn(Jo,d),Dn(Xo,u)),[f,x]=c.useState(null),[b,w]=c.useState("Session"),[v,y]=c.useState(null),[m,p]=c.useState(null);if(!n){let A;return e[2]!==l?(A=s.jsx(s.Fragment,{children:l}),e[2]=l,e[3]=A):A=e[3],A}let S;e[4]!==o||e[5]!==a?(S=A=>{x(null),y(null),p(null);const{active:P,over:T}=A;if(!T)return;const L=P.data.current,$=T.data.current;L?.type!=="session"||!L.sessionId||!L.ownerKey||L.archivedBucket===!0||a&&L.ownerKey!==a||$?.type!=="folder"||!$.folderId||!$.scopeKey||!$.ownerKey||Za($.scopeKey)||$.ownerKey!==L.ownerKey||o(L.sessionId,{folderId:$.folderId,scopeKey:$.scopeKey,ownerKey:$.ownerKey},L.ownerKey)},e[4]=o,e[5]=a,e[6]=S):S=e[6];const g=S;let C,k;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=A=>{const P=A.active.data.current;if(P?.type==="session"&&P.sessionId){x(P.sessionId),w(P.sessionTitle??"Session");const T=A.active.rect.current.initial?.width,L=A.active.rect.current.initial?.height;y(T??null),p(L??null)}},k=()=>{x(null),y(null),p(null)},e[7]=C,e[8]=k):(C=e[7],k=e[8]);let j;e[9]!==m||e[10]!==f||e[11]!==b||e[12]!==v||e[13]!==i?(j=f&&i?s.jsxs("div",{style:{width:v?`${v}px`:"auto",height:m?`${m}px`:"auto"},className:"flex items-center rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-2.5 py-1 shadow-none pointer-events-none",children:[s.jsx(M,{name:"sticky-note",className:"h-4 w-4 text-muted-foreground mr-2 flex-shrink-0"}),s.jsx("div",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal text-foreground",children:b})]}):null,e[9]=m,e[10]=f,e[11]=b,e[12]=v,e[13]=i,e[14]=j):j=e[14];let D;e[15]!==j?(D=s.jsx(Vx,{children:j}),e[15]=j,e[16]=D):D=e[16];let I;return e[17]!==l||e[18]!==g||e[19]!==h||e[20]!==D?(I=s.jsxs(Zo,{sensors:h,collisionDetection:ei,onDragStart:C,onDragCancel:k,onDragEnd:g,children:[l,D]}),e[17]=l,e[18]=g,e[19]=h,e[20]=D,e[21]=I):I=e[21],I},Ff=c.createContext(null),dj=({entries:t,descendantIds:e,sessionsById:n,children:r})=>{const i=c.useRef(t),o=c.useRef(e),l=c.useRef(n);i.current=t,o.current=e,l.current=n;const a=c.useRef(null);return a.current===null&&(a.current={getEntries:()=>i.current,getDescendantIds:()=>o.current,getSessionsById:()=>l.current}),s.jsx(Ff.Provider,{value:a.current,children:r})},_f=()=>c.useContext(Ff),uj=(t,e,n)=>{const r=t[0];if(!r)return null;const i=n??r.scopeKey,o=[],l=new Set;for(const a of t){if(i&&a.scopeKey!==i)continue;const d=a.descendantRange,u=d?[a.id,...e.slice(d[0],d[1])]:[a.id];for(const h of u)l.has(h)||(l.add(h),o.push(h))}return o.length>0?{ids:o,scopeKey:i}:null},Lf=(t,e)=>{if(t.size===0)return!1;for(const n of t)if(!e.get(n)?.time?.archived)return!1;return!0},_c=(t,e,n)=>{if(!e)return;const r=i=>{let o=i.session.id===e;for(const l of i.children)o=r(l)||o;return o&&n.add(i.session.id),o};for(const i of t)r(i)},Fn=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(Fn(n,e))return!0;return!1},fj=({isSubtaskSession:t,archivedBucket:e,isVSCode:n,sessionDirectory:r})=>!t&&!e&&!n&&!rg(r),mj=({sessionDirectory:t,isStreaming:e,isMovingToWorktree:n})=>!t||e||n,hj=(t,e,n)=>{const r=new Map,i=o=>{const l=Ds(o.session)??ht(o.worktree?.path)??n;if(l){const a=r.get(l)??[];a.push(o.session.id),r.set(l,a)}if(!(o===t&&e))for(const a of o.children)i(a)};return i(t),[...r].map(([o,l])=>({directory:o,sessionIDs:l}))},ca=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const i=new Set;let o=r.session.parentID??null;for(;o&&!i.has(o);){if(n.has(o)&&e.has(o))return!1;i.add(o),o=e.get(o)?.session?.parentID??null}return!0})},$f=t=>{const e=new Map(t.map(l=>[l.id,l])),n=new Map;for(const l of t){if(!l.parentId||!e.has(l.parentId))continue;const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}const r=new Set,i=[],o=l=>{if(r.has(l.id))return;i.push(l);const a=[l.id];for(;a.length>0;){const d=a.pop();if(!(!d||r.has(d))){r.add(d);for(const u of n.get(d)??[])a.push(u.id)}}};return t.forEach(l=>{(!l.parentId||!e.has(l.parentId))&&o(l)}),t.forEach(o),i},zf=(t,e)=>{const n=e.searchQuery.trim().toLowerCase().startsWith("ses_"),r=new Map(t.map(u=>[u.id,u])),i=new Map,o=new Set;for(const u of t){if(u.parentId&&!r.has(u.parentId)){o.add(u.id);continue}if(u.parentId){const x=i.get(u.parentId)??[];x.push(u.id),i.set(u.parentId,x)}const h=new Set;let f=u.id;for(;f;){if(h.has(f)){o.add(u.id);break}h.add(f),f=r.get(f)?.parentId}}const l=new Set,a=new Set,d=u=>{if(l.has(u))return!0;if(a.has(u))return!1;const h=r.get(u);if(!h)return!1;a.add(u);let f=o.has(u);return!f&&e.archivedBucket&&h.nodeCount===0?f=(i.get(u)??[]).some(d):(!f&&!e.searchQuery&&(f=!0),!f&&(h.nodeCount>0||!n&&Io([h.name],e.searchQuery))&&(f=!0),f||(f=(i.get(u)??[]).some(d))),a.delete(u),f&&l.add(u),f};return t.forEach(u=>d(u.id)),new Set(t.filter(u=>l.has(u.id)).map(u=>u.id))},Lc=new WeakMap;let $c=1;const pj=t=>{const e=Lc.get(t);if(e!==void 0)return e;const n=$c;return $c+=1,Lc.set(t,n),n},Lo=t=>t.children.length===0?"":t.children.map(n=>{const r=pj(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Lo(n)}`}).join("|"),Wf=(t,e,n,r,i,o)=>{const l=qt(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const h=d.session.directory??i,f=u.session.directory??o,x=Pl(l,h??"",d.session.id),b=Pl(l,f??"",u.session.id);return(x?n.has(x):!1)!==(b?r.has(b):!1)?!0:d.children.some((w,v)=>a(w,u.children[v]))};return a(t,e)},gj=t=>t.actionsAlwaysVisible?"":`transition-opacity duration-150 ${t.menuOpen?"opacity-0":t.hideOnHoverClass}`,$o=(t,e,n,r)=>{if(!e)return null;const i=r?"archived":"active";let o=null;const l=a=>{if(`${n}:${i}:${a.session.id}`===e)return o=a.session.id,!0;for(const u of a.children)if(l(u))return!0;return!1};return t.forEach(a=>l(a)),o},xj=t=>{const e=Ze.c(29),{menuInstanceKey:n,contextMenuInstanceKey:r,openSidebarMenuKey:i,setOpenSidebarMenuKey:o,hasDeferredCloseWork:l,onCloseComplete:a}=t,[d,u]=c.useState(!1),[h,f]=c.useState(!1),x=i===n&&!h,b=r?i===r&&!h:d;let w;e[0]!==l||e[1]!==i||e[2]!==o?(w=I=>{if(i===I){if(l()){f(!0);return}o(null)}},e[0]=l,e[1]=i,e[2]=o,e[3]=w):w=e[3];const v=w;let y;e[4]!==n||e[5]!==v||e[6]!==o?(y=I=>{if(I){u(!1),f(!1),o(n);return}v(n)},e[4]=n,e[5]=v,e[6]=o,e[7]=y):y=e[7];const m=y;let p;e[8]!==r||e[9]!==v||e[10]!==o?(p=I=>{if(!r){u(I);return}if(I){f(!1),o(r);return}v(r)},e[8]=r,e[9]=v,e[10]=o,e[11]=p):p=e[11];const S=p;let g;e[12]!==r||e[13]!==n||e[14]!==a||e[15]!==i||e[16]!==o?(g=I=>{I||(a(),f(!1),(i===n||i===r)&&o(null))},e[12]=r,e[13]=n,e[14]=a,e[15]=i,e[16]=o,e[17]=g):g=e[17];const C=g;let k;e[18]!==x||e[19]!==n||e[20]!==o?(k=()=>{f(!1),o(x?null:n)},e[18]=x,e[19]=n,e[20]=o,e[21]=k):k=e[21];const j=k;let D;return e[22]!==S||e[23]!==m||e[24]!==C||e[25]!==b||e[26]!==x||e[27]!==j?(D={isMenuOpen:x,isContextMenuOpen:b,handleMenuOpenChange:m,handleContextMenuOpenChange:S,handleMenuOpenChangeComplete:C,toggleMenu:j},e[22]=S,e[23]=m,e[24]=C,e[25]=b,e[26]=x,e[27]=j,e[28]=D):D=e[28],D};let da=!1;const ua=new Set;let zc=!1;function bj(){for(const t of ua)t()}function tl(t){da!==t&&(da=t,bj())}function yj(t){t.key==="Shift"&&tl(!0)}function wj(t){t.key==="Shift"&&tl(!1)}function vj(){tl(!1)}function Sj(){zc||typeof window>"u"||(zc=!0,window.addEventListener("keydown",yj),window.addEventListener("keyup",wj),window.addEventListener("blur",vj))}function jj(t){return Sj(),ua.add(t),()=>{ua.delete(t)}}function kj(){return da}function Cj(){return!1}function Nj(){return mt.useSyncExternalStore(jj,kj,Cj)}async function Aj(t,e,n,r){const i=await Promise.all(e.map(async o=>{r();const l=o.directory??o.session.directory,a=await t.session.get({sessionID:o.session.id,directory:l},{throwOnError:!0});if(r(),!a.data||!Ud(n,Po(a.data,o.projectDirectory??a.data.directory)))throw new Error("Fusion source membership changed");const d=await t.session.messages({sessionID:o.session.id,directory:l,limit:50},{throwOnError:!0});if(r(),!d.data)throw new Error("Fusion source messages unavailable");let u="";for(let h=d.data.length-1;h>=0;h-=1){const f=d.data[h];if(f.info.role==="assistant"){u=og(f.parts).trim();break}}return{source:{...o,session:a.data},text:u}}));return r(),i.filter(o=>o.text.length>0)}const Kf=t=>{const e=Ze.c(36),{value:n,onChange:r,className:i,disabled:o,id:l,portalToBody:a}=t,{t:d}=jt(),u=Gt(Dj),h=Gt(Pj),f=Gt(Ij);let x;e[0]!==u?(x=u(),e[0]=u,e[1]=x):x=e[1];const b=x;let w;e[2]!==b?(w=b.filter(Tj),e[2]=b,e[3]=w):w=e[3];const v=w;let y,m;e[4]!==b.length||e[5]!==h?(y=()=>{b.length===0&&h()},m=[b.length,h],e[4]=b.length,e[5]=h,e[6]=y,e[7]=m):(y=e[6],m=e[7]),c.useEffect(y,m);let p,S;e[8]!==f||e[9]!==o||e[10]!==r||e[11]!==v||e[12]!==n?(p=()=>{if(o)return;const T=n.trim();if(T.length>0&&v.some(K=>K.name===T))return;const L=typeof f=="string"&&f.trim().length>0?f.trim():null;if(L&&v.some(K=>K.name===L)){r(L);return}const $=v[0]?.name;$&&r($)},S=[f,o,r,v,n],e[8]=f,e[9]=o,e[10]=r,e[11]=v,e[12]=n,e[13]=p,e[14]=S):(p=e[13],S=e[14]),c.useEffect(p,S);const g=n.trim().length>0?n:void 0;let C;e[15]!==i?(C=Oe("max-w-full",i),e[15]=i,e[16]=C):C=e[16];let k;e[17]!==d?(k=d("multirun.agentSelector.placeholder"),e[17]=d,e[18]=k):k=e[18];let j;e[19]!==k?(j=s.jsx(ks,{placeholder:k}),e[19]=k,e[20]=j):j=e[20];let D;e[21]!==l||e[22]!==C||e[23]!==j?(D=s.jsx(Fs,{id:l,size:"lg",className:C,children:j}),e[21]=l,e[22]=C,e[23]=j,e[24]=D):D=e[24];let I;e[25]!==v?(I=v.length>0&&s.jsx(Wi,{children:v.map(Ej)}),e[25]=v,e[26]=I):I=e[26];let A;e[27]!==a||e[28]!==I?(A=s.jsx(_s,{fitContent:!0,portalToBody:a,children:I}),e[27]=a,e[28]=I,e[29]=A):A=e[29];let P;return e[30]!==o||e[31]!==r||e[32]!==g||e[33]!==D||e[34]!==A?(P=s.jsxs(Bs,{value:g,onValueChange:r,disabled:o,children:[D,A]}),e[30]=o,e[31]=r,e[32]=g,e[33]=D,e[34]=A,e[35]=P):P=e[35],P};function Dj(t){return t.getVisibleAgents}function Pj(t){return t.loadAgents}function Ij(t){return t.currentAgentName}function Tj(t){return Du(t.mode)}function Ej(t){return s.jsx(ss,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const Rj="h-7",Vr=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Mj=t=>{const e=Ze.c(12),{model:n,instanceIndex:r,totalSameModel:i,onRemove:o}=t,l=n.displayName||`${n.providerID}/${n.modelID}`,a=i>1?`${l} (${r})`:l;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=Oe("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",Rj),e[0]=d):d=e[0];let u;e[1]!==n.providerID?(u=s.jsx(Ki,{providerId:n.providerID,className:"h-3.5 w-3.5"}),e[1]=n.providerID,e[2]=u):u=e[2];let h;e[3]!==a?(h=s.jsx("span",{className:"typography-meta font-medium truncate max-w-[140px]",children:a}),e[3]=a,e[4]=h):h=e[4];let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(M,{name:"close",className:"h-3.5 w-3.5"}),e[5]=f):f=e[5];let x;e[6]!==o?(x=s.jsx("button",{type:"button",onClick:o,className:"text-muted-foreground hover:text-foreground ml-0.5",children:f}),e[6]=o,e[7]=x):x=e[7];let b;return e[8]!==u||e[9]!==h||e[10]!==x?(b=s.jsxs("div",{className:d,children:[u,h,x]}),e[8]=u,e[9]=h,e[10]=x,e[11]=b):b=e[11],b},Vf=t=>{const e=Ze.c(120),{selectedModels:n,onAdd:r,onRemove:i,onUpdate:o,minModels:l,addButtonLabel:a,showChips:d,maxModels:u,addButtonClassName:h,dropdownSide:f,dropdownClassName:x,containerClassName:b,triggerIcon:w}=t,v=d===void 0?!0:d,y=f===void 0?"top":f,{t:m}=jt(),p=Gt(Oj),S=Gt(Bj),g=Pe(Fj),C=Pe(_j),{favoriteModelsList:k,recentModelsList:j}=ig(),D=Pe(Lj),I=Pe($j),[A,P]=c.useState(!1),[T,L]=c.useState(""),[$,K]=c.useState(null),F=c.useRef(null),W=c.useRef(null),N=u===1,R=u===void 0||n.length<u||N;let E;if(e[0]!==n){E=new Map;for(const _e of n){const rt=`${_e.providerID}:${_e.modelID}`;E.set(rt,(E.get(rt)||0)+1)}e[0]=n,e[1]=E}else E=e[1];const X=E;let J;e[2]!==n?(J=_e=>n.filter(ct=>ct.providerID===_e.providerID&&ct.modelID===_e.modelID).findIndex(ct=>ct.instanceId===_e.instanceId)+1,e[2]=n,e[3]=J):J=e[3];const re=J;let fe,ne;e[4]!==y||e[5]!==A?(fe=()=>{if(!A||!W.current)return;const _e=W.current.getBoundingClientRect();if(y==="bottom"){const wt=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-_e.bottom-16-112;K(Math.max(160,Math.min(320,wt)));return}let rt=W.current.parentElement;for(;rt&&!rt.matches('[role="dialog"], [data-scroll-shadow-scroller]');){const pt=getComputedStyle(rt);if(pt.overflow==="auto"||pt.overflow==="hidden"||pt.overflowY==="auto"||pt.overflowY==="hidden")break;rt=rt.parentElement}const ct=rt?rt.getBoundingClientRect().top:0,et=_e.top-ct-16;K(Math.max(150,Math.min(300,et)))},ne=[y,A],e[4]=y,e[5]=A,e[6]=fe,e[7]=ne):(fe=e[6],ne=e[7]),c.useEffect(fe,ne);let te,ue;e[8]!==R||e[9]!==A?(te=()=>{!R&&A&&(P(!1),L(""))},ue=[R,A],e[8]=R,e[9]=A,e[10]=te,e[11]=ue):(te=e[10],ue=e[11]),c.useEffect(te,ue);let Se,we;e[12]!==A?(Se=()=>{if(!A)return;const _e=rt=>{F.current&&!F.current.contains(rt.target)&&(P(!1),L(""))};return document.addEventListener("mousedown",_e),()=>document.removeEventListener("mousedown",_e)},we=[A],e[12]=A,e[13]=Se,e[14]=we):(Se=e[13],we=e[14]),c.useEffect(Se,we);let ye;e[15]!==N||e[16]!==r||e[17]!==o||e[18]!==n.length?(ye=_e=>{const rt={providerID:_e.providerID,modelID:_e.modelID,displayName:_e.model.name||_e.modelID,instanceId:Vr()};N&&n.length>0&&o?o(0,rt):r(rt),N&&(P(!1),L(""))},e[15]=N,e[16]=r,e[17]=o,e[18]=n.length,e[19]=ye):ye=e[19];const Ae=ye;let pe;e[20]!==m?(pe=m("multirun.modelMultiSelect.search.placeholder"),e[20]=m,e[21]=pe):pe=e[21];let O;e[22]!==m?(O=m("multirun.modelMultiSelect.search.noResults"),e[22]=m,e[23]=O):O=e[23];let Q;e[24]!==m?(Q=m("multirun.modelMultiSelect.sections.favorites"),e[24]=m,e[25]=Q):Q=e[25];let le;e[26]!==m?(le=m("multirun.modelMultiSelect.sections.recent"),e[26]=m,e[27]=le):le=e[27];let H;e[28]!==m?(H=m("multirun.modelMultiSelect.keyboard.hint"),e[28]=m,e[29]=H):H=e[29];let me;e[30]!==m?(me=m("settings.agents.modelSelector.actions.favorite"),e[30]=m,e[31]=me):me=e[31];let ge;e[32]!==m?(ge=m("settings.agents.modelSelector.actions.unfavorite"),e[32]=m,e[33]=ge):ge=e[33];let oe;e[34]!==m?(oe=m("chat.modelControls.capabilities"),e[34]=m,e[35]=oe):oe=e[35];let de;e[36]!==m?(de=m("chat.modelControls.capability.toolCalling"),e[36]=m,e[37]=de):de=e[37];let _;e[38]!==m?(_=m("chat.modelControls.capability.reasoning"),e[38]=m,e[39]=_):_=e[39];let B;e[40]!==m?(B=m("chat.modelControls.input"),e[40]=m,e[41]=B):B=e[41];let he;e[42]!==m?(he=m("chat.modelControls.output"),e[42]=m,e[43]=he):he=e[43];let ve;e[44]!==m?(ve=m("chat.modelControls.costPerMillion"),e[44]=m,e[45]=ve):ve=e[45];let Re;e[46]!==pe||e[47]!==O||e[48]!==Q||e[49]!==le||e[50]!==H||e[51]!==me||e[52]!==ge||e[53]!==oe||e[54]!==de||e[55]!==_||e[56]!==B||e[57]!==he||e[58]!==ve?(Re={searchPlaceholder:pe,noResults:O,favorites:Q,recent:le,keyboardHint:H,favorite:me,unfavorite:ge,capabilities:oe,capabilityToolCalling:de,capabilityReasoning:_,input:B,output:he,costPerMillion:ve},e[46]=pe,e[47]=O,e[48]=Q,e[49]=le,e[50]=H,e[51]=me,e[52]=ge,e[53]=oe,e[54]=de,e[55]=_,e[56]=B,e[57]=he,e[58]=ve,e[59]=Re):Re=e[59];const ce=Re;let se;e[60]!==b?(se=Oe("relative",b),e[60]=b,e[61]=se):se=e[61];const q=A?"":void 0;let z;e[62]!==h?(z=Oe(Pu({size:"default"}),"w-fit",h),e[62]=h,e[63]=z):z=e[63];const ee=!R;let ae;e[64]!==A?(ae=()=>{P(!A)},e[64]=A,e[65]=ae):ae=e[65];let Ne;e[66]!==w?(Ne=w??s.jsx(M,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=w,e[67]=Ne):Ne=e[67];let Ce;e[68]!==a||e[69]!==m?(Ce=a??m("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=m,e[70]=Ce):Ce=e[70];let We;e[71]!==q||e[72]!==z||e[73]!==ee||e[74]!==ae||e[75]!==Ne||e[76]!==Ce?(We=s.jsxs("button",{ref:W,type:"button","data-popup-open":q,className:z,disabled:ee,onClick:ae,children:[Ne,Ce]}),e[71]=q,e[72]=z,e[73]=ee,e[74]=ae,e[75]=Ne,e[76]=Ce,e[77]=We):We=e[77];let Ee;e[78]!==$||e[79]!==R||e[80]!==x||e[81]!==y||e[82]!==k||e[83]!==Ae||e[84]!==D||e[85]!==C||e[86]!==A||e[87]!==ce||e[88]!==X||e[89]!==S||e[90]!==I||e[91]!==p||e[92]!==j||e[93]!==T||e[94]!==g?(Ee=A?s.jsx("div",{className:Oe("absolute left-0 z-50 w-[min(420px,calc(100vw-2rem))] max-w-[calc(100vw-2rem)] flex flex-col overflow-hidden rounded-xl border border-border/50 shadow-lg",y==="top"?"bottom-full mb-1":"top-full mt-1",x),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(ag,{providers:p,providerOrder:I,favoriteModels:k,recentModels:j,modelsMetadata:S,hiddenModels:D,searchQuery:T,onSearchQueryChange:L,onSelect:Ae,labels:ce,selectionCount:_e=>X.get(`${_e.providerID}:${_e.modelID}`)||0,disabled:!R,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:$?`${$}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:A,isFavorite:_e=>C(_e.providerID,_e.modelID),onToggleFavorite:_e=>g(_e.providerID,_e.modelID),onEscape:()=>{P(!1),L("")}})}):null,e[78]=$,e[79]=R,e[80]=x,e[81]=y,e[82]=k,e[83]=Ae,e[84]=D,e[85]=C,e[86]=A,e[87]=ce,e[88]=X,e[89]=S,e[90]=I,e[91]=p,e[92]=j,e[93]=T,e[94]=g,e[95]=Ee):Ee=e[95];let xe;e[96]!==se||e[97]!==We||e[98]!==Ee?(xe=s.jsxs("div",{className:se,ref:F,children:[We,Ee]}),e[96]=se,e[97]=We,e[98]=Ee,e[99]=xe):xe=e[99];let $e;e[100]!==re||e[101]!==X||e[102]!==i||e[103]!==o||e[104]!==p||e[105]!==n||e[106]!==v||e[107]!==m?($e=v&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((_e,rt)=>{const ct=`${_e.providerID}:${_e.modelID}`,et=X.get(ct)||1,pt=re(_e),wt=p.find(be=>be.id===_e.providerID)?.models?.find(be=>be.id===_e.modelID),Xe=wt?.variants?Object.keys(wt.variants):[],yt=Xe.length>0,Rt=_e.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Mj,{model:_e,instanceIndex:pt,totalSameModel:et,onRemove:()=>i(rt)}),yt&&s.jsxs(Bs,{value:Rt,onValueChange:be=>{if(!o)return;o(rt,{..._e,variant:be==="__default__"?void 0:be})},children:[s.jsxs(Fs,{size:"sm",className:"gap-1.5",children:[s.jsx(M,{name:"brain-ai-3",className:Oe("h-3.5 w-3.5 flex-shrink-0",Rt==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(ks,{placeholder:m("multirun.modelMultiSelect.variant.placeholder"),children:be=>be==="__default__"?m("multirun.modelMultiSelect.variant.default"):be})]}),s.jsxs(_s,{fitContent:!0,children:[s.jsx(ss,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:m("multirun.modelMultiSelect.variant.default")}),Xe.map(zj)]})]})]},_e.instanceId)})}),e[100]=re,e[101]=X,e[102]=i,e[103]=o,e[104]=p,e[105]=n,e[106]=v,e[107]=m,e[108]=$e):$e=e[108];let V;e[109]!==xe||e[110]!==$e?(V=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[xe,$e]}),e[109]=xe,e[110]=$e,e[111]=V):V=e[111];let De;e[112]!==u||e[113]!==l||e[114]!==n.length||e[115]!==m?(De=l!==void 0&&n.length<l&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:u!==void 0?m("multirun.modelMultiSelect.validation.minToMax",{min:l,max:u}):m("multirun.modelMultiSelect.validation.minOnly",{min:l})}),e[112]=u,e[113]=l,e[114]=n.length,e[115]=m,e[116]=De):De=e[116];let Fe;return e[117]!==V||e[118]!==De?(Fe=s.jsxs("div",{className:"space-y-2",children:[V,De]}),e[117]=V,e[118]=De,e[119]=Fe):Fe=e[119],Fe};function Oj(t){return t.providers}function Bj(t){return t.modelsMetadata}function Fj(t){return t.toggleFavoriteModel}function _j(t){return t.isFavoriteModel}function Lj(t){return t.hiddenModels}function $j(t){return t.providerOrder}function zj(t){return s.jsx(ss,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const Wj=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
|
|
881
881
|
|
|
@@ -892,5 +892,5 @@ Now write the final fused answer.`,synthetic:!0}],directory:fe})}catch(re){if(qt
|
|
|
892
892
|
`)?(A(et),D(!0)):D(!1);return}D(!1)},[]),Re=mt.useCallback(V=>{p(De=>({...De,execution:{...De.execution,prompt:V}}))},[]),ce=mt.useCallback(V=>{const De=m.execution.prompt,_e=J.current?.selectionStart??De.length,ct=De.substring(0,_e).lastIndexOf("@"),et=V.relativePath&&V.relativePath.trim().length>0?V.relativePath.trim():V.path||V.name,pt=ct!==-1?ct:_e,kt=`${De.substring(0,pt)}@${et} ${De.substring(_e)}`,wt=pt+et.length+2;Re(kt),D(!1),A(""),requestAnimationFrame(()=>{const Xe=J.current;Xe&&(Xe.selectionStart=wt,Xe.selectionEnd=wt,Xe.focus()),ve(kt,wt)})},[m.execution.prompt,Re,ve]),se=mt.useCallback(V=>{const De=m.execution.prompt,_e=J.current?.selectionStart??De.length,ct=De.substring(0,_e).lastIndexOf("@"),et=ct!==-1?ct:_e,pt=`${De.substring(0,et)}@${V} ${De.substring(_e)}`,kt=et+V.length+2;Re(pt),D(!1),A(""),requestAnimationFrame(()=>{const wt=J.current;wt&&(wt.selectionStart=kt,wt.selectionEnd=kt,wt.focus()),ve(pt,kt)})},[m.execution.prompt,Re,ve]),q=mt.useCallback(V=>{const De=`/${V.name} `;Re(De),T(!1),$(""),F(!1),requestAnimationFrame(()=>{const Fe=J.current;Fe&&(Fe.focus(),Fe.selectionStart=Fe.value.length,Fe.selectionEnd=Fe.value.length),ve(De,De.length)})},[Re,ve]),z=mt.useCallback((V,De)=>{const Fe=m.execution.prompt,rt=J.current?.selectionStart??Fe.length,et=Fe.substring(0,rt).lastIndexOf("#"),pt=et!==-1?et:rt,kt=`${Fe.substring(0,pt)}#${De} ${Fe.substring(rt)}`,wt=pt+De.length+2;Re(kt),F(!1),N(""),requestAnimationFrame(()=>{const Xe=J.current;Xe&&(Xe.selectionStart=wt,Xe.selectionEnd=wt,Xe.focus()),ve(kt,wt)})},[m.execution.prompt,Re,ve]),ee=mt.useCallback(V=>{if(P&&fe.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")){V.preventDefault(),fe.current.handleKeyDown(V.key);return}j&&re.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")&&(V.preventDefault(),re.current.handleKeyDown(V.key)),K&&ne.current&&(V.key==="Enter"||V.key==="ArrowUp"||V.key==="ArrowDown"||V.key==="Escape"||V.key==="Tab")&&(V.preventDefault(),ne.current.handleKeyDown(V.key))},[P,j,K]),ae=mt.useCallback(async()=>{const V=M4(m,o);if(V){Le.error(V);return}const De={...m.id?{id:m.id}:{},name:m.name.trim(),enabled:m.enabled,schedule:{kind:m.schedule.kind,timezone:m.schedule.timezone.trim(),...m.schedule.kind==="cron"?{cron:m.schedule.cronExpression.trim()}:m.schedule.kind==="once"?{date:m.schedule.onceDate,time:m.schedule.onceTime}:{times:O4(m.schedule.times),...m.schedule.kind==="weekly"?{weekdays:m.schedule.weekdays}:{}}},execution:{prompt:m.execution.prompt,providerID:m.execution.providerID,modelID:m.execution.modelID,...m.execution.variant.trim()?{variant:m.execution.variant.trim()}:{},...m.execution.agent.trim()?{agent:m.execution.agent.trim()}:{},...m.execution.permissionAutoAccept?{permissionAutoAccept:!0}:{},...m.execution.goalEnabled?{goalEnabled:!0}:{},...m.execution.goalEnabled&&m.execution.goalTokenBudget?{goalTokenBudget:m.execution.goalTokenBudget}:{}},...m.state?{state:m.state}:{}};g(!0);try{await i(De),r(!1)}catch(Fe){Le.error(Fe instanceof Error?Fe.message:o("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{g(!1)}},[m,r,i,o]),Ne=mt.useId(),Ce=mt.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),We=o(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),Ee=o("sessions.scheduledTasks.editor.description"),xe=s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{htmlFor:"sched-name",required:!0,children:o("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(An,{id:"sched-name",value:m.name,onChange:V=>p(De=>({...De,name:V.target.value})),placeholder:o("sessions.scheduledTasks.editor.taskName.placeholder"),maxLength:80,className:"w-full sm:max-w-[220px]"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Bs,{value:m.schedule.kind,onValueChange:V=>{p(De=>({...De,schedule:{...De.schedule,kind:V,...V==="cron"&&!De.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(ks,{children:V=>o(V==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":V==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":V==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"daily",children:o("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(ss,{value:"weekly",children:o("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(ss,{value:"once",children:o("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(ss,{value:"cron",children:o("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),m.schedule.kind==="cron"?s.jsx(B4,{draft:m,setDraft:p,locale:l,t:o}):m.schedule.kind==="once"?s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",ref:X,children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:Oe(Pu({size:"default"}),"w-fit max-w-full"),onClick:()=>k(V=>!V),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(M,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:k4(m.schedule.onceDate,o("sessions.scheduledTasks.editor.date.placeholder"),l)})]}),s.jsx(M,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),C?s.jsxs("div",{className:"oc-surface-elevated absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-surface-elevated p-3 shadow-sm",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40",onClick:()=>E(V=>ld(V,-1)),"aria-label":o("sessions.scheduledTasks.editor.date.previousMonth"),disabled:_,children:s.jsx(M,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(l,{month:"long",year:"numeric"}).format(R)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>E(V=>ld(V,1)),"aria-label":o("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(M,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:B.map((V,De)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:V},`${V}-${De}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:C4(R,we).map(({date:V,inCurrentMonth:De})=>{const Fe=ad(V),_e=Fe===m.schedule.onceDate,rt=md(V,ge),ct=V.getTime()<ge.getTime(),et=_e?"bg-interactive-selection text-interactive-selection-foreground":ct?"text-muted-foreground/40":De?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{ct||(he(Fe),k(!1))},disabled:ct,className:["h-8 rounded-md typography-ui-label",et,rt&&!_e?"ring-1 ring-inset ring-ring bg-interactive-selection text-interactive-selection-foreground":"",ct?"cursor-not-allowed opacity-45":""].join(" "),children:V.getDate()},Fe)})}),s.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-border pt-2",children:[s.jsx("div",{className:"typography-micro text-muted-foreground",children:de||""}),s.jsx(dt,{type:"button",size:"xs",variant:"ghost",onClick:()=>{he(ad(ge)),E(new Date(ge.getFullYear(),ge.getMonth(),1))},children:o("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.time.label")}),s.jsx(ud,{value:m.schedule.onceTime,use24Hour:Se,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:V=>p(De=>({...De,schedule:{...De.schedule,onceTime:V}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Bs,{value:m.schedule.timezone,onValueChange:V=>{p(De=>({...De,schedule:{...De.schedule,timezone:V}}))},children:[s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(ks,{})}),s.jsx(_s,{children:pa.map(V=>s.jsx(ss,{value:V,children:V},V))})]})]})]})]}):s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[m.schedule.kind==="weekly"?s.jsxs("div",{className:"flex flex-col gap-1 sm:col-span-2",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:ye.map(V=>{const De=m.schedule.weekdays.includes(V.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",De?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(pr,{checked:De,onChange:Fe=>Q(V.value,Fe),ariaLabel:V.label}),s.jsx("button",{type:"button",onClick:()=>Q(V.value,!De),className:"group-hover:text-foreground",children:V.label})]},V.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:m.schedule.times.map((V,De)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ud,{value:V,use24Hour:Se,hourAriaLabel:o("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:o("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:o("sessions.scheduledTasks.editor.time.periodAria"),amLabel:o("sessions.scheduledTasks.editor.time.period.am"),pmLabel:o("sessions.scheduledTasks.editor.time.period.pm"),onChange:Fe=>le(De,Fe)}),m.schedule.times.length>1?s.jsx(dt,{type:"button",size:"icon",variant:"ghost",onClick:()=>H(De),"aria-label":o("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(M,{name:"close",className:"h-4 w-4"})}):null]},De))}),s.jsx("div",{children:s.jsxs(dt,{type:"button",size:"sm",variant:"outline",onClick:me,children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"})," ",o("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Bs,{value:m.schedule.timezone,onValueChange:V=>{p(De=>({...De,schedule:{...De.schedule,timezone:V}}))},children:[s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(ks,{})}),s.jsx(_s,{children:pa.map(V=>s.jsx(ss,{value:V,children:V},V))})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{required:!0,children:o("sessions.scheduledTasks.editor.model.label")}),s.jsx(Bg,{providerId:m.execution.providerID,modelId:m.execution.modelID,onChange:(V,De)=>{p(Fe=>({...Fe,execution:{...Fe.execution,providerID:V,modelID:De,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Bs,{value:O,disabled:!pe,onValueChange:V=>{p(De=>({...De,execution:{...De.execution,variant:V==="__default"?"":V}}))},children:[s.jsx(Fs,{size:"lg",className:"w-fit max-w-full",children:s.jsx(ks,{children:V=>V==="__default"?o("sessions.scheduledTasks.editor.thinkingLevel.default"):V})}),s.jsxs(_s,{children:[s.jsx(ss,{value:"__default",children:o("sessions.scheduledTasks.editor.thinkingLevel.default")}),Ae.map(V=>s.jsx(ss,{value:V,children:V},V))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Ms,{children:o("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Fg,{agentName:m.execution.agent,filter:V=>Du(V.mode),onChange:V=>p(De=>({...De,execution:{...De.execution,agent:V}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Ms,{htmlFor:"sched-prompt",required:!0,children:o("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(fr,{id:"sched-prompt",ref:J,value:m.execution.prompt,onChange:V=>{const De=V.target.value;Re(De);const Fe=V.target.selectionStart??De.length;ve(De,Fe)},onKeyDown:ee,rows:8,placeholder:o("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),P?s.jsx(Mu,{ref:fe,searchQuery:L,onCommandSelect:q,onClose:()=>T(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,j?s.jsx(Ou,{ref:re,searchQuery:I,onFileSelect:ce,onAgentSelect:se,onClose:()=>D(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,K?s.jsx(Bu,{ref:ne,searchQuery:W,onSnippetSelect:z,onClose:()=>F(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null]})]}),m.execution.goalEnabled?s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-2",children:[s.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-2",children:[s.jsx(pr,{checked:m.execution.goalTokenBudget!==null,onChange:V=>p(De=>({...De,execution:{...De.execution,goalTokenBudget:V?2e5:null}})),ariaLabel:o("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),m.execution.goalTokenBudget!==null?s.jsx(_g,{value:m.execution.goalTokenBudget,onValueChange:V=>{typeof V=="number"&&Number.isFinite(V)&&V>0&&p(De=>({...De,execution:{...De.execution,goalTokenBudget:Math.floor(V)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),$e=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("label",{className:"inline-flex items-center gap-2",children:[s.jsx(pr,{checked:m.enabled,onChange:V=>p(De=>({...De,enabled:V})),ariaLabel:o("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:o("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe(od),onClick:()=>p(V=>({...V,execution:{...V.execution,permissionAutoAccept:!V.execution.permissionAutoAccept}})),"aria-pressed":m.execution.permissionAutoAccept,"aria-label":o("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:m.execution.permissionAutoAccept?s.jsx(M,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(M,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(Dt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",className:Oe(od,m.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>p(V=>({...V,execution:{...V.execution,goalEnabled:!V.execution.goalEnabled}})),"aria-pressed":m.execution.goalEnabled,"aria-label":o("sessions.scheduledTasks.editor.goal.aria"),children:m.execution.goalEnabled?s.jsx(M,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(M,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(Dt,{side:"top",sideOffset:6,children:o("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:S,children:o("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(dt,{type:"button",size:"sm",onClick:ae,disabled:S,children:o(S?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return y?s.jsx(Go,{open:e,title:We,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:V=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:We}),V]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:Ee})]}),footer:$e,children:xe}):s.jsx(ys,{open:e,onOpenChange:V=>{!V&&Ce()||r(V)},children:s.jsxs(ws,{"aria-describedby":Ne,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Is,{id:Ne,className:"sr-only",children:Ee}),s.jsx("header",{className:"shrink-0 px-4 sm:px-6 pt-5 pb-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsx(Ps,{className:"typography-ui-label font-medium text-foreground",children:We}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:Ee})]})}),s.jsx(Da,{className:"flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5",children:xe})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsx("div",{className:"mx-auto w-full max-w-2xl",children:$e})})]})})}function _4(t){return Cr(t,{min:0,max:23})}function L4(t,e){return Cr(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function $4(t,e){const n=Number(t),r=Number(e),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,o=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`}function z4(t){return s.jsx(ss,{value:t,children:t},t)}const W4=t=>{const n=(Array.isArray(t.schedule.times)?t.schedule.times:t.schedule.time?[t.schedule.time]:[]).filter(r=>typeof r=="string"&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(r));return Array.from(new Set(n)).sort((r,i)=>r.localeCompare(i))},K4=(t,e)=>{const n=W4(t).join(", ")||"--:--",r=i=>e(i===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":i===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":i===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":i===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":i===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":i===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":i===6?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sat":"sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown");if(t.schedule.kind==="daily")return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.dailyWithTimezone",{time:n,timezone:Jn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const i=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(o=>r(o)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:i,time:n,timezone:Jn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:i,time:n})}if(t.schedule.kind==="once"){const i=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),o=typeof t.schedule.time=="string"&&t.schedule.time.trim().length>0?t.schedule.time:"--:--";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.onceWithTimezone",{date:i,time:o,timezone:Jn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:i,time:o})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:Jn(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},V4=(t,e)=>!t||!Number.isFinite(t)?"":Lg(t,e),pd=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),i=6e4,o=60*i,l=24*o,a=n>=0;if(r<i)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<o){const f=Math.round(r/i);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<l){const f=Math.floor(r/o),x=Math.round(r%o/i),b=x>0?`${f}h ${x}m`:`${f}h`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:b}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:b})}const d=Math.floor(r/l),u=Math.round(r%l/o),h=u>0?`${d}d ${u}h`:`${d}d`;return a?e("sessions.scheduledTasks.dialog.relativeTime.inDuration",{duration:h}):e("sessions.scheduledTasks.dialog.relativeTime.durationAgo",{duration:h})},U4={success:{tone:"success",Icon:"checkbox-circle"},error:{tone:"error",Icon:"error-warning"},running:{tone:"warning",Icon:"loader-4",spin:!0},idle:{tone:"muted",Icon:"pulse"}},H4=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function G4(){const{t}=jt(),e=Pe(N=>N.isScheduledTasksDialogOpen),n=Pe(N=>N.setScheduledTasksDialogOpen),r=Pe(N=>N.isMobile),i=Pe(N=>N.timeFormatPreference),o=Ht(N=>N.projects),l=Ht(N=>N.getActiveProject()),a=ns(N=>N.homeDirectory),{currentTheme:d}=or(),[u,h]=mt.useState(""),[f,x]=mt.useState([]),[b,w]=mt.useState(!0),[v,y]=mt.useState(!1),[m,p]=mt.useState(null),[S,g]=mt.useState(null),C=mt.useMemo(()=>o.find(N=>N.id===u)||null,[o,u]),k=mt.useCallback(N=>{const R=N.label?.trim()||Ln(N.path,a||void 0),E=N.icon?_a[N.icon]:null,X=N.color?La[N.color]:void 0,J=E?s.jsx(M,{name:E,className:"h-3.5 w-3.5 shrink-0",style:X?{color:X}:void 0}):s.jsx(M,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:X?{color:X}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[N.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:N.iconBackground?{backgroundColor:N.iconBackground}:void 0,children:s.jsx($a,{project:{id:N.id,iconImage:N.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:J})}):J,s.jsx("span",{className:"truncate",children:R})]})},[a,d.metadata.variant,d.colors.surface.foreground]),j=mt.useCallback(async(N,R)=>{if(!N){x([]);return}R?.silent||w(!0);try{const E=await Fx(N);E.sort((X,J)=>{if(X.enabled!==J.enabled)return X.enabled?-1:1;const re=X.name.localeCompare(J.name);return re!==0?re:(X.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(J.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),x(E)}catch(E){Le.error(E instanceof Error?E.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),R?.silent||x([])}finally{R?.silent||w(!1)}},[t]);mt.useEffect(()=>{if(!e)return;const N=l?.id||o[0]?.id||"";h(N),N?j(N):(x([]),w(!1))},[e,l,o,j]),mt.useEffect(()=>{if(!e)return;let N=null;const R=eo(E=>{E.type==="scheduled-task-ran"&&E.projectId===u&&(N&&clearTimeout(N),N=setTimeout(()=>{j(u,{silent:!0})},400))});return()=>{N&&clearTimeout(N),R()}},[e,u,j]);const D=mt.useCallback(async N=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await Ul(u,N),await j(u),Le.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,j,t]),I=mt.useCallback(async(N,R)=>{if(u){g(N.id),x(E=>E.map(X=>X.id===N.id?{...X,enabled:R}:X));try{N.loopFile?await _x(u,N.id,R):await Ul(u,{...N,enabled:R}),await j(u,{silent:!0})}catch(E){Le.error(E instanceof Error?E.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await j(u,{silent:!0})}finally{g(null)}}},[u,j,t]),A=mt.useCallback(async N=>{if(!(!u||!window.confirm(N.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:N.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:N.name})))){g(N.id);try{N.loopFile?await Lx(u,N.id):await $x(u,N.id),await j(u,{silent:!0}),Le.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch(E){Le.error(E instanceof Error?E.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{g(null)}}},[u,j,t]),P=mt.useCallback(N=>{if(!N.loopFile){p(N),y(!0);return}C?.path&&(n(!1),hn.getState().setSelectedPath(C.path,N.loopFile,{allowOutsideRoot:!0}),Pe.getState().openContextFile(C.path,N.loopFile))},[C?.path,n]),T=mt.useCallback(async N=>{if(u){g(N.id);try{const{sessionId:R,persistError:E}=await zx(u,N.id);if(await Promise.all([j(u,{silent:!0}),za()]),E?Le.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Le.success(t("sessions.scheduledTasks.dialog.toast.started")),R){const X=o.find(J=>J.id===u);tt.getState().setCurrentSession(R,X?.path??null)}}catch(R){Le.error(R instanceof Error?R.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{g(null)}}},[u,o,j,t]),L=s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.label")}),s.jsxs(Bs,{value:u||"__none",onValueChange:N=>{const R=N==="__none"?"":N;h(R),R?j(R):x([])},children:[s.jsx(Fs,{size:"lg",className:r?"w-full":void 0,children:C?s.jsx(ks,{children:k(C)}):s.jsx(ks,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs(_s,{children:[o.length===0?s.jsx(ss,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,o.map(N=>s.jsx(ss,{value:N.id,children:k(N)},N.id))]})]})]}),$=()=>{p(null),y(!0)},K=N=>{h(N),N?j(N):x([])},F=s.jsx("div",{className:"min-h-[280px]",children:b?s.jsxs("div",{className:"flex items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx(M,{name:"loader-4",className:"h-4 w-4 animate-spin"})," ",t("sessions.scheduledTasks.dialog.loading")]}):f.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground",children:t(u?"sessions.scheduledTasks.dialog.empty.noTasks":"sessions.scheduledTasks.dialog.empty.selectProject")}):s.jsx("div",{className:"space-y-2.5",children:f.map(N=>{const R=S===N.id,E=N.state?.lastStatus||"idle",X=U4[E],J=t(E==="success"?"sessions.scheduledTasks.dialog.status.success":E==="error"?"sessions.scheduledTasks.dialog.status.error":E==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),re=N.state?.nextRunAt,fe=N.state?.lastRunAt;return s.jsxs("div",{className:Oe("rounded-lg border border-border p-4 transition-opacity"),children:[s.jsxs("div",{className:Oe("min-w-0",!N.enabled&&"opacity-60"),children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:N.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:K4(N,t)}),N.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:N.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:N.loopFile})}):null]}),s.jsxs("div",{className:Oe("mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",!N.enabled&&"opacity-60"),children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(M,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),re?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:pd(re,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:V4(re,i)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(M,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),E==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(M,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):fe?s.jsxs(s.Fragment,{children:[X.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${X.tone})`},children:[s.jsx(M,{name:X.Icon,className:"h-3.5 w-3.5"}),J]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:pd(fe,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),N.state?.lastError?s.jsxs("div",{className:Oe("mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",!N.enabled&&"opacity-60"),style:H4("error"),children:[s.jsx(M,{name:"error-warning",className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:N.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:Oe("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",N.enabled?"text-foreground":"text-muted-foreground",R&&"cursor-not-allowed opacity-50"),children:[s.jsx(pr,{checked:N.enabled,onChange:ne=>{I(N,ne)},ariaLabel:N.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:N.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:N.name}),disabled:R}),N.enabled?t("sessions.scheduledTasks.dialog.taskToggle.enabled"):t("sessions.scheduledTasks.dialog.taskToggle.paused")]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(dt,{variant:"outline",size:"sm",onClick:()=>{T(N)},disabled:R,children:[s.jsx(M,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(dt,{variant:"outline",size:"sm",onClick:()=>P(N),disabled:R,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:N.name}),children:[s.jsx(M,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(dt,{variant:"destructive",size:"sm",onClick:()=>{A(N)},disabled:R,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:N.name}),children:s.jsx(M,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},N.id)})})}),W=s.jsxs("div",{className:"space-y-4",children:[L,F]});return s.jsxs(s.Fragment,{children:[r?s.jsx(Go,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:N=>s.jsxs("div",{className:"flex flex-col gap-1 border-b border-border/40 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h2",{className:"typography-ui-label font-semibold text-foreground",children:t("sessions.scheduledTasks.dialog.title")}),N]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(dt,{className:"w-full",onClick:$,disabled:!u,children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:W}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface-elevated",children:s.jsxs("div",{className:"flex min-h-0 flex-1",children:[s.jsx("div",{className:"flex w-60 flex-shrink-0 flex-col border-r border-border/50",children:s.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:o.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):o.map(N=>s.jsx("button",{type:"button",onClick:()=>K(N.id),className:Oe("flex w-full min-w-0 items-center rounded-md px-2 py-1.5 text-left typography-ui-label focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",u===N.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:k(N)},N.id))})}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("div",{className:"flex items-center px-6 pt-3",children:s.jsxs(dt,{size:"sm",onClick:$,disabled:!u,children:[s.jsx(M,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-4",children:s.jsx("div",{className:"mx-auto w-full max-w-3xl",children:F})})]})]})}):null,s.jsx(F4,{open:v,task:m,onOpenChange:y,onSave:D})]})}const No=100;function q4(){const t=Ze.c(108),{t:e}=jt(),n=Pe(nC),r=Pe(sC),i=tt(tC),o=tt(eC),l=ns(Z4);let a;t[0]!==n?(a=re=>n?re.archivedSessions:[],t[0]=n,t[1]=a):a=t[1];const d=$s(rr(a)),[u,h]=c.useState(""),[f,x]=c.useState(null),[b,w]=c.useState(No);let v;t[2]!==u?(v=u.trim().toLowerCase(),t[2]=u,t[3]=v):v=t[3];const y=v;let m;e:{if(!n){let fe;t[4]===Symbol.for("react.memo_cache_sentinel")?(fe=[],t[4]=fe):fe=t[4],m=fe;break e}let re;t[5]!==d?(re=[...d].sort(J4),t[5]=d,t[6]=re):re=t[6],m=re}const p=m;let S;if(t[7]!==l||t[8]!==p||t[9]!==e){const re=new Map;for(const fe of p){const ne=ht(Ds(fe))??"",te=re.get(ne);if(te){te.sessions.push(fe);continue}re.set(ne,{directory:ne,label:ne?Ln(ne,l)||ne:e("sessions.archivePage.otherProjects"),sessions:[fe]})}S=[...re.values()].sort(X4),t[7]=l,t[8]=p,t[9]=e,t[10]=S}else S=t[10];const g=S;let C;e:{if(y){if(y.startsWith("ses_")){let ne;if(t[11]!==y||t[12]!==p){let te;t[14]!==y?(te=ue=>ue.id.toLowerCase()===y,t[14]=y,t[15]=te):te=t[15],ne=p.filter(te),t[11]=y,t[12]=p,t[13]=ne}else ne=t[13];C=ne;break e}let fe;t[16]!==y||t[17]!==p?(fe=$g(p,y,Q4),t[16]=y,t[17]=p,t[18]=fe):fe=t[18],C=fe;break e}if(f===null){C=p;break e}let re;t[19]!==g||t[20]!==f?(re=g.find(fe=>fe.directory===f)?.sessions??[],t[19]=g,t[20]=f,t[21]=re):re=t[21],C=re}const k=C;let j,D,I,A,P,T,L,$,K,F;if(t[22]!==d.length||t[23]!==g||t[24]!==k||t[25]!==l||t[26]!==y||t[27]!==n||t[28]!==u||t[29]!==f||t[30]!==i||t[31]!==r||t[32]!==e||t[33]!==o||t[34]!==b){P=Symbol.for("react.early_return_sentinel");e:{const re=k.slice(0,b);j=k.length-re.length;const fe=d.length;let ne;t[45]===Symbol.for("react.memo_cache_sentinel")?(ne=_=>{x(_),w(No)},t[45]=ne):ne=t[45];const te=ne;let ue;t[46]!==i||t[47]!==r?(ue=_=>{const B=ht(Ds(_));i(_.id,B??void 0),r(!1)},t[46]=i,t[47]=r,t[48]=ue):ue=t[48];const Se=ue;let we;t[49]!==e||t[50]!==o?(we=_=>{o(_.id).then(B=>{B?Le.success(e("sessions.sidebar.session.restore.success")):Le.error(e("sessions.sidebar.session.restore.error"))})},t[49]=e,t[50]=o,t[51]=we):we=t[51];const ye=we;if(!n){P=null;break e}let Ae;t[52]!==e?(Ae=(_,B,he,ve,Re,ce,se)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:Re,title:ce,className:Oe("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left typography-ui-label transition-[padding] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",se?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",ve?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:he})]}),se?s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>fn.requestDelete({sessions:se,mode:"session"}),className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:text-destructive group-hover/dir:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteProjectAria",{label:B}),children:s.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(Dt,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},_),t[52]=e,t[53]=Ae):Ae=t[53];const pe=Ae;A="absolute inset-0 z-10 flex flex-col bg-background",D="flex min-h-0 flex-1";let O;if(t[54]!==pe||t[55]!==f||t[56]!==e||t[57]!==fe){let _;t[59]===Symbol.for("react.memo_cache_sentinel")?(_=()=>te(null),t[59]=_):_=t[59],O=pe("__all__",e("sessions.archivePage.allDirectories"),fe,f===null,_),t[54]=pe,t[55]=f,t[56]=e,t[57]=fe,t[58]=O}else O=t[58];let Q;if(t[60]!==g||t[61]!==pe||t[62]!==f){let _;t[64]!==pe||t[65]!==f?(_=B=>pe(B.directory||"__none__",B.label,B.sessions.length,f===B.directory,()=>te(B.directory),B.directory||void 0,B.sessions),t[64]=pe,t[65]=f,t[66]=_):_=t[66],Q=g.map(_),t[60]=g,t[61]=pe,t[62]=f,t[63]=Q}else Q=t[63];t[67]!==O||t[68]!==Q?(I=s.jsx("div",{className:"flex w-64 flex-shrink-0 flex-col border-r border-border/50",children:s.jsxs("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:[O,Q]})}),t[67]=O,t[68]=Q,t[69]=I):I=t[69],K="flex min-w-0 flex-1 flex-col";let le;t[70]===Symbol.for("react.memo_cache_sentinel")?(le=_=>{h(_),w(No)},t[70]=le):le=t[70];let H;t[71]!==e?(H=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=H):H=t[72];let me;t[73]!==e?(me=e("sessions.sidebar.header.search.clear"),t[73]=e,t[74]=me):me=t[74];let ge;t[75]!==u||t[76]!==H||t[77]!==me?(ge=s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx(Vd,{value:u,onSearch:le,placeholder:H,clearLabel:me})}),t[75]=u,t[76]=H,t[77]=me,t[78]=ge):ge=t[78];let oe;t[79]!==k.length||t[80]!==e?(oe=k.length===1?e("sessions.archivePage.countSingle",{count:k.length}):e("sessions.archivePage.countPlural",{count:k.length}),t[79]=k.length,t[80]=e,t[81]=oe):oe=t[81];let de;t[82]!==oe?(de=s.jsx("span",{className:"flex h-8 flex-shrink-0 items-center self-start typography-micro text-muted-foreground",children:oe}),t[82]=oe,t[83]=de):de=t[83],t[84]!==ge||t[85]!==de?(F=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[ge,de]}),t[84]=ge,t[85]=de,t[86]=F):F=t[86],$="min-h-0 flex-1 overflow-y-auto px-6 py-3",T="mx-auto w-full max-w-3xl space-y-0.5",L=re.length===0?s.jsx("div",{className:"py-10 text-center text-muted-foreground",children:s.jsx("p",{className:"typography-ui-label font-semibold",children:e(y?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):re.map(_=>{const B=ht(Ds(_))??"",he=B?Ln(B,l)||B:null;return s.jsxs("div",{className:"group relative flex cursor-pointer items-center gap-3 rounded-md py-1 pl-2 pr-2 transition-[padding] hover:bg-interactive-hover/40 hover:pr-14 focus-within:pr-14",onClick:()=>Se(_),role:"button",tabIndex:0,onKeyDown:ve=>{(ve.key==="Enter"||ve.key===" ")&&(ve.preventDefault(),Se(_))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:_.title||e("sessions.sidebar.session.untitled")}),y&&he?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:B,children:he}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Ru(_.time?.archived??_.time?.updated??_.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),ye(_)},className:"absolute right-7 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-foreground group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.restoreSessionAria",{title:_.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(M,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:ve=>{ve.stopPropagation(),fn.requestDelete({sessions:[_],mode:"session"})},className:"absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity pointer-events-none hover:text-destructive group-hover:opacity-100 group-hover:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e("sessions.archivePage.deleteSessionAria",{title:_.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(M,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},_.id)})}t[22]=d.length,t[23]=g,t[24]=k,t[25]=l,t[26]=y,t[27]=n,t[28]=u,t[29]=f,t[30]=i,t[31]=r,t[32]=e,t[33]=o,t[34]=b,t[35]=j,t[36]=D,t[37]=I,t[38]=A,t[39]=P,t[40]=T,t[41]=L,t[42]=$,t[43]=K,t[44]=F}else j=t[35],D=t[36],I=t[37],A=t[38],P=t[39],T=t[40],L=t[41],$=t[42],K=t[43],F=t[44];if(P!==Symbol.for("react.early_return_sentinel"))return P;let W;t[87]!==j||t[88]!==e?(W=j>0?s.jsx("button",{type:"button",onClick:()=>w(Y4),className:"mt-1 flex items-center justify-start rounded-md px-2 py-1 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,t[87]=j,t[88]=e,t[89]=W):W=t[89];let N;t[90]!==W||t[91]!==T||t[92]!==L?(N=s.jsxs("div",{className:T,children:[L,W]}),t[90]=W,t[91]=T,t[92]=L,t[93]=N):N=t[93];let R;t[94]!==N||t[95]!==$?(R=s.jsx("div",{className:$,children:N}),t[94]=N,t[95]=$,t[96]=R):R=t[96];let E;t[97]!==R||t[98]!==K||t[99]!==F?(E=s.jsxs("div",{className:K,children:[F,R]}),t[97]=R,t[98]=K,t[99]=F,t[100]=E):E=t[100];let X;t[101]!==D||t[102]!==I||t[103]!==E?(X=s.jsxs("div",{className:D,children:[I,E]}),t[101]=D,t[102]=I,t[103]=E,t[104]=X):X=t[104];let J;return t[105]!==A||t[106]!==X?(J=s.jsx("div",{className:A,children:X}),t[105]=A,t[106]=X,t[107]=J):J=t[107],J}function Y4(t){return t+No}function Q4(t){return[t.title]}function X4(t,e){return e.sessions.length-t.sessions.length}function J4(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function Z4(t){return t.homeDirectory}function eC(t){return t.unarchiveSession}function tC(t){return t.setCurrentSession}function sC(t){return t.setArchivePageOpen}function nC(t){return t.isArchivePageOpen}function rC(){const t=Ze.c(18),{t:e}=jt(),n=Pe(aC),r=Pe(iC),i=Ht(oC);let o;t[0]!==n?(o=b=>b.projects.find(w=>w.id===n)??null,t[0]=n,t[1]=o):o=t[1];const l=Ht(o);if(!n||!l)return null;let a;t[2]!==l.id||t[3]!==i||t[4]!==r?(a=()=>{i(l.id),r(!0)},t[2]=l.id,t[3]=i,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(M,{name:"node-tree",className:"mr-1 h-3.5 w-3.5"}),t[6]=d):d=t[6];let u;t[7]!==e?(u=e("sessions.sidebar.project.actions.newWorktree"),t[7]=e,t[8]=u):u=t[8];let h;t[9]!==a||t[10]!==u?(h=s.jsx("div",{className:"flex items-center",children:s.jsxs(dt,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=h):h=t[11];let f;t[12]!==l.id||t[13]!==l.path?(f=s.jsx($h,{projectRef:{id:l.id,path:l.path},sections:"list-only"}),t[12]=l.id,t[13]=l.path,t[14]=f):f=t[14];let x;return t[15]!==h||t[16]!==f?(x=s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",children:s.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:s.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4",children:[h,f]})})}),t[15]=h,t[16]=f,t[17]=x):x=t[17],x}function oC(t){return t.setActiveProjectIdOnly}function iC(t){return t.setNewWorktreeDialogOpen}function aC(t){return t.worktreesPageProjectId}function em(t){const e=Ze.c(30),{git:n}=vn(),r=hu(t),i=pu(t),o=zg(t),l=Wg(t),a=Tn(fC),d=Tn(uC);let u,h;e[0]!==t||e[1]!==d||e[2]!==n||e[3]!==i||e[4]!==o?(u=()=>{!t||!n||i!==null||o||d(t,n,{silent:!0})},h=[t,n,d,i,o],e[0]=t,e[1]=d,e[2]=n,e[3]=i,e[4]=o,e[5]=u,e[6]=h):(u=e[5],h=e[6]),c.useEffect(u,h);let f;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==i?(f=()=>{!t||!n||i===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=i,e[12]=f):f=e[12];const x=r?.all;let b;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==i||e[17]!==x?(b=[t,n,i,x,a],e[13]=t,e[14]=a,e[15]=n,e[16]=i,e[17]=x,e[18]=b):b=e[18],c.useEffect(f,b);const w=o||i===!0&&l;let v;e:{if(!r?.all){let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[19]=j):j=e[19],v=j;break e}let k;e[20]!==r.all?(k=r.all.filter(dC).sort(),e[20]=r.all,e[21]=k):k=e[21],v=k}const y=v;let m;e:{if(!r?.all){let j;e[22]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[22]=j):j=e[22],m=j;break e}let k;e[23]!==r.all?(k=r.all.filter(cC).map(lC).sort(),e[23]=r.all,e[24]=k):k=e[24],m=k}const p=m;let S;e:{if(!t){S=null;break e}if(i!==null){S=i;break e}if(w){S=null;break e}S=r?.all?!0:null}const g=S;let C;return e[25]!==g||e[26]!==w||e[27]!==y||e[28]!==p?(C={localBranches:y,remoteBranches:p,isLoading:w,isGitRepository:g},e[25]=g,e[26]=w,e[27]=y,e[28]=p,e[29]=C):C=e[29],C}function lC(t){return t.replace(/^remotes\//,"")}function cC(t){return t.startsWith("remotes/")}function dC(t){return!t.startsWith("remotes/")}function uC(t){return t.fetchStatus}function fC(t){return t.fetchBranches}const mC=({directory:t,value:e,onChange:n,className:r,disabled:i,id:o})=>{const{t:l}=jt(),{localBranches:a,remoteBranches:d,isLoading:u,isGitRepository:h}=em(t),f=c.useMemo(()=>[...a,...d.map(b=>`remotes/${b}`)],[a,d]);c.useEffect(()=>{if(i||u||f.length===0||e&&f.includes(e))return;const b=e;let w=!1;return(async()=>{try{const y=t?await Aa(t).catch(()=>null):null;if(w)return;const m=localStorage.getItem(wl),{sourceBranch:p,shouldClearSavedSourceBranch:S}=zh({branches:f,savedSourceBranch:m,rootBranch:y});if(S&&localStorage.removeItem(wl),w||b&&f.includes(b))return;p&&n(p)}catch{}})(),()=>{w=!0}},[f,t,i,u,n,e]);const x=i||!h||u;return s.jsxs("div",{children:[s.jsxs(Bs,{value:e,onValueChange:n,disabled:x,children:[s.jsx(Fs,{id:o,size:"lg",className:Oe("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(ks,{placeholder:l(u?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(_s,{className:"max-h-[280px] max-w-[320px]",children:u?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.loadingBranches")}):a.length===0&&d.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:l("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(Wi,{children:[s.jsx(Bl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.localBranches")}),a.map(b=>s.jsx(ss,{value:b,className:"whitespace-normal break-all",children:b},b))]}),a.length>0&&d.length>0&&s.jsx(Kg,{}),d.length>0&&s.jsxs(Wi,{children:[s.jsx(Bl,{className:"font-semibold text-foreground",children:l("multiRun.branchSelector.groups.remoteBranches")}),d.map(b=>s.jsx(ss,{value:`remotes/${b}`,className:"whitespace-normal break-all",children:b},`remotes/${b}`))]})]})})]}),h===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:l("multiRun.branchSelector.status.notInGitRepository")})]})},hC=10*1024*1024,Ao=t=>{const e=Ze.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:-1,className:"inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:s.jsx(M,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let i;return e[1]!==n?(i=s.jsxs(Nt,{children:[r,s.jsx(Dt,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=i):i=e[2],i},Xn=t=>{const e=Ze.c(9),{htmlFor:n,required:r,children:i,info:o}=t;let l;e[0]!==r?(l=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=l):l=e[1];let a;e[2]!==i||e[3]!==n||e[4]!==l?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[i,l]}),e[2]=i,e[3]=n,e[4]=l,e[5]=a):a=e[5];const d=o&&o;let u;return e[6]!==a||e[7]!==d?(u=s.jsxs("div",{className:"flex items-center gap-1.5",children:[a,d]}),e[6]=a,e[7]=d,e[8]=u):u=e[8],u},pC=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:i}=jt(),[o,l]=c.useState(""),[a,d]=c.useState(()=>[{id:Vr(),prompt:"",models:[]}]),[u,h]=c.useState(""),[f,x]=c.useState([]),[b,w]=c.useState(!1),[v,y]=c.useState([]),[m,p]=c.useState(!1),[S,g]=c.useState(!1),[C,k]=c.useState(!0),j=c.useRef(null),D=ns(q=>q.currentDirectory??null),I=ns(q=>q.homeDirectory??null),A=c.useMemo(()=>{if(typeof window>"u")return null;const q=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof q=="string"&&q.trim().length>0?q.trim():null},[]),P=Ht(q=>q.activeProjectId),T=Ht(q=>q.setActiveProjectIdOnly),L=Ht(q=>q.projects),[$,K]=c.useState(()=>P??null);c.useEffect(()=>{if(P){K(P);return}!$&&L.length>0&&K(L[0].id)},[P,L,$]);const F=c.useMemo(()=>$?L.find(q=>q.id===$)??null:null,[L,$]),W=F?.path??D,N=c.useCallback(q=>{K(q),q!==P&&T(q)},[P,T]),{currentTheme:R}=or(),E=c.useCallback(q=>{const z=q.label?.trim()||Ln(q.path,I),ee=q.icon?_a[q.icon]:null,ae=q.color?La[q.color]:void 0,Ne=ee?s.jsx(M,{name:ee,className:"h-3.5 w-3.5 shrink-0",style:ae?{color:ae}:void 0}):s.jsx(M,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:ae?{color:ae}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[q.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:q.iconBackground?{backgroundColor:q.iconBackground}:void 0,children:s.jsx($a,{project:{id:q.id,iconImage:q.iconImage??null},options:{themeVariant:R.metadata.variant,iconColor:R.colors.surface.foreground},className:"h-full w-full object-contain",fallback:Ne})}):Ne,s.jsx("span",{className:"truncate",children:z})]})},[I,R.metadata.variant,R.colors.surface.foreground]),X=c.useMemo(()=>{if(F?.path)return{id:F.id,path:F.path};const q=D??A;return q?{id:`path:${q}`,path:q}:null},[F,D,A]),[J]=c.useState(()=>typeof window<"u"?xn():!1),re=c.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),fe=tu(),ne=c.useMemo(()=>{if(typeof window>"u")return null;const q=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof q=="number"&&Number.isFinite(q)&&q>0)return q;if(typeof navigator>"u")return null;const z=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!z)return null;const ee=Number.parseInt(z[1],10),ae=Number.parseInt(z[2],10);return Number.isNaN(ee)?null:ee===10?ae:ee},[]),te=c.useMemo(()=>J&&re||fe?"pl-[88px]":"pl-3",[J,re,fe]),ue=c.useMemo(()=>!J||!re||ne===null?"":ne>=26?"h-12":ne<=15?"h-14":"",[J,re,ne]),Se=c.useCallback(async q=>{q.target.closest("button, a, input, select, textarea")||q.button===0&&J&&await Vg()},[J]);c.useEffect(()=>{if(!n)return;const q=z=>{z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),n())};return window.addEventListener("keydown",q,!0),()=>window.removeEventListener("keydown",q,!0)},[n]);const[we,ye]=c.useState(""),{isLoading:Ae,isGitRepository:pe}=em(W),O=c.useRef(!1),Q=pe===!0,le=Q&&C;c.useEffect(()=>{if(pe===!1){O.current=!0,k(!1);return}pe===!0&&O.current&&(O.current=!1,k(!0))},[pe]);const H=li(q=>q.createMultiRun),me=li(q=>q.error),ge=li(q=>q.clearError);c.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&d(q=>{const z=[...q];return z.length>0&&!z[0].prompt.trim()&&(z[0]={...z[0],prompt:t}),z})},[t]),c.useEffect(()=>{if(!X)return;let q=!1;return g(!0),(async()=>{try{const z=await Ug(X);q||y(z)}catch{}finally{q||g(!1)}})(),()=>{q=!0}},[X]);const oe=c.useCallback((q,z)=>{d(ee=>ee.map(ae=>ae.id===q?{...ae,...z}:ae))},[]),de=c.useCallback(q=>{d(z=>z.filter(ee=>ee.id!==q))},[]),_=c.useCallback(()=>{d(q=>[...q,{id:Vr(),prompt:"",models:[]}])},[]),B=async q=>{const z=q.target.files;if(!z)return;let ee=0;for(let ae=0;ae<z.length;ae++){const Ne=z[ae];if(Ne.size>hC){Le.error(i("multirun.launcher.toast.fileTooLarge",{fileName:Ne.name}));continue}try{const Ce=await new Promise((We,Ee)=>{const xe=new FileReader;xe.onload=()=>We(xe.result),xe.onerror=Ee,xe.readAsDataURL(Ne)});x(We=>[...We,{id:Vr(),filename:Ne.name,mimeType:Ne.type||"application/octet-stream",size:Ne.size,dataUrl:Ce}]),ee++}catch(Ce){console.error("File attach failed",Ce),Le.error(i("multirun.launcher.toast.attachFailed",{fileName:Ne.name}))}}ee>0&&Le.success(ee===1?i("multirun.launcher.toast.attachedSingle",{count:ee}):i("multirun.launcher.toast.attachedPlural",{count:ee})),j.current&&(j.current.value="")},he=q=>{x(z=>z.filter(ee=>ee.id!==q))},ve=c.useMemo(()=>a.reduce((q,z)=>q+z.models.length,0),[a]),Re=async q=>{q.preventDefault();const z=a.filter(ee=>ee.prompt.trim()&&ee.models.length>=1);if(z.length!==0&&!(ve<1)){w(!0),ge();try{$&&$!==P&&T($);const ee=f.map(Ee=>({mime:Ee.mimeType,filename:Ee.filename,url:Ee.dataUrl})),ae=v.filter(Ee=>Ee.trim().length>0),Ne=z.map(Ee=>({prompt:Ee.prompt.trim(),models:Ee.models.map(xe=>({providerID:xe.providerID,modelID:xe.modelID,displayName:xe.displayName,variant:xe.variant}))})),Ce={name:o.trim(),groups:Ne,agent:u||void 0,worktreeBaseBranch:le?we:void 0,isolateRuns:le,files:ee.length>0?ee:void 0,setupCommands:ae.length>0?ae:void 0},We=await H(Ce);We&&(We.failedCount>0&&Le.error(i("multirun.launcher.toast.partialFailure",{failed:We.failedCount})),We.firstSessionId&&tt.getState().setCurrentSession(We.firstSessionId),e?.())}finally{w(!1)}}},ce=!!(o.trim()&&a.some(q=>q.prompt.trim()&&q.models.length>=1)&&ve>=1&&W&&!Ae&&(pe===!1||!le||we)),se=v.filter(q=>q.trim()).length;return s.jsxs("form",{onSubmit:Re,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:Se,className:Oe("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",te,ue),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:i("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":i("multirun.launcher.actions.closeEsc"),className:"inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring app-region-no-drag",children:s.jsx(M,{name:"close",className:"h-5 w-5"})})}),s.jsx(Dt,{children:s.jsx("p",{children:i("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(Da,{className:"flex-1 min-h-0 overflow-auto",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 py-5",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Xn,{htmlFor:"multirun-project",required:!0,children:i("multirun.launcher.project.label")}),L.length>0?s.jsxs(Bs,{value:$??void 0,onValueChange:N,children:[s.jsx(Fs,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:F?s.jsx(ks,{children:E(F)}):s.jsx(ks,{placeholder:i("multirun.launcher.project.placeholder")})}),s.jsx(_s,{fitContent:!0,children:L.map(q=>s.jsx(ss,{value:q.id,className:"max-w-[24rem]",children:E(q)},q.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:i("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Xn,{htmlFor:"group-name",required:!0,info:s.jsx(Ao,{children:i("multirun.launcher.groupName.info")}),children:i("multirun.launcher.groupName.label")}),s.jsx(An,{id:"group-name",value:o,onChange:q=>l(q.target.value),placeholder:i("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Xn,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(Ao,{children:i("multirun.launcher.baseBranch.info")}),children:i("multirun.launcher.baseBranch.label")}),s.jsx(mC,{directory:W,value:we,onChange:ye,disabled:!le,id:"multirun-worktree-base-branch"}),s.jsxs("label",{className:"mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(pr,{checked:C,onChange:k,disabled:!Q,ariaLabel:i("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:i("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Xn,{htmlFor:"multirun-agent",info:s.jsx(Ao,{children:i("multirun.launcher.agent.info")}),children:i("multirun.launcher.agent.label")}),s.jsx(Kf,{value:u,onChange:h,id:"multirun-agent"})]})]}),s.jsxs(Bi,{open:m,onOpenChange:p,children:[s.jsxs(mu,{className:"w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group",children:[s.jsx(M,{name:"terminal",className:"h-3.5 w-3.5 text-muted-foreground/70"}),s.jsx("span",{className:"typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors",children:i("multirun.launcher.setupCommands.label")}),se>0&&s.jsx("span",{className:"inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium",style:{backgroundColor:"var(--primary-base)",color:"var(--primary-foreground)",fontSize:"0.625rem",lineHeight:1},children:se}),s.jsx(M,{name:"arrow-down-s",className:Oe("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",m&&"rotate-180")})]}),s.jsx(Fi,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:S?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:i("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[v.map((q,z)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(An,{value:q,onChange:ee=>{const ae=[...v];ae[z]=ee.target.value,y(ae)},placeholder:i("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>y(v.filter((ee,ae)=>ae!==z)),className:"flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":i("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(M,{name:"close",className:"h-3.5 w-3.5"})})]},`${q}-${z}`)),s.jsxs("button",{type:"button",onClick:()=>y([...v,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(M,{name:"add",className:"h-3 w-3"}),i("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Xn,{htmlFor:"prompt",required:!0,children:i("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:j,type:"file",multiple:!0,className:"hidden",onChange:B,accept:"*/*"}),s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>j.current?.click(),className:"inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(M,{name:"attachment-2",className:"h-3 w-3"}),i("multirun.launcher.attachments.attach")]})}),s.jsx(Dt,{children:i("multirun.launcher.attachments.tooltip")})]}),f.map(q=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border",style:{backgroundColor:"var(--surface-elevated)",borderColor:"var(--interactive-border)"},children:[q.mimeType.startsWith("image/")?s.jsx(M,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(M,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:q.filename,children:q.filename}),s.jsx("button",{type:"button",onClick:()=>he(q.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(M,{name:"close",className:"h-3 w-3"})})]},q.id))]})]}),a.map((q,z)=>s.jsx(gC,{group:q,groupIndex:z,canRemove:a.length>1,onUpdate:oe,onRemove:de},q.id)),s.jsxs("button",{type:"button",onClick:_,className:"flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(M,{name:"add",className:"h-3.5 w-3.5"}),i("multirun.launcher.groups.addGroup")]}),me&&s.jsx("div",{className:"px-3 py-2 rounded-lg typography-meta",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderWidth:1,borderColor:"var(--status-error-border)"},children:me})]})})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl flex items-center justify-end gap-2",children:[!le&&pe!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(M,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:i("multirun.launcher.project.gitRequired")})]}):null,!r&&n?s.jsx(dt,{type:"button",variant:"ghost",size:"sm",onClick:n,children:i("multirun.launcher.actions.cancel")}):null,s.jsx(dt,{type:"submit",size:"sm",disabled:!ce||b,children:b?i("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:i("multirun.launcher.actions.startWithRunCount",{count:ve})})})]})})]})},gC=t=>{const e=Ze.c(99),{group:n,groupIndex:r,canRemove:i,onUpdate:o,onRemove:l}=t,{t:a}=jt(),[d,u]=c.useState(!1),[h,f]=c.useState(""),[x,b]=c.useState(!1),[w,v]=c.useState(""),[y,m]=c.useState(!1),[p,S]=c.useState(""),g=c.useRef(null),C=c.useRef(null),k=c.useRef(null),j=c.useRef(null);let D;e[0]!==n.id||e[1]!==n.models||e[2]!==o?(D=ae=>{o(n.id,{models:[...n.models,ae]})},e[0]=n.id,e[1]=n.models,e[2]=o,e[3]=D):D=e[3];const I=D;let A;e[4]!==n.id||e[5]!==n.models||e[6]!==o?(A=ae=>{o(n.id,{models:n.models.filter((Ne,Ce)=>Ce!==ae)})},e[4]=n.id,e[5]=n.models,e[6]=o,e[7]=A):A=e[7];const P=A;let T;e[8]!==n.id||e[9]!==n.models||e[10]!==o?(T=(ae,Ne)=>{o(n.id,{models:n.models.map((Ce,We)=>We===ae?Ne:Ce)})},e[8]=n.id,e[9]=n.models,e[10]=o,e[11]=T):T=e[11];const L=T;let $;e[12]===Symbol.for("react.memo_cache_sentinel")?($=(ae,Ne)=>{if(ae.startsWith("/")){const xe=ae.indexOf(" "),$e=ae.indexOf(`
|
|
893
893
|
`),V=Math.min(xe===-1?ae.length:xe,$e===-1?ae.length:$e);if(Ne<=V&&xe===-1){v(ae.substring(1,V)),b(!0),u(!1),m(!1);return}}b(!1);const Ce=ae.substring(0,Ne),We=Ce.lastIndexOf("#");if(We!==-1){const xe=We>0?Ce[We-1]:null,$e=Ce.substring(We+1);if((!xe||/\s/.test(xe))&&!$e.includes(" ")&&!$e.includes(`
|
|
894
894
|
`)){S($e),m(!0),u(!1);return}}m(!1);const Ee=Ce.lastIndexOf("@");if(Ee!==-1){const xe=Ee>0?Ce[Ee-1]:null,$e=Ce.substring(Ee+1);(!xe||/\s/.test(xe))&&!$e.includes(" ")&&!$e.includes(`
|
|
895
|
-
`)?(f($e),u(!0)):u(!1);return}u(!1)},e[12]=$):$=e[12];const K=$;let F;e[13]!==n.id||e[14]!==o?(F=ae=>{o(n.id,{prompt:ae})},e[13]=n.id,e[14]=o,e[15]=F):F=e[15];const W=F;let N;e[16]!==n.prompt||e[17]!==W?(N=ae=>{const Ne=n.prompt,We=g.current?.selectionStart??Ne.length,xe=Ne.substring(0,We).lastIndexOf("@"),$e=ae.relativePath&&ae.relativePath.trim().length>0?ae.relativePath.trim():ae.path||ae.name,V=xe!==-1?xe:We,De=`${Ne.substring(0,V)}@${$e} ${Ne.substring(We)}`,Fe=V+$e.length+2;W(De),u(!1),f(""),requestAnimationFrame(()=>{const _e=g.current;_e&&(_e.selectionStart=Fe,_e.selectionEnd=Fe,_e.focus()),K(De,Fe)})},e[16]=n.prompt,e[17]=W,e[18]=N):N=e[18];const R=N;let E;e[19]!==n.prompt||e[20]!==W?(E=ae=>{const Ne=n.prompt,We=g.current?.selectionStart??Ne.length,xe=Ne.substring(0,We).lastIndexOf("@"),$e=xe!==-1?xe:We,V=`${Ne.substring(0,$e)}@${ae} ${Ne.substring(We)}`,De=$e+ae.length+2;W(V),u(!1),f(""),requestAnimationFrame(()=>{const Fe=g.current;Fe&&(Fe.selectionStart=De,Fe.selectionEnd=De,Fe.focus()),K(V,De)})},e[19]=n.prompt,e[20]=W,e[21]=E):E=e[21];const X=E;let J;e[22]!==W?(J=ae=>{const Ne=`/${ae.name} `;W(Ne),b(!1),v(""),m(!1),requestAnimationFrame(()=>{const Ce=g.current;Ce&&(Ce.focus(),Ce.selectionStart=Ce.value.length,Ce.selectionEnd=Ce.value.length),K(Ne,Ne.length)})},e[22]=W,e[23]=J):J=e[23];const re=J;let fe;e[24]!==n.prompt||e[25]!==W?(fe=(ae,Ne)=>{const Ce=n.prompt,Ee=g.current?.selectionStart??Ce.length,$e=Ce.substring(0,Ee).lastIndexOf("#"),V=$e!==-1?$e:Ee,De=`${Ce.substring(0,V)}#${Ne} ${Ce.substring(Ee)}`,Fe=V+Ne.length+2;W(De),m(!1),S(""),requestAnimationFrame(()=>{const _e=g.current;_e&&(_e.selectionStart=Fe,_e.selectionEnd=Fe,_e.focus()),K(De,Fe)})},e[24]=n.prompt,e[25]=W,e[26]=fe):fe=e[26];const ne=fe;let te;e[27]!==x||e[28]!==d||e[29]!==y?(te=ae=>{if(x&&k.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")){ae.preventDefault(),k.current.handleKeyDown(ae.key);return}d&&C.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")&&(ae.preventDefault(),C.current.handleKeyDown(ae.key)),y&&j.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")&&(ae.preventDefault(),j.current.handleKeyDown(ae.key))},e[27]=x,e[28]=d,e[29]=y,e[30]=te):te=e[30];const ue=te,Se=r+1;let we;e[31]!==a||e[32]!==Se?(we=a("multirun.launcher.groups.groupLabel",{index:Se}),e[31]=a,e[32]=Se,e[33]=we):we=e[33];let ye;e[34]!==we?(ye=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:we}),e[34]=we,e[35]=ye):ye=e[35];let Ae;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(Ae=i&&s.jsx("button",{type:"button",onClick:()=>l(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":a("multirun.launcher.groups.removeGroup"),children:s.jsx(M,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=Ae):Ae=e[40];let pe;e[41]!==ye||e[42]!==Ae?(pe=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ye,Ae]}),e[41]=ye,e[42]=Ae,e[43]=pe):pe=e[43];let O;e[44]!==a?(O=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=O):O=e[45];let Q;e[46]!==O?(Q=s.jsx(Xn,{required:!0,children:O}),e[46]=O,e[47]=Q):Q=e[47];const le=n.prompt;let H;e[48]!==W?(H=ae=>{const Ne=ae.target.value;W(Ne);const Ce=ae.target.selectionStart??Ne.length;K(Ne,Ce)},e[48]=W,e[49]=H):H=e[49];let me;e[50]!==a?(me=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=me):me=e[51];let ge;e[52]!==n.prompt||e[53]!==ue||e[54]!==H||e[55]!==me?(ge=s.jsx(fr,{ref:g,value:le,onChange:H,onKeyDown:ue,placeholder:me,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=ue,e[54]=H,e[55]=me,e[56]=ge):ge=e[56];let oe;e[57]!==w||e[58]!==re||e[59]!==x?(oe=x?s.jsx(Mu,{ref:k,searchQuery:w,onCommandSelect:re,onClose:()=>b(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=w,e[58]=re,e[59]=x,e[60]=oe):oe=e[60];let de;e[61]!==X||e[62]!==R||e[63]!==h||e[64]!==d?(de=d?s.jsx(Ou,{ref:C,searchQuery:h,onFileSelect:R,onAgentSelect:X,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=X,e[62]=R,e[63]=h,e[64]=d,e[65]=de):de=e[65];let _;e[66]!==ne||e[67]!==y||e[68]!==p?(_=y?s.jsx(Bu,{ref:j,searchQuery:p,onSnippetSelect:ne,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=ne,e[67]=y,e[68]=p,e[69]=_):_=e[69];let B;e[70]!==ge||e[71]!==oe||e[72]!==de||e[73]!==_?(B=s.jsxs("div",{className:"relative",children:[ge,oe,de,_]}),e[70]=ge,e[71]=oe,e[72]=de,e[73]=_,e[74]=B):B=e[74];let he;e[75]!==Q||e[76]!==B?(he=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[Q,B]}),e[75]=Q,e[76]=B,e[77]=he):he=e[77];let ve;e[78]!==a?(ve=a("multirun.launcher.models.info"),e[78]=a,e[79]=ve):ve=e[79];let Re;e[80]!==ve?(Re=s.jsx(Ao,{children:ve}),e[80]=ve,e[81]=Re):Re=e[81];let ce;e[82]!==a?(ce=a("multirun.launcher.models.label"),e[82]=a,e[83]=ce):ce=e[83];let se;e[84]!==Re||e[85]!==ce?(se=s.jsx(Xn,{required:!0,info:Re,children:ce}),e[84]=Re,e[85]=ce,e[86]=se):se=e[86];let q;e[87]!==n.models||e[88]!==I||e[89]!==P||e[90]!==L?(q=s.jsx(Vf,{selectedModels:n.models,onAdd:I,onRemove:P,onUpdate:L,minModels:1}),e[87]=n.models,e[88]=I,e[89]=P,e[90]=L,e[91]=q):q=e[91];let z;e[92]!==se||e[93]!==q?(z=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[se,q]}),e[92]=se,e[93]=q,e[94]=z):z=e[94];let ee;return e[95]!==pe||e[96]!==he||e[97]!==z?(ee=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[pe,he,z]}),e[95]=pe,e[96]=he,e[97]=z,e[98]=ee):ee=e[98],ee};function xC(t){const e=[],n=(r,i)=>{const o=ht(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const bC=t=>{const e=new Map;for(const n of t){const r=Ds(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},yC=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},wC=t=>{const e=Ze.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,d;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const u=qt(),h=bC(i),f=l.current?.runtimeKey===u?l.current.identities:null;for(const x of yC(f,h))Hg({runtimeKey:u,...x});l.current={runtimeKey:u,identities:h}},d=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),c.useEffect(a,d)},vC=new Map,SC=t=>{const e=Ze.c(23),{isVSCode:n}=t,r=Yo(),i=Ht(jC),o=ns(kC),l=tt(CC);let a;e[0]!==n?(a=I=>n?vC:I.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=tt(a),u=!n;let h;e[2]!==d||e[3]!==i||e[4]!==u?(h=Xf(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=h):h=e[5];const f=h,x=$s(NC),b=$s(AC),w=$s(DC),v=`session-list-sync:${c.useId()}`;let y,m;e[6]!==v||e[7]!==r||e[8]!==o||e[9]!==l?(y=()=>(r.setBootstrapDemand(v,xC({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(v)),m=[v,r,o,l],e[6]=v,e[7]=r,e[8]=o,e[9]=l,e[10]=y,e[11]=m):(y=e[10],m=e[11]),c.useEffect(y,m);const p=c.useRef(null);let S,g;e[12]!==n||e[13]!==f?(S=()=>{const I=new Set(f),A=p.current;p.current=I;const P=A?[...I].filter(T=>!A.has(T)):n?[...I]:[];P.length&&ka(P,To())},g=[n,f],e[12]=n,e[13]=f,e[14]=S,e[15]=g):(S=e[14],g=e[15]),c.useEffect(S,g);let C;e[16]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[16]=C):C=e[16],c.useEffect(PC,C);let k;e[17]!==b||e[18]!==x?(k=[...x,...b],e[17]=b,e[18]=x,e[19]=k):k=e[19];const j=k;let D;e[20]!==j||e[21]!==w?(D={enabled:!0,hasAuthoritativeGlobalSessions:w,sessions:j},e[20]=j,e[21]=w,e[22]=D):D=e[22],wC(D)};function jC(t){return t.projects}function kC(t){return t.currentDirectory}function CC(t){return t.currentSessionDirectory}function NC(t){return t.activeSessions}function AC(t){return t.archivedSessions}function DC(t){return t.status==="ready"}function PC(){let t=null,e=!1;const n=new Set,r=eo(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),za(To());return}const o=[...n];n.clear(),o.length&&ka(o,To())},500)});return()=>{t&&clearTimeout(t),r()}}const IC=Wn(()=>En(()=>import("./SettingsWindow-FLDJXOgQ.js"),__vite__mapDeps([144,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,145,84,85,86,146,131,132,133,134,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,147,148,149])).then(t=>({default:t.SettingsWindow}))),TC=()=>{const t=Ze.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],SC(e),Wh();const n=Pe(EC),r=Pe(RC),i=Pe(MC),o=Pe(OC),[l,a]=c.useState(!1);let d,u;t[1]!==i?(d=()=>{i&&a(!0)},u=[i],t[1]=i,t[2]=d,t[3]=u):(d=t[2],u=t[3]),c.useEffect(d,u);const h=Pe(BC),f=Pe(FC),x=Pe(_C),b=Pe(LC),w=Pe($C),v=Pe(zC),y=Pe(WC),m=Cu();let p;if(t[4]!==m||t[5]!==y){let B;t[7]!==y?(B=he=>he.id===y,t[7]=y,t[8]=B):B=t[8],p=m.find(B),t[4]=m,t[5]=y,t[6]=p}else p=t[6];const S=p;let g,C;t[9]!==S||t[10]!==y?(g=()=>{y&&!S&&Pe.getState().setOpenGuestPage(null)},C=[y,S],t[9]=S,t[10]=y,t[11]=g,t[12]=C):(g=t[11],C=t[12]),c.useEffect(g,C);let k;t[13]===Symbol.for("react.memo_cache_sentinel")?(k=[],t[13]=k):k=t[13],c.useEffect(VC,k);const j=b||w||!!v||h||!!S;let D;t[14]===Symbol.for("react.memo_cache_sentinel")?(D=[],t[14]=D):D=t[14],c.useEffect(HC,D);const{isMobile:I}=zn();Kh();const A=ty();let P,T;t[15]!==I||t[16]!==r?(P=()=>{Pe.getState().isMobile!==I&&r(I)},T=[I,r],t[15]=I,t[16]=r,t[17]=P,t[18]=T):(P=t[17],T=t[18]),c.useEffect(P,T);let L,$,K,F;t[19]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx($S,{}),$=s.jsx(F0,{}),K=s.jsx(z0,{}),F=s.jsx(y4,{}),t[19]=L,t[20]=$,t[21]=K,t[22]=F):(L=t[19],$=t[20],K=t[21],F=t[22]);let W;t[23]!==A?(W=s.jsx(w4,{value:A,onMoveSessionOnly:GC,onMoveAllChanges:qC,onCancel:dy}),t[23]=A,t[24]=W):W=t[24];let N;t[25]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(by,{}),t[25]=N):N=t[25];let R;t[26]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(xy,{}),t[26]=R):R=t[26];let E;t[27]!==n?(E=s.jsx(b4,{isVisible:n}),t[27]=n,t[28]=E):E=t[28];let X;t[29]!==I||t[30]!==n||t[31]!==E?(X=s.jsx(gy,{isOpen:n,isMobile:I,className:"border-border",topBar:R,children:E}),t[29]=I,t[30]=n,t[31]=E,t[32]=X):X=t[32];let J;t[33]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(hy,{}),t[33]=J):J=t[33];const re=j&&"invisible";let fe;t[34]!==re?(fe=Oe("absolute inset-0",re),t[34]=re,t[35]=fe):fe=t[35];const ne=!i&&!j;let te;t[36]!==ne?(te=s.jsx(As,{children:s.jsx(Hd,{active:ne})}),t[36]=ne,t[37]=te):te=t[37];let ue;t[38]!==fe||t[39]!==te?(ue=s.jsx("div",{className:fe,children:te}),t[38]=fe,t[39]=te,t[40]=ue):ue=t[40];let Se;t[41]!==h||t[42]!==x||t[43]!==f?(Se=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(As,{children:s.jsx(pC,{isWindowed:!0,initialPrompt:x,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[41]=h,t[42]=x,t[43]=f,t[44]=Se):Se=t[44];let we;t[45]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx(As,{children:s.jsx(G4,{})}),t[45]=we):we=t[45];let ye;t[46]===Symbol.for("react.memo_cache_sentinel")?(ye=s.jsx(As,{children:s.jsx(q4,{})}),t[46]=ye):ye=t[46];let Ae;t[47]===Symbol.for("react.memo_cache_sentinel")?(Ae=s.jsx(As,{children:s.jsx(rC,{})}),t[47]=Ae):Ae=t[47];let pe;t[48]!==S?(pe=S&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(As,{children:s.jsx(ob,{mode:`plugin:${S.id}`,surface:"page",item:null,onDismiss:YC})})}),t[48]=S,t[49]=pe):pe=t[49];let O;t[50]!==ue||t[51]!==Se||t[52]!==pe?(O=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[ue,Se,we,ye,Ae,pe]}),t[50]=ue,t[51]=Se,t[52]=pe,t[53]=O):O=t[53];let Q;t[54]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(lS,{}),t[54]=Q):Q=t[54];let le;t[55]!==O?(le=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[O,Q]})})}),t[55]=O,t[56]=le):le=t[56];let H;t[57]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(As,{children:s.jsx(bS,{})})}),t[57]=H):H=t[57];let me;t[58]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(As,{children:s.jsx(Tx,{})}),t[58]=me):me=t[58];let ge;t[59]!==le?(ge=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[J,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[le,H,me]})]}),t[59]=le,t[60]=ge):ge=t[60];let oe;t[61]!==X||t[62]!==ge?(oe=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[X,ge]}),t[61]=X,t[62]=ge,t[63]=oe):oe=t[63];let de;t[64]!==i||t[65]!==o||t[66]!==l?(de=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(IC,{open:i,onOpenChange:o})}):null,t[64]=i,t[65]=o,t[66]=l,t[67]=de):de=t[67];let _;return t[68]!==W||t[69]!==oe||t[70]!==de?(_=s.jsx(Vh,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[L,$,K,F,W,N,oe,de]})}),t[68]=W,t[69]=oe,t[70]=de,t[71]=_):_=t[71],_};function EC(t){return t.isSidebarOpen}function RC(t){return t.setIsMobile}function MC(t){return t.isSettingsDialogOpen}function OC(t){return t.setSettingsDialogOpen}function BC(t){return t.isMultiRunLauncherOpen}function FC(t){return t.setMultiRunLauncherOpen}function _C(t){return t.multiRunLauncherPrefillPrompt}function LC(t){return t.isScheduledTasksDialogOpen}function $C(t){return t.isArchivePageOpen}function zC(t){return t.worktreesPageProjectId}function WC(t){return t.openGuestPageId}function KC(){return Pe.getState().setOpenGuestPage(null)}function VC(){return Qr(KC)}function UC(){return Pe.getState().closeMainSurfaces()}function HC(){const t=UC,e=tt.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function GC(){return rf(!1)}function qC(){return rf(!0)}function YC(){return Pe.getState().setOpenGuestPage(null)}const tm=12,QC=[{id:"left",x:22,y:58,delay:0,radius:120,colorVar:"--status-success"},{id:"center",x:50,y:42,delay:120,radius:150,colorVar:"--primary-base"},{id:"right",x:78,y:55,delay:200,radius:130,colorVar:"--status-info"}],XC=t=>{const e=Ze.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,h=l===void 0?QC:l,f=mt.useRef(!1);let x,b;e[0]!==n||e[1]!==a?(x=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},b=[n,a],e[0]=n,e[1]=a,e[2]=x,e[3]=b):(x=e[2],b=e[3]),mt.useEffect(x,b);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w=Array.from({length:tm},JC),e[4]=w):w=e[4];const v=w;if(!n)return null;let y;e[5]!==i?(y=Oe("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=y):y=e[6];let m;if(e[7]!==d||e[8]!==h||e[9]!==u){let S;e[11]!==d||e[12]!==u?(S=g=>{const C={"--burst-delay":`${g.delay}ms`,"--burst-x":`${g.x}%`,"--burst-y":`${g.y}%`,"--firework-color":`var(${g.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:C,children:v.map((k,j)=>{const D=k.x*g.radius,I=k.y*g.radius,A={"--translate-x":`${D}px`,"--translate-y":`${I}px`,"--particle-delay":`${k.delay}ms`,color:`var(${g.colorVar})`};return s.jsx("span",{className:"firework-particle",style:A},`${g.id}-${j}-${d}`)})},`${g.id}-${d}`)},e[11]=d,e[12]=u,e[13]=S):S=e[13],m=h.map(S),e[7]=d,e[8]=h,e[9]=u,e[10]=m}else m=e[10];let p;return e[14]!==d||e[15]!==y||e[16]!==m?(p=s.jsx("div",{className:y,"aria-hidden":"true","data-burst-key":d,children:m}),e[14]=d,e[15]=y,e[16]=m,e[17]=p):p=e[17],p};function JC(t,e){const n=Math.PI*2*e/tm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const ZC=t=>{const e=Ze.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=mt.useState(o),d=mt.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const h=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{h(),a(e5)},e[4]=f):f=e[4];const x=f;let b;e[5]!==i?(b=()=>{h(),a(t5),d.current=window.setTimeout(()=>{a(s5),d.current=null},i)},e[5]=i,e[6]=b):b=e[6];const w=b;let v,y;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>h(),y=[h],e[7]=v,e[8]=y):(v=e[7],y=e[8]),mt.useEffect(v,y);let m;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==w?(m={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:w,dismissFireworks:x},e[9]=l.cycle,e[10]=l.isActive,e[11]=w,e[12]=m):m=e[12],m};function e5(t){return t.isActive?{...t,isActive:!1}:t}function t5(t){return{isActive:!0,cycle:t.cycle+1}}function s5(t){return t.isActive?{...t,isActive:!1}:t}const sm=c.createContext(void 0),n5=t=>{const e=Ze.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=ZC();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(XC,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let h;return e[6]!==n||e[7]!==u||e[8]!==d?(h=s.jsxs(sm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=h):h=e[9],h},GN=()=>{const t=c.useContext(sm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},ga="openchamber_requests_in_flight",nm=1e3,r5=300*1e3,Ko=Math.ceil(r5/nm),o5=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ga)==="1"}catch{return!1}},rm=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let i5=1;const a5=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},l5=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},om=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},Sr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},c5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=i5++;a5(o,Date.now());try{return await e(r,i)}finally{l5(o)}};window.fetch=n},gd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Mr=t=>{t.length>Ko&&t.splice(0,t.length-Ko)},d5=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=om(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(Sr(e,50)),t.p90Samples.push(Sr(e,90)),t.p99Samples.push(Sr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Mr(t.samples),Mr(t.p50Samples),Mr(t.p90Samples),Mr(t.p99Samples),Mr(t.maxSamples),t.lastSampleAt=Date.now()},u5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(d5,nm))},xd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},bd=t=>{if(!(typeof window>"u"))try{if(t){xd(),gd(),window.localStorage.setItem(ga,"1"),window.__openchamberRequestsInFlight__=rm(),c5(),u5();return}window.localStorage.removeItem(ga),xd(),gd(),delete window.__openchamberRequestsInFlight__}catch{}},f5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=rm();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},xa=()=>{if(typeof window>"u")return yd();const t=window.__openchamberRequestsInFlight__;if(!o5()||!t)return yd();const e=om(t);return{enabled:!0,startedAt:t.startedAt,durationMs:Math.max(0,Date.now()-t.startedAt),inFlight:t.inFlight,peak:t.peak,totalStarted:t.totalStarted,totalSettled:t.totalSettled,samples:t.samples.slice(),ageP50:Sr(e,50),ageP90:Sr(e,90),ageP99:Sr(e,99),ageMax:e.length>0?e[e.length-1]:0,peakAgeMs:t.peakAgeMs,p50Samples:t.p50Samples.slice(),p90Samples:t.p90Samples.slice(),p99Samples:t.p99Samples.slice(),maxSamples:t.maxSamples.slice(),sampleCount:t.sampleCount,lastSampleAt:t.lastSampleAt,windowSeconds:Ko}},yd=()=>({enabled:!1,startedAt:null,durationMs:0,inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],ageP50:0,ageP90:0,ageP99:0,ageMax:0,peakAgeMs:0,p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],sampleCount:0,lastSampleAt:null,windowSeconds:Ko});function m5(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const im=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},ba=t=>`${(t/1e3).toFixed(2)} s`,bs=t=>{const e=Ze.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},wd=t=>{const e=Ze.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=jt();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(g5,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let h;e[10]!==n?(h=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=h):h=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?im(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let x;e[16]!==f?(x=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=x):x=e[17];let b;e[18]!==h||e[19]!==x?(b=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,x]}),e[18]=h,e[19]=x,e[20]=b):b=e[20];let w;e[21]!==o?(w=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=w):w=e[22];let v;e[23]!==r.entries.length||e[24]!==w?(v=s.jsx(bs,{label:w,value:r.entries.length}),e[23]=r.entries.length,e[24]=w,e[25]=v):v=e[25];let y;e[26]!==o?(y=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=y):y=e[27];let m;e[28]!==y||e[29]!==u?(m=s.jsx(bs,{label:y,value:u}),e[28]=y,e[29]=u,e[30]=m):m=e[30];let p;e[31]!==o?(p=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=p):p=e[32];let S;e[33]!==r.lastUpdatedAt||e[34]!==o?(S=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=S):S=e[35];let g;e[36]!==p||e[37]!==S?(g=s.jsx(bs,{label:p,value:S}),e[36]=p,e[37]=S,e[38]=g):g=e[38];let C;e[39]!==m||e[40]!==g||e[41]!==v?(C=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[v,m,g]}),e[39]=m,e[40]=g,e[41]=v,e[42]=C):C=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[b,C,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(yn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(k=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:k.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:k.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:k.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:k.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:k.total})})]})]},k.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},vd=t=>{const e=Ze.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(x5,0),u=r>0?52/r:0;let h;e[0]!==d||e[1]!==a?(h=g=>a-d+g,e[0]=d,e[1]=a,e[2]=h):h=e[2];const f=h;let x;e[3]!==u?(x=g=>56-g*u,e[3]=u,e[4]=x):x=e[4];const b=x;let w;e[5]!==l?(w=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=w):w=e[6];const v=`0 0 ${a} 56`;let y;e[7]!==a?(y=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=y):y=e[8];let m;if(e[9]!==n||e[10]!==f||e[11]!==b){let g;e[13]!==f||e[14]!==b?(g=(C,k)=>{const j=C.samples.length;if(j===0)return null;const D=C.samples.map((A,P)=>`${f(P)},${b(A).toFixed(2)}`),I=`M ${D.join(" L ")}`;return s.jsxs(c.Fragment,{children:[C.filled?s.jsx("path",{d:`M ${f(0)},56 L ${D.join(" L ")} L ${f(j-1)},56 Z`,fill:`color-mix(in srgb, ${C.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:I,fill:"none",stroke:C.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},k)},e[13]=f,e[14]=b,e[15]=g):g=e[15],m=n.map(g),e[9]=n,e[10]=f,e[11]=b,e[12]=m}else m=e[12];let p;e[16]!==o||e[17]!==v||e[18]!==y||e[19]!==m?(p=s.jsxs("svg",{viewBox:v,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[y,m]}),e[16]=o,e[17]=v,e[18]=y,e[19]=m,e[20]=p):p=e[20];let S;return e[21]!==w||e[22]!==p?(S=s.jsxs("div",{className:"relative w-full",children:[w,p]}),e[21]=w,e[22]=p,e[23]=S):S=e[23],S},h5=t=>{const e=Ze.c(100),{onClose:n}=t,{t:r}=jt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=tt(b5),u=Eu(y5),h=bu(),f=Gg(w5),x=Hs(v5),[b,w]=c.useState(S5),[v,y]=c.useState(j5),[m,p]=c.useState(k5),S=[{label:"p50",current:m.ageP50,samples:m.p50Samples,color:"var(--status-success)"},{label:"p90",current:m.ageP90,samples:m.p90Samples,color:"var(--status-info)"},{label:"p99",current:m.ageP99,samples:m.p99Samples,color:"var(--status-warning)"},{label:"max",current:m.ageMax,samples:m.maxSamples,color:"var(--status-error)"}];let g;e[0]!==m.samples?(g=m.samples.reduce(C5,0),e[0]=m.samples,e[1]=g):g=e[1];const C=g,k=S.reduce(A5,0);let j;e[2]!==b.entries?(j=new Map,b.entries.forEach(Fe=>{j.set(Fe.metric,Fe.count)}),e[2]=b.entries,e[3]=j):j=e[3];let D;e[4]!==j?(D=j.get("ui.message_list.render")??0,e[4]=j,e[5]=D):D=e[5];let I;e[6]!==j?(I=j.get("ui.message_list.render.streaming")??0,e[6]=j,e[7]=I):I=e[7];let A;e[8]!==j?(A=j.get("ui.chat_message.render")??0,e[8]=j,e[9]=A):A=e[9];let P;e[10]!==j?(P=j.get("ui.chat_message.render.streaming")??0,e[10]=j,e[11]=P):P=e[11];let T;e[12]!==j?(T=j.get("ui.chat_message.render.static_during_stream")??0,e[12]=j,e[13]=T):T=e[13];let L;e[14]!==j?(L=j.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=j,e[15]=L):L=e[15];let $;e[16]!==D||e[17]!==I||e[18]!==A||e[19]!==P||e[20]!==T||e[21]!==L?($={messageListRender:D,messageListRenderStreaming:I,chatMessageRender:A,chatMessageRenderStreaming:P,chatMessageRenderStaticDuringStream:T,chatMessageRenderStaticOutsideActiveTurnDuringStream:L},e[16]=D,e[17]=I,e[18]=A,e[19]=P,e[20]=T,e[21]=L,e[22]=$):$=e[22];const K=$;let F,W;e[23]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{const Fe=()=>{w(bo()),y(yo()),p(xa())};Fe();const _e=window.setInterval(Fe,500);return()=>window.clearInterval(_e)},F=[],e[23]=F,e[24]=W):(F=e[23],W=e[24]),c.useEffect(W,F);let N,R;e[25]!==l?(N=()=>{if(l==="idle")return;const Fe=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Fe)},R=[l],e[25]=l,e[26]=N,e[27]=R):(N=e[26],R=e[27]),c.useEffect(N,R);let E=0,X=0,J=0;for(const Fe of Object.keys(f)){const _e=f[Fe]??[];X=X+_e.length;for(const rt of _e)rt.role==="user"?J=J+1:rt.role==="assistant"&&(E=E+1)}let re;e[28]!==E||e[29]!==X||e[30]!==J?(re={assistant:E,total:X,user:J},e[28]=E,e[29]=X,e[30]=J,e[31]=re):re=e[31];const fe=re;let ne;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==h||e[36]!==r){let Fe;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?(Fe=_e=>{const rt=f[_e.id]??[];let ct=0,et=0;for(const kt of rt)kt.role==="user"?et=et+1:kt.role==="assistant"&&(ct=ct+1);const pt=u.get(_e.id);return{id:_e.id,title:_e.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ct,messageCount:rt.length,userMessageCount:et,isStreaming:pt?.isStreaming||!1,isZombie:pt?.isZombie||!1,backgroundCount:pt?.backgroundMessageCount||0,lastAccessed:pt?.lastAccessedAt||0,isCurrent:_e.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=Fe):Fe=e[42],ne=h.map(Fe).sort(D5),e[32]=d,e[33]=f,e[34]=u,e[35]=h,e[36]=r,e[37]=ne}else ne=e[37];const te=ne;let ue;e[43]!==f?(ue=Object.keys(f),e[43]=f,e[44]=ue):ue=e[44];const Se=ue.length;let we;e[45]===Symbol.for("react.memo_cache_sentinel")?(we=async()=>{try{const Fe={generatedAt:new Date().toISOString(),ui:bo(),vscode:yo()};await navigator.clipboard.writeText(JSON.stringify(Fe,null,2)),a("copied")}catch{a("error")}},e[45]=we):we=e[45];const ye=we,Ae=Yg,pe="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let O;e[46]===Symbol.for("react.memo_cache_sentinel")?(O={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=O):O=e[46];let Q;e[47]!==i?(Q=m5(i),e[47]=i,e[48]=Q):Q=e[48];let le;e[49]!==Q?(le=s.jsx(M,{name:Q,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=Q,e[50]=le):le=e[50];let H;e[51]!==r?(H=r("memoryDebugPanel.title"),e[51]=r,e[52]=H):H=e[52];let me;e[53]!==H?(me=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:H}),e[53]=H,e[54]=me):me=e[54];let ge;e[55]!==le||e[56]!==me?(ge=s.jsxs("div",{className:"flex items-center gap-2",children:[le,me]}),e[55]=le,e[56]=me,e[57]=ge):ge=e[57];let oe;e[58]!==i?(oe=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(dt,{size:"xs",variant:"ghost",onClick:ye,children:s.jsx(M,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(dt,{size:"xs",variant:"ghost",onClick:()=>{eh(),w(bo()),y(yo())},children:s.jsx(M,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=oe):oe=e[59];let de;e[60]!==i?(de=i==="requests"?s.jsx(dt,{size:"xs",variant:"ghost",onClick:()=>{f5(),p(xa())},children:s.jsx(M,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=de):de=e[61];let _;e[62]!==n?(_=n?s.jsx(dt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(M,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=_):_=e[63];let B;e[64]!==oe||e[65]!==de||e[66]!==_?(B=s.jsxs("div",{className:"flex items-center gap-1",children:[oe,de,_]}),e[64]=oe,e[65]=de,e[66]=_,e[67]=B):B=e[67];let he;e[68]!==ge||e[69]!==B?(he=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[ge,B]}),e[68]=ge,e[69]=B,e[70]=he):he=e[70];let ve;e[71]===Symbol.for("react.memo_cache_sentinel")?(ve={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=ve):ve=e[71];const Re=i==="memory"?"secondary":"ghost";let ce;e[72]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>o("memory"),e[72]=ce):ce=e[72];let se;e[73]!==r?(se=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=se):se=e[74];let q;e[75]!==Re||e[76]!==se?(q=s.jsx(dt,{size:"sm",variant:Re,className:"flex-1",onClick:ce,children:se}),e[75]=Re,e[76]=se,e[77]=q):q=e[77];const z=i==="streaming"?"secondary":"ghost";let ee;e[78]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>o("streaming"),e[78]=ee):ee=e[78];let ae;e[79]!==r?(ae=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=ae):ae=e[80];let Ne;e[81]!==z||e[82]!==ae?(Ne=s.jsx(dt,{size:"sm",variant:z,className:"flex-1",onClick:ee,children:ae}),e[81]=z,e[82]=ae,e[83]=Ne):Ne=e[83];const Ce=i==="requests"?"secondary":"ghost";let We;e[84]===Symbol.for("react.memo_cache_sentinel")?(We=()=>o("requests"),e[84]=We):We=e[84];let Ee;e[85]!==r?(Ee=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=Ee):Ee=e[86];let xe;e[87]!==Ce||e[88]!==Ee?(xe=s.jsx(dt,{size:"sm",variant:Ce,className:"flex-1",onClick:We,children:Ee}),e[87]=Ce,e[88]=Ee,e[89]=xe):xe=e[89];let $e;e[90]!==q||e[91]!==Ne||e[92]!==xe?($e=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ve,children:[q,Ne,xe]}),e[90]=q,e[91]=Ne,e[92]=xe,e[93]=$e):$e=e[93];const V=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(bs,{label:r("memoryDebugPanel.metric.totalMessages"),value:fe.total}),s.jsx(bs,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Se} / ${Fl.MAX_SESSIONS}`}),s.jsx(bs,{label:r("memoryDebugPanel.metric.userMessages"),value:fe.user}),s.jsx(bs,{label:r("memoryDebugPanel.metric.assistantMessages"),value:fe.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:qg()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:Fl.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:x})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(yn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:te.map(Fe=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Fe.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Fe.title}),Fe.isStreaming?s.jsx(M,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Fe.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Fe.assistantMessageCount,user:Fe.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Fe.messageCount})}),Fe.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Fe.backgroundCount]}):null]})]},Fe.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(dt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(P5),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:fe,sessionMessageRoleCounts:te.map(I5),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(Dt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(dt,{size:"xs",variant:"outline",onClick:ye,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(bs,{label:r("memoryDebugPanel.metric.uiMetrics"),value:b.entries.length}),s.jsx(bs,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:v.entries.length}),s.jsx(bs,{label:r("memoryDebugPanel.metric.messageListRenders"),value:K.messageListRender}),s.jsx(bs,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:K.messageListRenderStreaming}),s.jsx(bs,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:K.chatMessageRender}),s.jsx(bs,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:K.chatMessageRenderStreaming}),s.jsx(bs,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:K.chatMessageRenderStaticDuringStream}),s.jsx(bs,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:K.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(wd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),v.entries.length>0?s.jsx(wd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:v,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(bs,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${m.totalSettled} / ${m.totalStarted}`}),s.jsx(bs,{label:r("memoryDebugPanel.requests.tracking"),value:m.startedAt?im(m.durationMs):r("memoryDebugPanel.common.idle")})]}),m.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.peak})]})]}),s.jsx(vd,{series:[{samples:m.samples,color:"var(--status-info)",filled:!0}],peak:C,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:m.peak}),maxLabel:`${C}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:ba(m.peakAgeMs)})]}),s.jsx(vd,{series:S.map(T5),peak:k,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:ba(k)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:S.map(E5)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:m.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let De;return e[94]!==Ae||e[95]!==O||e[96]!==he||e[97]!==$e||e[98]!==V?(De=s.jsxs(Ae,{className:pe,style:O,children:[he,$e,V]}),e[94]=Ae,e[95]=O,e[96]=he,e[97]=$e,e[98]=V,e[99]=De):De=e[99],De},p5=h5;function g5(t,e){return t+e.count}function x5(t,e){return Math.max(t,e.samples.length)}function b5(t){return t.currentSessionId}function y5(t){return t.sessionMemoryState}function w5(t){return t.message}function v5(t){return t.totalRequestCount}function S5(){return bo()}function j5(){return yo()}function k5(){return xa()}function C5(t,e){return Math.max(t,e)}function N5(t,e){return Math.max(t,e)}function A5(t,e){return e.samples.reduce(N5,t)}function D5(t,e){return e.lastAccessed-t.lastAccessed}function P5(t){return{id:t.id,title:t.title}}function I5(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function T5(t){return{samples:t.samples,color:t.color}}function E5(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:ba(t.current)})]},t.label)}const R5=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},M5=async()=>{const t=R5()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Sd="openchamber:menu-action",Ci="openchamber:check-for-updates",O5=t=>{const e=tt(m=>m.openNewSessionDraft),n=Pe(m=>m.toggleCommandPalette),r=Pe(m=>m.setCommandPaletteOpen),i=Pe(m=>m.toggleHelpDialog),o=Pe(m=>m.toggleSidebar),l=Pe(m=>m.setSessionSwitcherOpen),a=Pe(m=>m.setSettingsDialogOpen),d=Pe(m=>m.setAboutDialogOpen),u=zr(m=>m.checkForUpdates),{setThemeMode:h}=or(),f=c.useRef(!1),x=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:m,error:p}=zr.getState();if(p){Le.error("Failed to check for updates",{description:p});return}m||Le.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),b=c.useCallback(()=>{fn.requestDirectoryDialog()},[]),w=c.useCallback(m=>{const p=Qg();if(p.length===0)return;const S=tt.getState().currentSessionId,g=p.findIndex(j=>j.id===S);let C=m>0?0:p.length-1;g>=0&&(C=(g+m+p.length)%p.length);const k=p[C];k&&(l(!1),tt.getState().setCurrentSession(k.id))},[l]),v=c.useCallback(m=>{const{activeProjectId:p,projects:S,setActiveProject:g}=Ht.getState();if(S.length===0)return;const C=S.findIndex(D=>D.id===p);let k=m>0?0:S.length-1;C>=0&&(k=(C+m+S.length)%S.length);const j=S[k];j&&g(j.id)},[]),y=c.useCallback(m=>{switch(m){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const p=tt.getState(),S=ns.getState().currentDirectory;e(p.currentSessionId&&S?{directoryOverride:S}:void 0)}break;case"new-worktree-session":l(!1),ju();break;case"change-workspace":b();break;case"toggle-right-sidebar":{const p=ns.getState().currentDirectory;if(!p)break;const S=Pe.getState(),g=cr(p),C=S.contextPanelByDirectory[g];C?.isOpen?S.closeContextPanel(g):C?.activeTabId?S.setActiveContextPanelTab(g,C.activeTabId):S.openContextSurface(g,"git");break}case"open-right-sidebar-git":{const p=ns.getState().currentDirectory;if(!p)break;Pe.getState().openContextSurface(cr(p),"git");break}case"open-right-sidebar-files":{const p=ns.getState().currentDirectory;if(!p)break;Pe.getState().openContextSurface(cr(p),"file");break}case"toggle-terminal":{const p=ns.getState().currentDirectory;if(!p)break;Pe.getState().openContextSurface(cr(p),"terminal");break}case"toggle-terminal-expanded":{const p=ns.getState().currentDirectory;if(!p)break;const S=cr(p),g=Pe.getState(),C=g.contextPanelByDirectory[S];(C?.isOpen?C.tabs.find(j=>j.id===C.activeTabId)?.mode:null)!=="terminal"&&g.openContextSurface(S,"terminal"),g.toggleContextPanelExpanded(S);break}case"copy":{const p=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(p)||M5();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":Xg();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":ns.getState().goBack();break;case"go-forward":ns.getState().goForward();break;case"previous-session":w(-1);break;case"next-session":w(1);break;case"previous-project":v(-1);break;case"next-project":v(1);break;case"help-dialog":i();break;case"download-logs":{ku().catch(()=>{Le.error("Failed to collect OpenCode status")});break}}},[b,v,w,t,e,d,l,r,a,h,n,i,o]);c.useEffect(()=>{const m=S=>{const g=S.detail;g&&y(g)},p=()=>{x()};return window.addEventListener(Sd,m),window.addEventListener(Ci,p),()=>{window.removeEventListener(Sd,m),window.removeEventListener(Ci,p)}},[y,x]),c.useEffect(()=>{if(typeof window>"u")return;const p=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof p!="function")return;let S=null,g=null;return p("openchamber:menu-action",C=>{const k=C?.payload;typeof k=="string"&&y(k)}).then(C=>{S=C}).catch(()=>{}),p("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Ci))}).then(C=>{g=C}).catch(()=>{}),()=>{(async()=>{try{const k=S?.();k instanceof Promise&&await k}catch{}try{const k=g?.();k instanceof Promise&&await k}catch{}})()}},[y])},B5="openchamber:tray-action",F5=5e3,_5=500,L5=20,jd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},kd=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,am=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},lm=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},$5=(t,e)=>Fa(t,e,Gr.getState().ids,Ta.getState().rankById),z5=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},W5=(t,e,n,r,i)=>{if(!t)return"";const o=qd(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||z5(t),d=vo(t);let u=d&&i.get(d)||"";if(!u){for(const[h,f]of Tn.getState().directories)if(vo(h)===d){u=f.status?.current??"";break}}if(!u)for(const h of r.values()){const f=h.find(x=>vo(x.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},K5=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ur.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of Zg){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const x=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:tx(h),value:ex(f.valueLabel,x)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},V5=async()=>{try{if(Vo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Pn();if(e&&dl(e,t))return"Local OpenChamber";const r=(await Td()).hosts.find(i=>e?dl(e,th(i)):!1);return r?.label?.trim()?Ed(r.label.trim()):"Instance"}catch{return""}},U5=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Ui()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(vo(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const h=u?.type,f=h==="busy"?"busy":h==="retry"?"retry":"idle",x=t.get(d);(!x||x==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"permission",id:h.id,sessionId:f,sessionTitle:"",label:am(h),directory:o})}for(const[d,u]of Object.entries(a.question??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"question",id:h.id,sessionId:f,sessionTitle:"",label:lm(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},H5=(t,e)=>{const n=Ma.getState().index.session,r=$s.getState().activeSessions,i=new Map;for(const p of r)if(p?.id&&p.parentID){const S=i.get(p.parentID)??[];S.push(p.id),i.set(p.parentID,S)}const o=p=>{const S=[],g=[...i.get(p)??[]],C=new Set;for(;g.length;){const k=g.pop();C.has(k)||(C.add(k),S.push(k),g.push(...i.get(k)??[]))}return S},l=Pe.getState();let a=0;if(l.dockBadgeEnabled)for(const p of r){if(!p?.id||p.parentID)continue;let S=n.unseenCount[p.id]??0;S===0&&l.notifyOnSubtasks&&(S=o(p.id).reduce((g,C)=>g+(n.unseenCount[C]??0),0)),S>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=U5(),u=new Map(d.titleById);for(const p of r)p?.id&&p.title&&u.set(p.id,p.title);const h=qo.getState().statusById,f=p=>{const S=d.statusById.get(p);return S&&S!=="idle"?S:h.get(p)?.status.type??S??"idle"},x=p=>{const S=p.map(g=>f(g));return S.includes("busy")?"busy":S.includes("retry")?"retry":"idle"},b=Ht.getState().projects,w=tt.getState().availableWorktreesByProject,v=r.filter(p=>p?.id&&!p.parentID).slice().sort($5).slice(0,L5).map(p=>{const S=[p.id,...o(p.id)],g=Ds(p)??"";return{id:p.id,title:p.title||"Untitled session",status:x(S),branch:g?d.branchByDirectory.get(g)??"":"",unseen:S.reduce((C,k)=>C+(n.unseenCount[k]??0),0),hasError:S.some(C=>n.unseenHasError[C]??!1),directory:g,subtitle:W5(g,p,b,w,d.branchByDirectory)}}),y=d.approvals.map(p=>({...p,sessionTitle:u.get(p.sessionId)||""})),m=new Set(y.map(p=>p.id));for(const[p,S]of Oa.getState().bySession){const g=u.get(p)||"";for(const C of S.permissions)m.has(C.id)||(m.add(C.id),y.push({kind:"permission",id:C.id,sessionId:p,sessionTitle:g,label:am(C),directory:S.directory}));for(const C of S.questions)m.has(C.id)||(m.add(C.id),y.push({kind:"question",id:C.id,sessionId:p,sessionTitle:g,label:lm(C),directory:S.directory}))}return{sessions:v,approvals:y,instanceName:t,usage:K5(),dockBadgeCount:a}},G5=()=>{c.useEffect(()=>{if(!jd()||!Ur())return;const t=kd();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const j=H5(i,t),D=JSON.stringify(j);D!==n&&(n=D,_n("desktop_tray_update",j))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},_5))},a=Ma.subscribe(()=>l()),d=$s.subscribe(()=>l()),u=Pe.subscribe((j,D)=>{(j.dockBadgeEnabled!==D.dockBadgeEnabled||j.notifyOnSubtasks!==D.notifyOnSubtasks)&&l()}),h=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),h;V5().then(j=>{e||(i=j,o())});const f=new Map,x=()=>{if(e)return;let j;try{j=Ui()}catch{return}const D=new Set;for(const[I,A]of j.children.entries())D.add(I),f.has(I)||f.set(I,A.subscribe(()=>l()));for(const[I,A]of f)D.has(I)||(A(),f.delete(I))};let b=null;try{b=Ui().subscribeRegistry(()=>{x(),l()})}catch{}x();const w=Ht.subscribe(()=>l()),v=tt.subscribe(()=>l()),y=Tn.subscribe(()=>l()),m=qo.subscribe(()=>l()),p=Oa.subscribe(()=>l()),S=Ta.subscribe(()=>l()),g=Gr.subscribe(()=>l()),C=ur.subscribe(()=>l());ur.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:j,results:D}=ur.getState();j.length>0&&j.some(A=>!D.some(P=>P.providerId===A))&&ur.getState().fetchQuotas(j)});const k=window.setInterval(()=>{x(),o()},F5);return o(),()=>{h(),window.clearInterval(k),w(),v(),y(),m(),p(),S(),g(),C(),b?.();for(const j of f.values())j();f.clear()}},[]),c.useEffect(()=>{if(!jd()||!kd()||!Ur())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&Jg(i.sessionId,i.id,i.response).catch(()=>{Le.error("Failed to respond to permission request")})};let r=null;return e(B5,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},q5=30*6e4,Y5=(t,e,n=q5)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>n||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({id:`host-seed:${i}`,type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let Or=null;const cm=()=>{if(Or)return Or;const t=qt();return Or=(async()=>{const e=await Cn.getHostSessionStatusSnapshot();if(!e||qt()!==t)return;const n=qo.getState(),r=$s.getState().entityById,i=Y5(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?Ds(a):null}});for(const[l,a]of i)sx(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?Ds(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,questions:a.questions})}nx(o)})().finally(()=>{Or=null}),Or},Q5=45e3,X5=(t,e,n=window.setInterval.bind(window),r=window.clearInterval.bind(window))=>{t();const i=n(e,Q5);return()=>r(i)},J5=t=>{const e=Ze.c(3);let n,r;e[0]!==t?(n=()=>{if(t)return X5(eN,sN)},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function Z5(){return cm()}function eN(){rx(To()).finally(Z5)}function tN(){return cm()}function sN(){za().finally(tN)}const nN="/api/notifications/stream",rN=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),oN=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="openchamber:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},iN=t=>{const e=Ze.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!n||xn()||!wa()||typeof window>"u"||typeof EventSource>"u")return;const o=new EventSource(ya().sse(nN));return o.onmessage=aN,()=>{o.close()}},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function aN(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Pe.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&rN())return;const r=oN(e);if(!r)return;Id()?.notifications?.notifyAgentCompletion(r)}const lN=6e4,cN=t=>{const e=Ze.c(10),n=Pe(dN),r=ox(uN),o=Uh(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:lN})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let d,u;e[5]!==n||e[6]!==r||e[7]!==o?(d=()=>{if(n)return eo(h=>{h.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function dN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function uN(t){return t.load}const Cd="pwa-install-toast-shown",Nd="pwa-install-toast-dismissed",fN=()=>{const t=Ze.c(6),{browserTab:e}=Hh(),{t:n}=jt(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!wa()||!e)return;let d=null,u=null;const h=()=>{u!==null&&(Le.dismiss(u),u=null)},f=async()=>{if(!d)return;const w=d;d=null,h(),await w.prompt();const{outcome:v}=await w.userChoice;v==="accepted"&&Le.success(r.current("pwa.installPrompt.started"))},x=w=>{const v=w;if(typeof v.prompt!="function")return;v.preventDefault(),d=v;const y=Do(),m=sh();Gh({dismissed:y.getItem(Nd),sessionShown:m.getItem(Cd),hasActiveToast:u!==null})&&(m.setItem(Cd,"true"),u=Le.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Do().setItem(Nd,"true"),h()}}}))},b=()=>{d=null,h(),Le.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",x),window.addEventListener("appinstalled",b),()=>{h(),window.removeEventListener("beforeinstallprompt",x),window.removeEventListener("appinstalled",b)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},mN=({open:t,onOpenChange:e})=>{const{t:n}=jt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[h,f]=c.useState(!1),[x,b]=c.useState(null),[w,v]=c.useState(!1);c.useCallback(async()=>{},[x,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const p=await ls("/api/system/info");if(p.ok){const S=await p.json();if(typeof S.openchamberVersion=="string"&&S.openchamberVersion.trim()){o(S.openchamberVersion);return}}}catch{}o(await ix())})()},[t]),c.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const S=await ls("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!S.ok)return;const g=await S.json().catch(()=>null),C=typeof g?.currentVersion=="string"?g.currentVersion.trim():"";!m&&C&&a(C)}catch{}})(),()=>{m=!0}},[t]),c.useEffect(()=>{{b(null),v(!1);return}},[t,r]);const y=i;return s.jsx(ys,{open:t,onOpenChange:e,children:s.jsx(ws,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(yu,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[y&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:y})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(M,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(M,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(M,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Ad=t=>{if(!(typeof window>"u")){if(t){window.location.href="openchamber://focus/mcp-auth";return}window.location.replace("/")}},Ni=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},hN=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to OpenChamber and click Authorize again.":n},pN=()=>{const t=ax(a=>a.completeAuth),[e,n]=c.useState("working"),[r,i]=c.useState(!1),[o,l]=c.useState("Completing MCP authorization...");return c.useEffect(()=>{if(typeof window>"u"){n("error"),l("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),d=Ni(a,"code"),u=lx(a),h=cx(a),f=Ni(a,"error"),x=Ni(a,"error_description");if(f){h&&ls(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(x??f);return}(async()=>{try{if(!d)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");let b=u,w=!1;if(h){const v=await ls(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(v.ok){const y=await v.json().catch(()=>null);w=y?.origin===dx,i(w),!b&&y?.name?.trim()&&(b={name:y.name.trim(),directory:typeof y.directory=="string"&&y.directory.trim()?y.directory.trim():null})}}if(!b?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");await t(b.name,d,b.directory),h&&await ls(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),w&&Ad(!0),l("Authorization completed. You can close this tab and return to OpenChamber.")}catch(b){h&&await ls(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(hN(b,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("h1",{className:ux,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:Oe("typography-body",e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]"),children:o})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx(dt,{type:"button",onClick:()=>Ad(r),children:"Return to OpenChamber"})})]})})},Dd=Wn(()=>En(()=>import("./OnboardingScreen-Dyxxiqdt.js"),__vite__mapDeps([150,1,2,4,5,6,7,8,9,3,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])).then(t=>({default:t.OnboardingScreen}))),gN=()=>{const t=Ze.c(3),e=Pe(SN),n=Pe(jN);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(mN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},xN=t=>{const e=Ze.c(21),{onRetry:n,isRetrying:r}=t,{t:i}=jt();let o;e[0]!==i?(o=i("startup.initRecovery.title"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=s.jsx("h1",{className:"typography-title text-foreground",children:o}),e[2]=o,e[3]=l):l=e[3];let a;e[4]!==i?(a=i("startup.initRecovery.description"),e[4]=i,e[5]=a):a=e[5];let d;e[6]!==a?(d=s.jsx("p",{className:"typography-body text-muted-foreground",children:a}),e[6]=a,e[7]=d):d=e[7];let u;e[8]!==l||e[9]!==d?(u=s.jsxs("div",{className:"flex flex-col gap-2",children:[l,d]}),e[8]=l,e[9]=d,e[10]=u):u=e[10];let h;e[11]!==r||e[12]!==i?(h=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=i,e[13]=h):h=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==h?(f=s.jsx(dt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=f):f=e[17];let x;return e[18]!==u||e[19]!==f?(x=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[u,f]})}),e[18]=u,e[19]=f,e[20]=x):x=e[20],x},Pd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",bN=()=>{if(typeof window>"u"||!rb())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},yN=()=>typeof window>"u"?!1:window.location.pathname===xx,wN=t=>{const e=Ze.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=ns(kN),l=tt(CN),a=tt(NN),d=ru(),u=c.useRef(null);let h;e[0]!==n.directory?(h=Pd(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let x;e[2]!==o?(x=Pd(o),e[2]=o,e[3]=x):x=e[3];const b=x;let w,v;if(e[4]!==b||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(w=()=>{if(r||f&&b!==f)return;const C=`${f}
|
|
895
|
+
`)?(f($e),u(!0)):u(!1);return}u(!1)},e[12]=$):$=e[12];const K=$;let F;e[13]!==n.id||e[14]!==o?(F=ae=>{o(n.id,{prompt:ae})},e[13]=n.id,e[14]=o,e[15]=F):F=e[15];const W=F;let N;e[16]!==n.prompt||e[17]!==W?(N=ae=>{const Ne=n.prompt,We=g.current?.selectionStart??Ne.length,xe=Ne.substring(0,We).lastIndexOf("@"),$e=ae.relativePath&&ae.relativePath.trim().length>0?ae.relativePath.trim():ae.path||ae.name,V=xe!==-1?xe:We,De=`${Ne.substring(0,V)}@${$e} ${Ne.substring(We)}`,Fe=V+$e.length+2;W(De),u(!1),f(""),requestAnimationFrame(()=>{const _e=g.current;_e&&(_e.selectionStart=Fe,_e.selectionEnd=Fe,_e.focus()),K(De,Fe)})},e[16]=n.prompt,e[17]=W,e[18]=N):N=e[18];const R=N;let E;e[19]!==n.prompt||e[20]!==W?(E=ae=>{const Ne=n.prompt,We=g.current?.selectionStart??Ne.length,xe=Ne.substring(0,We).lastIndexOf("@"),$e=xe!==-1?xe:We,V=`${Ne.substring(0,$e)}@${ae} ${Ne.substring(We)}`,De=$e+ae.length+2;W(V),u(!1),f(""),requestAnimationFrame(()=>{const Fe=g.current;Fe&&(Fe.selectionStart=De,Fe.selectionEnd=De,Fe.focus()),K(V,De)})},e[19]=n.prompt,e[20]=W,e[21]=E):E=e[21];const X=E;let J;e[22]!==W?(J=ae=>{const Ne=`/${ae.name} `;W(Ne),b(!1),v(""),m(!1),requestAnimationFrame(()=>{const Ce=g.current;Ce&&(Ce.focus(),Ce.selectionStart=Ce.value.length,Ce.selectionEnd=Ce.value.length),K(Ne,Ne.length)})},e[22]=W,e[23]=J):J=e[23];const re=J;let fe;e[24]!==n.prompt||e[25]!==W?(fe=(ae,Ne)=>{const Ce=n.prompt,Ee=g.current?.selectionStart??Ce.length,$e=Ce.substring(0,Ee).lastIndexOf("#"),V=$e!==-1?$e:Ee,De=`${Ce.substring(0,V)}#${Ne} ${Ce.substring(Ee)}`,Fe=V+Ne.length+2;W(De),m(!1),S(""),requestAnimationFrame(()=>{const _e=g.current;_e&&(_e.selectionStart=Fe,_e.selectionEnd=Fe,_e.focus()),K(De,Fe)})},e[24]=n.prompt,e[25]=W,e[26]=fe):fe=e[26];const ne=fe;let te;e[27]!==x||e[28]!==d||e[29]!==y?(te=ae=>{if(x&&k.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")){ae.preventDefault(),k.current.handleKeyDown(ae.key);return}d&&C.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")&&(ae.preventDefault(),C.current.handleKeyDown(ae.key)),y&&j.current&&(ae.key==="Enter"||ae.key==="ArrowUp"||ae.key==="ArrowDown"||ae.key==="Escape"||ae.key==="Tab")&&(ae.preventDefault(),j.current.handleKeyDown(ae.key))},e[27]=x,e[28]=d,e[29]=y,e[30]=te):te=e[30];const ue=te,Se=r+1;let we;e[31]!==a||e[32]!==Se?(we=a("multirun.launcher.groups.groupLabel",{index:Se}),e[31]=a,e[32]=Se,e[33]=we):we=e[33];let ye;e[34]!==we?(ye=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:we}),e[34]=we,e[35]=ye):ye=e[35];let Ae;e[36]!==i||e[37]!==n.id||e[38]!==l||e[39]!==a?(Ae=i&&s.jsx("button",{type:"button",onClick:()=>l(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":a("multirun.launcher.groups.removeGroup"),children:s.jsx(M,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=i,e[37]=n.id,e[38]=l,e[39]=a,e[40]=Ae):Ae=e[40];let pe;e[41]!==ye||e[42]!==Ae?(pe=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ye,Ae]}),e[41]=ye,e[42]=Ae,e[43]=pe):pe=e[43];let O;e[44]!==a?(O=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=O):O=e[45];let Q;e[46]!==O?(Q=s.jsx(Xn,{required:!0,children:O}),e[46]=O,e[47]=Q):Q=e[47];const le=n.prompt;let H;e[48]!==W?(H=ae=>{const Ne=ae.target.value;W(Ne);const Ce=ae.target.selectionStart??Ne.length;K(Ne,Ce)},e[48]=W,e[49]=H):H=e[49];let me;e[50]!==a?(me=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=me):me=e[51];let ge;e[52]!==n.prompt||e[53]!==ue||e[54]!==H||e[55]!==me?(ge=s.jsx(fr,{ref:g,value:le,onChange:H,onKeyDown:ue,placeholder:me,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=ue,e[54]=H,e[55]=me,e[56]=ge):ge=e[56];let oe;e[57]!==w||e[58]!==re||e[59]!==x?(oe=x?s.jsx(Mu,{ref:k,searchQuery:w,onCommandSelect:re,onClose:()=>b(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=w,e[58]=re,e[59]=x,e[60]=oe):oe=e[60];let de;e[61]!==X||e[62]!==R||e[63]!==h||e[64]!==d?(de=d?s.jsx(Ou,{ref:C,searchQuery:h,onFileSelect:R,onAgentSelect:X,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=X,e[62]=R,e[63]=h,e[64]=d,e[65]=de):de=e[65];let _;e[66]!==ne||e[67]!==y||e[68]!==p?(_=y?s.jsx(Bu,{ref:j,searchQuery:p,onSnippetSelect:ne,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=ne,e[67]=y,e[68]=p,e[69]=_):_=e[69];let B;e[70]!==ge||e[71]!==oe||e[72]!==de||e[73]!==_?(B=s.jsxs("div",{className:"relative",children:[ge,oe,de,_]}),e[70]=ge,e[71]=oe,e[72]=de,e[73]=_,e[74]=B):B=e[74];let he;e[75]!==Q||e[76]!==B?(he=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[Q,B]}),e[75]=Q,e[76]=B,e[77]=he):he=e[77];let ve;e[78]!==a?(ve=a("multirun.launcher.models.info"),e[78]=a,e[79]=ve):ve=e[79];let Re;e[80]!==ve?(Re=s.jsx(Ao,{children:ve}),e[80]=ve,e[81]=Re):Re=e[81];let ce;e[82]!==a?(ce=a("multirun.launcher.models.label"),e[82]=a,e[83]=ce):ce=e[83];let se;e[84]!==Re||e[85]!==ce?(se=s.jsx(Xn,{required:!0,info:Re,children:ce}),e[84]=Re,e[85]=ce,e[86]=se):se=e[86];let q;e[87]!==n.models||e[88]!==I||e[89]!==P||e[90]!==L?(q=s.jsx(Vf,{selectedModels:n.models,onAdd:I,onRemove:P,onUpdate:L,minModels:1}),e[87]=n.models,e[88]=I,e[89]=P,e[90]=L,e[91]=q):q=e[91];let z;e[92]!==se||e[93]!==q?(z=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[se,q]}),e[92]=se,e[93]=q,e[94]=z):z=e[94];let ee;return e[95]!==pe||e[96]!==he||e[97]!==z?(ee=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[pe,he,z]}),e[95]=pe,e[96]=he,e[97]=z,e[98]=ee):ee=e[98],ee};function xC(t){const e=[],n=(r,i)=>{const o=ht(r);!o||e.some(l=>l.directory===o)||e.push({directory:o,priority:"selected",reason:i})};return n(t.currentDirectory,"current-directory"),n(t.currentSessionDirectory,"selected-session"),e}const bC=t=>{const e=new Map;for(const n of t){const r=Ds(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},yC=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,i)=>{e.has(i)||n.push(r)}),n},wC=t=>{const e=Ze.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:i}=t,o=n===void 0?!0:n,l=c.useRef(null);let a,d;e[0]!==o||e[1]!==r||e[2]!==i?(a=()=>{if(!o||!r)return;const u=qt(),h=bC(i),f=l.current?.runtimeKey===u?l.current.identities:null;for(const x of yC(f,h))Hg({runtimeKey:u,...x});l.current={runtimeKey:u,identities:h}},d=[o,r,i],e[0]=o,e[1]=r,e[2]=i,e[3]=a,e[4]=d):(a=e[3],d=e[4]),c.useEffect(a,d)},vC=new Map,SC=t=>{const e=Ze.c(23),{isVSCode:n}=t,r=Yo(),i=Ht(jC),o=ns(kC),l=tt(CC);let a;e[0]!==n?(a=I=>n?vC:I.availableWorktreesByProject,e[0]=n,e[1]=a):a=e[1];const d=tt(a),u=!n;let h;e[2]!==d||e[3]!==i||e[4]!==u?(h=Xf(i,d,{includeWorktrees:u}),e[2]=d,e[3]=i,e[4]=u,e[5]=h):h=e[5];const f=h,x=$s(NC),b=$s(AC),w=$s(DC),v=`session-list-sync:${c.useId()}`;let y,m;e[6]!==v||e[7]!==r||e[8]!==o||e[9]!==l?(y=()=>(r.setBootstrapDemand(v,xC({currentDirectory:o,currentSessionDirectory:l})),()=>r.clearBootstrapDemand(v)),m=[v,r,o,l],e[6]=v,e[7]=r,e[8]=o,e[9]=l,e[10]=y,e[11]=m):(y=e[10],m=e[11]),c.useEffect(y,m);const p=c.useRef(null);let S,g;e[12]!==n||e[13]!==f?(S=()=>{const I=new Set(f),A=p.current;p.current=I;const P=A?[...I].filter(T=>!A.has(T)):n?[...I]:[];P.length&&ka(P,To())},g=[n,f],e[12]=n,e[13]=f,e[14]=S,e[15]=g):(S=e[14],g=e[15]),c.useEffect(S,g);let C;e[16]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[16]=C):C=e[16],c.useEffect(PC,C);let k;e[17]!==b||e[18]!==x?(k=[...x,...b],e[17]=b,e[18]=x,e[19]=k):k=e[19];const j=k;let D;e[20]!==j||e[21]!==w?(D={enabled:!0,hasAuthoritativeGlobalSessions:w,sessions:j},e[20]=j,e[21]=w,e[22]=D):D=e[22],wC(D)};function jC(t){return t.projects}function kC(t){return t.currentDirectory}function CC(t){return t.currentSessionDirectory}function NC(t){return t.activeSessions}function AC(t){return t.archivedSessions}function DC(t){return t.status==="ready"}function PC(){let t=null,e=!1;const n=new Set,r=eo(i=>{if(i.type==="scheduled-task-ran")e=!0;else if(i.type==="session-created")n.add(i.directory);else return;t&&clearTimeout(t),t=setTimeout(()=>{if(t=null,e){e=!1,n.clear(),za(To());return}const o=[...n];n.clear(),o.length&&ka(o,To())},500)});return()=>{t&&clearTimeout(t),r()}}const IC=Wn(()=>En(()=>import("./SettingsWindow-B5CHoJFZ.js"),__vite__mapDeps([144,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,145,84,85,86,146,131,132,133,134,120,121,106,107,91,92,93,94,95,96,97,98,99,100,101,102,103,104,147,148,149])).then(t=>({default:t.SettingsWindow}))),TC=()=>{const t=Ze.c(72);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={isVSCode:!1},t[0]=e):e=t[0],SC(e),Wh();const n=Pe(EC),r=Pe(RC),i=Pe(MC),o=Pe(OC),[l,a]=c.useState(!1);let d,u;t[1]!==i?(d=()=>{i&&a(!0)},u=[i],t[1]=i,t[2]=d,t[3]=u):(d=t[2],u=t[3]),c.useEffect(d,u);const h=Pe(BC),f=Pe(FC),x=Pe(_C),b=Pe(LC),w=Pe($C),v=Pe(zC),y=Pe(WC),m=Cu();let p;if(t[4]!==m||t[5]!==y){let B;t[7]!==y?(B=he=>he.id===y,t[7]=y,t[8]=B):B=t[8],p=m.find(B),t[4]=m,t[5]=y,t[6]=p}else p=t[6];const S=p;let g,C;t[9]!==S||t[10]!==y?(g=()=>{y&&!S&&Pe.getState().setOpenGuestPage(null)},C=[y,S],t[9]=S,t[10]=y,t[11]=g,t[12]=C):(g=t[11],C=t[12]),c.useEffect(g,C);let k;t[13]===Symbol.for("react.memo_cache_sentinel")?(k=[],t[13]=k):k=t[13],c.useEffect(VC,k);const j=b||w||!!v||h||!!S;let D;t[14]===Symbol.for("react.memo_cache_sentinel")?(D=[],t[14]=D):D=t[14],c.useEffect(HC,D);const{isMobile:I}=zn();Kh();const A=ty();let P,T;t[15]!==I||t[16]!==r?(P=()=>{Pe.getState().isMobile!==I&&r(I)},T=[I,r],t[15]=I,t[16]=r,t[17]=P,t[18]=T):(P=t[17],T=t[18]),c.useEffect(P,T);let L,$,K,F;t[19]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx($S,{}),$=s.jsx(F0,{}),K=s.jsx(z0,{}),F=s.jsx(y4,{}),t[19]=L,t[20]=$,t[21]=K,t[22]=F):(L=t[19],$=t[20],K=t[21],F=t[22]);let W;t[23]!==A?(W=s.jsx(w4,{value:A,onMoveSessionOnly:GC,onMoveAllChanges:qC,onCancel:dy}),t[23]=A,t[24]=W):W=t[24];let N;t[25]===Symbol.for("react.memo_cache_sentinel")?(N=s.jsx(by,{}),t[25]=N):N=t[25];let R;t[26]===Symbol.for("react.memo_cache_sentinel")?(R=s.jsx(xy,{}),t[26]=R):R=t[26];let E;t[27]!==n?(E=s.jsx(b4,{isVisible:n}),t[27]=n,t[28]=E):E=t[28];let X;t[29]!==I||t[30]!==n||t[31]!==E?(X=s.jsx(gy,{isOpen:n,isMobile:I,className:"border-border",topBar:R,children:E}),t[29]=I,t[30]=n,t[31]=E,t[32]=X):X=t[32];let J;t[33]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(hy,{}),t[33]=J):J=t[33];const re=j&&"invisible";let fe;t[34]!==re?(fe=Oe("absolute inset-0",re),t[34]=re,t[35]=fe):fe=t[35];const ne=!i&&!j;let te;t[36]!==ne?(te=s.jsx(As,{children:s.jsx(Hd,{active:ne})}),t[36]=ne,t[37]=te):te=t[37];let ue;t[38]!==fe||t[39]!==te?(ue=s.jsx("div",{className:fe,children:te}),t[38]=fe,t[39]=te,t[40]=ue):ue=t[40];let Se;t[41]!==h||t[42]!==x||t[43]!==f?(Se=h&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(As,{children:s.jsx(pC,{isWindowed:!0,initialPrompt:x,onCreated:()=>f(!1),onCancel:()=>f(!1)})})}),t[41]=h,t[42]=x,t[43]=f,t[44]=Se):Se=t[44];let we;t[45]===Symbol.for("react.memo_cache_sentinel")?(we=s.jsx(As,{children:s.jsx(G4,{})}),t[45]=we):we=t[45];let ye;t[46]===Symbol.for("react.memo_cache_sentinel")?(ye=s.jsx(As,{children:s.jsx(q4,{})}),t[46]=ye):ye=t[46];let Ae;t[47]===Symbol.for("react.memo_cache_sentinel")?(Ae=s.jsx(As,{children:s.jsx(rC,{})}),t[47]=Ae):Ae=t[47];let pe;t[48]!==S?(pe=S&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(As,{children:s.jsx(ob,{mode:`plugin:${S.id}`,surface:"page",item:null,onDismiss:YC})})}),t[48]=S,t[49]=pe):pe=t[49];let O;t[50]!==ue||t[51]!==Se||t[52]!==pe?(O=s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[ue,Se,we,ye,Ae,pe]}),t[50]=ue,t[51]=Se,t[52]=pe,t[53]=O):O=t[53];let Q;t[54]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(lS,{}),t[54]=Q):Q=t[54];let le;t[55]!==O?(le=s.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[O,Q]})})}),t[55]=O,t[56]=le):le=t[56];let H;t[57]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(As,{children:s.jsx(bS,{})})}),t[57]=H):H=t[57];let me;t[58]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(As,{children:s.jsx(Tx,{})}),t[58]=me):me=t[58];let ge;t[59]!==le?(ge=s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[J,s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[le,H,me]})]}),t[59]=le,t[60]=ge):ge=t[60];let oe;t[61]!==X||t[62]!==ge?(oe=s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[X,ge]}),t[61]=X,t[62]=ge,t[63]=oe):oe=t[63];let de;t[64]!==i||t[65]!==o||t[66]!==l?(de=l?s.jsx(c.Suspense,{fallback:null,children:s.jsx(IC,{open:i,onOpenChange:o})}):null,t[64]=i,t[65]=o,t[66]=l,t[67]=de):de=t[67];let _;return t[68]!==W||t[69]!==oe||t[70]!==de?(_=s.jsx(Vh,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:"main-content-safe-area relative flex h-[100dvh] bg-background",children:[L,$,K,F,W,N,oe,de]})}),t[68]=W,t[69]=oe,t[70]=de,t[71]=_):_=t[71],_};function EC(t){return t.isSidebarOpen}function RC(t){return t.setIsMobile}function MC(t){return t.isSettingsDialogOpen}function OC(t){return t.setSettingsDialogOpen}function BC(t){return t.isMultiRunLauncherOpen}function FC(t){return t.setMultiRunLauncherOpen}function _C(t){return t.multiRunLauncherPrefillPrompt}function LC(t){return t.isScheduledTasksDialogOpen}function $C(t){return t.isArchivePageOpen}function zC(t){return t.worktreesPageProjectId}function WC(t){return t.openGuestPageId}function KC(){return Pe.getState().setOpenGuestPage(null)}function VC(){return Qr(KC)}function UC(){return Pe.getState().closeMainSurfaces()}function HC(){const t=UC,e=tt.subscribe((n,r)=>{const i=!!n.currentSessionId&&n.currentSessionId!==r.currentSessionId,o=!!n.newSessionDraft?.open&&n.newSessionDraft!==r.newSessionDraft;(i||o)&&t()});return()=>{e()}}function GC(){return rf(!1)}function qC(){return rf(!0)}function YC(){return Pe.getState().setOpenGuestPage(null)}const tm=12,QC=[{id:"left",x:22,y:58,delay:0,radius:120,colorVar:"--status-success"},{id:"center",x:50,y:42,delay:120,radius:150,colorVar:"--primary-base"},{id:"right",x:78,y:55,delay:200,radius:130,colorVar:"--status-info"}],XC=t=>{const e=Ze.c(18),{isActive:n,burstKey:r,className:i,durationMs:o,bursts:l,onComplete:a}=t,d=r===void 0?0:r,u=o===void 0?900:o,h=l===void 0?QC:l,f=mt.useRef(!1);let x,b;e[0]!==n||e[1]!==a?(x=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},b=[n,a],e[0]=n,e[1]=a,e[2]=x,e[3]=b):(x=e[2],b=e[3]),mt.useEffect(x,b);let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w=Array.from({length:tm},JC),e[4]=w):w=e[4];const v=w;if(!n)return null;let y;e[5]!==i?(y=Oe("fireworks-overlay pointer-events-none",i),e[5]=i,e[6]=y):y=e[6];let m;if(e[7]!==d||e[8]!==h||e[9]!==u){let S;e[11]!==d||e[12]!==u?(S=g=>{const C={"--burst-delay":`${g.delay}ms`,"--burst-x":`${g.x}%`,"--burst-y":`${g.y}%`,"--firework-color":`var(${g.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:C,children:v.map((k,j)=>{const D=k.x*g.radius,I=k.y*g.radius,A={"--translate-x":`${D}px`,"--translate-y":`${I}px`,"--particle-delay":`${k.delay}ms`,color:`var(${g.colorVar})`};return s.jsx("span",{className:"firework-particle",style:A},`${g.id}-${j}-${d}`)})},`${g.id}-${d}`)},e[11]=d,e[12]=u,e[13]=S):S=e[13],m=h.map(S),e[7]=d,e[8]=h,e[9]=u,e[10]=m}else m=e[10];let p;return e[14]!==d||e[15]!==y||e[16]!==m?(p=s.jsx("div",{className:y,"aria-hidden":"true","data-burst-key":d,children:m}),e[14]=d,e[15]=y,e[16]=m,e[17]=p):p=e[17],p};function JC(t,e){const n=Math.PI*2*e/tm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const ZC=t=>{const e=Ze.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,i=r===void 0?3400:r;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={isActive:!1,cycle:0},e[2]=o):o=e[2];const[l,a]=mt.useState(o),d=mt.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const h=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{h(),a(e5)},e[4]=f):f=e[4];const x=f;let b;e[5]!==i?(b=()=>{h(),a(t5),d.current=window.setTimeout(()=>{a(s5),d.current=null},i)},e[5]=i,e[6]=b):b=e[6];const w=b;let v,y;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>h(),y=[h],e[7]=v,e[8]=y):(v=e[7],y=e[8]),mt.useEffect(v,y);let m;return e[9]!==l.cycle||e[10]!==l.isActive||e[11]!==w?(m={isActive:l.isActive,burstKey:l.cycle,triggerFireworks:w,dismissFireworks:x},e[9]=l.cycle,e[10]=l.isActive,e[11]=w,e[12]=m):m=e[12],m};function e5(t){return t.isActive?{...t,isActive:!1}:t}function t5(t){return{isActive:!0,cycle:t.cycle+1}}function s5(t){return t.isActive?{...t,isActive:!1}:t}const sm=c.createContext(void 0),n5=t=>{const e=Ze.c(10),{children:n}=t,{isActive:r,burstKey:i,triggerFireworks:o,dismissFireworks:l}=ZC();let a;e[0]!==l||e[1]!==o?(a={triggerFireworks:o,dismissFireworks:l},e[0]=l,e[1]=o,e[2]=a):a=e[2];const d=a;let u;e[3]!==i||e[4]!==r?(u=s.jsx(XC,{isActive:r,burstKey:i}),e[3]=i,e[4]=r,e[5]=u):u=e[5];let h;return e[6]!==n||e[7]!==u||e[8]!==d?(h=s.jsxs(sm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=h):h=e[9],h},GN=()=>{const t=c.useContext(sm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},ga="openchamber_requests_in_flight",nm=1e3,r5=300*1e3,Ko=Math.ceil(r5/nm),o5=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ga)==="1"}catch{return!1}},rm=()=>({enabled:!0,startedAt:Date.now(),inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],peakAgeMs:0,inFlightStarts:new Map,sampleCount:0,lastSampleAt:null,fetchWrapped:!1,originalFetch:null,sampleTimer:null});let i5=1;const a5=(t,e)=>{const n=window.__openchamberRequestsInFlight__;!n||!n.enabled||(n.inFlight+=1,n.totalStarted+=1,n.inFlight>n.peak&&(n.peak=n.inFlight),n.inFlightStarts.set(t,e))},l5=t=>{const e=window.__openchamberRequestsInFlight__;!e||!e.enabled||(e.inFlight=Math.max(0,e.inFlight-1),e.totalSettled+=1,e.inFlightStarts.delete(t))},om=t=>{if(t.inFlightStarts.size===0)return[];const e=Date.now(),n=[];for(const r of t.inFlightStarts.values())n.push(Math.max(0,e-r));return n.sort((r,i)=>r-i),n},Sr=(t,e)=>{const n=t.length;if(n===0)return 0;if(n===1)return t[0];const r=e/100*(n-1),i=Math.floor(r),o=Math.ceil(r);return i===o?t[i]:t[i]+(t[o]-t[i])*(r-i)},c5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t||t.fetchWrapped)return;const e=window.fetch.bind(window);t.originalFetch=e,t.fetchWrapped=!0;const n=async(r,i)=>{const o=i5++;a5(o,Date.now());try{return await e(r,i)}finally{l5(o)}};window.fetch=n},gd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||!t.fetchWrapped||!t.originalFetch||(window.fetch=t.originalFetch,t.fetchWrapped=!1,t.originalFetch=null)},Mr=t=>{t.length>Ko&&t.splice(0,t.length-Ko)},d5=()=>{const t=window.__openchamberRequestsInFlight__;if(!t||!t.enabled)return;t.samples.push(t.inFlight);const e=om(t),n=e.length>0?e[e.length-1]:0;t.p50Samples.push(Sr(e,50)),t.p90Samples.push(Sr(e,90)),t.p99Samples.push(Sr(e,99)),t.maxSamples.push(n),n>t.peakAgeMs&&(t.peakAgeMs=n),t.sampleCount+=1,Mr(t.samples),Mr(t.p50Samples),Mr(t.p90Samples),Mr(t.p99Samples),Mr(t.maxSamples),t.lastSampleAt=Date.now()},u5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer!=null||(t.sampleTimer=window.setInterval(d5,nm))},xd=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;!t||t.sampleTimer==null||(window.clearInterval(t.sampleTimer),t.sampleTimer=null)},bd=t=>{if(!(typeof window>"u"))try{if(t){xd(),gd(),window.localStorage.setItem(ga,"1"),window.__openchamberRequestsInFlight__=rm(),c5(),u5();return}window.localStorage.removeItem(ga),xd(),gd(),delete window.__openchamberRequestsInFlight__}catch{}},f5=()=>{if(typeof window>"u")return;const t=window.__openchamberRequestsInFlight__;if(!t)return;const e=rm();t.startedAt=e.startedAt,t.inFlight=e.inFlight,t.peak=e.peak,t.totalStarted=e.totalStarted,t.totalSettled=e.totalSettled,t.samples=e.samples,t.p50Samples=e.p50Samples,t.p90Samples=e.p90Samples,t.p99Samples=e.p99Samples,t.maxSamples=e.maxSamples,t.peakAgeMs=e.peakAgeMs,t.inFlightStarts=e.inFlightStarts,t.sampleCount=e.sampleCount,t.lastSampleAt=e.lastSampleAt},xa=()=>{if(typeof window>"u")return yd();const t=window.__openchamberRequestsInFlight__;if(!o5()||!t)return yd();const e=om(t);return{enabled:!0,startedAt:t.startedAt,durationMs:Math.max(0,Date.now()-t.startedAt),inFlight:t.inFlight,peak:t.peak,totalStarted:t.totalStarted,totalSettled:t.totalSettled,samples:t.samples.slice(),ageP50:Sr(e,50),ageP90:Sr(e,90),ageP99:Sr(e,99),ageMax:e.length>0?e[e.length-1]:0,peakAgeMs:t.peakAgeMs,p50Samples:t.p50Samples.slice(),p90Samples:t.p90Samples.slice(),p99Samples:t.p99Samples.slice(),maxSamples:t.maxSamples.slice(),sampleCount:t.sampleCount,lastSampleAt:t.lastSampleAt,windowSeconds:Ko}},yd=()=>({enabled:!1,startedAt:null,durationMs:0,inFlight:0,peak:0,totalStarted:0,totalSettled:0,samples:[],ageP50:0,ageP90:0,ageP99:0,ageMax:0,peakAgeMs:0,p50Samples:[],p90Samples:[],p99Samples:[],maxSamples:[],sampleCount:0,lastSampleAt:null,windowSeconds:Ko});function m5(t){switch(t){case"memory":return"database-2";case"streaming":return"bar-chart-box";case"requests":return"pulse"}}const im=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},ba=t=>`${(t/1e3).toFixed(2)} s`,bs=t=>{const e=Ze.c(8),{label:n,value:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=i):i=e[0];let o;e[1]!==n?(o=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r?(l=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=l):l=e[4];let a;return e[5]!==o||e[6]!==l?(a=s.jsxs("div",{className:"rounded-md p-2",style:i,children:[o,l]}),e[5]=o,e[6]=l,e[7]=a):a=e[7],a},wd=t=>{const e=Ze.c(43),{title:n,snapshot:r,emptyLabel:i}=t,{t:o}=jt();let l;if(e[0]!==i||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==o||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(g5,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let h;e[10]!==n?(h=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=h):h=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==o?(f=r.startedAt?im(r.durationMs):o("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=o,e[15]=f):f=e[15];let x;e[16]!==f?(x=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=x):x=e[17];let b;e[18]!==h||e[19]!==x?(b=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,x]}),e[18]=h,e[19]=x,e[20]=b):b=e[20];let w;e[21]!==o?(w=o("memoryDebugPanel.metric.metrics"),e[21]=o,e[22]=w):w=e[22];let v;e[23]!==r.entries.length||e[24]!==w?(v=s.jsx(bs,{label:w,value:r.entries.length}),e[23]=r.entries.length,e[24]=w,e[25]=v):v=e[25];let y;e[26]!==o?(y=o("memoryDebugPanel.metric.samples"),e[26]=o,e[27]=y):y=e[27];let m;e[28]!==y||e[29]!==u?(m=s.jsx(bs,{label:y,value:u}),e[28]=y,e[29]=u,e[30]=m):m=e[30];let p;e[31]!==o?(p=o("memoryDebugPanel.metric.lastUpdate"),e[31]=o,e[32]=p):p=e[32];let S;e[33]!==r.lastUpdatedAt||e[34]!==o?(S=r.lastUpdatedAt?o("memoryDebugPanel.common.live"):o("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=o,e[35]=S):S=e[35];let g;e[36]!==p||e[37]!==S?(g=s.jsx(bs,{label:p,value:S}),e[36]=p,e[37]=S,e[38]=g):g=e[38];let C;e[39]!==m||e[40]!==g||e[41]!==v?(C=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[v,m,g]}),e[39]=m,e[40]=g,e[41]=v,e[42]=C):C=e[42],l=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[b,C,a.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:i}):s.jsx(yn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(k=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:k.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:o("memoryDebugPanel.metric.countValue",{value:k.count})}),s.jsx("span",{children:o("memoryDebugPanel.metric.avgValue",{value:k.avg})}),s.jsx("span",{children:o("memoryDebugPanel.metric.maxValue",{value:k.max})}),s.jsx("span",{children:o("memoryDebugPanel.metric.totalValue",{value:k.total})})]})]},k.metric))})})]}),e[0]=i,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=o,e[6]=n,e[7]=l}else l=e[7];return l},vd=t=>{const e=Ze.c(24),{series:n,peak:r,windowSeconds:i,ariaLabel:o,maxLabel:l}=t,a=i,d=n.reduce(x5,0),u=r>0?52/r:0;let h;e[0]!==d||e[1]!==a?(h=g=>a-d+g,e[0]=d,e[1]=a,e[2]=h):h=e[2];const f=h;let x;e[3]!==u?(x=g=>56-g*u,e[3]=u,e[4]=x):x=e[4];const b=x;let w;e[5]!==l?(w=s.jsx("span",{className:"pointer-events-none absolute left-0 top-0 typography-meta text-[var(--surface-muted-foreground)]",children:l}),e[5]=l,e[6]=w):w=e[6];const v=`0 0 ${a} 56`;let y;e[7]!==a?(y=s.jsx("line",{x1:0,y1:56,x2:a,y2:56,stroke:"var(--interactive-border)",strokeWidth:1,vectorEffect:"non-scaling-stroke"}),e[7]=a,e[8]=y):y=e[8];let m;if(e[9]!==n||e[10]!==f||e[11]!==b){let g;e[13]!==f||e[14]!==b?(g=(C,k)=>{const j=C.samples.length;if(j===0)return null;const D=C.samples.map((A,P)=>`${f(P)},${b(A).toFixed(2)}`),I=`M ${D.join(" L ")}`;return s.jsxs(c.Fragment,{children:[C.filled?s.jsx("path",{d:`M ${f(0)},56 L ${D.join(" L ")} L ${f(j-1)},56 Z`,fill:`color-mix(in srgb, ${C.color} 18%, transparent)`,stroke:"none"}):null,s.jsx("path",{d:I,fill:"none",stroke:C.color,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},k)},e[13]=f,e[14]=b,e[15]=g):g=e[15],m=n.map(g),e[9]=n,e[10]=f,e[11]=b,e[12]=m}else m=e[12];let p;e[16]!==o||e[17]!==v||e[18]!==y||e[19]!==m?(p=s.jsxs("svg",{viewBox:v,preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":o,children:[y,m]}),e[16]=o,e[17]=v,e[18]=y,e[19]=m,e[20]=p):p=e[20];let S;return e[21]!==w||e[22]!==p?(S=s.jsxs("div",{className:"relative w-full",children:[w,p]}),e[21]=w,e[22]=p,e[23]=S):S=e[23],S},h5=t=>{const e=Ze.c(100),{onClose:n}=t,{t:r}=jt(),[i,o]=c.useState("memory"),[l,a]=c.useState("idle"),d=tt(b5),u=Eu(y5),h=bu(),f=Gg(w5),x=Hs(v5),[b,w]=c.useState(S5),[v,y]=c.useState(j5),[m,p]=c.useState(k5),S=[{label:"p50",current:m.ageP50,samples:m.p50Samples,color:"var(--status-success)"},{label:"p90",current:m.ageP90,samples:m.p90Samples,color:"var(--status-info)"},{label:"p99",current:m.ageP99,samples:m.p99Samples,color:"var(--status-warning)"},{label:"max",current:m.ageMax,samples:m.maxSamples,color:"var(--status-error)"}];let g;e[0]!==m.samples?(g=m.samples.reduce(C5,0),e[0]=m.samples,e[1]=g):g=e[1];const C=g,k=S.reduce(A5,0);let j;e[2]!==b.entries?(j=new Map,b.entries.forEach(Fe=>{j.set(Fe.metric,Fe.count)}),e[2]=b.entries,e[3]=j):j=e[3];let D;e[4]!==j?(D=j.get("ui.message_list.render")??0,e[4]=j,e[5]=D):D=e[5];let I;e[6]!==j?(I=j.get("ui.message_list.render.streaming")??0,e[6]=j,e[7]=I):I=e[7];let A;e[8]!==j?(A=j.get("ui.chat_message.render")??0,e[8]=j,e[9]=A):A=e[9];let P;e[10]!==j?(P=j.get("ui.chat_message.render.streaming")??0,e[10]=j,e[11]=P):P=e[11];let T;e[12]!==j?(T=j.get("ui.chat_message.render.static_during_stream")??0,e[12]=j,e[13]=T):T=e[13];let L;e[14]!==j?(L=j.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[14]=j,e[15]=L):L=e[15];let $;e[16]!==D||e[17]!==I||e[18]!==A||e[19]!==P||e[20]!==T||e[21]!==L?($={messageListRender:D,messageListRenderStreaming:I,chatMessageRender:A,chatMessageRenderStreaming:P,chatMessageRenderStaticDuringStream:T,chatMessageRenderStaticOutsideActiveTurnDuringStream:L},e[16]=D,e[17]=I,e[18]=A,e[19]=P,e[20]=T,e[21]=L,e[22]=$):$=e[22];const K=$;let F,W;e[23]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{const Fe=()=>{w(bo()),y(yo()),p(xa())};Fe();const _e=window.setInterval(Fe,500);return()=>window.clearInterval(_e)},F=[],e[23]=F,e[24]=W):(F=e[23],W=e[24]),c.useEffect(W,F);let N,R;e[25]!==l?(N=()=>{if(l==="idle")return;const Fe=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(Fe)},R=[l],e[25]=l,e[26]=N,e[27]=R):(N=e[26],R=e[27]),c.useEffect(N,R);let E=0,X=0,J=0;for(const Fe of Object.keys(f)){const _e=f[Fe]??[];X=X+_e.length;for(const rt of _e)rt.role==="user"?J=J+1:rt.role==="assistant"&&(E=E+1)}let re;e[28]!==E||e[29]!==X||e[30]!==J?(re={assistant:E,total:X,user:J},e[28]=E,e[29]=X,e[30]=J,e[31]=re):re=e[31];const fe=re;let ne;if(e[32]!==d||e[33]!==f||e[34]!==u||e[35]!==h||e[36]!==r){let Fe;e[38]!==d||e[39]!==f||e[40]!==u||e[41]!==r?(Fe=_e=>{const rt=f[_e.id]??[];let ct=0,et=0;for(const kt of rt)kt.role==="user"?et=et+1:kt.role==="assistant"&&(ct=ct+1);const pt=u.get(_e.id);return{id:_e.id,title:_e.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ct,messageCount:rt.length,userMessageCount:et,isStreaming:pt?.isStreaming||!1,isZombie:pt?.isZombie||!1,backgroundCount:pt?.backgroundMessageCount||0,lastAccessed:pt?.lastAccessedAt||0,isCurrent:_e.id===d}},e[38]=d,e[39]=f,e[40]=u,e[41]=r,e[42]=Fe):Fe=e[42],ne=h.map(Fe).sort(D5),e[32]=d,e[33]=f,e[34]=u,e[35]=h,e[36]=r,e[37]=ne}else ne=e[37];const te=ne;let ue;e[43]!==f?(ue=Object.keys(f),e[43]=f,e[44]=ue):ue=e[44];const Se=ue.length;let we;e[45]===Symbol.for("react.memo_cache_sentinel")?(we=async()=>{try{const Fe={generatedAt:new Date().toISOString(),ui:bo(),vscode:yo()};await navigator.clipboard.writeText(JSON.stringify(Fe,null,2)),a("copied")}catch{a("error")}},e[45]=we):we=e[45];const ye=we,Ae=Yg,pe="fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area";let O;e[46]===Symbol.for("react.memo_cache_sentinel")?(O={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[46]=O):O=e[46];let Q;e[47]!==i?(Q=m5(i),e[47]=i,e[48]=Q):Q=e[48];let le;e[49]!==Q?(le=s.jsx(M,{name:Q,className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[49]=Q,e[50]=le):le=e[50];let H;e[51]!==r?(H=r("memoryDebugPanel.title"),e[51]=r,e[52]=H):H=e[52];let me;e[53]!==H?(me=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:H}),e[53]=H,e[54]=me):me=e[54];let ge;e[55]!==le||e[56]!==me?(ge=s.jsxs("div",{className:"flex items-center gap-2",children:[le,me]}),e[55]=le,e[56]=me,e[57]=ge):ge=e[57];let oe;e[58]!==i?(oe=i==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(dt,{size:"xs",variant:"ghost",onClick:ye,children:s.jsx(M,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(dt,{size:"xs",variant:"ghost",onClick:()=>{eh(),w(bo()),y(yo())},children:s.jsx(M,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[58]=i,e[59]=oe):oe=e[59];let de;e[60]!==i?(de=i==="requests"?s.jsx(dt,{size:"xs",variant:"ghost",onClick:()=>{f5(),p(xa())},children:s.jsx(M,{name:"refresh",className:"h-3.5 w-3.5"})}):null,e[60]=i,e[61]=de):de=e[61];let _;e[62]!==n?(_=n?s.jsx(dt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(M,{name:"close",className:"h-4 w-4"})}):null,e[62]=n,e[63]=_):_=e[63];let B;e[64]!==oe||e[65]!==de||e[66]!==_?(B=s.jsxs("div",{className:"flex items-center gap-1",children:[oe,de,_]}),e[64]=oe,e[65]=de,e[66]=_,e[67]=B):B=e[67];let he;e[68]!==ge||e[69]!==B?(he=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[ge,B]}),e[68]=ge,e[69]=B,e[70]=he):he=e[70];let ve;e[71]===Symbol.for("react.memo_cache_sentinel")?(ve={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[71]=ve):ve=e[71];const Re=i==="memory"?"secondary":"ghost";let ce;e[72]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>o("memory"),e[72]=ce):ce=e[72];let se;e[73]!==r?(se=r("memoryDebugPanel.tabs.memory"),e[73]=r,e[74]=se):se=e[74];let q;e[75]!==Re||e[76]!==se?(q=s.jsx(dt,{size:"sm",variant:Re,className:"flex-1",onClick:ce,children:se}),e[75]=Re,e[76]=se,e[77]=q):q=e[77];const z=i==="streaming"?"secondary":"ghost";let ee;e[78]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>o("streaming"),e[78]=ee):ee=e[78];let ae;e[79]!==r?(ae=r("memoryDebugPanel.tabs.streaming"),e[79]=r,e[80]=ae):ae=e[80];let Ne;e[81]!==z||e[82]!==ae?(Ne=s.jsx(dt,{size:"sm",variant:z,className:"flex-1",onClick:ee,children:ae}),e[81]=z,e[82]=ae,e[83]=Ne):Ne=e[83];const Ce=i==="requests"?"secondary":"ghost";let We;e[84]===Symbol.for("react.memo_cache_sentinel")?(We=()=>o("requests"),e[84]=We):We=e[84];let Ee;e[85]!==r?(Ee=r("memoryDebugPanel.tabs.requests"),e[85]=r,e[86]=Ee):Ee=e[86];let xe;e[87]!==Ce||e[88]!==Ee?(xe=s.jsx(dt,{size:"sm",variant:Ce,className:"flex-1",onClick:We,children:Ee}),e[87]=Ce,e[88]=Ee,e[89]=xe):xe=e[89];let $e;e[90]!==q||e[91]!==Ne||e[92]!==xe?($e=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ve,children:[q,Ne,xe]}),e[90]=q,e[91]=Ne,e[92]=xe,e[93]=$e):$e=e[93];const V=i==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(bs,{label:r("memoryDebugPanel.metric.totalMessages"),value:fe.total}),s.jsx(bs,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${Se} / ${Fl.MAX_SESSIONS}`}),s.jsx(bs,{label:r("memoryDebugPanel.metric.userMessages"),value:fe.user}),s.jsx(bs,{label:r("memoryDebugPanel.metric.assistantMessages"),value:fe.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:qg()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:Fl.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:x})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(yn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:te.map(Fe=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:Fe.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:Fe.title}),Fe.isStreaming?s.jsx(M,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,Fe.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:Fe.assistantMessageCount,user:Fe.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:Fe.messageCount})}),Fe.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",Fe.backgroundCount]}):null]})]},Fe.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(Nt,{children:[s.jsx(At,{asChild:!0,children:s.jsx(dt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(P5),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:fe,sessionMessageRoleCounts:te.map(I5),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(Dt,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):i==="streaming"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(l==="copied"?"memoryDebugPanel.streaming.copy.copied":l==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(dt,{size:"xs",variant:"outline",onClick:ye,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(bs,{label:r("memoryDebugPanel.metric.uiMetrics"),value:b.entries.length}),s.jsx(bs,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:v.entries.length}),s.jsx(bs,{label:r("memoryDebugPanel.metric.messageListRenders"),value:K.messageListRender}),s.jsx(bs,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:K.messageListRenderStreaming}),s.jsx(bs,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:K.chatMessageRender}),s.jsx(bs,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:K.chatMessageRenderStreaming}),s.jsx(bs,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:K.chatMessageRenderStaticDuringStream}),s.jsx(bs,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:K.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(wd,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),v.entries.length>0?s.jsx(wd,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:v,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(bs,{label:r("memoryDebugPanel.requests.totalRequests"),value:`${m.totalSettled} / ${m.totalStarted}`}),s.jsx(bs,{label:r("memoryDebugPanel.requests.tracking"),value:m.startedAt?im(m.durationMs):r("memoryDebugPanel.common.idle")})]}),m.samples.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:r("memoryDebugPanel.requests.noSamples")}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.inFlight")}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.inFlight}),s.jsxs("span",{className:"text-[var(--surface-muted-foreground)]",children:[" · ",r("memoryDebugPanel.requests.peak")," "]}),s.jsx("span",{className:"font-medium text-[var(--surface-foreground)]",children:m.peak})]})]}),s.jsx(vd,{series:[{samples:m.samples,color:"var(--status-info)",filled:!0}],peak:C,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.chartLabel",{peak:m.peak}),maxLabel:`${C}`}),s.jsxs("div",{className:"flex items-center justify-between typography-meta",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.requests.duration")}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:ba(m.peakAgeMs)})]}),s.jsx(vd,{series:S.map(T5),peak:k,windowSeconds:m.windowSeconds,ariaLabel:r("memoryDebugPanel.requests.percentileChartLabel"),maxLabel:ba(k)}),s.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 typography-meta",children:S.map(E5)}),s.jsxs("div",{className:"flex items-center justify-between typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r("memoryDebugPanel.requests.windowHint",{seconds:m.windowSeconds})}),s.jsx("span",{children:r("memoryDebugPanel.requests.now")})]})]})]});let De;return e[94]!==Ae||e[95]!==O||e[96]!==he||e[97]!==$e||e[98]!==V?(De=s.jsxs(Ae,{className:pe,style:O,children:[he,$e,V]}),e[94]=Ae,e[95]=O,e[96]=he,e[97]=$e,e[98]=V,e[99]=De):De=e[99],De},p5=h5;function g5(t,e){return t+e.count}function x5(t,e){return Math.max(t,e.samples.length)}function b5(t){return t.currentSessionId}function y5(t){return t.sessionMemoryState}function w5(t){return t.message}function v5(t){return t.totalRequestCount}function S5(){return bo()}function j5(){return yo()}function k5(){return xa()}function C5(t,e){return Math.max(t,e)}function N5(t,e){return Math.max(t,e)}function A5(t,e){return e.samples.reduce(N5,t)}function D5(t,e){return e.lastAccessed-t.lastAccessed}function P5(t){return{id:t.id,title:t.title}}function I5(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}function T5(t){return{samples:t.samples,color:t.color}}function E5(t){return s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:t.color}}),s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:t.label}),s.jsx("span",{className:"font-medium tabular-nums text-[var(--surface-foreground)]",children:ba(t.current)})]},t.label)}const R5=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},M5=async()=>{const t=R5()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Sd="openchamber:menu-action",Ci="openchamber:check-for-updates",O5=t=>{const e=tt(m=>m.openNewSessionDraft),n=Pe(m=>m.toggleCommandPalette),r=Pe(m=>m.setCommandPaletteOpen),i=Pe(m=>m.toggleHelpDialog),o=Pe(m=>m.toggleSidebar),l=Pe(m=>m.setSessionSwitcherOpen),a=Pe(m=>m.setSettingsDialogOpen),d=Pe(m=>m.setAboutDialogOpen),u=zr(m=>m.checkForUpdates),{setThemeMode:h}=or(),f=c.useRef(!1),x=c.useCallback(()=>{f.current||(f.current=!0,u().then(()=>{const{available:m,error:p}=zr.getState();if(p){Le.error("Failed to check for updates",{description:p});return}m||Le.success("You are on the latest version")}).finally(()=>{f.current=!1}))},[u]),b=c.useCallback(()=>{fn.requestDirectoryDialog()},[]),w=c.useCallback(m=>{const p=Qg();if(p.length===0)return;const S=tt.getState().currentSessionId,g=p.findIndex(j=>j.id===S);let C=m>0?0:p.length-1;g>=0&&(C=(g+m+p.length)%p.length);const k=p[C];k&&(l(!1),tt.getState().setCurrentSession(k.id))},[l]),v=c.useCallback(m=>{const{activeProjectId:p,projects:S,setActiveProject:g}=Ht.getState();if(S.length===0)return;const C=S.findIndex(D=>D.id===p);let k=m>0?0:S.length-1;C>=0&&(k=(C+m+S.length)%S.length);const j=S[k];j&&g(j.id)},[]),y=c.useCallback(m=>{switch(m){case"about":d(!0);break;case"settings":a(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l(!1);{const p=tt.getState(),S=ns.getState().currentDirectory;e(p.currentSessionId&&S?{directoryOverride:S}:void 0)}break;case"new-worktree-session":l(!1),ju();break;case"change-workspace":b();break;case"toggle-right-sidebar":{const p=ns.getState().currentDirectory;if(!p)break;const S=Pe.getState(),g=cr(p),C=S.contextPanelByDirectory[g];C?.isOpen?S.closeContextPanel(g):C?.activeTabId?S.setActiveContextPanelTab(g,C.activeTabId):S.openContextSurface(g,"git");break}case"open-right-sidebar-git":{const p=ns.getState().currentDirectory;if(!p)break;Pe.getState().openContextSurface(cr(p),"git");break}case"open-right-sidebar-files":{const p=ns.getState().currentDirectory;if(!p)break;Pe.getState().openContextSurface(cr(p),"file");break}case"toggle-terminal":{const p=ns.getState().currentDirectory;if(!p)break;Pe.getState().openContextSurface(cr(p),"terminal");break}case"toggle-terminal-expanded":{const p=ns.getState().currentDirectory;if(!p)break;const S=cr(p),g=Pe.getState(),C=g.contextPanelByDirectory[S];(C?.isOpen?C.tabs.find(j=>j.id===C.activeTabId)?.mode:null)!=="terminal"&&g.openContextSurface(S,"terminal"),g.toggleContextPanelExpanded(S);break}case"copy":{const p=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(p)||M5();break}case"theme-light":h("light");break;case"theme-dark":h("dark");break;case"theme-system":h("system");break;case"add-selection-to-chat":Xg();break;case"toggle-sidebar":o();break;case"toggle-memory-debug":t?.();break;case"go-back":ns.getState().goBack();break;case"go-forward":ns.getState().goForward();break;case"previous-session":w(-1);break;case"next-session":w(1);break;case"previous-project":v(-1);break;case"next-project":v(1);break;case"help-dialog":i();break;case"download-logs":{ku().catch(()=>{Le.error("Failed to collect OpenCode status")});break}}},[b,v,w,t,e,d,l,r,a,h,n,i,o]);c.useEffect(()=>{const m=S=>{const g=S.detail;g&&y(g)},p=()=>{x()};return window.addEventListener(Sd,m),window.addEventListener(Ci,p),()=>{window.removeEventListener(Sd,m),window.removeEventListener(Ci,p)}},[y,x]),c.useEffect(()=>{if(typeof window>"u")return;const p=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof p!="function")return;let S=null,g=null;return p("openchamber:menu-action",C=>{const k=C?.payload;typeof k=="string"&&y(k)}).then(C=>{S=C}).catch(()=>{}),p("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Ci))}).then(C=>{g=C}).catch(()=>{}),()=>{(async()=>{try{const k=S?.();k instanceof Promise&&await k}catch{}try{const k=g?.();k instanceof Promise&&await k}catch{}})()}},[y])},B5="openchamber:tray-action",F5=5e3,_5=500,L5=20,jd=()=>{if(typeof window>"u")return!1;const t=window.__OPENCHAMBER_PLATFORM__;return t==="darwin"||t==="win32"||t==="linux"},kd=()=>typeof window<"u"&&window.__OPENCHAMBER_ELECTRON__?.trayEnabled!==!1,am=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},lm=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},$5=(t,e)=>Fa(t,e,Gr.getState().ids,Ta.getState().rankById),z5=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},W5=(t,e,n,r,i)=>{if(!t)return"";const o=qd(n,r,t),l=e.project?.name,a=o?.label?.trim()||l?.trim()||z5(t),d=vo(t);let u=d&&i.get(d)||"";if(!u){for(const[h,f]of Tn.getState().directories)if(vo(h)===d){u=f.status?.current??"";break}}if(!u)for(const h of r.values()){const f=h.find(x=>vo(x.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},K5=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=ur.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const i=new Map(t.map(l=>[l.providerId,l])),o=[];for(const l of Zg){if(!e.includes(l.id))continue;const a=i.get(l.id);if(!a||a.configured!==!0)continue;const d=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const x=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:tx(h),value:ex(f.valueLabel,x)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;o.push({provider:l.name,rows:d,status:u})}return{mode:r,groups:o}},V5=async()=>{try{if(Vo())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Pn();if(e&&dl(e,t))return"Local OpenChamber";const r=(await Td()).hosts.find(i=>e?dl(e,th(i)):!1);return r?.label?.trim()?Ed(r.label.trim()):"Instance"}catch{return""}},U5=()=>{const t=new Map,e=new Map,n=[],r=new Map;let i;try{i=Ui()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[o,l]of i.children.entries()){const a=l.getState();a.vcs?.branch&&e.set(vo(o)??o,a.vcs.branch);for(const d of a.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(a.session_status??{})){const h=u?.type,f=h==="busy"?"busy":h==="retry"?"retry":"idle",x=t.get(d);(!x||x==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(a.permission??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"permission",id:h.id,sessionId:f,sessionTitle:"",label:am(h),directory:o})}for(const[d,u]of Object.entries(a.question??{}))for(const h of u??[]){if(!h?.id)continue;const f=h.sessionID||d;n.push({kind:"question",id:h.id,sessionId:f,sessionTitle:"",label:lm(h),directory:o})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},H5=(t,e)=>{const n=Ma.getState().index.session,r=$s.getState().activeSessions,i=new Map;for(const p of r)if(p?.id&&p.parentID){const S=i.get(p.parentID)??[];S.push(p.id),i.set(p.parentID,S)}const o=p=>{const S=[],g=[...i.get(p)??[]],C=new Set;for(;g.length;){const k=g.pop();C.has(k)||(C.add(k),S.push(k),g.push(...i.get(k)??[]))}return S},l=Pe.getState();let a=0;if(l.dockBadgeEnabled)for(const p of r){if(!p?.id||p.parentID)continue;let S=n.unseenCount[p.id]??0;S===0&&l.notifyOnSubtasks&&(S=o(p.id).reduce((g,C)=>g+(n.unseenCount[C]??0),0)),S>0&&(a+=1)}if(!e)return{sessions:[],approvals:[],instanceName:t,usage:{mode:"usage",groups:[]},dockBadgeCount:a};const d=U5(),u=new Map(d.titleById);for(const p of r)p?.id&&p.title&&u.set(p.id,p.title);const h=qo.getState().statusById,f=p=>{const S=d.statusById.get(p);return S&&S!=="idle"?S:h.get(p)?.status.type??S??"idle"},x=p=>{const S=p.map(g=>f(g));return S.includes("busy")?"busy":S.includes("retry")?"retry":"idle"},b=Ht.getState().projects,w=tt.getState().availableWorktreesByProject,v=r.filter(p=>p?.id&&!p.parentID).slice().sort($5).slice(0,L5).map(p=>{const S=[p.id,...o(p.id)],g=Ds(p)??"";return{id:p.id,title:p.title||"Untitled session",status:x(S),branch:g?d.branchByDirectory.get(g)??"":"",unseen:S.reduce((C,k)=>C+(n.unseenCount[k]??0),0),hasError:S.some(C=>n.unseenHasError[C]??!1),directory:g,subtitle:W5(g,p,b,w,d.branchByDirectory)}}),y=d.approvals.map(p=>({...p,sessionTitle:u.get(p.sessionId)||""})),m=new Set(y.map(p=>p.id));for(const[p,S]of Oa.getState().bySession){const g=u.get(p)||"";for(const C of S.permissions)m.has(C.id)||(m.add(C.id),y.push({kind:"permission",id:C.id,sessionId:p,sessionTitle:g,label:am(C),directory:S.directory}));for(const C of S.questions)m.has(C.id)||(m.add(C.id),y.push({kind:"question",id:C.id,sessionId:p,sessionTitle:g,label:lm(C),directory:S.directory}))}return{sessions:v,approvals:y,instanceName:t,usage:K5(),dockBadgeCount:a}},G5=()=>{c.useEffect(()=>{if(!jd()||!Ur())return;const t=kd();let e=!1,n="",r=null,i="";const o=()=>{if(e)return;const j=H5(i,t),D=JSON.stringify(j);D!==n&&(n=D,_n("desktop_tray_update",j))},l=()=>{e||r!==null||(r=window.setTimeout(()=>{r=null,o()},_5))},a=Ma.subscribe(()=>l()),d=$s.subscribe(()=>l()),u=Pe.subscribe((j,D)=>{(j.dockBadgeEnabled!==D.dockBadgeEnabled||j.notifyOnSubtasks!==D.notifyOnSubtasks)&&l()}),h=()=>{e=!0,r!==null&&window.clearTimeout(r),a(),d(),u()};if(!t)return o(),h;V5().then(j=>{e||(i=j,o())});const f=new Map,x=()=>{if(e)return;let j;try{j=Ui()}catch{return}const D=new Set;for(const[I,A]of j.children.entries())D.add(I),f.has(I)||f.set(I,A.subscribe(()=>l()));for(const[I,A]of f)D.has(I)||(A(),f.delete(I))};let b=null;try{b=Ui().subscribeRegistry(()=>{x(),l()})}catch{}x();const w=Ht.subscribe(()=>l()),v=tt.subscribe(()=>l()),y=Tn.subscribe(()=>l()),m=qo.subscribe(()=>l()),p=Oa.subscribe(()=>l()),S=Ta.subscribe(()=>l()),g=Gr.subscribe(()=>l()),C=ur.subscribe(()=>l());ur.getState().loadSettings().then(()=>{if(e)return;const{dropdownProviderIds:j,results:D}=ur.getState();j.length>0&&j.some(A=>!D.some(P=>P.providerId===A))&&ur.getState().fetchQuotas(j)});const k=window.setInterval(()=>{x(),o()},F5);return o(),()=>{h(),window.clearInterval(k),w(),v(),y(),m(),p(),S(),g(),C(),b?.();for(const j of f.values())j();f.clear()}},[]),c.useEffect(()=>{if(!jd()||!kd()||!Ur())return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=i=>{i.type==="respond-permission"&&Jg(i.sessionId,i.id,i.response).catch(()=>{Le.error("Failed to respond to permission request")})};let r=null;return e(B5,i=>{const o=i?.payload;!o||typeof o!="object"||typeof o.type!="string"||n(o)}).then(i=>{r=i}).catch(()=>{}),()=>{try{const i=r?.();i instanceof Promise&&i.catch(()=>{})}catch{}}},[])},q5=30*6e4,Y5=(t,e,n=q5)=>{const r=new Map;for(const[i,o]of Object.entries(t.sessions)){if(o.status!=="busy"&&o.status!=="retry"||t.serverTime-o.lastUpdateAt>n||e.isKnown(i))continue;const l=e.resolveDirectory(i);if(!l)continue;const a=r.get(l)??[];a.push({id:`host-seed:${i}`,type:"session.status",properties:{sessionID:i,status:{type:"busy"}}}),r.set(l,a)}return r};let Or=null;const cm=()=>{if(Or)return Or;const t=qt();return Or=(async()=>{const e=await Cn.getHostSessionStatusSnapshot();if(!e||qt()!==t)return;const n=qo.getState(),r=$s.getState().entityById,i=Y5(e,{isKnown:l=>n.statusById.has(l)||n.observedById.has(l),resolveDirectory:l=>{const a=r.get(l);return a?Ds(a):null}});for(const[l,a]of i)sx(l,a);const o=[];for(const[l,a]of Object.entries(e.pending??{})){const d=r.get(l),u=d?Ds(d):null;u&&o.push({sessionId:l,directory:u,permissions:a.permissions,questions:a.questions})}nx(o)})().finally(()=>{Or=null}),Or},Q5=45e3,X5=(t,e,n=window.setInterval.bind(window),r=window.clearInterval.bind(window))=>{t();const i=n(e,Q5);return()=>r(i)},J5=t=>{const e=Ze.c(3);let n,r;e[0]!==t?(n=()=>{if(t)return X5(eN,sN)},r=[t],e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]),c.useEffect(n,r)};function Z5(){return cm()}function eN(){rx(To()).finally(Z5)}function tN(){return cm()}function sN(){za().finally(tN)}const nN="/api/notifications/stream",rN=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),oN=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="openchamber:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},iN=t=>{const e=Ze.c(3),n=t?.enabled??!0;let r,i;e[0]!==n?(r=()=>{if(!n||xn()||!wa()||typeof window>"u"||typeof EventSource>"u")return;const o=new EventSource(ya().sse(nN));return o.onmessage=aN,()=>{o.close()}},i=[n],e[0]=n,e[1]=r,e[2]=i):(r=e[1],i=e[2]),c.useEffect(r,i)};function aN(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Pe.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&rN())return;const r=oN(e);if(!r)return;Id()?.notifications?.notifyAgentCompletion(r)}const lN=6e4,cN=t=>{const e=Ze.c(10),n=Pe(dN),r=ox(uN),o=Uh(t)?.path??null;let l,a;e[0]!==n||e[1]!==r||e[2]!==o?(l=()=>{n&&r(o,{maxAgeMs:lN})},a=[n,r,o],e[0]=n,e[1]=r,e[2]=o,e[3]=l,e[4]=a):(l=e[3],a=e[4]),c.useEffect(l,a);let d,u;e[5]!==n||e[6]!==r||e[7]!==o?(d=()=>{if(n)return eo(h=>{h.type==="agent-memory-changed"&&r(o)})},u=[n,r,o],e[5]=n,e[6]=r,e[7]=o,e[8]=d,e[9]=u):(d=e[8],u=e[9]),c.useEffect(d,u)};function dN(t){return t.agentMemoryFeatureAvailable&&t.agentMemoryToolEnabled}function uN(t){return t.load}const Cd="pwa-install-toast-shown",Nd="pwa-install-toast-dismissed",fN=()=>{const t=Ze.c(6),{browserTab:e}=Hh(),{t:n}=jt(),r=c.useRef(n);let i,o;t[0]!==n?(i=()=>{r.current=n},o=[n],t[0]=n,t[1]=i,t[2]=o):(i=t[1],o=t[2]),c.useEffect(i,o);let l,a;t[3]!==e?(l=()=>{if(typeof window>"u"||!wa()||!e)return;let d=null,u=null;const h=()=>{u!==null&&(Le.dismiss(u),u=null)},f=async()=>{if(!d)return;const w=d;d=null,h(),await w.prompt();const{outcome:v}=await w.userChoice;v==="accepted"&&Le.success(r.current("pwa.installPrompt.started"))},x=w=>{const v=w;if(typeof v.prompt!="function")return;v.preventDefault(),d=v;const y=Do(),m=sh();Gh({dismissed:y.getItem(Nd),sessionShown:m.getItem(Cd),hasActiveToast:u!==null})&&(m.setItem(Cd,"true"),u=Le.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Do().setItem(Nd,"true"),h()}}}))},b=()=>{d=null,h(),Le.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",x),window.addEventListener("appinstalled",b),()=>{h(),window.removeEventListener("beforeinstallprompt",x),window.removeEventListener("appinstalled",b)}},a=[e],t[3]=e,t[4]=l,t[5]=a):(l=t[4],a=t[5]),c.useEffect(l,a)},mN=({open:t,onOpenChange:e})=>{const{t:n}=jt(),r=!1,[i,o]=c.useState(null),[l,a]=c.useState(null),[d,u]=c.useState(!1),[h,f]=c.useState(!1),[x,b]=c.useState(null),[w,v]=c.useState(!1);c.useCallback(async()=>{},[x,d,r,n]),c.useEffect(()=>{if(!t)return;(async()=>{try{const p=await ls("/api/system/info");if(p.ok){const S=await p.json();if(typeof S.openchamberVersion=="string"&&S.openchamberVersion.trim()){o(S.openchamberVersion);return}}}catch{}o(await ix())})()},[t]),c.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const S=await ls("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!S.ok)return;const g=await S.json().catch(()=>null),C=typeof g?.currentVersion=="string"?g.currentVersion.trim():"";!m&&C&&a(C)}catch{}})(),()=>{m=!0}},[t]),c.useEffect(()=>{{b(null),v(!1);return}},[t,r]);const y=i;return s.jsx(ys,{open:t,onOpenChange:e,children:s.jsx(ws,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(yu,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[y&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:y})}),l&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:l})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(M,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(M,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(M,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Ad=t=>{if(!(typeof window>"u")){if(t){window.location.href="openchamber://focus/mcp-auth";return}window.location.replace("/")}},Ni=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},hN=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to OpenChamber and click Authorize again.":n},pN=()=>{const t=ax(a=>a.completeAuth),[e,n]=c.useState("working"),[r,i]=c.useState(!1),[o,l]=c.useState("Completing MCP authorization...");return c.useEffect(()=>{if(typeof window>"u"){n("error"),l("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),d=Ni(a,"code"),u=lx(a),h=cx(a),f=Ni(a,"error"),x=Ni(a,"error_description");if(f){h&&ls(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(x??f);return}(async()=>{try{if(!d)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");let b=u,w=!1;if(h){const v=await ls(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(v.ok){const y=await v.json().catch(()=>null);w=y?.origin===dx,i(w),!b&&y?.name?.trim()&&(b={name:y.name.trim(),directory:typeof y.directory=="string"&&y.directory.trim()?y.directory.trim():null})}}if(!b?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");await t(b.name,d,b.directory),h&&await ls(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),w&&Ad(!0),l("Authorization completed. You can close this tab and return to OpenChamber.")}catch(b){h&&await ls(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),l(hN(b,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("h1",{className:ux,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:Oe("typography-body",e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]"),children:o})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx(dt,{type:"button",onClick:()=>Ad(r),children:"Return to OpenChamber"})})]})})},Dd=Wn(()=>En(()=>import("./OnboardingScreen-CQHBSTEi.js"),__vite__mapDeps([150,1,2,4,5,6,7,8,9,3,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])).then(t=>({default:t.OnboardingScreen}))),gN=()=>{const t=Ze.c(3),e=Pe(SN),n=Pe(jN);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(mN,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},xN=t=>{const e=Ze.c(21),{onRetry:n,isRetrying:r}=t,{t:i}=jt();let o;e[0]!==i?(o=i("startup.initRecovery.title"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=s.jsx("h1",{className:"typography-title text-foreground",children:o}),e[2]=o,e[3]=l):l=e[3];let a;e[4]!==i?(a=i("startup.initRecovery.description"),e[4]=i,e[5]=a):a=e[5];let d;e[6]!==a?(d=s.jsx("p",{className:"typography-body text-muted-foreground",children:a}),e[6]=a,e[7]=d):d=e[7];let u;e[8]!==l||e[9]!==d?(u=s.jsxs("div",{className:"flex flex-col gap-2",children:[l,d]}),e[8]=l,e[9]=d,e[10]=u):u=e[10];let h;e[11]!==r||e[12]!==i?(h=i(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=i,e[13]=h):h=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==h?(f=s.jsx(dt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=f):f=e[17];let x;return e[18]!==u||e[19]!==f?(x=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[u,f]})}),e[18]=u,e[19]=f,e[20]=x):x=e[20],x},Pd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",bN=()=>{if(typeof window>"u"||!rb())return null;const t=new URLSearchParams(window.location.search),e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),i=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:i,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},yN=()=>typeof window>"u"?!1:window.location.pathname===xx,wN=t=>{const e=Ze.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=t,o=ns(kN),l=tt(CN),a=tt(NN),d=ru(),u=c.useRef(null);let h;e[0]!==n.directory?(h=Pd(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let x;e[2]!==o?(x=Pd(o),e[2]=o,e[3]=x):x=e[3];const b=x;let w,v;if(e[4]!==b||e[5]!==l||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(w=()=>{if(r||f&&b!==f)return;const C=`${f}
|
|
896
896
|
${n.sessionId}`;u.current===C&&l||(u.current=C,a(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},v=[b,l,n.directory,n.sessionId,f,r,a,d],e[4]=b,e[5]=l,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=d,e[12]=w,e[13]=v):(w=e[12],v=e[13]),c.useEffect(w,v),f&&b!==f)return null;let y;e[14]!==i?(y=s.jsx(Fu,{embeddedBackgroundWorkEnabled:i}),e[14]=i,e[15]=y):y=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Gd,{}),e[16]=m):m=e[16];let p;e[17]!==i||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(p=s.jsx(Hd,{active:i,messagesEnabled:!0,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=i,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=p):p=e[20];let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(_u,{}),e[21]=S):S=e[21];let g;return e[22]!==y||e[23]!==p?(g=s.jsxs(s.Fragment,{children:[y,m,p,S]}),e[22]=y,e[23]=p,e[24]=g):g=e[24],g};function vN({apis:t}){c.useEffect(()=>{nh("App:mounted"),rh()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Gt(O=>O.initializeApp),n=Gt(O=>O.isInitialized),r=Gt(O=>O.isConnected),i=Gt(O=>O.providers.length),o=Gt(O=>O.agents.length),l=Gt(O=>O.loadProviders),a=Gt(O=>O.loadAgents),d=tt(O=>O.error),u=tt(O=>O.clearError),h=ns(O=>O.currentDirectory),f=ns(O=>O.setDirectory),x=ns(O=>O.isSwitchingDirectory),[b,w]=c.useState(!1),v=In(O=>O.refreshStatus),y=_i(O=>O.refreshStatus),[m,p]=c.useState(()=>t.runtime.isVSCode),[S,g]=c.useState(!1),[C,k]=c.useState(!1),[j,D]=c.useState(0),[I,A]=c.useState(0),[P,T]=c.useState(!1),L=Pe(O=>O.wideChatLayoutEnabled),$=Pe(O=>O.mobileKeyboardMode),K=c.useMemo(()=>xn(),[]),F=Ca(O=>O.setPlanModeEnabled),[W,N]=c.useState(()=>ul()),[R,E]=c.useState(()=>{const O=fl();return O!==null?ml({isDesktopShell:!0,bootOutcome:O}):null}),X=c.useRef(!1),J=c.useMemo(()=>bN(),[]),re=!J||S,fe=c.useMemo(()=>yN(),[]);c.useEffect(()=>(hl(b),bd(b),()=>{hl(!1),bd(!1)}),[b]),c.useEffect(()=>{oh($)},[$]),c.useEffect(()=>{p(t.runtime.isVSCode)},[t.runtime.isVSCode]),c.useEffect(()=>Qr(O=>{qh(O),A(Q=>Q+1),k(!1),D(Q=>Q+1)}),[]);const ne=_l(O=>{const Q=qt();return Object.values(O.runsByOriginalSessionID).filter(le=>le.status==="running"&&le.runtimeKey===Q).map(le=>`${le.originalSessionID}:${le.phase}:${le.lastForwardedMessageID??""}:${le.expectedAssistantParentID??""}`).sort().join("|")});c.useEffect(()=>{if(J)return;const O=qt(),Q=Object.values(_l.getState().runsByOriginalSessionID).filter(le=>le.status==="running"&&le.runtimeKey===O);for(const le of Q)fx(le.originalSessionID)},[ne,J,I]),c.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",L),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[L]),c.useEffect(()=>(pl(t),()=>pl(null)),[t]),c.useEffect(()=>{J||(v(t.github,{force:!0}),y(t.linear,{force:!0}))},[t.github,t.linear,J,r,v,y,I]),mx();const te=W==="valid",ue=R?.screen==="main";c.useEffect(()=>{if(!ih({isDesktopShell:K,isInitialized:n,bootOutcomeKnown:te,bootViewIsMain:ue}))return;const O=setTimeout(()=>{const Q=document.getElementById("initial-loading");Q&&(Q.classList.add("fade-out"),setTimeout(()=>{Q.remove()},300))},150);return()=>clearTimeout(O)},[K,n,te,ue]),c.useEffect(()=>{if(!K||W!=="malformed")return;const O=document.getElementById("initial-loading");O&&(O.textContent="Desktop startup failed — please restart the app.")},[K,W]),c.useEffect(()=>{if(K)return;const O=setTimeout(()=>{const Q=document.getElementById("initial-loading");Q&&!n&&(Q.classList.add("fade-out"),setTimeout(()=>{Q.remove()},300))},5e3);return()=>clearTimeout(O)},[K,n]),c.useEffect(()=>{let O=!1;return(async()=>{const le=await ls("/health",{method:"GET"}).catch(()=>null);if(!le||!le.ok||O)return;const H=await le.json().catch(()=>null);if(!H||O)return;const me=H.planModeExperimentalEnabled;F(me===!0||me===1||me==="1"||me==="true")})(),()=>{O=!0}},[F]),c.useEffect(()=>{m||e()},[e,m]),c.useEffect(()=>{if(m||n)return;let O=!0,Q,le=0;const H=10,me=1e3,ge=async()=>{if(!O)return;if(le>=H){k(!0);return}const oe=Gt.getState();if(oe.isInitialized){k(!1);return}le+=1,await oe.initializeApp();const de=Gt.getState();if(!O)return;if(de.isInitialized){k(!1);return}if(le>=H){k(!0);return}const _=Math.min(me*Math.pow(2,le-1),16e3);Q=setTimeout(ge,_)};return Q=setTimeout(ge,me),()=>{O=!1,Q&&clearTimeout(Q)}},[j,n,m]),c.useEffect(()=>{n&&k(!1)},[n]),c.useEffect(()=>{if(!C)return;const O=document.getElementById("initial-loading");O&&(O.classList.add("fade-out"),setTimeout(()=>{O.remove()},300))},[C]),c.useEffect(()=>{if(m||!r||i>0&&o>0)return;let O=!0,Q=0;const le=15,H=async()=>{const ge=Gt.getState();if(!(ge.providers.length>0&&ge.agents.length>0))try{ge.providers.length===0&&await l({source:"startupRecovery"}),Gt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};H();const me=setInterval(()=>{if(O){if(++Q>=le){clearInterval(me);return}H()}},2e3);return()=>{O=!1,clearInterval(me)}},[r,m,a,l,i,o]),c.useEffect(()=>{x||m||r&&Cn.setDirectory(h)},[h,x,r,m]),c.useEffect(()=>{if(!J||typeof window>"u")return;const O=H=>{g(H?.visible===!0)},Q=H=>{if(H.origin!==window.location.origin||H.source!==window.parent)return;const me=H.data;me?.type===Gu&&O(me.payload)},le=window;return le.__openchamberSetEmbeddedVisibility=O,window.addEventListener("message",Q),nb(),()=>{window.removeEventListener("message",Q),le.__openchamberSetEmbeddedVisibility===O&&delete le.__openchamberSetEmbeddedVisibility}},[J]),c.useEffect(()=>{!J?.directory||m||h!==J.directory&&f(J.directory,{showOverlay:!1})},[h,J,m,f]),c.useEffect(()=>{if(!J||typeof window>"u")return;const O=Q=>{Q.storageArea===window.localStorage&&Q.key==="ui-store"&&Pe.persist.rehydrate()};return window.addEventListener("storage",O),()=>{window.removeEventListener("storage",O)}},[J]),c.useEffect(()=>{if(typeof window>"u")return;const O=Q=>{const le=Q.detail,H=typeof le?.sessionId=="string"?le.sessionId.trim():"";if(!H)return;const me=typeof le?.directory=="string"&&le.directory.trim().length>0?le.directory.trim():null;tt.getState().setCurrentSession(H,me)};return window.addEventListener("openchamber:open-session",O),()=>window.removeEventListener("openchamber:open-session",O)},[]),c.useEffect(()=>{if(typeof window>"u")return;const O=()=>{_n("desktop_open_draft_mini_chat_window",{directory:"",projectId:null})};return window.addEventListener("openchamber:open-mini-chat",O),()=>window.removeEventListener("openchamber:open-mini-chat",O)},[]),c.useEffect(()=>{if(typeof window>"u")return;const O=()=>{const Q=tt.getState().currentSessionId;Q&&wu(Q)};return window.addEventListener("focus",O),()=>window.removeEventListener("focus",O)},[]),c.useEffect(()=>{if(typeof window>"u")return;const O=Q=>{const le=Q.detail,H=typeof le?.directory=="string"&&le.directory.trim().length>0?le.directory.trim():null,me=typeof le?.projectId=="string"&&le.projectId.trim().length>0?le.projectId.trim():null,ge=!!(H||me);Pe.getState().setSessionSwitcherOpen(!1),tt.getState().openNewSessionDraft({target:ge?"project":"chat",selectedProjectId:ge?me:null,directoryOverride:ge?H:null,preserveDirectoryOverride:!!H})};return window.addEventListener("openchamber:open-draft-session",O),()=>window.removeEventListener("openchamber:open-draft-session",O)},[]),c.useEffect(()=>{typeof window>"u"||!n||x||X.current||(X.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,x]),hx({enabled:re}),iN({enabled:re}),cN(h||null),px(),fN(),gx(),Ex(),Yh();const Se=c.useCallback(()=>{w(O=>!O)},[]);O5(Se),G5(),J5(!J),c.useEffect(()=>{if(J)return;const O=()=>w(Q=>!Q);return window.addEventListener("openchamber:memory-debug-toggle",O),()=>window.removeEventListener("openchamber:memory-debug-toggle",O)},[J]),c.useEffect(()=>{J||d&&setTimeout(()=>u(),5e3)},[u,J,d]),c.useEffect(()=>{if(!K||W!=="not-injected")return;let O=!1,Q=0;const le=200,H=2e3,me=50,ge=()=>{if(O)return;Q++;const oe=ul();if(oe!=="not-injected"){if(O=!0,N(oe),oe==="valid"){const _=fl();_&&E(ml({isDesktopShell:!0,bootOutcome:_}))}return}const de=Math.min(le*Math.pow(1.1,Q),H);if(Q>=me){const _=document.getElementById("initial-loading");_&&!_.textContent?.includes("taking longer")&&(_.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(ge,de)};return window.setTimeout(ge,le),()=>{O=!0}},[K,W]);const we=c.useCallback(async()=>{if(ah({isDesktopShell:xn(),isDesktopLocalOriginActive:Vo()})){await lh();return}window.location.reload()},[]),ye=c.useCallback(async()=>{if(!P){k(!1),T(!0);try{await Gt.getState().initializeApp()}finally{T(!1)}Gt.getState().isInitialized||D(O=>O+1)}},[P]),Ae=O=>{if(O.screen==="recovery")return O.variant};if(K&&R&&R.screen!=="main"){if(R.screen==="chooser")return s.jsx(As,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Dd,{mode:"first-launch",localAvailable:R.localAvailable!==!1,onCliAvailable:we,onChooseRemote:()=>{}})})})});const O=Ae(R),Q=R.screen==="recovery"&&"url"in R?R.url:void 0;return s.jsx(As,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Dd,{mode:"recovery",recoveryVariant:O,recoveryHostUrl:Q,recoveryHostLabel:void 0,localAvailable:R.localAvailable!==!1,onCliAvailable:we})})})})}if(J)return s.jsx(As,{children:s.jsx(Ll,{sdk:Cn.getSdkClient(),directory:h||"",children:s.jsx($l,{apis:t,children:s.jsx(Vi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:"h-full text-foreground bg-background",children:[s.jsx(wN,{embeddedSessionChat:J,isVSCodeRuntime:m,embeddedBackgroundWorkEnabled:re}),s.jsx(zl,{}),s.jsx(Wl,{})]})})})},I)});if(fe)return s.jsx(As,{children:s.jsx(pN,{})});if(C&&!n&&!m&&!J)return s.jsx(As,{children:s.jsx(xN,{onRetry:()=>{ye()},isRetrying:P})});const pe=!n&&!K;return s.jsx(As,{children:s.jsx(Ll,{sdk:Cn.getSdkClient(),directory:h||"",children:s.jsx($l,{apis:t,children:s.jsx(n5,{children:s.jsx(Vi,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:K?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(Fu,{embeddedBackgroundWorkEnabled:re}),s.jsx(Gd,{}),s.jsx(TC,{}),s.jsx(Qh,{ready:n&&(!K||te&&ue)}),s.jsx(_u,{}),s.jsx(zl,{}),s.jsx(Wl,{}),!pe&&s.jsxs(s.Fragment,{children:[s.jsx(Xh,{}),s.jsx(gN,{}),b&&s.jsx(p5,{onClose:()=>w(!1)})]})]})})})})},I)})}function SN(t){return t.isAboutDialogOpen}function jN(t){return t.setAboutDialogOpen}function kN(t){return t.currentDirectory}function CN(t){return t.currentSessionId}function NN(t){return t.setCurrentSession}const AN=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();bx();ch().then(()=>{Promise.all([dh(),yx()]).catch(t=>{console.error("[main] settings init failed:",t)}),wx(),vx(),Sx()}).catch(t=>{console.error("[main] appearance init failed:",t)});const dm=document.getElementById("root");if(!dm)throw new Error("Root element not found");jx();Mm.createRoot(dm).render(s.jsx(mt.StrictMode,{children:s.jsx(kx,{children:s.jsx(Cx,{children:s.jsx(Nx,{children:s.jsx(Ax,{children:s.jsx(vN,{apis:AN})})})})})}));const qN=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{My as W,jy as a,GN as b,ff as g,qN as m,Ry as u,uf as v};
|