@openchamber/web 1.18.3 → 1.18.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-DbUi6I9s.js → CodeMirrorCommentWidgets-4qZbrEXU.js} +1 -1
- package/dist/assets/{CommitSection-Jc2_hNPE.js → CommitSection-MJmntVPJ.js} +1 -1
- package/dist/assets/{DiagramEditor-PCrYHBko.js → DiagramEditor-jnG3Hbxg.js} +1 -1
- package/dist/assets/{DiagramView-CndEcZNu.js → DiagramView-CFXxgg_a.js} +1 -1
- package/dist/assets/{DiffView-DEGlNjMH.js → DiffView-DZIoOnV7.js} +1 -1
- package/dist/assets/{FilesView-CzUgIvUm.js → FilesView-BKL6YlKG.js} +1 -1
- package/dist/assets/{GitView-C-n17voy.js → GitView-DBFrDDBv.js} +1 -1
- package/dist/assets/{JsonTreeView-BYcgdTOQ.js → JsonTreeView-DLW2Wy1g.js} +1 -1
- package/dist/assets/MarkdownImageGallery-DKIylIK7.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CLv8hxvv.js +12 -0
- package/dist/assets/{OnboardingScreen-BmN0lhk4.js → OnboardingScreen-D2Y6djMw.js} +1 -1
- package/dist/assets/{PatchDiff-Bn7bfgUv.js → PatchDiff-BuLPx7AN.js} +1 -1
- package/dist/assets/{PierreDiffViewer-D1fWvrUn.js → PierreDiffViewer-BHm4Yr0X.js} +1 -1
- package/dist/assets/{PlanView-CWM0iyFk.js → PlanView-ZYEJn8A_.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-Cez-9xRh.js → SessionSwitcherDropdown-rro-SsaO.js} +1 -1
- package/dist/assets/{SettingsView-Bl1drwPw.js → SettingsView-5RmswFZe.js} +1 -1
- package/dist/assets/{SettingsWindow-DL5axjDZ.js → SettingsWindow-BZhAYFdS.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BtIJkFno.js → ToolOutputDialog-Za6V4VMJ.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-i3PQo6_0.js → ToolPartDiffPreview-BL-9ixyC.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-DkcusvMa.js → VirtualizedFileDiff-CwGocYQd.js} +1 -1
- package/dist/assets/{WalkthroughView-Cc5Hd6P5.js → WalkthroughView-5DyvN03T.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-xPena3W2.js → computeVirtualFileMetrics-Da00Jg7M.js} +1 -1
- package/dist/assets/{contextPanelEmbeddedChat-tQekJUAF.js → contextPanelEmbeddedChat-B-bSg3P5.js} +1 -1
- package/dist/assets/index-BzIpNlNE.css +1 -0
- package/dist/assets/{index-Crz1YOFl.js → index-C0yNhuZw.js} +1 -1
- package/dist/assets/{index-iFY_N5aO.js → index-DRpChWux.js} +1 -1
- package/dist/assets/{isDiffPlainText-Dudf-dWx.js → isDiffPlainText-D9YpoLrV.js} +1 -1
- package/dist/assets/{isFilePlainText-DS4QV1dd.js → isFilePlainText-gTibdNIe.js} +1 -1
- package/dist/assets/{main-C0DyIwTb.js → main-D7UcL3VQ.js} +2 -2
- package/dist/assets/{main-CAxX6DAN.js → main-DPMd2iKS.js} +4 -4
- package/dist/assets/markdownCore-DDrHVneM.js +2 -0
- package/dist/assets/{miniChat-CGfrxKpJ.js → miniChat-O_GVoEbc.js} +2 -2
- package/dist/assets/{mobile-DEmhwNcV.js → mobile-Br4TtAqc.js} +2 -2
- package/dist/assets/{patchFileDiff-C5D1OPCa.js → patchFileDiff-KNkxM1C1.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-Dpbswpom.js → renderElectronMiniChatApp-CJpdxTT1.js} +2 -2
- package/dist/assets/{renderMobileApp-B5HA4qbi.js → renderMobileApp-toj9cXoh.js} +4 -4
- package/dist/assets/{runtimeEndpointReset-cbahJ3hD.js → runtimeEndpointReset-BVmispdD.js} +2 -2
- package/dist/assets/{scheduledTasksApi-BxgGWTL8.js → scheduledTasksApi-ByKya3Un.js} +1 -1
- package/dist/assets/{shikiHighlight-CmanopUB.js → shikiHighlight-C7LTbwFx.js} +1 -1
- package/dist/assets/{useAppFontEffects-sHmU5b8u.js → useAppFontEffects-BikB6enL.js} +131 -131
- package/dist/assets/{useInlineCommentController-gt56WkxJ.js → useInlineCommentController-CYPvYJDt.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-Dihw9MtL.js → vendor-codemirror-language-data-CLHw8NWn.js} +2 -2
- package/dist/assets/{web-components-BL-Ur2Tb.js → web-components-GMc3oR3i.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/dev-tunnel/client.js +20 -1
- package/server/lib/dev-tunnel/tunnel.test.js +9 -0
- package/server/lib/markdown-image-grants/DOCUMENTATION.md +36 -0
- package/server/lib/markdown-image-grants/routes.js +340 -0
- package/server/lib/markdown-image-grants/routes.test.js +221 -0
- package/server/lib/opencode/feature-routes-runtime.js +11 -0
- package/server/lib/opencode/server-startup-runtime.js +22 -1
- package/server/lib/opencode/server-startup-runtime.test.js +44 -0
- package/dist/assets/MarkdownImageGallery-DzHwkVIH.js +0 -1
- package/dist/assets/MarkdownRendererImpl-DUcIcWgs.js +0 -12
- package/dist/assets/index-CVNuER6G.css +0 -1
- package/dist/assets/markdownCore-DhfzuGXu.js +0 -2
- package/dist/assets/markdownImageAssets-BTNlRyjd.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-
|
|
2
|
-
import{f as tt,j as s,R as l,r as Ge,h as Dm}from"./vendor-react-BUCujlKS.js";import{x as $n,y as Ti,O as Hl,D as Pm,z as Em,A as Jd,r as ms,n as Ii,u as xe,B as Tm,C as er,E as Im,F as wt,G as In,H as Ri,I as Zd,J as eu,q as Mi,K as tu,L as ur,M as ko,e as fr,N as Rm,a as xn,P as Mm,Q as Om,R as Fm,S as su,m as Bn,t as Xs,T as nu,U as Bm,V as ru,W as Lm,X as Vr,l as ls,Y as rl,Z as Da,_ as _m,$ as $m,d as Hr,a0 as si,a1 as ni,a2 as zm,a3 as Kl,a4 as Um,a5 as Wm,a6 as Vm,a7 as Hm,a8 as Gl,a9 as ql,aa as Yl,ab as Ql,ac as Km,o as Xl,ad as Gm,ae as qm,af as Ym,v as Qm,w as Xm}from"./index-iFY_N5aO.js";import{_ as Js}from"./vendor-vite-runtime-DD1OZmLC.js";import{I as R,f as mt,h as ye,aQ as Gt,g as Xn,t as Ee,aR as bn,aS as gn,aT as yn,aU as vn,L as _r,V as tr,aV as pr,o as Oi,aW as Jl,aX as dt,aY as ut,aZ as ft,a_ as ou,a$ as Co,b0 as Jm,y as Je,b1 as Zm,b2 as eh,b3 as iu,b4 as th,b5 as ri,b6 as sh,b7 as nh,K as au,b8 as rh,b9 as Pa,l as Vt,ba as oh,A as lu,u as Rs,b as qt,n as Cs,aj as Lr,bb as cu,bc as ih,bd as ah,be as lh,bf as ch,p as dh,bg as du,bh as uh,bi as fh,bj as mh,bk as uu,bl as hh,bm as ph,bn as ol,bo as Fi,bp as Ea,ak as il,bq as Bi,br as Or,ae as fu,bs as Ws,bt as Vs,bu as Rn,bv as wn,bw as Sn,bx as gr,B as nt,by as mu,bz as oa,P as pi,i as Ta,j as gh,bA as hu,bB as xh,bC as pu,ac as cs,G as bh,bD as yh,bE as vh,bF as hn,bG as Li,bH as gu,bI as Ia,bJ as wh,bK as Ls,bL as _s,bM as Ds,bN as $s,bO as rs,S as Jn,bP as Kr,bQ as Zl,bR as qr,M as _i,a0 as Io,a1 as al,bS as xu,a4 as mr,bT as $i,bU as Yn,Z as ll,bV as Sh,bW as jh,ab as kh,bX as Ch,bY as Nh,bZ as Ah,ad as cl,b_ as dl,b$ as yo,c0 as bu,c1 as Dh,c2 as Ph,c3 as Ro,c4 as Eh,O as yu,c5 as Th,c6 as Zs,c7 as Ih,c8 as Rh,c9 as ia,ca as vu,cb as Mh,cc as Oh,cd as Fh,ce as ec,cf as xo,c as No,d as zi,Y as wu,cg as Su,ch as uo,ci as bo,cj as Bh,r as Us,ck as Lh,W as ul,cl as _h,cm as $h,cn as zh,co as Uh,cp as ju,cq as _n,cr as Wh,cs as Vh,ct as tc,cu as ku,cv as Hh,cw as Cu,e as to,cx as gi,cy as Kh,cz as sc,cA as hr,cB as Ra,cC as Gh,cD as qh,cE as nc,cF as Fs,cG as Nu,cH as Au,cI as Yh,cJ as oi,cK as Qh,Q as fl,N as ml,R as hl,cL as pl,cM as Ma,cN as Du,cO as Xh,cP as Pu,cQ as Jh,H as Zh,cR as rc,cS as ep,cT as oc,cU as tp,cV as sp,cW as Eu,cX as np,D as rp,cY as op,cZ as ip,c_ as ap,c$ as ic,d0 as lp,d1 as cp,C as dp,d2 as Tu,E as up,d3 as ac,d4 as fp,d5 as mp,d6 as hp,d7 as pp,d8 as gp,d9 as xp,da as Ui,a as Wi,db as bp,dc as aa,F as xi,dd as yp,de as vp,df as lc,aw as Oa,dg as Iu,_ as wp,$ as Sp,az as jp,dh as kp,J as Cp,di as Np,dj as Ap,dk as Dp,dl as Ru,dm as Mu,dn as Ou,dp as Pp,dq as Ep,dr as Tp,ds as Ip,dt as Rp,du as Mp,dv as Op,dw as Fp,dx as Bp,dy as bi,a2 as Lp,a3 as _p,dz as $p,dA as cc,dB as zp,dC as Up,dD as Wp,dE as Vp,dF as dc,dG as Hp,dH as Kp,dI as Gp,dJ as qp,dK as Yp,dL as Qp,dM as Xp,dN as Jp,dO as Zp,dP as ii,dQ as eg,dR as tg,af as sg,dS as ng,dT as rg,dU as og,dV as ig,dW as uc,dX as ag,aq as lg,ar as cg,as as dg,au as fc,av as mc,ax as Fu,ay as Bu,dY as ug,aL as fg,aM as mg,aN as hg,aO as pg,aP as gg,aH as xg,aI as bg,aJ as yg,aK as vg}from"./useAppFontEffects-sHmU5b8u.js";import{h as hc,i as Qt,n as wg,j as pc,t as Kn,k as Sg,l as la,m as jg,o as kg,U as Lu,b as gl,M as Cg,p as gc,q as yi,s as xl,v as vi,w as _u,x as Ng,y as $u,z as zu,A as Uu,P as Wu,T as Vu,B as Ag,E as Dg,F as Pg,S as xc,u as vo,N as Eg,D as Tg,W as Ig,L as bc,G as Rg,d as Mg,g as Og,f as Fa,H as Fg,I as Bg,c as Lg,e as _g,O as Hu,C as $g}from"./runtimeEndpointReset-cbahJ3hD.js";import{u as Ku,S as zg,C as Ug,W as Gu}from"./SessionSwitcherDropdown-Cez-9xRh.js";import{u as Pr,f as Wg,a as yc,s as Vg,d as Hg,b as Kg,r as Gg}from"./scheduledTasksApi-BxgGWTL8.js";import{c as xr,u as qn,d as qu,p as Yu}from"./vendor-zustand-BAGL70zf.js";import{g as qg,b as Yg,E as Qg,c as Xg,i as Jg}from"./contextPanelEmbeddedChat-tQekJUAF.js";import{f as wi,h as Yr,T as Zg,M as ex,D as Si,j as ji,P as Ba,b as tx,d as sx,k as La,i as nx}from"./vendor-dnd-kit-core-BZknOX2w.js";import{a as Qu,S as _a,v as $a,u as bl,s as rx}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as yl}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{u as ox}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{M as vc,a as wc,b as Sc,C as ix,c as ax,d as lx,S as cx,e as dx,f as ux}from"./vendor-base-ui-D_V6hAcE.js";import{d as Xu}from"./vendor-cron-parser-CUcP7OfX.js";import{u as jc,a as kc,m as Cc}from"./vendor-framer-motion-CRSgBxjL.js";function Ju(t){const e=tt.c(5),{className:n}=t,o=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let i,c,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),c=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(R,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=i,e[1]=c,e[2]=a):(i=e[0],c=e[1],a=e[2]);let d;return e[3]!==o?(d=s.jsxs("span",{"aria-hidden":"true",className:o,children:[i,c,a]}),e[3]=o,e[4]=d):d=e[4],d}function Nc(t){const e=tt.c(14);let n,r,o,i;e[0]!==t?({size:o,className:n,style:i,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=o,e[4]=i):(n=e[1],r=e[2],o=e[3],i=e[4]);const c=typeof o=="number"?`${o}px`:o,a=typeof o=="number"?`${o}px`:o;let d;e[5]!==i||e[6]!==c||e[7]!==a?(d={width:c,height:a,...i},e[5]=i,e[6]=c,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("path",{d:"M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z"}),e[9]=u):u=e[9];let h;return e[10]!==n||e[11]!==r||e[12]!==d?(h=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:n,style:d,...r,children:u}),e[10]=n,e[11]=r,e[12]=d,e[13]=h):h=e[13],h}const fx="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",mx="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",ca=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?fx:t.id==="terminal"?mx:void 0}),Ac=t=>{const e=tt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:o}=t,[i,c]=l.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||o;if(u&&!i){let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>c(!0),e[2]=g):g=e[2];let b;return e[3]!==u?(b=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:g}),e[3]=u,e[4]=b):b=e[4],b}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=ye("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},hx=t=>{const e=tt.c(75),{directory:n,className:r}=t,{t:o}=mt(),i=Pr(px),c=Pr(gx),a=Pr(xx),d=Pr(bx),u=Pr(yx),h=Pr(vx),f=Pr(wx);let g,b;e[0]!==u?(g=()=>{u()},b=[u],e[0]=u,e[1]=g,e[2]=b):(g=e[1],b=e[2]),l.useEffect(g,b);const S=$n()&&Ti();let v;e:{let Y;e[3]!==c||e[4]!==i?(Y=c.find(Q=>Q.id===i)??c.find(Sx)??c[0]??Hl[0],e[3]=c,e[4]=i,e[5]=Y):Y=e[5];const we=Y;if(we){let Q;e[6]!==we?(Q=ca(we),e[6]=we,e[7]=Q):Q=e[7],v=Q;break e}let me;e[8]===Symbol.for("react.memo_cache_sentinel")?(me=ca(Hl[0]),e[8]=me):me=e[8],v=me}const p=v;if(!S||!n||c.length===0)return null;let m;e[9]!==n?(m=async Y=>{await Em(n,Y.id,Y.appName)||await Jd(n,Y.appName)},e[9]=n,e[10]=m):m=e[10];const x=m;let w;e[11]!==x||e[12]!==f?(w=async Y=>{await f(Y.id),await x(Y)},e[11]=x,e[12]=f,e[13]=w):w=e[13];const j=w;let N;e[14]!==n||e[15]!==o?(N=async()=>{(await Xn(n)).ok&&Ee.success(o("openInApp.toast.pathCopied"))},e[14]=n,e[15]=o,e[16]=N):N=e[16];const A=N;let k;e[17]!==r?(k=ye("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]=k):k=e[18];let C;e[19]!==x||e[20]!==p?(C=()=>{x(p)},e[19]=x,e[20]=p,e[21]=C):C=e[21];const P=d&&"animate-pulse";let D;e[22]!==P?(D=ye("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",P),e[22]=P,e[23]=D):D=e[23];let F;e[24]!==p.label||e[25]!==o?(F=o("openInApp.actions.openInAria",{app:p.label}),e[24]=p.label,e[25]=o,e[26]=F):F=e[26];let B;e[27]!==p.fallbackIconDataUrl||e[28]!==p.iconDataUrl||e[29]!==p.label?(B=s.jsx(Ac,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}),e[27]=p.fallbackIconDataUrl,e[28]=p.iconDataUrl,e[29]=p.label,e[30]=B):B=e[30];let E;e[31]!==D||e[32]!==F||e[33]!==B||e[34]!==C?(E=s.jsx("button",{type:"button",onClick:C,className:D,"aria-label":F,children:B}),e[31]=D,e[32]=F,e[33]=B,e[34]=C,e[35]=E):E=e[35];let _;e[36]===Symbol.for("react.memo_cache_sentinel")?(_=ye("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 W;e[37]!==o?(W=o("openInApp.actions.chooseAppAria"),e[37]=o,e[38]=W):W=e[38];let V;e[39]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(R,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=V):V=e[39];let K;e[40]!==W?(K=s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:_,"aria-label":W,children:V})}),e[40]=W,e[41]=K):K=e[41];let y;e[42]!==A?(y=()=>{A()},e[42]=A,e[43]=y):y=e[43];let I;e[44]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(R,{name:"file-copy",className:"h-4 w-4"}),e[44]=I):I=e[44];let $;e[45]!==o?($=o("openInApp.actions.copyPath"),e[45]=o,e[46]=$):$=e[46];let z;e[47]!==$?(z=s.jsx("span",{className:"typography-ui-label text-foreground",children:$}),e[47]=$,e[48]=z):z=e[48];let G;e[49]!==y||e[50]!==z?(G=s.jsxs(Gt,{className:"flex items-center gap-2",onClick:y,children:[I,z]}),e[49]=y,e[50]=z,e[51]=G):G=e[51];let J;e[52]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(gn,{}),e[52]=J):J=e[52];let Z;if(e[53]!==c||e[54]!==j||e[55]!==p.id){let Y;e[57]!==j||e[58]!==p.id?(Y=we=>{const me=ca(we);return s.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{j(we)},children:[s.jsx(Ac,{label:we.label,iconDataUrl:we.iconDataUrl,fallbackIconDataUrl:me.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:we.label}),p.id===we.id?s.jsx(R,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},we.id)},e[57]=j,e[58]=p.id,e[59]=Y):Y=e[59],Z=c.map(Y),e[53]=c,e[54]=j,e[55]=p.id,e[56]=Z}else Z=e[56];let re;e[60]!==a||e[61]!==h||e[62]!==o?(re=a?s.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(R,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=h,e[62]=o,e[63]=re):re=e[63];let ee;e[64]!==G||e[65]!==Z||e[66]!==re?(ee=s.jsxs(yn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[G,J,Z,re]}),e[64]=G,e[65]=Z,e[66]=re,e[67]=ee):ee=e[67];let he;e[68]!==K||e[69]!==ee?(he=s.jsxs(vn,{children:[K,ee]}),e[68]=K,e[69]=ee,e[70]=he):he=e[70];let be;return e[71]!==E||e[72]!==he||e[73]!==k?(be=s.jsxs("div",{className:k,children:[E,he]}),e[71]=E,e[72]=he,e[73]=k,e[74]=be):be=e[74],be};function px(t){return t.selectedAppId}function gx(t){return t.availableApps}function xx(t){return t.isCacheStale}function bx(t){return t.isScanning}function yx(t){return t.initialize}function vx(t){return t.loadInstalledApps}function wx(t){return t.selectApp}function Sx(t){return t.id===Pm}const ki=new Map,za=new Set,Zu=()=>{for(const t of za)t()},da=(t,e)=>{const n=t.trim();n&&(e.length===0?ki.delete(n):ki.set(n,[...e]),Zu())},jx=t=>{ki.delete(t.trim())&&Zu()},ef=[],kx=t=>ki.get(t.trim())??ef,Cx=t=>(za.add(t),()=>{za.delete(t)}),Nx=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=()=>kx(t),e[0]=t,e[1]=n):n=e[1],l.useSyncExternalStore(Cx,n,Ax)};function Ax(){return ef}const Dx=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Px=["dev","start","preview","serve"];async function Ex(t,e,n){if(!t)return null;const r=Rx(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const o=Mx(n);if(o){const i=await Ox(t);return{command:`${i==="npm"?"npm run":i==="yarn"?"yarn":i==="pnpm"?"pnpm":i==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await Tx(t)){const o=await Ix(),i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${i}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${i}/`}}return null}async function Tx(t){const e=`${t}/index.html`,n=await Ci(e,t);return typeof n=="string"&&n.trim().length>0}async function Ix(){try{const t=await ms("/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 Rx(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Px.some(o=>n.includes(o)))return e}return null}function Mx(t){for(const{pattern:e}of Dx)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Ox(t){const e=await Ci(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.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,o]of n){const i=await Ci(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function Ci(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await ms(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=Ii()?.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 ms(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Fx(t){try{const e=await Ci(`${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 Bx=(t,e,n)=>new Promise(r=>{let o=!1,i=null,c=null;const a=d=>{o||(o=!0,c&&clearTimeout(c),i?.close(),r(d))};i=t.connect(e,{onEvent:d=>{(d.type==="exit"||d.type==="snapshot"&&d.status==="exited")&&a(!0)},onError:(d,u)=>{u&&a(!0)}}),o?i.close():c=setTimeout(()=>a(!1),n)}),Ys="__openchamber_auto_discover_preview__",Lx=15e3,_x=3e3,$x=t=>{let e="";for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(e+=t[n])}return e},zx=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}},tf=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:o=!1})=>{const{t:i}=mt(),{currentTheme:c}=_r(),{terminal:a,runtime:d}=tr(),{isMobile:u}=pr(),h=l.useMemo(()=>$n(),[]),f=hc(X=>X.instances),g=hc(X=>X.load),b=xe(X=>X.terminalShell),S=xe(X=>X.terminalLoginShells.includes(X.terminalShell)),v=xe(X=>X.setSettingsPage),p=xe(X=>X.setSettingsDialogOpen),m=xe(X=>X.setSettingsProjectsSelectedId),x=xe(X=>X.openContextPreview),w=Qt(X=>X.ensureDirectory),j=Qt(X=>X.setTabLabel),N=Qt(X=>X.setTabIconKey),A=Qt(X=>X.setActiveTab),k=Qt(X=>X.setConnecting),C=Qt(X=>X.setTabSessionId),P=Qt(X=>X.setTabPreviewUrl),D=Qt(X=>X.projectActionRuns),F=Qt(X=>X.setProjectActionRun),B=Qt(X=>X.updateProjectActionRunStatus),E=Qt(X=>X.removeProjectActionRun),[_,W]=l.useState([]),[V,K]=l.useState(null),[y,I]=l.useState(!1),$=l.useRef({}),z=l.useRef({}),G=l.useRef({}),J=l.useRef({}),Z=l.useRef(new Set),re=l.useRef(0),ee=t?.id??null,he=t?.path??"",be=l.useMemo(()=>ee?{id:ee,path:he}:null,[ee,he]);l.useEffect(()=>{h&&g().catch(()=>{})},[h,g]);const Y=l.useCallback(async X=>{await Oi(X)},[]),we=l.useCallback(async()=>{if(!be)return;const X=re.current+1;re.current=X,I(!0);try{const le=await Jl(be);if(re.current!==X)return;const se=le.actions;W(se),K(T=>T===Ys||T&&se.some(ie=>ie.id===T)?T:null)}catch{if(re.current!==X)return}finally{re.current===X&&I(!1)}},[be]),me=l.useMemo(()=>wg(e||be?.path||""),[e,be?.path]),Q=l.useMemo(()=>V?_.find(X=>X.id===V)??null:null,[_,V]),pe=l.useMemo(()=>({id:Ys,name:i("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[i]),ve=!u,Te=l.useMemo(()=>ve?[pe,..._]:_,[_,pe,ve]);l.useEffect(()=>{we()},[we]),l.useEffect(()=>{if(typeof window>"u")return;const X=le=>{const se=le.detail;ee&&(se?.projectId&&se.projectId!==ee||we())};return window.addEventListener(pc,X),()=>{window.removeEventListener(pc,X)}},[we,ee]),l.useEffect(()=>{V&&(V===Ys&&ve||_.some(X=>X.id===V)||K(null))},[_,ve,V]),l.useEffect(()=>{const X=se=>{delete J.current[se];const T=z.current[se];if(!T||T.openedUrl)return;const ie=Qt.getState(),je=ie.projectActionRuns[se];if(!je)return;const Pe=T.announced;if(Pe.length!==0){if(T.openedUrl=!0,ie.updateProjectActionRunStatus(se,"running"),Pe.length===1){da(je.directory,[]),P(je.directory,je.tabId,Pe[0],{locked:!1,autoOpened:!0}),x(je.directory,Pe[0]);return}T.offering=!0,da(je.directory,Pe),xe.getState().openContextSurface(je.directory,"browser"),Ee.info(i("projectActions.toast.multipleServers"))}},le=()=>{const se=Qt.getState(),T=se.sessions,ie=se.projectActionRuns;for(const[je,Pe]of Object.entries(ie)){const Be=T.get(Pe.directory)?.tabs.find(it=>it.id===Pe.tabId);if(!Be||Be.terminalSessionId!==Pe.sessionId){E(je);continue}const Fe=z.current[je]??{lastSeenChunkId:null,openedUrl:!1,tail:"",openInPreview:!1,announced:[],offering:!1};z.current[je]=Fe;const Ye=Te.find(it=>it.id===Pe.actionId),at=se.getBuffer(Pe.directory,Pe.tabId).chunks;if(!Ye||at.length===0)continue;const st=at.filter(it=>Fe.lastSeenChunkId===null||it.id>Fe.lastSeenChunkId);if(st.length===0)continue;const ct=st.map(it=>it.data).join(""),bt=`${Fe.tail}${ct}`;if(Fe.openInPreview&&(!Fe.openedUrl||Fe.offering)){const it=jg(bt),Et=Fe.announced.length;for(const Dt of it)Fe.announced.includes(Dt)||Fe.announced.push(Dt);const Ft=Fe.announced.length-Et;Fe.offering&&Ft>0?da(Pe.directory,Fe.announced):!Fe.openedUrl&&Et===0&&Fe.announced.length>0&&(window.clearTimeout(J.current[je]),J.current[je]=window.setTimeout(()=>X(je),_x))}const rt=!Fe.openedUrl&&Ye.autoOpenUrl===!0&&!Fe.openInPreview?kg(bt):null,gt=st[st.length-1]?.id??Fe.lastSeenChunkId;if(Fe.lastSeenChunkId=gt,Fe.tail=bt.slice(-512),rt)if(Fe.openedUrl=!0,Fe.openInPreview){const it=ie[je];it&&(P(it.directory,it.tabId,rt,{locked:!1,autoOpened:!1}),it.status==="waiting-for-preview"&&B(je,"running"),window.clearTimeout(J.current[je]),delete J.current[je],x(it.directory,rt))}else Y(rt),Ee.success(i("projectActions.toast.openedUrlFromOutput"));z.current[je]=Fe}for(const je of Object.keys(z.current))ie[je]||(delete z.current[je],window.clearTimeout(J.current[je]),delete J.current[je])};return le(),Qt.subscribe((se,T)=>{(se.sessions!==T.sessions||se.buffers!==T.buffers)&&le()})},[Te,x,Y,D,E,P,i,B]);const ke=l.useCallback(async(X,le={})=>{if(!me)throw new Error(i("projectActions.error.noActiveDirectory"));const se=Kn(me,X.id);w(me);const T=Qt.getState(),ie=T.getDirectoryState(me);let je=$.current[se]||null;const Pe=je?!!ie?.tabs.some(Fe=>Fe.id===je):!1;(!je||!Pe)&&(je=T.createTab(me),$.current[se]=je),j(me,je,`Action: ${X.name}`),N(me,je,X.icon||"play"),A(me,je),le.revealTerminal!==!1&&xe.getState().openContextPanelTab(me,{mode:"terminal"});const Be=Qt.getState().getDirectoryState(me)?.tabs.find(Fe=>Fe.id===je);return{key:se,tabId:je,sessionId:Be?.terminalSessionId??null}},[w,me,A,N,j,i]),Ie=l.useCallback(async X=>{if(d.isVSCode||!o&&u)return;if(!me){Ee.error(i("projectActions.error.noActiveDirectoryForAction"));return}const le=Kn(me,X.id),se=D[le];if(!(se&&se.status==="running")&&!Z.current.has(le)){Z.current.add(le);try{const T=X.id===Ys?await(async()=>{const[rt,gt]=await Promise.all([Jl({id:be?.id??"",path:me}),Fx(me)]),it=await Ex(me,rt.actions,gt);if(!it)throw new Error(i("contextPanel.preview.noDevServer"));return{id:Ys,name:i("projectActions.actions.autoDiscover"),command:it.command,icon:"scan-2",autoOpenUrl:!0,openUrl:it.previewUrlHint||""}})():X,ie=T.autoOpenUrl===!0&&(T.openUrl||"").trim().length>0,je=!ie&&X.id!==Ys,{key:Pe,tabId:U,sessionId:Be}=await ke(T,{revealTerminal:je});let Fe=Be;if(!Fe){k(me,U,!0);try{Fe=(await a.createSession({cwd:me,sessionId:U,shell:b,loginShell:S,themeMode:c.metadata.variant==="light"?"light":"dark",terminalBackground:c.colors.surface.background,terminalForeground:c.colors.syntax.base.foreground})).sessionId,C(me,U,Fe)}finally{k(me,U,!1)}}if(!Fe)throw new Error(i("projectActions.error.failedToCreateTerminalSession"));G.current[Pe]?.(),k(me,U,!0);const Ye=a.connect(Fe,{onEvent:rt=>{rt.type==="snapshot"&&(Qt.getState().replaceBuffer(me,U,rt.data??"",rt.sequence??0),Qt.getState().setConnecting(me,U,!1)),rt.type==="data"&&typeof rt.data=="string"&&rt.data.length>0&&Qt.getState().appendToBuffer(me,U,rt.data,rt.sequence,rt.replayData),rt.type==="exit"&&(Qt.getState().setTabLifecycle(me,U,"exited"),Qt.getState().setConnecting(me,U,!1),Qt.getState().removeProjectActionRun(Pe),delete z.current[Pe],G.current[Pe]?.(),delete G.current[Pe],window.clearTimeout(J.current[Pe]),delete J.current[Pe])},onError:(rt,gt)=>{Qt.getState().setConnecting(me,U,!1),gt&&(Qt.getState().setTabLifecycle(me,U,"exited"),Qt.getState().setTabSessionId(me,U,null),Qt.getState().removeProjectActionRun(Pe))}});G.current[Pe]=Ye.close;const at=T.autoOpenUrl===!0&&h&&(T.desktopOpenSshForward||"").trim().length>0,st=T.autoOpenUrl?zx(T.openUrl):null,ct=T.autoOpenUrl&&h?Sg(T.desktopOpenSshForward,f):null;F({key:Pe,directory:me,actionId:T.id,tabId:U,sessionId:Fe,status:T.id===Ys&&!st?"waiting-for-preview":"running"}),window.clearTimeout(J.current[Pe]),delete J.current[Pe],T.id===Ys&&!st&&(J.current[Pe]=window.setTimeout(()=>{const rt=Qt.getState(),gt=rt.projectActionRuns[Pe];rt.updateProjectActionRunStatus(Pe,"running"),gt&&(rt.setActiveTab(gt.directory,gt.tabId),xe.getState().openContextPanelTab(gt.directory,{mode:"terminal"})),delete J.current[Pe]},Lx)),z.current[Pe]={lastSeenChunkId:null,openedUrl:!!ct||!!st||ie,tail:"",openInPreview:T.id===Ys,announced:[],offering:!1};const bt=$x(T.command.trim().replace(/\r\n|\r/g,`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WalkthroughView-5DyvN03T.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-BikB6enL.js","assets/index-DRpChWux.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/vendor-zustand-BAGL70zf.js","assets/index-BzIpNlNE.css","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-D_V6hAcE.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-DKpLs02S.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-B-bSg3P5.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-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-DUOssd4j.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-DSzLbZiS.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-Bbw3D7r0.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BjbBRsUA.js","assets/vendor-codemirror-lang-json-ryCw7nab.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-VgNqFSH-.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-B3Qe3OpS.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-FGQydhTc.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CLHw8NWn.js","assets/vendor-codemirror-lang-python-N414WYK-.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-ARAOgp1x.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CRSgBxjL.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/PierreDiffViewer-BHm4Yr0X.js","assets/web-components-GMc3oR3i.js","assets/computeVirtualFileMetrics-Da00Jg7M.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/VirtualizedFileDiff-CwGocYQd.js","assets/isDiffPlainText-D9YpoLrV.js","assets/vendor-diff-C3JhlQdm.js","assets/useInlineCommentController-CYPvYJDt.js","assets/runtimeEndpointReset-BVmispdD.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/patchFileDiff-KNkxM1C1.js","assets/SessionSwitcherDropdown-rro-SsaO.js","assets/scheduledTasksApi-ByKya3Un.js","assets/vendor-cron-parser-CUcP7OfX.js","assets/vendor-luxon-BZ0puJYg.js","assets/DiffView-DZIoOnV7.js","assets/FilesView-BKL6YlKG.js","assets/shikiHighlight-C7LTbwFx.js","assets/vendor-codemirror-search-8kyQdB3f.js","assets/vendor-replit-codemirror-vim-B0Ecqnlh.js","assets/JsonTreeView-DLW2Wy1g.js","assets/Virtualizer-X_7XPoTH.js","assets/isFilePlainText-gTibdNIe.js","assets/DiagramEditor-jnG3Hbxg.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/CodeMirrorCommentWidgets-4qZbrEXU.js","assets/GitView-DBFrDDBv.js","assets/CommitSection-MJmntVPJ.js","assets/PlanView-ZYEJn8A_.js","assets/DiagramView-CFXxgg_a.js","assets/SettingsView-5RmswFZe.js","assets/vendor-yaml-3778uTud.js","assets/vendor-qrcode-DTJ12-WC.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/SettingsWindow-BZhAYFdS.js","assets/OnboardingScreen-D2Y6djMw.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as tt,j as s,R as l,r as Ge,h as Dm}from"./vendor-react-BUCujlKS.js";import{x as $n,y as Ti,O as Hl,D as Pm,z as Em,A as Jd,r as ms,n as Ii,u as xe,B as Tm,C as er,E as Im,F as wt,G as In,H as Ri,I as Zd,J as eu,q as Mi,K as tu,L as ur,M as ko,e as fr,N as Rm,a as xn,P as Mm,Q as Om,R as Fm,S as su,m as Bn,t as Xs,T as nu,U as Bm,V as ru,W as Lm,X as Vr,l as ls,Y as rl,Z as Da,_ as _m,$ as $m,d as Hr,a0 as si,a1 as ni,a2 as zm,a3 as Kl,a4 as Um,a5 as Wm,a6 as Vm,a7 as Hm,a8 as Gl,a9 as ql,aa as Yl,ab as Ql,ac as Km,o as Xl,ad as Gm,ae as qm,af as Ym,v as Qm,w as Xm}from"./index-DRpChWux.js";import{_ as Js}from"./vendor-vite-runtime-DD1OZmLC.js";import{I as R,f as mt,h as ye,aQ as Gt,g as Xn,t as Ee,aR as bn,aS as gn,aT as yn,aU as vn,L as _r,V as tr,aV as pr,o as Oi,aW as Jl,aX as dt,aY as ut,aZ as ft,a_ as ou,a$ as Co,b0 as Jm,y as Je,b1 as Zm,b2 as eh,b3 as iu,b4 as th,b5 as ri,b6 as sh,b7 as nh,K as au,b8 as rh,b9 as Pa,l as Vt,ba as oh,A as lu,u as Rs,b as qt,n as Cs,aj as Lr,bb as cu,bc as ih,bd as ah,be as lh,bf as ch,p as dh,bg as du,bh as uh,bi as fh,bj as mh,bk as uu,bl as hh,bm as ph,bn as ol,bo as Fi,bp as Ea,ak as il,bq as Bi,br as Or,ae as fu,bs as Ws,bt as Vs,bu as Rn,bv as wn,bw as Sn,bx as gr,B as nt,by as mu,bz as oa,P as pi,i as Ta,j as gh,bA as hu,bB as xh,bC as pu,ac as cs,G as bh,bD as yh,bE as vh,bF as hn,bG as Li,bH as gu,bI as Ia,bJ as wh,bK as Ls,bL as _s,bM as Ds,bN as $s,bO as rs,S as Jn,bP as Kr,bQ as Zl,bR as qr,M as _i,a0 as Io,a1 as al,bS as xu,a4 as mr,bT as $i,bU as Yn,Z as ll,bV as Sh,bW as jh,ab as kh,bX as Ch,bY as Nh,bZ as Ah,ad as cl,b_ as dl,b$ as yo,c0 as bu,c1 as Dh,c2 as Ph,c3 as Ro,c4 as Eh,O as yu,c5 as Th,c6 as Zs,c7 as Ih,c8 as Rh,c9 as ia,ca as vu,cb as Mh,cc as Oh,cd as Fh,ce as ec,cf as xo,c as No,d as zi,Y as wu,cg as Su,ch as uo,ci as bo,cj as Bh,r as Us,ck as Lh,W as ul,cl as _h,cm as $h,cn as zh,co as Uh,cp as ju,cq as _n,cr as Wh,cs as Vh,ct as tc,cu as ku,cv as Hh,cw as Cu,e as to,cx as gi,cy as Kh,cz as sc,cA as hr,cB as Ra,cC as Gh,cD as qh,cE as nc,cF as Fs,cG as Nu,cH as Au,cI as Yh,cJ as oi,cK as Qh,Q as fl,N as ml,R as hl,cL as pl,cM as Ma,cN as Du,cO as Xh,cP as Pu,cQ as Jh,H as Zh,cR as rc,cS as ep,cT as oc,cU as tp,cV as sp,cW as Eu,cX as np,D as rp,cY as op,cZ as ip,c_ as ap,c$ as ic,d0 as lp,d1 as cp,C as dp,d2 as Tu,E as up,d3 as ac,d4 as fp,d5 as mp,d6 as hp,d7 as pp,d8 as gp,d9 as xp,da as Ui,a as Wi,db as bp,dc as aa,F as xi,dd as yp,de as vp,df as lc,aw as Oa,dg as Iu,_ as wp,$ as Sp,az as jp,dh as kp,J as Cp,di as Np,dj as Ap,dk as Dp,dl as Ru,dm as Mu,dn as Ou,dp as Pp,dq as Ep,dr as Tp,ds as Ip,dt as Rp,du as Mp,dv as Op,dw as Fp,dx as Bp,dy as bi,a2 as Lp,a3 as _p,dz as $p,dA as cc,dB as zp,dC as Up,dD as Wp,dE as Vp,dF as dc,dG as Hp,dH as Kp,dI as Gp,dJ as qp,dK as Yp,dL as Qp,dM as Xp,dN as Jp,dO as Zp,dP as ii,dQ as eg,dR as tg,af as sg,dS as ng,dT as rg,dU as og,dV as ig,dW as uc,dX as ag,aq as lg,ar as cg,as as dg,au as fc,av as mc,ax as Fu,ay as Bu,dY as ug,aL as fg,aM as mg,aN as hg,aO as pg,aP as gg,aH as xg,aI as bg,aJ as yg,aK as vg}from"./useAppFontEffects-BikB6enL.js";import{h as hc,i as Qt,n as wg,j as pc,t as Kn,k as Sg,l as la,m as jg,o as kg,U as Lu,b as gl,M as Cg,p as gc,q as yi,s as xl,v as vi,w as _u,x as Ng,y as $u,z as zu,A as Uu,P as Wu,T as Vu,B as Ag,E as Dg,F as Pg,S as xc,u as vo,N as Eg,D as Tg,W as Ig,L as bc,G as Rg,d as Mg,g as Og,f as Fa,H as Fg,I as Bg,c as Lg,e as _g,O as Hu,C as $g}from"./runtimeEndpointReset-BVmispdD.js";import{u as Ku,S as zg,C as Ug,W as Gu}from"./SessionSwitcherDropdown-rro-SsaO.js";import{u as Pr,f as Wg,a as yc,s as Vg,d as Hg,b as Kg,r as Gg}from"./scheduledTasksApi-ByKya3Un.js";import{c as xr,u as qn,d as qu,p as Yu}from"./vendor-zustand-BAGL70zf.js";import{g as qg,b as Yg,E as Qg,c as Xg,i as Jg}from"./contextPanelEmbeddedChat-B-bSg3P5.js";import{f as wi,h as Yr,T as Zg,M as ex,D as Si,j as ji,P as Ba,b as tx,d as sx,k as La,i as nx}from"./vendor-dnd-kit-core-BZknOX2w.js";import{a as Qu,S as _a,v as $a,u as bl,s as rx}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as yl}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{u as ox}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{M as vc,a as wc,b as Sc,C as ix,c as ax,d as lx,S as cx,e as dx,f as ux}from"./vendor-base-ui-D_V6hAcE.js";import{d as Xu}from"./vendor-cron-parser-CUcP7OfX.js";import{u as jc,a as kc,m as Cc}from"./vendor-framer-motion-CRSgBxjL.js";function Ju(t){const e=tt.c(5),{className:n}=t,o=`relative inline-block overflow-hidden rounded-[2px] ${n===void 0?"h-5 w-5":n}`;let i,c,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("span",{className:"absolute left-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-error)]/25"}),c=s.jsx("span",{className:"absolute right-[20%] top-[20%] h-[60%] w-[25%] bg-[var(--status-success)]/25"}),a=s.jsx(R,{name:"layout-column",className:"absolute inset-0 h-full w-full"}),e[0]=i,e[1]=c,e[2]=a):(i=e[0],c=e[1],a=e[2]);let d;return e[3]!==o?(d=s.jsxs("span",{"aria-hidden":"true",className:o,children:[i,c,a]}),e[3]=o,e[4]=d):d=e[4],d}function Nc(t){const e=tt.c(14);let n,r,o,i;e[0]!==t?({size:o,className:n,style:i,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=o,e[4]=i):(n=e[1],r=e[2],o=e[3],i=e[4]);const c=typeof o=="number"?`${o}px`:o,a=typeof o=="number"?`${o}px`:o;let d;e[5]!==i||e[6]!==c||e[7]!==a?(d={width:c,height:a,...i},e[5]=i,e[6]=c,e[7]=a,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("path",{d:"M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z"}),e[9]=u):u=e[9];let h;return e[10]!==n||e[11]!==r||e[12]!==d?(h=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:n,style:d,...r,children:u}),e[10]=n,e[11]=r,e[12]=d,e[13]=h):h=e[13],h}const fx="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",mx="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",ca=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__==="darwin"?fx:t.id==="terminal"?mx:void 0}),Ac=t=>{const e=tt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:o}=t,[i,c]=l.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||o;if(u&&!i){let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>c(!0),e[2]=g):g=e[2];let b;return e[3]!==u?(b=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:g}),e[3]=u,e[4]=b):b=e[4],b}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=ye("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},hx=t=>{const e=tt.c(75),{directory:n,className:r}=t,{t:o}=mt(),i=Pr(px),c=Pr(gx),a=Pr(xx),d=Pr(bx),u=Pr(yx),h=Pr(vx),f=Pr(wx);let g,b;e[0]!==u?(g=()=>{u()},b=[u],e[0]=u,e[1]=g,e[2]=b):(g=e[1],b=e[2]),l.useEffect(g,b);const S=$n()&&Ti();let v;e:{let Y;e[3]!==c||e[4]!==i?(Y=c.find(Q=>Q.id===i)??c.find(Sx)??c[0]??Hl[0],e[3]=c,e[4]=i,e[5]=Y):Y=e[5];const we=Y;if(we){let Q;e[6]!==we?(Q=ca(we),e[6]=we,e[7]=Q):Q=e[7],v=Q;break e}let me;e[8]===Symbol.for("react.memo_cache_sentinel")?(me=ca(Hl[0]),e[8]=me):me=e[8],v=me}const p=v;if(!S||!n||c.length===0)return null;let m;e[9]!==n?(m=async Y=>{await Em(n,Y.id,Y.appName)||await Jd(n,Y.appName)},e[9]=n,e[10]=m):m=e[10];const x=m;let w;e[11]!==x||e[12]!==f?(w=async Y=>{await f(Y.id),await x(Y)},e[11]=x,e[12]=f,e[13]=w):w=e[13];const j=w;let N;e[14]!==n||e[15]!==o?(N=async()=>{(await Xn(n)).ok&&Ee.success(o("openInApp.toast.pathCopied"))},e[14]=n,e[15]=o,e[16]=N):N=e[16];const A=N;let k;e[17]!==r?(k=ye("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]=k):k=e[18];let C;e[19]!==x||e[20]!==p?(C=()=>{x(p)},e[19]=x,e[20]=p,e[21]=C):C=e[21];const P=d&&"animate-pulse";let D;e[22]!==P?(D=ye("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",P),e[22]=P,e[23]=D):D=e[23];let F;e[24]!==p.label||e[25]!==o?(F=o("openInApp.actions.openInAria",{app:p.label}),e[24]=p.label,e[25]=o,e[26]=F):F=e[26];let B;e[27]!==p.fallbackIconDataUrl||e[28]!==p.iconDataUrl||e[29]!==p.label?(B=s.jsx(Ac,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}),e[27]=p.fallbackIconDataUrl,e[28]=p.iconDataUrl,e[29]=p.label,e[30]=B):B=e[30];let E;e[31]!==D||e[32]!==F||e[33]!==B||e[34]!==C?(E=s.jsx("button",{type:"button",onClick:C,className:D,"aria-label":F,children:B}),e[31]=D,e[32]=F,e[33]=B,e[34]=C,e[35]=E):E=e[35];let _;e[36]===Symbol.for("react.memo_cache_sentinel")?(_=ye("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 W;e[37]!==o?(W=o("openInApp.actions.chooseAppAria"),e[37]=o,e[38]=W):W=e[38];let V;e[39]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(R,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=V):V=e[39];let K;e[40]!==W?(K=s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:_,"aria-label":W,children:V})}),e[40]=W,e[41]=K):K=e[41];let y;e[42]!==A?(y=()=>{A()},e[42]=A,e[43]=y):y=e[43];let I;e[44]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(R,{name:"file-copy",className:"h-4 w-4"}),e[44]=I):I=e[44];let $;e[45]!==o?($=o("openInApp.actions.copyPath"),e[45]=o,e[46]=$):$=e[46];let z;e[47]!==$?(z=s.jsx("span",{className:"typography-ui-label text-foreground",children:$}),e[47]=$,e[48]=z):z=e[48];let G;e[49]!==y||e[50]!==z?(G=s.jsxs(Gt,{className:"flex items-center gap-2",onClick:y,children:[I,z]}),e[49]=y,e[50]=z,e[51]=G):G=e[51];let J;e[52]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(gn,{}),e[52]=J):J=e[52];let Z;if(e[53]!==c||e[54]!==j||e[55]!==p.id){let Y;e[57]!==j||e[58]!==p.id?(Y=we=>{const me=ca(we);return s.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{j(we)},children:[s.jsx(Ac,{label:we.label,iconDataUrl:we.iconDataUrl,fallbackIconDataUrl:me.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:we.label}),p.id===we.id?s.jsx(R,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},we.id)},e[57]=j,e[58]=p.id,e[59]=Y):Y=e[59],Z=c.map(Y),e[53]=c,e[54]=j,e[55]=p.id,e[56]=Z}else Z=e[56];let re;e[60]!==a||e[61]!==h||e[62]!==o?(re=a?s.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{h(!0)},children:[s.jsx(R,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[60]=a,e[61]=h,e[62]=o,e[63]=re):re=e[63];let ee;e[64]!==G||e[65]!==Z||e[66]!==re?(ee=s.jsxs(yn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[G,J,Z,re]}),e[64]=G,e[65]=Z,e[66]=re,e[67]=ee):ee=e[67];let he;e[68]!==K||e[69]!==ee?(he=s.jsxs(vn,{children:[K,ee]}),e[68]=K,e[69]=ee,e[70]=he):he=e[70];let be;return e[71]!==E||e[72]!==he||e[73]!==k?(be=s.jsxs("div",{className:k,children:[E,he]}),e[71]=E,e[72]=he,e[73]=k,e[74]=be):be=e[74],be};function px(t){return t.selectedAppId}function gx(t){return t.availableApps}function xx(t){return t.isCacheStale}function bx(t){return t.isScanning}function yx(t){return t.initialize}function vx(t){return t.loadInstalledApps}function wx(t){return t.selectApp}function Sx(t){return t.id===Pm}const ki=new Map,za=new Set,Zu=()=>{for(const t of za)t()},da=(t,e)=>{const n=t.trim();n&&(e.length===0?ki.delete(n):ki.set(n,[...e]),Zu())},jx=t=>{ki.delete(t.trim())&&Zu()},ef=[],kx=t=>ki.get(t.trim())??ef,Cx=t=>(za.add(t),()=>{za.delete(t)}),Nx=t=>{const e=tt.c(2);let n;return e[0]!==t?(n=()=>kx(t),e[0]=t,e[1]=n):n=e[1],l.useSyncExternalStore(Cx,n,Ax)};function Ax(){return ef}const Dx=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Px=["dev","start","preview","serve"];async function Ex(t,e,n){if(!t)return null;const r=Rx(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id,previewUrlHint:r.openUrl};if(n){const o=Mx(n);if(o){const i=await Ox(t);return{command:`${i==="npm"?"npm run":i==="yarn"?"yarn":i==="pnpm"?"pnpm":i==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await Tx(t)){const o=await Ix(),i=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${i}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${i}/`}}return null}async function Tx(t){const e=`${t}/index.html`,n=await Ci(e,t);return typeof n=="string"&&n.trim().length>0}async function Ix(){try{const t=await ms("/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 Rx(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Px.some(o=>n.includes(o)))return e}return null}function Mx(t){for(const{pattern:e}of Dx)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Ox(t){const e=await Ci(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.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,o]of n){const i=await Ci(`${t}/${r}`,t);if(typeof i=="string"&&i.trim().length>0)return o}return"npm"}async function Ci(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await ms(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=Ii()?.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 ms(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Fx(t){try{const e=await Ci(`${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 Bx=(t,e,n)=>new Promise(r=>{let o=!1,i=null,c=null;const a=d=>{o||(o=!0,c&&clearTimeout(c),i?.close(),r(d))};i=t.connect(e,{onEvent:d=>{(d.type==="exit"||d.type==="snapshot"&&d.status==="exited")&&a(!0)},onError:(d,u)=>{u&&a(!0)}}),o?i.close():c=setTimeout(()=>a(!1),n)}),Ys="__openchamber_auto_discover_preview__",Lx=15e3,_x=3e3,$x=t=>{let e="";for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(e+=t[n])}return e},zx=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}},tf=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:o=!1})=>{const{t:i}=mt(),{currentTheme:c}=_r(),{terminal:a,runtime:d}=tr(),{isMobile:u}=pr(),h=l.useMemo(()=>$n(),[]),f=hc(X=>X.instances),g=hc(X=>X.load),b=xe(X=>X.terminalShell),S=xe(X=>X.terminalLoginShells.includes(X.terminalShell)),v=xe(X=>X.setSettingsPage),p=xe(X=>X.setSettingsDialogOpen),m=xe(X=>X.setSettingsProjectsSelectedId),x=xe(X=>X.openContextPreview),w=Qt(X=>X.ensureDirectory),j=Qt(X=>X.setTabLabel),N=Qt(X=>X.setTabIconKey),A=Qt(X=>X.setActiveTab),k=Qt(X=>X.setConnecting),C=Qt(X=>X.setTabSessionId),P=Qt(X=>X.setTabPreviewUrl),D=Qt(X=>X.projectActionRuns),F=Qt(X=>X.setProjectActionRun),B=Qt(X=>X.updateProjectActionRunStatus),E=Qt(X=>X.removeProjectActionRun),[_,W]=l.useState([]),[V,K]=l.useState(null),[y,I]=l.useState(!1),$=l.useRef({}),z=l.useRef({}),G=l.useRef({}),J=l.useRef({}),Z=l.useRef(new Set),re=l.useRef(0),ee=t?.id??null,he=t?.path??"",be=l.useMemo(()=>ee?{id:ee,path:he}:null,[ee,he]);l.useEffect(()=>{h&&g().catch(()=>{})},[h,g]);const Y=l.useCallback(async X=>{await Oi(X)},[]),we=l.useCallback(async()=>{if(!be)return;const X=re.current+1;re.current=X,I(!0);try{const le=await Jl(be);if(re.current!==X)return;const se=le.actions;W(se),K(T=>T===Ys||T&&se.some(ie=>ie.id===T)?T:null)}catch{if(re.current!==X)return}finally{re.current===X&&I(!1)}},[be]),me=l.useMemo(()=>wg(e||be?.path||""),[e,be?.path]),Q=l.useMemo(()=>V?_.find(X=>X.id===V)??null:null,[_,V]),pe=l.useMemo(()=>({id:Ys,name:i("projectActions.actions.autoDiscover"),command:"",icon:"scan-2",autoOpenUrl:!0}),[i]),ve=!u,Te=l.useMemo(()=>ve?[pe,..._]:_,[_,pe,ve]);l.useEffect(()=>{we()},[we]),l.useEffect(()=>{if(typeof window>"u")return;const X=le=>{const se=le.detail;ee&&(se?.projectId&&se.projectId!==ee||we())};return window.addEventListener(pc,X),()=>{window.removeEventListener(pc,X)}},[we,ee]),l.useEffect(()=>{V&&(V===Ys&&ve||_.some(X=>X.id===V)||K(null))},[_,ve,V]),l.useEffect(()=>{const X=se=>{delete J.current[se];const T=z.current[se];if(!T||T.openedUrl)return;const ie=Qt.getState(),je=ie.projectActionRuns[se];if(!je)return;const Pe=T.announced;if(Pe.length!==0){if(T.openedUrl=!0,ie.updateProjectActionRunStatus(se,"running"),Pe.length===1){da(je.directory,[]),P(je.directory,je.tabId,Pe[0],{locked:!1,autoOpened:!0}),x(je.directory,Pe[0]);return}T.offering=!0,da(je.directory,Pe),xe.getState().openContextSurface(je.directory,"browser"),Ee.info(i("projectActions.toast.multipleServers"))}},le=()=>{const se=Qt.getState(),T=se.sessions,ie=se.projectActionRuns;for(const[je,Pe]of Object.entries(ie)){const Be=T.get(Pe.directory)?.tabs.find(it=>it.id===Pe.tabId);if(!Be||Be.terminalSessionId!==Pe.sessionId){E(je);continue}const Fe=z.current[je]??{lastSeenChunkId:null,openedUrl:!1,tail:"",openInPreview:!1,announced:[],offering:!1};z.current[je]=Fe;const Ye=Te.find(it=>it.id===Pe.actionId),at=se.getBuffer(Pe.directory,Pe.tabId).chunks;if(!Ye||at.length===0)continue;const st=at.filter(it=>Fe.lastSeenChunkId===null||it.id>Fe.lastSeenChunkId);if(st.length===0)continue;const ct=st.map(it=>it.data).join(""),bt=`${Fe.tail}${ct}`;if(Fe.openInPreview&&(!Fe.openedUrl||Fe.offering)){const it=jg(bt),Et=Fe.announced.length;for(const Dt of it)Fe.announced.includes(Dt)||Fe.announced.push(Dt);const Ft=Fe.announced.length-Et;Fe.offering&&Ft>0?da(Pe.directory,Fe.announced):!Fe.openedUrl&&Et===0&&Fe.announced.length>0&&(window.clearTimeout(J.current[je]),J.current[je]=window.setTimeout(()=>X(je),_x))}const rt=!Fe.openedUrl&&Ye.autoOpenUrl===!0&&!Fe.openInPreview?kg(bt):null,gt=st[st.length-1]?.id??Fe.lastSeenChunkId;if(Fe.lastSeenChunkId=gt,Fe.tail=bt.slice(-512),rt)if(Fe.openedUrl=!0,Fe.openInPreview){const it=ie[je];it&&(P(it.directory,it.tabId,rt,{locked:!1,autoOpened:!1}),it.status==="waiting-for-preview"&&B(je,"running"),window.clearTimeout(J.current[je]),delete J.current[je],x(it.directory,rt))}else Y(rt),Ee.success(i("projectActions.toast.openedUrlFromOutput"));z.current[je]=Fe}for(const je of Object.keys(z.current))ie[je]||(delete z.current[je],window.clearTimeout(J.current[je]),delete J.current[je])};return le(),Qt.subscribe((se,T)=>{(se.sessions!==T.sessions||se.buffers!==T.buffers)&&le()})},[Te,x,Y,D,E,P,i,B]);const ke=l.useCallback(async(X,le={})=>{if(!me)throw new Error(i("projectActions.error.noActiveDirectory"));const se=Kn(me,X.id);w(me);const T=Qt.getState(),ie=T.getDirectoryState(me);let je=$.current[se]||null;const Pe=je?!!ie?.tabs.some(Fe=>Fe.id===je):!1;(!je||!Pe)&&(je=T.createTab(me),$.current[se]=je),j(me,je,`Action: ${X.name}`),N(me,je,X.icon||"play"),A(me,je),le.revealTerminal!==!1&&xe.getState().openContextPanelTab(me,{mode:"terminal"});const Be=Qt.getState().getDirectoryState(me)?.tabs.find(Fe=>Fe.id===je);return{key:se,tabId:je,sessionId:Be?.terminalSessionId??null}},[w,me,A,N,j,i]),Ie=l.useCallback(async X=>{if(d.isVSCode||!o&&u)return;if(!me){Ee.error(i("projectActions.error.noActiveDirectoryForAction"));return}const le=Kn(me,X.id),se=D[le];if(!(se&&se.status==="running")&&!Z.current.has(le)){Z.current.add(le);try{const T=X.id===Ys?await(async()=>{const[rt,gt]=await Promise.all([Jl({id:be?.id??"",path:me}),Fx(me)]),it=await Ex(me,rt.actions,gt);if(!it)throw new Error(i("contextPanel.preview.noDevServer"));return{id:Ys,name:i("projectActions.actions.autoDiscover"),command:it.command,icon:"scan-2",autoOpenUrl:!0,openUrl:it.previewUrlHint||""}})():X,ie=T.autoOpenUrl===!0&&(T.openUrl||"").trim().length>0,je=!ie&&X.id!==Ys,{key:Pe,tabId:U,sessionId:Be}=await ke(T,{revealTerminal:je});let Fe=Be;if(!Fe){k(me,U,!0);try{Fe=(await a.createSession({cwd:me,sessionId:U,shell:b,loginShell:S,themeMode:c.metadata.variant==="light"?"light":"dark",terminalBackground:c.colors.surface.background,terminalForeground:c.colors.syntax.base.foreground})).sessionId,C(me,U,Fe)}finally{k(me,U,!1)}}if(!Fe)throw new Error(i("projectActions.error.failedToCreateTerminalSession"));G.current[Pe]?.(),k(me,U,!0);const Ye=a.connect(Fe,{onEvent:rt=>{rt.type==="snapshot"&&(Qt.getState().replaceBuffer(me,U,rt.data??"",rt.sequence??0),Qt.getState().setConnecting(me,U,!1)),rt.type==="data"&&typeof rt.data=="string"&&rt.data.length>0&&Qt.getState().appendToBuffer(me,U,rt.data,rt.sequence,rt.replayData),rt.type==="exit"&&(Qt.getState().setTabLifecycle(me,U,"exited"),Qt.getState().setConnecting(me,U,!1),Qt.getState().removeProjectActionRun(Pe),delete z.current[Pe],G.current[Pe]?.(),delete G.current[Pe],window.clearTimeout(J.current[Pe]),delete J.current[Pe])},onError:(rt,gt)=>{Qt.getState().setConnecting(me,U,!1),gt&&(Qt.getState().setTabLifecycle(me,U,"exited"),Qt.getState().setTabSessionId(me,U,null),Qt.getState().removeProjectActionRun(Pe))}});G.current[Pe]=Ye.close;const at=T.autoOpenUrl===!0&&h&&(T.desktopOpenSshForward||"").trim().length>0,st=T.autoOpenUrl?zx(T.openUrl):null,ct=T.autoOpenUrl&&h?Sg(T.desktopOpenSshForward,f):null;F({key:Pe,directory:me,actionId:T.id,tabId:U,sessionId:Fe,status:T.id===Ys&&!st?"waiting-for-preview":"running"}),window.clearTimeout(J.current[Pe]),delete J.current[Pe],T.id===Ys&&!st&&(J.current[Pe]=window.setTimeout(()=>{const rt=Qt.getState(),gt=rt.projectActionRuns[Pe];rt.updateProjectActionRunStatus(Pe,"running"),gt&&(rt.setActiveTab(gt.directory,gt.tabId),xe.getState().openContextPanelTab(gt.directory,{mode:"terminal"})),delete J.current[Pe]},Lx)),z.current[Pe]={lastSeenChunkId:null,openedUrl:!!ct||!!st||ie,tail:"",openInPreview:T.id===Ys,announced:[],offering:!1};const bt=$x(T.command.trim().replace(/\r\n|\r/g,`
|
|
3
3
|
`));await a.sendInput(Fe,`${bt}\r`),ct?(P(me,U,null,{locked:!0}),Y(ct),Ee.success(i("projectActions.toast.openedForwardedUrl"))):st?(P(me,U,st,{locked:!0,autoOpened:!0}),x(me,st),Ee.success(i("projectActions.toast.openedActionUrl"))):ie?(P(me,U,null,{locked:!0}),Ee.error(i("projectActions.error.invalidCustomUrlFormat"))):at?(P(me,U,null,{locked:!0}),Ee.error(i("projectActions.error.selectedDesktopSshForwardUnavailable"))):P(me,U,null,{locked:!1,autoOpened:!1})}catch(T){E(le),delete z.current[le],G.current[le]?.(),delete G.current[le],window.clearTimeout(J.current[le]),delete J.current[le],Ee.error(T instanceof Error?T.message:i("projectActions.error.failedToRunAction"))}finally{Z.current.delete(le)}}},[c.colors.surface.background,c.colors.syntax.base.foreground,c.metadata.variant,f,ke,o,u,h,me,S,b,Y,x,D,d.isVSCode,E,k,F,P,C,be?.id,i,a]),Ne=l.useCallback(async X=>{const le=Kn(me,X.id),se=D[le];if(!se)return;B(le,"stopping");const T=Bx(a,se.sessionId,1e3);try{await a.sendInput(se.sessionId,"")}catch{}const ie=await T;if(Qt.getState().getDirectoryState(se.directory)?.tabs.find(U=>U.id===se.tabId)?.terminalSessionId===se.sessionId&&!ie){if(typeof a.forceKill=="function")try{await a.forceKill({sessionId:se.sessionId})}catch{}else try{await a.close(se.sessionId)}catch{}C(se.directory,se.tabId,null)}E(le),delete z.current[le],G.current[le]?.(),delete G.current[le],window.clearTimeout(J.current[le]),delete J.current[le]},[me,D,E,C,a,B]),Ae=l.useCallback(()=>{const X=Q??Te[0];if(!X)return;const le=Kn(me,X.id),se=D[le];if(se?.status!=="stopping"){if(se){Ne(X);return}Ie(X)}},[Te,me,Ie,D,Q,Ne]),Se=l.useCallback((X,le=!1)=>{if(K(X.id),!le){Ie(X);return}const se=Kn(me,X.id),T=D[se];if(T?.status!=="stopping"){if(T){Ne(X);return}Ie(X)}},[me,Ie,D,Ne]),Oe=l.useCallback(()=>{be?.id&&(m(be.id),v("projects"),p(!0))},[p,v,m,be?.id]),ne=Q??Te[0]??null,ce=ne?D[Kn(me,ne.id)]:null,Re=Qt(X=>ce?X.sessions.get(ce.directory)?.tabs.find(le=>le.id===ce.tabId)?.previewUrl??null:null);if(d.isVSCode||!o&&u||!be||!me)return null;const te=Q??Te[0]??null;if(!te)return null;const ae=te.icon||"play",de=te.id===Ys?"scan-2":la[ae]||"play",H=Kn(me,te.id),ge=D[H],ue=ge?.status==="stopping",M=ge?.status==="waiting-for-preview",oe=!!(ge&&Re),De=()=>{!ge||!Re||x(ge.directory,Re)},fe=te.id===Ys;return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",disabled:y||ue,className:ye("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-primary","disabled:cursor-not-allowed",n),onClick:Ae,"aria-label":ge?i("projectActions.actions.stopNamedAria",{name:te.name}):i("projectActions.actions.runNamedAria",{name:te.name}),children:ue||M?s.jsx(R,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):ge?s.jsx(R,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(R,{name:de,className:"h-5 w-5"})})}),fe?s.jsx(ft,{sideOffset:6,children:i("projectActions.actions.autoDiscoverTooltip")}):null]}),oe?s.jsxs(dt,{children:[s.jsx(ut,{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-primary","aria-label":i("projectActions.actions.openPreview"),onClick:De,children:s.jsx(R,{name:"global",className:"h-4 w-4"})})}),s.jsx(ft,{sideOffset:6,children:i("projectActions.actions.openPreview")})]}):null,s.jsxs(vn,{children:[s.jsx(bn,{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-primary","aria-label":i("projectActions.actions.chooseActionAria"),children:s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(yn,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Gt,{className:"flex items-center gap-2",onClick:Oe,children:[s.jsx(R,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("projectActions.actions.addNewAction")})]}),s.jsx(gn,{}),Te.map(X=>{const le=X.icon||"play",se=X.id===Ys?"scan-2":la[le]||"play",T=Kn(me,X.id),ie=D[T],je=!!ie,Pe=ie?.status==="stopping";return s.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{Se(X,!0)},children:[s.jsx(R,{name:se,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.name}),Pe||ie?.status==="waiting-for-preview"?s.jsx(R,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):je?s.jsx(R,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},X.id)})]})]})]}):s.jsxs("div",{className:ye("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(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Ae,disabled:y||ue,className:ye("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-primary disabled:cursor-not-allowed"),"aria-label":ge?i("projectActions.actions.stopNamedAria",{name:te.name}):i("projectActions.actions.runNamedAria",{name:te.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:ue||M?s.jsx(R,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):ge?s.jsx(R,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(R,{name:de,className:"h-4 w-4"})})})}),fe?s.jsx(ft,{sideOffset:6,children:i("projectActions.actions.autoDiscoverTooltip")}):null]}),oe?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:De,className:ye(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-primary"),"aria-label":i("projectActions.actions.openPreview"),children:s.jsx(R,{name:"global",className:"h-4 w-4"})})}),s.jsx(ft,{sideOffset:6,children:i("projectActions.actions.openPreview")})]}):null,s.jsxs(vn,{children:[s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:ye(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-primary"),"aria-label":i("projectActions.actions.chooseActionAria"),children:s.jsx(R,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(yn,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(Gt,{className:"flex items-center gap-2",onClick:Oe,children:[s.jsx(R,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:i("projectActions.actions.addNewAction")})]}),s.jsx(gn,{}),Te.map(X=>{const le=X.icon||"play",se=X.id===Ys?"scan-2":la[le]||"play",T=Kn(me,X.id),ie=D[T],je=!!ie,Pe=ie?.status==="stopping";return s.jsxs(Gt,{className:"flex items-center gap-2",onClick:()=>{Se(X,!0)},children:[s.jsx(R,{name:se,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:X.name}),Pe||ie?.status==="waiting-for-preview"?s.jsx(R,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):je?s.jsx(R,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},X.id)})]})]})]})};function Ux(t){if(typeof t!="number"||!Number.isFinite(t))return"";const e=new Date(t);if(Number.isNaN(e.getTime()))return"";const n=e.toLocaleString(Co(),{month:"short"}),r=e.getDate(),o=e.getFullYear(),i=String(e.getHours()).padStart(2,"0"),c=String(e.getMinutes()).padStart(2,"0");return`${n} ${r}, ${o}, ${i}:${c}`}function Wx(t){if(t.info.role==="user")return"";const e=typeof t.info.providerID=="string"?t.info.providerID.trim():"",n=typeof t.info.modelID=="string"?t.info.modelID.trim():"";return e&&n?`${e}/${n}`:n||e}function Vx(t){const e=t.info.role==="user"?"User":"Assistant",n=Ux(t.info.time?.created),r=Wx(t),o=n&&r?`${n} (${r})`:n||r;return o?`**${e}**
|
|
4
4
|
|
|
5
5
|
*${o}*`:`**${e}**`}function Hx(t){return t.filter(e=>e.type==="text"&&typeof e.text=="string").map(e=>e.text).join("")}function sf(t){const e=Vx(t),n=Hx(t.parts).trim();return n?`${e}
|
|
@@ -896,7 +896,7 @@ ${t}
|
|
|
896
896
|
styles: styles
|
|
897
897
|
};
|
|
898
898
|
`),Wv=t=>{const e=tt.c(18),{entries:n,activeIndex:r,onSelect:o,onForget:i,onHighlight:c}=t,{t:a}=mt();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]!==i||e[5]!==c||e[6]!==o||e[7]!==a){let f;e[9]!==r||e[10]!==i||e[11]!==c||e[12]!==o||e[13]!==a?(f=(g,b)=>s.jsxs("div",{role:"option","aria-selected":b===r,className:ye("group flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1",b===r?"bg-interactive-hover":"hover:bg-interactive-hover"),onPointerDown:S=>{S.preventDefault(),o(g.url)},onPointerEnter:()=>c(b),children:[s.jsx(R,{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:g.title||Cl(g.url)}),s.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:g.url})]}),s.jsx("button",{type:"button",className:ye("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:S=>{S.preventDefault(),S.stopPropagation(),i(g.url)},children:s.jsx(R,{name:"close",className:"size-3","aria-hidden":"true"})})]},g.url),e[9]=r,e[10]=i,e[11]=c,e[12]=o,e[13]=a,e[14]=f):f=e[14],u=n.map(f),e[2]=r,e[3]=n,e[4]=i,e[5]=c,e[6]=o,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},fn=t=>{const e=tt.c(17),{icon:n,label:r,onClick:o,disabled:i,pressed:c}=t,a=c?"secondary":"ghost",d=c&&"text-foreground";let u;e[0]!==d?(u=ye("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(R,{name:n,className:"size-3.5","aria-hidden":"true"}),e[2]=n,e[3]=h):h=e[3];let f;e[4]!==i||e[5]!==r||e[6]!==o||e[7]!==c||e[8]!==a||e[9]!==u||e[10]!==h?(f=s.jsx(ut,{asChild:!0,children:s.jsx(nt,{type:"button",variant:a,size:"xs",className:u,onClick:o,disabled:i,"aria-label":r,"aria-pressed":c,children:h})}),e[4]=i,e[5]=r,e[6]=o,e[7]=c,e[8]=a,e[9]=u,e[10]=h,e[11]=f):f=e[11];let g;e[12]!==r?(g=s.jsx(ft,{sideOffset:6,children:r}),e[12]=r,e[13]=g):g=e[13];let b;return e[14]!==f||e[15]!==g?(b=s.jsxs(dt,{children:[f,g]}),e[14]=f,e[15]=g,e[16]=b):b=e[16],b},If=t=>{const e=tt.c(104),{address:n,suggestions:r,onForgetSuggestion:o,onAddressChange:i,onSubmit:c,onBack:a,onForward:d,onReload:u,onOpenExternal:h,canGoBack:f,canGoForward:g,isLoading:b,onAnnotate:S,onOpenDevTools:v,isAnnotating:p,onHardReload:m,onZoomIn:x,onZoomOut:w,onZoomReset:j,zoomPercent:N,onClearCookies:A,onClearCache:k,onToggleDeviceBar:C,isDeviceBarOpen:P}=t;let D;e[0]!==r?(D=r===void 0?[]:r,e[0]=r,e[1]=D):D=e[1];const F=D,B=N===void 0?100:N,{t:E}=mt(),[_,W]=l.useState(!1),[V,K]=l.useState(-1);let y;e[2]!==_||e[3]!==F?(y=_?F:[],e[2]=_,e[3]=F,e[4]=y):y=e[4];const I=y;let $;e[5]===Symbol.for("react.memo_cache_sentinel")?($=()=>{K(-1)},e[5]=$):$=e[5];let z;e[6]!==n||e[7]!==_?(z=[n,_],e[6]=n,e[7]=_,e[8]=z):z=e[8],l.useEffect($,z);let G;e[9]!==c?(G=X=>{W(!1),K(-1),c(X)},e[9]=c,e[10]=G):G=e[10];const J=G;let Z;e[11]!==V||e[12]!==J||e[13]!==I?(Z=X=>{if(I.length!==0){if(X.key==="ArrowDown"||X.key==="ArrowUp"){X.preventDefault();const le=X.key==="ArrowDown"?1:-1,se=I.length;K(T=>{const ie=T+le;return ie<-1?se-1:ie>=se?-1:ie});return}if(X.key==="Escape"&&V>=0){X.preventDefault(),K(-1);return}if(X.key==="Enter"&&V>=0){X.preventDefault();const le=I[V];le&&J(le.url)}}},e[11]=V,e[12]=J,e[13]=I,e[14]=Z):Z=e[14];const re=Z;let ee;e[15]!==E?(ee=E("contextPanel.browser.back"),e[15]=E,e[16]=ee):ee=e[16];const he=!f;let be;e[17]!==a||e[18]!==he||e[19]!==ee?(be=s.jsx(fn,{icon:"arrow-left",label:ee,onClick:a,disabled:he}),e[17]=a,e[18]=he,e[19]=ee,e[20]=be):be=e[20];let Y;e[21]!==E?(Y=E("contextPanel.browser.forward"),e[21]=E,e[22]=Y):Y=e[22];const we=!g;let me;e[23]!==d||e[24]!==Y||e[25]!==we?(me=s.jsx(fn,{icon:"arrow-right",label:Y,onClick:d,disabled:we}),e[23]=d,e[24]=Y,e[25]=we,e[26]=me):me=e[26];let Q;e[27]!==b||e[28]!==E?(Q=E(b?"contextPanel.browser.stop":"contextPanel.browser.reload"),e[27]=b,e[28]=E,e[29]=Q):Q=e[29];let pe;e[30]!==u||e[31]!==Q?(pe=s.jsx(fn,{icon:"refresh",label:Q,onClick:u}),e[30]=u,e[31]=Q,e[32]=pe):pe=e[32];let ve;e[33]!==m||e[34]!==E?(ve=m?s.jsx(fn,{icon:"restart",label:E("contextPanel.browser.hardReload"),onClick:m}):null,e[33]=m,e[34]=E,e[35]=ve):ve=e[35];let Te;e[36]!==n||e[37]!==J?(Te=X=>{X.preventDefault(),J(n)},e[36]=n,e[37]=J,e[38]=Te):Te=e[38];let ke;e[39]!==i?(ke=X=>i(X.target.value),e[39]=i,e[40]=ke):ke=e[40];let Ie,Ne;e[41]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>W(!0),Ne=()=>W(!1),e[41]=Ie,e[42]=Ne):(Ie=e[41],Ne=e[42]);const Ae=I.length>0;let Se;e[43]===Symbol.for("react.memo_cache_sentinel")?(Se=ye("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]=Se):Se=e[43];let Oe;e[44]!==E?(Oe=E("contextPanel.browser.addressAria"),e[44]=E,e[45]=Oe):Oe=e[45];let ne;e[46]!==n||e[47]!==re||e[48]!==ke||e[49]!==Ae||e[50]!==Oe?(ne=s.jsx("input",{value:n,onChange:ke,onFocus:Ie,onBlur:Ne,onKeyDown:re,spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":Ae,"aria-controls":"openchamber-browser-address-suggestions",className:Se,"aria-label":Oe}),e[46]=n,e[47]=re,e[48]=ke,e[49]=Ae,e[50]=Oe,e[51]=ne):ne=e[51];let ce;e[52]!==o?(ce=X=>o?.(X),e[52]=o,e[53]=ce):ce=e[53];let Re;e[54]!==V||e[55]!==J||e[56]!==ce||e[57]!==I?(Re=s.jsx("div",{id:"openchamber-browser-address-suggestions",children:s.jsx(Wv,{entries:I,activeIndex:V,onSelect:J,onForget:ce,onHighlight:K})}),e[54]=V,e[55]=J,e[56]=ce,e[57]=I,e[58]=Re):Re=e[58];let te;e[59]!==Te||e[60]!==ne||e[61]!==Re?(te=s.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:Te,children:[ne,Re]}),e[59]=Te,e[60]=ne,e[61]=Re,e[62]=te):te=e[62];let ae;e[63]!==x||e[64]!==w||e[65]!==j||e[66]!==E||e[67]!==B?(ae=w&&x?s.jsxs("div",{className:"flex shrink-0 items-center",children:[s.jsx(fn,{icon:"subtract",label:E("contextPanel.browser.zoomOut"),onClick:w}),B!==100&&j?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsxs(nt,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 rounded-full px-1.5 typography-micro tabular-nums text-muted-foreground",onClick:j,"aria-label":E("contextPanel.browser.zoomReset"),children:[B,"%"]})}),s.jsx(ft,{sideOffset:6,children:E("contextPanel.browser.zoomReset")})]}):null,s.jsx(fn,{icon:"add",label:E("contextPanel.browser.zoomIn"),onClick:x})]}):null,e[63]=x,e[64]=w,e[65]=j,e[66]=E,e[67]=B,e[68]=ae):ae=e[68];let de;e[69]!==A||e[70]!==E?(de=A?s.jsx(fn,{icon:"delete-bin",label:E("contextPanel.browser.clearCookies"),onClick:A}):null,e[69]=A,e[70]=E,e[71]=de):de=e[71];let H;e[72]!==k||e[73]!==E?(H=k?s.jsx(fn,{icon:"database-2",label:E("contextPanel.browser.clearCache"),onClick:k}):null,e[72]=k,e[73]=E,e[74]=H):H=e[74];let ge;e[75]!==P||e[76]!==C||e[77]!==E?(ge=C?s.jsx(fn,{icon:"smartphone",label:E("contextPanel.browser.deviceToolbar"),onClick:C,pressed:P}):null,e[75]=P,e[76]=C,e[77]=E,e[78]=ge):ge=e[78];let ue;e[79]!==p||e[80]!==S||e[81]!==E?(ue=S?s.jsx(fn,{icon:"cursor",label:E("contextPanel.browser.annotate.toggle"),onClick:S,pressed:p}):null,e[79]=p,e[80]=S,e[81]=E,e[82]=ue):ue=e[82];let M;e[83]!==v||e[84]!==E?(M=v?s.jsx(fn,{icon:"terminal-box",label:E("contextPanel.browser.devTools"),onClick:v}):null,e[83]=v,e[84]=E,e[85]=M):M=e[85];let oe;e[86]!==E?(oe=E("contextPanel.browser.openExternal"),e[86]=E,e[87]=oe):oe=e[87];let De;e[88]!==h||e[89]!==oe?(De=s.jsx(fn,{icon:"external-link",label:oe,onClick:h}),e[88]=h,e[89]=oe,e[90]=De):De=e[90];let fe;return e[91]!==be||e[92]!==me||e[93]!==pe||e[94]!==ve||e[95]!==te||e[96]!==ae||e[97]!==de||e[98]!==H||e[99]!==ge||e[100]!==ue||e[101]!==M||e[102]!==De?(fe=s.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[be,me,pe,ve,te,ae,de,H,ge,ue,M,De]}),e[91]=be,e[92]=me,e[93]=pe,e[94]=ve,e[95]=te,e[96]=ae,e[97]=de,e[98]=H,e[99]=ge,e[100]=ue,e[101]=M,e[102]=De,e[103]=fe):fe=e[103],fe},Ai={kind:"fill"},Xc=240,Vv=3840,Rf=[{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}],Jc=t=>Number.isFinite(t)?Math.round(Math.min(Vv,Math.max(Xc,t))):Xc,Di=t=>t.kind==="fill"?null:{width:t.width,height:t.height},Mf=t=>{const e=Rf.find(n=>n.id===t);return e?{kind:"preset",id:e.id,width:e.width,height:e.height}:null},Hv=t=>t.kind==="fill"?t:{kind:"custom",width:t.height,height:t.width},Kv=(t,e)=>{const n=Di(t);if(!n)return null;const r=Math.max(1,e.width),o=Math.max(1,e.height),i=Math.min(1,r/n.width,o/n.height);return{width:n.width,height:n.height,scale:i}},Gv=["mobile","tablet","desktop","fill"],qv={mobile:"iphone-14",tablet:"ipad-mini",desktop:"desktop"},Zc=t=>typeof t=="string"&&Gv.includes(t),Ga=t=>t==="fill"?Ai:Mf(qv[t])??Ai,Go=t=>{const e=Di(t);if(!e)return{mode:"fill",width:null,height:null};for(const n of["mobile","tablet","desktop"]){const r=Ga(n),o=Di(r);if(o&&o.width===e.width&&o.height===e.height)return{mode:n,width:e.width,height:e.height}}return{mode:"custom",width:e.width,height:e.height}},Yv=t=>{const e=tt.c(70),{viewport:n,onViewportChange:r,colorScheme:o,onColorSchemeChange:i,scale:c}=t,{t:a}=mt();let d;e[0]!==n?(d=Di(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=(he,be)=>{const Y=Number.parseInt(be,10);if(!Number.isFinite(Y))return;const we=u??{width:1280,height:800};r({kind:"custom",width:Jc(he==="width"?Y:we.width),height:Jc(he==="height"?Y:we.height)})},e[2]=r,e[3]=u,e[4]=f):f=e[4];const g=f;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=ye("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 S=b;let v;e[6]!==r?(v=he=>{const be=Mf(he.target.value);r(be??Ai)},e[6]=r,e[7]=v):v=e[7];let p;e[8]!==a?(p=a("contextPanel.browser.device.preset"),e[8]=a,e[9]=p):p=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=ye("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 x;e[11]!==a?(x=a("contextPanel.browser.device.responsive"),e[11]=a,e[12]=x):x=e[12];let w;e[13]!==x?(w=s.jsx("option",{value:"",children:x}),e[13]=x,e[14]=w):w=e[14];let j;e[15]===Symbol.for("react.memo_cache_sentinel")?(j=Rf.map(Qv),e[15]=j):j=e[15];let N;e[16]!==h||e[17]!==v||e[18]!==p||e[19]!==w?(N=s.jsxs("select",{value:h,onChange:v,"aria-label":p,className:m,children:[w,j]}),e[16]=h,e[17]=v,e[18]=p,e[19]=w,e[20]=N):N=e[20];const A=u?String(u.width):"";let k;e[21]!==g?(k=he=>g("width",he.target.value),e[21]=g,e[22]=k):k=e[22];let C;e[23]!==a?(C=a("contextPanel.browser.device.width"),e[23]=a,e[24]=C):C=e[24];let P;e[25]!==A||e[26]!==k||e[27]!==C?(P=s.jsx("input",{value:A,onChange:k,placeholder:"—",inputMode:"numeric","aria-label":C,className:S}),e[25]=A,e[26]=k,e[27]=C,e[28]=P):P=e[28];let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx("span",{className:"typography-micro text-muted-foreground",children:"×"}),e[29]=D):D=e[29];const F=u?String(u.height):"";let B;e[30]!==g?(B=he=>g("height",he.target.value),e[30]=g,e[31]=B):B=e[31];let E;e[32]!==a?(E=a("contextPanel.browser.device.height"),e[32]=a,e[33]=E):E=e[33];let _;e[34]!==F||e[35]!==B||e[36]!==E?(_=s.jsx("input",{value:F,onChange:B,placeholder:"—",inputMode:"numeric","aria-label":E,className:S}),e[34]=F,e[35]=B,e[36]=E,e[37]=_):_=e[37];let W;e[38]!==r||e[39]!==n?(W=()=>r(Hv(n)),e[38]=r,e[39]=n,e[40]=W):W=e[40];const V=!u;let K;e[41]!==a?(K=a("contextPanel.browser.device.rotate"),e[41]=a,e[42]=K):K=e[42];let y;e[43]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(R,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),e[43]=y):y=e[43];let I;e[44]!==W||e[45]!==V||e[46]!==K?(I=s.jsx(ut,{asChild:!0,children:s.jsx(nt,{type:"button",variant:"ghost",size:"xs",className:"w-6 shrink-0 rounded-full px-0 text-muted-foreground hover:text-foreground",onClick:W,disabled:V,"aria-label":K,children:y})}),e[44]=W,e[45]=V,e[46]=K,e[47]=I):I=e[47];let $;e[48]!==a?($=a("contextPanel.browser.device.rotate"),e[48]=a,e[49]=$):$=e[49];let z;e[50]!==$?(z=s.jsx(ft,{sideOffset:6,children:$}),e[50]=$,e[51]=z):z=e[51];let G;e[52]!==I||e[53]!==z?(G=s.jsxs(dt,{children:[I,z]}),e[52]=I,e[53]=z,e[54]=G):G=e[54];let J;e[55]!==c||e[56]!==u?(J=u&&c<1?s.jsxs("span",{className:"shrink-0 typography-micro tabular-nums text-muted-foreground",children:[Math.round(c*100),"%"]}):null,e[55]=c,e[56]=u,e[57]=J):J=e[57];let Z;e[58]===Symbol.for("react.memo_cache_sentinel")?(Z=["system","light","dark"],e[58]=Z):Z=e[58];let re;e[59]!==o||e[60]!==i||e[61]!==a?(re=s.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:Z.map(he=>s.jsx(nt,{type:"button",variant:o===he?"secondary":"ghost",size:"xs",className:ye("shrink-0 rounded-full px-2.5 typography-micro",o===he?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>i(he),"aria-pressed":o===he,children:a(he==="system"?"contextPanel.browser.device.schemeSystem":he==="light"?"contextPanel.browser.device.schemeLight":"contextPanel.browser.device.schemeDark")},he))}),e[59]=o,e[60]=i,e[61]=a,e[62]=re):re=e[62];let ee;return e[63]!==N||e[64]!==P||e[65]!==_||e[66]!==G||e[67]!==J||e[68]!==re?(ee=s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[N,P,D,_,G,J,re]}),e[63]=N,e[64]=P,e[65]=_,e[66]=G,e[67]=J,e[68]=re,e[69]=ee):ee=e[69],ee};function Qv(t){return s.jsx("option",{value:t.id,children:t.label},t.id)}const Xv=t=>{try{const e=new URL(t).pathname;return e==="/"?"":e}catch{return""}},Jv=2e3,Zv=()=>{if(typeof window>"u"||window.__OPENCHAMBER_ELECTRON__)return!1;const t=fr();if(!t)return!1;try{return!so(new URL(t,window.location.href).toString())}catch{return!1}},Of=t=>{const e=tt.c(33),{onOpen:n,directory:r}=t,o=r===void 0?"":r,{t:i}=mt();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={kind:"loading"},e[0]=c):c=e[0];const[a,d]=l.useState(c),u=Nx(o),[h]=l.useState(Zv);let f,g;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{let P=!0,D=null;const F=new AbortController,B=()=>{Vy(F.signal).then(E=>{P&&(d(E),D=setTimeout(B,Jv))})};return B(),()=>{P=!1,D&&clearTimeout(D),F.abort()}},g=[],e[1]=f,e[2]=g):(f=e[1],g=e[2]),l.useEffect(f,g);const b=a.kind==="ready"?a.servers:null;let S;e[3]!==u||e[4]!==b?(S=Gy({announced:u,discovered:b}),e[3]=u,e[4]=b,e[5]=S):S=e[5];const v=S;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx(yu,{width:110,height:110,className:"shrink-0 opacity-20"}),e[6]=p):p=e[6];let m;e[7]!==i?(m=i("contextPanel.browser.empty"),e[7]=i,e[8]=m):m=e[8];let x;e[9]!==m?(x=s.jsx("span",{className:"typography-ui-header text-foreground",children:m}),e[9]=m,e[10]=x):x=e[10];let w;e[11]!==i?(w=i("contextPanel.browser.emptyHint"),e[11]=i,e[12]=w):w=e[12];let j;e[13]!==w?(j=s.jsx("span",{className:"typography-micro text-muted-foreground",children:w}),e[13]=w,e[14]=j):j=e[14];let N;e[15]!==j||e[16]!==x?(N=s.jsxs("div",{className:"flex shrink-0 flex-col gap-1",children:[x,j]}),e[15]=j,e[16]=x,e[17]=N):N=e[17];let A;e[18]!==u||e[19]!==v||e[20]!==o||e[21]!==n||e[22]!==h||e[23]!==i?(A=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?i("contextPanel.browser.devServers.justStarted"):i("contextPanel.browser.devServers.title")}),h?s.jsx("span",{className:"shrink-0 pb-1 text-left typography-micro text-muted-foreground",children:i("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(P=>s.jsxs(nt,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 justify-start gap-2",onClick:()=>{jx(o),n(P.url)},children:[s.jsx(R,{name:"global",className:"size-3.5 shrink-0","aria-hidden":"true"}),s.jsx("span",{className:"truncate",children:Cl(P.url)||P.url}),s.jsx("span",{className:"ml-auto truncate typography-micro text-muted-foreground",children:Xv(P.url)})]},P.port))})]}):null,e[18]=u,e[19]=v,e[20]=o,e[21]=n,e[22]=h,e[23]=i,e[24]=A):A=e[24];let k;e[25]!==v.length||e[26]!==a.kind||e[27]!==i?(k=v.length===0&&a.kind==="unavailable"?s.jsx("span",{className:"typography-micro text-muted-foreground",children:i("contextPanel.browser.devServers.unavailable")}):null,e[25]=v.length,e[26]=a.kind,e[27]=i,e[28]=k):k=e[28];let C;return e[29]!==N||e[30]!==A||e[31]!==k?(C=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:[p,N,A,k]}),e[29]=N,e[30]=A,e[31]=k,e[32]=C):C=e[32],C},zs=t=>Math.round(t),ew=(t,e)=>{const n=t.text.trim(),r=Object.entries(t.attributes).map(([a,d])=>`${a}="${d}"`).join(" "),o=t.ancestry.map(a=>a.selectorPart).join(" > "),i=t.computedStyle,c=t.bounds;return[`Element ${e+1}: ${t.tag}`,n?`- Text: ${n}`:null,`- Selector: ${t.selector}`,`- Path: ${t.path}`,o?`- Ancestry: ${o}`:null,r?`- Attributes: ${r}`:null,`- Bounds: x=${zs(c.x)}, y=${zs(c.y)}, width=${zs(c.width)}, height=${zs(c.height)}`,`- Styles: display=${i.display??""}; position=${i.position??""}; font=${i.fontWeight??""} ${i.fontSize??""} / ${i.lineHeight??""} ${i.fontFamily??""}; color=${i.color??""}; background=${i.backgroundColor??""}`].filter(a=>typeof a=="string")},tw=(t,e)=>{const n=t.rect;return`Region ${e+1}: x=${zs(n.x)}, y=${zs(n.y)}, width=${zs(n.width)}, height=${zs(n.height)}`},sw=(t,e)=>{const n=t.bounds;return`Drawing ${e+1}: ${t.points.length} points over x=${zs(n.x)}, y=${zs(n.y)}, width=${zs(n.width)}, height=${zs(n.height)}`},nw=({payload:t,screenshotAttached:e,intro:n})=>{const r=n.replace(/[.:]+$/g,""),o=t.comment.trim(),i=[`${r}:`,`Page: ${t.pageTitle.trim()||t.pageUrl||"browser"}`,t.pageTitle.trim()&&t.pageUrl?`URL: ${t.pageUrl}`:null,`Viewport: ${zs(t.viewport.width)}x${zs(t.viewport.height)}, DPR ${t.devicePixelRatio}`,`Screenshot: ${e?"attached":"not attached"}`,o?`Comment: ${o}`:null];for(const[c,a]of t.elements.entries())i.push("",...ew(a.element,c));return t.regions.length>0&&(i.push(""),t.regions.forEach((c,a)=>i.push(tw(c,a)))),t.strokes.length>0&&(i.push(""),t.strokes.forEach((c,a)=>i.push(sw(c,a)))),i.filter(c=>typeof c=="string").join(`
|
|
899
|
-
`)},rw=t=>{const e=tt.c(7),{t:n}=mt(),r=Je(iw),o=Je(aw),i=Ia(lw),c=Th(cw);let a;return e[0]!==c||e[1]!==i||e[2]!==r||e[3]!==t||e[4]!==o||e[5]!==n?(a=async d=>{const u=r??(o?"draft":null);if(!u){Ee.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(d.screenshot)try{await c(d.screenshot),h=!0}catch{h=!1}i({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:nw({payload:d.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Ee.success(n("contextPanel.browser.annotate.attached"))},e[0]=c,e[1]=i,e[2]=r,e[3]=t,e[4]=o,e[5]=n,e[6]=a):a=e[6],a},ow=()=>{const t=tt.c(16),{t:e}=mt();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 o;t[4]!==e?(o=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=o):o=t[5];let i;t[6]!==e?(i=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=i):i=t[7];let c;t[8]!==e?(c=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=c):c=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==o||t[13]!==i||t[14]!==c?(a={select:n,marquee:r,draw:o,commentPlaceholder:i,submit:c},t[10]=n,t[11]=r,t[12]=o,t[13]=i,t[14]=c,t[15]=a):a=t[15],a};function iw(t){return t.currentSessionId}function aw(t){return t.newSessionDraft?.open}function lw(t){return t.addDraft}function cw(t){return t.addAttachedFile}const dw=3e4,uw=3,fw=250,mw={attempts:0,windowStartedAt:null},hw=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=dw,r=n?0:t.attempts;return r>=uw?null:{delayMs:fw*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},pw=-3,qo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",Gr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},gw=(t,{initialUrl:e,onUrlChange:n})=>{const[r,o]=l.useState(e?{kind:"loading",url:e}:Qy),[i,c]=l.useState(e),[a,d]=l.useState(""),[u,h]=l.useState(!1),[f,g]=l.useState(!1),b=l.useRef(n);b.current=n;const S=l.useRef(mw);return l.useEffect(()=>{if(!t)return;const v=()=>{try{const D=t.getURL();return qo(D)?D:""}catch{return""}},p=()=>{try{h(t.canGoBack()),g(t.canGoForward())}catch{}},m=D=>{qo(D)&&(c(D),b.current(D))},x=()=>{const D=v();o({kind:"loading",url:D})},w=()=>{const D=v();let F="";try{F=t.getTitle()||""}catch{F=""}d(F),m(D),p(),o(B=>B.kind==="failed"&&B.url===D?B:{kind:"ready",url:D,title:F})},j=D=>{const F=Gr(D);qo(F.url)&&(m(F.url),p())},N=D=>{const F=Gr(D),B=Array.isArray(F.favicons)?F.favicons.find(Boolean):"",E=v();B&&E&&yf.getState().resolve(E,B)},A=D=>{const F=Gr(D);typeof F.title=="string"&&d(F.title)},k=D=>{const F=Gr(D);if(F.isMainFrame===!1)return;const B=typeof F.errorCode=="number"?F.errorCode:0;B!==pw&&o({kind:"failed",url:qo(F.validatedURL)?F.validatedURL:v(),code:B,description:typeof F.errorDescription=="string"?F.errorDescription:""})};let C=null;const P=()=>{const D=v(),F=hw(S.current,Date.now());if(!F){o({kind:"failed",url:D,code:0,description:"",crashed:!0});return}S.current=F.state,o({kind:"loading",url:D}),C=setTimeout(()=>{C=null;try{t.reload()}catch{o({kind:"failed",url:D,code:0,description:"",crashed:!0})}},F.delayMs)};t.addEventListener("did-start-loading",x),t.addEventListener("did-stop-loading",w),t.addEventListener("did-navigate",j),t.addEventListener("did-navigate-in-page",j),t.addEventListener("page-title-updated",A),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",k),t.addEventListener("render-process-gone",P),t.addEventListener("crashed",P);try{!t.isLoading()&&v()&&w()}catch{}return()=>{C!==null&&clearTimeout(C),t.removeEventListener("render-process-gone",P),t.removeEventListener("crashed",P),t.removeEventListener("did-start-loading",x),t.removeEventListener("did-stop-loading",w),t.removeEventListener("did-navigate",j),t.removeEventListener("did-navigate-in-page",j),t.removeEventListener("page-title-updated",A),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",k)}},[t]),{status:r,url:i,title:a,canGoBack:u,canGoForward:f}},xw=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,bw=4e4,ed=.5,yw=-3,vw=4,ww="persist:openchamber-browser",td=20,Sw=600,jw=2e4,kw=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=mt(),{currentTheme:o}=_r(),i=l.useRef(null),[c,a]=l.useState(null),d=l.useCallback(te=>{i.current=te,a(te)},[]),u=xe(te=>te.setContextPanelTabTargetPath),h=l.useRef(Qr(t)),f=h.current!==pn?h.current:"",[g,b]=l.useState(f?null:pn),[S,v]=l.useState(f),[p,m]=l.useState(!1),[x,w]=l.useState(!1),[j,N]=l.useState(0),[A,k]=l.useState(!1),[C,P]=l.useState(Ai),D=l.useRef(C);D.current=C;const F=l.useRef([]),[B,E]=l.useState("system"),[_,W]=l.useState({width:0,height:0}),V=l.useRef(null),K=l.useRef(null),y=l.useRef(!1),I=l.useRef(Date.now()),$=l.useCallback(te=>{!te||te===pn||!e||!n||u(e,n,te)},[e,n,u]),z=gw(c,{initialUrl:f,onUrlChange:l.useCallback(te=>{const ae=po(te);v(ae),$(ae)},[$])}),[G,J]=l.useState(null),Z=rw(e),re=ow(),ee=z.status.kind==="loading",he=eo(Df(e)),be=eo(te=>te.recordVisit),Y=eo(te=>te.forget);l.useEffect(()=>{z.status.kind==="ready"&&be(e,{url:po(z.status.url),title:z.status.title})},[e,z.status,be]);const we=l.useMemo(()=>Af(he,S),[he,S]),me=l.useCallback(te=>{const ae=Qr(te);ae!==pn&&(v(ae),J(null),qc(ae).then(de=>{const H=i.current;if(!H){b(de);return}try{H.loadURL(de)}catch{b(de)}}).catch(de=>{de instanceof So&&J(ae)}))},[]);l.useEffect(()=>{if(!f)return;let te=!0;return qc(f).then(ae=>{te&&b(ae)}).catch(ae=>{if(te){if(ae instanceof So){J(f),b(pn);return}b(f)}}),()=>{te=!1}},[]);const Q=l.useMemo(()=>({executeJavaScript:async(te,ae)=>{const de=i.current;if(!de)throw new Error("Browser view is not available");return de.executeJavaScript(te,ae)},capturePage:async()=>{const te=i.current;if(!te)return null;const ae=te.getWebContentsId();return Number.isFinite(ae)?await yo("desktop_browser_capture_page",{webContentsId:ae}):null}}),[]),pe=l.useCallback(()=>{if(p){m(!1),li(Q);return}if(!z.url){Ee.error(r("contextPanel.browser.annotate.noPage"));return}const te=dv(o.metadata.variant==="light"?"light":"dark");m(!0),lv({host:Q,theme:te,labels:re}).then(async ae=>{m(!1),ae&&await Z(ae)}).catch(()=>{m(!1),Ee.error(r("contextPanel.browser.annotate.failed"))})},[Q,Z,o,p,z.url,re,r]);l.useEffect(()=>{if(!p)return;const te=ae=>{ae.key==="Escape"&&(ae.preventDefault(),ae.stopImmediatePropagation(),m(!1),li(Q))};return window.addEventListener("keydown",te,!0),()=>window.removeEventListener("keydown",te,!0)},[Q,p]);const ve=l.useCallback(async(te=8e3)=>{const ae=Date.now();for(;;){const de=i.current;if(!de)return!1;let H=!1;try{H=de.isLoading()}catch{return!1}if(!H)return!0;if(Date.now()-ae>te)return!1;await new Promise(ge=>setTimeout(ge,120))}},[]),Te=l.useCallback(async(te,ae)=>{const de=i.current;if(!de)throw new Error("The browser panel is not ready");const H=()=>{Zc(ae.viewport)&&(P(Ga(ae.viewport)),k(!0))};if(te==="browser.back"||te==="browser.forward"){const fe=te==="browser.back";if(!(fe?de.canGoBack():de.canGoForward()))throw new Error(fe?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");fe?de.goBack():de.goForward(),await new Promise(se=>setTimeout(se,150)),await ve();let le="";try{le=de.getTitle()||""}catch{le=""}return{url:po(de.getURL()),title:le}}if(te==="browser.capture"){await ve();const fe=await Q.capturePage();if(!fe)throw new Error("The page could not be captured");let X="";try{X=de.getTitle()||""}catch{X=""}return{...fe,url:po(de.getURL()),title:X,viewport:Go(D.current)}}if(te==="browser.resize"){if(!Zc(ae.viewport))throw new Error("viewport is required");return H(),await new Promise(fe=>setTimeout(fe,200)),await ve(),{viewport:Go(Ga(ae.viewport))}}if(te==="browser.open"){const fe=typeof ae.url=="string"?ae.url:"";if(!fe)throw new Error("url is required");H(),me(fe),await new Promise(se=>setTimeout(se,150));const X=await ve(25e3);let le="";try{le=de.getTitle()||""}catch{le=""}return{url:Qr(fe),title:le,opened:!0,settled:X,viewport:Go(D.current)}}await ve();const ge=fe=>typeof fe=="string"&&fe?fe:void 0,M=(()=>{switch(te){case"browser.snapshot":return Bv({selector:ge(ae.selector)});case"browser.click":return Lv({selector:ge(ae.selector),text:ge(ae.text)});case"browser.type":return _v({selector:String(ae.selector??""),value:String(ae.value??""),submit:ae.submit===!0});case"browser.inspect":return Uv({selector:String(ae.selector??"")});case"browser.scroll":return $v({selector:ge(ae.selector),direction:ge(ae.direction)});default:return null}})();if(!M)throw new Error(`Unsupported browser action: ${te}`);const oe=await de.executeJavaScript(M,!0);if(!oe||typeof oe!="object")throw new Error("The page returned no result");const De=oe;if(De.ok!==!0)throw new Error(typeof De.error=="string"&&De.error?De.error:"Browser action failed");if(te==="browser.snapshot"){const fe=F.current;return{...De,viewport:Go(D.current),...fe.length>0?{consoleProblems:[...fe]}:{}}}return(te==="browser.click"||te==="browser.type"&&ae.submit===!0)&&(await new Promise(fe=>setTimeout(fe,150)),await ve()),oe},[Q,me,ve]);l.useEffect(()=>Sv({run:Te}),[Te]),l.useEffect(()=>{const te=Q;return()=>{li(te)}},[Q]),l.useEffect(()=>{if(!c)return;const te=de=>{const H=de;if(typeof H.level!="number"||H.level<2)return;const ge=H.sourceId?`${H.sourceId}${H.line?`:${H.line}`:""}`:"";F.current.push({level:H.level>=3?"error":"warning",message:String(H.message??"").slice(0,400),source:ge}),F.current.length>td&&F.current.splice(0,F.current.length-td)},ae=()=>{F.current=[]};return c.addEventListener("console-message",te),c.addEventListener("did-start-loading",ae),()=>{c.removeEventListener("console-message",te),c.removeEventListener("did-start-loading",ae)}},[c]);const ke=l.useRef(new Set),Ie=l.useCallback(te=>{ke.current.clear(),me(te)},[me]);l.useEffect(()=>{if(!c)return;const te=de=>{const H=Gr(de),ge=typeof H.url=="string"?H.url:"";!ge||!Yc(ge)||(de.preventDefault(),me(ge))},ae=de=>{const H=Gr(de);if(H.isMainFrame===!1||H.errorCode===-3)return;const ge=typeof H.validatedURL=="string"?H.validatedURL:"";!ge||!Yc(ge)||ke.current.has(ge)||(ke.current.add(ge),me(ge))};return c.addEventListener("will-navigate",te),c.addEventListener("did-fail-load",ae),()=>{c.removeEventListener("will-navigate",te),c.removeEventListener("did-fail-load",ae)}},[me,c]),l.useEffect(()=>{if(!c)return;const te=ae=>{const de=ae.detail;ae.preventDefault(),de?.url&&me(de.url)};return c.addEventListener("new-window",te),()=>c.removeEventListener("new-window",te)},[me,c]);const Ne=l.useCallback(te=>{const ae=Math.min(vw,Math.max(yw,te));N(ae);try{i.current?.setZoomLevel(ae)}catch{}},[]),Ae=l.useCallback(te=>{yo("desktop_browser_clear_data",{partition:ww,cookies:te==="cookies",cache:te==="cache"}).then(()=>{Ee.success(r(te==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{i.current?.reloadIgnoringCache()}catch{}}).catch(()=>Ee.error(r("contextPanel.browser.clearFailed")))},[r]);l.useEffect(()=>{const te=V.current;if(!te||typeof ResizeObserver>"u")return;const ae=new ResizeObserver(de=>{const H=de[0]?.contentRect;H&&W({width:H.width,height:H.height})});return ae.observe(te),()=>ae.disconnect()},[]);const Se=l.useCallback(te=>{E(te);const ae=i.current;if(!ae)return;let de=-1;try{de=ae.getWebContentsId()}catch{return}yo("desktop_browser_set_color_scheme",{webContentsId:de,scheme:te}).catch(H=>{E("system"),Ee.error(H instanceof Error?H.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),Oe=l.useCallback(()=>{try{ee?i.current?.stop():i.current?.reload()}catch{}},[ee]),ne=z.status;l.useEffect(()=>{const te=()=>{w(!0);const H=setTimeout(()=>{try{i.current?.reload()}catch{}},Sw);return()=>clearTimeout(H)};if(ne.kind==="failed"){if(!Uy(ne.code,ne.url)){w(!1);return}const H=Date.now(),ge=K.current?.url===ne.url?K.current:{url:ne.url,startedAt:H};if(K.current=ge,H-ge.startedAt>bw){w(!1);return}return te()}if(ne.kind==="loading")return;if(K.current=null,ne.kind!=="ready"||!ne.url||!so(ne.url)){y.current=!0,w(!1);return}if(y.current||Date.now()-I.current>jw){y.current=!0,w(!1);return}let ae=!1,de=null;return Hy(po(ne.url)).then(H=>{if(!ae){if(H===null||H<500){y.current=!0,w(!1);return}de=te()}}),()=>{ae=!0,de?.()}},[ne]);const ce=z.status.kind==="failed"&&!x?z.status:null,Re=Kv(C,_);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(If,{address:S,onAddressChange:v,onSubmit:Ie,suggestions:we,onForgetSuggestion:te=>Y(e,te),onBack:()=>{try{i.current?.goBack()}catch{}},onForward:()=>{try{i.current?.goForward()}catch{}},onReload:Oe,onOpenExternal:()=>{Oi(z.url||S)},canGoBack:z.canGoBack,canGoForward:z.canGoForward,isLoading:ee,onAnnotate:pe,isAnnotating:p,onOpenDevTools:()=>{try{i.current?.openDevTools()}catch{}},onHardReload:()=>{try{i.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Ne(j+ed),onZoomOut:()=>Ne(j-ed),onZoomReset:()=>Ne(0),zoomPercent:Math.round(Math.pow(1.2,j)*100),onClearCookies:()=>Ae("cookies"),onClearCache:()=>Ae("cache"),onToggleDeviceBar:()=>k(te=>!te),isDeviceBarOpen:A}),A?s.jsx(Yv,{viewport:C,onViewportChange:P,colorScheme:B,onColorSchemeChange:Se,scale:Re?.scale??1}):null,s.jsxs("div",{ref:V,className:ye("relative min-h-0 flex-1 bg-background",Re&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null?s.jsx("webview",{ref:d,src:g,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,g!==null&&!f&&!z.url&&!ee?s.jsx(Of,{onOpen:Ie,directory:e}):null,x?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,G?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:G})})]}):null,ce&&!G?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:ce.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ce.crashed?r("contextPanel.browser.crashedHint"):ce.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ee?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]})]})},Cw=t=>{const e=tt.c(49),{initialUrl:n,directory:r,tabID:o}=t,{t:i}=mt(),c=xe(Aw);let a;e[0]!==n?(a=Qr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==pn?d:"",[h,f]=l.useState(u),[g,b]=l.useState(u);let S;e[2]!==u?(S=u?[u]:[],e[2]=u,e[3]=S):S=e[3];const[v,p]=l.useState(S),[m,x]=l.useState(u?0:-1),[w,j]=l.useReducer(Dw,0);let N;e[4]!==r||e[5]!==c||e[6]!==o?(N=ee=>{!ee||ee===pn||!r||!o||c(r,o,ee)},e[4]=r,e[5]=c,e[6]=o,e[7]=N):N=e[7];const A=N;let k;e[8]!==r?(k=Df(r),e[8]=r,e[9]=k):k=e[9];const C=eo(k),P=eo(Pw),D=eo(Ew);let F;e[10]!==h||e[11]!==C?(F=Af(C,h),e[10]=h,e[11]=C,e[12]=F):F=e[12];const B=F;let E;e[13]!==r||e[14]!==m||e[15]!==A||e[16]!==P?(E=ee=>{const he=Qr(ee);he!==pn&&(f(he),b(he),A(he),P(r,{url:he}),p(be=>{const Y=m>=0?be.slice(0,m+1):[];return Y[Y.length-1]===he?(x(Y.length-1),Y):(x(Y.length),[...Y,he])}))},e[13]=r,e[14]=m,e[15]=A,e[16]=P,e[17]=E):E=e[17];const _=E;let W;e[18]!==v||e[19]!==A?(W=ee=>{const he=v[ee];he&&(x(ee),f(he),b(he),A(he))},e[18]=v,e[19]=A,e[20]=W):W=e[20];const V=W;let K;e[21]!==r||e[22]!==D?(K=ee=>D(r,ee),e[21]=r,e[22]=D,e[23]=K):K=e[23];let y,I;e[24]!==V||e[25]!==m?(I=()=>V(m-1),y=()=>V(m+1),e[24]=V,e[25]=m,e[26]=y,e[27]=I):(y=e[26],I=e[27]);let $;e[28]!==h||e[29]!==g?($=()=>{Oi(g||h)},e[28]=h,e[29]=g,e[30]=$):$=e[30];const z=m>0,G=m>=0&&m<v.length-1;let J;e[31]!==h||e[32]!==_||e[33]!==B||e[34]!==y||e[35]!==$||e[36]!==z||e[37]!==G||e[38]!==K||e[39]!==I?(J=s.jsx(If,{address:h,onAddressChange:f,onSubmit:_,suggestions:B,onForgetSuggestion:K,onBack:I,onForward:y,onReload:j,onOpenExternal:$,canGoBack:z,canGoForward:G,isLoading:!1}),e[31]=h,e[32]=_,e[33]=B,e[34]=y,e[35]=$,e[36]=z,e[37]=G,e[38]=K,e[39]=I,e[40]=J):J=e[40];let Z;e[41]!==g||e[42]!==_||e[43]!==w||e[44]!==i?(Z=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:g?s.jsx("iframe",{src:g,title:i("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${w}`):s.jsx(Of,{onOpen:_})}),e[41]=g,e[42]=_,e[43]=w,e[44]=i,e[45]=Z):Z=e[45];let re;return e[46]!==J||e[47]!==Z?(re=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[J,Z]}),e[46]=J,e[47]=Z,e[48]=re):re=e[48],re},Nw=t=>{const e=tt.c(3),[n]=l.useState(xw);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(kw,{...t}):s.jsx(Cw,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function Aw(t){return t.setContextPanelTabTargetPath}function Dw(t){return t+1}function Pw(t){return t.recordVisit}function Ew(t){return t.forget}const Tw=Zs(()=>Js(()=>import("./WalkthroughView-Cc5Hd6P5.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])).then(t=>({default:t.WalkthroughView}))),Iw=Zs(()=>Js(()=>import("./DiffView-DEGlNjMH.js"),__vite__mapDeps([121,1,2,4,5,6,7,8,3,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])).then(t=>({default:t.DiffView}))),Rw=Zs(()=>Js(()=>import("./FilesView-CzUgIvUm.js"),__vite__mapDeps([122,1,2,4,5,6,7,8,3,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,113,123,124,125,126,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,127,128,114,115,129,130,112,131,118])).then(t=>({default:t.FilesView}))),Mw=Zs(()=>Js(()=>import("./GitView-C-n17voy.js"),__vite__mapDeps([132,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,113,133,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,114,115,117,118,119,120])).then(t=>({default:t.GitView}))),Ow=Zs(()=>Js(()=>import("./PlanView-CWM0iyFk.js"),__vite__mapDeps([134,1,2,4,5,6,7,8,123,50,51,52,53,54,55,72,48,49,56,124,125,3,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,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,73,74,75,76,77,78,79,80,112,113,131,114,115,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(t=>({default:t.PlanView}))),Fw=380,Bw=1400,Ff=600,Lw=100,_w=24,Pi=new Map,$w=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},sd=t=>Number.isFinite(t)?Math.min(Bw,Math.max(Fw,Math.round(t))):Ff,zw=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},Uw=(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},Bf=(t,e)=>e(t==="chat"?"contextPanel.mode.chat":t==="file"?"contextPanel.mode.files":t==="diff"?"contextPanel.mode.diff":t==="walkthrough"?"contextPanel.mode.walkthrough":t==="plan"?"contextPanel.mode.plan":t==="browser"?"contextPanel.mode.browser":t==="git"?"layout.rightSidebar.git":t==="pr"?"contextPanel.mode.pr":t==="notes"?"contextRail.surface.notes":t==="terminal"?"layout.mainTab.terminal":"contextPanel.mode.context"),Ww=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},Vw=(t,e,n)=>{if(t.mode==="chat"){const r=qa(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||n("contextPanel.mode.chat")}return t.mode==="browser"?Cl(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Ww(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Bf(t.mode,n)},nd=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(cl,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(Ju,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(R,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(R,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(R,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(R,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(R,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(R,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(R,{name:"chat-4",className:"h-3.5 w-3.5"});if(t.mode==="browser"){const n=Hw(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(R,{name:"global",className:"h-3.5 w-3.5"})}},Hw=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Kw=200,Gw=480,qw=({visible:t})=>{const{t:e}=mt(),n=xe(m=>m.contextEditorTreeWidth),r=xe(m=>m.setContextEditorTreeWidth),[o,i]=l.useState(!1),c=l.useRef(0),a=l.useRef(n),d=l.useRef(null),u=l.useRef(null),h=l.useRef(null),f=l.useCallback(m=>Math.min(Gw,Math.max(Kw,Math.round(m))),[]),g=l.useCallback(m=>{const x=h.current;x&&(x.style.width=`${m}px`,x.style.setProperty("--oc-editor-tree-width",`${m}px`))},[]),b=m=>{if(t){try{m.currentTarget.setPointerCapture(m.pointerId)}catch{}u.current=m.pointerId,i(!0),c.current=m.clientX,a.current=n,d.current=n,m.preventDefault()}},S=m=>{if(!o||u.current!==m.pointerId)return;const x=c.current-m.clientX,w=f(a.current+x);d.current!==w&&(d.current=w,g(w))},v=m=>{if(u.current!==m.pointerId)return;try{m.currentTarget.releasePointerCapture(m.pointerId)}catch{}const x=f(d.current??n);u.current=null,d.current=null,i(!1),r(x)},p=t?n:0;return s.jsxs("div",{ref:h,className:ye("relative h-full flex-shrink-0 overflow-hidden border-l border-border bg-background will-change-[width] motion-reduce:transition-none",!t&&"border-l-0"),style:{width:`${o?d.current??p:p}px`,"--oc-editor-tree-width":`${o?d.current??n:n}px`,overflowX:"clip",transitionProperty:o?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&s.jsx("div",{className:ye("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",o&&"bg-[var(--interactive-border)]"),onPointerDown:b,onPointerMove:S,onPointerUp:v,onPointerCancel:v,role:"separator","aria-orientation":"vertical","aria-label":e("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:ye("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",o&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:s.jsx(dy,{})})]})},qa=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Yw=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},Qw=(t,e)=>{if(e.length===0)return Pi;const n=new Set(e),r=new Map;for(const o of t){if(!n.has(o.id))continue;const i=o.title?.trim();i&&r.set(o.id,i)}return r.size===0?Pi:r},Xw=(t,e)=>{const n=ol(t),r=l.useRef(Pi),o=l.useRef(e);return o.current=e,l.useSyncExternalStore(n.subscribe,l.useCallback(()=>{const i=Qw(n.getState().session,o.current);return Yw(r.current,i)?r.current:(r.current=i,i)},[n]),()=>Pi)},Jw=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,Zw=()=>{const{t}=mt(),e=Io()??"",n=l.useMemo(()=>$w(e),[e]),r=xe(U=>n?U.contextPanelByDirectory[n]:void 0),o=xe(U=>U.closeContextPanel),i=xe(U=>U.closeContextPanelTab),c=xe(U=>U.openContextPanelTab),a=xe(U=>U.toggleContextPanelExpanded),d=xe(U=>U.setContextPanelWidth),u=xe(U=>U.setActiveContextPanelTab),h=xe(U=>U.openContextBrowser);l.useEffect(()=>{if(e)return jv(U=>h(e,U))},[e,h]);const f=xe(U=>U.reorderContextPanelTabs),g=Bn(U=>U.setSelectedPath),b=xe(U=>U.contextEditorTreeVisible),S=xe(U=>U.toggleContextEditorTree),v=xe(U=>U.openNewContextBrowserTab),p=yf(U=>U.byOrigin),m=xe(U=>U.allowPromptingSubagentSessions),{themeMode:x,setThemeMode:w,lightThemeId:j,darkThemeId:N,currentTheme:A}=_r(),k=l.useMemo(()=>r?.tabs??[],[r?.tabs]),C=k.find(U=>U.id===r?.activeTabId)??k[k.length-1]??null,P=!!(r?.isOpen&&C),D=!!(P&&r?.expanded),[F,B]=l.useState(null),E=C?.mode??null,_=E?r?.widthByMode?.[E]:void 0,W=E?Ih(E):.5,V=F??(typeof window<"u"?window.innerWidth:Ff*2),K=sd(_??Math.round(W*V)),y=l.useMemo(()=>{const U=[];for(const Be of k){if(Be.mode!=="chat")continue;const Fe=qa(Be.dedupeKey);Fe&&!U.includes(Fe)&&U.push(Fe)}return U},[k]),I=Xw(n||void 0,y),[$,z]=l.useState(!1),G=l.useRef(0),J=l.useRef(K),Z=l.useRef(null),re=l.useRef(null),ee=l.useRef(null),he=l.useRef(new Map),be=l.useRef(new Map),Y=l.useRef(!1);l.useLayoutEffect(()=>{const U=ee.current?.parentElement;if(!U||typeof ResizeObserver>"u")return;const Be=new ResizeObserver(()=>{B(U.clientWidth||null)});return Be.observe(U),B(U.clientWidth||null),()=>Be.disconnect()},[]),l.useEffect(()=>{if(!P||Y.current){Y.current=P;return}const U=window.requestAnimationFrame(()=>{ee.current?.focus({preventScroll:!0})});return Y.current=!0,()=>window.cancelAnimationFrame(U)},[P]);const we=l.useRef(null),me=l.useRef(null),Q=l.useCallback(()=>{me.current=null;const U=ee.current,Be=Z.current;!U||Be===null||U.style.setProperty("--oc-context-panel-width",`${Be}px`)},[]);l.useEffect(()=>()=>{me.current!==null&&clearTimeout(me.current)},[]);const pe=l.useCallback(U=>{const Be=sd(U),Fe=we.current;return Fe===null?Be:Math.min(Be,Math.max(1,Fe))},[]),ve=l.useCallback(U=>{!P||D||!n||(re.current=U.pointerId,z(!0),G.current=U.clientX,J.current=K,Z.current=K,we.current=zw(ee.current),document.documentElement.style.cursor="col-resize",U.preventDefault())},[n,D,P,K]),Te=l.useCallback(()=>{const U=pe(Z.current??K);Z.current=null,we.current=null,me.current!==null&&(clearTimeout(me.current),me.current=null),document.documentElement.style.cursor="",n&&E&&d(n,E,U),z(!1),re.current=null},[E,pe,n,d,K]);l.useEffect(()=>{if(!$)return;const U=Ye=>{if(re.current!==Ye.pointerId)return;const at=G.current-Ye.clientX,st=pe(J.current+at);Z.current!==st&&(Z.current=st,me.current===null&&(me.current=setTimeout(Q,Lw)))},Be=Ye=>{re.current===Ye.pointerId&&Te()},Fe=()=>{Te()};return window.addEventListener("pointermove",U),window.addEventListener("pointerup",Be),window.addEventListener("pointercancel",Be),window.addEventListener("blur",Fe),()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",Be),window.removeEventListener("pointercancel",Be),window.removeEventListener("blur",Fe)}},[Q,pe,Te,$]),l.useEffect(()=>{$||(Z.current=null,document.documentElement.style.cursor="")},[$]);const ke=l.useCallback(()=>{n&&o(n)},[o,n]),Ie=l.useCallback(()=>{n&&a(n)},[n,a]),Ne=l.useCallback(U=>{U.key==="Escape"&&(Rh(U.target)||(U.preventDefault(),U.stopPropagation(),ke()))},[ke]);l.useEffect(()=>{if(!(!n||!C)&&C.mode==="file"&&C.targetPath){g(n,C.targetPath,{allowOutsideRoot:!0});return}},[C,n,g]);const Ae=l.useMemo(()=>k.filter(U=>U.mode==="chat"),[k]),Se=P&&C?.mode==="chat"?C.id:null,Oe=P&&C?.mode==="chat"?qa(C.dedupeKey):null,ne=qg(Ae,Se);l.useEffect(()=>{if(!P||!n||!Oe||typeof window>"u")return;const U=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ia(n,Oe,!1);return}vu(Oe),ia(n,Oe,!0)};U();const Be=window.setInterval(U,1e4);return window.addEventListener("focus",U),window.addEventListener("blur",U),document.addEventListener("visibilitychange",U),()=>{window.clearInterval(Be),window.removeEventListener("focus",U),window.removeEventListener("blur",U),document.removeEventListener("visibilitychange",U),ia(n,Oe,!1)}},[Oe,n,P]);const ce=l.useCallback((U,Be,Fe)=>Yg(be.current,U,Be,n||null,Fe,{mode:x,lightThemeId:j,darkThemeId:N,currentTheme:A},{allowPromptingSubagentSessions:m}),[m,A,N,n,j,x]),Re=ne&&Oe?ce(ne.id,Oe,ne.readOnly):null;l.useEffect(()=>{const U=new Set(k.map(Be=>Be.id));for(const Be of be.current.keys())U.has(Be)||be.current.delete(Be)},[k]);const te=l.useCallback(U=>{!n||C?.mode!=="diff"||c(n,{mode:"diff",targetPath:C.targetPath,stagedDiff:U==="staged",diffScope:U})},[C,n,c]),ae=l.useCallback(()=>{if(typeof window>"u")return;const U={themeMode:x,lightThemeId:j,darkThemeId:N,currentTheme:A};for(const Be of he.current.values()){const Fe=Be.contentWindow;Fe&&Fe.postMessage({type:"openchamber:theme-sync",payload:U},window.location.origin)}},[A,N,j,x]),de=l.useCallback(()=>{if(typeof window>"u")return;const U={allowPromptingSubagentSessions:m};for(const Be of he.current.values()){const Fe=Be.contentWindow;Fe&&Fe.postMessage({type:"openchamber:chat-settings-sync",payload:U},window.location.origin)}},[m]),H=l.useCallback(()=>{if(!(typeof window>"u"))for(const[U,Be]of he.current.entries()){const Fe=Be.contentWindow;if(!Fe)continue;const Ye={visible:Se===U};Fe.postMessage({type:"openchamber:embedded-visibility",payload:Ye},window.location.origin)}},[Se]);l.useEffect(()=>{if(typeof window>"u")return;const U=Be=>{if(Be.origin!==window.location.origin||!Array.from(he.current.values()).some(bt=>bt.contentWindow===Be.source))return;const Ye=Be.data;if(Ye?.type===Qg){if(typeof Ye.requestId!="string"||!Ye.requestId)return;const bt=xn(),rt={apiBaseUrl:fr(),clientToken:ko(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:ru(),relayHostId:bt.startsWith("host:")?bt.slice(5):"",relay:Lm()??void 0};Be.source?.postMessage({type:Xg,requestId:Ye.requestId,payload:rt},Be.origin);return}if(Ye?.type==="openchamber:theme-sync-request"){ae();return}if(Ye?.type==="openchamber:chat-settings-request"){de();return}if(Ye?.type!=="openchamber:cycle-theme-request")return;const at=["light","dark","system"],ct=(at.indexOf(x)+1)%at.length;w(at[ct])};return window.addEventListener("message",U),()=>window.removeEventListener("message",U)},[de,ae,w,x]),l.useLayoutEffect(()=>{k.some(Be=>Be.mode==="chat")&&(ae(),de(),H())},[N,j,de,H,ae,k,x]);const ge=C?.mode==="file"||C?.mode==="chat"||C?.mode==="browser",ue=l.useMemo(()=>C?k.filter(U=>U.mode===C.mode):[],[C,k]),M=l.useMemo(()=>ue.map(U=>{const Be=Vw(U,I,t),Fe=Jw(Be,_w),Ye=Uw(U.targetPath,e);return{id:U.id,label:Fe,icon:nd(U,p),title:Ye?`${Be}: ${Ye}`:Be,closeLabel:t("contextPanel.tab.closeTabAria",{label:Fe})}}),[ue,e,p,I,t]),oe=C?.mode==="context"?s.jsx(Dy,{}):C?.mode==="git"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Mw,{isActive:P})}):C?.mode==="pr"?s.jsx(_b,{}):C?.mode==="notes"?s.jsx(Wu,{}):C?.mode==="plan"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Ow,{targetPath:C.targetPath})}):null,De=l.useMemo(()=>k.filter(U=>U.mode==="browser"),[k]),fe=l.useMemo(()=>k.filter(U=>U.mode==="diff"),[k]),X=l.useMemo(()=>k.some(U=>U.mode==="terminal"),[k]),le=l.useMemo(()=>k.some(U=>U.mode==="walkthrough"),[k]),se=l.useMemo(()=>k.some(U=>U.mode==="file"),[k]),T=l.useMemo(()=>k.some(U=>U.mode==="file"&&U.targetPath),[k]),ie=C?.mode==="file",je=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[ge?s.jsx(gl,{items:M,activeId:C?.id??null,onSelect:U=>{n&&u(n,U)},onClose:U=>{n&&i(n,U)},onReorder:(U,Be)=>{n&&f(n,U,Be)},layoutMode:"scrollable",variant:"default"}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[C?nd(C,p):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:C?Bf(C.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[C?.mode==="browser"?s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&v(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(R,{name:"add",className:"h-3.5 w-3.5"})}):null,ie?s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:S,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(R,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:Ie,className:"h-7 w-7 p-0",title:t(D?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(D?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:D?s.jsx(R,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:ke,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Pe=P?D?{"--oc-context-panel-width":F!==null?`${F}px`:"100%",width:F!==null?`${F}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${K}px`}:{"--oc-context-panel-width":`${K}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:ee,"data-context-panel":"true",tabIndex:-1,inert:!P||void 0,className:ye("flex min-h-0 flex-col overflow-hidden bg-background",D?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!P&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:Ne,style:Pe,children:[P&&!D&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),P&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!D&&s.jsx("div",{className:ye("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",$&&"bg-[var(--interactive-border)]"),onPointerDown:ve,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:ye("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]",!P&&"pointer-events-none select-none opacity-0"),style:{width:D?F!==null?`${F}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!P,children:[je,s.jsxs("div",{className:ye("relative min-h-0 flex-1 overflow-hidden",$&&"pointer-events-none"),children:[se?s.jsxs("div",{className:ye("absolute inset-0 flex",ie?"flex":"hidden"),children:[s.jsx("div",{className:"h-full min-w-0 flex-1",children:T?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Rw,{mode:"editor-only"})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(R,{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")})]})}),s.jsx(qw,{visible:b})]}):null,ne&&Oe&&Re?s.jsx("iframe",{ref:U=>{if(!U){he.current.delete(ne.id);return}he.current.set(ne.id,U)},src:Re,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:Oe}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{ae(),de(),H()}},ne.id):null,De.map(U=>s.jsx("div",{className:ye("absolute inset-0",C?.id!==U.id&&"hidden"),children:s.jsx(Nw,{initialUrl:U.targetPath??"",directory:n,tabID:U.id})},U.id)),fe.map(U=>s.jsx("div",{className:ye("absolute inset-0",C?.id!==U.id&&"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(Iw,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:U.diffScope??(U.stagedDiff?"staged":"working"),onDiffScopeChange:te,targetFilePath:U.targetPath,flushContent:!0})})},U.id)),X?s.jsx("div",{className:ye("absolute inset-0",C?.mode==="terminal"?"block":"hidden"),children:s.jsx(Vu,{visible:P&&C?.mode==="terminal"})}):null,le?s.jsx("div",{className:ye("absolute inset-0",C?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(Tw,{directory:e})})}):null,C?.mode!=="chat"&&!ie&&C?.mode!=="browser"&&C?.mode!=="diff"&&C?.mode!=="terminal"&&C?.mode!=="walkthrough"?oe:null]})]})]})},e1=150,t1=500,s1=[],n1=t=>t>99?"99+":String(t),r1=t=>{const e=tt.c(51),{surface:n,isActive:r,showActivityDot:o,label:i,description:c,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:h,showOrderNumber:f,onSelect:g}=t;let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:S,listeners:v,setNodeRef:p,transform:m,transition:x,isDragging:w}=bl(b);let j;e[2]!==a?(j=a!=null&&a>0?n1(a):null,e[2]=a,e[3]=j):j=e[3];const N=j;let A;e[4]!==m?(A=yl.Translate.toString(m),e[4]=m,e[5]=A):A=e[5];let k;e[6]!==A||e[7]!==x?(k={transform:A,transition:x},e[6]=A,e[7]=x,e[8]=k):k=e[8];const C=w&&"z-10 opacity-70";let P;e[9]!==C?(P=ye("relative",C),e[9]=C,e[10]=P):P=e[10];let D;e[11]!==g||e[12]!==n?(D=()=>g(n),e[11]=g,e[12]=n,e[13]=D):D=e[13];const F=d??i,B=r?"text-primary":"text-muted-foreground hover:text-foreground";let E;e[14]!==B?(E=ye("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",B),e[14]=B,e[15]=E):E=e[15];let _;e[16]!==n.icon||e[17]!==n.id?(_=n.id==="diff"?s.jsx(Ju,{}):s.jsx(R,{name:n.icon,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.id,e[18]=_):_=e[18];let W;e[19]!==N||e[20]!==h||e[21]!==o||e[22]!==f?(W=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}):N?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:N}):o?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[19]=N,e[20]=h,e[21]=o,e[22]=f,e[23]=W):W=e[23];let V;e[24]!==S||e[25]!==r||e[26]!==v||e[27]!==E||e[28]!==_||e[29]!==W||e[30]!==D||e[31]!==F?(V=s.jsx(ut,{asChild:!0,children:s.jsxs("button",{type:"button",...S,...v,onClick:D,"aria-label":F,"aria-pressed":r,className:E,children:[_,W]})}),e[24]=S,e[25]=r,e[26]=v,e[27]=E,e[28]=_,e[29]=W,e[30]=D,e[31]=F,e[32]=V):V=e[32];let K;e[33]!==i?(K=s.jsx("span",{children:i}),e[33]=i,e[34]=K):K=e[34];let y;e[35]!==c?(y=s.jsx("span",{className:"typography-micro text-muted-foreground",children:c}),e[35]=c,e[36]=y):y=e[36];let I;e[37]!==u?(I=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[37]=u,e[38]=I):I=e[38];let $;e[39]!==K||e[40]!==y||e[41]!==I?($=s.jsx(ft,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[K,y,I]})}),e[39]=K,e[40]=y,e[41]=I,e[42]=$):$=e[42];let z;e[43]!==V||e[44]!==$?(z=s.jsxs(dt,{delayDuration:e1,children:[V,$]}),e[43]=V,e[44]=$,e[45]=z):z=e[45];let G;return e[46]!==p||e[47]!==z||e[48]!==k||e[49]!==P?(G=s.jsx("div",{ref:p,style:k,className:P,children:z}),e[46]=p,e[47]=z,e[48]=k,e[49]=P,e[50]=G):G=e[50],G},o1=()=>{const t=tt.c(52),{t:e}=mt(),n=Io();let r;t[0]!==n?(r=n?Vr(n):"",t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=J=>o?J.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const c=xe(i),a=xe(i1),d=xe(a1),u=xe(l1),h=xe(c1),f=xe(d1),g=il(u1),{screenWidth:b}=pr(),S=al(o||null);let v;t[4]!==f?(v=Mh("switch_context_surface",f),t[4]=f,t[5]=v):v=t[5];const p=v,[m,x]=l.useState(!1);let w,j;t[6]!==p?(w=()=>{const J=new Set;let Z=null,re=!1;const ee=f1,he=()=>{ec(p,J)?!re&&Z===null&&(Z=setTimeout(()=>x(!0),t1)):(re=!1,Z!==null&&(clearTimeout(Z),Z=null),x(!1))},be=me=>{if(J.add(me.key.toLowerCase()),ee(me.key)&&ec(p,J)){re=!0,Z!==null&&(clearTimeout(Z),Z=null),x(!1);return}he()},Y=me=>{J.delete(me.key.toLowerCase()),he()},we=()=>{J.clear(),re=!1,Z!==null&&(clearTimeout(Z),Z=null),x(!1)};return window.addEventListener("keydown",be,!0),window.addEventListener("keyup",Y,!0),window.addEventListener("blur",we),()=>{window.removeEventListener("keydown",be,!0),window.removeEventListener("keyup",Y,!0),window.removeEventListener("blur",we),Z!==null&&clearTimeout(Z)}},j=[p],t[6]=p,t[7]=w,t[8]=j):(w=t[7],j=t[8]),l.useEffect(w,j);let N;t[9]===Symbol.for("react.memo_cache_sentinel")?(N={activationConstraint:{distance:8}},t[9]=N):N=t[9];let A;t[10]===Symbol.for("react.memo_cache_sentinel")?(A={activationConstraint:{delay:200,tolerance:6}},t[10]=A):A=t[10];const k=wi(Yr(ex,N),Yr(Zg,A)),C=c?.tabs??s1;let P;t[11]!==c?.activeTabId||t[12]!==C?(P=C.find(J=>J.id===c?.activeTabId)??null,t[11]=c?.activeTabId,t[12]=C,t[13]=P):P=t[13];const D=P,F=c?.isOpen?D?.mode??null:null,B=S?.files.length??0;let E;t[14]!==d||t[15]!==g||t[16]!==b||t[17]!==C?(E=Oh({railOrder:d,planModeEnabled:g,isVSCode:er(),screenWidth:b,tabs:C}),t[14]=d,t[15]=g,t[16]=b,t[17]=C,t[18]=E):E=t[18];const _=E;let W;t[19]!==u?(W=J=>{const{active:Z,over:re}=J;if(!re||Z.id===re.id)return;const ee=Fh(xe.getState().contextRailOrder).map(m1),he=ee.indexOf(Z.id),be=ee.indexOf(re.id);he===-1||be===-1||u(Qu(ee,he,be))},t[19]=u,t[20]=W):W=t[20];const V=W;if(!o)return null;let K;t[21]!==e?(K=e("contextRail.aria.rail"),t[21]=e,t[22]=K):K=t[22];let y;t[23]!==_?(y=_.map(h1),t[23]=_,t[24]=y):y=t[24];let I;if(t[25]!==F||t[26]!==B||t[27]!==o||t[28]!==h||t[29]!==m||t[30]!==_||t[31]!==e||t[32]!==a){let J;t[34]!==F||t[35]!==B||t[36]!==o||t[37]!==h||t[38]!==m||t[39]!==e||t[40]!==a?(J=(Z,re)=>{const ee=e(Z.labelKey),he=Z.id==="git"&&!a?B:0,be=he>0?he:null;return s.jsx(r1,{surface:Z,isActive:F===Z.mode,showActivityDot:!1,label:ee,description:e(Z.descriptionKey),badgeCount:be,badgeAriaLabel:be!==null?e(be===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:ee,count:be}):null,badgeDescription:be!==null?e(be===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:be}):null,orderNumber:re+1,showOrderNumber:m,onSelect:Y=>h(o,Y.mode)},Z.id)},t[34]=F,t[35]=B,t[36]=o,t[37]=h,t[38]=m,t[39]=e,t[40]=a,t[41]=J):J=t[41],I=_.map(J),t[25]=F,t[26]=B,t[27]=o,t[28]=h,t[29]=m,t[30]=_,t[31]=e,t[32]=a,t[33]=I}else I=t[33];let $;t[42]!==y||t[43]!==I?($=s.jsx(_a,{items:y,strategy:$a,children:I}),t[42]=y,t[43]=I,t[44]=$):$=t[44];let z;t[45]!==V||t[46]!==k||t[47]!==$?(z=s.jsx(Si,{sensors:k,collisionDetection:ji,onDragEnd:V,children:$}),t[45]=V,t[46]=k,t[47]=$,t[48]=z):z=t[48];let G;return t[49]!==K||t[50]!==z?(G=s.jsx("nav",{"aria-label":K,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:z}),t[49]=K,t[50]=z,t[51]=G):G=t[51],G};function i1(t){return t.workStatusPanelVisible}function a1(t){return t.contextRailOrder}function l1(t){return t.setContextRailOrder}function c1(t){return t.openContextSurface}function d1(t){return t.shortcutOverrides}function u1(t){return t.planModeEnabled}function f1(t){return t.length===1&&t>="0"&&t<="9"}function m1(t){return t.id}function h1(t){return t.id}const p1=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),g1=(t,e,n,r)=>!n||r!==n||t.length===0?[]:xo(t,e,o=>o.name,{limit:10,threshold:.4}),x1=new Set,b1=[],Ya=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const o=r==="/",i=/^[A-Za-z]:\/$/.test(r);return!o&&!i&&(r=r.replace(/\/+$/,"")),r},y1=()=>{const t=tt.c(178),{t:e}=mt(),n=xe(v1),r=xe(w1),o=xe(S1),i=xe(j1),c=xe(k1),a=xe(C1),d=xe(N1),u=xe(A1),h=xe(D1),f=xe(P1),g=xe(E1),b=Je(T1),S=Je(I1);let v;t[0]!==n?(v=Ze=>n?Ze.activeSessions:b1,t[0]=n,t[1]=v):v=t[1];const p=Rs(v);let m;t[2]!==n?(m=Ze=>n?Ze.ids:x1,t[2]=n,t[3]=m):m=t[3];const x=No(m);let w;t[4]!==n?(w=Ze=>n?Ze.rankById:ul,t[4]=n,t[5]=w):w=t[5];const j=zi(w),N=ls(R1),A=qt(M1),k=qt(O1),C=Io(),P=su(F1),{files:D,git:F}=tr(),B=mr(B1),{isMobile:E}=pr();let _;t[6]!==C?(_=C?Ya(C):null,t[6]=C,t[7]=_):_=t[7];const W=_,[V,K]=l.useState(""),I=dl(V,200).trim();let $;t[8]!==V?($=V.trim(),t[8]=V,t[9]=$):$=t[9];const z=$;let G,J;t[10]!==n?(G=()=>{n&&K("")},J=[n],t[10]=n,t[11]=G,t[12]=J):(G=t[11],J=t[12]),l.useEffect(G,J);let Z,re;t[13]!==p||t[14]!==B||t[15]!==F||t[16]!==n?(Z=()=>{if(!n||!F)return;const Ze=setTimeout(()=>{const $e=new Set;for(const St of p){const Lt=Us(St);!Lt||$e.has(Lt)||($e.add(Lt),B(Lt,F))}},0);return()=>clearTimeout(Ze)},re=[n,p,F,B],t[13]=p,t[14]=B,t[15]=F,t[16]=n,t[17]=Z,t[18]=re):(Z=t[17],re=t[18]),l.useEffect(Z,re);let ee;t[19]!==r?(ee=()=>r(!1),t[19]=r,t[20]=ee):ee=t[20];const he=ee;let be;t[21]!==he?(be=Ze=>()=>{he(),Ze()},t[21]=he,t[22]=be):be=t[22];const Y=be;let we;t[23]!==A?.id||t[24]!==A?.path||t[25]!==N||t[26]!==E||t[27]!==u||t[28]!==h||t[29]!==b||t[30]!==Y||t[31]!==o||t[32]!==a||t[33]!==i||t[34]!==e||t[35]!==d?(we=()=>{const Ze=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(R,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:Y(()=>{o("chat"),a(!1),b()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(R,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:Y(L1)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(R,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:Y(_1)},{id:"toggle-sidebar",title:e(E?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(R,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(E?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:Y(()=>{if(E){const{isSessionSwitcherOpen:$e}=xe.getState();a(!$e)}else d()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(R,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:Y(()=>{N&&h(N,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(R,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:Y(()=>{N&&u(N)})},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(R,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:Y(()=>i(!0))}];return Ri()&&Ze.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(R,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:Y(()=>{ur("desktop_open_draft_mini_chat_window",{directory:Ya(N||A?.path||""),projectId:A?.id??null}).catch($1)})}),Ze},t[23]=A?.id,t[24]=A?.path,t[25]=N,t[26]=E,t[27]=u,t[28]=h,t[29]=b,t[30]=Y,t[31]=o,t[32]=a,t[33]=i,t[34]=e,t[35]=d,t[36]=we):we=t[36],A?.id,A?.path;let me;t[37]!==we?(me=we(),t[37]=we,t[38]=me):me=t[38];const Q=me;let pe;t[39]===Symbol.for("react.memo_cache_sentinel")?(pe=$n(),t[39]=pe):pe=t[39];const ve=pe;let Te,ke;t[40]===Symbol.for("react.memo_cache_sentinel")?(Te=er(),ke=!ve&&rl(),t[40]=Te,t[41]=ke):(Te=t[40],ke=t[41]);let Ie;t[42]!==E?(Ie={isVSCode:Te,isWeb:ke,isDesktop:ve,isMobile:E},t[42]=E,t[43]=Ie):Ie=t[43];const Ne=Ie;let Ae;if(t[44]!==Y||t[45]!==i||t[46]!==c||t[47]!==Ne){let Ze;t[49]!==Ne?(Ze=St=>St.isAvailable?St.isAvailable(Ne):!0,t[49]=Ne,t[50]=Ze):Ze=t[50];let $e;t[51]!==Y||t[52]!==i||t[53]!==c?($e=St=>{const Lt=Dg(St.slug)??"settings-3",Ot=(St.keywords??[]).join(" ");return{id:`settings:${St.slug}`,title:St.title,icon:St.slug==="mcp"?s.jsx(fu,{className:"mr-2 h-4 w-4"}):s.jsx(R,{name:Lt,className:"mr-2 h-4 w-4"}),searchText:`${St.title} ${St.group} ${Ot}`,onSelect:Y(()=>{c(St.slug),i(!0)})}},t[51]=Y,t[52]=i,t[53]=c,t[54]=$e):$e=t[54],Ae=Ag.filter(z1).filter(Ze).map($e),t[44]=Y,t[45]=i,t[46]=c,t[47]=Ne,t[48]=Ae}else Ae=t[48];const Se=Ae;let Oe;t[55]!==p||t[56]!==x||t[57]!==j?(Oe=wu(p,x,j),t[55]=p,t[56]=x,t[57]=j,t[58]=Oe):Oe=t[58];const ne=Oe,ce=Su(),Re=Je(U1);let te;t[59]!==ce||t[60]!==Re?(te=(Ze,$e)=>{const St=Re.get(Ze);return St?.branch?St.branch.trim()||null:$e&&ce.get($e)?.trim()||null},t[59]=ce,t[60]=Re,t[61]=te):te=t[61];const ae=te;let de;t[62]===Symbol.for("react.memo_cache_sentinel")?(de=[],t[62]=de):de=t[62];const[H,ge]=l.useState(de),[ue,M]=l.useState(""),oe=p1(W,I);let De;t[63]!==W||t[64]!==oe||t[65]!==n||t[66]!==P||t[67]!==ge||t[68]!==M||t[69]!==I?(De=()=>{if(!n){ge([]),M("");return}if(!oe){ge([]),M("");return}if(!W){ge([]),M("");return}let Ze=!1;return P(W,I,10,{type:"file"}).then($e=>{Ze||(ge($e.map(W1)),M(oe))}).catch(()=>{Ze||(ge([]),M(oe))}),()=>{Ze=!0}},t[63]=W,t[64]=oe,t[65]=n,t[66]=P,t[67]=ge,t[68]=M,t[69]=I,t[70]=De):De=t[70];let fe;t[71]!==W||t[72]!==oe||t[73]!==n||t[74]!==P||t[75]!==I?(fe=[n,W,I,oe,P],t[71]=W,t[72]=oe,t[73]=n,t[74]=P,t[75]=I,t[76]=fe):fe=t[76],l.useEffect(De,fe);const X=z.length>0;let le;e:{if(!X){let $e;t[77]!==Q?($e=Q.map(V1),t[77]=Q,t[78]=$e):$e=t[78],le=$e;break e}let Ze;t[79]!==Q||t[80]!==z?(Ze=xo(Q,z,H1,{limit:7,noFuzzy:!0}),t[79]=Q,t[80]=z,t[81]=Ze):Ze=t[81],le=Ze}const se=le;let T;e:{if(!X){let $e;t[82]===Symbol.for("react.memo_cache_sentinel")?($e=[],t[82]=$e):$e=t[82],T=$e;break e}let Ze;t[83]!==z||t[84]!==Se?(Ze=xo(Se,z,K1,{limit:7,noFuzzy:!0}),t[83]=z,t[84]=Se,t[85]=Ze):Ze=t[85],T=Ze}const ie=T;let je;e:{if(!X){let $e;t[86]!==ne?($e=ne.slice(0,5).map(G1),t[86]=ne,t[87]=$e):$e=t[87],je=$e;break e}let Ze;t[88]!==z||t[89]!==ne?(Ze=xo(ne,z,q1,{limit:7,threshold:.2}),t[88]=z,t[89]=ne,t[90]=Ze):Ze=t[90],je=Ze}const Pe=je;let U;e:{if(!n){let $e;t[91]===Symbol.for("react.memo_cache_sentinel")?($e=[],t[91]=$e):$e=t[91],U=$e;break e}let Ze;t[92]!==H||t[93]!==ue||t[94]!==oe||t[95]!==I?(Ze=g1(H,I,oe,ue),t[92]=H,t[93]=ue,t[94]=oe,t[95]=I,t[96]=Ze):Ze=t[96],U=Ze}const Be=U,Fe=n&&oe.length>0&&ue!==oe;let Ye;e:{if(!X){let $e;t[97]===Symbol.for("react.memo_cache_sentinel")?($e=[],t[97]=$e):$e=t[97],Ye=$e;break e}let Ze;if(t[98]!==z||t[99]!==k){const $e=k.map(Y1);Ze=xo($e,z,Q1,{limit:7,threshold:.4}),t[98]=z,t[99]=k,t[100]=Ze}else Ze=t[100];Ye=Ze}const at=Ye;let st,ct,bt,rt,gt,it,Et,Ft,Dt,Bt,qe,zt,Nt,xt;if(t[101]!==ae||t[102]!==he||t[103]!==W||t[104]!==D||t[105]!==X||t[106]!==n||t[107]!==f||t[108]!==b||t[109]!==V||t[110]!==se||t[111]!==Be||t[112]!==at||t[113]!==Pe||t[114]!==ie||t[115]!==r||t[116]!==S||t[117]!==g||t[118]!==e){const Ze=se.map(X1),$e=ie.map(J1),St=Pe.map(Z1),Lt=X?Be.map(eS):[],Ot=X?at.map(tS):[];let ss;e:{if(!X){ss=["commands","sessions"];break e}const He=sS,Ve=[{key:"commands",score:He(se)},{key:"settings",score:He(ie)},{key:"sessions",score:He(Pe)},{key:"files",score:He(Be)},{key:"projects",score:He(at)}];Ve.sort(nS),ss=Ve.map(rS)}const _t=ss,Ct=He=>{he(),S(He.id,Us(He))},os=async He=>{if(!W)return;const Ve=await pf(D,He,{directory:W});if(!Ve.ok){Ee.error(gf(Ve.reason));return}f(W,He),he()},hs=(He,Ve)=>{he(),b({selectedProjectId:He,directoryOverride:Ve})},Rt=He=>Bi(Or(He,g));rt=Ws,zt=n,Nt=r;let $t;t[133]!==e?($t=e("commandPalette.title"),t[133]=e,t[134]=$t):$t=t[134];let Wt;t[135]!==$t?(Wt=s.jsx(wn,{children:$t}),t[135]=$t,t[136]=Wt):Wt=t[136];let is;t[137]!==e?(is=e("commandPalette.description"),t[137]=e,t[138]=is):is=t[138];let Me;t[139]!==is?(Me=s.jsx(Sn,{children:is}),t[139]=is,t[140]=Me):Me=t[140],t[141]!==Wt||t[142]!==Me?(xt=s.jsxs(Rn,{className:"sr-only",children:[Wt,Me]}),t[141]=Wt,t[142]=Me,t[143]=xt):xt=t[143],bt=Vs,Bt="overflow-hidden p-0",qe=!0,ct=_h,Et=!1,Ft="[&_[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 Ke;t[144]!==e?(Ke=e("commandPalette.input.placeholder"),t[144]=e,t[145]=Ke):Ke=t[145],t[146]!==V||t[147]!==Ke?(Dt=s.jsx($h,{value:V,onValueChange:K,placeholder:Ke}),t[146]=V,t[147]=Ke,t[148]=Dt):Dt=t[148],st=zh;let ze;t[149]!==e?(ze=e("commandPalette.empty.noResults"),t[149]=e,t[150]=ze):ze=t[150],t[151]!==ze?(gt=s.jsx(Uh,{children:ze}),t[151]=ze,t[152]=gt):gt=t[152],it=_t.map(He=>He==="commands"&&Ze.length>0?s.jsx(uo,{children:Ze.map(Ve=>s.jsxs(bo,{value:Ve.id,onSelect:Ve.onSelect,children:[Ve.icon,s.jsx("span",{children:Ve.title}),Ve.shortcutId?s.jsx(Bh,{children:Rt(Ve.shortcutId)}):null]},Ve.id))},"commands"):He==="settings"&&$e.length>0?s.jsx(uo,{children:$e.map(oS)},"settings"):He==="sessions"&&St.length>0?s.jsx(uo,{children:St.map(Ve=>{const jt=Ve.title||e("commandPalette.session.untitled"),Jt=Us(Ve),yt=ae(Ve.id,Jt);return s.jsxs(bo,{value:`session:${Ve.id}`,onSelect:()=>Ct(Ve),children:[s.jsx(R,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:jt}),yt?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(R,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:yt})]}):null]},Ve.id)})},"sessions"):He==="files"&&Lt.length>0?s.jsx(uo,{children:Lt.map(Ve=>{const jt=Lh(Ve.relativePath||Ve.name,{maxLength:80});return s.jsxs(bo,{value:`file:${Ve.path}`,onSelect:()=>{os(Ve.path)},children:[s.jsx(cl,{filePath:Ve.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":Ve.relativePath,children:jt})]},`file:${Ve.path}`)})},"files"):He==="projects"&&Ot.length>0?s.jsx(uo,{children:Ot.map(Ve=>{const jt=Ve.displayName;return s.jsxs(bo,{value:`project:${Ve.id}`,onSelect:()=>hs(Ve.id,Ve.path),children:[s.jsx(R,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:jt}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:Ve.path})]},`project:${Ve.id}`)})},"projects"):null),t[101]=ae,t[102]=he,t[103]=W,t[104]=D,t[105]=X,t[106]=n,t[107]=f,t[108]=b,t[109]=V,t[110]=se,t[111]=Be,t[112]=at,t[113]=Pe,t[114]=ie,t[115]=r,t[116]=S,t[117]=g,t[118]=e,t[119]=st,t[120]=ct,t[121]=bt,t[122]=rt,t[123]=gt,t[124]=it,t[125]=Et,t[126]=Ft,t[127]=Dt,t[128]=Bt,t[129]=qe,t[130]=zt,t[131]=Nt,t[132]=xt}else st=t[119],ct=t[120],bt=t[121],rt=t[122],gt=t[123],it=t[124],Et=t[125],Ft=t[126],Dt=t[127],Bt=t[128],qe=t[129],zt=t[130],Nt=t[131],xt=t[132];let Pt;t[153]!==Fe||t[154]!==e?(Pt=Fe?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[153]=Fe,t[154]=e,t[155]=Pt):Pt=t[155];let Mt;t[156]!==st||t[157]!==gt||t[158]!==it||t[159]!==Pt?(Mt=s.jsxs(st,{children:[gt,it,Pt]}),t[156]=st,t[157]=gt,t[158]=it,t[159]=Pt,t[160]=Mt):Mt=t[160];let Xt;t[161]!==ct||t[162]!==Et||t[163]!==Ft||t[164]!==Dt||t[165]!==Mt?(Xt=s.jsxs(ct,{shouldFilter:Et,className:Ft,children:[Dt,Mt]}),t[161]=ct,t[162]=Et,t[163]=Ft,t[164]=Dt,t[165]=Mt,t[166]=Xt):Xt=t[166];let Qe;t[167]!==bt||t[168]!==Bt||t[169]!==qe||t[170]!==Xt?(Qe=s.jsx(bt,{className:Bt,showCloseButton:qe,children:Xt}),t[167]=bt,t[168]=Bt,t[169]=qe,t[170]=Xt,t[171]=Qe):Qe=t[171];let ht;return t[172]!==rt||t[173]!==zt||t[174]!==Nt||t[175]!==xt||t[176]!==Qe?(ht=s.jsxs(rt,{open:zt,onOpenChange:Nt,children:[xt,Qe]}),t[172]=rt,t[173]=zt,t[174]=Nt,t[175]=xt,t[176]=Qe,t[177]=ht):ht=t[177],ht};function v1(t){return t.isCommandPaletteOpen}function w1(t){return t.setCommandPaletteOpen}function S1(t){return t.setActiveMainTab}function j1(t){return t.setSettingsDialogOpen}function k1(t){return t.setSettingsPage}function C1(t){return t.setSessionSwitcherOpen}function N1(t){return t.toggleSidebar}function A1(t){return t.openContextOverview}function D1(t){return t.openContextSurface}function P1(t){return t.openContextFile}function E1(t){return t.shortcutOverrides}function T1(t){return t.openNewSessionDraft}function I1(t){return t.setCurrentSession}function R1(t){return t.currentDirectory}function M1(t){return t.getActiveProject()}function O1(t){return t.projects}function F1(t){return t.searchFiles}function B1(t){return t.ensureStatus}function L1(){ju()}function _1(){_n.requestDirectoryDialog()}function $1(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function z1(t){return t.slug!=="home"}function U1(t){return t.worktreeMetadata}function W1(t){return{path:Ya(t.path),name:t.name,relativePath:t.relativePath}}function V1(t){return{item:t,score:0}}function H1(t){return t.searchText}function K1(t){return t.searchText}function G1(t){return{item:t,score:0}}function q1(t){return t.title||""}function Y1(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function Q1(t){return t.searchText}function X1(t){return t.item}function J1(t){return t.item}function Z1(t){return t.item}function eS(t){return t.item}function tS(t){return t.item}function sS(t){return t.length?t[0].score:1/0}function nS(t,e){return t.score-e.score}function rS(t){return t.key}function oS(t){return s.jsxs(bo,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const rd=(t,e,n)=>Vh(t)?Bi(Or(t,n)):e,iS=()=>{const t=tt.c(69),{t:e}=mt(),n=xe(aS),r=xe(lS),o=xe(cS);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=Wh(),t[0]=i):i=t[0];const c=i;let a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=er(),t[1]=a):a=t[1];const d=a;let u,h,f,g,b,S,v,p,m;if(t[2]!==n||t[3]!==r||t[4]!==o||t[5]!==e){const K=[{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:[`Shift + Alt + ${c} + 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:"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_right_sidebar",descriptionKey:"helpDialog.item.toggleRightSidebar",icon:"layout-right",keys:""},{id:"open_right_sidebar_git",descriptionKey:"helpDialog.item.openRightSidebarGitTab",icon:"git-branch",keys:""},{id:"open_right_sidebar_files",descriptionKey:"helpDialog.item.openRightSidebarFilesTab",icon:"layout-right",keys:""},{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{id:"toggle_context_plan",descriptionKey:"helpDialog.item.togglePlanContextPanel",icon:"time",keys:""},{keys:[`${c} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",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:"cycle_services_tab",descriptionKey:"helpDialog.item.cycleServicesTab",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];h=Ws,p=n,m=r,u=Vs,S="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let y;t[15]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(R,{name:"command",className:"h-5 w-5"}),t[15]=y):y=t[15];let I;t[16]!==e?(I=e("helpDialog.title"),t[16]=e,t[17]=I):I=t[17];let $;t[18]!==I?($=s.jsxs(wn,{className:"flex items-center gap-2",children:[y,I]}),t[18]=I,t[19]=$):$=t[19];let z;t[20]!==e?(z=e("helpDialog.description"),t[20]=e,t[21]=z):z=t[21];let G;t[22]!==z?(G=s.jsx(Sn,{children:z}),t[22]=z,t[23]=G):G=t[23],t[24]!==$||t[25]!==G?(v=s.jsxs(Rn,{children:[$,G]}),t[24]=$,t[25]=G,t[26]=v):v=t[26],b="flex-1 overflow-y-auto mt-3 pr-1",f="space-y-4",g=K.map(J=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(J.categoryKey)}),s.jsx("div",{className:"space-y-1",children:J.items.filter(Z=>!(d&&Z.id==="toggle_prompt_navigator")).map(Z=>{const re=Z.id?rd(Z.id,Array.isArray(Z.keys)?Z.keys[0]:Z.keys,o):Array.isArray(Z.keys)?Z.keys:Z.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:[Z.icon&&s.jsx(R,{name:Z.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(Z.descriptionKey)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(re)?re:[re]).map((ee,he)=>s.jsxs(l.Fragment,{children:[he>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:ee})]},`${ee}-${he}`))})]},Z.id||Z.descriptionKey)})})]},J.categoryKey)),t[2]=n,t[3]=r,t[4]=o,t[5]=e,t[6]=u,t[7]=h,t[8]=f,t[9]=g,t[10]=b,t[11]=S,t[12]=v,t[13]=p,t[14]=m}else u=t[6],h=t[7],f=t[8],g=t[9],b=t[10],S=t[11],v=t[12],p=t[13],m=t[14];let x;t[27]!==f||t[28]!==g?(x=s.jsx("div",{className:f,children:g}),t[27]=f,t[28]=g,t[29]=x):x=t[29];let w;t[30]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(R,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[30]=w):w=t[30];let j;t[31]!==e?(j=e("helpDialog.proTips.title"),t[31]=e,t[32]=j):j=t[32];let N;t[33]!==j?(N=s.jsx("p",{className:"font-medium mb-1",children:j}),t[33]=j,t[34]=N):N=t[34];let A;t[35]!==o||t[36]!==e?(A=e("helpDialog.proTips.commandPalette",{shortcut:rd("open_command_palette",`${c} P`,o)}),t[35]=o,t[36]=e,t[37]=A):A=t[37];let k;t[38]!==A?(k=s.jsxs("li",{children:["• ",A]}),t[38]=A,t[39]=k):k=t[39];let C;t[40]!==e?(C=e("helpDialog.proTips.recentSessions"),t[40]=e,t[41]=C):C=t[41];let P;t[42]!==C?(P=s.jsxs("li",{children:["• ",C]}),t[42]=C,t[43]=P):P=t[43];let D;t[44]!==e?(D=e("helpDialog.proTips.themeCycling"),t[44]=e,t[45]=D):D=t[45];let F;t[46]!==D?(F=s.jsxs("li",{children:["• ",D]}),t[46]=D,t[47]=F):F=t[47];let B;t[48]!==k||t[49]!==P||t[50]!==F?(B=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[k,P,F]}),t[48]=k,t[49]=P,t[50]=F,t[51]=B):B=t[51];let E;t[52]!==N||t[53]!==B?(E=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[w,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[N,B]})]})}),t[52]=N,t[53]=B,t[54]=E):E=t[54];let _;t[55]!==E||t[56]!==b||t[57]!==x?(_=s.jsxs("div",{className:b,children:[x,E]}),t[55]=E,t[56]=b,t[57]=x,t[58]=_):_=t[58];let W;t[59]!==u||t[60]!==_||t[61]!==S||t[62]!==v?(W=s.jsxs(u,{className:S,children:[v,_]}),t[59]=u,t[60]=_,t[61]=S,t[62]=v,t[63]=W):W=t[63];let V;return t[64]!==h||t[65]!==W||t[66]!==p||t[67]!==m?(V=s.jsx(h,{open:p,onOpenChange:m,children:W}),t[64]=h,t[65]=W,t[66]=p,t[67]=m,t[68]=V):V=t[68],V};function aS(t){return t.isHelpDialogOpen}function lS(t){return t.setHelpDialogOpen}function cS(t){return t.shortcutOverrides}const dS=()=>{const t=tt.c(32),{t:e}=mt(),n=xe(uS),r=xe(fS),o=xe(mS);let i;t[0]!==o||t[1]!==e?(i=async()=>{if(!o)return;if((await Xn(o)).ok){Ee.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Ee.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=o,t[1]=e,t[2]=i):i=t[2];const c=i;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(wn,{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(Sn,{children:u}),t[9]=u,t[10]=h):h=t[10];let f;t[11]!==d||t[12]!==h?(f=s.jsxs(Rn,{children:[d,h]}),t[11]=d,t[12]=h,t[13]=f):f=t[13];let g;t[14]!==e?(g=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=g):g=t[15];let b;t[16]!==c||t[17]!==g?(b=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:c,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-primary",children:g})}),t[16]=c,t[17]=g,t[18]=b):b=t[18];let S;t[19]!==o||t[20]!==e?(S=o||e("openCodeStatusDialog.empty.noData"),t[19]=o,t[20]=e,t[21]=S):S=t[21];let v;t[22]!==S?(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:S}),t[22]=S,t[23]=v):v=t[23];let p;t[24]!==f||t[25]!==b||t[26]!==v?(p=s.jsxs(Vs,{className:"max-w-2xl",children:[f,b,v]}),t[24]=f,t[25]=b,t[26]=v,t[27]=p):p=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==p?(m=s.jsx(Ws,{open:n,onOpenChange:r,children:p}),t[28]=n,t[29]=r,t[30]=p,t[31]=m):m=t[31],m};function uS(t){return t.isOpenCodeStatusDialogOpen}function fS(t){return t.setOpenCodeStatusDialogOpen}function mS(t){return t.openCodeStatusText}const hS=180,od=600,pS=1,gS=6,xS=t=>{const e=t?.directory;return typeof e=="string"&&e.trim()?e:null},bS=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:o})=>{const i=l.useRef(new Map),c=l.useRef([]),a=l.useRef(new Set),d=l.useRef(0),u=l.useMemo(()=>er(),[]),h=l.useCallback(S=>`${S.directory}
|
|
899
|
+
`)},rw=t=>{const e=tt.c(7),{t:n}=mt(),r=Je(iw),o=Je(aw),i=Ia(lw),c=Th(cw);let a;return e[0]!==c||e[1]!==i||e[2]!==r||e[3]!==t||e[4]!==o||e[5]!==n?(a=async d=>{const u=r??(o?"draft":null);if(!u){Ee.error(n("contextPanel.browser.annotate.noSession"));return}let h=!1;if(d.screenshot)try{await c(d.screenshot),h=!0}catch{h=!1}i({directory:t,sessionKey:u},{source:"preview-annotation",fileLabel:d.payload.pageUrl||"browser",startLine:1,endLine:1,code:nw({payload:d.payload,screenshotAttached:h,intro:n("contextPanel.browser.annotate.intro")}),language:"markdown",text:""}),Ee.success(n("contextPanel.browser.annotate.attached"))},e[0]=c,e[1]=i,e[2]=r,e[3]=t,e[4]=o,e[5]=n,e[6]=a):a=e[6],a},ow=()=>{const t=tt.c(16),{t:e}=mt();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 o;t[4]!==e?(o=e("contextPanel.browser.annotate.tool.draw"),t[4]=e,t[5]=o):o=t[5];let i;t[6]!==e?(i=e("contextPanel.browser.annotate.commentPlaceholder"),t[6]=e,t[7]=i):i=t[7];let c;t[8]!==e?(c=e("contextPanel.browser.annotate.submit"),t[8]=e,t[9]=c):c=t[9];let a;return t[10]!==n||t[11]!==r||t[12]!==o||t[13]!==i||t[14]!==c?(a={select:n,marquee:r,draw:o,commentPlaceholder:i,submit:c},t[10]=n,t[11]=r,t[12]=o,t[13]=i,t[14]=c,t[15]=a):a=t[15],a};function iw(t){return t.currentSessionId}function aw(t){return t.newSessionDraft?.open}function lw(t){return t.addDraft}function cw(t){return t.addAttachedFile}const dw=3e4,uw=3,fw=250,mw={attempts:0,windowStartedAt:null},hw=(t,e)=>{const n=t.windowStartedAt===null||e-t.windowStartedAt>=dw,r=n?0:t.attempts;return r>=uw?null:{delayMs:fw*2**r,state:{attempts:r+1,windowStartedAt:n?e:t.windowStartedAt}}},pw=-3,qo=t=>typeof t=="string"&&t.length>0&&t!=="about:blank",Gr=t=>{const e=t;return e.detail&&typeof e.detail=="object"?e.detail:t},gw=(t,{initialUrl:e,onUrlChange:n})=>{const[r,o]=l.useState(e?{kind:"loading",url:e}:Qy),[i,c]=l.useState(e),[a,d]=l.useState(""),[u,h]=l.useState(!1),[f,g]=l.useState(!1),b=l.useRef(n);b.current=n;const S=l.useRef(mw);return l.useEffect(()=>{if(!t)return;const v=()=>{try{const D=t.getURL();return qo(D)?D:""}catch{return""}},p=()=>{try{h(t.canGoBack()),g(t.canGoForward())}catch{}},m=D=>{qo(D)&&(c(D),b.current(D))},x=()=>{const D=v();o({kind:"loading",url:D})},w=()=>{const D=v();let F="";try{F=t.getTitle()||""}catch{F=""}d(F),m(D),p(),o(B=>B.kind==="failed"&&B.url===D?B:{kind:"ready",url:D,title:F})},j=D=>{const F=Gr(D);qo(F.url)&&(m(F.url),p())},N=D=>{const F=Gr(D),B=Array.isArray(F.favicons)?F.favicons.find(Boolean):"",E=v();B&&E&&yf.getState().resolve(E,B)},A=D=>{const F=Gr(D);typeof F.title=="string"&&d(F.title)},k=D=>{const F=Gr(D);if(F.isMainFrame===!1)return;const B=typeof F.errorCode=="number"?F.errorCode:0;B!==pw&&o({kind:"failed",url:qo(F.validatedURL)?F.validatedURL:v(),code:B,description:typeof F.errorDescription=="string"?F.errorDescription:""})};let C=null;const P=()=>{const D=v(),F=hw(S.current,Date.now());if(!F){o({kind:"failed",url:D,code:0,description:"",crashed:!0});return}S.current=F.state,o({kind:"loading",url:D}),C=setTimeout(()=>{C=null;try{t.reload()}catch{o({kind:"failed",url:D,code:0,description:"",crashed:!0})}},F.delayMs)};t.addEventListener("did-start-loading",x),t.addEventListener("did-stop-loading",w),t.addEventListener("did-navigate",j),t.addEventListener("did-navigate-in-page",j),t.addEventListener("page-title-updated",A),t.addEventListener("page-favicon-updated",N),t.addEventListener("did-fail-load",k),t.addEventListener("render-process-gone",P),t.addEventListener("crashed",P);try{!t.isLoading()&&v()&&w()}catch{}return()=>{C!==null&&clearTimeout(C),t.removeEventListener("render-process-gone",P),t.removeEventListener("crashed",P),t.removeEventListener("did-start-loading",x),t.removeEventListener("did-stop-loading",w),t.removeEventListener("did-navigate",j),t.removeEventListener("did-navigate-in-page",j),t.removeEventListener("page-title-updated",A),t.removeEventListener("page-favicon-updated",N),t.removeEventListener("did-fail-load",k)}},[t]),{status:r,url:i,title:a,canGoBack:u,canGoForward:f}},xw=()=>typeof window<"u"&&!!window.__OPENCHAMBER_ELECTRON__,bw=4e4,ed=.5,yw=-3,vw=4,ww="persist:openchamber-browser",td=20,Sw=600,jw=2e4,kw=({initialUrl:t,directory:e,tabID:n})=>{const{t:r}=mt(),{currentTheme:o}=_r(),i=l.useRef(null),[c,a]=l.useState(null),d=l.useCallback(te=>{i.current=te,a(te)},[]),u=xe(te=>te.setContextPanelTabTargetPath),h=l.useRef(Qr(t)),f=h.current!==pn?h.current:"",[g,b]=l.useState(f?null:pn),[S,v]=l.useState(f),[p,m]=l.useState(!1),[x,w]=l.useState(!1),[j,N]=l.useState(0),[A,k]=l.useState(!1),[C,P]=l.useState(Ai),D=l.useRef(C);D.current=C;const F=l.useRef([]),[B,E]=l.useState("system"),[_,W]=l.useState({width:0,height:0}),V=l.useRef(null),K=l.useRef(null),y=l.useRef(!1),I=l.useRef(Date.now()),$=l.useCallback(te=>{!te||te===pn||!e||!n||u(e,n,te)},[e,n,u]),z=gw(c,{initialUrl:f,onUrlChange:l.useCallback(te=>{const ae=po(te);v(ae),$(ae)},[$])}),[G,J]=l.useState(null),Z=rw(e),re=ow(),ee=z.status.kind==="loading",he=eo(Df(e)),be=eo(te=>te.recordVisit),Y=eo(te=>te.forget);l.useEffect(()=>{z.status.kind==="ready"&&be(e,{url:po(z.status.url),title:z.status.title})},[e,z.status,be]);const we=l.useMemo(()=>Af(he,S),[he,S]),me=l.useCallback(te=>{const ae=Qr(te);ae!==pn&&(v(ae),J(null),qc(ae).then(de=>{const H=i.current;if(!H){b(de);return}try{H.loadURL(de)}catch{b(de)}}).catch(de=>{de instanceof So&&J(ae)}))},[]);l.useEffect(()=>{if(!f)return;let te=!0;return qc(f).then(ae=>{te&&b(ae)}).catch(ae=>{if(te){if(ae instanceof So){J(f),b(pn);return}b(f)}}),()=>{te=!1}},[]);const Q=l.useMemo(()=>({executeJavaScript:async(te,ae)=>{const de=i.current;if(!de)throw new Error("Browser view is not available");return de.executeJavaScript(te,ae)},capturePage:async()=>{const te=i.current;if(!te)return null;const ae=te.getWebContentsId();return Number.isFinite(ae)?await yo("desktop_browser_capture_page",{webContentsId:ae}):null}}),[]),pe=l.useCallback(()=>{if(p){m(!1),li(Q);return}if(!z.url){Ee.error(r("contextPanel.browser.annotate.noPage"));return}const te=dv(o.metadata.variant==="light"?"light":"dark");m(!0),lv({host:Q,theme:te,labels:re}).then(async ae=>{m(!1),ae&&await Z(ae)}).catch(()=>{m(!1),Ee.error(r("contextPanel.browser.annotate.failed"))})},[Q,Z,o,p,z.url,re,r]);l.useEffect(()=>{if(!p)return;const te=ae=>{ae.key==="Escape"&&(ae.preventDefault(),ae.stopImmediatePropagation(),m(!1),li(Q))};return window.addEventListener("keydown",te,!0),()=>window.removeEventListener("keydown",te,!0)},[Q,p]);const ve=l.useCallback(async(te=8e3)=>{const ae=Date.now();for(;;){const de=i.current;if(!de)return!1;let H=!1;try{H=de.isLoading()}catch{return!1}if(!H)return!0;if(Date.now()-ae>te)return!1;await new Promise(ge=>setTimeout(ge,120))}},[]),Te=l.useCallback(async(te,ae)=>{const de=i.current;if(!de)throw new Error("The browser panel is not ready");const H=()=>{Zc(ae.viewport)&&(P(Ga(ae.viewport)),k(!0))};if(te==="browser.back"||te==="browser.forward"){const fe=te==="browser.back";if(!(fe?de.canGoBack():de.canGoForward()))throw new Error(fe?"There is nothing to go back to in this tab":"There is nothing to go forward to in this tab");fe?de.goBack():de.goForward(),await new Promise(se=>setTimeout(se,150)),await ve();let le="";try{le=de.getTitle()||""}catch{le=""}return{url:po(de.getURL()),title:le}}if(te==="browser.capture"){await ve();const fe=await Q.capturePage();if(!fe)throw new Error("The page could not be captured");let X="";try{X=de.getTitle()||""}catch{X=""}return{...fe,url:po(de.getURL()),title:X,viewport:Go(D.current)}}if(te==="browser.resize"){if(!Zc(ae.viewport))throw new Error("viewport is required");return H(),await new Promise(fe=>setTimeout(fe,200)),await ve(),{viewport:Go(Ga(ae.viewport))}}if(te==="browser.open"){const fe=typeof ae.url=="string"?ae.url:"";if(!fe)throw new Error("url is required");H(),me(fe),await new Promise(se=>setTimeout(se,150));const X=await ve(25e3);let le="";try{le=de.getTitle()||""}catch{le=""}return{url:Qr(fe),title:le,opened:!0,settled:X,viewport:Go(D.current)}}await ve();const ge=fe=>typeof fe=="string"&&fe?fe:void 0,M=(()=>{switch(te){case"browser.snapshot":return Bv({selector:ge(ae.selector)});case"browser.click":return Lv({selector:ge(ae.selector),text:ge(ae.text)});case"browser.type":return _v({selector:String(ae.selector??""),value:String(ae.value??""),submit:ae.submit===!0});case"browser.inspect":return Uv({selector:String(ae.selector??"")});case"browser.scroll":return $v({selector:ge(ae.selector),direction:ge(ae.direction)});default:return null}})();if(!M)throw new Error(`Unsupported browser action: ${te}`);const oe=await de.executeJavaScript(M,!0);if(!oe||typeof oe!="object")throw new Error("The page returned no result");const De=oe;if(De.ok!==!0)throw new Error(typeof De.error=="string"&&De.error?De.error:"Browser action failed");if(te==="browser.snapshot"){const fe=F.current;return{...De,viewport:Go(D.current),...fe.length>0?{consoleProblems:[...fe]}:{}}}return(te==="browser.click"||te==="browser.type"&&ae.submit===!0)&&(await new Promise(fe=>setTimeout(fe,150)),await ve()),oe},[Q,me,ve]);l.useEffect(()=>Sv({run:Te}),[Te]),l.useEffect(()=>{const te=Q;return()=>{li(te)}},[Q]),l.useEffect(()=>{if(!c)return;const te=de=>{const H=de;if(typeof H.level!="number"||H.level<2)return;const ge=H.sourceId?`${H.sourceId}${H.line?`:${H.line}`:""}`:"";F.current.push({level:H.level>=3?"error":"warning",message:String(H.message??"").slice(0,400),source:ge}),F.current.length>td&&F.current.splice(0,F.current.length-td)},ae=()=>{F.current=[]};return c.addEventListener("console-message",te),c.addEventListener("did-start-loading",ae),()=>{c.removeEventListener("console-message",te),c.removeEventListener("did-start-loading",ae)}},[c]);const ke=l.useRef(new Set),Ie=l.useCallback(te=>{ke.current.clear(),me(te)},[me]);l.useEffect(()=>{if(!c)return;const te=de=>{const H=Gr(de),ge=typeof H.url=="string"?H.url:"";!ge||!Yc(ge)||(de.preventDefault(),me(ge))},ae=de=>{const H=Gr(de);if(H.isMainFrame===!1||H.errorCode===-3)return;const ge=typeof H.validatedURL=="string"?H.validatedURL:"";!ge||!Yc(ge)||ke.current.has(ge)||(ke.current.add(ge),me(ge))};return c.addEventListener("will-navigate",te),c.addEventListener("did-fail-load",ae),()=>{c.removeEventListener("will-navigate",te),c.removeEventListener("did-fail-load",ae)}},[me,c]),l.useEffect(()=>{if(!c)return;const te=ae=>{const de=ae.detail;ae.preventDefault(),de?.url&&me(de.url)};return c.addEventListener("new-window",te),()=>c.removeEventListener("new-window",te)},[me,c]);const Ne=l.useCallback(te=>{const ae=Math.min(vw,Math.max(yw,te));N(ae);try{i.current?.setZoomLevel(ae)}catch{}},[]),Ae=l.useCallback(te=>{yo("desktop_browser_clear_data",{partition:ww,cookies:te==="cookies",cache:te==="cache"}).then(()=>{Ee.success(r(te==="cookies"?"contextPanel.browser.clearedCookies":"contextPanel.browser.clearedCache"));try{i.current?.reloadIgnoringCache()}catch{}}).catch(()=>Ee.error(r("contextPanel.browser.clearFailed")))},[r]);l.useEffect(()=>{const te=V.current;if(!te||typeof ResizeObserver>"u")return;const ae=new ResizeObserver(de=>{const H=de[0]?.contentRect;H&&W({width:H.width,height:H.height})});return ae.observe(te),()=>ae.disconnect()},[]);const Se=l.useCallback(te=>{E(te);const ae=i.current;if(!ae)return;let de=-1;try{de=ae.getWebContentsId()}catch{return}yo("desktop_browser_set_color_scheme",{webContentsId:de,scheme:te}).catch(H=>{E("system"),Ee.error(H instanceof Error?H.message:r("contextPanel.browser.device.schemeFailed"))})},[r]),Oe=l.useCallback(()=>{try{ee?i.current?.stop():i.current?.reload()}catch{}},[ee]),ne=z.status;l.useEffect(()=>{const te=()=>{w(!0);const H=setTimeout(()=>{try{i.current?.reload()}catch{}},Sw);return()=>clearTimeout(H)};if(ne.kind==="failed"){if(!Uy(ne.code,ne.url)){w(!1);return}const H=Date.now(),ge=K.current?.url===ne.url?K.current:{url:ne.url,startedAt:H};if(K.current=ge,H-ge.startedAt>bw){w(!1);return}return te()}if(ne.kind==="loading")return;if(K.current=null,ne.kind!=="ready"||!ne.url||!so(ne.url)){y.current=!0,w(!1);return}if(y.current||Date.now()-I.current>jw){y.current=!0,w(!1);return}let ae=!1,de=null;return Hy(po(ne.url)).then(H=>{if(!ae){if(H===null||H<500){y.current=!0,w(!1);return}de=te()}}),()=>{ae=!0,de?.()}},[ne]);const ce=z.status.kind==="failed"&&!x?z.status:null,Re=Kv(C,_);return s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[s.jsx(If,{address:S,onAddressChange:v,onSubmit:Ie,suggestions:we,onForgetSuggestion:te=>Y(e,te),onBack:()=>{try{i.current?.goBack()}catch{}},onForward:()=>{try{i.current?.goForward()}catch{}},onReload:Oe,onOpenExternal:()=>{Oi(z.url||S)},canGoBack:z.canGoBack,canGoForward:z.canGoForward,isLoading:ee,onAnnotate:pe,isAnnotating:p,onOpenDevTools:()=>{try{i.current?.openDevTools()}catch{}},onHardReload:()=>{try{i.current?.reloadIgnoringCache()}catch{}},onZoomIn:()=>Ne(j+ed),onZoomOut:()=>Ne(j-ed),onZoomReset:()=>Ne(0),zoomPercent:Math.round(Math.pow(1.2,j)*100),onClearCookies:()=>Ae("cookies"),onClearCache:()=>Ae("cache"),onToggleDeviceBar:()=>k(te=>!te),isDeviceBarOpen:A}),A?s.jsx(Yv,{viewport:C,onViewportChange:P,colorScheme:B,onColorSchemeChange:Se,scale:Re?.scale??1}):null,s.jsxs("div",{ref:V,className:ye("relative min-h-0 flex-1 bg-background",Re&&"flex items-center justify-center overflow-hidden bg-[var(--surface-muted)]"),children:[g!==null?s.jsx("webview",{ref:d,src:g,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,g!==null&&!f&&!z.url&&!ee?s.jsx(Of,{onOpen:Ie,directory:e}):null,x?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,G?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:G})})]}):null,ce&&!G?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:ce.crashed?r("contextPanel.browser.crashed"):r("contextPanel.browser.loadFailed")}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:ce.crashed?r("contextPanel.browser.crashedHint"):ce.description||r("contextPanel.browser.loadFailedUnknown")})]}):null,ee?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]})]})},Cw=t=>{const e=tt.c(49),{initialUrl:n,directory:r,tabID:o}=t,{t:i}=mt(),c=xe(Aw);let a;e[0]!==n?(a=Qr(n),e[0]=n,e[1]=a):a=e[1];const d=a,u=d!==pn?d:"",[h,f]=l.useState(u),[g,b]=l.useState(u);let S;e[2]!==u?(S=u?[u]:[],e[2]=u,e[3]=S):S=e[3];const[v,p]=l.useState(S),[m,x]=l.useState(u?0:-1),[w,j]=l.useReducer(Dw,0);let N;e[4]!==r||e[5]!==c||e[6]!==o?(N=ee=>{!ee||ee===pn||!r||!o||c(r,o,ee)},e[4]=r,e[5]=c,e[6]=o,e[7]=N):N=e[7];const A=N;let k;e[8]!==r?(k=Df(r),e[8]=r,e[9]=k):k=e[9];const C=eo(k),P=eo(Pw),D=eo(Ew);let F;e[10]!==h||e[11]!==C?(F=Af(C,h),e[10]=h,e[11]=C,e[12]=F):F=e[12];const B=F;let E;e[13]!==r||e[14]!==m||e[15]!==A||e[16]!==P?(E=ee=>{const he=Qr(ee);he!==pn&&(f(he),b(he),A(he),P(r,{url:he}),p(be=>{const Y=m>=0?be.slice(0,m+1):[];return Y[Y.length-1]===he?(x(Y.length-1),Y):(x(Y.length),[...Y,he])}))},e[13]=r,e[14]=m,e[15]=A,e[16]=P,e[17]=E):E=e[17];const _=E;let W;e[18]!==v||e[19]!==A?(W=ee=>{const he=v[ee];he&&(x(ee),f(he),b(he),A(he))},e[18]=v,e[19]=A,e[20]=W):W=e[20];const V=W;let K;e[21]!==r||e[22]!==D?(K=ee=>D(r,ee),e[21]=r,e[22]=D,e[23]=K):K=e[23];let y,I;e[24]!==V||e[25]!==m?(I=()=>V(m-1),y=()=>V(m+1),e[24]=V,e[25]=m,e[26]=y,e[27]=I):(y=e[26],I=e[27]);let $;e[28]!==h||e[29]!==g?($=()=>{Oi(g||h)},e[28]=h,e[29]=g,e[30]=$):$=e[30];const z=m>0,G=m>=0&&m<v.length-1;let J;e[31]!==h||e[32]!==_||e[33]!==B||e[34]!==y||e[35]!==$||e[36]!==z||e[37]!==G||e[38]!==K||e[39]!==I?(J=s.jsx(If,{address:h,onAddressChange:f,onSubmit:_,suggestions:B,onForgetSuggestion:K,onBack:I,onForward:y,onReload:j,onOpenExternal:$,canGoBack:z,canGoForward:G,isLoading:!1}),e[31]=h,e[32]=_,e[33]=B,e[34]=y,e[35]=$,e[36]=z,e[37]=G,e[38]=K,e[39]=I,e[40]=J):J=e[40];let Z;e[41]!==g||e[42]!==_||e[43]!==w||e[44]!==i?(Z=s.jsx("div",{className:"relative min-h-0 flex-1 bg-background",children:g?s.jsx("iframe",{src:g,title:i("contextPanel.browser.frameTitle"),className:"h-full w-full border-none bg-white",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups"},`${g}|${w}`):s.jsx(Of,{onOpen:_})}),e[41]=g,e[42]=_,e[43]=w,e[44]=i,e[45]=Z):Z=e[45];let re;return e[46]!==J||e[47]!==Z?(re=s.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",children:[J,Z]}),e[46]=J,e[47]=Z,e[48]=re):re=e[48],re},Nw=t=>{const e=tt.c(3),[n]=l.useState(xw);let r;return e[0]!==n||e[1]!==t?(r=n?s.jsx(kw,{...t}):s.jsx(Cw,{...t}),e[0]=n,e[1]=t,e[2]=r):r=e[2],r};function Aw(t){return t.setContextPanelTabTargetPath}function Dw(t){return t+1}function Pw(t){return t.recordVisit}function Ew(t){return t.forget}const Tw=Zs(()=>Js(()=>import("./WalkthroughView-5DyvN03T.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])).then(t=>({default:t.WalkthroughView}))),Iw=Zs(()=>Js(()=>import("./DiffView-DZIoOnV7.js"),__vite__mapDeps([121,1,2,4,5,6,7,8,3,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])).then(t=>({default:t.DiffView}))),Rw=Zs(()=>Js(()=>import("./FilesView-BKL6YlKG.js"),__vite__mapDeps([122,1,2,4,5,6,7,8,3,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,113,123,124,125,126,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,127,128,114,115,129,130,112,131,118])).then(t=>({default:t.FilesView}))),Mw=Zs(()=>Js(()=>import("./GitView-DBFrDDBv.js"),__vite__mapDeps([132,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,113,133,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,114,115,117,118,119,120])).then(t=>({default:t.GitView}))),Ow=Zs(()=>Js(()=>import("./PlanView-ZYEJn8A_.js"),__vite__mapDeps([134,1,2,4,5,6,7,8,123,50,51,52,53,54,55,72,48,49,56,124,125,3,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,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,73,74,75,76,77,78,79,80,112,113,131,114,115,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(t=>({default:t.PlanView}))),Fw=380,Bw=1400,Ff=600,Lw=100,_w=24,Pi=new Map,$w=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},sd=t=>Number.isFinite(t)?Math.min(Bw,Math.max(Fw,Math.round(t))):Ff,zw=t=>{const e=t?.parentElement?.clientWidth;return!e||e<=0?null:e},Uw=(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},Bf=(t,e)=>e(t==="chat"?"contextPanel.mode.chat":t==="file"?"contextPanel.mode.files":t==="diff"?"contextPanel.mode.diff":t==="walkthrough"?"contextPanel.mode.walkthrough":t==="plan"?"contextPanel.mode.plan":t==="browser"?"contextPanel.mode.browser":t==="git"?"layout.rightSidebar.git":t==="pr"?"contextPanel.mode.pr":t==="notes"?"contextRail.surface.notes":t==="terminal"?"layout.mainTab.terminal":"contextPanel.mode.context"),Ww=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},Vw=(t,e,n)=>{if(t.mode==="chat"){const r=qa(t.dedupeKey);if(r){const i=e.get(r)?.trim();if(i)return i}const o=t.sessionTitleFallback?.trim();return o||n("contextPanel.mode.chat")}return t.mode==="browser"?Cl(t.targetPath??"")||t.label||n("contextPanel.mode.browser"):t.label?t.label:t.mode==="file"?Ww(t.targetPath)||n("contextPanel.mode.files"):t.mode==="diff"?n("contextPanel.mode.diff"):Bf(t.mode,n)},nd=(t,e={})=>{if(t.mode==="file")return t.targetPath?s.jsx(cl,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return s.jsx(Ju,{className:"h-3.5 w-3.5"});if(t.mode==="walkthrough")return s.jsx(R,{name:"route",className:"h-3.5 w-3.5"});if(t.mode==="git")return s.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5"});if(t.mode==="pr")return s.jsx(R,{name:"github",className:"h-3.5 w-3.5"});if(t.mode==="notes")return s.jsx(R,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return s.jsx(R,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="plan")return s.jsx(R,{name:"file-text",className:"h-3.5 w-3.5"});if(t.mode==="context")return s.jsx(R,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="chat")return s.jsx(R,{name:"chat-4",className:"h-3.5 w-3.5"});if(t.mode==="browser"){const n=Hw(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(R,{name:"global",className:"h-3.5 w-3.5"})}},Hw=(t,e)=>{try{return e[new URL(t).origin]??""}catch{return""}},Kw=200,Gw=480,qw=({visible:t})=>{const{t:e}=mt(),n=xe(m=>m.contextEditorTreeWidth),r=xe(m=>m.setContextEditorTreeWidth),[o,i]=l.useState(!1),c=l.useRef(0),a=l.useRef(n),d=l.useRef(null),u=l.useRef(null),h=l.useRef(null),f=l.useCallback(m=>Math.min(Gw,Math.max(Kw,Math.round(m))),[]),g=l.useCallback(m=>{const x=h.current;x&&(x.style.width=`${m}px`,x.style.setProperty("--oc-editor-tree-width",`${m}px`))},[]),b=m=>{if(t){try{m.currentTarget.setPointerCapture(m.pointerId)}catch{}u.current=m.pointerId,i(!0),c.current=m.clientX,a.current=n,d.current=n,m.preventDefault()}},S=m=>{if(!o||u.current!==m.pointerId)return;const x=c.current-m.clientX,w=f(a.current+x);d.current!==w&&(d.current=w,g(w))},v=m=>{if(u.current!==m.pointerId)return;try{m.currentTarget.releasePointerCapture(m.pointerId)}catch{}const x=f(d.current??n);u.current=null,d.current=null,i(!1),r(x)},p=t?n:0;return s.jsxs("div",{ref:h,className:ye("relative h-full flex-shrink-0 overflow-hidden border-l border-border bg-background will-change-[width] motion-reduce:transition-none",!t&&"border-l-0"),style:{width:`${o?d.current??p:p}px`,"--oc-editor-tree-width":`${o?d.current??n:n}px`,overflowX:"clip",transitionProperty:o?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&s.jsx("div",{className:ye("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",o&&"bg-[var(--interactive-border)]"),onPointerDown:b,onPointerMove:S,onPointerUp:v,onPointerCancel:v,role:"separator","aria-orientation":"vertical","aria-label":e("contextPanel.actions.resizePanelAria")}),s.jsx("div",{className:ye("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",o&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:s.jsx(dy,{})})]})},qa=t=>!t||!t.startsWith("session:")?null:t.slice(8).trim()||null,Yw=(t,e)=>{if(t.size!==e.size)return!1;for(const[n,r]of t)if(e.get(n)!==r)return!1;return!0},Qw=(t,e)=>{if(e.length===0)return Pi;const n=new Set(e),r=new Map;for(const o of t){if(!n.has(o.id))continue;const i=o.title?.trim();i&&r.set(o.id,i)}return r.size===0?Pi:r},Xw=(t,e)=>{const n=ol(t),r=l.useRef(Pi),o=l.useRef(e);return o.current=e,l.useSyncExternalStore(n.subscribe,l.useCallback(()=>{const i=Qw(n.getState().session,o.current);return Yw(r.current,i)?r.current:(r.current=i,i)},[n]),()=>Pi)},Jw=(t,e)=>t.length<=e?t:`${t.slice(0,e-3)}...`,Zw=()=>{const{t}=mt(),e=Io()??"",n=l.useMemo(()=>$w(e),[e]),r=xe(U=>n?U.contextPanelByDirectory[n]:void 0),o=xe(U=>U.closeContextPanel),i=xe(U=>U.closeContextPanelTab),c=xe(U=>U.openContextPanelTab),a=xe(U=>U.toggleContextPanelExpanded),d=xe(U=>U.setContextPanelWidth),u=xe(U=>U.setActiveContextPanelTab),h=xe(U=>U.openContextBrowser);l.useEffect(()=>{if(e)return jv(U=>h(e,U))},[e,h]);const f=xe(U=>U.reorderContextPanelTabs),g=Bn(U=>U.setSelectedPath),b=xe(U=>U.contextEditorTreeVisible),S=xe(U=>U.toggleContextEditorTree),v=xe(U=>U.openNewContextBrowserTab),p=yf(U=>U.byOrigin),m=xe(U=>U.allowPromptingSubagentSessions),{themeMode:x,setThemeMode:w,lightThemeId:j,darkThemeId:N,currentTheme:A}=_r(),k=l.useMemo(()=>r?.tabs??[],[r?.tabs]),C=k.find(U=>U.id===r?.activeTabId)??k[k.length-1]??null,P=!!(r?.isOpen&&C),D=!!(P&&r?.expanded),[F,B]=l.useState(null),E=C?.mode??null,_=E?r?.widthByMode?.[E]:void 0,W=E?Ih(E):.5,V=F??(typeof window<"u"?window.innerWidth:Ff*2),K=sd(_??Math.round(W*V)),y=l.useMemo(()=>{const U=[];for(const Be of k){if(Be.mode!=="chat")continue;const Fe=qa(Be.dedupeKey);Fe&&!U.includes(Fe)&&U.push(Fe)}return U},[k]),I=Xw(n||void 0,y),[$,z]=l.useState(!1),G=l.useRef(0),J=l.useRef(K),Z=l.useRef(null),re=l.useRef(null),ee=l.useRef(null),he=l.useRef(new Map),be=l.useRef(new Map),Y=l.useRef(!1);l.useLayoutEffect(()=>{const U=ee.current?.parentElement;if(!U||typeof ResizeObserver>"u")return;const Be=new ResizeObserver(()=>{B(U.clientWidth||null)});return Be.observe(U),B(U.clientWidth||null),()=>Be.disconnect()},[]),l.useEffect(()=>{if(!P||Y.current){Y.current=P;return}const U=window.requestAnimationFrame(()=>{ee.current?.focus({preventScroll:!0})});return Y.current=!0,()=>window.cancelAnimationFrame(U)},[P]);const we=l.useRef(null),me=l.useRef(null),Q=l.useCallback(()=>{me.current=null;const U=ee.current,Be=Z.current;!U||Be===null||U.style.setProperty("--oc-context-panel-width",`${Be}px`)},[]);l.useEffect(()=>()=>{me.current!==null&&clearTimeout(me.current)},[]);const pe=l.useCallback(U=>{const Be=sd(U),Fe=we.current;return Fe===null?Be:Math.min(Be,Math.max(1,Fe))},[]),ve=l.useCallback(U=>{!P||D||!n||(re.current=U.pointerId,z(!0),G.current=U.clientX,J.current=K,Z.current=K,we.current=zw(ee.current),document.documentElement.style.cursor="col-resize",U.preventDefault())},[n,D,P,K]),Te=l.useCallback(()=>{const U=pe(Z.current??K);Z.current=null,we.current=null,me.current!==null&&(clearTimeout(me.current),me.current=null),document.documentElement.style.cursor="",n&&E&&d(n,E,U),z(!1),re.current=null},[E,pe,n,d,K]);l.useEffect(()=>{if(!$)return;const U=Ye=>{if(re.current!==Ye.pointerId)return;const at=G.current-Ye.clientX,st=pe(J.current+at);Z.current!==st&&(Z.current=st,me.current===null&&(me.current=setTimeout(Q,Lw)))},Be=Ye=>{re.current===Ye.pointerId&&Te()},Fe=()=>{Te()};return window.addEventListener("pointermove",U),window.addEventListener("pointerup",Be),window.addEventListener("pointercancel",Be),window.addEventListener("blur",Fe),()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",Be),window.removeEventListener("pointercancel",Be),window.removeEventListener("blur",Fe)}},[Q,pe,Te,$]),l.useEffect(()=>{$||(Z.current=null,document.documentElement.style.cursor="")},[$]);const ke=l.useCallback(()=>{n&&o(n)},[o,n]),Ie=l.useCallback(()=>{n&&a(n)},[n,a]),Ne=l.useCallback(U=>{U.key==="Escape"&&(Rh(U.target)||(U.preventDefault(),U.stopPropagation(),ke()))},[ke]);l.useEffect(()=>{if(!(!n||!C)&&C.mode==="file"&&C.targetPath){g(n,C.targetPath,{allowOutsideRoot:!0});return}},[C,n,g]);const Ae=l.useMemo(()=>k.filter(U=>U.mode==="chat"),[k]),Se=P&&C?.mode==="chat"?C.id:null,Oe=P&&C?.mode==="chat"?qa(C.dedupeKey):null,ne=qg(Ae,Se);l.useEffect(()=>{if(!P||!n||!Oe||typeof window>"u")return;const U=()=>{if(document.visibilityState==="hidden"||!document.hasFocus()){ia(n,Oe,!1);return}vu(Oe),ia(n,Oe,!0)};U();const Be=window.setInterval(U,1e4);return window.addEventListener("focus",U),window.addEventListener("blur",U),document.addEventListener("visibilitychange",U),()=>{window.clearInterval(Be),window.removeEventListener("focus",U),window.removeEventListener("blur",U),document.removeEventListener("visibilitychange",U),ia(n,Oe,!1)}},[Oe,n,P]);const ce=l.useCallback((U,Be,Fe)=>Yg(be.current,U,Be,n||null,Fe,{mode:x,lightThemeId:j,darkThemeId:N,currentTheme:A},{allowPromptingSubagentSessions:m}),[m,A,N,n,j,x]),Re=ne&&Oe?ce(ne.id,Oe,ne.readOnly):null;l.useEffect(()=>{const U=new Set(k.map(Be=>Be.id));for(const Be of be.current.keys())U.has(Be)||be.current.delete(Be)},[k]);const te=l.useCallback(U=>{!n||C?.mode!=="diff"||c(n,{mode:"diff",targetPath:C.targetPath,stagedDiff:U==="staged",diffScope:U})},[C,n,c]),ae=l.useCallback(()=>{if(typeof window>"u")return;const U={themeMode:x,lightThemeId:j,darkThemeId:N,currentTheme:A};for(const Be of he.current.values()){const Fe=Be.contentWindow;Fe&&Fe.postMessage({type:"openchamber:theme-sync",payload:U},window.location.origin)}},[A,N,j,x]),de=l.useCallback(()=>{if(typeof window>"u")return;const U={allowPromptingSubagentSessions:m};for(const Be of he.current.values()){const Fe=Be.contentWindow;Fe&&Fe.postMessage({type:"openchamber:chat-settings-sync",payload:U},window.location.origin)}},[m]),H=l.useCallback(()=>{if(!(typeof window>"u"))for(const[U,Be]of he.current.entries()){const Fe=Be.contentWindow;if(!Fe)continue;const Ye={visible:Se===U};Fe.postMessage({type:"openchamber:embedded-visibility",payload:Ye},window.location.origin)}},[Se]);l.useEffect(()=>{if(typeof window>"u")return;const U=Be=>{if(Be.origin!==window.location.origin||!Array.from(he.current.values()).some(bt=>bt.contentWindow===Be.source))return;const Ye=Be.data;if(Ye?.type===Qg){if(typeof Ye.requestId!="string"||!Ye.requestId)return;const bt=xn(),rt={apiBaseUrl:fr(),clientToken:ko(),localOrigin:typeof window.__OPENCHAMBER_LOCAL_ORIGIN__=="string"?window.__OPENCHAMBER_LOCAL_ORIGIN__:"",runtimeHeaders:ru(),relayHostId:bt.startsWith("host:")?bt.slice(5):"",relay:Lm()??void 0};Be.source?.postMessage({type:Xg,requestId:Ye.requestId,payload:rt},Be.origin);return}if(Ye?.type==="openchamber:theme-sync-request"){ae();return}if(Ye?.type==="openchamber:chat-settings-request"){de();return}if(Ye?.type!=="openchamber:cycle-theme-request")return;const at=["light","dark","system"],ct=(at.indexOf(x)+1)%at.length;w(at[ct])};return window.addEventListener("message",U),()=>window.removeEventListener("message",U)},[de,ae,w,x]),l.useLayoutEffect(()=>{k.some(Be=>Be.mode==="chat")&&(ae(),de(),H())},[N,j,de,H,ae,k,x]);const ge=C?.mode==="file"||C?.mode==="chat"||C?.mode==="browser",ue=l.useMemo(()=>C?k.filter(U=>U.mode===C.mode):[],[C,k]),M=l.useMemo(()=>ue.map(U=>{const Be=Vw(U,I,t),Fe=Jw(Be,_w),Ye=Uw(U.targetPath,e);return{id:U.id,label:Fe,icon:nd(U,p),title:Ye?`${Be}: ${Ye}`:Be,closeLabel:t("contextPanel.tab.closeTabAria",{label:Fe})}}),[ue,e,p,I,t]),oe=C?.mode==="context"?s.jsx(Dy,{}):C?.mode==="git"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Mw,{isActive:P})}):C?.mode==="pr"?s.jsx(_b,{}):C?.mode==="notes"?s.jsx(Wu,{}):C?.mode==="plan"?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Ow,{targetPath:C.targetPath})}):null,De=l.useMemo(()=>k.filter(U=>U.mode==="browser"),[k]),fe=l.useMemo(()=>k.filter(U=>U.mode==="diff"),[k]),X=l.useMemo(()=>k.some(U=>U.mode==="terminal"),[k]),le=l.useMemo(()=>k.some(U=>U.mode==="walkthrough"),[k]),se=l.useMemo(()=>k.some(U=>U.mode==="file"),[k]),T=l.useMemo(()=>k.some(U=>U.mode==="file"&&U.targetPath),[k]),ie=C?.mode==="file",je=s.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[ge?s.jsx(gl,{items:M,activeId:C?.id??null,onSelect:U=>{n&&u(n,U)},onClose:U=>{n&&i(n,U)},onReorder:(U,Be)=>{n&&f(n,U,Be)},layoutMode:"scrollable",variant:"default"}):s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[C?nd(C,p):null,s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:C?Bf(C.mode,t):null})]}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[C?.mode==="browser"?s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:()=>{n&&v(n)},className:"h-7 w-7 p-0",title:t("contextPanel.browser.newTab"),"aria-label":t("contextPanel.browser.newTab"),children:s.jsx(R,{name:"add",className:"h-3.5 w-3.5"})}):null,ie?s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:S,className:"h-7 w-7 p-0",title:t("contextRail.editorTree.toggle"),"aria-label":t("contextRail.editorTree.toggle"),"aria-pressed":b,children:s.jsx(R,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:Ie,className:"h-7 w-7 p-0",title:t(D?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),"aria-label":t(D?"contextPanel.actions.collapsePanel":"contextPanel.actions.expandPanel"),children:D?s.jsx(R,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"fullscreen",className:"h-3.5 w-3.5"})}),s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:ke,className:"h-7 w-7 p-0",title:t("contextPanel.actions.closePanel"),"aria-label":t("contextPanel.actions.closePanel"),children:s.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]})]}),Pe=P?D?{"--oc-context-panel-width":F!==null?`${F}px`:"100%",width:F!==null?`${F}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${K}px`}:{"--oc-context-panel-width":`${K}px`,width:0,maxWidth:"100%",overflowX:"clip"};return s.jsxs("aside",{ref:ee,"data-context-panel":"true",tabIndex:-1,inert:!P||void 0,className:ye("flex min-h-0 flex-col overflow-hidden bg-background",D?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!P&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:Ne,style:Pe,children:[P&&!D&&s.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),P&&s.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!D&&s.jsx("div",{className:ye("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",$&&"bg-[var(--interactive-border)]"),onPointerDown:ve,role:"separator","aria-orientation":"vertical","aria-label":t("contextPanel.actions.resizePanelAria")}),s.jsxs("div",{className:ye("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]",!P&&"pointer-events-none select-none opacity-0"),style:{width:D?F!==null?`${F}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!P,children:[je,s.jsxs("div",{className:ye("relative min-h-0 flex-1 overflow-hidden",$&&"pointer-events-none"),children:[se?s.jsxs("div",{className:ye("absolute inset-0 flex",ie?"flex":"hidden"),children:[s.jsx("div",{className:"h-full min-w-0 flex-1",children:T?s.jsx(l.Suspense,{fallback:null,children:s.jsx(Rw,{mode:"editor-only"})}):s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx(R,{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")})]})}),s.jsx(qw,{visible:b})]}):null,ne&&Oe&&Re?s.jsx("iframe",{ref:U=>{if(!U){he.current.delete(ne.id);return}he.current.set(ne.id,U)},src:Re,title:t("contextPanel.iframe.sessionChatTitle",{sessionID:Oe}),className:"absolute inset-0 h-full w-full border-0 bg-background",onLoad:()=>{ae(),de(),H()}},ne.id):null,De.map(U=>s.jsx("div",{className:ye("absolute inset-0",C?.id!==U.id&&"hidden"),children:s.jsx(Nw,{initialUrl:U.targetPath??"",directory:n,tabID:U.id})},U.id)),fe.map(U=>s.jsx("div",{className:ye("absolute inset-0",C?.id!==U.id&&"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(Iw,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:U.diffScope??(U.stagedDiff?"staged":"working"),onDiffScopeChange:te,targetFilePath:U.targetPath,flushContent:!0})})},U.id)),X?s.jsx("div",{className:ye("absolute inset-0",C?.mode==="terminal"?"block":"hidden"),children:s.jsx(Vu,{visible:P&&C?.mode==="terminal"})}):null,le?s.jsx("div",{className:ye("absolute inset-0",C?.mode==="walkthrough"?"block":"hidden"),children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(Tw,{directory:e})})}):null,C?.mode!=="chat"&&!ie&&C?.mode!=="browser"&&C?.mode!=="diff"&&C?.mode!=="terminal"&&C?.mode!=="walkthrough"?oe:null]})]})]})},e1=150,t1=500,s1=[],n1=t=>t>99?"99+":String(t),r1=t=>{const e=tt.c(51),{surface:n,isActive:r,showActivityDot:o,label:i,description:c,badgeCount:a,badgeAriaLabel:d,badgeDescription:u,orderNumber:h,showOrderNumber:f,onSelect:g}=t;let b;e[0]!==n.id?(b={id:n.id},e[0]=n.id,e[1]=b):b=e[1];const{attributes:S,listeners:v,setNodeRef:p,transform:m,transition:x,isDragging:w}=bl(b);let j;e[2]!==a?(j=a!=null&&a>0?n1(a):null,e[2]=a,e[3]=j):j=e[3];const N=j;let A;e[4]!==m?(A=yl.Translate.toString(m),e[4]=m,e[5]=A):A=e[5];let k;e[6]!==A||e[7]!==x?(k={transform:A,transition:x},e[6]=A,e[7]=x,e[8]=k):k=e[8];const C=w&&"z-10 opacity-70";let P;e[9]!==C?(P=ye("relative",C),e[9]=C,e[10]=P):P=e[10];let D;e[11]!==g||e[12]!==n?(D=()=>g(n),e[11]=g,e[12]=n,e[13]=D):D=e[13];const F=d??i,B=r?"text-primary":"text-muted-foreground hover:text-foreground";let E;e[14]!==B?(E=ye("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",B),e[14]=B,e[15]=E):E=e[15];let _;e[16]!==n.icon||e[17]!==n.id?(_=n.id==="diff"?s.jsx(Ju,{}):s.jsx(R,{name:n.icon,className:"h-[18px] w-[18px]"}),e[16]=n.icon,e[17]=n.id,e[18]=_):_=e[18];let W;e[19]!==N||e[20]!==h||e[21]!==o||e[22]!==f?(W=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}):N?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:N}):o?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[19]=N,e[20]=h,e[21]=o,e[22]=f,e[23]=W):W=e[23];let V;e[24]!==S||e[25]!==r||e[26]!==v||e[27]!==E||e[28]!==_||e[29]!==W||e[30]!==D||e[31]!==F?(V=s.jsx(ut,{asChild:!0,children:s.jsxs("button",{type:"button",...S,...v,onClick:D,"aria-label":F,"aria-pressed":r,className:E,children:[_,W]})}),e[24]=S,e[25]=r,e[26]=v,e[27]=E,e[28]=_,e[29]=W,e[30]=D,e[31]=F,e[32]=V):V=e[32];let K;e[33]!==i?(K=s.jsx("span",{children:i}),e[33]=i,e[34]=K):K=e[34];let y;e[35]!==c?(y=s.jsx("span",{className:"typography-micro text-muted-foreground",children:c}),e[35]=c,e[36]=y):y=e[36];let I;e[37]!==u?(I=u?s.jsx("span",{className:"typography-micro text-muted-foreground",children:u}):null,e[37]=u,e[38]=I):I=e[38];let $;e[39]!==K||e[40]!==y||e[41]!==I?($=s.jsx(ft,{side:"left",sideOffset:8,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[K,y,I]})}),e[39]=K,e[40]=y,e[41]=I,e[42]=$):$=e[42];let z;e[43]!==V||e[44]!==$?(z=s.jsxs(dt,{delayDuration:e1,children:[V,$]}),e[43]=V,e[44]=$,e[45]=z):z=e[45];let G;return e[46]!==p||e[47]!==z||e[48]!==k||e[49]!==P?(G=s.jsx("div",{ref:p,style:k,className:P,children:z}),e[46]=p,e[47]=z,e[48]=k,e[49]=P,e[50]=G):G=e[50],G},o1=()=>{const t=tt.c(52),{t:e}=mt(),n=Io();let r;t[0]!==n?(r=n?Vr(n):"",t[0]=n,t[1]=r):r=t[1];const o=r;let i;t[2]!==o?(i=J=>o?J.contextPanelByDirectory[o]:void 0,t[2]=o,t[3]=i):i=t[3];const c=xe(i),a=xe(i1),d=xe(a1),u=xe(l1),h=xe(c1),f=xe(d1),g=il(u1),{screenWidth:b}=pr(),S=al(o||null);let v;t[4]!==f?(v=Mh("switch_context_surface",f),t[4]=f,t[5]=v):v=t[5];const p=v,[m,x]=l.useState(!1);let w,j;t[6]!==p?(w=()=>{const J=new Set;let Z=null,re=!1;const ee=f1,he=()=>{ec(p,J)?!re&&Z===null&&(Z=setTimeout(()=>x(!0),t1)):(re=!1,Z!==null&&(clearTimeout(Z),Z=null),x(!1))},be=me=>{if(J.add(me.key.toLowerCase()),ee(me.key)&&ec(p,J)){re=!0,Z!==null&&(clearTimeout(Z),Z=null),x(!1);return}he()},Y=me=>{J.delete(me.key.toLowerCase()),he()},we=()=>{J.clear(),re=!1,Z!==null&&(clearTimeout(Z),Z=null),x(!1)};return window.addEventListener("keydown",be,!0),window.addEventListener("keyup",Y,!0),window.addEventListener("blur",we),()=>{window.removeEventListener("keydown",be,!0),window.removeEventListener("keyup",Y,!0),window.removeEventListener("blur",we),Z!==null&&clearTimeout(Z)}},j=[p],t[6]=p,t[7]=w,t[8]=j):(w=t[7],j=t[8]),l.useEffect(w,j);let N;t[9]===Symbol.for("react.memo_cache_sentinel")?(N={activationConstraint:{distance:8}},t[9]=N):N=t[9];let A;t[10]===Symbol.for("react.memo_cache_sentinel")?(A={activationConstraint:{delay:200,tolerance:6}},t[10]=A):A=t[10];const k=wi(Yr(ex,N),Yr(Zg,A)),C=c?.tabs??s1;let P;t[11]!==c?.activeTabId||t[12]!==C?(P=C.find(J=>J.id===c?.activeTabId)??null,t[11]=c?.activeTabId,t[12]=C,t[13]=P):P=t[13];const D=P,F=c?.isOpen?D?.mode??null:null,B=S?.files.length??0;let E;t[14]!==d||t[15]!==g||t[16]!==b||t[17]!==C?(E=Oh({railOrder:d,planModeEnabled:g,isVSCode:er(),screenWidth:b,tabs:C}),t[14]=d,t[15]=g,t[16]=b,t[17]=C,t[18]=E):E=t[18];const _=E;let W;t[19]!==u?(W=J=>{const{active:Z,over:re}=J;if(!re||Z.id===re.id)return;const ee=Fh(xe.getState().contextRailOrder).map(m1),he=ee.indexOf(Z.id),be=ee.indexOf(re.id);he===-1||be===-1||u(Qu(ee,he,be))},t[19]=u,t[20]=W):W=t[20];const V=W;if(!o)return null;let K;t[21]!==e?(K=e("contextRail.aria.rail"),t[21]=e,t[22]=K):K=t[22];let y;t[23]!==_?(y=_.map(h1),t[23]=_,t[24]=y):y=t[24];let I;if(t[25]!==F||t[26]!==B||t[27]!==o||t[28]!==h||t[29]!==m||t[30]!==_||t[31]!==e||t[32]!==a){let J;t[34]!==F||t[35]!==B||t[36]!==o||t[37]!==h||t[38]!==m||t[39]!==e||t[40]!==a?(J=(Z,re)=>{const ee=e(Z.labelKey),he=Z.id==="git"&&!a?B:0,be=he>0?he:null;return s.jsx(r1,{surface:Z,isActive:F===Z.mode,showActivityDot:!1,label:ee,description:e(Z.descriptionKey),badgeCount:be,badgeAriaLabel:be!==null?e(be===1?"contextRail.surface.git.changesCountAriaSingle":"contextRail.surface.git.changesCountAriaPlural",{label:ee,count:be}):null,badgeDescription:be!==null?e(be===1?"contextRail.surface.git.changesCountTooltipSingle":"contextRail.surface.git.changesCountTooltipPlural",{count:be}):null,orderNumber:re+1,showOrderNumber:m,onSelect:Y=>h(o,Y.mode)},Z.id)},t[34]=F,t[35]=B,t[36]=o,t[37]=h,t[38]=m,t[39]=e,t[40]=a,t[41]=J):J=t[41],I=_.map(J),t[25]=F,t[26]=B,t[27]=o,t[28]=h,t[29]=m,t[30]=_,t[31]=e,t[32]=a,t[33]=I}else I=t[33];let $;t[42]!==y||t[43]!==I?($=s.jsx(_a,{items:y,strategy:$a,children:I}),t[42]=y,t[43]=I,t[44]=$):$=t[44];let z;t[45]!==V||t[46]!==k||t[47]!==$?(z=s.jsx(Si,{sensors:k,collisionDetection:ji,onDragEnd:V,children:$}),t[45]=V,t[46]=k,t[47]=$,t[48]=z):z=t[48];let G;return t[49]!==K||t[50]!==z?(G=s.jsx("nav",{"aria-label":K,className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:z}),t[49]=K,t[50]=z,t[51]=G):G=t[51],G};function i1(t){return t.workStatusPanelVisible}function a1(t){return t.contextRailOrder}function l1(t){return t.setContextRailOrder}function c1(t){return t.openContextSurface}function d1(t){return t.shortcutOverrides}function u1(t){return t.planModeEnabled}function f1(t){return t.length===1&&t>="0"&&t<="9"}function m1(t){return t.id}function h1(t){return t.id}const p1=(t,e)=>!t||e.length===0?"":JSON.stringify([t,e]),g1=(t,e,n,r)=>!n||r!==n||t.length===0?[]:xo(t,e,o=>o.name,{limit:10,threshold:.4}),x1=new Set,b1=[],Ya=t=>{if(!t)return"";const e=t.replace(/\\/g,"/"),n=e.startsWith("//");let r=e.replace(/\/+/g,"/");n&&!r.startsWith("//")&&(r=`/${r}`);const o=r==="/",i=/^[A-Za-z]:\/$/.test(r);return!o&&!i&&(r=r.replace(/\/+$/,"")),r},y1=()=>{const t=tt.c(178),{t:e}=mt(),n=xe(v1),r=xe(w1),o=xe(S1),i=xe(j1),c=xe(k1),a=xe(C1),d=xe(N1),u=xe(A1),h=xe(D1),f=xe(P1),g=xe(E1),b=Je(T1),S=Je(I1);let v;t[0]!==n?(v=Ze=>n?Ze.activeSessions:b1,t[0]=n,t[1]=v):v=t[1];const p=Rs(v);let m;t[2]!==n?(m=Ze=>n?Ze.ids:x1,t[2]=n,t[3]=m):m=t[3];const x=No(m);let w;t[4]!==n?(w=Ze=>n?Ze.rankById:ul,t[4]=n,t[5]=w):w=t[5];const j=zi(w),N=ls(R1),A=qt(M1),k=qt(O1),C=Io(),P=su(F1),{files:D,git:F}=tr(),B=mr(B1),{isMobile:E}=pr();let _;t[6]!==C?(_=C?Ya(C):null,t[6]=C,t[7]=_):_=t[7];const W=_,[V,K]=l.useState(""),I=dl(V,200).trim();let $;t[8]!==V?($=V.trim(),t[8]=V,t[9]=$):$=t[9];const z=$;let G,J;t[10]!==n?(G=()=>{n&&K("")},J=[n],t[10]=n,t[11]=G,t[12]=J):(G=t[11],J=t[12]),l.useEffect(G,J);let Z,re;t[13]!==p||t[14]!==B||t[15]!==F||t[16]!==n?(Z=()=>{if(!n||!F)return;const Ze=setTimeout(()=>{const $e=new Set;for(const St of p){const Lt=Us(St);!Lt||$e.has(Lt)||($e.add(Lt),B(Lt,F))}},0);return()=>clearTimeout(Ze)},re=[n,p,F,B],t[13]=p,t[14]=B,t[15]=F,t[16]=n,t[17]=Z,t[18]=re):(Z=t[17],re=t[18]),l.useEffect(Z,re);let ee;t[19]!==r?(ee=()=>r(!1),t[19]=r,t[20]=ee):ee=t[20];const he=ee;let be;t[21]!==he?(be=Ze=>()=>{he(),Ze()},t[21]=he,t[22]=be):be=t[22];const Y=be;let we;t[23]!==A?.id||t[24]!==A?.path||t[25]!==N||t[26]!==E||t[27]!==u||t[28]!==h||t[29]!==b||t[30]!==Y||t[31]!==o||t[32]!==a||t[33]!==i||t[34]!==e||t[35]!==d?(we=()=>{const Ze=[{id:"new-session",title:e("commandPalette.item.newSession"),icon:s.jsx(R,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:e("commandPalette.item.newSession"),onSelect:Y(()=>{o("chat"),a(!1),b()})},{id:"new-worktree",title:e("commandPalette.item.newWorktreeDraft"),icon:s.jsx(R,{name:"git-branch",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat_worktree",searchText:e("commandPalette.item.newWorktreeDraft"),onSelect:Y(L1)},{id:"add-project",title:e("commandPalette.item.addProject"),icon:s.jsx(R,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.addProject"),onSelect:Y(_1)},{id:"toggle-sidebar",title:e(E?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),icon:s.jsx(R,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:e(E?"commandPalette.item.showSessionSwitcher":"commandPalette.item.toggleSidebar"),onSelect:Y(()=>{if(E){const{isSessionSwitcherOpen:$e}=xe.getState();a(!$e)}else d()})},{id:"toggle-terminal",title:e("commandPalette.item.toggleTerminal"),icon:s.jsx(R,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:e("commandPalette.item.toggleTerminal"),onSelect:Y(()=>{N&&h(N,"terminal")})},{id:"context-usage",title:e("commandPalette.item.showContextUsage"),icon:s.jsx(R,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:e("commandPalette.item.showContextUsage"),onSelect:Y(()=>{N&&u(N)})},{id:"open-settings",title:e("commandPalette.item.openSettings"),icon:s.jsx(R,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:e("commandPalette.item.openSettings"),onSelect:Y(()=>i(!0))}];return Ri()&&Ze.splice(1,0,{id:"new-mini-chat",title:e("commandPalette.item.newMiniChat"),icon:s.jsx(R,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:e("commandPalette.item.newMiniChat"),onSelect:Y(()=>{ur("desktop_open_draft_mini_chat_window",{directory:Ya(N||A?.path||""),projectId:A?.id??null}).catch($1)})}),Ze},t[23]=A?.id,t[24]=A?.path,t[25]=N,t[26]=E,t[27]=u,t[28]=h,t[29]=b,t[30]=Y,t[31]=o,t[32]=a,t[33]=i,t[34]=e,t[35]=d,t[36]=we):we=t[36],A?.id,A?.path;let me;t[37]!==we?(me=we(),t[37]=we,t[38]=me):me=t[38];const Q=me;let pe;t[39]===Symbol.for("react.memo_cache_sentinel")?(pe=$n(),t[39]=pe):pe=t[39];const ve=pe;let Te,ke;t[40]===Symbol.for("react.memo_cache_sentinel")?(Te=er(),ke=!ve&&rl(),t[40]=Te,t[41]=ke):(Te=t[40],ke=t[41]);let Ie;t[42]!==E?(Ie={isVSCode:Te,isWeb:ke,isDesktop:ve,isMobile:E},t[42]=E,t[43]=Ie):Ie=t[43];const Ne=Ie;let Ae;if(t[44]!==Y||t[45]!==i||t[46]!==c||t[47]!==Ne){let Ze;t[49]!==Ne?(Ze=St=>St.isAvailable?St.isAvailable(Ne):!0,t[49]=Ne,t[50]=Ze):Ze=t[50];let $e;t[51]!==Y||t[52]!==i||t[53]!==c?($e=St=>{const Lt=Dg(St.slug)??"settings-3",Ot=(St.keywords??[]).join(" ");return{id:`settings:${St.slug}`,title:St.title,icon:St.slug==="mcp"?s.jsx(fu,{className:"mr-2 h-4 w-4"}):s.jsx(R,{name:Lt,className:"mr-2 h-4 w-4"}),searchText:`${St.title} ${St.group} ${Ot}`,onSelect:Y(()=>{c(St.slug),i(!0)})}},t[51]=Y,t[52]=i,t[53]=c,t[54]=$e):$e=t[54],Ae=Ag.filter(z1).filter(Ze).map($e),t[44]=Y,t[45]=i,t[46]=c,t[47]=Ne,t[48]=Ae}else Ae=t[48];const Se=Ae;let Oe;t[55]!==p||t[56]!==x||t[57]!==j?(Oe=wu(p,x,j),t[55]=p,t[56]=x,t[57]=j,t[58]=Oe):Oe=t[58];const ne=Oe,ce=Su(),Re=Je(U1);let te;t[59]!==ce||t[60]!==Re?(te=(Ze,$e)=>{const St=Re.get(Ze);return St?.branch?St.branch.trim()||null:$e&&ce.get($e)?.trim()||null},t[59]=ce,t[60]=Re,t[61]=te):te=t[61];const ae=te;let de;t[62]===Symbol.for("react.memo_cache_sentinel")?(de=[],t[62]=de):de=t[62];const[H,ge]=l.useState(de),[ue,M]=l.useState(""),oe=p1(W,I);let De;t[63]!==W||t[64]!==oe||t[65]!==n||t[66]!==P||t[67]!==ge||t[68]!==M||t[69]!==I?(De=()=>{if(!n){ge([]),M("");return}if(!oe){ge([]),M("");return}if(!W){ge([]),M("");return}let Ze=!1;return P(W,I,10,{type:"file"}).then($e=>{Ze||(ge($e.map(W1)),M(oe))}).catch(()=>{Ze||(ge([]),M(oe))}),()=>{Ze=!0}},t[63]=W,t[64]=oe,t[65]=n,t[66]=P,t[67]=ge,t[68]=M,t[69]=I,t[70]=De):De=t[70];let fe;t[71]!==W||t[72]!==oe||t[73]!==n||t[74]!==P||t[75]!==I?(fe=[n,W,I,oe,P],t[71]=W,t[72]=oe,t[73]=n,t[74]=P,t[75]=I,t[76]=fe):fe=t[76],l.useEffect(De,fe);const X=z.length>0;let le;e:{if(!X){let $e;t[77]!==Q?($e=Q.map(V1),t[77]=Q,t[78]=$e):$e=t[78],le=$e;break e}let Ze;t[79]!==Q||t[80]!==z?(Ze=xo(Q,z,H1,{limit:7,noFuzzy:!0}),t[79]=Q,t[80]=z,t[81]=Ze):Ze=t[81],le=Ze}const se=le;let T;e:{if(!X){let $e;t[82]===Symbol.for("react.memo_cache_sentinel")?($e=[],t[82]=$e):$e=t[82],T=$e;break e}let Ze;t[83]!==z||t[84]!==Se?(Ze=xo(Se,z,K1,{limit:7,noFuzzy:!0}),t[83]=z,t[84]=Se,t[85]=Ze):Ze=t[85],T=Ze}const ie=T;let je;e:{if(!X){let $e;t[86]!==ne?($e=ne.slice(0,5).map(G1),t[86]=ne,t[87]=$e):$e=t[87],je=$e;break e}let Ze;t[88]!==z||t[89]!==ne?(Ze=xo(ne,z,q1,{limit:7,threshold:.2}),t[88]=z,t[89]=ne,t[90]=Ze):Ze=t[90],je=Ze}const Pe=je;let U;e:{if(!n){let $e;t[91]===Symbol.for("react.memo_cache_sentinel")?($e=[],t[91]=$e):$e=t[91],U=$e;break e}let Ze;t[92]!==H||t[93]!==ue||t[94]!==oe||t[95]!==I?(Ze=g1(H,I,oe,ue),t[92]=H,t[93]=ue,t[94]=oe,t[95]=I,t[96]=Ze):Ze=t[96],U=Ze}const Be=U,Fe=n&&oe.length>0&&ue!==oe;let Ye;e:{if(!X){let $e;t[97]===Symbol.for("react.memo_cache_sentinel")?($e=[],t[97]=$e):$e=t[97],Ye=$e;break e}let Ze;if(t[98]!==z||t[99]!==k){const $e=k.map(Y1);Ze=xo($e,z,Q1,{limit:7,threshold:.4}),t[98]=z,t[99]=k,t[100]=Ze}else Ze=t[100];Ye=Ze}const at=Ye;let st,ct,bt,rt,gt,it,Et,Ft,Dt,Bt,qe,zt,Nt,xt;if(t[101]!==ae||t[102]!==he||t[103]!==W||t[104]!==D||t[105]!==X||t[106]!==n||t[107]!==f||t[108]!==b||t[109]!==V||t[110]!==se||t[111]!==Be||t[112]!==at||t[113]!==Pe||t[114]!==ie||t[115]!==r||t[116]!==S||t[117]!==g||t[118]!==e){const Ze=se.map(X1),$e=ie.map(J1),St=Pe.map(Z1),Lt=X?Be.map(eS):[],Ot=X?at.map(tS):[];let ss;e:{if(!X){ss=["commands","sessions"];break e}const He=sS,Ve=[{key:"commands",score:He(se)},{key:"settings",score:He(ie)},{key:"sessions",score:He(Pe)},{key:"files",score:He(Be)},{key:"projects",score:He(at)}];Ve.sort(nS),ss=Ve.map(rS)}const _t=ss,Ct=He=>{he(),S(He.id,Us(He))},os=async He=>{if(!W)return;const Ve=await pf(D,He,{directory:W});if(!Ve.ok){Ee.error(gf(Ve.reason));return}f(W,He),he()},hs=(He,Ve)=>{he(),b({selectedProjectId:He,directoryOverride:Ve})},Rt=He=>Bi(Or(He,g));rt=Ws,zt=n,Nt=r;let $t;t[133]!==e?($t=e("commandPalette.title"),t[133]=e,t[134]=$t):$t=t[134];let Wt;t[135]!==$t?(Wt=s.jsx(wn,{children:$t}),t[135]=$t,t[136]=Wt):Wt=t[136];let is;t[137]!==e?(is=e("commandPalette.description"),t[137]=e,t[138]=is):is=t[138];let Me;t[139]!==is?(Me=s.jsx(Sn,{children:is}),t[139]=is,t[140]=Me):Me=t[140],t[141]!==Wt||t[142]!==Me?(xt=s.jsxs(Rn,{className:"sr-only",children:[Wt,Me]}),t[141]=Wt,t[142]=Me,t[143]=xt):xt=t[143],bt=Vs,Bt="overflow-hidden p-0",qe=!0,ct=_h,Et=!1,Ft="[&_[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 Ke;t[144]!==e?(Ke=e("commandPalette.input.placeholder"),t[144]=e,t[145]=Ke):Ke=t[145],t[146]!==V||t[147]!==Ke?(Dt=s.jsx($h,{value:V,onValueChange:K,placeholder:Ke}),t[146]=V,t[147]=Ke,t[148]=Dt):Dt=t[148],st=zh;let ze;t[149]!==e?(ze=e("commandPalette.empty.noResults"),t[149]=e,t[150]=ze):ze=t[150],t[151]!==ze?(gt=s.jsx(Uh,{children:ze}),t[151]=ze,t[152]=gt):gt=t[152],it=_t.map(He=>He==="commands"&&Ze.length>0?s.jsx(uo,{children:Ze.map(Ve=>s.jsxs(bo,{value:Ve.id,onSelect:Ve.onSelect,children:[Ve.icon,s.jsx("span",{children:Ve.title}),Ve.shortcutId?s.jsx(Bh,{children:Rt(Ve.shortcutId)}):null]},Ve.id))},"commands"):He==="settings"&&$e.length>0?s.jsx(uo,{children:$e.map(oS)},"settings"):He==="sessions"&&St.length>0?s.jsx(uo,{children:St.map(Ve=>{const jt=Ve.title||e("commandPalette.session.untitled"),Jt=Us(Ve),yt=ae(Ve.id,Jt);return s.jsxs(bo,{value:`session:${Ve.id}`,onSelect:()=>Ct(Ve),children:[s.jsx(R,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:jt}),yt?s.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[s.jsx(R,{name:"git-branch",className:"h-3 w-3"}),s.jsx("span",{className:"truncate max-w-[160px]",children:yt})]}):null]},Ve.id)})},"sessions"):He==="files"&&Lt.length>0?s.jsx(uo,{children:Lt.map(Ve=>{const jt=Lh(Ve.relativePath||Ve.name,{maxLength:80});return s.jsxs(bo,{value:`file:${Ve.path}`,onSelect:()=>{os(Ve.path)},children:[s.jsx(cl,{filePath:Ve.path,className:"mr-2 size-4 shrink-0"}),s.jsx("span",{className:"truncate","aria-label":Ve.relativePath,children:jt})]},`file:${Ve.path}`)})},"files"):He==="projects"&&Ot.length>0?s.jsx(uo,{children:Ot.map(Ve=>{const jt=Ve.displayName;return s.jsxs(bo,{value:`project:${Ve.id}`,onSelect:()=>hs(Ve.id,Ve.path),children:[s.jsx(R,{name:"folder",className:"mr-2 h-4 w-4"}),s.jsx("span",{className:"truncate",children:jt}),s.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:Ve.path})]},`project:${Ve.id}`)})},"projects"):null),t[101]=ae,t[102]=he,t[103]=W,t[104]=D,t[105]=X,t[106]=n,t[107]=f,t[108]=b,t[109]=V,t[110]=se,t[111]=Be,t[112]=at,t[113]=Pe,t[114]=ie,t[115]=r,t[116]=S,t[117]=g,t[118]=e,t[119]=st,t[120]=ct,t[121]=bt,t[122]=rt,t[123]=gt,t[124]=it,t[125]=Et,t[126]=Ft,t[127]=Dt,t[128]=Bt,t[129]=qe,t[130]=zt,t[131]=Nt,t[132]=xt}else st=t[119],ct=t[120],bt=t[121],rt=t[122],gt=t[123],it=t[124],Et=t[125],Ft=t[126],Dt=t[127],Bt=t[128],qe=t[129],zt=t[130],Nt=t[131],xt=t[132];let Pt;t[153]!==Fe||t[154]!==e?(Pt=Fe?s.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:e("commandPalette.empty.searchingFiles")}):null,t[153]=Fe,t[154]=e,t[155]=Pt):Pt=t[155];let Mt;t[156]!==st||t[157]!==gt||t[158]!==it||t[159]!==Pt?(Mt=s.jsxs(st,{children:[gt,it,Pt]}),t[156]=st,t[157]=gt,t[158]=it,t[159]=Pt,t[160]=Mt):Mt=t[160];let Xt;t[161]!==ct||t[162]!==Et||t[163]!==Ft||t[164]!==Dt||t[165]!==Mt?(Xt=s.jsxs(ct,{shouldFilter:Et,className:Ft,children:[Dt,Mt]}),t[161]=ct,t[162]=Et,t[163]=Ft,t[164]=Dt,t[165]=Mt,t[166]=Xt):Xt=t[166];let Qe;t[167]!==bt||t[168]!==Bt||t[169]!==qe||t[170]!==Xt?(Qe=s.jsx(bt,{className:Bt,showCloseButton:qe,children:Xt}),t[167]=bt,t[168]=Bt,t[169]=qe,t[170]=Xt,t[171]=Qe):Qe=t[171];let ht;return t[172]!==rt||t[173]!==zt||t[174]!==Nt||t[175]!==xt||t[176]!==Qe?(ht=s.jsxs(rt,{open:zt,onOpenChange:Nt,children:[xt,Qe]}),t[172]=rt,t[173]=zt,t[174]=Nt,t[175]=xt,t[176]=Qe,t[177]=ht):ht=t[177],ht};function v1(t){return t.isCommandPaletteOpen}function w1(t){return t.setCommandPaletteOpen}function S1(t){return t.setActiveMainTab}function j1(t){return t.setSettingsDialogOpen}function k1(t){return t.setSettingsPage}function C1(t){return t.setSessionSwitcherOpen}function N1(t){return t.toggleSidebar}function A1(t){return t.openContextOverview}function D1(t){return t.openContextSurface}function P1(t){return t.openContextFile}function E1(t){return t.shortcutOverrides}function T1(t){return t.openNewSessionDraft}function I1(t){return t.setCurrentSession}function R1(t){return t.currentDirectory}function M1(t){return t.getActiveProject()}function O1(t){return t.projects}function F1(t){return t.searchFiles}function B1(t){return t.ensureStatus}function L1(){ju()}function _1(){_n.requestDirectoryDialog()}function $1(t){console.warn("[command-palette] failed to open draft mini chat window",t)}function z1(t){return t.slug!=="home"}function U1(t){return t.worktreeMetadata}function W1(t){return{path:Ya(t.path),name:t.name,relativePath:t.relativePath}}function V1(t){return{item:t,score:0}}function H1(t){return t.searchText}function K1(t){return t.searchText}function G1(t){return{item:t,score:0}}function q1(t){return t.title||""}function Y1(t){return{...t,displayName:t.label||t.path.split("/").pop()||t.path,searchText:`${t.label||""} ${t.path}`}}function Q1(t){return t.searchText}function X1(t){return t.item}function J1(t){return t.item}function Z1(t){return t.item}function eS(t){return t.item}function tS(t){return t.item}function sS(t){return t.length?t[0].score:1/0}function nS(t,e){return t.score-e.score}function rS(t){return t.key}function oS(t){return s.jsxs(bo,{value:t.id,onSelect:t.onSelect,children:[t.icon,s.jsx("span",{children:t.title})]},t.id)}const rd=(t,e,n)=>Vh(t)?Bi(Or(t,n)):e,iS=()=>{const t=tt.c(69),{t:e}=mt(),n=xe(aS),r=xe(lS),o=xe(cS);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=Wh(),t[0]=i):i=t[0];const c=i;let a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=er(),t[1]=a):a=t[1];const d=a;let u,h,f,g,b,S,v,p,m;if(t[2]!==n||t[3]!==r||t[4]!==o||t[5]!==e){const K=[{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:[`Shift + Alt + ${c} + 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:"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_right_sidebar",descriptionKey:"helpDialog.item.toggleRightSidebar",icon:"layout-right",keys:""},{id:"open_right_sidebar_git",descriptionKey:"helpDialog.item.openRightSidebarGitTab",icon:"git-branch",keys:""},{id:"open_right_sidebar_files",descriptionKey:"helpDialog.item.openRightSidebarFilesTab",icon:"layout-right",keys:""},{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{id:"toggle_context_plan",descriptionKey:"helpDialog.item.togglePlanContextPanel",icon:"time",keys:""},{keys:[`${c} + 1...0`],descriptionKey:"helpDialog.item.switchContextSurface",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:"cycle_services_tab",descriptionKey:"helpDialog.item.cycleServicesTab",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"helpDialog.item.openSettings",icon:"settings-3",keys:""}]}];h=Ws,p=n,m=r,u=Vs,S="max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden";let y;t[15]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(R,{name:"command",className:"h-5 w-5"}),t[15]=y):y=t[15];let I;t[16]!==e?(I=e("helpDialog.title"),t[16]=e,t[17]=I):I=t[17];let $;t[18]!==I?($=s.jsxs(wn,{className:"flex items-center gap-2",children:[y,I]}),t[18]=I,t[19]=$):$=t[19];let z;t[20]!==e?(z=e("helpDialog.description"),t[20]=e,t[21]=z):z=t[21];let G;t[22]!==z?(G=s.jsx(Sn,{children:z}),t[22]=z,t[23]=G):G=t[23],t[24]!==$||t[25]!==G?(v=s.jsxs(Rn,{children:[$,G]}),t[24]=$,t[25]=G,t[26]=v):v=t[26],b="flex-1 overflow-y-auto mt-3 pr-1",f="space-y-4",g=K.map(J=>s.jsxs("div",{children:[s.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:e(J.categoryKey)}),s.jsx("div",{className:"space-y-1",children:J.items.filter(Z=>!(d&&Z.id==="toggle_prompt_navigator")).map(Z=>{const re=Z.id?rd(Z.id,Array.isArray(Z.keys)?Z.keys[0]:Z.keys,o):Array.isArray(Z.keys)?Z.keys:Z.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:[Z.icon&&s.jsx(R,{name:Z.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"typography-meta",children:e(Z.descriptionKey)})]}),s.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(re)?re:[re]).map((ee,he)=>s.jsxs(l.Fragment,{children:[he>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:ee})]},`${ee}-${he}`))})]},Z.id||Z.descriptionKey)})})]},J.categoryKey)),t[2]=n,t[3]=r,t[4]=o,t[5]=e,t[6]=u,t[7]=h,t[8]=f,t[9]=g,t[10]=b,t[11]=S,t[12]=v,t[13]=p,t[14]=m}else u=t[6],h=t[7],f=t[8],g=t[9],b=t[10],S=t[11],v=t[12],p=t[13],m=t[14];let x;t[27]!==f||t[28]!==g?(x=s.jsx("div",{className:f,children:g}),t[27]=f,t[28]=g,t[29]=x):x=t[29];let w;t[30]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(R,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),t[30]=w):w=t[30];let j;t[31]!==e?(j=e("helpDialog.proTips.title"),t[31]=e,t[32]=j):j=t[32];let N;t[33]!==j?(N=s.jsx("p",{className:"font-medium mb-1",children:j}),t[33]=j,t[34]=N):N=t[34];let A;t[35]!==o||t[36]!==e?(A=e("helpDialog.proTips.commandPalette",{shortcut:rd("open_command_palette",`${c} P`,o)}),t[35]=o,t[36]=e,t[37]=A):A=t[37];let k;t[38]!==A?(k=s.jsxs("li",{children:["• ",A]}),t[38]=A,t[39]=k):k=t[39];let C;t[40]!==e?(C=e("helpDialog.proTips.recentSessions"),t[40]=e,t[41]=C):C=t[41];let P;t[42]!==C?(P=s.jsxs("li",{children:["• ",C]}),t[42]=C,t[43]=P):P=t[43];let D;t[44]!==e?(D=e("helpDialog.proTips.themeCycling"),t[44]=e,t[45]=D):D=t[45];let F;t[46]!==D?(F=s.jsxs("li",{children:["• ",D]}),t[46]=D,t[47]=F):F=t[47];let B;t[48]!==k||t[49]!==P||t[50]!==F?(B=s.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[k,P,F]}),t[48]=k,t[49]=P,t[50]=F,t[51]=B):B=t[51];let E;t[52]!==N||t[53]!==B?(E=s.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:s.jsxs("div",{className:"flex items-start gap-2",children:[w,s.jsxs("div",{className:"typography-meta text-muted-foreground",children:[N,B]})]})}),t[52]=N,t[53]=B,t[54]=E):E=t[54];let _;t[55]!==E||t[56]!==b||t[57]!==x?(_=s.jsxs("div",{className:b,children:[x,E]}),t[55]=E,t[56]=b,t[57]=x,t[58]=_):_=t[58];let W;t[59]!==u||t[60]!==_||t[61]!==S||t[62]!==v?(W=s.jsxs(u,{className:S,children:[v,_]}),t[59]=u,t[60]=_,t[61]=S,t[62]=v,t[63]=W):W=t[63];let V;return t[64]!==h||t[65]!==W||t[66]!==p||t[67]!==m?(V=s.jsx(h,{open:p,onOpenChange:m,children:W}),t[64]=h,t[65]=W,t[66]=p,t[67]=m,t[68]=V):V=t[68],V};function aS(t){return t.isHelpDialogOpen}function lS(t){return t.setHelpDialogOpen}function cS(t){return t.shortcutOverrides}const dS=()=>{const t=tt.c(32),{t:e}=mt(),n=xe(uS),r=xe(fS),o=xe(mS);let i;t[0]!==o||t[1]!==e?(i=async()=>{if(!o)return;if((await Xn(o)).ok){Ee.success(e("openCodeStatusDialog.toast.copiedTitle"),{description:e("openCodeStatusDialog.toast.copiedDescription")});return}Ee.error(e("openCodeStatusDialog.toast.copyFailed"))},t[0]=o,t[1]=e,t[2]=i):i=t[2];const c=i;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(wn,{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(Sn,{children:u}),t[9]=u,t[10]=h):h=t[10];let f;t[11]!==d||t[12]!==h?(f=s.jsxs(Rn,{children:[d,h]}),t[11]=d,t[12]=h,t[13]=f):f=t[13];let g;t[14]!==e?(g=e("openCodeStatusDialog.actions.copy"),t[14]=e,t[15]=g):g=t[15];let b;t[16]!==c||t[17]!==g?(b=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",onClick:c,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-primary",children:g})}),t[16]=c,t[17]=g,t[18]=b):b=t[18];let S;t[19]!==o||t[20]!==e?(S=o||e("openCodeStatusDialog.empty.noData"),t[19]=o,t[20]=e,t[21]=S):S=t[21];let v;t[22]!==S?(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:S}),t[22]=S,t[23]=v):v=t[23];let p;t[24]!==f||t[25]!==b||t[26]!==v?(p=s.jsxs(Vs,{className:"max-w-2xl",children:[f,b,v]}),t[24]=f,t[25]=b,t[26]=v,t[27]=p):p=t[27];let m;return t[28]!==n||t[29]!==r||t[30]!==p?(m=s.jsx(Ws,{open:n,onOpenChange:r,children:p}),t[28]=n,t[29]=r,t[30]=p,t[31]=m):m=t[31],m};function uS(t){return t.isOpenCodeStatusDialogOpen}function fS(t){return t.setOpenCodeStatusDialogOpen}function mS(t){return t.openCodeStatusText}const hS=180,od=600,pS=1,gS=6,xS=t=>{const e=t?.directory;return typeof e=="string"&&e.trim()?e:null},bS=({enabled:t=!0,currentSessionId:e,sortedSessions:n,recentSessions:r=[],prefetchSession:o})=>{const i=l.useRef(new Map),c=l.useRef([]),a=l.useRef(new Set),d=l.useRef(0),u=l.useMemo(()=>er(),[]),h=l.useCallback(S=>`${S.directory}
|
|
900
900
|
${S.sessionId}`,[]),f=l.useCallback(()=>{d.current+=1,c.current=[],i.current.forEach(S=>window.clearTimeout(S)),i.current.clear()},[]),g=l.useCallback(()=>{if(!(!t||u||typeof window>"u"))for(;a.current.size<pS&&c.current.length>0;){const S=c.current.shift();if(!S)break;if(S.generation!==d.current||Je.getState().currentSessionId===S.sessionId||tc(S.sessionId,S.directory).renderable)continue;const p=h(S);a.current.add(p),o(S.sessionId,S.directory).catch(()=>{}).finally(()=>{a.current.delete(p),g()})}},[t,u,o,h]),b=l.useCallback(S=>{const v=S?.id,p=xS(S);if(!t||u||!v||!p||v===e||typeof window>"u")return;const m={sessionId:v,directory:p,generation:d.current},x=h(m);if(tc(v,p).renderable||a.current.has(x)||c.current.some(N=>h(N)===x))return;const w=i.current.get(x);w!==void 0&&window.clearTimeout(w);const j=window.setTimeout(()=>{if(i.current.delete(x),m.generation!==d.current)return;const N=c.current;N.length>=gS&&N.shift(),N.push(m),g()},hS);i.current.set(x,j)},[e,t,u,g,h]);l.useEffect(()=>{f()},[f,e,t,u]),l.useEffect(()=>{if(!t||u||!e||n.length===0)return;const S=window.setTimeout(()=>{const v=n.findIndex(p=>p.id===e);v<0||(b(n[v-1]),b(n[v+1]))},od);return()=>window.clearTimeout(S)},[e,t,u,b,n]),l.useEffect(()=>{if(!t||u||!e||r.length===0)return;const S=window.setTimeout(()=>{const v=r.findIndex(p=>p.id===e);v<0||(b(r[v-1]),b(r[v+1]))},od);return()=>window.clearTimeout(S)},[e,t,u,r,b]),l.useEffect(()=>f,[f])},yS=t=>{const e=tt.c(3),n=Je(vS);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],bS(r),null};function vS(t){return t.currentSessionId}const wS=t=>{const e=tt.c(12),{normalizedProjects:n,enabled:r,ownership:o,isSessionsLoading:i,hasAuthoritativeGlobalSessions:c,isWorktreeTopologyLoading:a,unresolvedWorktreeProjectPaths:d,foldersMap:u,createFolder:h,addSessionToFolder:f}=t,g=r===void 0?!0:r;let b,S;e[0]!==f||e[1]!==h||e[2]!==g||e[3]!==u||e[4]!==c||e[5]!==i||e[6]!==a||e[7]!==n||e[8]!==o||e[9]!==d?(b=()=>{!g||i||!c||a||n.forEach(v=>{if(d.has(v.normalizedPath))return;const p=ku(v.normalizedPath),m=o.archivedSessionsByProject.get(v.id)??[],x=u[p]??[],w=new Map(x.map(SS));m.forEach(j=>{const N=Hh(j,v.normalizedPath),A=N.toLowerCase();let k=w.get(A);k||(k=h(p,N),w.set(A,k)),k.sessionIds.includes(j.id)||f(p,k.id,j.id)})})},S=[n,g,o,i,c,a,d,u,h,f],e[0]=f,e[1]=h,e[2]=g,e[3]=u,e[4]=c,e[5]=i,e[6]=a,e[7]=n,e[8]=o,e[9]=d,e[10]=b,e[11]=S):(b=e[10],S=e[11]),l.useEffect(b,S)};function SS(t){return[t.name.toLowerCase(),t]}const jS=t=>{const e=tt.c(4);let n;e[0]!==t?(n=(i,c)=>{const a=t.get(i);if(!a||a.length===0)return c;const d=new Map(c.map(kS)),u=[];a.forEach(g=>{const b=d.get(g);b&&(u.push(b),d.delete(g))});const h=[],f=[];return c.forEach(g=>{d.has(g.id)&&(g.isArchivedBucket?f.push(g):h.push(g))}),[...h,...u,...f]},e[0]=t,e[1]=n):n=e[1];const r=n;let o;return e[2]!==r?(o={getOrderedGroups:r},e[2]=r,e[3]=o):o=e[3],o};function kS(t){return[t.id,t]}const CS=[],NS=t=>{const{normalizedProjects:e,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:o,projectRepoStatus:i,projectRootBranches:c,lastRepoStatus:a,buildGroupedSessions:d,hasSessionSearchQuery:u,normalizedSessionSearchQuery:h,filterSessionNodesForSearch:f,buildGroupSearchText:g,foldersMap:b}=t,S=l.useRef(new Map),v=l.useMemo(()=>{const k=S.current,C=new Map;let P=0,D=0;const F=(E,_)=>E.length===_.length&&E.every((W,V)=>W===_[V]),B=e.map(E=>{const _=n(E.id),W=r(E.id),V=o.get(E.normalizedPath)??CS,K=i.has(E.id)?!!i.get(E.id):a,y=c.get(E.id)??null,I=k.get(E.id);if(I&&I.project===E&&F(I.activeSessions,_)&&F(I.archivedSessions,W)&&I.availableWorktrees===V&&I.rootBranch===y&&I.isRepo===K&&I.buildGroupedSessions===d)return P+=1,C.set(E.id,I),I.section;D+=1;const $=Cu([..._,...W]),z=d($,E.normalizedPath,V,y,K),G={project:E,groups:z};return C.set(E.id,{project:E,activeSessions:_,archivedSessions:W,availableWorktrees:V,rootBranch:y,isRepo:K,buildGroupedSessions:d,section:G}),G});return S.current=C,P>0&&In("ui.sidebar.project_section.reused",P),D>0&&In("ui.sidebar.project_section.rebuilt",D),B},[e,n,r,o,i,a,d,c]),p=l.useMemo(()=>v,[v]),m=l.useMemo(()=>{const k=new WeakMap;if(!u)return k;const C=P=>P.reduce((D,F)=>D+1+C(F.children),0);return p.forEach(P=>{P.groups.forEach(D=>{const F=f(D.sessions,h),B=C(F),E=g(D).includes(h),_=wt(D.directory??null),V=(_?b[_]??[]:[]).filter(K=>K.name.toLowerCase().includes(h)).length;k.set(D,{filteredNodes:F,matchedSessionCount:B,folderNameMatchCount:V,groupMatches:E,hasMatch:E||B>0||V>0})})}),k},[u,p,f,h,g,b]),x=l.useMemo(()=>u?p.map(k=>({...k,groups:k.groups.filter(C=>m.get(C)?.hasMatch===!0)})).filter(k=>k.groups.length>0):p,[u,p,m]),w=u?x:p,j=l.useRef(new WeakMap),N=l.useMemo(()=>{const k=j.current;return w.map(C=>{const P=k.get(C);if(P&&P.query===h)return P.section;const D=C.groups.filter(K=>!K.isArchivedBucket),F=C.groups.filter(K=>K.isArchivedBucket),B=D.flatMap(K=>u?m.get(K)?.filteredNodes??[]:K.sessions),E=D.map(K=>({scopeKey:K.folderScopeKey??wt(K.directory??null),directory:K.directory??null})).filter(K=>!!K.scopeKey),_=D.find(K=>K.isMain)??null,W={id:"flat",label:_?.label??"",branch:_?.branch??null,description:_?.description??null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:_?.directory??C.project.normalizedPath,folderScopeKey:_?.folderScopeKey??C.project.normalizedPath,folderScopes:E,sessions:B};if(u){const K=D.map(y=>m.get(y)).filter(y=>!!y);m.set(W,{filteredNodes:B,matchedSessionCount:K.reduce((y,I)=>y+I.matchedSessionCount,0),folderNameMatchCount:K.reduce((y,I)=>y+I.folderNameMatchCount,0),groupMatches:K.some(y=>y.groupMatches),hasMatch:K.some(y=>y.hasMatch)})}const V={project:C.project,groups:[W,...F]};return k.set(C,{query:h,section:V}),V})},[m,u,h,w]),A=l.useMemo(()=>u?w.reduce((k,C)=>k+C.groups.reduce((P,D)=>{const F=m.get(D);if(!F)return P;const B=F.folderNameMatchCount+(F.groupMatches?1:0);return P+F.matchedSessionCount+B},0),0):0,[u,w,m]);return{projectSections:v,visibleProjectSections:p,groupSearchDataByGroup:m,searchableProjectSections:x,sectionsForRender:w,flatSectionsForRender:N,searchMatchCount:A}};function AS({activeProjectId:t,currentSessionId:e,currentSessionOwnerProjectId:n,projectMap:r,metaByProject:o,rememberedSessionId:i,fallbackSessionId:c}){if(e&&n===t)return{kind:"preserve-current"};if(n==null){const u=!!(e&&Array.from(o.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=(i&&r.has(i)?i:null)??c;return!d||d===e?{kind:"none"}:{kind:"select-session",sessionId:d}}const DS=t=>{const e=tt.c(27),{projectSections:n,activeProjectId:r,activeSessionByProject:o,setActiveSessionByProject:i,currentSessionId:c,currentSessionOwnerProjectId:a,handleSessionSelect:d,newSessionDraftOpen:u,mobileVariant:h,openNewSessionDraft:f,setActiveMainTab:g,setSessionSwitcherOpen:b}=t;let S,v;if(e[0]!==n){v=new Map,S=new Map;const k=(C,P,D,F)=>{v.has(C)||v.set(C,new Map);const B=v.get(C);F.forEach(E=>{const _=wt(E.worktree?.path??E.session.directory??D??P);B.set(E.session.id,{directory:_}),S.has(C)||S.set(C,{id:E.session.id,directory:_}),E.children.length>0&&k(C,P,_,E.children)})};n.forEach(C=>{C.groups.forEach(P=>{k(C.project.id,C.project.normalizedPath,P.directory,P.sessions)})}),e[0]=n,e[1]=S,e[2]=v}else S=e[1],v=e[2];let p;e[3]!==S||e[4]!==v?(p={metaByProject:v,firstSessionByProject:S},e[3]=S,e[4]=v,e[5]=p):p=e[5];const m=p,x=l.useRef(null);let w,j;e[6]!==r||e[7]!==o||e[8]!==c||e[9]!==a||e[10]!==d||e[11]!==h||e[12]!==u||e[13]!==f||e[14]!==n||e[15]!==m||e[16]!==g||e[17]!==i||e[18]!==b?(w=()=>{if(!r||u||xe.getState().isNewWorktreeDialogOpen||x.current===r)return;const k=n.find(F=>F.project.id===r);if(!k)return;const C=m.metaByProject.get(r);if(c&&C&&C.has(c)){x.current=r,i(F=>{if(F.get(r)===c)return F;const B=new Map(F);return B.set(r,c),B});return}const P=AS({activeProjectId:r,currentSessionId:c,currentSessionOwnerProjectId:a,projectMap:C,metaByProject:m.metaByProject,rememberedSessionId:o.get(r),fallbackSessionId:m.firstSessionByProject.get(r)?.id??null});if(P.kind==="preserve-current"){a===r&&(x.current=r);return}if(x.current=r,P.kind==="open-draft"){g("chat"),h&&b(!1),f({selectedProjectId:k.project.id,directoryOverride:k.project.normalizedPath});return}if(P.kind!=="select-session")return;const D=C?.get(P.sessionId)?.directory??null;d(P.sessionId,D)},j=[r,o,c,a,d,u,h,f,n,m,g,b,i],e[6]=r,e[7]=o,e[8]=c,e[9]=a,e[10]=d,e[11]=h,e[12]=u,e[13]=f,e[14]=n,e[15]=m,e[16]=g,e[17]=i,e[18]=b,e[19]=w,e[20]=j):(w=e[19],j=e[20]),l.useLayoutEffect(w,j);let N,A;e[21]!==r||e[22]!==c||e[23]!==m||e[24]!==i?(N=()=>{if(!r||!c)return;const k=m.metaByProject.get(r);!k||!k.has(c)||i(C=>{if(C.get(r)===c)return C;const P=new Map(C);return P.set(r,c),P})},A=[r,c,m,i],e[21]=r,e[22]=c,e[23]=m,e[24]=i,e[25]=N,e[26]=A):(N=e[25],A=e[26]),l.useEffect(N,A)},PS=t=>{const e=tt.c(20);let n,r,o,i;e[0]!==t?({initialActiveSessionByProject:r,persistActiveSessionByProject:o,sessionOwnerBySessionId:i,...n}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=o,e[4]=i):(n=e[1],r=e[2],o=e[3],i=e[4]);const c=Je(ES),a=Je(TS);let d;e[5]!==c||e[6]!==i?(d=c?i?.get(c)?.projectId??null:null,e[5]=c,e[6]=i,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,g]=l.useState(h);let b;e[10]!==f||e[11]!==n||e[12]!==c||e[13]!==u||e[14]!==a?(b={...n,activeSessionByProject:f,setActiveSessionByProject:g,currentSessionId:c,currentSessionOwnerProjectId:u,newSessionDraftOpen:a},e[10]=f,e[11]=n,e[12]=c,e[13]=u,e[14]=a,e[15]=b):b=e[15],DS(b);let S,v;return e[16]!==f||e[17]!==o?(S=()=>{o(f)},v=[f,o],e[16]=f,e[17]=o,e[18]=S,e[19]=v):(S=e[18],v=e[19]),l.useEffect(S,v),null};function ES(t){return t.currentSessionId}function TS(t){return!!t.newSessionDraft?.open}const Qa=new Map,IS=(t,e)=>{for(const n of t){const r=wt(n??null);r&&!Qa.has(r)&&Qa.set(r,e)}},id=t=>{const e=wt(t??null);return e?Qa.get(e)??0:0},Yo=t=>!!t.time?.archived,RS=t=>{const{t:e}=mt(),n=l.useCallback(c=>[c.label,c.branch??"",c.description??"",c.directory??""].join(" ").toLowerCase(),[]),r=l.useCallback(c=>{const a=wt(c.directory??null)??"";return`${(c.title||e("sessions.sidebar.session.untitled")).trim()} ${a}`.toLowerCase()},[e]),o=l.useCallback((c,a)=>a?c.flatMap(d=>{if(r(d.session).includes(a))return[d];const h=o(d.children,a);return h.length===0?[]:[{...d,children:h}]}):c,[r]),i=l.useCallback((c,a,d,u,h)=>{const f=wt(a??null),g=Cu(c).sort((B,E)=>to(B,E,t.pinnedSessionIds,t.sessionOrderRanks)),b=new Map(g.map(B=>[B.id,B])),S=new Map;g.forEach(B=>{const E=B.parentID;if(!E)return;const _=b.get(E);if(!_||Yo(_)!==Yo(B))return;const W=S.get(E)??[];W.push(B),S.set(E,W)}),S.forEach(B=>B.sort((E,_)=>to(E,_,t.pinnedSessionIds,t.sessionOrderRanks)));const v=new Map;d.forEach(B=>{if(B.path){const E=wt(B.path)??B.path;v.set(E,B)}});const p=B=>{const E=wt(B.directory??null),_=t.worktreeMetadata.get(B.id)??null;if(_)return _;if(E){const W=v.get(E)??null;if(W&&E!==f)return W}return null},m=B=>{const E=S.get(B.id)??[];return{session:B,children:E.map(_=>m(_)),worktree:p(B)}},x=g.filter(B=>{const E=B.parentID;if(!E)return!0;const _=b.get(E);return _?Yo(_)!==Yo(B):!0}),w=new Map,j="__archived__",N=B=>{if(B.time?.archived)return j;if(t.isVSCode)return f??"__project_root__";const _=wt(t.worktreeMetadata.get(B.id)?.path??null)??Us(B);return _?_!==f&&v.has(_)?_:_===f?f??"__project_root__":j:j};x.forEach(B=>{const E=m(B),_=N(B);w.has(_)||w.set(_,[]),w.get(_)?.push(E)});const A=f??"__project_root__",k=[{id:"root",label:h&&u&&u!=="HEAD"?e("sessions.sidebar.grouping.projectRootWithBranch",{branch:u}):e("sessions.sidebar.grouping.projectRoot"),branch:u??null,description:f?gi(f,t.homeDirectory):null,isMain:!0,isArchivedBucket:!1,worktree:null,directory:f,folderScopeKey:f,sessions:w.get(A)??[]}],C=new Map;d.forEach(B=>{const E=wt(B.path)??B.path,_=w.get(E)??[],W=_.length>0,V=_.reduce((K,y)=>{const I=Kh(y.session,t.sessionOrderRanks);return Number.isFinite(I)?Math.max(K,I):K},0);C.set(E,{hasActiveSession:W,lastUpdatedAt:V})});const P=[...d].sort((B,E)=>{const _=wt(B.path)??B.path,W=wt(E.path)??E.path,V=C.get(_)??{hasActiveSession:!1,lastUpdatedAt:0},K=C.get(W)??{hasActiveSession:!1,lastUpdatedAt:0};if(V.hasActiveSession!==K.hasActiveSession)return V.hasActiveSession?-1:1;if(V.hasActiveSession&&K.hasActiveSession)return K.lastUpdatedAt-V.lastUpdatedAt;const y=id(B.path),I=id(E.path);if(y!==I)return I-y;const $=(B.label||B.branch||B.name||B.path||"").toLowerCase(),z=(E.label||E.branch||E.name||E.path||"").toLowerCase();return $.localeCompare(z)});(t.isVSCode?[]:P).forEach(B=>{const E=wt(B.path)??B.path,_=t.gitBranches.get(E)?.trim()||null,W=B.branch?.trim()||null,K=!!(_&&W&&B.label&&sc(B.label)===sc(W))?_:B.label||B.name||hr(E,t.homeDirectory)||E;k.push({id:`worktree:${E}`,label:K,branch:_||W,description:gi(E,t.homeDirectory),isMain:!1,isArchivedBucket:!1,worktree:B,directory:E,folderScopeKey:E,sessions:w.get(E)??[]})});const F=w.get(j)??[];return F.length>0&&k.push({id:"archived",label:e("sessions.sidebar.grouping.archived"),branch:null,description:e("sessions.sidebar.grouping.archivedDescription"),isMain:!1,isArchivedBucket:!0,worktree:null,directory:null,folderScopeKey:!t.isVSCode&&f?ku(f):null,sessions:F}),k},[t.homeDirectory,t.worktreeMetadata,t.pinnedSessionIds,t.sessionOrderRanks,t.gitBranches,t.isVSCode,e]);return{buildGroupSearchText:n,buildSessionSearchText:r,filterSessionNodesForSearch:o,buildGroupedSessions:i}},MS=t=>{const e=tt.c(11),{enabled:n,isSessionSearchOpen:r,setIsSessionSearchOpen:o,sessionSearchInputRef:i,sessionSearchContainerRef:c}=t,a=n===void 0?!0:n;let d,u;e[0]!==a||e[1]!==r||e[2]!==i?(d=()=>{if(!a||!r||typeof window>"u")return;const g=window.requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()});return()=>window.cancelAnimationFrame(g)},u=[a,r,i],e[0]=a,e[1]=r,e[2]=i,e[3]=d,e[4]=u):(d=e[3],u=e[4]),l.useEffect(d,u);let h,f;e[5]!==a||e[6]!==r||e[7]!==c||e[8]!==o?(h=()=>{if(!a||!r||typeof document>"u")return;const g=b=>{c.current&&(c.current.contains(b.target)||o(!1))};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},f=[a,r,o,c],e[5]=a,e[6]=r,e[7]=c,e[8]=o,e[9]=h,e[10]=f):(h=e[9],f=e[10]),l.useEffect(h,f)},OS=t=>{const e=tt.c(50),{t:n}=mt(),[r,o]=l.useState(null),i=l.useRef(null);let c,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=()=>()=>{i.current&&clearTimeout(i.current)},a=[],e[0]=c,e[1]=a):(c=e[0],a=e[1]),l.useEffect(c,a);let d;e[2]!==t?(d=(G,J)=>{Da("navigation.session_select"),xe.getState().closeMainSurfaces();const Z=()=>{!t.isSessionSearchOpen&&t.sessionSearchQuery.length===0||(t.setSessionSearchQuery(""),t.setIsSessionSearchOpen(!1))};if(t.mobileVariant&&(t.setActiveMainTab("chat"),t.setSessionSwitcherOpen(!1)),G===Je.getState().currentSessionId){t.allowReselect&&t.onSessionSelected?.(G),Z();return}Da("navigation.session_state_set"),t.setCurrentSession(G,J??null),t.onSessionSelected?.(G),Z()},e[2]=t,e[3]=d):d=e[3];const u=d;let h;e[4]!==t?(h=(G,J)=>{t.setEditingId(G),t.setEditTitle(J)},e[4]=t,e[5]=h):h=e[5];const f=h;let g;e[6]!==t?(g=async G=>{if(!t.editingId)return;const J=(G??t.editTitle).trim();J&&await t.updateSessionTitle(t.editingId,J),t.setEditingId(null),t.setEditTitle("")},e[6]=t,e[7]=g):g=e[7];const b=g;let S;e[8]!==t?(S=()=>{t.setEditingId(null),t.setEditTitle("")},e[8]=t,e[9]=S):S=e[9];const v=S;let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=async(G,J)=>{try{return(await Xn(G)).ok?(o(J),i.current&&clearTimeout(i.current),i.current=window.setTimeout(()=>{o(null),i.current=null},2e3),!0):!1}catch{return!1}},e[10]=p):p=e[10];const m=p;let x;e[11]!==t||e[12]!==n?(x=async G=>{const J=await t.shareSession(G.id);if(!J?.share?.url){Ee.error(n("sessions.sidebar.session.share.error"));return}const Z=await m(J.share.url,G.id);Ee[Z?"success":"warning"](n("sessions.sidebar.session.share.successTitle"),{description:n(Z?"sessions.sidebar.session.share.successDescription":"sessions.sidebar.session.share.copyUrlError")})},e[11]=t,e[12]=n,e[13]=x):x=e[13];const w=x;let j;e[14]!==n?(j=(G,J)=>{m(G,J).then(Z=>{Z||Ee.error(n("sessions.sidebar.session.share.copyUrlError"))})},e[14]=n,e[15]=j):j=e[15];const N=j;let A;e[16]!==n?(A=G=>{Xn(G).then(J=>{if(J.ok){Ee.success(n("sessions.sidebar.session.copyId.success"));return}Ee.error(n("sessions.sidebar.session.copyId.error"))}).catch(()=>Ee.error(n("sessions.sidebar.session.copyId.error")))},e[16]=n,e[17]=A):A=e[17];const k=A;let C;e[18]!==t||e[19]!==n?(C=async G=>{await t.unshareSession(G)?Ee.success(n("sessions.sidebar.session.unshare.success")):Ee.error(n("sessions.sidebar.session.unshare.error"))},e[18]=t,e[19]=n,e[20]=C):C=e[20];const P=C;let D;e[21]!==t.childrenMap?(D=G=>{const J=[],Z=re=>{(t.childrenMap.get(re)??[]).forEach(he=>{J.push(he),Z(he.id)})};return Z(G),J},e[21]=t.childrenMap,e[22]=D):D=e[22];const F=D,B=BS;let E;e[23]!==t||e[24]!==F||e[25]!==n?(E=async(G,J,Z)=>{const re=J?.archivedBucket===!0||J?.hardDelete===!0,ee=Z?.descendantIds??B(F(G.id),re).map(LS);if(ee.length===0){(re?await t.deleteSession(G.id):await t.archiveSession(G.id))?Ee.success(n(re?"sessions.sidebar.session.delete.success":"sessions.sidebar.session.archive.success")):Ee.error(n(re?"sessions.sidebar.session.delete.error":"sessions.sidebar.session.archive.error"));return}const he=[G.id,...ee];if(re){const{deletedIds:we,failedIds:me}=await t.deleteSessions(he);if(me.length===0){const Q=we.length;Ee.success(Q===1?n("sessions.sidebar.bulkActions.deletedSingle",{count:Q}):n("sessions.sidebar.bulkActions.deletedPlural",{count:Q}))}else Ee.error(n("sessions.sidebar.session.delete.error"));return}const{archivedIds:be,failedIds:Y}=await t.archiveSessions(he);be.length>0&&Ee.success(be.length===1?n("sessions.sidebar.bulkActions.archivedSingle",{count:be.length}):n("sessions.sidebar.bulkActions.archivedPlural",{count:be.length})),Y.length>0&&Ee.error(Y.length===1?n("sessions.sidebar.bulkActions.failedArchiveSingle",{count:Y.length}):n("sessions.sidebar.bulkActions.failedArchivePlural",{count:Y.length}))},e[23]=t,e[24]=F,e[25]=n,e[26]=E):E=e[26];const _=E;let W;e[27]!==t||e[28]!==F||e[29]!==_?(W=(G,J)=>{const Z=J?.archivedBucket===!0||J?.hardDelete===!0,re=B(F(G.id),Z).map(_S);if(!t.showDeletionDialog||J?.skipConfirm===!0){_(G,J,{descendantIds:re});return}t.setDeleteSessionConfirm({session:G,descendantCount:re.length,descendantIds:re,archivedBucket:Z})},e[27]=t,e[28]=F,e[29]=_,e[30]=W):W=e[30];const V=W;let K;e[31]!==t||e[32]!==_?(K=async()=>{if(!t.deleteSessionConfirm)return;const{session:G,archivedBucket:J,descendantIds:Z}=t.deleteSessionConfirm;t.setDeleteSessionConfirm(null),await _(G,{archivedBucket:J},{descendantIds:Z})},e[31]=t,e[32]=_,e[33]=K):K=e[33];const y=K;let I;e[34]!==t||e[35]!==n?(I=async G=>{await t.unarchiveSession(G.id)?Ee.success(n("sessions.sidebar.session.restore.success")):Ee.error(n("sessions.sidebar.session.restore.error"))},e[34]=t,e[35]=n,e[36]=I):I=e[36];const $=I;let z;return e[37]!==y||e[38]!==r||e[39]!==v||e[40]!==k||e[41]!==N||e[42]!==V||e[43]!==$||e[44]!==b||e[45]!==f||e[46]!==u||e[47]!==w||e[48]!==P?(z={copiedSessionId:r,handleSessionSelect:u,handleSessionDoubleClick:f,handleSaveEdit:b,handleCancelEdit:v,handleShareSession:w,handleCopyShareUrl:N,handleCopySessionId:k,handleUnshareSession:P,handleDeleteSession:V,handleRestoreSession:$,confirmDeleteSession:y},e[37]=y,e[38]=r,e[39]=v,e[40]=k,e[41]=N,e[42]=V,e[43]=$,e[44]=b,e[45]=f,e[46]=u,e[47]=w,e[48]=P,e[49]=z):z=e[49],z};function FS(t){return!t.time?.archived}function BS(t,e){return e?t:t.filter(FS)}function LS(t){return t.id}function _S(t){return t.id}const $S=t=>{const e=tt.c(26),{isVSCode:n,safeStorage:r,keys:o,groupOrderByProject:i,collapsedGroups:c,setExpandedParents:a,setCollapsedProjects:d}=t,u=l.useRef(null),h=l.useRef(null);let f;e[0]!==n?(f=()=>{if(n)return;const C=h.current;if(h.current=null,u.current=null,!C)return;const{projects:P}=qt.getState(),D=P.map(F=>({...F,sidebarCollapsed:C.has(F.id)}));tu({projects:D}).catch(zS)},e[0]=n,e[1]=f):f=e[1];const g=f;let b;e[2]!==g||e[3]!==n?(b=C=>{typeof window>"u"||n||(h.current=C,u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{g()},700))},e[2]=g,e[3]=n,e[4]=b):b=e[4];const S=b;let v,p;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>{typeof window<"u"&&u.current!==null&&window.clearTimeout(u.current),u.current=null,h.current=null},p=[],e[5]=v,e[6]=p):(v=e[5],p=e[6]),l.useEffect(v,p);let m,x;e[7]!==o.projectCollapse||e[8]!==o.sessionExpanded||e[9]!==r||e[10]!==d||e[11]!==a?(m=()=>{try{const C=r.getItem(o.sessionExpanded);if(C){const D=JSON.parse(C);Array.isArray(D)&&a(new Set(D.filter(US)))}const P=r.getItem(o.projectCollapse);if(P){const D=JSON.parse(P);Array.isArray(D)&&d(new Set(D.filter(WS)))}}catch{}},x=[o.projectCollapse,o.sessionExpanded,r,d,a],e[7]=o.projectCollapse,e[8]=o.sessionExpanded,e[9]=r,e[10]=d,e[11]=a,e[12]=m,e[13]=x):(m=e[12],x=e[13]),l.useEffect(m,x);let w,j;e[14]!==i||e[15]!==o.groupOrder||e[16]!==r?(w=()=>{try{const C=Object.fromEntries(i.entries());r.setItem(o.groupOrder,JSON.stringify(C))}catch{}},j=[i,o.groupOrder,r],e[14]=i,e[15]=o.groupOrder,e[16]=r,e[17]=w,e[18]=j):(w=e[17],j=e[18]),l.useEffect(w,j);let N,A;e[19]!==c||e[20]!==o.groupCollapse||e[21]!==r?(N=()=>{try{r.setItem(o.groupCollapse,JSON.stringify(Array.from(c)))}catch{}},A=[c,o.groupCollapse,r],e[19]=c,e[20]=o.groupCollapse,e[21]=r,e[22]=N,e[23]=A):(N=e[22],A=e[23]),l.useEffect(N,A);let k;return e[24]!==S?(k={scheduleCollapsedProjectsPersist:S},e[24]=S,e[25]=k):k=e[25],k};function zS(){}function US(t){return typeof t=="string"}function WS(t){return typeof t=="string"}const VS=5*6e4,HS=t=>{const e=tt.c(31),{normalizedProjects:n,enabled:r,gitRepoStatus:o,setProjectRepoStatus:i,setProjectRootBranches:c}=t,a=r===void 0?!0:r,{git:d}=tr(),u=mr(KS);let h,f;e[0]!==a||e[1]!==u||e[2]!==d||e[3]!==n||e[4]!==i?(h=()=>{if(!a||!d||n.length===0){i(new Map);return}n.forEach(A=>{Ra(()=>u(A.normalizedPath,d))})},f=[a,n,d,u,i],e[0]=a,e[1]=u,e[2]=d,e[3]=n,e[4]=i,e[5]=h,e[6]=f):(h=e[5],f=e[6]),l.useEffect(h,f);let g,b;e[7]!==a||e[8]!==o||e[9]!==n||e[10]!==i?(g=()=>{if(!a)return;const A=new Map;n.forEach(k=>{A.set(k.id,o.get(k.normalizedPath)?.isGitRepo??null)}),i(A)},b=[a,n,o,i],e[7]=a,e[8]=o,e[9]=n,e[10]=i,e[11]=g,e[12]=b):(g=e[11],b=e[12]),l.useEffect(g,b);let S;if(e[13]!==o||e[14]!==n){let A;e[16]!==o?(A=k=>{const C=o.get(k.normalizedPath)?.branch??"";return`${k.id}:${C}`},e[16]=o,e[17]=A):A=e[17],S=n.map(A).join("|"),e[13]=o,e[14]=n,e[15]=S}else S=e[15];const v=S;let p;e[18]===Symbol.for("react.memo_cache_sentinel")?(p=new Map,e[18]=p):p=e[18];const m=l.useRef(p);let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=new Map,e[19]=x):x=e[19];const w=l.useRef(x);let j;e[20]!==a||e[21]!==o||e[22]!==n||e[23]!==c?(j=()=>{if(!a)return;let A=!1;const k=setTimeout(()=>{(async()=>{const P=new Set(n.map(GS));for(const W of m.current.keys())P.has(W)||(m.current.delete(W),w.current.delete(W));const D=Date.now(),F=n.filter(W=>{const V=o.get(W.normalizedPath);if(V?.isGitRepo===!1)return m.current.delete(W.id),w.current.delete(W.id),!1;if(V?.isGitRepo!==!0||V.branch===null)return!1;const K=V.branch.trim(),y=`${W.normalizedPath}\0${K}`,I=m.current.get(W.id);if(I===y){const $=w.current.get(W.id);return $&&($.at=D),!1}return!(I!==void 0&&D-(w.current.get(W.id)?.at??0)<VS)});if(F.length===0)return;const B=await Gh(F,2,async W=>{const V=o.get(W.normalizedPath)?.branch?.trim()??"",K=`${W.normalizedPath}\0${V}`,y=await Ra(()=>$i(W.normalizedPath,V?{knownBranch:V}:void 0)).catch(qS);return{id:W.id,inputKey:K,branch:y}});if(A)return;const E=B.filter(YS);if(E.length===0)return;const _=Date.now();c(W=>{const V=new Map(W);return E.forEach(K=>{const{id:y,branch:I}=K;I&&V.set(y,I)}),V}),E.forEach(W=>{const{id:V,inputKey:K,branch:y}=W;m.current.set(V,K),y&&w.current.set(V,{branch:y,at:_})})})()},150);return()=>{A=!0,clearTimeout(k)}},e[20]=a,e[21]=o,e[22]=n,e[23]=c,e[24]=j):j=e[24];let N;e[25]!==a||e[26]!==o||e[27]!==n||e[28]!==v||e[29]!==c?(N=[a,n,v,o,c],e[25]=a,e[26]=o,e[27]=n,e[28]=v,e[29]=c,e[30]=N):N=e[30],l.useEffect(j,N)};function KS(t){return t.ensureStatus}function GS(t){return t.id}function qS(){return null}function YS(t){return t.branch}const QS=t=>{const e=tt.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 o=r;let i;e[2]!==n?(i=d=>n.archivedSessionsByProject.get(d)??[],e[2]=n,e[3]=i):i=e[3];const c=i;let a;return e[4]!==c||e[5]!==o?(a={getSessionsForProject:o,getArchivedSessionsForProject:c},e[4]=c,e[5]=o,e[6]=a):a=e[6],a},XS=t=>{const e=new Map;for(const n of t){const r=Us(n);r&&e.set(n.id,{directory:r,sessionId:n.id})}return e},JS=(t,e)=>{if(!t)return[];const n=[];return t.forEach((r,o)=>{e.has(o)||n.push(r)}),n},ZS=t=>{const e=tt.c(5),{enabled:n,hasAuthoritativeGlobalSessions:r,sessions:o}=t,i=n===void 0?!0:n,c=l.useRef(null);let a,d;e[0]!==i||e[1]!==r||e[2]!==o?(a=()=>{if(!i||!r)return;const u=xn(),h=XS(o),f=c.current?.runtimeKey===u?c.current.identities:null;for(const g of JS(f,h))qh({runtimeKey:u,...g});c.current={runtimeKey:u,identities:h}},d=[i,r,o],e[0]=i,e[1]=r,e[2]=o,e[3]=a,e[4]=d):(a=e[3],d=e[4]),l.useEffect(a,d)},e0=(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,ad=(t,e,n)=>{e0(t.get(e),n)&&t.set(e,n)},t0=t=>{const e=t;return wt(e.directory)??wt(e.project?.worktree)},s0=t=>{if(t==="/"||/^[A-Z]:$/.test(t))return null;const e=t.lastIndexOf("/");return e<0?null:e===0?"/":e===2&&/^[A-Z]:\//.test(t)?t.slice(0,2):t.slice(0,e)},n0=(t,e,n,r,o=[])=>{const i=new Map,c=new Map;for(const S of e){const v=wt(S.normalizedPath);if(!v)continue;const p=c.get(v);(!p||S.id.localeCompare(p.id)<0)&&c.set(v,S),ad(i,v,{projectId:S.id,projectRoot:v,scopeDirectory:v,kind:"project"})}if(!r)for(const[S,v]of n){const p=wt(S),m=p?c.get(p):void 0;if(!(!m||!p))for(const x of v){const w=wt(x.path);w&&ad(i,w,{projectId:m.id,projectRoot:p,scopeDirectory:w,kind:"worktree"})}}const a=new Map,d=new Map,u=new Map,h=new Map,f=new Map,g=S=>{if(!S)return null;if(a.has(S))return a.get(S)??null;if(r){const x=i.get(S)??null;return a.set(S,x),x}const v=[];let p=S,m=null;for(;p;){if(a.has(p)){m=a.get(p)??null;break}if(v.push(p),m=i.get(p)??null,m)break;p=s0(p)}for(const x of v)a.set(x,m);return m},b=(S,v,p)=>{for(const m of S){const x=g(t0(m));if(!x)continue;d.set(m.id,x);const w=v.get(x.projectId);if(w?w.push(m):v.set(x.projectId,[m]),!p)continue;const j=p.get(x.scopeDirectory);j?j.add(m.id):p.set(x.scopeDirectory,new Set([m.id]))}};return b(t,u,f),b(o,h),{bySessionId:d,sessionsByProject:u,archivedSessionsByProject:h,sessionsByScope:f,directoryResolutions:a.size}},r0=t=>{const e=tt.c(10),{enabled:n,isDesktopShellRuntime:r,projectSections:o,projectHeaderSentinelRefs:i}=t,c=n===void 0?!0:n;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,e[0]=a):a=e[0];const[d,u]=l.useState(a);let h;e[1]!==c||e[2]!==r||e[3]!==i?(h=()=>{if(!c||!r){u(o0);return}const b=Array.from(i.current.values()).find(i0)?.closest(".oc-sidebar-scroller")??null;if(!b)return;const S=new IntersectionObserver(v=>{u(p=>{const m=new Set(p);let x=!1;for(const w of v){const j=w.target.dataset.projectId;if(!j)continue;const N=w.rootBounds?.top??b.getBoundingClientRect().top,A=!w.isIntersecting&&w.boundingClientRect.top<N;m.has(j)!==A&&(x=!0,A?m.add(j):m.delete(j))}return x?m:p})},{root:b,threshold:0});return i.current.forEach(v=>{v&&S.observe(v)}),()=>S.disconnect()},e[1]=c,e[2]=r,e[3]=i,e[4]=h):h=e[4];let f;return e[5]!==c||e[6]!==r||e[7]!==i||e[8]!==o?(f=[c,r,i,o],e[5]=c,e[6]=r,e[7]=i,e[8]=o,e[9]=f):f=e[9],l.useEffect(h,f),d};function o0(t){return t.size===0?t:new Set}function i0(t){return t!==null}const a0=t=>{const e=tt.c(10),{open:n,onOpenChange:r,project:o,onSave:i}=t;let c;e[0]!==i||e[1]!==n||e[2]!==o?(c=n&&o?s.jsx(Pg,{project:o,onIdentitySave:i,showWorktrees:!1}):null,e[0]=i,e[1]=n,e[2]=o,e[3]=c):c=e[3];let a;e[4]!==c?(a=s.jsx(Vs,{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-background",children:s.jsx("div",{className:"w-full p-3 sm:p-6 sm:pt-8",children:c})})}),e[4]=c,e[5]=a):a=e[5];let d;return e[6]!==r||e[7]!==n||e[8]!==a?(d=s.jsx(Ws,{open:n,onOpenChange:r,children:a}),e[6]=r,e[7]=n,e[8]=a,e[9]=d):d=e[9],d};function Lf(t){const e=tt.c(6),{state:n,activeLabel:r,unreadLabel:o,className:i}=t,c=n==="active"?r:o,a=n==="active"?"bg-primary":"bg-[var(--status-info)]";let d;e[0]!==i||e[1]!==a?(d=ye("h-1.5 w-1.5 shrink-0 rounded-full",a,i),e[0]=i,e[1]=a,e[2]=d):d=e[2];let u;return e[3]!==c||e[4]!==d?(u=s.jsx("span",{className:d,"aria-label":c,title:c}),e[3]=c,e[4]=d,e[5]=u):u=e[5],u}const l0=t=>{const e=tt.c(86),{folder:n,displayName:r,sessions:o,subFolderItems:i,isCollapsed:c,collapsedActivityState:a,onToggle:d,onRename:u,onDelete:h,renderSessionNode:f,getRenderExtras:g,groupDirectory:b,projectId:S,mobileVariant:v,alwaysShowActions:p,isRenaming:m,renameDraft:x,onRenameDraftChange:w,onRenameSave:j,onRenameCancel:N,droppableRef:A,isDropTarget:k,onNewSession:C,depth:P,hideActions:D,archivedBucket:F}=t,B=a===void 0?null:a,_=p===void 0?v===void 0?!1:v:p,W=m===void 0?!1:m,V=x===void 0?"":x,K=k===void 0?!1:k,y=D===void 0?!1:D,I=F===void 0?!1:F,{t:$}=mt(),[z,G]=l.useState(!1),[J,Z]=l.useState(""),re=l.useRef(null),ee=W||z,he=W?V:J;let be;e[0]!==n.name?(be=()=>{Z(n.name),G(!0)},e[0]=n.name,e[1]=be):be=e[1];const Y=be;let we;e[2]!==he||e[3]!==n.name||e[4]!==W||e[5]!==u||e[6]!==j?(we=()=>{const se=he.trim();se&&se!==n.name&&u(se),W&&j&&j(),G(!1),Z("")},e[2]=he,e[3]=n.name,e[4]=W,e[5]=u,e[6]=j,e[7]=we):we=e[7];const me=we;let Q;e[8]!==W||e[9]!==N?(Q=()=>{W&&N&&N(),G(!1),Z("")},e[8]=W,e[9]=N,e[10]=Q):Q=e[10];const pe=Q;let ve;e[11]!==W||e[12]!==w?(ve=se=>{W&&w?w(se):Z(se)},e[11]=W,e[12]=w,e[13]=ve):ve=e[13];const Te=ve;let ke,Ie;e[14]!==W?(ke=()=>{if(!W)return;const se=()=>{const je=re.current;je&&(je.focus(),je.select())},T=requestAnimationFrame(se),ie=window.setTimeout(se,0);return()=>{cancelAnimationFrame(T),window.clearTimeout(ie)}},Ie=[W],e[14]=W,e[15]=ke,e[16]=Ie):(ke=e[15],Ie=e[16]),l.useEffect(ke,Ie);const Ne=c?"folder":"folder-open",Ae=K&&"bg-primary/10 ring-1 ring-inset ring-primary/30";let Se;e[17]!==Ae?(Se=ye("group/folder relative flex items-center justify-between gap-1.5 py-1 min-w-0 rounded-md","cursor-pointer",Ae),e[17]=Ae,e[18]=Se):Se=e[18];let Oe;e[19]!==d||e[20]!==ee?(Oe=ee?void 0:se=>{se.currentTarget.blur(),d()},e[19]=d,e[20]=ee,e[21]=Oe):Oe=e[21];const ne=ee?void 0:"button",ce=ee?void 0:0;let Re;e[22]!==d||e[23]!==ee?(Re=ee?void 0:se=>{(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),d())},e[22]=d,e[23]=ee,e[24]=Re):Re=e[24];let te;e[25]!==n.name||e[26]!==c||e[27]!==$?(te=c?$("sessions.sidebar.folderItem.expandAria",{folderName:n.name}):$("sessions.sidebar.folderItem.collapseAria",{folderName:n.name}),e[25]=n.name,e[26]=c,e[27]=$,e[28]=te):te=e[28];const ae=I?_?"pr-7":"group-hover/folder:pr-7 group-focus-within/folder:pr-7":_?"pr-20":"group-hover/folder:pr-20 group-focus-within/folder:pr-20";let de;e[29]!==ae?(de=ye("min-w-0 flex items-center gap-1.5 pl-1.5 flex-1 transition-[padding]",ae),e[29]=ae,e[30]=de):de=e[30];const H=K?"text-primary":"text-muted-foreground";let ge;e[31]!==H?(ge=ye("h-3.5 w-3.5 flex-shrink-0",H),e[31]=H,e[32]=ge):ge=e[32];let ue;e[33]!==Ne||e[34]!==ge?(ue=s.jsx(R,{name:Ne,className:ge}),e[33]=Ne,e[34]=ge,e[35]=ue):ue=e[35];let M;e[36]!==B||e[37]!==r||e[38]!==he||e[39]!==n.name||e[40]!==pe||e[41]!==Te||e[42]!==me||e[43]!==c||e[44]!==K||e[45]!==ee||e[46]!==o||e[47]!==$?(M=ee?s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-1",onPointerDown:d0,onMouseDown:u0,onSubmit:se=>{se.preventDefault(),me()},children:[s.jsx("input",{ref:re,value:he,onChange:se=>Te(se.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:$("sessions.sidebar.folderItem.namePlaceholder"),onClick:f0,onPointerDown:m0,onMouseDown:h0,onKeyDown:se=>{if(se.key==="Escape"){se.stopPropagation(),pe();return}(se.key===" "||se.key==="Enter")&&se.stopPropagation()}}),s.jsx("button",{type:"submit",className:"shrink-0 text-muted-foreground hover:text-foreground",onClick:p0,onPointerDown:g0,onMouseDown:x0,children:s.jsx(R,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),pe()},onPointerDown:b0,onMouseDown:y0,className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(R,{name:"close",className:"size-4"})})]}):s.jsxs("div",{className:"min-w-0 flex items-center gap-1.5 flex-1",children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("span",{className:ye("typography-ui-label font-semibold truncate",K?"text-primary":"text-muted-foreground"),children:r??n.name})}),s.jsx(ft,{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:["• ",o.length]}),B?s.jsx(Lf,{state:B,activeLabel:$("sessions.sidebar.session.status.active"),unreadLabel:$("sessions.sidebar.session.status.unread")}):null,c?s.jsx(R,{name:"arrow-right-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"})]}),e[36]=B,e[37]=r,e[38]=he,e[39]=n.name,e[40]=pe,e[41]=Te,e[42]=me,e[43]=c,e[44]=K,e[45]=ee,e[46]=o,e[47]=$,e[48]=M):M=e[48];let oe;e[49]!==de||e[50]!==ue||e[51]!==M?(oe=s.jsxs("div",{className:de,children:[ue,M]}),e[49]=de,e[50]=ue,e[51]=M,e[52]=oe):oe=e[52];let De;e[53]!==_||e[54]!==I||e[55]!==n.name||e[56]!==Y||e[57]!==y||e[58]!==h||e[59]!==C||e[60]!==ee||e[61]!==$?(De=!ee&&(!y||I)?s.jsx("div",{className:ye("absolute right-0.5 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",_?"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:[!I&&C?s.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),C()},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-primary/50","aria-label":$("sessions.sidebar.folderItem.newSessionAria",{folderName:n.name}),title:$("sessions.sidebar.project.actions.newSession"),children:s.jsx(R,{name:"add",className:"h-3.5 w-3.5"})}):null,I?null:s.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),Y()},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-primary/50","aria-label":$("sessions.sidebar.folderItem.renameAria",{folderName:n.name}),children:s.jsx(R,{name:"pencil-ai",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:se=>{se.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-primary/50","aria-label":I?$("sessions.sidebar.folderItem.deleteArchivedInFolderAria",{folderName:n.name}):$("sessions.sidebar.folderItem.deleteFolderAria",{folderName:n.name}),children:s.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})}):null,e[53]=_,e[54]=I,e[55]=n.name,e[56]=Y,e[57]=y,e[58]=h,e[59]=C,e[60]=ee,e[61]=$,e[62]=De):De=e[62];let fe;e[63]!==A||e[64]!==Se||e[65]!==Oe||e[66]!==ne||e[67]!==ce||e[68]!==Re||e[69]!==te||e[70]!==oe||e[71]!==De?(fe=s.jsxs("div",{ref:A,className:Se,onClick:Oe,role:ne,tabIndex:ce,onKeyDown:Re,"aria-label":te,children:[oe,De]}),e[63]=A,e[64]=Se,e[65]=Oe,e[66]=ne,e[67]=ce,e[68]=Re,e[69]=te,e[70]=oe,e[71]=De,e[72]=fe):fe=e[72];let X;e[73]!==I||e[74]!==g||e[75]!==b||e[76]!==c||e[77]!==S||e[78]!==f||e[79]!==o||e[80]!==i||e[81]!==$?(X=c?null:s.jsxs("div",{className:"pb-1",children:[i,o.length>0?o.map(se=>f(se,0,b??null,S??null,I,void 0,"project",g?.(se))):i?null:s.jsx("div",{className:"py-1 pl-1.5 text-left typography-micro text-muted-foreground/70",children:$("sessions.sidebar.folderItem.emptyFolder")})]}),e[73]=I,e[74]=g,e[75]=b,e[76]=c,e[77]=S,e[78]=f,e[79]=o,e[80]=i,e[81]=$,e[82]=X):X=e[82];let le;return e[83]!==fe||e[84]!==X?(le=s.jsxs("div",{className:"oc-folder",children:[fe,X]}),e[83]=fe,e[84]=X,e[85]=le):le=e[85],le},c0=l.memo(l0);function d0(t){return t.stopPropagation()}function u0(t){return t.stopPropagation()}function f0(t){return t.stopPropagation()}function m0(t){return t.stopPropagation()}function h0(t){return t.stopPropagation()}function p0(t){return t.stopPropagation()}function g0(t){return t.stopPropagation()}function x0(t){return t.stopPropagation()}function b0(t){return t.stopPropagation()}function y0(t){return t.stopPropagation()}const v0=t=>{const e=tt.c(15),{sessionId:n,sessionDirectory:r,sessionTitle:o,children:i}=t,c=`session-drag:${n}`;let a;e[0]!==r||e[1]!==n||e[2]!==o?(a={type:"session",sessionId:n,sessionDirectory:r,sessionTitle:o},e[0]=r,e[1]=n,e[2]=o,e[3]=a):a=e[3];let d;e[4]!==c||e[5]!==a?(d={id:c,data:a},e[4]=c,e[5]=a,e[6]=d):d=e[6];const{attributes:u,listeners:h,setNodeRef:f,isDragging:g}=sx(d);let b;e[7]!==h?(b=m=>{m.stopPropagation(),h?.onPointerDown&&h.onPointerDown(m)},e[7]=h,e[8]=b):b=e[8];const S=b,v=g?"opacity-30":void 0;let p;return e[9]!==u||e[10]!==i||e[11]!==S||e[12]!==f||e[13]!==v?(p=s.jsx("div",{ref:f,...u,onPointerDown:S,className:v,children:i}),e[9]=u,e[10]=i,e[11]=S,e[12]=f,e[13]=v,e[14]=p):p=e[14],p},w0=t=>{const e=tt.c(11),{folderId:n,children:r}=t,o=`folder-drop:${n}`;let i;e[0]!==n?(i={type:"folder",folderId:n},e[0]=n,e[1]=i):i=e[1];let c;e[2]!==o||e[3]!==i?(c={id:o,data:i},e[2]=o,e[3]=i,e[4]=c):c=e[4];const{setNodeRef:a,isOver:d}=tx(c);let u;e[5]!==r||e[6]!==d||e[7]!==a?(u=r(a,d),e[5]=r,e[6]=d,e[7]=a,e[8]=u):u=e[8];let h;return e[9]!==u?(h=s.jsx(s.Fragment,{children:u}),e[9]=u,e[10]=h):h=e[10],h},S0=t=>{const e=tt.c(20),{scopeKey:n,hasFolders:r,onSessionDroppedOnFolder:o,children:i}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={activationConstraint:{distance:8}},e[0]=c):c=e[0];const a=wi(Yr(Ba,c)),[d,u]=l.useState(null),[h,f]=l.useState("Session"),[g,b]=l.useState(null),[S,v]=l.useState(null);if(!n){let k;return e[1]!==i?(k=s.jsx(s.Fragment,{children:i}),e[1]=i,e[2]=k):k=e[2],k}let p;e[3]!==o?(p=k=>{u(null),b(null),v(null);const{active:C,over:P}=k;if(!P)return;const D=C.data.current,F=P.data.current;D?.type==="session"&&D.sessionId&&F?.type==="folder"&&F.folderId&&o(D.sessionId,F.folderId)},e[3]=o,e[4]=p):p=e[4];const m=p;let x,w;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=k=>{const C=k.active.data.current;if(C?.type==="session"&&C.sessionId){u(C.sessionId),f(C.sessionTitle??"Session");const P=k.active.rect.current.initial?.width,D=k.active.rect.current.initial?.height;b(typeof P=="number"?P:null),v(typeof D=="number"?D:null)}},w=()=>{u(null),b(null),v(null)},e[5]=x,e[6]=w):(x=e[5],w=e[6]);let j;e[7]!==S||e[8]!==d||e[9]!==h||e[10]!==g||e[11]!==r?(j=d&&r?s.jsxs("div",{style:{width:g?`${g}px`:"auto",height:S?`${S}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(R,{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:h})]}):null,e[7]=S,e[8]=d,e[9]=h,e[10]=g,e[11]=r,e[12]=j):j=e[12];let N;e[13]!==j?(N=s.jsx(La,{children:j}),e[13]=j,e[14]=N):N=e[14];let A;return e[15]!==i||e[16]!==m||e[17]!==a||e[18]!==N?(A=s.jsxs(Si,{sensors:a,collisionDetection:ji,onDragStart:x,onDragCancel:w,onDragEnd:m,children:[i,N]}),e[15]=i,e[16]=m,e[17]=a,e[18]=N,e[19]=A):A=e[19],A},Xa=(t,e,n)=>{if(!e)return;const r=o=>{let i=o.session.id===e;for(const c of o.children)i=r(c)||i;return i&&n.add(o.session.id),i};for(const o of t)r(o)},Gn=(t,e)=>{if(!e)return!1;if(t.session.id===e)return!0;for(const n of t.children)if(Gn(n,e))return!0;return!1},j0=(t,e,n)=>{const r=new Map,o=i=>{const c=Us(i.session)??wt(i.worktree?.path)??n;if(c){const a=r.get(c)??[];a.push(i.session.id),r.set(c,a)}if(!(i===t&&e))for(const a of i.children)o(a)};return o(t),[...r].map(([i,c])=>({directory:i,sessionIDs:c}))},k0=(t,e)=>{const n=new Set(t);return t.map(r=>e.get(r)).filter(r=>{if(!r)return!1;const o=new Set;let i=r.session.parentID??null;for(;i&&!o.has(i);){if(n.has(i)&&e.has(i))return!1;o.add(i),i=e.get(i)?.session?.parentID??null}return!0})},ld=new WeakMap;let cd=1;const C0=t=>{const e=ld.get(t);if(e!==void 0)return e;const n=cd;return cd+=1,ld.set(t,n),n},Ei=t=>t.children.length===0?"":t.children.map(n=>{const r=C0(n.session);return n.children.length===0?`${n.session.id}@${r}`:`${n.session.id}@${r}:${Ei(n)}`}).join("|"),_f=(t,e,n,r,o,i)=>{const c=xn(),a=(d,u)=>{if(d.session.id!==u.session.id||d.children.length!==u.children.length)return!0;const h=d.session.directory??o,f=u.session.directory??i,g=nc(c,h??"",d.session.id),b=nc(c,f??"",u.session.id);return(g?n.has(g):!1)!==(b?r.has(b):!1)?!0:d.children.some((S,v)=>a(S,u.children[v]))};return a(t,e)},To=(t,e,n,r)=>{if(!e)return null;const o=r?"archived":"active";let i=null;const c=a=>{if(`${n}:${o}:${a.session.id}`===e)return i=a.session.id,!0;for(const u of a.children)if(c(u))return!0;return!1};return t.forEach(a=>c(a)),i},Pl=(t,e)=>t==="active"||e==="active"?"active":t==="unread"||e==="unread"?"unread":null,$f=(t,e,n,r)=>{if(e.has(t.session.id))return"active";let o=null;const i=!!t.session.parentID;n.has(t.session.id)&&(r||!i)&&(o="unread");for(const c of t.children)if(o=Pl(o,$f(c,e,n,r)),o==="active")return o;return o},dd=(t,e,n,r)=>{let o=null;for(const i of t)if(o=Pl(o,$f(i,e,n,r)),o==="active")return o;return o},N0=50,A0=28,Qo=(t,e)=>e?t.sessions.some(n=>Gn(n,e)):!1,D0=(t,e,n)=>t.sessions.some(r=>_f(r,r,e,n,t.directory,t.directory)),P0=(t,e,n)=>{const r=o=>{const i=o.session.id;return e.get(i)!==n.get(i)?!0:o.children.some(r)};return t.sessions.some(r)},ud=(t,e,n)=>{const r=o=>e.has(o.session.id)!==n.has(o.session.id)?!0:o.children.some(r);return t.sessions.some(r)},E0=(t,e)=>{const n=r=>e.has(r.session.id)?!0:r.children.some(n);return t.sessions.some(n)},T0=(t,e,n)=>{const r=t.isArchivedBucket?"archived":"active",o=i=>{const c=`project:${r}:${i.session.id}`;return e.has(c)!==n.has(c)?!0:i.children.some(o)};return t.sessions.some(o)},I0=(t,e)=>{if(t.group!==e.group||t.groupKey!==e.groupKey||t.projectId!==e.projectId||t.hideGroupLabel!==e.hideGroupLabel||t.compactBodyPadding!==e.compactBodyPadding||t.groupSearchDataByGroup!==e.groupSearchDataByGroup||t.visibleSessionCount!==e.visibleSessionCount||t.collapsedGroups!==e.collapsedGroups&&t.collapsedGroups.has(t.groupKey)!==e.collapsedGroups.has(e.groupKey)||t.pinnedSessionIds!==e.pinnedSessionIds&&D0(e.group,t.pinnedSessionIds,e.pinnedSessionIds)||t.expandedParents!==e.expandedParents&&T0(e.group,t.expandedParents,e.expandedParents)||t.sessionOrderIndex!==e.sessionOrderIndex&&P0(e.group,t.sessionOrderIndex,e.sessionOrderIndex)||t.editingId!==e.editingId&&(Qo(t.group,t.editingId)||Qo(e.group,e.editingId))||t.editTitle!==e.editTitle&&(Qo(t.group,t.editingId)||Qo(e.group,e.editingId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=To(t.group.sessions,t.openSidebarMenuKey,"project",!!t.group.isArchivedBucket),r=To(e.group.sessions,e.openSidebarMenuKey,"project",!!e.group.isArchivedBucket);if(n||r)return!1}return t.activeActivitySessionIds!==e.activeActivitySessionIds&&ud(e.group,t.activeActivitySessionIds,e.activeActivitySessionIds)||t.unreadActivitySessionIds!==e.unreadActivitySessionIds&&ud(e.group,t.unreadActivitySessionIds,e.unreadActivitySessionIds)||t.notifyOnSubtasks!==e.notifyOnSubtasks&&E0(e.group,e.unreadActivitySessionIds)?!1:t.hasSessionSearchQuery===e.hasSessionSearchQuery&&t.normalizedSessionSearchQuery===e.normalizedSessionSearchQuery&&t.hideDirectoryControls===e.hideDirectoryControls&&t.collapsedFolderIds===e.collapsedFolderIds&&t.toggleFolderCollapse===e.toggleFolderCollapse&&t.renameFolder===e.renameFolder&&t.deleteFolder===e.deleteFolder&&t.showDeletionDialog===e.showDeletionDialog&&t.setDeleteFolderConfirm===e.setDeleteFolderConfirm&&t.renderSessionNode===e.renderSessionNode&&t.showMoreGroupSessions===e.showMoreGroupSessions&&t.resetGroupSessionLimit===e.resetGroupSessionLimit&&t.mobileVariant===e.mobileVariant&&t.alwaysShowActions===e.alwaysShowActions&&t.activeProjectId===e.activeProjectId&&t.setActiveProjectIdOnly===e.setActiveProjectIdOnly&&t.setActiveMainTab===e.setActiveMainTab&&t.setSessionSwitcherOpen===e.setSessionSwitcherOpen&&t.openNewSessionDraft===e.openNewSessionDraft&&t.addSessionToFolder===e.addSessionToFolder&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.renamingFolderId===e.renamingFolderId&&t.renameFolderDraft===e.renameFolderDraft&&t.setRenameFolderDraft===e.setRenameFolderDraft&&t.setRenamingFolderId===e.setRenamingFolderId&&t.onToggleCollapsedGroup===e.onToggleCollapsedGroup&&t.dragHandleProps===e.dragHandleProps&&t.scrollContainerRef===e.scrollContainerRef};function R0(t){const{t:e}=mt(),{group:n,groupKey:r,projectId:o,hideGroupLabel:i,hasSessionSearchQuery:c,normalizedSessionSearchQuery:a,groupSearchDataByGroup:d,visibleSessionCount:u,collapsedGroups:h,hideDirectoryControls:f,collapsedFolderIds:g,toggleFolderCollapse:b,renameFolder:S,deleteFolder:v,showDeletionDialog:p,setDeleteFolderConfirm:m,renderSessionNode:x,showMoreGroupSessions:w,resetGroupSessionLimit:j,mobileVariant:N,alwaysShowActions:A,activeProjectId:k,setActiveProjectIdOnly:C,setActiveMainTab:P,setSessionSwitcherOpen:D,openNewSessionDraft:F,addSessionToFolder:B,createFolderAndStartRename:E,renamingFolderId:_,renameFolderDraft:W,setRenameFolderDraft:V,setRenamingFolderId:K,pinnedSessionIds:y,expandedParents:I,sessionOrderIndex:$,editingId:z,openSidebarMenuKey:G,activeActivitySessionIds:J,unreadActivitySessionIds:Z,notifyOnSubtasks:re,onToggleCollapsedGroup:ee,dragHandleProps:he,compactBodyPadding:be=!1,scrollContainerRef:Y}=t,we=l.useCallback((Me,Ke)=>{const ze=$.get(Me.session.id),He=$.get(Ke.session.id);if(ze!==void 0||He!==void 0){if(ze===void 0)return 1;if(He===void 0)return-1;if(ze!==He)return ze-He}return to(Me.session,Ke.session,y,ul)},[y,$]),me=c?d.get(n):null,Q=Fs(Me=>Me.foldersMap),pe=c?!1:h.has(r),ve=l.useMemo(()=>{if(n.isMain||n.isArchivedBucket||i)return null;const Me=wt(n.directory??null),Ke=n.branch?.trim();return Me&&Ke?Li(Me,Ke):null},[n.branch,n.directory,n.isArchivedBucket,n.isMain,i]),Te=Nu(ve),ke=Te?`var(--pr-${Te.visualState})`:void 0,Ie=Au(),Ne=l.useMemo(()=>{const Me=n.folderScopes?.map(Ke=>wt(Ke.directory))??[wt(n.directory??null)];return[...new Set(Me.filter(Ke=>!!Ke))]},[n.directory,n.folderScopes]);l.useSyncExternalStore(l.useCallback(Me=>Ne.length>0?Ie.subscribeBootstrap(Me):()=>{},[Ne.length,Ie]),l.useCallback(()=>Ne.map(Me=>`${Me}\0${Ie.getBootstrapState(Me)??""}\0${Ie.getBootstrapFailure(Me)??""}`).join(""),[Ne,Ie]),l.useCallback(()=>"",[]));const Ae=Ne.some(Me=>{const Ke=Ie.getBootstrapState(Me);return Ke==="queued"||Ke==="running"}),Se=Ne.find(Me=>Ie.getBootstrapState(Me)==="failed")??null,Oe=Se?Ie.getBootstrapFailure(Se):void 0,ne=Oe==="os-permission"&&_m(),[ce,Re]=l.useState(!1),te=l.useCallback(()=>{Se&&Ie.requestBootstrap({directory:Se,priority:pe?"visible":"expanded",reason:n.isMain?"project-expanded":"worktree-expanded",force:!0})},[Ie,Se,n.isMain,pe]),ae=l.useCallback(async()=>{if(!(!Se||!ne||ce)){Re(!0);try{(await $m(Se)).success&&te()}finally{Re(!1)}}},[ne,Se,ce,te]),de=f?10:5,H=Math.max(de,u??de),ge=c?me?.groupMatches===!0:!1,ue=c,M=l.useMemo(()=>[...ue?me?.filteredNodes??[]:n.sessions].sort(we),[we,n.sessions,me?.filteredNodes,ue]),oe=n.folderScopeKey??wt(n.directory??null),De=l.useMemo(()=>n.folderScopes&&n.folderScopes.length>0?n.folderScopes:oe?[{scopeKey:oe,directory:n.directory??null}]:[],[oe,n.directory,n.folderScopes]),fe=l.useMemo(()=>De.flatMap(({scopeKey:Me,directory:Ke})=>(Q[Me]??[]).map(ze=>({folder:ze,scopeKey:Me,scopeDirectory:Ke}))),[De,Q]),X=l.useMemo(()=>{const Me=new Map,Ke=ze=>{ze.forEach(He=>{Me.set(He.session.id,He),He.children.length>0&&Ke(He.children)})};return Ke(M),Me},[M]),le=l.useMemo(()=>fe.map(({folder:Me,scopeKey:Ke,scopeDirectory:ze})=>{const He=k0(Me.sessionIds,X).sort(we);return{folder:Me,scopeKey:Ke,scopeDirectory:ze,nodes:He}}),[fe,X,we]),se=l.useMemo(()=>{const Me=new Map(le.map(Ve=>[Ve.folder.id,Ve])),Ke=new Map;for(const{folder:Ve}of le){if(!Ve.parentId)continue;const jt=Ke.get(Ve.parentId);jt?jt.push(Ve.id):Ke.set(Ve.parentId,[Ve.id])}const ze=new Map,He=Ve=>{const jt=ze.get(Ve);if(jt!==void 0)return jt;const Jt=Me.get(Ve);if(!Jt)return ze.set(Ve,!1),!1;const yt=Ke.get(Ve)??[];if(n.isArchivedBucket&&Jt.nodes.length===0){const Zt=yt.some(Ss=>He(Ss));return ze.set(Ve,Zt),Zt}if(!c||Jt.folder.name.toLowerCase().includes(a)||Jt.nodes.length>0)return ze.set(Ve,!0),!0;const ps=yt.some(Zt=>He(Zt));return ze.set(Ve,ps),ps};return le.filter(({folder:Ve})=>He(Ve.id))},[le,n.isArchivedBucket,c,a]),T=l.useMemo(()=>new Set(se.flatMap(Me=>Me.folder.sessionIds)),[se]),ie=l.useMemo(()=>M.filter(Me=>!T.has(Me.session.id)),[M,T]),je=l.useMemo(()=>se.filter(({folder:Me})=>!Me.parentId),[se]),Pe=l.useMemo(()=>{const Me=new Map;return se.forEach(Ke=>{if(!Ke.folder.parentId)return;const ze=Me.get(Ke.folder.parentId)??[];ze.push(Ke),Me.set(Ke.folder.parentId,ze)}),Me},[se]),U=l.useMemo(()=>{const Me=new Map(se.map(He=>[He.folder.id,He])),Ke=new Map,ze=(He,Ve)=>{const jt=Ke.get(He);if(jt!==void 0)return jt;if(Ve.has(He))return null;Ve.add(He);const Jt=Me.get(He);let yt=Jt?dd(Jt.nodes,J,Z,re):null;for(const Yt of Pe.get(He)??[])if(yt=Pl(yt,ze(Yt.folder.id,Ve)),yt==="active")break;return Ke.set(He,yt),yt};return se.forEach(({folder:He})=>ze(He.id,new Set)),Ke},[J,se,Pe,re,Z]),Be="project",Fe=l.useMemo(()=>{const Me=new Set;return Xa(M,z,Me),se.forEach(({nodes:Ke})=>{Xa(Ke,z,Me)}),Me},[M,se,z]),Ye=l.useMemo(()=>{if(!G)return null;const Me=To(M,G,Be,!!n.isArchivedBucket);if(Me)return Me;for(const{nodes:Ke}of se){const ze=To(Ke,G,Be,!!n.isArchivedBucket);if(ze)return ze}return null},[G,M,se,n.isArchivedBucket]),at=l.useCallback(Me=>{const Ke=new WeakMap,ze=He=>{Ke.set(He,Ei(He));for(const Ve of He.children)ze(Ve)};return Me.forEach(ze),Ke},[]),st=l.useMemo(()=>at(M),[at,M]),ct=l.useMemo(()=>{const Me=new WeakMap;return se.forEach(({nodes:Ke})=>{Ke.forEach(ze=>Me.set(ze,Ei(ze)))}),Me},[se]),bt=l.useCallback(Me=>st.get(Me)??ct.get(Me)??"",[st,ct]),rt=l.useCallback(Me=>({subtreeContainsEditing:Fe,menuOpenSessionId:Ye,nodeStructureKey:bt(Me)}),[Fe,Ye,bt]),gt=ie.length,it=n.isArchivedBucket||c?ie:ie.slice(0,H),Et=gt-it.length,Ft=!n.isArchivedBucket&&!c&>>de&&Et===0,Dt=n.isArchivedBucket===!0&&!c&&it.length>=N0,Bt=n.isArchivedBucket?"archived":"active",qe=Dt&&it.some(Me=>{if(Me.children.length===0)return!1;const Ke=`project:${Bt}:${Me.session.id}`;return I.has(Ke)}),zt=l.useRef(null),[Nt,xt]=l.useState(null),[Pt,Mt]=l.useState(0),[,Xt]=l.useState(0);l.useEffect(()=>{if(!Dt)return;const Me=zt.current;if(!Me||typeof ResizeObserver>"u")return;const Ke=new ResizeObserver(()=>Xt(ze=>ze+1));return Ke.observe(Me),()=>Ke.disconnect()},[Dt]),l.useLayoutEffect(()=>{if(!Dt){Nt!==null&&xt(null),Pt!==0&&Mt(0);return}const Me=zt.current;if(!Me)return;let Ke=Nt;const ze=Y?.current??null;if(ze&&ze.contains(Me)){if(Ke=ze,Ke!==Nt){xt(Ke);return}}else if(!Ke||!Ke.contains(Me)){let Ve=Me.parentElement;for(;Ve;){const jt=window.getComputedStyle(Ve);if(jt.overflowY==="auto"||jt.overflowY==="scroll"){Ke=Ve;break}Ve=Ve.parentElement}if(Ke!==Nt){xt(Ke);return}}if(!Ke)return;const He=Me.getBoundingClientRect().top-Ke.getBoundingClientRect().top+Ke.scrollTop;Mt(Ve=>Math.abs(Ve-He)<1?Ve:He)});const Qe=Dt&&Nt!==null,ht=ox({count:it.length,enabled:Qe,getScrollElement:()=>Nt,initialOffset:()=>Nt?.scrollTop??0,estimateSize:()=>A0,overscan:qe?20:8,scrollMargin:Pt,getItemKey:Me=>it[Me]?.session.id??Me}),Ze=l.useCallback(Me=>{const Ke=[],ze=He=>{He.forEach(Ve=>{Ke.push(Ve.session),Ve.children.length>0&&ze(Ve.children)})};return ze(Me),Ke},[]),$e=l.useMemo(()=>Ze(M),[Ze,M]),St=l.useMemo(()=>{if(!n.isArchivedBucket)return new Map;const Me=new Map,Ke=new Map;for(const{folder:He}of se){if(!He.parentId)continue;const Ve=Ke.get(He.parentId)??[];Ve.push(He.id),Ke.set(He.parentId,Ve)}const ze=(He,Ve)=>{if(Ve.has(He))return[];Ve.add(He);const jt=se.find(({folder:Yt})=>Yt.id===He),Jt=jt?Ze(jt.nodes):[],yt=Ke.get(He)??[];for(const Yt of yt)Jt.push(...ze(Yt,Ve));return Jt};for(const{folder:He}of se)Me.set(He.id,ze(He.id,new Set));return Me},[se,Ze,n.isArchivedBucket]);if(c&&!ge&&je.length===0&&ie.length===0)return null;const Lt=!n.isMain&&!!n.branch,Ot=n.branch&&Yh(n.branch,n.label)?{label:n.branch}:null,ss=pe?dd(M,J,Z,re):null,_t=ss?s.jsx(Lf,{state:ss,activeLabel:e("sessions.sidebar.session.status.active"),unreadLabel:e("sessions.sidebar.session.status.unread")}):null,Ct=(Me,Ke)=>{const{folder:ze,scopeKey:He,scopeDirectory:Ve,nodes:jt}=Me,Jt=St.get(ze.id)??[],yt=c?!1:g.has(ze.id);return s.jsx(w0,{folderId:ze.id,children:(Yt,ps)=>s.jsx(c0,{folder:ze,displayName:Ke,sessions:jt,isCollapsed:yt,collapsedActivityState:yt?U.get(ze.id)??null:null,onToggle:()=>b(ze.id),onRename:Zt=>{S(He,ze.id,Zt)},onDelete:()=>{if(n.isArchivedBucket){_n.requestDelete({sessions:Jt,mode:"session"});return}if(!p){v(He,ze.id);return}const Zt=se.filter(({folder:en})=>en.parentId===ze.id).length,Ss=jt.length;m({scopeKey:He,folderId:ze.id,folderName:ze.name,subFolderCount:Zt,sessionCount:Ss})},renderSessionNode:x,getRenderExtras:bt?Zt=>({subtreeContainsEditing:Fe,menuOpenSessionId:Ye,nodeStructureKey:bt(Zt),childRenderExtrasFor:rt}):void 0,groupDirectory:Ve??n.directory,projectId:o,mobileVariant:N,alwaysShowActions:A,isRenaming:_===ze.id,renameDraft:_===ze.id?W:void 0,onRenameDraftChange:Zt=>V(Zt),onRenameSave:()=>{const Zt=W.trim();Zt&&S(He,ze.id,Zt),K(null),V("")},onRenameCancel:()=>{K(null),V("")},droppableRef:Yt,isDropTarget:ps,depth:0,onNewSession:()=>{o&&o!==k&&C(o),P("chat"),N&&D(!1),F({selectedProjectId:o,directoryOverride:Ve??n.directory,targetFolderId:ze.id})},hideActions:!1,archivedBucket:n.isArchivedBucket===!0})},ze.id)},os=()=>{const Me=new Map;for(const He of se){const Ve=He.folder.parentId;if(!Ve)continue;const jt=Me.get(Ve);jt?jt.push(He):Me.set(Ve,[He])}const Ke=[],ze=(He,Ve)=>{const jt=Ve?`${Ve} / ${He.folder.name}`:He.folder.name;Ke.push(Ct(He,jt)),!(!c&&g.has(He.folder.id))&&(Me.get(He.folder.id)??[]).forEach(yt=>ze(yt,jt))};return je.forEach(He=>ze(He,"")),Ke},hs=!!(!n.isMain&&n.worktree),Rt=A?hs?"pr-14":"pr-7":hs?"pr-2 group-hover/gh:pr-14 group-focus-within/gh:pr-14":"pr-2 group-hover/gh:pr-7 group-focus-within/gh:pr-7",$t=Se?s.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[e(Oe==="os-permission"?"sessions.sidebar.group.empty.permissionDenied":"sessions.sidebar.group.empty.loadFailed"),ne?s.jsx(nt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",disabled:ce,onClick:()=>{ae()},children:e("sessions.sidebar.group.empty.grantAccess")}):null,s.jsx(nt,{variant:"link",size:"xs",className:"h-auto p-0 typography-micro",onClick:te,children:e("sessions.sidebar.group.empty.retry")})]}):null,Wt=s.jsxs(S0,{scopeKey:De[0]?.scopeKey??oe,hasFolders:se.length>0,onSessionDroppedOnFolder:(Me,Ke)=>{const ze=se.find(({folder:Ve})=>Ve.id===Ke);if(!ze)return;const He=Fs.getState();for(const{scopeKey:Ve}of De)Ve!==ze.scopeKey&&He.getSessionFolderId(Ve,Me)&&He.removeSessionFromFolder(Ve,Me);B(ze.scopeKey,Ke,Me)},children:[os(),Dt?s.jsx("div",{ref:zt,children:Qe?s.jsx("div",{style:{height:ht.getTotalSize(),position:"relative"},children:ht.getVirtualItems().map(Me=>{const Ke=it[Me.index];return Ke?s.jsx("div",{"data-index":Me.index,ref:ht.measureElement,className:"[&_[data-session-row]]:my-px",style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${Me.start-Pt}px)`},children:x(Ke,0,n.directory,o,n.isArchivedBucket===!0,void 0,"project",{subtreeContainsEditing:Fe,menuOpenSessionId:Ye,nodeStructureKey:bt(Ke),childRenderExtrasFor:rt})},Ke.session.id):null})}):it.map(Me=>x(Me,0,n.directory,o,n.isArchivedBucket===!0,void 0,"project",{subtreeContainsEditing:Fe,menuOpenSessionId:Ye,nodeStructureKey:bt(Me),childRenderExtrasFor:rt}))}):it.map(Me=>x(Me,0,n.directory,o,n.isArchivedBucket===!0,void 0,"project",{subtreeContainsEditing:Fe,menuOpenSessionId:Ye,nodeStructureKey:bt(Me),childRenderExtrasFor:rt})),gt===0&&se.length===0?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-muted-foreground",children:n.isArchivedBucket?e("sessions.sidebar.group.empty.noArchivedSessions"):Ae?s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(R,{name:"loader-4",className:"size-3 animate-spin"}),e("sessions.sidebar.group.empty.loadingSessions")]}):$t||e("sessions.sidebar.group.empty.noSessionsInWorkspace")}):null,gt>0&&$t?s.jsx("div",{className:"py-1 pl-[26px] text-left typography-micro text-status-error",children:$t}):null,Et>0?s.jsx("button",{type:"button",onClick:()=>w(r,it.length),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showMore")}):null,Ft?s.jsx("button",{type:"button",onClick:()=>j(r),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:e("sessions.sidebar.group.showFewer")}):null]}),is="pb-2";return i?s.jsx("div",{className:"oc-group",children:s.jsx("div",{className:ye("oc-group-body",is),children:Wt})}):s.jsxs("div",{className:"oc-group",children:[s.jsxs("div",{className:ye("group/gh relative flex items-start justify-between gap-1 py-1 min-w-0 rounded-md","cursor-pointer"),onClick:()=>ee(r),role:"button",tabIndex:0,onKeyDown:Me=>{(Me.key==="Enter"||Me.key===" ")&&(Me.preventDefault(),ee(r))},"aria-label":pe?e("sessions.sidebar.group.expandAria",{label:n.label}):e("sessions.sidebar.group.collapseAria",{label:n.label}),"aria-expanded":!pe,children:[s.jsx("div",{ref:he?.setActivatorNodeRef,className:ye("min-w-0 flex flex-1 items-start gap-1 overflow-hidden pl-1.5 transition-[padding]",Rt),...he?.listeners??{},children:s.jsxs("div",{className:"min-w-0 flex flex-1 flex-col justify-center gap-0.5 overflow-hidden",children:[s.jsx("p",{className:"text-[14px] font-normal truncate text-foreground/92",children:n.isArchivedBucket?s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(R,{name:"archive",className:ye("h-3.5 w-3.5 shrink-0 text-muted-foreground",A?"hidden":"group-hover/gh:hidden")}),s.jsx("span",{className:ye("text-muted-foreground h-3.5 w-3.5 items-center justify-center",A?"inline-flex":"hidden group-hover/gh:inline-flex"),children:pe?s.jsx(R,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:oi(n.label,a)}),_t]}):!n.isMain||n.worktree?s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center",children:[s.jsx(R,{name:"git-branch",className:ye("h-3.5 w-3.5 shrink-0",!ke&&"text-muted-foreground",A?"hidden":"group-hover/gh:hidden"),style:ke?{color:ke}:void 0}),s.jsx("span",{className:ye("text-muted-foreground h-3.5 w-3.5 items-center justify-center",A?"inline-flex":"hidden group-hover/gh:inline-flex"),children:pe?s.jsx(R,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"min-w-0 truncate typography-ui-label font-semibold text-muted-foreground",children:oi(n.label,a)}),_t,Te?s.jsxs("span",{className:"ml-auto flex-shrink-0 text-[0.72rem] font-medium leading-none",style:ke?{color:ke}:void 0,children:["#",Te.number]}):null]}):s.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",children:[s.jsx("span",{className:"min-w-0 truncate",children:oi(n.label,a)}),_t]})}),Lt&&Ot?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 leading-tight",children:[n.isArchivedBucket?s.jsx(R,{name:"archive",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}):s.jsx(R,{name:"git-branch",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-muted-foreground/80",children:Ot.label})]}):null]})}),n.isArchivedBucket&&$e.length>0?s.jsx("div",{className:ye("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",A?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),_n.requestDelete({sessions:$e,mode:"session"})},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-primary/50","aria-label":e("sessions.sidebar.group.actions.deleteArchivedInGroupAria",{label:n.label}),children:s.jsx(R,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteArchivedSessions")})})]})}):null,n.directory&&!n.isMain&&n.worktree?s.jsx("div",{className:ye("absolute right-7 top-1/2 -translate-y-1/2 z-10 transition-opacity",A?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),_n.requestDelete({sessions:$e,mode:"worktree",worktree:n.worktree})},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-primary/50","aria-label":e("sessions.sidebar.group.actions.deleteGroupAria",{label:n.label}),children:s.jsx(R,{name:"delete-bin",className:"h-4 w-4"})})}),s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.group.actions.deleteWorktree")})})]})}):null,n.directory?s.jsx("div",{className:ye("absolute right-0.5 top-1/2 -translate-y-1/2 z-10 transition-opacity",A?"opacity-100":"opacity-0 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100"),children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:Me=>{Me.stopPropagation(),o&&o!==k&&C(o),P("chat"),N&&D(!1),F({selectedProjectId:o,directoryOverride:n.directory})},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-primary/50","aria-label":e("sessions.sidebar.group.actions.newDraftInGroupAria",{label:n.label}),children:s.jsx(R,{name:"add",className:"h-4 w-4"})})}),s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:e("sessions.sidebar.project.actions.newDraftSession")})})]})}):null]}),pe?null:s.jsx("div",{className:ye("oc-group-body",is),children:Wt})]})}const M0=l.memo(R0,I0),O0=(t,e)=>{const n=t??{};return e<2&&(n.projectSortOrder="manual"),e<3&&n.projectSortOrder==="recent"&&(n.projectSortOrder="manual"),e<4&&delete n.displayMode,n},As=xr()(Yu(t=>({sessionGroupingMode:"by-worktree",setSessionGroupingMode:e=>t({sessionGroupingMode:e}),stickyZoneHeaders:!0,toggleStickyZoneHeaders:()=>t(e=>({stickyZoneHeaders:!e.stickyZoneHeaders})),showRecentSection:!0,showArchivedSessions:!1,projectSortOrder:"manual",setShowRecentSection:e=>t({showRecentSection:e}),setShowArchivedSessions:e=>t({showArchivedSessions:e}),toggleRecentSection:()=>t(e=>({showRecentSection:!e.showRecentSection})),toggleArchivedSessions:()=>t(e=>({showArchivedSessions:!e.showArchivedSessions})),setProjectSortOrder:e=>t({projectSortOrder:e})}),{name:"session-display-mode",version:4,migrate:O0}));function F0(t){const e=tt.c(219),{t:n}=mt(),{hideDirectoryControls:r,showRecentControls:o,handleOpenDirectoryDialog:i,onOpenScheduled:c,onOpenMultiRun:a,canOpenMultiRun:d,onOpenArchive:u,headerActionIconClass:h,headerActionButtonClass:f,isSessionSearchOpen:g,setIsSessionSearchOpen:b,sessionSearchInputRef:S,sessionSearchQuery:v,setSessionSearchQuery:p,hasSessionSearchQuery:m,searchMatchCount:x,collapseAllProjects:w,expandAllProjects:j,selectionModeEnabled:N,onToggleSelectionMode:A}=t,k=As(H0),C=As(V0),P=As(W0),D=As(U0),F=As(z0),B=As($0),E=As(_0),_=As(L0);if(r)return null;let W;e[0]!==f?(W=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[0]=f,e[1]=W):W=e[1];let V;e[2]!==n?(V=n("sessions.sidebar.header.actions.addProject"),e[2]=n,e[3]=V):V=e[3];let K;e[4]!==h?(K=s.jsx(R,{name:"folder-add",className:h}),e[4]=h,e[5]=K):K=e[5];let y;e[6]!==i||e[7]!==W||e[8]!==V||e[9]!==K?(y=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:i,className:W,"aria-label":V,children:K})}),e[6]=i,e[7]=W,e[8]=V,e[9]=K,e[10]=y):y=e[10];let I;e[11]!==n?(I=n("sessions.sidebar.header.actions.addProject"),e[11]=n,e[12]=I):I=e[12];let $;e[13]!==I?($=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:I})}),e[13]=I,e[14]=$):$=e[14];let z;e[15]!==y||e[16]!==$?(z=s.jsxs(dt,{children:[y,$]}),e[15]=y,e[16]=$,e[17]=z):z=e[17];let G;e[18]!==f?(G=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[18]=f,e[19]=G):G=e[19];let J;e[20]!==n?(J=n("sessions.sidebar.header.actions.scheduledTasks"),e[20]=n,e[21]=J):J=e[21];let Z;e[22]!==h?(Z=s.jsx(R,{name:"calendar-schedule",className:h}),e[22]=h,e[23]=Z):Z=e[23];let re;e[24]!==c||e[25]!==G||e[26]!==J||e[27]!==Z?(re=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:c,className:G,"aria-label":J,children:Z})}),e[24]=c,e[25]=G,e[26]=J,e[27]=Z,e[28]=re):re=e[28];let ee;e[29]!==n?(ee=n("sessions.sidebar.header.actions.scheduledTasks"),e[29]=n,e[30]=ee):ee=e[30];let he;e[31]!==ee?(he=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ee})}),e[31]=ee,e[32]=he):he=e[32];let be;e[33]!==re||e[34]!==he?(be=s.jsxs(dt,{children:[re,he]}),e[33]=re,e[34]=he,e[35]=be):be=e[35];let Y;e[36]!==f?(Y=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[36]=f,e[37]=Y):Y=e[37];let we;e[38]!==n?(we=n("sessions.sidebar.header.actions.newMultiRun"),e[38]=n,e[39]=we):we=e[39];const me=!d;let Q;e[40]!==h?(Q=s.jsx(Qh,{className:h}),e[40]=h,e[41]=Q):Q=e[41];let pe;e[42]!==a||e[43]!==Y||e[44]!==we||e[45]!==me||e[46]!==Q?(pe=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:a,className:Y,"aria-label":we,disabled:me,children:Q})}),e[42]=a,e[43]=Y,e[44]=we,e[45]=me,e[46]=Q,e[47]=pe):pe=e[47];let ve;e[48]!==n?(ve=n("sessions.sidebar.header.actions.newMultiRun"),e[48]=n,e[49]=ve):ve=e[49];let Te;e[50]!==ve?(Te=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ve})}),e[50]=ve,e[51]=Te):Te=e[51];let ke;e[52]!==pe||e[53]!==Te?(ke=s.jsxs(dt,{children:[pe,Te]}),e[52]=pe,e[53]=Te,e[54]=ke):ke=e[54];let Ie;e[55]!==f?(Ie=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[55]=f,e[56]=Ie):Ie=e[56];let Ne;e[57]!==n?(Ne=n("sessions.sidebar.nav.archive"),e[57]=n,e[58]=Ne):Ne=e[58];let Ae;e[59]!==h?(Ae=s.jsx(R,{name:"archive",className:h}),e[59]=h,e[60]=Ae):Ae=e[60];let Se;e[61]!==u||e[62]!==Ie||e[63]!==Ne||e[64]!==Ae?(Se=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:u,className:Ie,"aria-label":Ne,children:Ae})}),e[61]=u,e[62]=Ie,e[63]=Ne,e[64]=Ae,e[65]=Se):Se=e[65];let Oe;e[66]!==n?(Oe=n("sessions.sidebar.nav.archive"),e[66]=n,e[67]=Oe):Oe=e[67];let ne;e[68]!==Oe?(ne=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Oe})}),e[68]=Oe,e[69]=ne):ne=e[69];let ce;e[70]!==Se||e[71]!==ne?(ce=s.jsxs(dt,{children:[Se,ne]}),e[70]=Se,e[71]=ne,e[72]=ce):ce=e[72];let Re;e[73]!==be||e[74]!==ke||e[75]!==ce||e[76]!==z?(Re=s.jsxs("div",{className:"ml-[3px] flex items-center gap-1.5",children:[z,be,ke,ce]}),e[73]=be,e[74]=ke,e[75]=ce,e[76]=z,e[77]=Re):Re=e[77];let te;e[78]!==b?(te=()=>b(B0),e[78]=b,e[79]=te):te=e[79];let ae;e[80]!==f?(ae=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[80]=f,e[81]=ae):ae=e[81];let de;e[82]!==n?(de=n("sessions.sidebar.header.actions.searchSessions"),e[82]=n,e[83]=de):de=e[83];let H;e[84]!==h?(H=s.jsx(R,{name:"search",className:h}),e[84]=h,e[85]=H):H=e[85];let ge;e[86]!==g||e[87]!==te||e[88]!==ae||e[89]!==de||e[90]!==H?(ge=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:te,className:ae,"aria-label":de,"aria-expanded":g,children:H})}),e[86]=g,e[87]=te,e[88]=ae,e[89]=de,e[90]=H,e[91]=ge):ge=e[91];let ue;e[92]!==n?(ue=n("sessions.sidebar.header.actions.searchSessions"),e[92]=n,e[93]=ue):ue=e[93];let M;e[94]!==ue?(M=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:ue})}),e[94]=ue,e[95]=M):M=e[95];let oe;e[96]!==ge||e[97]!==M?(oe=s.jsxs(dt,{children:[ge,M]}),e[96]=ge,e[97]=M,e[98]=oe):oe=e[98];const De=N&&"bg-interactive-hover text-primary";let fe;e[99]!==f||e[100]!==De?(fe=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent",De),e[99]=f,e[100]=De,e[101]=fe):fe=e[101];let X;e[102]!==N||e[103]!==n?(X=n(N?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[102]=N,e[103]=n,e[104]=X):X=e[104];let le;e[105]!==h?(le=s.jsx(R,{name:"checkbox-multiple",className:h}),e[105]=h,e[106]=le):le=e[106];let se;e[107]!==A||e[108]!==N||e[109]!==fe||e[110]!==X||e[111]!==le?(se=s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:A,className:fe,"aria-label":X,"aria-pressed":N,children:le})}),e[107]=A,e[108]=N,e[109]=fe,e[110]=X,e[111]=le,e[112]=se):se=e[112];let T;e[113]!==N||e[114]!==n?(T=n(N?"sessions.sidebar.header.actions.exitSelection":"sessions.sidebar.header.actions.selectSessions"),e[113]=N,e[114]=n,e[115]=T):T=e[115];let ie;e[116]!==T?(ie=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:T})}),e[116]=T,e[117]=ie):ie=e[117];let je;e[118]!==se||e[119]!==ie?(je=s.jsxs(dt,{children:[se,ie]}),e[118]=se,e[119]=ie,e[120]=je):je=e[120];let Pe;e[121]!==f?(Pe=ye(f,"text-muted-foreground hover:text-foreground hover:bg-transparent"),e[121]=f,e[122]=Pe):Pe=e[122];let U;e[123]!==n?(U=n("sessions.sidebar.header.displayMode.label"),e[123]=n,e[124]=U):U=e[124];let Be;e[125]!==h?(Be=s.jsx(R,{name:"equalizer-2",className:h}),e[125]=h,e[126]=Be):Be=e[126];let Fe;e[127]!==Pe||e[128]!==U||e[129]!==Be?(Fe=s.jsx(ut,{asChild:!0,children:s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe,"aria-label":U,children:Be})})}),e[127]=Pe,e[128]=U,e[129]=Be,e[130]=Fe):Fe=e[130];let Ye;e[131]!==n?(Ye=n("sessions.sidebar.header.displayMode.label"),e[131]=n,e[132]=Ye):Ye=e[132];let at;e[133]!==Ye?(at=s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:Ye})}),e[133]=Ye,e[134]=at):at=e[134];let st;e[135]!==Fe||e[136]!==at?(st=s.jsxs(dt,{children:[Fe,at]}),e[135]=Fe,e[136]=at,e[137]=st):st=e[137];let ct;e[138]!==n?(ct=n("sessions.sidebar.header.actions.sortProjects"),e[138]=n,e[139]=ct):ct=e[139];let bt;e[140]!==ct?(bt=s.jsx(Pa,{children:ct}),e[140]=ct,e[141]=bt):bt=e[141];let rt;e[142]!==P||e[143]!==D||e[144]!==n?(rt=[["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(Rt=>{const[$t,Wt]=Rt;return s.jsxs(Gt,{onClick:()=>D($t),className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Wt)}),P===$t?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null]},$t)}),e[142]=P,e[143]=D,e[144]=n,e[145]=rt):rt=e[145];let gt;e[146]===Symbol.for("react.memo_cache_sentinel")?(gt=s.jsx(gn,{}),e[146]=gt):gt=e[146];let it;e[147]!==n?(it=n("sessions.sidebar.header.grouping.label"),e[147]=n,e[148]=it):it=e[148];let Et;e[149]!==it?(Et=s.jsx(Pa,{children:it}),e[149]=it,e[150]=Et):Et=e[150];let Ft;e[151]!==F||e[152]!==B||e[153]!==n?(Ft=[["by-worktree","sessions.sidebar.header.grouping.byWorktree"],["flat","sessions.sidebar.header.grouping.flat"]].map(Rt=>{const[$t,Wt]=Rt;return s.jsxs(Gt,{onClick:()=>B($t),className:"flex items-center justify-between",children:[s.jsx("span",{children:n(Wt)}),F===$t?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null]},$t)}),e[151]=F,e[152]=B,e[153]=n,e[154]=Ft):Ft=e[154];let Dt;e[155]===Symbol.for("react.memo_cache_sentinel")?(Dt=s.jsx(gn,{}),e[155]=Dt):Dt=e[155];let Bt;e[156]!==o||e[157]!==k||e[158]!==n||e[159]!==C?(Bt=o?s.jsxs(Gt,{onClick:C,className:"flex items-center justify-between",children:[s.jsx("span",{children:n("sessions.sidebar.header.displayMode.showRecent")}),k?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null]}):null,e[156]=o,e[157]=k,e[158]=n,e[159]=C,e[160]=Bt):Bt=e[160];let qe;e[161]!==n?(qe=n("sessions.sidebar.header.displayMode.stickyHeaders"),e[161]=n,e[162]=qe):qe=e[162];let zt;e[163]!==qe?(zt=s.jsx("span",{children:qe}),e[163]=qe,e[164]=zt):zt=e[164];let Nt;e[165]!==E?(Nt=E?s.jsx(R,{name:"check",className:"h-4 w-4 text-primary"}):null,e[165]=E,e[166]=Nt):Nt=e[166];let xt;e[167]!==zt||e[168]!==Nt||e[169]!==_?(xt=s.jsxs(Gt,{onClick:_,className:"flex items-center justify-between",children:[zt,Nt]}),e[167]=zt,e[168]=Nt,e[169]=_,e[170]=xt):xt=e[170];let Pt;e[171]===Symbol.for("react.memo_cache_sentinel")?(Pt=s.jsx(gn,{}),e[171]=Pt):Pt=e[171];let Mt;e[172]===Symbol.for("react.memo_cache_sentinel")?(Mt=s.jsx(R,{name:"contract-up-down",className:"h-4 w-4"}),e[172]=Mt):Mt=e[172];let Xt;e[173]!==n?(Xt=n("sessions.sidebar.header.displayMode.collapseAll"),e[173]=n,e[174]=Xt):Xt=e[174];let Qe;e[175]!==Xt?(Qe=s.jsx("span",{children:Xt}),e[175]=Xt,e[176]=Qe):Qe=e[176];let ht;e[177]!==w||e[178]!==Qe?(ht=s.jsxs(Gt,{onClick:w,className:"flex items-center gap-2",children:[Mt,Qe]}),e[177]=w,e[178]=Qe,e[179]=ht):ht=e[179];let Ze;e[180]===Symbol.for("react.memo_cache_sentinel")?(Ze=s.jsx(R,{name:"expand-up-down",className:"h-4 w-4"}),e[180]=Ze):Ze=e[180];let $e;e[181]!==n?($e=n("sessions.sidebar.header.displayMode.expandAll"),e[181]=n,e[182]=$e):$e=e[182];let St;e[183]!==$e?(St=s.jsx("span",{children:$e}),e[183]=$e,e[184]=St):St=e[184];let Lt;e[185]!==j||e[186]!==St?(Lt=s.jsxs(Gt,{onClick:j,className:"flex items-center gap-2",children:[Ze,St]}),e[185]=j,e[186]=St,e[187]=Lt):Lt=e[187];let Ot;e[188]!==bt||e[189]!==rt||e[190]!==Et||e[191]!==Ft||e[192]!==Bt||e[193]!==xt||e[194]!==ht||e[195]!==Lt?(Ot=s.jsxs(yn,{align:"end",className:"min-w-[180px]",children:[bt,rt,gt,Et,Ft,Dt,Bt,xt,Pt,ht,Lt]}),e[188]=bt,e[189]=rt,e[190]=Et,e[191]=Ft,e[192]=Bt,e[193]=xt,e[194]=ht,e[195]=Lt,e[196]=Ot):Ot=e[196];let ss;e[197]!==st||e[198]!==Ot?(ss=s.jsxs(vn,{children:[st,Ot]}),e[197]=st,e[198]=Ot,e[199]=ss):ss=e[199];let _t;e[200]!==oe||e[201]!==je||e[202]!==ss?(_t=s.jsxs("div",{className:"flex items-center gap-1.5",children:[oe,je,ss]}),e[200]=oe,e[201]=je,e[202]=ss,e[203]=_t):_t=e[203];let Ct;e[204]!==Re||e[205]!==_t?(Ct=s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2",children:[Re,_t]}),e[204]=Re,e[205]=_t,e[206]=Ct):Ct=e[206];let os;e[207]!==m||e[208]!==g||e[209]!==x||e[210]!==S||e[211]!==v||e[212]!==b||e[213]!==p||e[214]!==n?(os=g?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:[m?s.jsx("span",{children:x===1?n("sessions.sidebar.header.search.matchCountSingle",{count:x}):n("sessions.sidebar.header.search.matchCountPlural",{count:x})}):s.jsx("span",{}),s.jsx("span",{children:n("sessions.sidebar.header.search.escapeHint")})]}),s.jsxs("div",{className:"relative",children:[s.jsx(R,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:S,value:v,onChange:Rt=>p(Rt.target.value),placeholder:n("sessions.sidebar.header.search.placeholder"),className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-8 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50",onKeyDown:Rt=>{Rt.key==="Escape"&&(Rt.stopPropagation(),m?p(""):b(!1))}}),v.length>0?s.jsx("button",{type:"button",onClick:()=>p(""),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 hover:bg-interactive-hover/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":n("sessions.sidebar.header.search.clear"),children:s.jsx(R,{name:"close",className:"h-3.5 w-3.5"})}):null]})]}):null,e[207]=m,e[208]=g,e[209]=x,e[210]=S,e[211]=v,e[212]=b,e[213]=p,e[214]=n,e[215]=os):os=e[215];let hs;return e[216]!==Ct||e[217]!==os?(hs=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:[Ct,os]})}),e[216]=Ct,e[217]=os,e[218]=hs):hs=e[218],hs}function B0(t){return!t}function L0(t){return t.toggleStickyZoneHeaders}function _0(t){return t.stickyZoneHeaders}function $0(t){return t.setSessionGroupingMode}function z0(t){return t.sessionGroupingMode}function U0(t){return t.setProjectSortOrder}function W0(t){return t.projectSortOrder}function V0(t){return t.toggleRecentSection}function H0(t){return t.showRecentSection}function K0(t){const e=tt.c(8),{t:n}=mt(),r=t.onNewSession;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(R,{name:"chat-new",className:"h-4 w-4 flex-shrink-0"}),e[0]=o):o=e[0];let i;e[1]!==n?(i=n("sessions.sidebar.header.actions.newSession"),e[1]=n,e[2]=i):i=e[2];let c;e[3]!==i?(c=s.jsx("span",{className:"truncate",children:i}),e[3]=i,e[4]=c):c=e[4];let a;return e[5]!==t.onNewSession||e[6]!==c?(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-primary/50",children:[o,c]})}),e[5]=t.onNewSession,e[6]=c,e[7]=a):a=e[7],a}const fd=7;function G0(t){const{sections:e,renderSessionNode:n,editingId:r,openSidebarMenuKey:o,variant:i="section",initialVisibleCount:c=fd,batchSize:a=fd}=t,{t:d}=mt(),u=As(j=>j.stickyZoneHeaders),[h,f]=l.useState(new Set),[g,b]=l.useState(new Map),S=i==="flat",v=l.useCallback(j=>{b(N=>{if(!N.has(j))return N;const A=new Map(N);return A.delete(j),A})},[]),p=l.useCallback(j=>{v(j),f(N=>{const A=new Set(N);return A.has(j)?A.delete(j):A.add(j),A})},[v]),m=l.useCallback((j,N,A)=>{b(k=>{const C=Math.min(A,N+a),P=new Map(k);return P.set(j,C),P})},[a]),x=l.useCallback(j=>{const N=new Set;Xa(j,r,N);const A=To(j,o,"recent",!1),k=new WeakMap,C=D=>{k.set(D,Ei(D)),D.children.forEach(C)};j.forEach(C);const P=D=>({subtreeContainsEditing:N,menuOpenSessionId:A,nodeStructureKey:k.get(D)??"",childRenderExtrasFor:P});return D=>({subtreeContainsEditing:N,menuOpenSessionId:A,nodeStructureKey:k.get(D)??"",childRenderExtrasFor:P})},[r,o]),w=e.filter(j=>j.items.length>0);return w.length===0?null:s.jsx("div",{className:ye(S?"space-y-0.5 pb-2":"space-y-2 pb-2"),children:w.map(j=>{const N=h.has(j.key),A=Math.max(c,g.get(j.key)??c),k=j.items.slice(0,A),C=j.items.length-k.length,P=!S&&j.items.length>c&&C===0,D=x(k.map(B=>B.node)),F=B=>n(B.node,0,B.groupDirectory,B.projectId,!1,B.secondaryMeta,"recent",D(B.node));return S?s.jsxs("div",{className:"space-y-0.5",children:[k.map(F),C>0?s.jsx("button",{type:"button",onClick:()=>m(j.key,k.length,j.items.length),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:d("sessions.sidebar.group.showMore")}):null]},j.key):s.jsxs("div",{className:"relative space-y-1",children:[s.jsx("div",{className:ye("-ml-2.5 -mr-2",u&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":u?"true":void 0,children:s.jsxs("button",{type:"button",onClick:()=>p(j.key),className:"group flex w-full items-center gap-1.5 py-1 pl-4 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-expanded":!N,children:[s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center",children:[s.jsx(R,{name:"history",className:ye("h-3.5 w-3.5 text-muted-foreground/80","group-hover:hidden")}),s.jsx("span",{className:"hidden h-3.5 w-3.5 items-center justify-center text-muted-foreground group-hover:inline-flex",children:N?s.jsx(R,{name:"arrow-right-s",className:"h-3.5 w-3.5"}):s.jsx(R,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})]}),s.jsx("span",{className:"text-[14px] font-semibold lowercase text-foreground",children:j.title})]})}),N?null:s.jsxs("div",{className:ye("space-y-0.5"),children:[k.map(F),C>0?s.jsx("button",{type:"button",onClick:()=>m(j.key,k.length,j.items.length),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:d("sessions.sidebar.group.showMore")}):null,P?s.jsx("button",{type:"button",onClick:()=>v(j.key),className:"mt-0.5 flex items-center justify-start rounded-md pl-[26px] pr-1.5 py-0.5 text-left text-xs text-muted-foreground/70 leading-tight hover:text-foreground hover:underline",children:d("sessions.sidebar.group.showFewer")}):null]})]},j.key)})})}const wa="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-primary/50";function q0(t){const e=tt.c(13),{onOpenSettings:n,onOpenShortcuts:r,onOpenAbout:o,onOpenUpdate:i,showRuntimeButtons:c,showUpdateButton:a}=t,d=c===void 0?!0:c,u=a===void 0?!0:a,{t:h}=mt();if(!d&&!u)return null;let f;e[0]!==o||e[1]!==n||e[2]!==r||e[3]!==d||e[4]!==h?(f=d?s.jsxs(s.Fragment,{children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,className:wa,"aria-label":h("sessions.sidebar.footer.actions.settings"),children:s.jsx(R,{name:"settings-3",className:"h-4.5 w-4.5"})})}),s.jsx(ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.settings")})})]}),s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:r,className:wa,"aria-label":h("sessions.sidebar.footer.actions.shortcuts"),children:s.jsx(R,{name:"command",className:"h-4.5 w-4.5"})})}),s.jsx(ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.shortcuts")})})]}),s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:o,className:wa,"aria-label":h("sessions.sidebar.footer.actions.aboutOpenChamber"),children:s.jsx(R,{name:"information",className:"h-4.5 w-4.5"})})}),s.jsx(ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:h("sessions.sidebar.footer.actions.aboutOpenChamber")})})]})]}):null,e[0]=o,e[1]=n,e[2]=r,e[3]=d,e[4]=h,e[5]=f):f=e[5];let g;e[6]!==i||e[7]!==u||e[8]!==h?(g=u?s.jsx(nt,{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:i,children:h("sessions.sidebar.footer.actions.update")}):null,e[6]=i,e[7]=u,e[8]=h,e[9]=g):g=e[9];let b;return e[10]!==f||e[11]!==g?(b=s.jsxs("div",{className:"flex shrink-0 items-center justify-start gap-1 px-2.5 py-2",children:[f,g]}),e[10]=f,e[11]=g,e[12]=b):b=e[12],b}const zf=t=>{const e=tt.c(22),{id:n,projectLabel:r,projectIcon:o,projectColor:i,projectIconImage:c,projectIconBackground:a,isCollapsed:d,alwaysShowActions:u}=t,h=u===void 0?!1:u,{currentTheme:f}=_r(),g=o?fl[o]:null,b=i?ml[i]??null:null,S=d!==void 0,v=S?h?"hidden":"group-hover/project:hidden group-focus-within/project:hidden":void 0;let p;e[0]!==h||e[1]!==S||e[2]!==d?(p=S?s.jsx("span",{className:ye("h-3.5 w-3.5 items-center justify-center text-muted-foreground",h?"inline-flex":"hidden group-hover/project:inline-flex group-focus-within/project:inline-flex"),children:s.jsx(R,{name:d?"arrow-right-s":"arrow-down-s",className:"h-3.5 w-3.5"})}):null,e[0]=h,e[1]=S,e[2]=d,e[3]=p):p=e[3];let m;e[4]!==h||e[5]!==f||e[6]!==S||e[7]!==b||e[8]!==v||e[9]!==n||e[10]!==a||e[11]!==c||e[12]!==g?(m=c?s.jsx("span",{className:ye("h-3.5 w-3.5 items-center justify-center overflow-hidden rounded-[3px]",S&&h?"hidden":"inline-flex",v),style:a?{backgroundColor:a}:void 0,children:s.jsx(hl,{project:{id:n,iconImage:c},options:{themeVariant:f.metadata.variant,iconColor:f.colors.surface.foreground},className:"h-full w-full object-contain",fallback:g?s.jsx(R,{name:g,className:"h-3.5 w-3.5",style:b?{color:b}:void 0}):s.jsx(R,{name:"folder",className:"h-3.5 w-3.5 text-muted-foreground/80",style:b?{color:b}:void 0})})}):g?s.jsx(R,{name:g,className:ye("h-3.5 w-3.5",v),style:b?{color:b}:void 0}):s.jsx(R,{name:"folder",className:ye("h-3.5 w-3.5 text-muted-foreground/80",v),style:b?{color:b}:void 0}),e[4]=h,e[5]=f,e[6]=S,e[7]=b,e[8]=v,e[9]=n,e[10]=a,e[11]=c,e[12]=g,e[13]=m):m=e[13];let x;e[14]!==p||e[15]!==m?(x=s.jsxs("span",{className:"inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",children:[p,m]}),e[14]=p,e[15]=m,e[16]=x):x=e[16];let w;e[17]!==r?(w=s.jsx("span",{className:"truncate text-[14px] font-semibold lowercase text-foreground",children:r}),e[17]=r,e[18]=w):w=e[18];let j;return e[19]!==x||e[20]!==w?(j=s.jsxs(s.Fragment,{children:[x,w]}),e[19]=x,e[20]=w,e[21]=j):j=e[21],j},Y0=t=>{const e=tt.c(59),{id:n,disabled:r,projectLabel:o,projectDescription:i,projectIcon:c,projectColor:a,projectIconImage:d,projectIconBackground:u,isCollapsed:h,isRepo:f,isDesktopShell:g,hideDirectoryControls:b,alwaysShowActions:S,onToggle:v,onNewSession:p,onNewWorktreeSession:m,onManageWorktrees:x,onRenameStart:w,onClose:j,sentinelRef:N,children:A,showCreateButtons:k,hideHeader:C,openSidebarMenuKey:P,setOpenSidebarMenuKey:D,statusIndicator:F}=t,B=r===void 0?!1:r,E=k===void 0?!0:k,_=C===void 0?!1:C,W=F===void 0?null:F,{t:V}=mt(),K=As(J0);let y;e[0]!==B||e[1]!==n?(y={id:n,disabled:B},e[0]=B,e[1]=n,e[2]=y):y=e[2];const{attributes:I,listeners:$,setNodeRef:z,transform:G,transition:J,isDragging:Z}=bl(y),re=l.useRef(!1),ee=`project:${n}`,he=P===ee,[be,Y]=l.useState(!1);let we;e[3]!==ee||e[4]!==D?(we=de=>{de&&Y(!1),D(de?ee:null)},e[3]=ee,e[4]=D,e[5]=we):we=e[5];const me=we;let Q;e[6]!==b||e[7]!==f||e[8]!==j||e[9]!==x||e[10]!==p||e[11]!==w||e[12]!==E||e[13]!==V?(Q=de=>s.jsxs(s.Fragment,{children:[E&&!f&&!b&&p&&s.jsxs(de,{onClick:p,children:[s.jsx(R,{name:"add",className:"mr-1.5 h-4 w-4"}),V("sessions.sidebar.project.actions.newSession")]}),f&&!b&&x&&s.jsxs(de,{onClick:x,children:[s.jsx(R,{name:"node-tree",className:"mr-1.5 h-4 w-4"}),V("sessions.sidebar.project.actions.manageWorktrees")]}),s.jsxs(de,{onClick:w,children:[s.jsx(R,{name:"pencil-ai",className:"mr-1.5 h-4 w-4"}),V("sessions.sidebar.project.actions.edit")]}),s.jsxs(de,{onClick:j,className:"text-destructive focus:text-destructive",children:[s.jsx(R,{name:"close",className:"mr-1.5 h-4 w-4"}),V("sessions.sidebar.project.actions.closeProject")]})]}),e[6]=b,e[7]=f,e[8]=j,e[9]=x,e[10]=p,e[11]=w,e[12]=E,e[13]=V,e[14]=Q):Q=e[14];const pe=Q,ve=Z0,Te=ej,ke=tj;let Ie;e[15]===Symbol.for("react.memo_cache_sentinel")?(Ie=de=>{(de.button===2||de.button===0&&de.ctrlKey)&&(re.current=!0)},e[15]=Ie):Ie=e[15];const Ne=Ie;let Ae;e[16]!==v?(Ae=de=>{if(de.currentTarget.blur(),re.current){re.current=!1;return}v()},e[16]=v,e[17]=Ae):Ae=e[17];const Se=Ae;let Oe;e[18]!==G?(Oe=yl.Transform.toString(G),e[18]=G,e[19]=Oe):Oe=e[19];let ne;e[20]!==Oe||e[21]!==J?(ne={transform:Oe,transition:J},e[20]=Oe,e[21]=J,e[22]=ne):ne=e[22];const ce=Z&&"opacity-30";let Re;e[23]!==ce?(Re=ye("relative",ce),e[23]=ce,e[24]=Re):Re=e[24];let te;e[25]!==S||e[26]!==I||e[27]!==me||e[28]!==Se||e[29]!==b||e[30]!==_||e[31]!==n||e[32]!==h||e[33]!==be||e[34]!==g||e[35]!==he||e[36]!==f||e[37]!==$||e[38]!==p||e[39]!==m||e[40]!==a||e[41]!==i||e[42]!==c||e[43]!==u||e[44]!==d||e[45]!==o||e[46]!==pe||e[47]!==N||e[48]!==E||e[49]!==W||e[50]!==K||e[51]!==V?(te=_?null:s.jsxs(s.Fragment,{children:[g&&s.jsx("div",{ref:N,"data-project-id":n,className:"absolute top-0 h-px w-full pointer-events-none","aria-hidden":"true"}),s.jsxs(Uu,{open:be,onOpenChange:Y,children:[s.jsx(zu,{render:s.jsx("div",{className:ye("-ml-2.5 -mr-2 text-left group/project select-none",K&&"sticky top-0 z-20 bg-sidebar"),"data-sidebar-sticky-header":K?"true":void 0,onContextMenu:de=>{b||(de.preventDefault(),Y(!0))}}),children:s.jsxs("div",{className:"relative flex items-center gap-1 py-1 pl-4 pr-3.5",...I,children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsxs("button",{type:"button",onMouseDown:Ne,onClick:Se,...$,className:ye("flex-1 min-w-0 flex items-center gap-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 rounded-md cursor-grab active:cursor-grabbing transition-[padding]",f&&!b?S?"pr-20":"pr-7 group-hover/project:pr-20 group-focus-within/project:pr-20":S?"pr-14":"pr-7 group-hover/project:pr-14 group-focus-within/project:pr-14"),children:[s.jsx(zf,{id:n,projectLabel:o,projectIcon:c,projectColor:a,projectIconImage:d,projectIconBackground:u,isCollapsed:h,alwaysShowActions:S}),W?s.jsx("span",{className:"ml-1 inline-flex flex-shrink-0 items-center",children:W}):null]})}),s.jsx(ft,{side:"right",sideOffset:8,children:i})]}),s.jsxs("div",{className:ye("absolute top-1/2 z-10 flex -translate-y-1/2 items-center gap-1",E?"right-7":"right-0.5"),children:[E&&f&&!b&&m?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:de=>{de.stopPropagation(),m()},className:ye("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 hover:text-foreground transition-opacity",S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":V("sessions.sidebar.project.actions.newWorktree"),children:s.jsx(R,{name:"node-tree",className:"h-4 w-4"})})}),s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:V("sessions.sidebar.project.actions.newWorktreeEllipsis")})})]}):null,b?null:s.jsxs(vn,{open:he,onOpenChange:me,children:[s.jsx(bn,{asChild:!0,children:s.jsx("button",{type:"button",className:ye("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground transition-opacity focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 hover:text-foreground",he?"opacity-100 pointer-events-auto":S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":V("sessions.sidebar.project.actions.projectMenu"),onPointerDown:Te,onMouseDown:ke,onClick:ve,children:s.jsx(R,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(yn,{align:"end",className:"min-w-[180px]",children:pe(Gt)})]})]}),E&&p?s.jsx("div",{className:"absolute right-0.5 top-1/2 z-10 -translate-y-1/2",children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:de=>{de.stopPropagation(),p()},className:ye("inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",S?"opacity-100":"opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto group-focus-within/project:opacity-100 group-focus-within/project:pointer-events-auto"),"aria-label":V(f?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession"),children:s.jsx(R,{name:"add",className:"h-4 w-4"})})}),s.jsx(ft,{side:"bottom",sideOffset:4,children:s.jsx("p",{children:V(f?"sessions.sidebar.project.actions.newDraftSession":"sessions.sidebar.project.actions.newSession")})})]})}):null]})}),s.jsx(_u,{className:"min-w-[180px]",children:pe($u)})]})]}),e[25]=S,e[26]=I,e[27]=me,e[28]=Se,e[29]=b,e[30]=_,e[31]=n,e[32]=h,e[33]=be,e[34]=g,e[35]=he,e[36]=f,e[37]=$,e[38]=p,e[39]=m,e[40]=a,e[41]=i,e[42]=c,e[43]=u,e[44]=d,e[45]=o,e[46]=pe,e[47]=N,e[48]=E,e[49]=W,e[50]=K,e[51]=V,e[52]=te):te=e[52];let ae;return e[53]!==A||e[54]!==z||e[55]!==ne||e[56]!==Re||e[57]!==te?(ae=s.jsxs("div",{ref:z,style:ne,className:Re,children:[te,A]}),e[53]=A,e[54]=z,e[55]=ne,e[56]=Re,e[57]=te,e[58]=ae):ae=e[58],ae},Q0=t=>{const e=tt.c(21),{id:n,disabled:r,children:o}=t,i=r===void 0?!1:r;let c;e[0]!==i||e[1]!==n?(c={id:n,disabled:i},e[0]=i,e[1]=n,e[2]=c):c=e[2];const{listeners:a,setNodeRef:d,setActivatorNodeRef:u,transform:h,transition:f,isDragging:g}=bl(c);let b;e[3]!==a||e[4]!==u?(b={listeners:a,setActivatorNodeRef:u},e[3]=a,e[4]=u,e[5]=b):b=e[5];const S=b;let v;e[6]!==h?(v=yl.Transform.toString(h),e[6]=h,e[7]=v):v=e[7];let p;e[8]!==v||e[9]!==f?(p={transform:v,transition:f},e[8]=v,e[9]=f,e[10]=p):p=e[10];const m=g&&"opacity-50";let x;e[11]!==m?(x=ye("space-y-0.5 rounded-md",m),e[11]=m,e[12]=x):x=e[12];let w;e[13]!==o||e[14]!==S?(w=typeof o=="function"?o(S):o,e[13]=o,e[14]=S,e[15]=w):w=e[15];let j;return e[16]!==d||e[17]!==p||e[18]!==x||e[19]!==w?(j=s.jsx("div",{ref:d,style:p,className:x,children:w}),e[16]=d,e[17]=p,e[18]=x,e[19]=w,e[20]=j):j=e[20],j},X0=l.memo(Q0);function J0(t){return t.stickyZoneHeaders}function Z0(t){t.stopPropagation()}function ej(t){t.stopPropagation()}function tj(t){t.stopPropagation()}const sj=48,nj=32,rj=24,md=(t,e)=>pl(t.label?.trim()||hr(t.normalizedPath,e)||t.normalizedPath);function oj(t){In("ui.sidebar_projects_list.render");const{t:e}=mt(),n=t.isDesktopShellRuntime&&t.stickyZoneHeaders,r=wi(Yr(Ba,{activationConstraint:{distance:8}}),Yr(nx,{coordinateGetter:rx})),o=wi(Yr(Ba,{activationConstraint:{distance:8}})),i=l.useRef(new Map),c=l.useRef(t.getOrderedGroups);c.current!==t.getOrderedGroups&&(c.current=t.getOrderedGroups,i.current.clear());const a=(p,m)=>{const x=i.current,w=x.get(p);if(w&&w.groups===m)return w.ordered;const j=t.getOrderedGroups(p,m);if(x.set(p,{groups:m,ordered:j}),x.size>256){const N=x.keys().next().value;N!==void 0&&x.delete(N)}return j},d=l.useRef(null),u=l.useRef(0),h=l.useCallback(p=>{const x=p.scrollTop>1?Math.min(nj+p.scrollTop,sj):0;u.current=x,p.style.setProperty("--scroll-shadow-top-size",`${x}px`),p.style.setProperty("--scroll-shadow-top-clear-size",`${Math.min(Math.max(x-8,0),rj)}px`)},[]),f=l.useCallback(p=>{p.target.closest("[data-overlay-scrollbar-thumb], [data-sidebar-sticky-header]")||p.clientY-p.currentTarget.getBoundingClientRect().top>=u.current||(p.preventDefault(),p.stopPropagation())},[]),g=t.projectSections.length>0&&t.sectionsForRender.length>0;l.useLayoutEffect(()=>{n&&g&&d.current&&h(d.current)},[n,g,h]);let b=null;for(const p of t.projectSections)t.stuckProjectHeaders.has(p.project.id)&&(b=p.project);const S=b??(t.hasSharedSessions?null:t.sectionsForRender[0]?.project??null),v=S?md(S,t.homeDirectory):null;return t.sharedSessionsOnly?s.jsxs(Yn,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:ye("space-y-1 pb-1 pr-2",(t.mobileVariant,"")),children:[t.topContent,t.hasSharedSessions?null:t.hasSessionSearchQuery?t.searchEmptyState:t.emptyState]}):t.projectSections.length===0?s.jsxs(Yn,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:ye("space-y-1 pb-1 pl-2.5 pr-2",(t.mobileVariant,"")),children:[t.topContent,t.emptyState]}):t.sectionsForRender.length===0?s.jsx(Yn,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:ye("space-y-1 pb-1 pl-2.5 pr-2",(t.mobileVariant,"")),children:t.searchEmptyState}):s.jsxs("div",{className:"oc-sticky-fade-root relative flex min-h-0 flex-1",onPointerDownCapture:n?f:void 0,onClickCapture:n?f:void 0,onContextMenuCapture:n?f:void 0,children:[s.jsxs(Yn,{ref:d,useScrollShadow:!0,hideTopScrollShadow:!n,scrollShadowSize:96,outerClassName:"flex-1 min-h-0",className:ye("oc-sidebar-scroller oc-sticky-fade-scroller space-y-1.5 pb-1 pl-2.5 pr-2 [overflow-anchor:none]",(t.mobileVariant,"")),style:n?{"--scroll-shadow-top-size":"0px"}:void 0,onScroll:n?p=>h(p.currentTarget):void 0,children:[t.topContent,t.showOnlyMainWorkspace?s.jsx("div",{className:"space-y-[0.6rem] py-1",children:(()=>{const p=t.sectionsForRender.find(j=>j.project.id===t.activeProjectId)??t.sectionsForRender[0];if(!p)return t.hasSessionSearchQuery?t.searchEmptyState:t.emptyState;const m=p.groups.find(j=>j.isMain&&j.sessions.length>0)??p.groups.find(j=>j.sessions.length>0)??p.groups.find(j=>j.isMain)??p.groups[0];if(!m)return s.jsx("div",{className:"py-1 text-left typography-micro text-muted-foreground",children:e("sessions.sidebar.empty.noSessions.title")});const x=p.groups.find(j=>j.isArchivedBucket);return[m,...x&&x.id!==m.id?[x]:[]].map(j=>{const N=`${p.project.id}:${j.id}`,A=j.id===m.id;return s.jsx(l.Fragment,{children:t.renderGroupSessions(j,N,p.project.id,A,null,!0,d)},N)})})()}):s.jsxs(Si,{sensors:r,collisionDetection:ji,onDragEnd:p=>{if(t.isInlineEditing||t.projectSortOrder!=="manual")return;const{active:m,over:x}=p;if(!x||m.id===x.id)return;const w=t.sectionsForRender.findIndex(N=>N.project.id===m.id),j=t.sectionsForRender.findIndex(N=>N.project.id===x.id);w===-1||j===-1||w===j||t.reorderProjects(w,j)},children:[s.jsx(_a,{items:t.sectionsForRender.map(p=>p.project.id),strategy:$a,children:t.sectionsForRender.map(p=>{const m=p.project,x=m.id,w=md(m,t.homeDirectory),j=gi(m.normalizedPath,t.homeDirectory),N=t.collapsedProjects.has(x),A=t.projectRepoStatus.get(x);return s.jsx(Y0,{id:x,disabled:t.projectSortOrder!=="manual",projectLabel:w,projectDescription:j,projectIcon:m.icon,projectColor:m.color,projectIconImage:m.iconImage,projectIconBackground:m.iconBackground,isCollapsed:N,isRepo:!!A,isDesktopShell:t.isDesktopShellRuntime,hideDirectoryControls:t.hideDirectoryControls,mobileVariant:t.mobileVariant,alwaysShowActions:t.alwaysShowActions,statusIndicator:N?t.renderProjectStatusIndicator?.(x,p.groups):null,onToggle:()=>t.toggleProject(x),onNewSession:()=>{x!==t.activeProjectId&&t.setActiveProjectIdOnly(x),t.setActiveMainTab("chat"),t.mobileVariant&&t.setSessionSwitcherOpen(!1),t.openNewSessionDraft({selectedProjectId:x,directoryOverride:m.normalizedPath})},onNewWorktreeSession:()=>{x!==t.activeProjectId&&t.setActiveProjectIdOnly(x),t.setActiveMainTab("chat"),t.openNewWorktreeDialog()},onManageWorktrees:()=>t.openWorktreesPage(x),onRenameStart:()=>t.openProjectEditDialog(x),onClose:()=>t.removeProject(x),sentinelRef:k=>{t.projectHeaderSentinelRefs.current.set(x,k)},showCreateButtons:!0,openSidebarMenuKey:t.openSidebarMenuKey,setOpenSidebarMenuKey:t.setOpenSidebarMenuKey,children:N?null:s.jsx("div",{className:"space-y-0 pt-0.5 pb-0.5",children:(()=>{const k=a(x,p.groups),C=k.find(D=>D.isMain)??null,P=C?k.filter(D=>D.id!==C.id):k;return s.jsxs(Si,{sensors:o,collisionDetection:ji,onDragEnd:D=>{if(t.isInlineEditing)return;const{active:F,over:B}=D;if(!B||F.id===B.id)return;const E=P.findIndex(K=>K.id===F.id),_=P.findIndex(K=>K.id===B.id);if(E===-1||_===-1||E===_)return;const W=Qu(P,E,_).map(K=>K.id),V=C?[C.id,...W]:W;t.setGroupOrderByProject(K=>{const y=new Map(K);return y.set(x,V),y})},children:[C?t.renderGroupSessions(C,`${x}:${C.id}`,x,!0,null,void 0,d):null,s.jsx(_a,{items:P.map(D=>D.id),strategy:$a,children:P.map(D=>{const F=`${x}:${D.id}`;return s.jsx(X0,{id:D.id,disabled:t.isInlineEditing,children:B=>t.renderGroupSessions(D,F,x,!1,B,void 0,d)},D.id)})}),s.jsx(La,{dropAnimation:null})]})})()})},x)})}),s.jsx(La,{dropAnimation:null})]})]}),n&&(S||t.hasSharedSessions)?s.jsx("div",{className:"oc-sticky-fade-overlay pointer-events-none absolute inset-x-0 top-0 z-30 flex items-center gap-1.5 py-1 pl-4 pr-5","aria-hidden":"true",children:S&&v?s.jsx(zf,{id:S.id,projectLabel:v,projectIcon:S.icon,projectColor:S.color,projectIconImage:S.iconImage,projectIconBackground:S.iconBackground}):s.jsxs(s.Fragment,{children:[s.jsx(R,{name:"history",className:"h-3.5 w-3.5 flex-shrink-0 text-muted-foreground/80"}),s.jsx("span",{className:"truncate text-[14px] font-semibold lowercase text-foreground",children:e("sessions.sidebar.activity.recentTitle")})]})}):null]})}const ij=l.memo(oj),aj=(t,e)=>{if(!e)return Array.from(t);const n=[],r=new Set;for(const o of t){r.has(o)||(r.add(o),n.push(o));const i=e.get(o);if(i)for(const c of i)r.has(c)||(r.add(c),n.push(c))}return n},Ns=xr()((t,e)=>({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null,enable:()=>{e().enabled||t({enabled:!0})},disable:()=>{t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null})},toggleMode:()=>{e().enabled?t({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null}):t({enabled:!0})},toggleSelected:(n,r,o)=>{const i=e(),c=new Set(i.selectedIds);let a=i.scopeKey,d=i.anchorId;r!==null&&i.scopeKey!==null&&r!==i.scopeKey?(c.clear(),a=r,d=null):a===null&&r!==null&&(a=r);const h=o&&o.length>0?[n,...o]:[n];if(c.has(n)){for(const g of h)c.delete(g);d===n&&(d=null)}else{for(const g of h)c.add(g);d=n}c.size===0?t({selectedIds:c,scopeKey:null,anchorId:null}):t({selectedIds:c,scopeKey:a,anchorId:d})},setRange:(n,r,o,i,c)=>{const a=e();if(o.length===0)return;const d=n&&o.includes(n)?n:o[0],u=o.indexOf(d),h=o.indexOf(r);if(u<0||h<0)return;const[f,g]=u<=h?[u,h]:[h,u],b=o.slice(f,g+1),S=aj(b,c),p=i!==null&&a.scopeKey!==null&&i!==a.scopeKey?new Set:new Set(a.selectedIds);for(const m of S)p.add(m);t({selectedIds:p,scopeKey:i??a.scopeKey,anchorId:d})},replaceAll:(n,r)=>{if(n.length===0){t({selectedIds:new Set,scopeKey:null,anchorId:null});return}t({selectedIds:new Set(n),scopeKey:r,anchorId:n[0]??null})},clear:()=>{t({selectedIds:new Set,scopeKey:null,anchorId:null})},removeMany:n=>{const r=e();if(r.selectedIds.size===0||n.length===0)return;const o=new Set(r.selectedIds);for(const i of n)o.delete(i);o.size!==r.selectedIds.size&&(o.size===0?t({selectedIds:o,scopeKey:null,anchorId:null}):t({selectedIds:o}))}}));let Ja=!1;const Za=new Set;let hd=!1;function lj(){for(const t of Za)t()}function El(t){Ja!==t&&(Ja=t,lj())}function cj(t){t.key==="Shift"&&El(!0)}function dj(t){t.key==="Shift"&&El(!1)}function uj(){El(!1)}function fj(){hd||typeof window>"u"||(hd=!0,window.addEventListener("keydown",cj),window.addEventListener("keyup",dj),window.addEventListener("blur",uj))}function mj(t){return fj(),Za.add(t),()=>{Za.delete(t)}}function hj(){return Ja}function pj(){return!1}function gj(){return Ge.useSyncExternalStore(mj,hj,pj)}const xj=/^[a-z0-9](?:[a-z0-9-]{0,48}[a-z0-9])?$/,Uf=/^g[1-9]\d*$/,go=(t,e,n,r,o)=>{if(!xj.test(t)||e!==void 0&&!Uf.test(e)||!n?.trim()||!r?.trim()||n!==n.trim()||r!==r.trim())return null;if(o===void 0)return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!1};if(o==="fusion")return{groupSlug:t,runGroup:e,providerID:n,modelID:r,fusion:!0};if(!/^\d+$/.test(o))return null;const i=Number.parseInt(o,10);return!Number.isSafeInteger(i)||i<=0?null:{groupSlug:t,runGroup:e,providerID:n,modelID:r,index:i,fusion:!1}},ui=t=>{if(!t)return null;const e=t.split("/");if(e.length<3||e.length>5)return null;const[n]=e;if(e.length===3)return go(n,void 0,e[1],e[2],void 0);if(e.length===4){const[,a,d,u]=e;return Uf.test(a)?go(n,a,d,u,void 0):go(n,void 0,a,d,u)}const[,r,o,i,c]=e;return r===""?go(n,void 0,o,i,c):go(n,r,o,i,c)},bj=t=>{const e=[t.groupSlug];return t.runGroup&&e.push(t.runGroup),e.push(t.providerID,t.modelID),t.index!==void 0&&e.push(String(t.index)),e.join("/")},yj=(t,e,n,r)=>{const o=[t];return r&&o.push(r),o.push(e,n,"fusion"),o.join("/")},Wf=t=>{const e=tt.c(36),{value:n,onChange:r,className:o,disabled:i,id:c,portalToBody:a}=t,{t:d}=mt(),u=Vt(vj),h=Vt(wj),f=Vt(Sj);let g;e[0]!==u?(g=u(),e[0]=u,e[1]=g):g=e[1];const b=g;let S;e[2]!==b?(S=b.filter(jj),e[2]=b,e[3]=S):S=e[3];const v=S;let p,m;e[4]!==b.length||e[5]!==h?(p=()=>{b.length===0&&h()},m=[b.length,h],e[4]=b.length,e[5]=h,e[6]=p,e[7]=m):(p=e[6],m=e[7]),l.useEffect(p,m);let x,w;e[8]!==f||e[9]!==i||e[10]!==r||e[11]!==v||e[12]!==n?(x=()=>{if(i)return;const B=n.trim();if(B.length>0&&v.some(W=>W.name===B))return;const E=typeof f=="string"&&f.trim().length>0?f.trim():null;if(E&&v.some(W=>W.name===E)){r(E);return}const _=v[0]?.name;_&&r(_)},w=[f,i,r,v,n],e[8]=f,e[9]=i,e[10]=r,e[11]=v,e[12]=n,e[13]=x,e[14]=w):(x=e[13],w=e[14]),l.useEffect(x,w);const j=n.trim().length>0?n:void 0;let N;e[15]!==o?(N=ye("max-w-full",o),e[15]=o,e[16]=N):N=e[16];let A;e[17]!==d?(A=d("multirun.agentSelector.placeholder"),e[17]=d,e[18]=A):A=e[18];let k;e[19]!==A?(k=s.jsx(Ds,{placeholder:A}),e[19]=A,e[20]=k):k=e[20];let C;e[21]!==c||e[22]!==N||e[23]!==k?(C=s.jsx(_s,{id:c,size:"lg",className:N,children:k}),e[21]=c,e[22]=N,e[23]=k,e[24]=C):C=e[24];let P;e[25]!==v?(P=v.length>0&&s.jsx(Ma,{children:v.map(kj)}),e[25]=v,e[26]=P):P=e[26];let D;e[27]!==a||e[28]!==P?(D=s.jsx($s,{fitContent:!0,portalToBody:a,children:P}),e[27]=a,e[28]=P,e[29]=D):D=e[29];let F;return e[30]!==i||e[31]!==r||e[32]!==j||e[33]!==C||e[34]!==D?(F=s.jsxs(Ls,{value:j,onValueChange:r,disabled:i,children:[C,D]}),e[30]=i,e[31]=r,e[32]=j,e[33]=C,e[34]=D,e[35]=F):F=e[35],F};function vj(t){return t.getVisibleAgents}function wj(t){return t.loadAgents}function Sj(t){return t.currentAgentName}function jj(t){return Du(t.mode)}function kj(t){return s.jsx(rs,{value:t.name,className:"w-auto whitespace-nowrap",children:t.name},t.name)}const Cj="h-7",jo=()=>`${Date.now()}-${Math.random().toString(36).substring(2,9)}`,Nj=t=>{const e=tt.c(12),{model:n,instanceIndex:r,totalSameModel:o,onRemove:i}=t,c=n.displayName||`${n.providerID}/${n.modelID}`,a=o>1?`${c} (${r})`:c;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=ye("flex items-center gap-1.5 px-2 rounded-md bg-interactive-selection/20 border border-border/30",Cj),e[0]=d):d=e[0];let u;e[1]!==n.providerID?(u=s.jsx(pi,{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(R,{name:"close",className:"h-3.5 w-3.5"}),e[5]=f):f=e[5];let g;e[6]!==i?(g=s.jsx("button",{type:"button",onClick:i,className:"text-muted-foreground hover:text-foreground ml-0.5",children:f}),e[6]=i,e[7]=g):g=e[7];let b;return e[8]!==u||e[9]!==h||e[10]!==g?(b=s.jsxs("div",{className:d,children:[u,h,g]}),e[8]=u,e[9]=h,e[10]=g,e[11]=b):b=e[11],b},Vf=t=>{const e=tt.c(120),{selectedModels:n,onAdd:r,onRemove:o,onUpdate:i,minModels:c,addButtonLabel:a,showChips:d,maxModels:u,addButtonClassName:h,dropdownSide:f,dropdownClassName:g,containerClassName:b,triggerIcon:S}=t,v=d===void 0?!0:d,p=f===void 0?"top":f,{t:m}=mt(),x=Vt(Aj),w=Vt(Dj),j=xe(Pj),N=xe(Ej),{favoriteModelsList:A,recentModelsList:k}=Xh(),C=xe(Tj),P=xe(Ij),[D,F]=l.useState(!1),[B,E]=l.useState(""),[_,W]=l.useState(null),V=l.useRef(null),K=l.useRef(null),y=u===1,I=u===void 0||n.length<u||y;let $;if(e[0]!==n){$=new Map;for(const Pe of n){const U=`${Pe.providerID}:${Pe.modelID}`;$.set(U,($.get(U)||0)+1)}e[0]=n,e[1]=$}else $=e[1];const z=$;let G;e[2]!==n?(G=Pe=>n.filter(Be=>Be.providerID===Pe.providerID&&Be.modelID===Pe.modelID).findIndex(Be=>Be.instanceId===Pe.instanceId)+1,e[2]=n,e[3]=G):G=e[3];const J=G;let Z,re;e[4]!==p||e[5]!==D?(Z=()=>{if(!D||!K.current)return;const Pe=K.current.getBoundingClientRect();if(p==="bottom"){const st=(window.visualViewport?.height??document.documentElement.clientHeight??window.innerHeight)-Pe.bottom-16-112;W(Math.max(160,Math.min(320,st)));return}let U=K.current.parentElement;for(;U&&!(U.getAttribute("role")==="dialog"||U.hasAttribute("data-scroll-shadow"));){const Ye=getComputedStyle(U);if(Ye.overflow==="auto"||Ye.overflow==="hidden"||Ye.overflowY==="auto"||Ye.overflowY==="hidden")break;U=U.parentElement}const Be=U?U.getBoundingClientRect().top:0,Fe=Pe.top-Be-16;W(Math.max(150,Math.min(300,Fe)))},re=[p,D],e[4]=p,e[5]=D,e[6]=Z,e[7]=re):(Z=e[6],re=e[7]),l.useEffect(Z,re);let ee,he;e[8]!==I||e[9]!==D?(ee=()=>{!I&&D&&(F(!1),E(""))},he=[I,D],e[8]=I,e[9]=D,e[10]=ee,e[11]=he):(ee=e[10],he=e[11]),l.useEffect(ee,he);let be,Y;e[12]!==D?(be=()=>{if(!D)return;const Pe=U=>{V.current&&!V.current.contains(U.target)&&(F(!1),E(""))};return document.addEventListener("mousedown",Pe),()=>document.removeEventListener("mousedown",Pe)},Y=[D],e[12]=D,e[13]=be,e[14]=Y):(be=e[13],Y=e[14]),l.useEffect(be,Y);let we;e[15]!==y||e[16]!==r||e[17]!==i||e[18]!==n.length?(we=Pe=>{const U={providerID:Pe.providerID,modelID:Pe.modelID,displayName:Pe.model.name||Pe.modelID,instanceId:jo()};y&&n.length>0&&i?i(0,U):r(U),y&&(F(!1),E(""))},e[15]=y,e[16]=r,e[17]=i,e[18]=n.length,e[19]=we):we=e[19];const me=we;let Q;e[20]!==m?(Q=m("multirun.modelMultiSelect.search.placeholder"),e[20]=m,e[21]=Q):Q=e[21];let pe;e[22]!==m?(pe=m("multirun.modelMultiSelect.search.noResults"),e[22]=m,e[23]=pe):pe=e[23];let ve;e[24]!==m?(ve=m("multirun.modelMultiSelect.sections.favorites"),e[24]=m,e[25]=ve):ve=e[25];let Te;e[26]!==m?(Te=m("multirun.modelMultiSelect.sections.recent"),e[26]=m,e[27]=Te):Te=e[27];let ke;e[28]!==m?(ke=m("multirun.modelMultiSelect.keyboard.hint"),e[28]=m,e[29]=ke):ke=e[29];let Ie;e[30]!==m?(Ie=m("settings.agents.modelSelector.actions.favorite"),e[30]=m,e[31]=Ie):Ie=e[31];let Ne;e[32]!==m?(Ne=m("settings.agents.modelSelector.actions.unfavorite"),e[32]=m,e[33]=Ne):Ne=e[33];let Ae;e[34]!==m?(Ae=m("chat.modelControls.capabilities"),e[34]=m,e[35]=Ae):Ae=e[35];let Se;e[36]!==m?(Se=m("chat.modelControls.capability.toolCalling"),e[36]=m,e[37]=Se):Se=e[37];let Oe;e[38]!==m?(Oe=m("chat.modelControls.capability.reasoning"),e[38]=m,e[39]=Oe):Oe=e[39];let ne;e[40]!==m?(ne=m("chat.modelControls.input"),e[40]=m,e[41]=ne):ne=e[41];let ce;e[42]!==m?(ce=m("chat.modelControls.output"),e[42]=m,e[43]=ce):ce=e[43];let Re;e[44]!==m?(Re=m("chat.modelControls.costPerMillion"),e[44]=m,e[45]=Re):Re=e[45];let te;e[46]!==Q||e[47]!==pe||e[48]!==ve||e[49]!==Te||e[50]!==ke||e[51]!==Ie||e[52]!==Ne||e[53]!==Ae||e[54]!==Se||e[55]!==Oe||e[56]!==ne||e[57]!==ce||e[58]!==Re?(te={searchPlaceholder:Q,noResults:pe,favorites:ve,recent:Te,keyboardHint:ke,favorite:Ie,unfavorite:Ne,capabilities:Ae,capabilityToolCalling:Se,capabilityReasoning:Oe,input:ne,output:ce,costPerMillion:Re},e[46]=Q,e[47]=pe,e[48]=ve,e[49]=Te,e[50]=ke,e[51]=Ie,e[52]=Ne,e[53]=Ae,e[54]=Se,e[55]=Oe,e[56]=ne,e[57]=ce,e[58]=Re,e[59]=te):te=e[59];const ae=te;let de;e[60]!==b?(de=ye("relative",b),e[60]=b,e[61]=de):de=e[61];const H=D?"":void 0;let ge;e[62]!==h?(ge=ye(Pu({size:"default"}),"w-fit",h),e[62]=h,e[63]=ge):ge=e[63];const ue=!I;let M;e[64]!==D?(M=()=>{F(!D)},e[64]=D,e[65]=M):M=e[65];let oe;e[66]!==S?(oe=S??s.jsx(R,{name:"add",className:"h-3.5 w-3.5 mr-1"}),e[66]=S,e[67]=oe):oe=e[67];let De;e[68]!==a||e[69]!==m?(De=a??m("multirun.modelMultiSelect.actions.addModel"),e[68]=a,e[69]=m,e[70]=De):De=e[70];let fe;e[71]!==H||e[72]!==ge||e[73]!==ue||e[74]!==M||e[75]!==oe||e[76]!==De?(fe=s.jsxs("button",{ref:K,type:"button","data-popup-open":H,className:ge,disabled:ue,onClick:M,children:[oe,De]}),e[71]=H,e[72]=ge,e[73]=ue,e[74]=M,e[75]=oe,e[76]=De,e[77]=fe):fe=e[77];let X;e[78]!==_||e[79]!==I||e[80]!==g||e[81]!==p||e[82]!==A||e[83]!==me||e[84]!==C||e[85]!==N||e[86]!==D||e[87]!==ae||e[88]!==z||e[89]!==w||e[90]!==P||e[91]!==x||e[92]!==k||e[93]!==B||e[94]!==j?(X=D?s.jsx("div",{className:ye("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",p==="top"?"bottom-full mb-1":"top-full mt-1",g),style:{background:"linear-gradient(var(--surface-elevated),var(--surface-elevated)),linear-gradient(var(--surface-background),var(--surface-background))"},children:s.jsx(Jh,{providers:x,providerOrder:P,favoriteModels:A,recentModels:k,modelsMetadata:w,hiddenModels:C,searchQuery:B,onSearchQueryChange:E,onSelect:me,labels:ae,selectionCount:Pe=>z.get(`${Pe.providerID}:${Pe.modelID}`)||0,disabled:!I,maxHeightClassName:"flex-1",maxHeightStyle:{maxHeight:_?`${_}px`:"300px"},stickyHeaders:!0,tooltipsEnabled:D,isFavorite:Pe=>N(Pe.providerID,Pe.modelID),onToggleFavorite:Pe=>j(Pe.providerID,Pe.modelID),onEscape:()=>{F(!1),E("")}})}):null,e[78]=_,e[79]=I,e[80]=g,e[81]=p,e[82]=A,e[83]=me,e[84]=C,e[85]=N,e[86]=D,e[87]=ae,e[88]=z,e[89]=w,e[90]=P,e[91]=x,e[92]=k,e[93]=B,e[94]=j,e[95]=X):X=e[95];let le;e[96]!==de||e[97]!==fe||e[98]!==X?(le=s.jsxs("div",{className:de,ref:V,children:[fe,X]}),e[96]=de,e[97]=fe,e[98]=X,e[99]=le):le=e[99];let se;e[100]!==J||e[101]!==z||e[102]!==o||e[103]!==i||e[104]!==x||e[105]!==n||e[106]!==v||e[107]!==m?(se=v&&n.length>0&&s.jsx("div",{className:"flex flex-col gap-2 w-full",children:n.map((Pe,U)=>{const Be=`${Pe.providerID}:${Pe.modelID}`,Fe=z.get(Be)||1,Ye=J(Pe),st=x.find(gt=>gt.id===Pe.providerID)?.models?.find(gt=>gt.id===Pe.modelID),ct=st?.variants?Object.keys(st.variants):[],bt=ct.length>0,rt=Pe.variant??"__default__";return s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Nj,{model:Pe,instanceIndex:Ye,totalSameModel:Fe,onRemove:()=>o(U)}),bt&&s.jsxs(Ls,{value:rt,onValueChange:gt=>{if(!i)return;i(U,{...Pe,variant:gt==="__default__"?void 0:gt})},children:[s.jsxs(_s,{size:"sm",className:"gap-1.5",children:[s.jsx(R,{name:"brain-ai-3",className:ye("h-3.5 w-3.5 flex-shrink-0",rt==="__default__"?"text-muted-foreground":"text-[color:var(--status-info)]")}),s.jsx(Ds,{placeholder:m("multirun.modelMultiSelect.variant.placeholder"),children:gt=>gt==="__default__"?m("multirun.modelMultiSelect.variant.default"):gt})]}),s.jsxs($s,{fitContent:!0,children:[s.jsx(rs,{value:"__default__",className:"pr-2 [&>span:first-child]:hidden",children:m("multirun.modelMultiSelect.variant.default")}),ct.map(Rj)]})]})]},Pe.instanceId)})}),e[100]=J,e[101]=z,e[102]=o,e[103]=i,e[104]=x,e[105]=n,e[106]=v,e[107]=m,e[108]=se):se=e[108];let T;e[109]!==le||e[110]!==se?(T=s.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[le,se]}),e[109]=le,e[110]=se,e[111]=T):T=e[111];let ie;e[112]!==u||e[113]!==c||e[114]!==n.length||e[115]!==m?(ie=c!==void 0&&n.length<c&&s.jsx("p",{className:"typography-micro text-muted-foreground",children:u!==void 0?m("multirun.modelMultiSelect.validation.minToMax",{min:c,max:u}):m("multirun.modelMultiSelect.validation.minOnly",{min:c})}),e[112]=u,e[113]=c,e[114]=n.length,e[115]=m,e[116]=ie):ie=e[116];let je;return e[117]!==T||e[118]!==ie?(je=s.jsxs("div",{className:"space-y-2",children:[T,ie]}),e[117]=T,e[118]=ie,e[119]=je):je=e[119],je};function Aj(t){return t.providers}function Dj(t){return t.modelsMetadata}function Pj(t){return t.toggleFavoriteModel}function Ej(t){return t.isFavoriteModel}function Tj(t){return t.hiddenModels}function Ij(t){return t.providerOrder}function Rj(t){return s.jsx(rs,{value:t,className:"pr-2 [&>span:first-child]:hidden",children:t},t)}const Mj=(t,e,n)=>{const r=t.session.title?.trim()||t.session.id;return`
|
|
901
901
|
|
|
902
902
|
--- RESULT ${n+1}: ${r} ---
|
|
@@ -911,5 +911,5 @@ Now write the final fused answer.`,synthetic:!0}],directory:$??Xs.getDirectory()
|
|
|
911
911
|
`)?(D(Fe),C(!0)):C(!1);return}C(!1)},[]),te=Ge.useCallback(T=>{x(ie=>({...ie,execution:{...ie.execution,prompt:T}}))},[]),ae=Ge.useCallback(T=>{const ie=m.execution.prompt,Pe=G.current?.selectionStart??ie.length,Be=ie.substring(0,Pe).lastIndexOf("@"),Fe=T.relativePath&&T.relativePath.trim().length>0?T.relativePath.trim():T.path||T.name,Ye=Be!==-1?Be:Pe,at=`${ie.substring(0,Ye)}@${Fe} ${ie.substring(Pe)}`,st=Ye+Fe.length+2;te(at),C(!1),D(""),requestAnimationFrame(()=>{const ct=G.current;ct&&(ct.selectionStart=st,ct.selectionEnd=st,ct.focus()),Re(at,st)})},[m.execution.prompt,te,Re]),de=Ge.useCallback(T=>{const ie=m.execution.prompt,Pe=G.current?.selectionStart??ie.length,Be=ie.substring(0,Pe).lastIndexOf("@"),Fe=Be!==-1?Be:Pe,Ye=`${ie.substring(0,Fe)}@${T} ${ie.substring(Pe)}`,at=Fe+T.length+2;te(Ye),C(!1),D(""),requestAnimationFrame(()=>{const st=G.current;st&&(st.selectionStart=at,st.selectionEnd=at,st.focus()),Re(Ye,at)})},[m.execution.prompt,te,Re]),H=Ge.useCallback(T=>{const ie=`/${T.name} `;te(ie),B(!1),_(""),V(!1),requestAnimationFrame(()=>{const je=G.current;je&&(je.focus(),je.selectionStart=je.value.length,je.selectionEnd=je.value.length),Re(ie,ie.length)})},[te,Re]),ge=Ge.useCallback((T,ie)=>{const je=m.execution.prompt,U=G.current?.selectionStart??je.length,Fe=je.substring(0,U).lastIndexOf("#"),Ye=Fe!==-1?Fe:U,at=`${je.substring(0,Ye)}#${ie} ${je.substring(U)}`,st=Ye+ie.length+2;te(at),V(!1),y(""),requestAnimationFrame(()=>{const ct=G.current;ct&&(ct.selectionStart=st,ct.selectionEnd=st,ct.focus()),Re(at,st)})},[m.execution.prompt,te,Re]),ue=Ge.useCallback(T=>{if(F&&Z.current&&(T.key==="Enter"||T.key==="ArrowUp"||T.key==="ArrowDown"||T.key==="Escape"||T.key==="Tab")){T.preventDefault(),Z.current.handleKeyDown(T.key);return}k&&J.current&&(T.key==="Enter"||T.key==="ArrowUp"||T.key==="ArrowDown"||T.key==="Escape"||T.key==="Tab")&&(T.preventDefault(),J.current.handleKeyDown(T.key)),W&&re.current&&(T.key==="Enter"||T.key==="ArrowUp"||T.key==="ArrowDown"||T.key==="Escape"||T.key==="Tab")&&(T.preventDefault(),re.current.handleKeyDown(T.key))},[F,k,W]),M=Ge.useCallback(async()=>{const T=N2(m,i);if(T){Ee.error(T);return}const ie={...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:A2(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}:{}};j(!0);try{await o(ie),r(!1)}catch(je){Ee.error(je instanceof Error?je.message:i("sessions.scheduledTasks.editor.toast.saveFailed"))}finally{j(!1)}},[m,r,o,i]),oe=Ge.useId(),De=Ge.useCallback(()=>typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]'),[]),fe=i(n?"sessions.scheduledTasks.editor.title.edit":"sessions.scheduledTasks.editor.title.new"),X=i("sessions.scheduledTasks.editor.description"),le=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(Bs,{htmlFor:"sched-name",required:!0,children:i("sessions.scheduledTasks.editor.taskName.label")}),s.jsx(Jn,{id:"sched-name",value:m.name,onChange:T=>x(ie=>({...ie,name:T.target.value})),placeholder:i("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(Bs,{children:i("sessions.scheduledTasks.editor.scheduleType.label")}),s.jsxs(Ls,{value:m.schedule.kind,onValueChange:T=>{x(ie=>({...ie,schedule:{...ie.schedule,kind:T,...T==="cron"&&!ie.schedule.cronExpression?{cronExpression:"0 * * * *"}:{}}}))},children:[s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ds,{children:T=>i(T==="daily"?"sessions.scheduledTasks.editor.scheduleType.daily":T==="weekly"?"sessions.scheduledTasks.editor.scheduleType.weekly":T==="cron"?"sessions.scheduledTasks.editor.scheduleType.cron":"sessions.scheduledTasks.editor.scheduleType.once")})}),s.jsxs($s,{children:[s.jsx(rs,{value:"daily",children:i("sessions.scheduledTasks.editor.scheduleType.daily")}),s.jsx(rs,{value:"weekly",children:i("sessions.scheduledTasks.editor.scheduleType.weekly")}),s.jsx(rs,{value:"once",children:i("sessions.scheduledTasks.editor.scheduleType.once")}),s.jsx(rs,{value:"cron",children:i("sessions.scheduledTasks.editor.scheduleType.cron")})]})]})]})]}),m.schedule.kind==="cron"?s.jsx(D2,{draft:m,setDraft:x,locale:c,t:i}):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:z,children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.date.label")}),s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",className:ye(Pu({size:"default"}),"w-fit max-w-full"),onClick:()=>A(T=>!T),children:[s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(R,{name:"calendar",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:g2(m.schedule.onceDate,i("sessions.scheduledTasks.editor.date.placeholder"),c)})]}),s.jsx(R,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),N?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+6px)] z-50 w-[288px] rounded-xl border border-border bg-background 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:()=>$(T=>Ad(T,-1)),"aria-label":i("sessions.scheduledTasks.editor.date.previousMonth"),disabled:Oe,children:s.jsx(R,{name:"arrow-left-s",className:"h-4 w-4"})}),s.jsx("div",{className:"typography-ui-label text-foreground",children:new Intl.DateTimeFormat(c,{month:"long",year:"numeric"}).format(I)}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover",onClick:()=>$(T=>Ad(T,1)),"aria-label":i("sessions.scheduledTasks.editor.date.nextMonth"),children:s.jsx(R,{name:"arrow-right-s",className:"h-4 w-4"})})]}),s.jsx("div",{className:"mb-1 grid grid-cols-7 gap-1 px-1",children:ne.map((T,ie)=>s.jsx("div",{className:"py-1 text-center typography-micro text-muted-foreground",children:T},`${T}-${ie}`))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:x2(I,Y).map(({date:T,inCurrentMonth:ie})=>{const je=Nd(T),Pe=je===m.schedule.onceDate,U=Id(T,Ne),Be=T.getTime()<Ne.getTime(),Fe=Pe?"bg-interactive-selection text-interactive-selection-foreground":Be?"text-muted-foreground/40":ie?"text-foreground hover:bg-interactive-hover":"text-muted-foreground/60 hover:bg-interactive-hover";return s.jsx("button",{type:"button",onClick:()=>{Be||(ce(je),A(!1))},disabled:Be,className:["h-8 rounded-md typography-ui-label",Fe,U&&!Pe?"ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50":"",Be?"cursor-not-allowed opacity-45":""].join(" "),children:T.getDate()},je)})}),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:Se||""}),s.jsx(nt,{type:"button",size:"xs",variant:"ghost",onClick:()=>{ce(Nd(Ne)),$(new Date(Ne.getFullYear(),Ne.getMonth(),1))},children:i("sessions.scheduledTasks.editor.date.jumpToToday")})]})]}):null]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.time.label")}),s.jsx(Ed,{value:m.schedule.onceTime,use24Hour:be,hourAriaLabel:i("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:i("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:i("sessions.scheduledTasks.editor.time.periodAria"),amLabel:i("sessions.scheduledTasks.editor.time.period.am"),pmLabel:i("sessions.scheduledTasks.editor.time.period.pm"),onChange:T=>x(ie=>({...ie,schedule:{...ie.schedule,onceTime:T}}))}),s.jsxs("div",{className:"mt-2 flex flex-col gap-1",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Ls,{value:m.schedule.timezone,onValueChange:T=>{x(ie=>({...ie,schedule:{...ie.schedule,timezone:T}}))},children:[s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ds,{})}),s.jsx($s,{children:sl.map(T=>s.jsx(rs,{value:T,children:T},T))})]})]})]})]}):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(Bs,{children:i("sessions.scheduledTasks.editor.weekdays.label")}),s.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:we.map(T=>{const ie=m.schedule.weekdays.includes(T.value);return s.jsxs("div",{className:["group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta",ie?"text-foreground":"text-muted-foreground"].join(" "),children:[s.jsx(qr,{checked:ie,onChange:je=>ve(T.value,je),ariaLabel:T.label}),s.jsx("button",{type:"button",onClick:()=>ve(T.value,!ie),className:"group-hover:text-foreground",children:T.label})]},T.value)})})]}):null,s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.times.label")}),s.jsx("div",{className:"flex flex-col gap-2",children:m.schedule.times.map((T,ie)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ed,{value:T,use24Hour:be,hourAriaLabel:i("sessions.scheduledTasks.editor.time.hourAria"),minuteAriaLabel:i("sessions.scheduledTasks.editor.time.minuteAria"),periodAriaLabel:i("sessions.scheduledTasks.editor.time.periodAria"),amLabel:i("sessions.scheduledTasks.editor.time.period.am"),pmLabel:i("sessions.scheduledTasks.editor.time.period.pm"),onChange:je=>Te(ie,je)}),m.schedule.times.length>1?s.jsx(nt,{type:"button",size:"icon",variant:"ghost",onClick:()=>ke(ie),"aria-label":i("sessions.scheduledTasks.editor.times.removeAria"),children:s.jsx(R,{name:"close",className:"h-4 w-4"})}):null]},ie))}),s.jsx("div",{children:s.jsxs(nt,{type:"button",size:"sm",variant:"outline",onClick:Ie,children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"})," ",i("sessions.scheduledTasks.editor.times.add")]})})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.timezone.label")}),s.jsxs(Ls,{value:m.schedule.timezone,onValueChange:T=>{x(ie=>({...ie,schedule:{...ie.schedule,timezone:T}}))},children:[s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ds,{})}),s.jsx($s,{children:sl.map(T=>s.jsx(rs,{value:T,children:T},T))})]})]})]}),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(Bs,{required:!0,children:i("sessions.scheduledTasks.editor.model.label")}),s.jsx(Ap,{providerId:m.execution.providerID,modelId:m.execution.modelID,onChange:(T,ie)=>{x(je=>({...je,execution:{...je.execution,providerID:T,modelID:ie,variant:""}}))}})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.thinkingLevel.label")}),s.jsxs(Ls,{value:pe,disabled:!Q,onValueChange:T=>{x(ie=>({...ie,execution:{...ie.execution,variant:T==="__default"?"":T}}))},children:[s.jsx(_s,{size:"lg",className:"w-fit max-w-full",children:s.jsx(Ds,{children:T=>T==="__default"?i("sessions.scheduledTasks.editor.thinkingLevel.default"):T})}),s.jsxs($s,{children:[s.jsx(rs,{value:"__default",children:i("sessions.scheduledTasks.editor.thinkingLevel.default")}),me.map(T=>s.jsx(rs,{value:T,children:T},T))]})]})]})]}),s.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx(Bs,{children:i("sessions.scheduledTasks.editor.agent.label")}),s.jsx(Dp,{agentName:m.execution.agent,filter:T=>Du(T.mode),onChange:T=>x(ie=>({...ie,execution:{...ie.execution,agent:T}}))})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Bs,{htmlFor:"sched-prompt",required:!0,children:i("sessions.scheduledTasks.editor.prompt.label")}),s.jsxs("div",{className:"relative",children:[s.jsx(Kr,{id:"sched-prompt",ref:G,value:m.execution.prompt,onChange:T=>{const ie=T.target.value;te(ie);const je=T.target.selectionStart??ie.length;Re(ie,je)},onKeyDown:ue,rows:8,placeholder:i("sessions.scheduledTasks.editor.prompt.placeholder"),className:"typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto"}),F?s.jsx(Ru,{ref:Z,searchQuery:E,onCommandSelect:H,onClose:()=>B(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,k?s.jsx(Mu,{ref:J,searchQuery:P,onFileSelect:ae,onAgentSelect:de,onClose:()=>C(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,W?s.jsx(Ou,{ref:re,searchQuery:K,onSnippetSelect:ge,onClose:()=>V(!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(qr,{checked:m.execution.goalTokenBudget!==null,onChange:T=>x(ie=>({...ie,execution:{...ie.execution,goalTokenBudget:T?2e5:null}})),ariaLabel:i("sessions.scheduledTasks.editor.goal.budgetAria")}),s.jsx("span",{className:"typography-meta",children:i("sessions.scheduledTasks.editor.goal.budgetLabel")})]}),m.execution.goalTokenBudget!==null?s.jsx(Pp,{value:m.execution.goalTokenBudget,onValueChange:T=>{typeof T=="number"&&Number.isFinite(T)&&T>0&&x(ie=>({...ie,execution:{...ie.execution,goalTokenBudget:Math.floor(T)}}))},min:1e3,max:1e8,step:5e4}):null]}):null]}),se=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(qr,{checked:m.enabled,onChange:T=>x(ie=>({...ie,enabled:T})),ariaLabel:i("sessions.scheduledTasks.editor.enabled.aria")}),s.jsx("span",{className:"typography-meta",children:i("sessions.scheduledTasks.editor.enabled.label")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",className:ye(kd),onClick:()=>x(T=>({...T,execution:{...T.execution,permissionAutoAccept:!T.execution.permissionAutoAccept}})),"aria-pressed":m.execution.permissionAutoAccept,"aria-label":i("sessions.scheduledTasks.editor.permissionAutoAccept.aria"),children:m.execution.permissionAutoAccept?s.jsx(R,{name:"shield-check",className:"h-[18px] w-[18px]",style:{color:"var(--status-info)"},"aria-hidden":"true"}):s.jsx(R,{name:"shield-user",className:"h-[18px] w-[18px]","aria-hidden":"true"})})}),s.jsx(ft,{side:"top",sideOffset:6,children:i("sessions.scheduledTasks.editor.permissionAutoAccept.label")})]}),s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",className:ye(kd,m.execution.goalEnabled&&"text-[var(--status-info)]"),onClick:()=>x(T=>({...T,execution:{...T.execution,goalEnabled:!T.execution.goalEnabled}})),"aria-pressed":m.execution.goalEnabled,"aria-label":i("sessions.scheduledTasks.editor.goal.aria"),children:m.execution.goalEnabled?s.jsx(R,{name:"target-fill",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"}):s.jsx(R,{name:"target",className:"h-[18px] w-[18px] text-current","aria-hidden":"true"})})}),s.jsx(ft,{side:"top",sideOffset:6,children:i("sessions.scheduledTasks.editor.goal.label")})]}),s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!1),disabled:w,children:i("sessions.scheduledTasks.editor.actions.cancel")}),s.jsx(nt,{type:"button",size:"sm",onClick:M,disabled:w,children:i(w?"sessions.scheduledTasks.editor.actions.saving":"sessions.scheduledTasks.editor.actions.save")})]})]});return p?s.jsx(_i,{open:e,title:fe,onClose:()=>r(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:T=>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:fe}),T]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:X})]}),footer:se,children:le}):s.jsx(Ws,{open:e,onOpenChange:T=>{!T&&De()||r(T)},children:s.jsxs(Vs,{"aria-describedby":oe,className:"!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden",children:[s.jsx(Sn,{id:oe,className:"sr-only",children:X}),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(wn,{className:"typography-ui-label font-medium text-foreground",children:fe}),s.jsx("p",{className:"typography-meta mt-0.5 text-muted-foreground",children:X})]})}),s.jsx(ll,{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:le})}),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:se})})]})})}function E2(t){return no(t,{min:0,max:23})}function T2(t,e){return no(String(Number.parseInt(t,10)+e),{min:0,max:23,loop:!0})}function I2(t,e){const n=Number(t),r=Number(e),o=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,i=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function R2(t){return s.jsx(rs,{value:t,children:t},t)}const M2=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,o)=>r.localeCompare(o))},O2=(t,e)=>{const n=M2(t).join(", ")||"--:--",r=o=>e(o===0?"sessions.scheduledTasks.dialog.schedule.weekdayShort.sun":o===1?"sessions.scheduledTasks.dialog.schedule.weekdayShort.mon":o===2?"sessions.scheduledTasks.dialog.schedule.weekdayShort.tue":o===3?"sessions.scheduledTasks.dialog.schedule.weekdayShort.wed":o===4?"sessions.scheduledTasks.dialog.schedule.weekdayShort.thu":o===5?"sessions.scheduledTasks.dialog.schedule.weekdayShort.fri":o===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:Fr(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.daily",{time:n});if(t.schedule.kind==="weekly"){const o=Array.isArray(t.schedule.weekdays)?t.schedule.weekdays.map(i=>r(i)).join(", "):"";return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone",{days:o,time:n,timezone:Fr(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.weekly",{days:o,time:n})}if(t.schedule.kind==="once"){const o=typeof t.schedule.date=="string"&&t.schedule.date.trim().length>0?t.schedule.date:e("sessions.scheduledTasks.dialog.schedule.unknownDate"),i=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:o,time:i,timezone:Fr(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.once",{date:o,time:i})}return t.schedule.timezone?e("sessions.scheduledTasks.dialog.schedule.cronWithTimezone",{cron:t.schedule.cron||"",timezone:Fr(t.schedule.timezone)}):e("sessions.scheduledTasks.dialog.schedule.cron",{cron:t.schedule.cron||""})},F2=(t,e)=>!t||!Number.isFinite(t)?"":pu(t,e),Md=(t,e)=>{if(!t||!Number.isFinite(t))return"";const n=t-Date.now(),r=Math.abs(n),o=6e4,i=60*o,c=24*i,a=n>=0;if(r<o)return e(a?"sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute":"sessions.scheduledTasks.dialog.relativeTime.justNow");if(r<i){const f=Math.round(r/o);return a?e("sessions.scheduledTasks.dialog.relativeTime.inMinutes",{count:f}):e("sessions.scheduledTasks.dialog.relativeTime.minutesAgo",{count:f})}if(r<c){const f=Math.floor(r/i),g=Math.round(r%i/o),b=g>0?`${f}h ${g}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/c),u=Math.round(r%c/i),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})},B2={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"}},L2=t=>({color:`var(--status-${t})`,backgroundColor:`var(--status-${t}-background)`,borderColor:`var(--status-${t}-border)`});function Od(){const{t}=mt(),e=xe(y=>y.isScheduledTasksDialogOpen),n=xe(y=>y.setScheduledTasksDialogOpen),r=xe(y=>y.isMobile),o=xe(y=>y.timeFormatPreference),i=qt(y=>y.projects),c=qt(y=>y.getActiveProject()),a=ls(y=>y.homeDirectory),{currentTheme:d}=_r(),[u,h]=Ge.useState(""),[f,g]=Ge.useState([]),[b,S]=Ge.useState(!0),[v,p]=Ge.useState(!1),[m,x]=Ge.useState(null),[w,j]=Ge.useState(null),N=Ge.useMemo(()=>i.find(y=>y.id===u)||null,[i,u]),A=Ge.useCallback(y=>{const I=y.label?.trim()||hr(y.path,a||void 0),$=y.icon?fl[y.icon]:null,z=y.color?ml[y.color]:void 0,G=$?s.jsx(R,{name:$,className:"h-3.5 w-3.5 shrink-0",style:z?{color:z}:void 0}):s.jsx(R,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:z?{color:z}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[y.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:y.iconBackground?{backgroundColor:y.iconBackground}:void 0,children:s.jsx(hl,{project:{id:y.id,iconImage:y.iconImage??null},options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:G})}):G,s.jsx("span",{className:"truncate",children:I})]})},[a,d.metadata.variant,d.colors.surface.foreground]),k=Ge.useCallback(async(y,I)=>{if(!y){g([]);return}I?.silent||S(!0);try{const $=await Wg(y);$.sort((z,G)=>{if(z.enabled!==G.enabled)return z.enabled?-1:1;const J=z.name.localeCompare(G.name);return J!==0?J:(z.state?.nextRunAt||Number.MAX_SAFE_INTEGER)-(G.state?.nextRunAt||Number.MAX_SAFE_INTEGER)}),g($)}catch($){Ee.error($ instanceof Error?$.message:t("sessions.scheduledTasks.dialog.toast.loadFailed")),I?.silent||g([])}finally{I?.silent||S(!1)}},[t]);Ge.useEffect(()=>{if(!e)return;const y=c?.id||i[0]?.id||"";h(y),y?k(y):(g([]),S(!1))},[e,c,i,k]),Ge.useEffect(()=>{if(!e)return;let y=null;const I=Dl($=>{$.type==="scheduled-task-ran"&&$.projectId===u&&(y&&clearTimeout(y),y=setTimeout(()=>{k(u,{silent:!0})},400))});return()=>{y&&clearTimeout(y),I()}},[e,u,k]);const C=Ge.useCallback(async y=>{if(!u)throw new Error(t("sessions.scheduledTasks.dialog.error.chooseProjectFirst"));await yc(u,y),await k(u),Ee.success(t("sessions.scheduledTasks.dialog.toast.saved"))},[u,k,t]),P=Ge.useCallback(async(y,I)=>{if(u){j(y.id),g($=>$.map(z=>z.id===y.id?{...z,enabled:I}:z));try{y.loopFile?await Vg(u,y.id,I):await yc(u,{...y,enabled:I}),await k(u,{silent:!0})}catch($){Ee.error($ instanceof Error?$.message:t("sessions.scheduledTasks.dialog.toast.updateFailed")),await k(u,{silent:!0})}finally{j(null)}}},[u,k,t]),D=Ge.useCallback(async y=>{if(!(!u||!window.confirm(y.loopFile?t("sessions.scheduledTasks.dialog.confirm.deleteLoopFile",{taskName:y.name}):t("sessions.scheduledTasks.dialog.confirm.deleteTask",{taskName:y.name})))){j(y.id);try{y.loopFile?await Hg(u,y.id):await Kg(u,y.id),await k(u,{silent:!0}),Ee.success(t("sessions.scheduledTasks.dialog.toast.deleted"))}catch($){Ee.error($ instanceof Error?$.message:t("sessions.scheduledTasks.dialog.toast.deleteFailed"))}finally{j(null)}}},[u,k,t]),F=Ge.useCallback(y=>{if(!y.loopFile){x(y),p(!0);return}if(N?.path){if(n(!1),r){Bn.getState().setSelectedPath(N.path,y.loopFile,{allowOutsideRoot:!0}),xe.getState().setActiveMainTab("files");return}xe.getState().openContextFile(N.path,y.loopFile)}},[r,N?.path,n]),B=Ge.useCallback(async y=>{if(u){j(y.id);try{const{sessionId:I,persistError:$}=await Gg(u,y.id);if(await Promise.all([k(u,{silent:!0}),xi()]),$?Ee.warning(t("sessions.scheduledTasks.dialog.toast.startedPersistWarning")):Ee.success(t("sessions.scheduledTasks.dialog.toast.started")),I){const z=i.find(G=>G.id===u);Je.getState().setCurrentSession(I,z?.path??null),xe.getState().setActiveMainTab("chat")}}catch(I){Ee.error(I instanceof Error?I.message:t("sessions.scheduledTasks.dialog.toast.runFailed"))}finally{j(null)}}},[u,i,k,t]),E=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(Ls,{value:u||"__none",onValueChange:y=>{const I=y==="__none"?"":y;h(I),I?k(I):g([])},children:[s.jsx(_s,{size:"lg",className:r?"w-full":void 0,children:N?s.jsx(Ds,{children:A(N)}):s.jsx(Ds,{placeholder:t("sessions.scheduledTasks.dialog.project.placeholder")})}),s.jsxs($s,{children:[i.length===0?s.jsx(rs,{value:"__none",children:t("sessions.scheduledTasks.dialog.project.empty")}):null,i.map(y=>s.jsx(rs,{value:y.id,children:A(y)},y.id))]})]})]}),_=()=>{x(null),p(!0)},W=y=>{h(y),y?k(y):g([])},V=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(R,{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(y=>{const I=w===y.id,$=y.state?.lastStatus||"idle",z=B2[$],G=t($==="success"?"sessions.scheduledTasks.dialog.status.success":$==="error"?"sessions.scheduledTasks.dialog.status.error":$==="running"?"sessions.scheduledTasks.dialog.status.running":"sessions.scheduledTasks.dialog.status.idle"),J=y.state?.nextRunAt,Z=y.state?.lastRunAt;return s.jsxs("div",{className:ye("rounded-lg border border-border p-4 transition-opacity",!y.enabled&&"opacity-60"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-header truncate font-semibold text-foreground",children:y.name}),s.jsx("div",{className:"typography-micro truncate text-muted-foreground",children:O2(y,t)}),y.loopFile?s.jsx("div",{className:"typography-micro truncate text-muted-foreground/70",title:y.loopFile,children:t("sessions.scheduledTasks.dialog.loopFile.note",{file:y.loopFile})}):null]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-5 gap-y-1 typography-micro text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(R,{name:"timer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.nextRun.label")}),J?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-foreground",children:Md(J,t)}),s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:F2(J,o)})]}):s.jsx("span",{children:"—"})]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(R,{name:"history",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-medium text-foreground",children:t("sessions.scheduledTasks.dialog.lastRun.label")}),$==="running"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:"var(--status-warning)"},children:[s.jsx(R,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}),t("sessions.scheduledTasks.dialog.lastRun.runningNow")]}):Z?s.jsxs(s.Fragment,{children:[z.tone!=="muted"?s.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:`var(--status-${z.tone})`},children:[s.jsx(R,{name:z.Icon,className:"h-3.5 w-3.5"}),G]}):null,s.jsx("span",{className:"text-muted-foreground/50",children:"·"}),s.jsx("span",{children:Md(Z,t)})]}):s.jsx("span",{children:t("sessions.scheduledTasks.dialog.lastRun.never")})]})]}),y.state?.lastError?s.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-md border p-2 typography-micro",style:L2("error"),children:[s.jsx(R,{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:y.state.lastError})]}):null,s.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("label",{className:ye("inline-flex cursor-pointer items-center gap-2 typography-micro font-medium",y.enabled?"text-foreground":"text-muted-foreground",I&&"cursor-not-allowed opacity-50"),children:[s.jsx(qr,{checked:y.enabled,onChange:re=>{P(y,re)},ariaLabel:y.enabled?t("sessions.scheduledTasks.dialog.taskToggle.pauseAria",{taskName:y.name}):t("sessions.scheduledTasks.dialog.taskToggle.enableAria",{taskName:y.name}),disabled:I}),y.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(nt,{variant:"outline",size:"sm",onClick:()=>{B(y)},disabled:I,children:[s.jsx(R,{name:"play",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.runNow")]}),s.jsxs(nt,{variant:"outline",size:"sm",onClick:()=>F(y),disabled:I,"aria-label":t("sessions.scheduledTasks.dialog.actions.editAria",{taskName:y.name}),children:[s.jsx(R,{name:"edit-2",className:"h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.edit")]}),s.jsx(nt,{variant:"destructive",size:"sm",onClick:()=>{D(y)},disabled:I,"aria-label":t("sessions.scheduledTasks.dialog.actions.deleteAria",{taskName:y.name}),children:s.jsx(R,{name:"delete-bin",className:"h-4 w-4"})})]})]})]},y.id)})})}),K=s.jsxs("div",{className:"space-y-4",children:[E,V]});return s.jsxs(s.Fragment,{children:[r?s.jsx(_i,{open:e,title:t("sessions.scheduledTasks.dialog.title"),onClose:()=>n(!1),contentMaxHeightClassName:"max-h-[min(80vh,640px)]",renderHeader:y=>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")}),y]}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("sessions.scheduledTasks.dialog.description")})]}),footer:s.jsxs(nt,{className:"w-full",onClick:_,disabled:!u,children:[s.jsx(R,{name:"add",className:"mr-1 h-4 w-4"})," ",t("sessions.scheduledTasks.dialog.actions.newTask")]}),children:K}):e?s.jsx("div",{className:"absolute inset-0 z-10 flex flex-col bg-background",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:i.length===0?s.jsx("div",{className:"px-2 py-2 typography-meta text-muted-foreground",children:t("sessions.scheduledTasks.dialog.project.empty")}):i.map(y=>s.jsx("button",{type:"button",onClick:()=>W(y.id),className:ye("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-primary/50",u===y.id?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground"),children:A(y)},y.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(nt,{size:"sm",onClick:_,disabled:!u,children:[s.jsx(R,{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:V})})]})]})}):null,s.jsx(P2,{open:v,task:m,onOpenChange:p,onSave:C})]})}const mi=100;function Fd(){const t=tt.c(105),{t:e}=mt(),n=xe(G2),r=xe(K2),o=xe(H2),i=Je(V2),c=Je(W2),a=ls(U2);let d;t[0]!==n?(d=Z=>n?Z.archivedSessions:[],t[0]=n,t[1]=d):d=t[1];const u=Rs(qn(d)),[h,f]=l.useState(""),[g,b]=l.useState(null),[S,v]=l.useState(mi);let p;t[2]!==h?(p=h.trim().toLowerCase(),t[2]=h,t[3]=p):p=t[3];const m=p;let x;e:{if(!n){let re;t[4]===Symbol.for("react.memo_cache_sentinel")?(re=[],t[4]=re):re=t[4],x=re;break e}let Z;t[5]!==u?(Z=[...u].sort(z2),t[5]=u,t[6]=Z):Z=t[6],x=Z}const w=x;let j;if(t[7]!==a||t[8]!==w||t[9]!==e){const Z=new Map;for(const re of w){const ee=wt(Us(re))??"",he=Z.get(ee);if(he){he.sessions.push(re);continue}Z.set(ee,{directory:ee,label:ee?hr(ee,a)||ee:e("sessions.archivePage.otherProjects"),sessions:[re]})}j=[...Z.values()].sort($2),t[7]=a,t[8]=w,t[9]=e,t[10]=j}else j=t[10];const N=j;let A;e:{if(m){let re;if(t[11]!==m||t[12]!==w){let ee;t[14]!==m?(ee=he=>(he.title??"").toLowerCase().includes(m),t[14]=m,t[15]=ee):ee=t[15],re=w.filter(ee),t[11]=m,t[12]=w,t[13]=re}else re=t[13];A=re;break e}if(g===null){A=w;break e}let Z;t[16]!==N||t[17]!==g?(Z=N.find(re=>re.directory===g)?.sessions??[],t[16]=N,t[17]=g,t[18]=Z):Z=t[18],A=Z}const k=A;let C,P,D,F,B,E,_,W,V,K;if(t[19]!==u.length||t[20]!==N||t[21]!==k||t[22]!==a||t[23]!==m||t[24]!==n||t[25]!==h||t[26]!==g||t[27]!==o||t[28]!==i||t[29]!==r||t[30]!==e||t[31]!==c||t[32]!==S){B=Symbol.for("react.early_return_sentinel");e:{const Z=k.slice(0,S);C=k.length-Z.length;const re=u.length;let ee;t[43]===Symbol.for("react.memo_cache_sentinel")?(ee=ne=>{b(ne),v(mi)},t[43]=ee):ee=t[43];const he=ee;let be;t[44]!==o||t[45]!==i||t[46]!==r?(be=ne=>{const ce=wt(Us(ne));i(ne.id,ce??void 0),o("chat"),r(!1)},t[44]=o,t[45]=i,t[46]=r,t[47]=be):be=t[47];const Y=be;let we;t[48]!==e||t[49]!==c?(we=ne=>{c(ne.id).then(ce=>{ce?Ee.success(e("sessions.sidebar.session.restore.success")):Ee.error(e("sessions.sidebar.session.restore.error"))})},t[48]=e,t[49]=c,t[50]=we):we=t[50];const me=we;if(!n){B=null;break e}let Q;t[51]!==e?(Q=(ne,ce,Re,te,ae,de,H)=>s.jsxs("div",{className:"group/dir relative",children:[s.jsxs("button",{type:"button",onClick:ae,title:de,className:ye("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-primary/50",H?"group-hover/dir:pr-8 group-focus-within/dir:pr-8":"",te?"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:ce}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground/70",children:Re})]}),H?s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>_n.requestDelete({sessions:H,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-primary/50","aria-label":e("sessions.archivePage.deleteProjectAria",{label:ce}),children:s.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})}),s.jsx(ft,{side:"bottom",sideOffset:4,children:e("sessions.archivePage.deleteProject")})]}):null]},ne),t[51]=e,t[52]=Q):Q=t[52];const pe=Q;F="absolute inset-0 z-10 flex flex-col bg-background",P="flex min-h-0 flex-1";let ve;if(t[53]!==pe||t[54]!==g||t[55]!==e||t[56]!==re){let ne;t[58]===Symbol.for("react.memo_cache_sentinel")?(ne=()=>he(null),t[58]=ne):ne=t[58],ve=pe("__all__",e("sessions.archivePage.allDirectories"),re,g===null,ne),t[53]=pe,t[54]=g,t[55]=e,t[56]=re,t[57]=ve}else ve=t[57];let Te;if(t[59]!==N||t[60]!==pe||t[61]!==g){let ne;t[63]!==pe||t[64]!==g?(ne=ce=>pe(ce.directory||"__none__",ce.label,ce.sessions.length,g===ce.directory,()=>he(ce.directory),ce.directory||void 0,ce.sessions),t[63]=pe,t[64]=g,t[65]=ne):ne=t[65],Te=N.map(ne),t[59]=N,t[60]=pe,t[61]=g,t[62]=Te}else Te=t[62];t[66]!==ve||t[67]!==Te?(D=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:[ve,Te]})}),t[66]=ve,t[67]=Te,t[68]=D):D=t[68],V="flex min-w-0 flex-1 flex-col";let ke;t[69]===Symbol.for("react.memo_cache_sentinel")?(ke=s.jsx(R,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t[69]=ke):ke=t[69];let Ie;t[70]===Symbol.for("react.memo_cache_sentinel")?(Ie=ne=>{f(ne.target.value),v(mi)},t[70]=Ie):Ie=t[70];let Ne;t[71]!==e?(Ne=e("sessions.archivePage.searchPlaceholder"),t[71]=e,t[72]=Ne):Ne=t[72];let Ae;t[73]!==h||t[74]!==Ne?(Ae=s.jsxs("div",{className:"relative min-w-0 flex-1",children:[ke,s.jsx("input",{value:h,onChange:Ie,placeholder:Ne,className:"h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-3 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50"})]}),t[73]=h,t[74]=Ne,t[75]=Ae):Ae=t[75];let Se;t[76]!==k.length||t[77]!==e?(Se=k.length===1?e("sessions.archivePage.countSingle",{count:k.length}):e("sessions.archivePage.countPlural",{count:k.length}),t[76]=k.length,t[77]=e,t[78]=Se):Se=t[78];let Oe;t[79]!==Se?(Oe=s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:Se}),t[79]=Se,t[80]=Oe):Oe=t[80],t[81]!==Ae||t[82]!==Oe?(K=s.jsxs("div",{className:"flex items-center gap-3 px-6 pt-3",children:[Ae,Oe]}),t[81]=Ae,t[82]=Oe,t[83]=K):K=t[83],W="min-h-0 flex-1 overflow-y-auto px-6 py-3",E="mx-auto w-full max-w-3xl space-y-0.5",_=Z.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(m?"sessions.archivePage.empty.noMatches":"sessions.archivePage.empty.noArchived")})}):Z.map(ne=>{const ce=wt(Us(ne))??"",Re=ce?hr(ce,a)||ce: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:()=>Y(ne),role:"button",tabIndex:0,onKeyDown:te=>{(te.key==="Enter"||te.key===" ")&&(te.preventDefault(),Y(ne))},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:ne.title||e("sessions.sidebar.session.untitled")}),m&&Re?s.jsx("span",{className:"max-w-40 flex-shrink-0 truncate text-[0.72rem] text-muted-foreground/70",title:ce,children:Re}):null,s.jsx("span",{className:"flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:Tu(ne.time?.archived??ne.time?.updated??ne.time?.created??Date.now())}),s.jsx("button",{type:"button",onClick:te=>{te.stopPropagation(),me(ne)},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-primary/50","aria-label":e("sessions.archivePage.restoreSessionAria",{title:ne.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(R,{name:"inbox-unarchive",className:"h-3.5 w-3.5"})}),s.jsx("button",{type:"button",onClick:te=>{te.stopPropagation(),_n.requestDelete({sessions:[ne],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-primary/50","aria-label":e("sessions.archivePage.deleteSessionAria",{title:ne.title||e("sessions.sidebar.session.untitled")}),children:s.jsx(R,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},ne.id)})}t[19]=u.length,t[20]=N,t[21]=k,t[22]=a,t[23]=m,t[24]=n,t[25]=h,t[26]=g,t[27]=o,t[28]=i,t[29]=r,t[30]=e,t[31]=c,t[32]=S,t[33]=C,t[34]=P,t[35]=D,t[36]=F,t[37]=B,t[38]=E,t[39]=_,t[40]=W,t[41]=V,t[42]=K}else C=t[33],P=t[34],D=t[35],F=t[36],B=t[37],E=t[38],_=t[39],W=t[40],V=t[41],K=t[42];if(B!==Symbol.for("react.early_return_sentinel"))return B;let y;t[84]!==C||t[85]!==e?(y=C>0?s.jsx("button",{type:"button",onClick:()=>v(_2),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[84]=C,t[85]=e,t[86]=y):y=t[86];let I;t[87]!==y||t[88]!==E||t[89]!==_?(I=s.jsxs("div",{className:E,children:[_,y]}),t[87]=y,t[88]=E,t[89]=_,t[90]=I):I=t[90];let $;t[91]!==I||t[92]!==W?($=s.jsx("div",{className:W,children:I}),t[91]=I,t[92]=W,t[93]=$):$=t[93];let z;t[94]!==$||t[95]!==V||t[96]!==K?(z=s.jsxs("div",{className:V,children:[K,$]}),t[94]=$,t[95]=V,t[96]=K,t[97]=z):z=t[97];let G;t[98]!==P||t[99]!==D||t[100]!==z?(G=s.jsxs("div",{className:P,children:[D,z]}),t[98]=P,t[99]=D,t[100]=z,t[101]=G):G=t[101];let J;return t[102]!==F||t[103]!==G?(J=s.jsx("div",{className:F,children:G}),t[102]=F,t[103]=G,t[104]=J):J=t[104],J}function _2(t){return t+mi}function $2(t,e){return e.sessions.length-t.sessions.length}function z2(t,e){return(e.time?.archived??0)-(t.time?.archived??0)}function U2(t){return t.homeDirectory}function W2(t){return t.unarchiveSession}function V2(t){return t.setCurrentSession}function H2(t){return t.setActiveMainTab}function K2(t){return t.setArchivePageOpen}function G2(t){return t.isArchivePageOpen}function Bd(){const t=tt.c(18),{t:e}=mt(),n=xe(Q2),r=xe(Y2),o=qt(q2);let i;t[0]!==n?(i=b=>b.projects.find(S=>S.id===n)??null,t[0]=n,t[1]=i):i=t[1];const c=qt(i);if(!n||!c)return null;let a;t[2]!==c.id||t[3]!==o||t[4]!==r?(a=()=>{o(c.id),r(!0)},t[2]=c.id,t[3]=o,t[4]=r,t[5]=a):a=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(R,{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(nt,{size:"sm",onClick:a,children:[d,u]})}),t[9]=a,t[10]=u,t[11]=h):h=t[11];let f;t[12]!==c.id||t[13]!==c.path?(f=s.jsx(Ig,{projectRef:{id:c.id,path:c.path},sections:"list-only"}),t[12]=c.id,t[13]=c.path,t[14]=f):f=t[14];let g;return t[15]!==h||t[16]!==f?(g=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]=g):g=t[17],g}function q2(t){return t.setActiveProjectIdOnly}function Y2(t){return t.setNewWorktreeDialogOpen}function Q2(t){return t.worktreesPageProjectId}const nl=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").substring(0,50),X2=(t,e)=>{const n=nl(t),r=nl(e);return`${n}-${r}`.substring(0,60)},Ld=(t,e)=>`${t}/${e}`,J2=t=>{const e=t.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},_d=(t,e)=>{const n=J2(e),r=t.directory,o=typeof r=="string"&&r.trim().length>0?t:{...t,directory:n};Bp(t.id,n),Je.getState().markSessionAsOpenChamberCreated(t.id),Rs.getState().upsertSession(o);try{bi().ensureChild(n,{bootstrap:!1}).setState(c=>{const a=c.session.findIndex(u=>u.id===t.id);if(a>=0&&c.session[a]===o)return c;const d=a>=0?c.session.map((u,h)=>h===a?o:u):[...c.session,o].sort((u,h)=>u.id.localeCompare(h.id));return{session:d,sessionTotal:Math.max(c.sessionTotal,d.length),limit:Math.max(c.limit,d.length)}})}catch{}return o},Z2=()=>{const t=qt.getState(),e=t.activeProjectId;if(!e)return null;const n=t.projects.find(o=>o.id===e);if(n?.path)return{id:n.id,path:n.path};const r=ls.getState().currentDirectory??null;if(r&&r.trim().length>0){const o=r.replace(/\\/g,"/").replace(/\/+$/,"")||r;return{id:`path:${o}`,path:o}}return null},ka=xr()(qu(t=>({isLoading:!1,error:null,createMultiRun:async e=>{const n=e.name.trim(),{groups:r,agent:o,files:i,setupCommands:c}=e;if(!n)return t({error:"Group name is required"}),null;if(!r||r.length===0)return t({error:"At least one run group is required"}),null;for(let a=0;a<r.length;a++){if(!r[a].prompt.trim())return t({error:`Group ${a+1}: prompt is required`}),null;if(r[a].models.length<1)return t({error:`Group ${a+1}: select at least 1 model`}),null;if(r[a].models.length>5)return t({error:`Group ${a+1}: maximum 5 models allowed`}),null}t({isLoading:!0,error:null});try{const a=Z2();if(!a)return t({error:"Select a project",isLoading:!1}),null;const d=a.path,h=await Iu(d)&&e.isolateRuns!==!1,f=nl(n),g=h?await $i(d):void 0,b=h?await Ep(d):null,S=[],v=c?.filter(j=>j.trim().length>0)??[];for(let j=0;j<r.length;j++){const N=r[j],A=N.prompt,k=new Map;for(const P of N.models){const D=`${P.providerID}:${P.modelID}`;k.set(D,(k.get(D)||0)+1)}const C=new Map;for(const P of N.models){const D=`${P.providerID}:${P.modelID}`,F=k.get(D)||1,B=(C.get(D)||0)+1;C.set(D,B);const E=X2(P.providerID,P.modelID),_=r.length>1?`g${j+1}`:void 0,W=F>1?Ld(f,`${E}/${B}`):Ld(f,E),V=_?`${_}/${W}`:W,K=bj({groupSlug:f,runGroup:_,providerID:P.providerID,modelID:P.modelID,index:F>1?B:void 0});try{if(!h){const z=await Xs.withDirectory(d,()=>Xs.createSession({title:K}));_d(z,d),S.push({sessionId:z.id,worktreePath:d,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:A});continue}const y=await Tp(a,{preferredName:V,mode:"new",branchName:V,worktreeName:V,startRef:e.worktreeBaseBranch||"HEAD",setupCommands:v,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:b}),I={...y,createdFromBranch:g,kind:"standard"};await Ip(a)&&await Rp(y.path);const $=await Xs.withDirectory(y.path,()=>Xs.createSession({title:K}));_d($,y.path),Je.getState().setWorktreeMetadata($.id,I),S.push({sessionId:$.id,worktreePath:y.path,providerID:P.providerID,modelID:P.modelID,variant:P.variant,prompt:A})}catch(y){console.warn("[MultiRun] Failed to create session:",y)}}}const p=c?.filter(j=>j.trim().length>0)??[];p.length>0&&Mp(a,p).catch(()=>{console.warn("[MultiRun] Failed to save worktree setup commands")});const m=S.map(j=>j.sessionId),x=S[0]?.sessionId??null;if(m.length===0)return t({error:"Failed to create any sessions",isLoading:!1}),null;const w=i?.map(j=>({type:"file",mime:j.mime,filename:j.filename,url:j.url}));return(async()=>{try{const j=Op.getState().expandText;await Promise.allSettled(S.map(async N=>{try{const A=await j(N.prompt).catch(()=>N.prompt);await Fp({sessionId:N.sessionId,directory:N.worktreePath,content:A,providerID:N.providerID,modelID:N.modelID,variant:N.variant,agent:o,files:w})}catch(A){console.warn("[MultiRun] Failed to start run:",A)}}))}catch(j){console.warn("[MultiRun] Failed to start runs:",j)}})(),t({isLoading:!1}),{groupSlug:f,sessionIds:m,firstSessionId:x}}catch(a){return t({error:a instanceof Error?a.message:"Failed to create Multi-Run",isLoading:!1}),null}},clearError:()=>{t({error:null})}}),{name:"multirun-store"}));function Gf(t){const e=tt.c(30),{git:n}=tr(),r=xu(t),o=Lp(t),i=_p(t),c=$p(t),a=mr(rk),d=mr(nk);let u,h;e[0]!==t||e[1]!==d||e[2]!==n||e[3]!==o||e[4]!==i?(u=()=>{!t||!n||o!==null||i||d(t,n,{silent:!0})},h=[t,n,d,o,i],e[0]=t,e[1]=d,e[2]=n,e[3]=o,e[4]=i,e[5]=u,e[6]=h):(u=e[5],h=e[6]),l.useEffect(u,h);let f;e[7]!==r?.all||e[8]!==t||e[9]!==a||e[10]!==n||e[11]!==o?(f=()=>{!t||!n||o===!0&&(r?.all||a(t,n))},e[7]=r?.all,e[8]=t,e[9]=a,e[10]=n,e[11]=o,e[12]=f):f=e[12];const g=r?.all;let b;e[13]!==t||e[14]!==a||e[15]!==n||e[16]!==o||e[17]!==g?(b=[t,n,o,g,a],e[13]=t,e[14]=a,e[15]=n,e[16]=o,e[17]=g,e[18]=b):b=e[18],l.useEffect(f,b);const S=i||o===!0&&c;let v;e:{if(!r?.all){let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[19]=k):k=e[19],v=k;break e}let A;e[20]!==r.all?(A=r.all.filter(sk).sort(),e[20]=r.all,e[21]=A):A=e[21],v=A}const p=v;let m;e:{if(!r?.all){let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=[],e[22]=k):k=e[22],m=k;break e}let A;e[23]!==r.all?(A=r.all.filter(tk).map(ek).sort(),e[23]=r.all,e[24]=A):A=e[24],m=A}const x=m;let w;e:{if(!t){w=null;break e}if(o!==null){w=o;break e}if(S){w=null;break e}w=r?.all?!0:null}const j=w;let N;return e[25]!==j||e[26]!==S||e[27]!==p||e[28]!==x?(N={localBranches:p,remoteBranches:x,isLoading:S,isGitRepository:j},e[25]=j,e[26]=S,e[27]=p,e[28]=x,e[29]=N):N=e[29],N}function ek(t){return t.replace(/^remotes\//,"")}function tk(t){return t.startsWith("remotes/")}function sk(t){return!t.startsWith("remotes/")}function nk(t){return t.fetchStatus}function rk(t){return t.fetchBranches}const ok=({directory:t,value:e,onChange:n,className:r,disabled:o,id:i})=>{const{t:c}=mt(),{localBranches:a,remoteBranches:d,isLoading:u,isGitRepository:h}=Gf(t),f=l.useMemo(()=>[...a,...d.map(b=>`remotes/${b}`)],[a,d]);l.useEffect(()=>{if(o||u||f.length===0||e&&f.includes(e))return;const b=e;let S=!1;return(async()=>{try{const p=t?await $i(t).catch(()=>null):null;if(S)return;const m=localStorage.getItem(bc),{sourceBranch:x,shouldClearSavedSourceBranch:w}=Rg({branches:f,savedSourceBranch:m,rootBranch:p});if(w&&localStorage.removeItem(bc),S||b&&f.includes(b))return;x&&n(x)}catch{}})(),()=>{S=!0}},[f,t,o,u,n,e]);const g=o||!h||u;return s.jsxs("div",{children:[s.jsxs(Ls,{value:e,onValueChange:n,disabled:g,children:[s.jsx(_s,{id:i,size:"lg",className:ye("min-w-0 max-w-full *:data-[slot=select-value]:truncate",r??"w-fit"),children:s.jsx(Ds,{placeholder:c(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:c("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:c("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[a.length>0&&s.jsxs(Ma,{children:[s.jsx(cc,{className:"font-semibold text-foreground",children:c("multiRun.branchSelector.groups.localBranches")}),a.map(b=>s.jsx(rs,{value:b,className:"whitespace-normal break-all",children:b},b))]}),a.length>0&&d.length>0&&s.jsx(zp,{}),d.length>0&&s.jsxs(Ma,{children:[s.jsx(cc,{className:"font-semibold text-foreground",children:c("multiRun.branchSelector.groups.remoteBranches")}),d.map(b=>s.jsx(rs,{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:c("multiRun.branchSelector.status.notInGitRepository")})]})},ik=10*1024*1024,Ca=5,hi=t=>{const e=tt.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(ut,{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(R,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let o;return e[1]!==n?(o=s.jsxs(dt,{children:[r,s.jsx(ft,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=o):o=e[2],o},Mr=t=>{const e=tt.c(9),{htmlFor:n,required:r,children:o,info:i}=t;let c;e[0]!==r?(c=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=c):c=e[1];let a;e[2]!==o||e[3]!==n||e[4]!==c?(a=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[o,c]}),e[2]=o,e[3]=n,e[4]=c,e[5]=a):a=e[5];const d=i&&i;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},$d=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:o}=mt(),[i,c]=l.useState(""),[a,d]=l.useState(()=>[{id:jo(),prompt:"",models:[]}]),[u,h]=l.useState(""),[f,g]=l.useState([]),[b,S]=l.useState(!1),[v,p]=l.useState([]),[m,x]=l.useState(!1),[w,j]=l.useState(!1),[N,A]=l.useState(!0),k=l.useRef(null),C=ls(H=>H.currentDirectory??null),P=ls(H=>H.homeDirectory??null),D=l.useMemo(()=>{if(typeof window>"u")return null;const H=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof H=="string"&&H.trim().length>0?H.trim():null},[]),F=qt(H=>H.activeProjectId),B=qt(H=>H.setActiveProjectIdOnly),E=qt(H=>H.projects),[_,W]=l.useState(()=>F??null);l.useEffect(()=>{if(F){W(F);return}!_&&E.length>0&&W(E[0].id)},[F,E,_]);const V=l.useMemo(()=>_?E.find(H=>H.id===_)??null:null,[E,_]),K=V?.path??C,y=l.useCallback(H=>{W(H),H!==F&&B(H)},[F,B]),{currentTheme:I}=_r(),$=l.useCallback(H=>{const ge=H.label?.trim()||hr(H.path,P),ue=H.icon?fl[H.icon]:null,M=H.color?ml[H.color]:void 0,oe=ue?s.jsx(R,{name:ue,className:"h-3.5 w-3.5 shrink-0",style:M?{color:M}:void 0}):s.jsx(R,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:M?{color:M}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[H.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:H.iconBackground?{backgroundColor:H.iconBackground}:void 0,children:s.jsx(hl,{project:{id:H.id,iconImage:H.iconImage??null},options:{themeVariant:I.metadata.variant,iconColor:I.colors.surface.foreground},className:"h-full w-full object-contain",fallback:oe})}):oe,s.jsx("span",{className:"truncate",children:ge})]})},[P,I.metadata.variant,I.colors.surface.foreground]),z=l.useMemo(()=>{if(V?.path)return{id:V.id,path:V.path};const H=C??D;return H?{id:`path:${H}`,path:H}:null},[V,C,D]),[G]=l.useState(()=>typeof window<"u"?$n():!1),J=l.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),Z=cu(),re=l.useMemo(()=>{if(typeof window>"u")return null;const H=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof H=="number"&&Number.isFinite(H)&&H>0)return H;if(typeof navigator>"u")return null;const ge=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!ge)return null;const ue=Number.parseInt(ge[1],10),M=Number.parseInt(ge[2],10);return Number.isNaN(ue)?null:ue===10?M:ue},[]),ee=l.useMemo(()=>G&&J||Z?"pl-[5.5rem]":"pl-3",[G,J,Z]),he=l.useMemo(()=>!G||!J||re===null?"":re>=26?"h-12":re<=15?"h-14":"",[G,J,re]),be=l.useCallback(async H=>{H.target.closest("button, a, input, select, textarea")||H.button===0&&G&&await Up()},[G]);l.useEffect(()=>{if(!n)return;const H=ge=>{ge.key==="Escape"&&(ge.preventDefault(),ge.stopPropagation(),n())};return window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)},[n]);const[Y,we]=l.useState(""),{isLoading:me,isGitRepository:Q}=Gf(K),pe=l.useRef(!1),ve=Q===!0,Te=ve&&N;l.useEffect(()=>{if(Q===!1){pe.current=!0,A(!1);return}Q===!0&&pe.current&&(pe.current=!1,A(!0))},[Q]);const ke=ka(H=>H.createMultiRun),Ie=ka(H=>H.error),Ne=ka(H=>H.clearError);l.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&d(H=>{const ge=[...H];return ge.length>0&&!ge[0].prompt.trim()&&(ge[0]={...ge[0],prompt:t}),ge})},[t]),l.useEffect(()=>{if(!z)return;let H=!1;return j(!0),(async()=>{try{const ge=await Wp(z);H||p(ge)}catch{}finally{H||j(!1)}})(),()=>{H=!0}},[z]);const Ae=l.useCallback((H,ge)=>{d(ue=>ue.map(M=>M.id===H?{...M,...ge}:M))},[]),Se=l.useCallback(H=>{d(ge=>ge.filter(ue=>ue.id!==H))},[]),Oe=l.useCallback(()=>{d(H=>[...H,{id:jo(),prompt:"",models:[]}])},[]),ne=async H=>{const ge=H.target.files;if(!ge)return;let ue=0;for(let M=0;M<ge.length;M++){const oe=ge[M];if(oe.size>ik){Ee.error(o("multirun.launcher.toast.fileTooLarge",{fileName:oe.name}));continue}try{const De=await new Promise((fe,X)=>{const le=new FileReader;le.onload=()=>fe(le.result),le.onerror=X,le.readAsDataURL(oe)});g(fe=>[...fe,{id:jo(),filename:oe.name,mimeType:oe.type||"application/octet-stream",size:oe.size,dataUrl:De}]),ue++}catch(De){console.error("File attach failed",De),Ee.error(o("multirun.launcher.toast.attachFailed",{fileName:oe.name}))}}ue>0&&Ee.success(ue===1?o("multirun.launcher.toast.attachedSingle",{count:ue}):o("multirun.launcher.toast.attachedPlural",{count:ue})),k.current&&(k.current.value="")},ce=H=>{g(ge=>ge.filter(ue=>ue.id!==H))},Re=l.useMemo(()=>a.reduce((H,ge)=>H+ge.models.length,0),[a]),te=async H=>{H.preventDefault();const ge=a.filter(ue=>ue.prompt.trim()&&ue.models.length>=1);if(ge.length!==0&&!(Re<1)){S(!0),Ne();try{_&&_!==F&&B(_);const ue=f.map(X=>({mime:X.mimeType,filename:X.filename,url:X.dataUrl})),M=v.filter(X=>X.trim().length>0),oe=ge.map(X=>({prompt:X.prompt.trim(),models:X.models.map(le=>({providerID:le.providerID,modelID:le.modelID,displayName:le.displayName,variant:le.variant}))})),De={name:i.trim(),groups:oe,agent:u||void 0,worktreeBaseBranch:Te?Y:void 0,isolateRuns:Te,files:ue.length>0?ue:void 0,setupCommands:M.length>0?M:void 0},fe=await ke(De);fe&&(fe.firstSessionId&&Je.getState().setCurrentSession(fe.firstSessionId),e?.())}finally{S(!1)}}},ae=!!(i.trim()&&a.some(H=>H.prompt.trim()&&H.models.length>=1)&&Re>=1&&K&&!me&&(Q===!1||!Te||Y)),de=v.filter(H=>H.trim()).length;return s.jsxs("form",{onSubmit:te,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:be,className:ye("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",ee,he),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:o("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":o("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-primary app-region-no-drag",children:s.jsx(R,{name:"close",className:"h-5 w-5"})})}),s.jsx(ft,{children:s.jsx("p",{children:o("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(ll,{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(Mr,{htmlFor:"multirun-project",required:!0,children:o("multirun.launcher.project.label")}),E.length>0?s.jsxs(Ls,{value:_??void 0,onValueChange:y,children:[s.jsx(_s,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:V?s.jsx(Ds,{children:$(V)}):s.jsx(Ds,{placeholder:o("multirun.launcher.project.placeholder")})}),s.jsx($s,{fitContent:!0,children:E.map(H=>s.jsx(rs,{value:H.id,className:"max-w-[24rem]",children:$(H)},H.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:o("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Mr,{htmlFor:"group-name",required:!0,info:s.jsx(hi,{children:o("multirun.launcher.groupName.info")}),children:o("multirun.launcher.groupName.label")}),s.jsx(Jn,{id:"group-name",value:i,onChange:H=>c(H.target.value),placeholder:o("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Mr,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(hi,{children:o("multirun.launcher.baseBranch.info")}),children:o("multirun.launcher.baseBranch.label")}),s.jsx(ok,{directory:K,value:Y,onChange:we,disabled:!Te,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(qr,{checked:N,onChange:A,disabled:!ve,ariaLabel:o("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:o("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Mr,{htmlFor:"multirun-agent",info:s.jsx(hi,{children:o("multirun.launcher.agent.info")}),children:o("multirun.launcher.agent.label")}),s.jsx(Wf,{value:u,onChange:h,id:"multirun-agent"})]})]}),s.jsxs(yi,{open:m,onOpenChange:x,children:[s.jsxs(xl,{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(R,{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:o("multirun.launcher.setupCommands.label")}),de>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:de}),s.jsx(R,{name:"arrow-down-s",className:ye("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",m&&"rotate-180")})]}),s.jsx(vi,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:w?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:o("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[v.map((H,ge)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(Jn,{value:H,onChange:ue=>{const M=[...v];M[ge]=ue.target.value,p(M)},placeholder:o("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>p(v.filter((ue,M)=>M!==ge)),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-primary/50","aria-label":o("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(R,{name:"close",className:"h-3.5 w-3.5"})})]},`${H}-${ge}`)),s.jsxs("button",{type:"button",onClick:()=>p([...v,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(R,{name:"add",className:"h-3 w-3"}),o("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Mr,{htmlFor:"prompt",required:!0,children:o("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:k,type:"file",multiple:!0,className:"hidden",onChange:ne,accept:"*/*"}),s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>k.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(R,{name:"attachment-2",className:"h-3 w-3"}),o("multirun.launcher.attachments.attach")]})}),s.jsx(ft,{children:o("multirun.launcher.attachments.tooltip")})]}),f.map(H=>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:[H.mimeType.startsWith("image/")?s.jsx(R,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(R,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:H.filename,children:H.filename}),s.jsx("button",{type:"button",onClick:()=>ce(H.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(R,{name:"close",className:"h-3 w-3"})})]},H.id))]})]}),a.map((H,ge)=>s.jsx(ak,{group:H,groupIndex:ge,canRemove:a.length>1,onUpdate:Ae,onRemove:Se},H.id)),s.jsxs("button",{type:"button",onClick:Oe,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(R,{name:"add",className:"h-3.5 w-3.5"}),o("multirun.launcher.groups.addGroup")]}),Ie&&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:Ie})]})})}),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:[!Te&&Q!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(R,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:o("multirun.launcher.project.gitRequired")})]}):null,!r&&n?s.jsx(nt,{type:"button",variant:"ghost",size:"sm",onClick:n,children:o("multirun.launcher.actions.cancel")}):null,s.jsx(nt,{type:"submit",size:"sm",disabled:!ae||b,children:b?o("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:o("multirun.launcher.actions.startWithRunCount",{count:Re})})})]})})]})},ak=t=>{const e=tt.c(99),{group:n,groupIndex:r,canRemove:o,onUpdate:i,onRemove:c}=t,{t:a}=mt(),[d,u]=l.useState(!1),[h,f]=l.useState(""),[g,b]=l.useState(!1),[S,v]=l.useState(""),[p,m]=l.useState(!1),[x,w]=l.useState(""),j=l.useRef(null),N=l.useRef(null),A=l.useRef(null),k=l.useRef(null);let C;e[0]!==n.id||e[1]!==n.models||e[2]!==i?(C=M=>{n.models.length>=Ca||i(n.id,{models:[...n.models,M]})},e[0]=n.id,e[1]=n.models,e[2]=i,e[3]=C):C=e[3];const P=C;let D;e[4]!==n.id||e[5]!==n.models||e[6]!==i?(D=M=>{i(n.id,{models:n.models.filter((oe,De)=>De!==M)})},e[4]=n.id,e[5]=n.models,e[6]=i,e[7]=D):D=e[7];const F=D;let B;e[8]!==n.id||e[9]!==n.models||e[10]!==i?(B=(M,oe)=>{i(n.id,{models:n.models.map((De,fe)=>fe===M?oe:De)})},e[8]=n.id,e[9]=n.models,e[10]=i,e[11]=B):B=e[11];const E=B;let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=(M,oe)=>{if(M.startsWith("/")){const le=M.indexOf(" "),se=M.indexOf(`
|
|
912
912
|
`),T=Math.min(le===-1?M.length:le,se===-1?M.length:se);if(oe<=T&&le===-1){v(M.substring(1,T)),b(!0),u(!1),m(!1);return}}b(!1);const De=M.substring(0,oe),fe=De.lastIndexOf("#");if(fe!==-1){const le=fe>0?De[fe-1]:null,se=De.substring(fe+1);if((!le||/\s/.test(le))&&!se.includes(" ")&&!se.includes(`
|
|
913
913
|
`)){w(se),m(!0),u(!1);return}}m(!1);const X=De.lastIndexOf("@");if(X!==-1){const le=X>0?De[X-1]:null,se=De.substring(X+1);(!le||/\s/.test(le))&&!se.includes(" ")&&!se.includes(`
|
|
914
|
-
`)?(f(se),u(!0)):u(!1);return}u(!1)},e[12]=_):_=e[12];const W=_;let V;e[13]!==n.id||e[14]!==i?(V=M=>{i(n.id,{prompt:M})},e[13]=n.id,e[14]=i,e[15]=V):V=e[15];const K=V;let y;e[16]!==n.prompt||e[17]!==K?(y=M=>{const oe=n.prompt,fe=j.current?.selectionStart??oe.length,le=oe.substring(0,fe).lastIndexOf("@"),se=M.relativePath&&M.relativePath.trim().length>0?M.relativePath.trim():M.path||M.name,T=le!==-1?le:fe,ie=`${oe.substring(0,T)}@${se} ${oe.substring(fe)}`,je=T+se.length+2;K(ie),u(!1),f(""),requestAnimationFrame(()=>{const Pe=j.current;Pe&&(Pe.selectionStart=je,Pe.selectionEnd=je,Pe.focus()),W(ie,je)})},e[16]=n.prompt,e[17]=K,e[18]=y):y=e[18];const I=y;let $;e[19]!==n.prompt||e[20]!==K?($=M=>{const oe=n.prompt,fe=j.current?.selectionStart??oe.length,le=oe.substring(0,fe).lastIndexOf("@"),se=le!==-1?le:fe,T=`${oe.substring(0,se)}@${M} ${oe.substring(fe)}`,ie=se+M.length+2;K(T),u(!1),f(""),requestAnimationFrame(()=>{const je=j.current;je&&(je.selectionStart=ie,je.selectionEnd=ie,je.focus()),W(T,ie)})},e[19]=n.prompt,e[20]=K,e[21]=$):$=e[21];const z=$;let G;e[22]!==K?(G=M=>{const oe=`/${M.name} `;K(oe),b(!1),v(""),m(!1),requestAnimationFrame(()=>{const De=j.current;De&&(De.focus(),De.selectionStart=De.value.length,De.selectionEnd=De.value.length),W(oe,oe.length)})},e[22]=K,e[23]=G):G=e[23];const J=G;let Z;e[24]!==n.prompt||e[25]!==K?(Z=(M,oe)=>{const De=n.prompt,X=j.current?.selectionStart??De.length,se=De.substring(0,X).lastIndexOf("#"),T=se!==-1?se:X,ie=`${De.substring(0,T)}#${oe} ${De.substring(X)}`,je=T+oe.length+2;K(ie),m(!1),w(""),requestAnimationFrame(()=>{const Pe=j.current;Pe&&(Pe.selectionStart=je,Pe.selectionEnd=je,Pe.focus()),W(ie,je)})},e[24]=n.prompt,e[25]=K,e[26]=Z):Z=e[26];const re=Z;let ee;e[27]!==g||e[28]!==d||e[29]!==p?(ee=M=>{if(g&&A.current&&(M.key==="Enter"||M.key==="ArrowUp"||M.key==="ArrowDown"||M.key==="Escape"||M.key==="Tab")){M.preventDefault(),A.current.handleKeyDown(M.key);return}d&&N.current&&(M.key==="Enter"||M.key==="ArrowUp"||M.key==="ArrowDown"||M.key==="Escape"||M.key==="Tab")&&(M.preventDefault(),N.current.handleKeyDown(M.key)),p&&k.current&&(M.key==="Enter"||M.key==="ArrowUp"||M.key==="ArrowDown"||M.key==="Escape"||M.key==="Tab")&&(M.preventDefault(),k.current.handleKeyDown(M.key))},e[27]=g,e[28]=d,e[29]=p,e[30]=ee):ee=e[30];const he=ee,be=r+1;let Y;e[31]!==a||e[32]!==be?(Y=a("multirun.launcher.groups.groupLabel",{index:be}),e[31]=a,e[32]=be,e[33]=Y):Y=e[33];let we;e[34]!==Y?(we=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:Y}),e[34]=Y,e[35]=we):we=e[35];let me;e[36]!==o||e[37]!==n.id||e[38]!==c||e[39]!==a?(me=o&&s.jsx("button",{type:"button",onClick:()=>c(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(R,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=o,e[37]=n.id,e[38]=c,e[39]=a,e[40]=me):me=e[40];let Q;e[41]!==we||e[42]!==me?(Q=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[we,me]}),e[41]=we,e[42]=me,e[43]=Q):Q=e[43];let pe;e[44]!==a?(pe=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=pe):pe=e[45];let ve;e[46]!==pe?(ve=s.jsx(Mr,{required:!0,children:pe}),e[46]=pe,e[47]=ve):ve=e[47];const Te=n.prompt;let ke;e[48]!==K?(ke=M=>{const oe=M.target.value;K(oe);const De=M.target.selectionStart??oe.length;W(oe,De)},e[48]=K,e[49]=ke):ke=e[49];let Ie;e[50]!==a?(Ie=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=Ie):Ie=e[51];let Ne;e[52]!==n.prompt||e[53]!==he||e[54]!==ke||e[55]!==Ie?(Ne=s.jsx(Kr,{ref:j,value:Te,onChange:ke,onKeyDown:he,placeholder:Ie,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]=he,e[54]=ke,e[55]=Ie,e[56]=Ne):Ne=e[56];let Ae;e[57]!==S||e[58]!==J||e[59]!==g?(Ae=g?s.jsx(Ru,{ref:A,searchQuery:S,onCommandSelect:J,onClose:()=>b(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=S,e[58]=J,e[59]=g,e[60]=Ae):Ae=e[60];let Se;e[61]!==z||e[62]!==I||e[63]!==h||e[64]!==d?(Se=d?s.jsx(Mu,{ref:N,searchQuery:h,onFileSelect:I,onAgentSelect:z,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=z,e[62]=I,e[63]=h,e[64]=d,e[65]=Se):Se=e[65];let Oe;e[66]!==re||e[67]!==p||e[68]!==x?(Oe=p?s.jsx(Ou,{ref:k,searchQuery:x,onSnippetSelect:re,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=re,e[67]=p,e[68]=x,e[69]=Oe):Oe=e[69];let ne;e[70]!==Ne||e[71]!==Ae||e[72]!==Se||e[73]!==Oe?(ne=s.jsxs("div",{className:"relative",children:[Ne,Ae,Se,Oe]}),e[70]=Ne,e[71]=Ae,e[72]=Se,e[73]=Oe,e[74]=ne):ne=e[74];let ce;e[75]!==ve||e[76]!==ne?(ce=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ve,ne]}),e[75]=ve,e[76]=ne,e[77]=ce):ce=e[77];let Re;e[78]!==a?(Re=a("multirun.launcher.models.info",{max:Ca}),e[78]=a,e[79]=Re):Re=e[79];let te;e[80]!==Re?(te=s.jsx(hi,{children:Re}),e[80]=Re,e[81]=te):te=e[81];let ae;e[82]!==a?(ae=a("multirun.launcher.models.label"),e[82]=a,e[83]=ae):ae=e[83];let de;e[84]!==te||e[85]!==ae?(de=s.jsx(Mr,{required:!0,info:te,children:ae}),e[84]=te,e[85]=ae,e[86]=de):de=e[86];let H;e[87]!==n.models||e[88]!==P||e[89]!==F||e[90]!==E?(H=s.jsx(Vf,{selectedModels:n.models,onAdd:P,onRemove:F,onUpdate:E,minModels:1,maxModels:Ca}),e[87]=n.models,e[88]=P,e[89]=F,e[90]=E,e[91]=H):H=e[91];let ge;e[92]!==de||e[93]!==H?(ge=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[de,H]}),e[92]=de,e[93]=H,e[94]=ge):ge=e[94];let ue;return e[95]!==Q||e[96]!==ce||e[97]!==ge?(ue=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[Q,ce,ge]}),e[95]=Q,e[96]=ce,e[97]=ge,e[98]=ue):ue=e[98],ue},lk=l.createContext(null),ck=t=>{const e=tt.c(3),{children:n,value:r}=t;let o;return e[0]!==n||e[1]!==r?(o=s.jsx(lk.Provider,{value:r,children:n}),e[0]=n,e[1]=r,e[2]=o):o=e[2],o},dk=Zs(()=>Js(()=>import("./PlanView-CWM0iyFk.js"),__vite__mapDeps([134,1,2,4,5,6,7,8,123,50,51,52,53,54,55,72,48,49,56,124,125,3,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,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,73,74,75,76,77,78,79,80,112,113,131,114,115,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(t=>({default:t.PlanView}))),zd=Zs(()=>Js(()=>import("./GitView-C-n17voy.js"),__vite__mapDeps([132,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,113,133,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,114,115,117,118,119,120])).then(t=>({default:t.GitView}))),uk=Zs(()=>Js(()=>import("./DiffView-DEGlNjMH.js"),__vite__mapDeps([121,1,2,4,5,6,7,8,3,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])).then(t=>({default:t.DiffView}))),fk=Zs(()=>Js(()=>import("./FilesView-CzUgIvUm.js"),__vite__mapDeps([122,1,2,4,5,6,7,8,3,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,113,123,124,125,126,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,127,128,114,115,129,130,112,131,118])).then(t=>({default:t.FilesView}))),mk=Zs(()=>Js(()=>import("./DiagramView-CndEcZNu.js"),__vite__mapDeps([135,1,2,4,5,6,7,8,3,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,129,130])).then(t=>({default:t.DiagramView}))),hk=Zs(()=>Js(()=>import("./SettingsView-Bl1drwPw.js").then(t=>t.a),__vite__mapDeps([136,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,113,137,123,124,125,114,115,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98,138,139])).then(t=>({default:t.SettingsView}))),pk=Zs(()=>Js(()=>import("./SettingsWindow-DL5axjDZ.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,136,113,137,123,124,125,114,115,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98,138,139])).then(t=>({default:t.SettingsWindow}))),gk=()=>{const t=xe(y=>y.isSidebarOpen),e=xe(y=>y.activeMainTab),n=xe(y=>y.setIsMobile),r=xe(y=>y.isSessionSwitcherOpen),o=xe(y=>y.isSettingsDialogOpen),i=xe(y=>y.setSettingsDialogOpen),[c,a]=l.useState(!1);l.useEffect(()=>{o&&a(!0)},[o]);const d=xe(y=>y.isMultiRunLauncherOpen),u=xe(y=>y.setMultiRunLauncherOpen),h=xe(y=>y.multiRunLauncherPrefillPrompt),f=xe(y=>y.isScheduledTasksDialogOpen),g=xe(y=>y.isArchivePageOpen),b=xe(y=>y.worktreesPageProjectId),S=f||g||!!b||d;l.useEffect(()=>{const y=()=>xe.getState().closeMainSurfaces(),I=Je.subscribe((z,G)=>{const J=!!z.currentSessionId&&z.currentSessionId!==G.currentSessionId,Z=!!z.newSessionDraft?.open&&z.newSessionDraft!==G.newSessionDraft;(J||Z)&&y()}),$=xe.subscribe((z,G)=>{z.activeMainTab!==G.activeMainTab&&y()});return()=>{I(),$()}},[]);const{isMobile:v}=pr(),p=l.useRef(!1),[m,x]=l.useState(!1),[w,j]=l.useState(!1),[N,A]=l.useState(!1),[k,C]=l.useState(!1),P=l.useCallback(y=>{x(y),xe.getState().setSessionSwitcherOpen(y)},[]),D=l.useRef(typeof window>"u"?0:window.innerWidth),F=jc(-D.current),B=Ge.useRef(0),E=jc(D.current),_=Ge.useRef(0);Ge.useEffect(()=>{v&&(B.current=window.innerWidth,_.current=window.innerWidth)},[v]),Ge.useEffect(()=>{if(!v){A(!1);return}m&&A(!0),kc(F,m?0:-B.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[m,v,F]),Ge.useEffect(()=>{if(!v){C(!1);return}w&&C(!0),kc(E,w?0:_.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[v,w,E]),Ge.useEffect(()=>{if(v)return F.on("change",y=>{const I=B.current||D.current,$=m||y>-I+.5;A(z=>z===$?z:$)})},[v,F,m]),Ge.useEffect(()=>{if(v)return E.on("change",y=>{const I=_.current||D.current,$=w||y<I-.5;C(z=>z===$?z:$)})},[v,w,E]),Ge.useEffect(()=>{v&&!r&&m&&P(!1)},[r,v,m,P]),Ge.useEffect(()=>{if(!v){p.current=!1;return}p.current||(p.current=!0,P(!1),j(!1))},[v,P]),Ge.useEffect(()=>{if(!v||e!=="chat"||m||w||o)return;let y=!1,I;const $=z=>{I=window.setTimeout(()=>{if(y)return;const G=Je.getState(),J=xe.getState();if(!(J.activeMainTab!=="chat"||J.isSettingsDialogOpen||G.currentSessionId||G.newSessionDraft?.open)){if(G.isLoading){$(250);return}G.openNewSessionDraft({automatic:!0})}},z)};return $(500),()=>{y=!0,I!==void 0&&window.clearTimeout(I)}},[e,v,o,m,w]),Ge.useEffect(()=>{!v||!o||(P(!1),j(!1))},[v,o,P]),Mg(),l.useEffect(()=>{xe.getState().isMobile!==v&&n(v)},[v,n]);const W=l.useCallback(()=>{m&&P(!1),j(!w)},[m,w,P]),V=l.useMemo(()=>{if(!v&&e!=="terminal"&&e!=="diagram")return null;switch(e){case"plan":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(dk,{})});case"git":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(zd,{isActive:!w})});case"diff":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(uk,{})});case"terminal":return s.jsx(Vu,{});case"files":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(fk,{})});case"context":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(Wu,{})});case"diagram":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(mk,{})});default:return null}},[e,v,w]),K=e==="chat";return s.jsx(Og,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:ye("main-content-safe-area",v?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[s.jsx(y1,{}),s.jsx(iS,{}),s.jsx(dS,{}),s.jsx(f2,{}),v?s.jsxs(ck,{value:{leftDrawerOpen:m,rightDrawerOpen:w,toggleLeftDrawer:()=>{const y=!m;w&&j(!1),P(y)},toggleRightDrawer:W,leftDrawerX:F,rightDrawerX:E,leftDrawerWidth:B,rightDrawerWidth:_,setMobileLeftDrawerOpen:P,setRightSidebarOpen:j},children:[!o&&s.jsx(Ec,{onToggleLeftDrawer:()=>{const y=!m;w&&j(!1),P(y)},onToggleRightDrawer:()=>{W()},leftDrawerOpen:m,rightDrawerOpen:w}),s.jsx("div",{"data-page-scroll-lock":"true",className:ye("flex flex-1 overflow-hidden relative",o&&"hidden"),children:s.jsxs("main",{className:"w-full h-full overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:ye("absolute inset-0",(!K||S)&&"invisible"),children:s.jsx(cs,{children:s.jsx(Fa,{active:K&&!o&&!S})})}),V&&s.jsx("div",{className:ye("absolute inset-0",S&&"invisible"),children:s.jsx(cs,{children:V})}),d&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(cs,{children:s.jsx($d,{initialPrompt:h,onCreated:()=>u(!1),onCancel:()=>u(!1)})})}),s.jsx(cs,{children:s.jsx(Od,{})}),s.jsx(cs,{children:s.jsx(Fd,{})}),s.jsx(cs,{children:s.jsx(Bd,{})}),s.jsx(Cc.div,{className:ye("absolute inset-0 z-20 bg-sidebar",!N&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:F},"aria-hidden":!m,children:s.jsx(cs,{children:s.jsx(jd,{mobileVariant:!0,isVisible:N})})}),k&&s.jsx(Cc.div,{className:"absolute inset-0 z-20 bg-sidebar","data-page-scroll-lock":"true",style:{x:E},"aria-hidden":!w,children:s.jsx(cs,{children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(zd,{isActive:w})})})})]})}),o&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:s.jsx(cs,{children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(hk,{onClose:()=>i(!1)})})})})]}):s.jsxs(s.Fragment,{children:[s.jsx(cb,{}),s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[s.jsx(ib,{isOpen:t,isMobile:v,className:"border-border",topBar:s.jsx(ab,{}),children:s.jsx(jd,{isVisible:t})}),s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[s.jsx(Ec,{}),s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[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:[s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:ye("absolute inset-0",(!K||S)&&"invisible"),children:s.jsx(cs,{children:s.jsx(Fa,{active:K&&!o&&!S})})}),V&&s.jsx("div",{className:ye("absolute inset-0",S&&"invisible"),children:s.jsx(cs,{children:V})}),d&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(cs,{children:s.jsx($d,{isWindowed:!0,initialPrompt:h,onCreated:()=>u(!1),onCancel:()=>u(!1)})})}),s.jsx(cs,{children:s.jsx(Od,{})}),s.jsx(cs,{children:s.jsx(Fd,{})}),s.jsx(cs,{children:s.jsx(Bd,{})})]}),s.jsx(Zw,{})]})})}),s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(cs,{children:s.jsx(o1,{})})})]})]})]}),c?s.jsx(l.Suspense,{fallback:null,children:s.jsx(pk,{open:o,onOpenChange:i})}):null]})]})})},qf=12,xk=[{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"}],bk=t=>{const e=tt.c(18),{isActive:n,burstKey:r,className:o,durationMs:i,bursts:c,onComplete:a}=t,d=r===void 0?0:r,u=i===void 0?900:i,h=c===void 0?xk:c,f=Ge.useRef(!1);let g,b;e[0]!==n||e[1]!==a?(g=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},b=[n,a],e[0]=n,e[1]=a,e[2]=g,e[3]=b):(g=e[2],b=e[3]),Ge.useEffect(g,b);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=Array.from({length:qf},yk),e[4]=S):S=e[4];const v=S;if(!n)return null;let p;e[5]!==o?(p=ye("fireworks-overlay pointer-events-none",o),e[5]=o,e[6]=p):p=e[6];let m;if(e[7]!==d||e[8]!==h||e[9]!==u){let w;e[11]!==d||e[12]!==u?(w=j=>{const N={"--burst-delay":`${j.delay}ms`,"--burst-x":`${j.x}%`,"--burst-y":`${j.y}%`,"--firework-color":`var(${j.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:v.map((A,k)=>{const C=A.x*j.radius,P=A.y*j.radius,D={"--translate-x":`${C}px`,"--translate-y":`${P}px`,"--particle-delay":`${A.delay}ms`,color:`var(${j.colorVar})`};return s.jsx("span",{className:"firework-particle",style:D},`${j.id}-${k}-${d}`)})},`${j.id}-${d}`)},e[11]=d,e[12]=u,e[13]=w):w=e[13],m=h.map(w),e[7]=d,e[8]=h,e[9]=u,e[10]=m}else m=e[10];let x;return e[14]!==d||e[15]!==p||e[16]!==m?(x=s.jsx("div",{className:p,"aria-hidden":"true","data-burst-key":d,children:m}),e[14]=d,e[15]=p,e[16]=m,e[17]=x):x=e[17],x};function yk(t,e){const n=Math.PI*2*e/qf;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const vk=t=>{const e=tt.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,o=r===void 0?3400:r;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={isActive:!1,cycle:0},e[2]=i):i=e[2];const[c,a]=Ge.useState(i),d=Ge.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(wk)},e[4]=f):f=e[4];const g=f;let b;e[5]!==o?(b=()=>{h(),a(Sk),d.current=window.setTimeout(()=>{a(jk),d.current=null},o)},e[5]=o,e[6]=b):b=e[6];const S=b;let v,p;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>h(),p=[h],e[7]=v,e[8]=p):(v=e[7],p=e[8]),Ge.useEffect(v,p);let m;return e[9]!==c.cycle||e[10]!==c.isActive||e[11]!==S?(m={isActive:c.isActive,burstKey:c.cycle,triggerFireworks:S,dismissFireworks:g},e[9]=c.cycle,e[10]=c.isActive,e[11]=S,e[12]=m):m=e[12],m};function wk(t){return t.isActive?{...t,isActive:!1}:t}function Sk(t){return{isActive:!0,cycle:t.cycle+1}}function jk(t){return t.isActive?{...t,isActive:!1}:t}const Yf=l.createContext(void 0),kk=t=>{const e=tt.c(10),{children:n}=t,{isActive:r,burstKey:o,triggerFireworks:i,dismissFireworks:c}=vk();let a;e[0]!==c||e[1]!==i?(a={triggerFireworks:i,dismissFireworks:c},e[0]=c,e[1]=i,e[2]=a):a=e[2];const d=a;let u;e[3]!==o||e[4]!==r?(u=s.jsx(bk,{isActive:r,burstKey:o}),e[3]=o,e[4]=r,e[5]=u):u=e[5];let h;return e[6]!==n||e[7]!==u||e[8]!==d?(h=s.jsxs(Yf.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=h):h=e[9],h},WC=()=>{const t=l.useContext(Yf);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Ck=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`},Is=t=>{const e=tt.c(8),{label:n,value:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=o):o=e[0];let i;e[1]!==n?(i=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=i):i=e[2];let c;e[3]!==r?(c=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=c):c=e[4];let a;return e[5]!==i||e[6]!==c?(a=s.jsxs("div",{className:"rounded-md p-2",style:o,children:[i,c]}),e[5]=i,e[6]=c,e[7]=a):a=e[7],a},Ud=t=>{const e=tt.c(43),{title:n,snapshot:r,emptyLabel:o}=t,{t:i}=mt();let c;if(e[0]!==o||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==i||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(Dk,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]!==i?(f=r.startedAt?Ck(r.durationMs):i("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=i,e[15]=f):f=e[15];let g;e[16]!==f?(g=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=g):g=e[17];let b;e[18]!==h||e[19]!==g?(b=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,g]}),e[18]=h,e[19]=g,e[20]=b):b=e[20];let S;e[21]!==i?(S=i("memoryDebugPanel.metric.metrics"),e[21]=i,e[22]=S):S=e[22];let v;e[23]!==r.entries.length||e[24]!==S?(v=s.jsx(Is,{label:S,value:r.entries.length}),e[23]=r.entries.length,e[24]=S,e[25]=v):v=e[25];let p;e[26]!==i?(p=i("memoryDebugPanel.metric.samples"),e[26]=i,e[27]=p):p=e[27];let m;e[28]!==p||e[29]!==u?(m=s.jsx(Is,{label:p,value:u}),e[28]=p,e[29]=u,e[30]=m):m=e[30];let x;e[31]!==i?(x=i("memoryDebugPanel.metric.lastUpdate"),e[31]=i,e[32]=x):x=e[32];let w;e[33]!==r.lastUpdatedAt||e[34]!==i?(w=r.lastUpdatedAt?i("memoryDebugPanel.common.live"):i("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=i,e[35]=w):w=e[35];let j;e[36]!==x||e[37]!==w?(j=s.jsx(Is,{label:x,value:w}),e[36]=x,e[37]=w,e[38]=j):j=e[38];let N;e[39]!==m||e[40]!==j||e[41]!==v?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[v,m,j]}),e[39]=m,e[40]=j,e[41]=v,e[42]=N):N=e[42],c=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[b,N,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:o}):s.jsx(Yn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(A=>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:A.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:i("memoryDebugPanel.metric.countValue",{value:A.count})}),s.jsx("span",{children:i("memoryDebugPanel.metric.avgValue",{value:A.avg})}),s.jsx("span",{children:i("memoryDebugPanel.metric.maxValue",{value:A.max})}),s.jsx("span",{children:i("memoryDebugPanel.metric.totalValue",{value:A.total})})]})]},A.metric))})})]}),e[0]=o,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=i,e[6]=n,e[7]=c}else c=e[7];return c},Nk=t=>{const e=tt.c(99),{onClose:n}=t,{t:r}=mt(),[o,i]=l.useState("memory"),[c,a]=l.useState("idle"),d=Je(Pk),u=Eu(Ek),h=bu(),f=Vp(Tk),g=hn(Ik),[b,S]=l.useState(Rk),[v,p]=l.useState(Mk);let m;e[0]!==b.entries?(m=new Map,b.entries.forEach(ae=>{m.set(ae.metric,ae.count)}),e[0]=b.entries,e[1]=m):m=e[1];let x;e[2]!==m?(x=m.get("ui.message_list.render")??0,e[2]=m,e[3]=x):x=e[3];let w;e[4]!==m?(w=m.get("ui.message_list.render.streaming")??0,e[4]=m,e[5]=w):w=e[5];let j;e[6]!==m?(j=m.get("ui.chat_message.render")??0,e[6]=m,e[7]=j):j=e[7];let N;e[8]!==m?(N=m.get("ui.chat_message.render.streaming")??0,e[8]=m,e[9]=N):N=e[9];let A;e[10]!==m?(A=m.get("ui.chat_message.render.static_during_stream")??0,e[10]=m,e[11]=A):A=e[11];let k;e[12]!==m?(k=m.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[12]=m,e[13]=k):k=e[13];let C;e[14]!==x||e[15]!==w||e[16]!==j||e[17]!==N||e[18]!==A||e[19]!==k?(C={messageListRender:x,messageListRenderStreaming:w,chatMessageRender:j,chatMessageRenderStreaming:N,chatMessageRenderStaticDuringStream:A,chatMessageRenderStaticOutsideActiveTurnDuringStream:k},e[14]=x,e[15]=w,e[16]=j,e[17]=N,e[18]=A,e[19]=k,e[20]=C):C=e[20];const P=C;let D,F;e[21]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{const ae=()=>{S(si()),p(ni())};ae();const de=window.setInterval(ae,500);return()=>window.clearInterval(de)},F=[],e[21]=D,e[22]=F):(D=e[21],F=e[22]),l.useEffect(D,F);let B,E;e[23]!==c?(B=()=>{if(c==="idle")return;const ae=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(ae)},E=[c],e[23]=c,e[24]=B,e[25]=E):(B=e[24],E=e[25]),l.useEffect(B,E);let _=0,W=0,V=0;for(const ae of Object.keys(f)){const de=f[ae]??[];W=W+de.length;for(const H of de)H.role==="user"?V=V+1:H.role==="assistant"&&(_=_+1)}let K;e[26]!==_||e[27]!==W||e[28]!==V?(K={assistant:_,total:W,user:V},e[26]=_,e[27]=W,e[28]=V,e[29]=K):K=e[29];const y=K;let I;if(e[30]!==d||e[31]!==f||e[32]!==u||e[33]!==h||e[34]!==r){let ae;e[36]!==d||e[37]!==f||e[38]!==u||e[39]!==r?(ae=de=>{const H=f[de.id]??[];let ge=0,ue=0;for(const oe of H)oe.role==="user"?ue=ue+1:oe.role==="assistant"&&(ge=ge+1);const M=u.get(de.id);return{id:de.id,title:de.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ge,messageCount:H.length,userMessageCount:ue,isStreaming:M?.isStreaming||!1,isZombie:M?.isZombie||!1,backgroundCount:M?.backgroundMessageCount||0,lastAccessed:M?.lastAccessedAt||0,isCurrent:de.id===d}},e[36]=d,e[37]=f,e[38]=u,e[39]=r,e[40]=ae):ae=e[40],I=h.map(ae).sort(Ok),e[30]=d,e[31]=f,e[32]=u,e[33]=h,e[34]=r,e[35]=I}else I=e[35];const $=I;let z;e[41]!==f?(z=Object.keys(f),e[41]=f,e[42]=z):z=e[42];const G=z.length;let J;e[43]===Symbol.for("react.memo_cache_sentinel")?(J=async()=>{try{const ae={generatedAt:new Date().toISOString(),ui:si(),vscode:ni()};await navigator.clipboard.writeText(JSON.stringify(ae,null,2)),a("copied")}catch{a("error")}},e[43]=J):J=e[43];const Z=J;let re;e[44]===Symbol.for("react.memo_cache_sentinel")?(re={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[44]=re):re=e[44];let ee;e[45]!==o?(ee=o==="memory"?s.jsx(R,{name:"database-2",className:"h-4 w-4 text-[var(--surface-foreground)]"}):s.jsx(R,{name:"bar-chart-box",className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[45]=o,e[46]=ee):ee=e[46];let he;e[47]!==r?(he=r("memoryDebugPanel.title"),e[47]=r,e[48]=he):he=e[48];let be;e[49]!==he?(be=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:he}),e[49]=he,e[50]=be):be=e[50];let Y;e[51]!==ee||e[52]!==be?(Y=s.jsxs("div",{className:"flex items-center gap-2",children:[ee,be]}),e[51]=ee,e[52]=be,e[53]=Y):Y=e[53];let we;e[54]!==o?(we=o==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(nt,{size:"xs",variant:"ghost",onClick:Z,children:s.jsx(R,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(nt,{size:"xs",variant:"ghost",onClick:()=>{zm(),S(si()),p(ni())},children:s.jsx(R,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[54]=o,e[55]=we):we=e[55];let me;e[56]!==n?(me=n?s.jsx(nt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(R,{name:"close",className:"h-4 w-4"})}):null,e[56]=n,e[57]=me):me=e[57];let Q;e[58]!==we||e[59]!==me?(Q=s.jsxs("div",{className:"flex items-center gap-1",children:[we,me]}),e[58]=we,e[59]=me,e[60]=Q):Q=e[60];let pe;e[61]!==Y||e[62]!==Q?(pe=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Y,Q]}),e[61]=Y,e[62]=Q,e[63]=pe):pe=e[63];let ve;e[64]===Symbol.for("react.memo_cache_sentinel")?(ve={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[64]=ve):ve=e[64];const Te=o==="memory"?"secondary":"ghost";let ke;e[65]===Symbol.for("react.memo_cache_sentinel")?(ke=()=>i("memory"),e[65]=ke):ke=e[65];let Ie;e[66]!==r?(Ie=r("memoryDebugPanel.tabs.memory"),e[66]=r,e[67]=Ie):Ie=e[67];let Ne;e[68]!==Te||e[69]!==Ie?(Ne=s.jsx(nt,{size:"sm",variant:Te,className:"flex-1",onClick:ke,children:Ie}),e[68]=Te,e[69]=Ie,e[70]=Ne):Ne=e[70];const Ae=o==="streaming"?"secondary":"ghost";let Se;e[71]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>i("streaming"),e[71]=Se):Se=e[71];let Oe;e[72]!==r?(Oe=r("memoryDebugPanel.tabs.streaming"),e[72]=r,e[73]=Oe):Oe=e[73];let ne;e[74]!==Ae||e[75]!==Oe?(ne=s.jsx(nt,{size:"sm",variant:Ae,className:"flex-1",onClick:Se,children:Oe}),e[74]=Ae,e[75]=Oe,e[76]=ne):ne=e[76];let ce;e[77]!==Ne||e[78]!==ne?(ce=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ve,children:[Ne,ne]}),e[77]=Ne,e[78]=ne,e[79]=ce):ce=e[79];let Re;e[80]!==o||e[81]!==G||e[82]!==c||e[83]!==d||e[84]!==f||e[85]!==y||e[86]!==u||e[87]!==$||e[88]!==h||e[89]!==P||e[90]!==b||e[91]!==r||e[92]!==g||e[93]!==v?(Re=o==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(Is,{label:r("memoryDebugPanel.metric.totalMessages"),value:y.total}),s.jsx(Is,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${G} / ${dc.MAX_SESSIONS}`}),s.jsx(Is,{label:r("memoryDebugPanel.metric.userMessages"),value:y.user}),s.jsx(Is,{label:r("memoryDebugPanel.metric.assistantMessages"),value:y.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:Hp()})})]}),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:dc.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:g})]})]}),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:$.map(ae=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:ae.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:ae.title}),ae.isStreaming?s.jsx(R,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,ae.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:ae.assistantMessageCount,user:ae.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:ae.messageCount})}),ae.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",ae.backgroundCount]}):null]})]},ae.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx(nt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(Fk),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:y,sessionMessageRoleCounts:$.map(Bk),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(ft,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):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(c==="copied"?"memoryDebugPanel.streaming.copy.copied":c==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(nt,{size:"xs",variant:"outline",onClick:Z,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(Is,{label:r("memoryDebugPanel.metric.uiMetrics"),value:b.entries.length}),s.jsx(Is,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:v.entries.length}),s.jsx(Is,{label:r("memoryDebugPanel.metric.messageListRenders"),value:P.messageListRender}),s.jsx(Is,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:P.messageListRenderStreaming}),s.jsx(Is,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:P.chatMessageRender}),s.jsx(Is,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:P.chatMessageRenderStreaming}),s.jsx(Is,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:P.chatMessageRenderStaticDuringStream}),s.jsx(Is,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:P.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Ud,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),v.entries.length>0?s.jsx(Ud,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:v,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}),e[80]=o,e[81]=G,e[82]=c,e[83]=d,e[84]=f,e[85]=y,e[86]=u,e[87]=$,e[88]=h,e[89]=P,e[90]=b,e[91]=r,e[92]=g,e[93]=v,e[94]=Re):Re=e[94];let te;return e[95]!==pe||e[96]!==ce||e[97]!==Re?(te=s.jsxs(Kp,{className:"fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area",style:re,children:[pe,ce,Re]}),e[95]=pe,e[96]=ce,e[97]=Re,e[98]=te):te=e[98],te},Ak=Nk;function Dk(t,e){return t+e.count}function Pk(t){return t.currentSessionId}function Ek(t){return t.sessionMemoryState}function Tk(t){return t.message}function Ik(t){return t.totalRequestCount}function Rk(){return si()}function Mk(){return ni()}function Ok(t,e){return e.lastAccessed-t.lastAccessed}function Fk(t){return{id:t.id,title:t.title}}function Bk(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}const Lk=()=>{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()??"":""},_k=async()=>{const t=Lk()||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")},Wd="openchamber:menu-action",Na="openchamber:check-for-updates",$k=t=>{const e=Je(x=>x.openNewSessionDraft),n=xe(x=>x.toggleCommandPalette),r=xe(x=>x.setCommandPaletteOpen),o=xe(x=>x.toggleHelpDialog),i=xe(x=>x.toggleSidebar),c=xe(x=>x.setSessionSwitcherOpen),a=xe(x=>x.setActiveMainTab),d=xe(x=>x.setSettingsDialogOpen),u=xe(x=>x.setAboutDialogOpen),h=vo(x=>x.checkForUpdates),{setThemeMode:f}=_r(),g=l.useRef(!1),b=l.useCallback(()=>{g.current||(g.current=!0,h().then(()=>{const{available:x,error:w}=vo.getState();if(w){Ee.error("Failed to check for updates",{description:w});return}x||Ee.success("You are on the latest version")}).finally(()=>{g.current=!1}))},[h]),S=l.useCallback(()=>{_n.requestDirectoryDialog()},[]),v=l.useCallback(x=>{const w=Gp();if(w.length===0)return;const j=Je.getState().currentSessionId,N=w.findIndex(C=>C.id===j);let A=x>0?0:w.length-1;N>=0&&(A=(N+x+w.length)%w.length);const k=w[A];k&&(a("chat"),c(!1),Je.getState().setCurrentSession(k.id))},[a,c]),p=l.useCallback(x=>{const{activeProjectId:w,projects:j,setActiveProject:N}=qt.getState();if(j.length===0)return;const A=j.findIndex(P=>P.id===w);let k=x>0?0:j.length-1;A>=0&&(k=(A+x+j.length)%j.length);const C=j[k];C&&N(C.id)},[]),m=l.useCallback(x=>{switch(x){case"about":u(!0);break;case"settings":d(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":a("chat"),c(!1),e();break;case"new-worktree-session":a("chat"),c(!1),ju();break;case"change-workspace":S();break;case"toggle-right-sidebar":{const w=ls.getState().currentDirectory;if(!w)break;const j=xe.getState(),N=Vr(w),A=j.contextPanelByDirectory[N];A?.isOpen?j.closeContextPanel(N):A?.activeTabId?j.setActiveContextPanelTab(N,A.activeTabId):j.openContextSurface(N,"git");break}case"open-right-sidebar-git":{const w=ls.getState().currentDirectory;if(!w)break;xe.getState().openContextSurface(Vr(w),"git");break}case"open-right-sidebar-files":{const w=ls.getState().currentDirectory;if(!w)break;xe.getState().openContextSurface(Vr(w),"file");break}case"toggle-terminal":{const w=ls.getState().currentDirectory;if(!w)break;xe.getState().openContextSurface(Vr(w),"terminal");break}case"toggle-terminal-expanded":{const w=ls.getState().currentDirectory;if(!w)break;const j=Vr(w),N=xe.getState(),A=N.contextPanelByDirectory[j];(A?.isOpen?A.tabs.find(C=>C.id===A.activeTabId)?.mode:null)!=="terminal"&&N.openContextSurface(j,"terminal"),N.toggleContextPanelExpanded(j);break}case"copy":{const w=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(w)||_k();break}case"theme-light":f("light");break;case"theme-dark":f("dark");break;case"theme-system":f("system");break;case"add-selection-to-chat":Yp();break;case"toggle-sidebar":i();break;case"toggle-memory-debug":t?.();break;case"go-back":ls.getState().goBack();break;case"go-forward":ls.getState().goForward();break;case"previous-session":v(-1);break;case"next-session":v(1);break;case"previous-project":p(-1);break;case"next-project":p(1);break;case"help-dialog":o();break;case"download-logs":{qp().catch(()=>{Ee.error("Failed to collect OpenCode status")});break}}},[S,p,v,t,e,u,a,c,r,d,f,n,o,i]);l.useEffect(()=>{const x=j=>{const N=j.detail;N&&m(N)},w=()=>{b()};return window.addEventListener(Wd,x),window.addEventListener(Na,w),()=>{window.removeEventListener(Wd,x),window.removeEventListener(Na,w)}},[m,b]),l.useEffect(()=>{if(typeof window>"u")return;const w=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof w!="function")return;let j=null,N=null;return w("openchamber:menu-action",A=>{const k=A?.payload;typeof k=="string"&&m(k)}).then(A=>{j=A}).catch(()=>{}),w("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Na))}).then(A=>{N=A}).catch(()=>{}),()=>{(async()=>{try{const k=j?.();k instanceof Promise&&await k}catch{}try{const k=N?.();k instanceof Promise&&await k}catch{}})()}},[m])},zk="openchamber:tray-action",Vd=5e3,Uk=500,Wk=45e3,Qf=20,Hd=()=>{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,Vk=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},Hk=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Xf=(t,e)=>to(t,e,No.getState().ids,zi.getState().rankById),Kk=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},Gk=(t,e,n,r,o)=>{if(!t)return"";const i=eg(n,r,t),c=e.project?.name,a=i?.label?.trim()||c?.trim()||Kk(t),d=ii(t);let u=d&&o.get(d)||"";if(!u){for(const[h,f]of mr.getState().directories)if(ii(h)===d){u=f.status?.current??"";break}}if(!u)for(const h of r.values()){const f=h.find(g=>ii(g.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},qk=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=Cs.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(c=>[c.providerId,c])),i=[];for(const c of du){if(!e.includes(c.id))continue;const a=o.get(c.id);if(!a||a.configured!==!0)continue;const d=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const g=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:hu(h),value:Ta(f.valueLabel,g)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;i.push({provider:c.name,rows:d,status:u})}return{mode:r,groups:i}},Yk=async()=>{try{if(Ti())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=fr();if(e&&Kl(e,t))return"Local OpenChamber";const r=(await Zd()).hosts.find(o=>e?Kl(e,Um(o)):!1);return r?.label?.trim()?eu(r.label.trim()):"Instance"}catch{return""}},Qk=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=bi()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[i,c]of o.children.entries()){const a=c.getState();a.vcs?.branch&&e.set(ii(i)??i,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",g=t.get(d);(!g||g==="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:Vk(h),directory:i})}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:Hk(h),directory:i})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},Xk=()=>{const t=Rs.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort(Xf).slice(0,Qf).forEach(r=>{const o=Us(r);o&&e.add(o)});const n=new Map;for(const r of t){if(!r?.id)continue;const o=Us(r);if(!o||!e.has(o))continue;const i=n.get(o)??[];i.push(r.id),n.set(o,i)}return n},Jk=t=>{const e=Qk(),n=Wi.getState().index.session,r=Rs.getState().activeSessions,o=new Map(e.titleById),i=new Map;for(const p of r)if(p?.id&&(p.title&&o.set(p.id,p.title),p.parentID)){const m=i.get(p.parentID)??[];m.push(p.id),i.set(p.parentID,m)}const c=p=>{const m=[],x=[...i.get(p)??[]],w=new Set;for(;x.length;){const j=x.pop();w.has(j)||(w.add(j),m.push(j),x.push(...i.get(j)??[]))}return m},a=Ui.getState().statusById,d=p=>{const m=e.statusById.get(p);return m&&m!=="idle"?m:a.get(p)?.status.type??m??"idle"},u=p=>{const m=p.map(x=>d(x));return m.includes("busy")?"busy":m.includes("retry")?"retry":"idle"},h=qt.getState().projects,f=Je.getState().availableWorktreesByProject,g=r.filter(p=>p?.id&&!p.parentID).slice().sort(Xf).slice(0,Qf).map(p=>{const m=[p.id,...c(p.id)],x=Us(p)??"";return{id:p.id,title:p.title||"Untitled session",status:u(m),branch:x?e.branchByDirectory.get(x)??"":"",unseen:m.reduce((w,j)=>w+(n.unseenCount[j]??0),0),hasError:m.some(w=>n.unseenHasError[w]??!1),directory:x,subtitle:Gk(x,p,h,f,e.branchByDirectory)}}),b=e.approvals.map(p=>({...p,sessionTitle:o.get(p.sessionId)||""})),S=xe.getState();let v=0;if(S.dockBadgeEnabled)for(const p of r){if(!p?.id||p.parentID)continue;let m=n.unseenCount[p.id]??0;m===0&&S.notifyOnSubtasks&&(m=c(p.id).reduce((x,w)=>x+(n.unseenCount[w]??0),0)),m>0&&(v+=1)}return{sessions:g,approvals:b,instanceName:t,usage:qk(),dockBadgeCount:v}},Zk=()=>{l.useEffect(()=>{if(!Hd()||!Kd()||!Ri())return;let t=!1,e="",n=null,r="";const o=()=>{if(t)return;const k=Jk(r),C=JSON.stringify(k);C!==e&&(e=C,ur("desktop_tray_update",k))};Yk().then(k=>{t||(r=k,o())});const i=async()=>{const k=Xk();await Promise.all([...k.entries()].map(async([C,P])=>{const D=await Xs.getSessionStatusForDirectory(C).catch(()=>null);t||D===null||Jp(C,D,P)}))},c=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,o()},Uk))},a=new Map,d=()=>{if(t)return;let k;try{k=bi()}catch{return}const C=new Set;for(const[P,D]of k.children.entries())C.add(P),a.has(P)||a.set(P,D.subscribe(()=>c()));for(const[P,D]of a)C.has(P)||(D(),a.delete(P))};let u=null;try{u=bi().subscribeRegistry(()=>{d(),c()})}catch{}d();const h=Wi.subscribe(()=>c()),f=Rs.subscribe(()=>c()),g=qt.subscribe(()=>c()),b=Je.subscribe(()=>c()),S=mr.subscribe(()=>c()),v=xe.subscribe(()=>c()),p=Ui.subscribe(()=>c()),m=zi.subscribe(()=>c()),x=No.subscribe(()=>c());Qp(Xp());const w=window.setInterval(()=>{xi()},Wk);i();const j=window.setInterval(()=>{i()},Vd),N=Cs.subscribe(()=>c());Cs.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:k,results:C}=Cs.getState();k.length>0&&k.some(D=>!C.some(F=>F.providerId===D))&&Cs.getState().fetchQuotas(k)});const A=window.setInterval(()=>{d(),o()},Vd);return o(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(A),window.clearInterval(w),window.clearInterval(j),h(),f(),g(),b(),S(),v(),p(),m(),x(),N(),u?.();for(const k of a.values())k();a.clear()}},[]),l.useEffect(()=>{if(!Hd()||!Kd()||typeof window>"u")return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=o=>{o.type==="respond-permission"&&Zp(o.sessionId,o.id,o.response).catch(()=>{Ee.error("Failed to respond to permission request")})};let r=null;return e(zk,o=>{const i=o?.payload;!i||typeof i!="object"||typeof i.type!="string"||n(i)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},eC="/api/notifications/stream",tC=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),sC=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}},nC=t=>{const e=tt.c(3),n=t?.enabled??!0;let r,o;e[0]!==n?(r=()=>{if(!n||$n()||!rl()||typeof window>"u"||typeof EventSource>"u")return;const i=new EventSource(nu().sse(eC));return i.onmessage=rC,()=>{i.close()}},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),l.useEffect(r,o)};function rC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=xe.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&tC())return;const r=sC(e);if(!r)return;Ii()?.notifications?.notifyAgentCompletion(r)}const Gd="pwa-install-toast-shown",qd="pwa-install-toast-dismissed",oC=()=>{const t=tt.c(6),{browserTab:e}=Fg(),{t:n}=mt(),r=l.useRef(n);let o,i;t[0]!==n?(o=()=>{r.current=n},i=[n],t[0]=n,t[1]=o,t[2]=i):(o=t[1],i=t[2]),l.useEffect(o,i);let c,a;t[3]!==e?(c=()=>{if(typeof window>"u"||!rl()||!e)return;let d=null,u=null;const h=()=>{u!==null&&(Ee.dismiss(u),u=null)},f=async()=>{if(!d)return;const S=d;d=null,h(),await S.prompt();const{outcome:v}=await S.userChoice;v==="accepted"&&Ee.success(r.current("pwa.installPrompt.started"))},g=S=>{const v=S;if(typeof v.prompt!="function")return;v.preventDefault(),d=v;const p=Hr(),m=Wm();Bg({dismissed:p.getItem(qd),sessionShown:m.getItem(Gd),hasActiveToast:u!==null})&&(m.setItem(Gd,"true"),u=Ee.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:()=>{Hr().setItem(qd,"true"),h()}}}))},b=()=>{d=null,h(),Ee.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",g),window.addEventListener("appinstalled",b),()=>{h(),window.removeEventListener("beforeinstallprompt",g),window.removeEventListener("appinstalled",b)}},a=[e],t[3]=e,t[4]=c,t[5]=a):(c=t[4],a=t[5]),l.useEffect(c,a)},iC=({open:t,onOpenChange:e})=>{const{t:n}=mt(),r=!1,[o,i]=l.useState(null),[c,a]=l.useState(null),[d,u]=l.useState(!1),[h,f]=l.useState(!1),[g,b]=l.useState(null),[S,v]=l.useState(!1);l.useCallback(async()=>{},[g,d,r,n]),l.useEffect(()=>{if(!t)return;(async()=>{try{const x=await ms("/api/system/info");if(x.ok){const w=await x.json();if(typeof w.openchamberVersion=="string"&&w.openchamberVersion.trim()){i(w.openchamberVersion);return}}}catch{}i(await tg())})()},[t]),l.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const w=await ms("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!w.ok)return;const j=await w.json().catch(()=>null),N=typeof j?.currentVersion=="string"?j.currentVersion.trim():"";!m&&N&&a(N)}catch{}})(),()=>{m=!0}},[t]),l.useEffect(()=>{{b(null),v(!1);return}},[t,r]);const p=o;return s.jsx(Ws,{open:t,onOpenChange:e,children:s.jsx(Vs,{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:[p&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:p})}),c&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:c})})]})]}),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(R,{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(R,{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(R,{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")})]})})})},Yd=t=>{if(!(typeof window>"u")){if(t){window.location.href="openchamber://focus/mcp-auth";return}window.location.replace("/")}},Aa=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},aC=(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},lC=()=>{const t=sg(a=>a.completeAuth),[e,n]=l.useState("working"),[r,o]=l.useState(!1),[i,c]=l.useState("Completing MCP authorization...");return l.useEffect(()=>{if(typeof window>"u"){n("error"),c("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),d=Aa(a,"code"),u=ng(a),h=rg(a),f=Aa(a,"error"),g=Aa(a,"error_description");if(f){h&&ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),c(g??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,S=!1;if(h){const v=await ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(v.ok){const p=await v.json().catch(()=>null);S=p?.origin===og,o(S),!b&&p?.name?.trim()&&(b={name:p.name.trim(),directory:typeof p.directory=="string"&&p.directory.trim()?p.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 ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),S&&Yd(!0),c("Authorization completed. You can close this tab and return to OpenChamber.")}catch(b){h&&await ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),c(aC(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:ig,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:ye("typography-body",e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]"),children:i})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx(nt,{type:"button",onClick:()=>Yd(r),children:"Return to OpenChamber"})})]})})},Qd=Zs(()=>Js(()=>import("./OnboardingScreen-BmN0lhk4.js"),__vite__mapDeps([141,1,2,4,5,6,7,8,3,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])).then(t=>({default:t.OnboardingScreen}))),cC=()=>{const t=tt.c(3),e=xe(pC),n=xe(gC);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(iC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},dC=t=>{const e=tt.c(21),{onRetry:n,isRetrying:r}=t,{t:o}=mt();let i;e[0]!==o?(i=o("startup.initRecovery.title"),e[0]=o,e[1]=i):i=e[1];let c;e[2]!==i?(c=s.jsx("h1",{className:"typography-title text-foreground",children:i}),e[2]=i,e[3]=c):c=e[3];let a;e[4]!==o?(a=o("startup.initRecovery.description"),e[4]=o,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]!==c||e[9]!==d?(u=s.jsxs("div",{className:"flex flex-col gap-2",children:[c,d]}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let h;e[11]!==r||e[12]!==o?(h=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=o,e[13]=h):h=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==h?(f=s.jsx(nt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=f):f=e[17];let g;return e[18]!==u||e[19]!==f?(g=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]=g):g=e[20],g},Xd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",uC=()=>{if(typeof window>"u"||!Jg())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"),o=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:o,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},fC=()=>typeof window>"u"?!1:window.location.pathname===ug,mC=t=>{const e=tt.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:o}=t,i=ls(xC),c=Je(bC),a=Je(yC),d=Fi(),u=l.useRef(null);let h;e[0]!==n.directory?(h=Xd(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let g;e[2]!==i?(g=Xd(i),e[2]=i,e[3]=g):g=e[3];const b=g;let S,v;if(e[4]!==b||e[5]!==c||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(S=()=>{if(r||f&&b!==f)return;const N=`${f}
|
|
914
|
+
`)?(f(se),u(!0)):u(!1);return}u(!1)},e[12]=_):_=e[12];const W=_;let V;e[13]!==n.id||e[14]!==i?(V=M=>{i(n.id,{prompt:M})},e[13]=n.id,e[14]=i,e[15]=V):V=e[15];const K=V;let y;e[16]!==n.prompt||e[17]!==K?(y=M=>{const oe=n.prompt,fe=j.current?.selectionStart??oe.length,le=oe.substring(0,fe).lastIndexOf("@"),se=M.relativePath&&M.relativePath.trim().length>0?M.relativePath.trim():M.path||M.name,T=le!==-1?le:fe,ie=`${oe.substring(0,T)}@${se} ${oe.substring(fe)}`,je=T+se.length+2;K(ie),u(!1),f(""),requestAnimationFrame(()=>{const Pe=j.current;Pe&&(Pe.selectionStart=je,Pe.selectionEnd=je,Pe.focus()),W(ie,je)})},e[16]=n.prompt,e[17]=K,e[18]=y):y=e[18];const I=y;let $;e[19]!==n.prompt||e[20]!==K?($=M=>{const oe=n.prompt,fe=j.current?.selectionStart??oe.length,le=oe.substring(0,fe).lastIndexOf("@"),se=le!==-1?le:fe,T=`${oe.substring(0,se)}@${M} ${oe.substring(fe)}`,ie=se+M.length+2;K(T),u(!1),f(""),requestAnimationFrame(()=>{const je=j.current;je&&(je.selectionStart=ie,je.selectionEnd=ie,je.focus()),W(T,ie)})},e[19]=n.prompt,e[20]=K,e[21]=$):$=e[21];const z=$;let G;e[22]!==K?(G=M=>{const oe=`/${M.name} `;K(oe),b(!1),v(""),m(!1),requestAnimationFrame(()=>{const De=j.current;De&&(De.focus(),De.selectionStart=De.value.length,De.selectionEnd=De.value.length),W(oe,oe.length)})},e[22]=K,e[23]=G):G=e[23];const J=G;let Z;e[24]!==n.prompt||e[25]!==K?(Z=(M,oe)=>{const De=n.prompt,X=j.current?.selectionStart??De.length,se=De.substring(0,X).lastIndexOf("#"),T=se!==-1?se:X,ie=`${De.substring(0,T)}#${oe} ${De.substring(X)}`,je=T+oe.length+2;K(ie),m(!1),w(""),requestAnimationFrame(()=>{const Pe=j.current;Pe&&(Pe.selectionStart=je,Pe.selectionEnd=je,Pe.focus()),W(ie,je)})},e[24]=n.prompt,e[25]=K,e[26]=Z):Z=e[26];const re=Z;let ee;e[27]!==g||e[28]!==d||e[29]!==p?(ee=M=>{if(g&&A.current&&(M.key==="Enter"||M.key==="ArrowUp"||M.key==="ArrowDown"||M.key==="Escape"||M.key==="Tab")){M.preventDefault(),A.current.handleKeyDown(M.key);return}d&&N.current&&(M.key==="Enter"||M.key==="ArrowUp"||M.key==="ArrowDown"||M.key==="Escape"||M.key==="Tab")&&(M.preventDefault(),N.current.handleKeyDown(M.key)),p&&k.current&&(M.key==="Enter"||M.key==="ArrowUp"||M.key==="ArrowDown"||M.key==="Escape"||M.key==="Tab")&&(M.preventDefault(),k.current.handleKeyDown(M.key))},e[27]=g,e[28]=d,e[29]=p,e[30]=ee):ee=e[30];const he=ee,be=r+1;let Y;e[31]!==a||e[32]!==be?(Y=a("multirun.launcher.groups.groupLabel",{index:be}),e[31]=a,e[32]=be,e[33]=Y):Y=e[33];let we;e[34]!==Y?(we=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:Y}),e[34]=Y,e[35]=we):we=e[35];let me;e[36]!==o||e[37]!==n.id||e[38]!==c||e[39]!==a?(me=o&&s.jsx("button",{type:"button",onClick:()=>c(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(R,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=o,e[37]=n.id,e[38]=c,e[39]=a,e[40]=me):me=e[40];let Q;e[41]!==we||e[42]!==me?(Q=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[we,me]}),e[41]=we,e[42]=me,e[43]=Q):Q=e[43];let pe;e[44]!==a?(pe=a("multirun.launcher.groups.prompt.label"),e[44]=a,e[45]=pe):pe=e[45];let ve;e[46]!==pe?(ve=s.jsx(Mr,{required:!0,children:pe}),e[46]=pe,e[47]=ve):ve=e[47];const Te=n.prompt;let ke;e[48]!==K?(ke=M=>{const oe=M.target.value;K(oe);const De=M.target.selectionStart??oe.length;W(oe,De)},e[48]=K,e[49]=ke):ke=e[49];let Ie;e[50]!==a?(Ie=a("multirun.launcher.groups.prompt.placeholder"),e[50]=a,e[51]=Ie):Ie=e[51];let Ne;e[52]!==n.prompt||e[53]!==he||e[54]!==ke||e[55]!==Ie?(Ne=s.jsx(Kr,{ref:j,value:Te,onChange:ke,onKeyDown:he,placeholder:Ie,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]=he,e[54]=ke,e[55]=Ie,e[56]=Ne):Ne=e[56];let Ae;e[57]!==S||e[58]!==J||e[59]!==g?(Ae=g?s.jsx(Ru,{ref:A,searchQuery:S,onCommandSelect:J,onClose:()=>b(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=S,e[58]=J,e[59]=g,e[60]=Ae):Ae=e[60];let Se;e[61]!==z||e[62]!==I||e[63]!==h||e[64]!==d?(Se=d?s.jsx(Mu,{ref:N,searchQuery:h,onFileSelect:I,onAgentSelect:z,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=z,e[62]=I,e[63]=h,e[64]=d,e[65]=Se):Se=e[65];let Oe;e[66]!==re||e[67]!==p||e[68]!==x?(Oe=p?s.jsx(Ou,{ref:k,searchQuery:x,onSnippetSelect:re,onClose:()=>m(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=re,e[67]=p,e[68]=x,e[69]=Oe):Oe=e[69];let ne;e[70]!==Ne||e[71]!==Ae||e[72]!==Se||e[73]!==Oe?(ne=s.jsxs("div",{className:"relative",children:[Ne,Ae,Se,Oe]}),e[70]=Ne,e[71]=Ae,e[72]=Se,e[73]=Oe,e[74]=ne):ne=e[74];let ce;e[75]!==ve||e[76]!==ne?(ce=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ve,ne]}),e[75]=ve,e[76]=ne,e[77]=ce):ce=e[77];let Re;e[78]!==a?(Re=a("multirun.launcher.models.info",{max:Ca}),e[78]=a,e[79]=Re):Re=e[79];let te;e[80]!==Re?(te=s.jsx(hi,{children:Re}),e[80]=Re,e[81]=te):te=e[81];let ae;e[82]!==a?(ae=a("multirun.launcher.models.label"),e[82]=a,e[83]=ae):ae=e[83];let de;e[84]!==te||e[85]!==ae?(de=s.jsx(Mr,{required:!0,info:te,children:ae}),e[84]=te,e[85]=ae,e[86]=de):de=e[86];let H;e[87]!==n.models||e[88]!==P||e[89]!==F||e[90]!==E?(H=s.jsx(Vf,{selectedModels:n.models,onAdd:P,onRemove:F,onUpdate:E,minModels:1,maxModels:Ca}),e[87]=n.models,e[88]=P,e[89]=F,e[90]=E,e[91]=H):H=e[91];let ge;e[92]!==de||e[93]!==H?(ge=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[de,H]}),e[92]=de,e[93]=H,e[94]=ge):ge=e[94];let ue;return e[95]!==Q||e[96]!==ce||e[97]!==ge?(ue=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[Q,ce,ge]}),e[95]=Q,e[96]=ce,e[97]=ge,e[98]=ue):ue=e[98],ue},lk=l.createContext(null),ck=t=>{const e=tt.c(3),{children:n,value:r}=t;let o;return e[0]!==n||e[1]!==r?(o=s.jsx(lk.Provider,{value:r,children:n}),e[0]=n,e[1]=r,e[2]=o):o=e[2],o},dk=Zs(()=>Js(()=>import("./PlanView-ZYEJn8A_.js"),__vite__mapDeps([134,1,2,4,5,6,7,8,123,50,51,52,53,54,55,72,48,49,56,124,125,3,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,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,73,74,75,76,77,78,79,80,112,113,131,114,115,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98])).then(t=>({default:t.PlanView}))),zd=Zs(()=>Js(()=>import("./GitView-DBFrDDBv.js"),__vite__mapDeps([132,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,113,133,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,114,115,117,118,119,120])).then(t=>({default:t.GitView}))),uk=Zs(()=>Js(()=>import("./DiffView-DZIoOnV7.js"),__vite__mapDeps([121,1,2,4,5,6,7,8,3,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])).then(t=>({default:t.DiffView}))),fk=Zs(()=>Js(()=>import("./FilesView-BKL6YlKG.js"),__vite__mapDeps([122,1,2,4,5,6,7,8,3,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,113,123,124,125,126,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,127,128,114,115,129,130,112,131,118])).then(t=>({default:t.FilesView}))),mk=Zs(()=>Js(()=>import("./DiagramView-CFXxgg_a.js"),__vite__mapDeps([135,1,2,4,5,6,7,8,3,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,129,130])).then(t=>({default:t.DiagramView}))),hk=Zs(()=>Js(()=>import("./SettingsView-5RmswFZe.js").then(t=>t.a),__vite__mapDeps([136,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,113,137,123,124,125,114,115,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98,138,139])).then(t=>({default:t.SettingsView}))),pk=Zs(()=>Js(()=>import("./SettingsWindow-BZhAYFdS.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,136,113,137,123,124,125,114,115,100,101,85,86,87,88,89,90,91,92,93,94,95,96,97,98,138,139])).then(t=>({default:t.SettingsWindow}))),gk=()=>{const t=xe(y=>y.isSidebarOpen),e=xe(y=>y.activeMainTab),n=xe(y=>y.setIsMobile),r=xe(y=>y.isSessionSwitcherOpen),o=xe(y=>y.isSettingsDialogOpen),i=xe(y=>y.setSettingsDialogOpen),[c,a]=l.useState(!1);l.useEffect(()=>{o&&a(!0)},[o]);const d=xe(y=>y.isMultiRunLauncherOpen),u=xe(y=>y.setMultiRunLauncherOpen),h=xe(y=>y.multiRunLauncherPrefillPrompt),f=xe(y=>y.isScheduledTasksDialogOpen),g=xe(y=>y.isArchivePageOpen),b=xe(y=>y.worktreesPageProjectId),S=f||g||!!b||d;l.useEffect(()=>{const y=()=>xe.getState().closeMainSurfaces(),I=Je.subscribe((z,G)=>{const J=!!z.currentSessionId&&z.currentSessionId!==G.currentSessionId,Z=!!z.newSessionDraft?.open&&z.newSessionDraft!==G.newSessionDraft;(J||Z)&&y()}),$=xe.subscribe((z,G)=>{z.activeMainTab!==G.activeMainTab&&y()});return()=>{I(),$()}},[]);const{isMobile:v}=pr(),p=l.useRef(!1),[m,x]=l.useState(!1),[w,j]=l.useState(!1),[N,A]=l.useState(!1),[k,C]=l.useState(!1),P=l.useCallback(y=>{x(y),xe.getState().setSessionSwitcherOpen(y)},[]),D=l.useRef(typeof window>"u"?0:window.innerWidth),F=jc(-D.current),B=Ge.useRef(0),E=jc(D.current),_=Ge.useRef(0);Ge.useEffect(()=>{v&&(B.current=window.innerWidth,_.current=window.innerWidth)},[v]),Ge.useEffect(()=>{if(!v){A(!1);return}m&&A(!0),kc(F,m?0:-B.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[m,v,F]),Ge.useEffect(()=>{if(!v){C(!1);return}w&&C(!0),kc(E,w?0:_.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[v,w,E]),Ge.useEffect(()=>{if(v)return F.on("change",y=>{const I=B.current||D.current,$=m||y>-I+.5;A(z=>z===$?z:$)})},[v,F,m]),Ge.useEffect(()=>{if(v)return E.on("change",y=>{const I=_.current||D.current,$=w||y<I-.5;C(z=>z===$?z:$)})},[v,w,E]),Ge.useEffect(()=>{v&&!r&&m&&P(!1)},[r,v,m,P]),Ge.useEffect(()=>{if(!v){p.current=!1;return}p.current||(p.current=!0,P(!1),j(!1))},[v,P]),Ge.useEffect(()=>{if(!v||e!=="chat"||m||w||o)return;let y=!1,I;const $=z=>{I=window.setTimeout(()=>{if(y)return;const G=Je.getState(),J=xe.getState();if(!(J.activeMainTab!=="chat"||J.isSettingsDialogOpen||G.currentSessionId||G.newSessionDraft?.open)){if(G.isLoading){$(250);return}G.openNewSessionDraft({automatic:!0})}},z)};return $(500),()=>{y=!0,I!==void 0&&window.clearTimeout(I)}},[e,v,o,m,w]),Ge.useEffect(()=>{!v||!o||(P(!1),j(!1))},[v,o,P]),Mg(),l.useEffect(()=>{xe.getState().isMobile!==v&&n(v)},[v,n]);const W=l.useCallback(()=>{m&&P(!1),j(!w)},[m,w,P]),V=l.useMemo(()=>{if(!v&&e!=="terminal"&&e!=="diagram")return null;switch(e){case"plan":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(dk,{})});case"git":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(zd,{isActive:!w})});case"diff":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(uk,{})});case"terminal":return s.jsx(Vu,{});case"files":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(fk,{})});case"context":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(Wu,{})});case"diagram":return s.jsx(l.Suspense,{fallback:null,children:s.jsx(mk,{})});default:return null}},[e,v,w]),K=e==="chat";return s.jsx(Og,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:ye("main-content-safe-area",v?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[s.jsx(y1,{}),s.jsx(iS,{}),s.jsx(dS,{}),s.jsx(f2,{}),v?s.jsxs(ck,{value:{leftDrawerOpen:m,rightDrawerOpen:w,toggleLeftDrawer:()=>{const y=!m;w&&j(!1),P(y)},toggleRightDrawer:W,leftDrawerX:F,rightDrawerX:E,leftDrawerWidth:B,rightDrawerWidth:_,setMobileLeftDrawerOpen:P,setRightSidebarOpen:j},children:[!o&&s.jsx(Ec,{onToggleLeftDrawer:()=>{const y=!m;w&&j(!1),P(y)},onToggleRightDrawer:()=>{W()},leftDrawerOpen:m,rightDrawerOpen:w}),s.jsx("div",{"data-page-scroll-lock":"true",className:ye("flex flex-1 overflow-hidden relative",o&&"hidden"),children:s.jsxs("main",{className:"w-full h-full overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:ye("absolute inset-0",(!K||S)&&"invisible"),children:s.jsx(cs,{children:s.jsx(Fa,{active:K&&!o&&!S})})}),V&&s.jsx("div",{className:ye("absolute inset-0",S&&"invisible"),children:s.jsx(cs,{children:V})}),d&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(cs,{children:s.jsx($d,{initialPrompt:h,onCreated:()=>u(!1),onCancel:()=>u(!1)})})}),s.jsx(cs,{children:s.jsx(Od,{})}),s.jsx(cs,{children:s.jsx(Fd,{})}),s.jsx(cs,{children:s.jsx(Bd,{})}),s.jsx(Cc.div,{className:ye("absolute inset-0 z-20 bg-sidebar",!N&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:F},"aria-hidden":!m,children:s.jsx(cs,{children:s.jsx(jd,{mobileVariant:!0,isVisible:N})})}),k&&s.jsx(Cc.div,{className:"absolute inset-0 z-20 bg-sidebar","data-page-scroll-lock":"true",style:{x:E},"aria-hidden":!w,children:s.jsx(cs,{children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(zd,{isActive:w})})})})]})}),o&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:s.jsx(cs,{children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(hk,{onClose:()=>i(!1)})})})})]}):s.jsxs(s.Fragment,{children:[s.jsx(cb,{}),s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[s.jsx(ib,{isOpen:t,isMobile:v,className:"border-border",topBar:s.jsx(ab,{}),children:s.jsx(jd,{isVisible:t})}),s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[s.jsx(Ec,{}),s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[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:[s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:ye("absolute inset-0",(!K||S)&&"invisible"),children:s.jsx(cs,{children:s.jsx(Fa,{active:K&&!o&&!S})})}),V&&s.jsx("div",{className:ye("absolute inset-0",S&&"invisible"),children:s.jsx(cs,{children:V})}),d&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(cs,{children:s.jsx($d,{isWindowed:!0,initialPrompt:h,onCreated:()=>u(!1),onCancel:()=>u(!1)})})}),s.jsx(cs,{children:s.jsx(Od,{})}),s.jsx(cs,{children:s.jsx(Fd,{})}),s.jsx(cs,{children:s.jsx(Bd,{})})]}),s.jsx(Zw,{})]})})}),s.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:s.jsx(cs,{children:s.jsx(o1,{})})})]})]})]}),c?s.jsx(l.Suspense,{fallback:null,children:s.jsx(pk,{open:o,onOpenChange:i})}):null]})]})})},qf=12,xk=[{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"}],bk=t=>{const e=tt.c(18),{isActive:n,burstKey:r,className:o,durationMs:i,bursts:c,onComplete:a}=t,d=r===void 0?0:r,u=i===void 0?900:i,h=c===void 0?xk:c,f=Ge.useRef(!1);let g,b;e[0]!==n||e[1]!==a?(g=()=>{!n&&f.current&&a?.(),n&&(f.current=!0)},b=[n,a],e[0]=n,e[1]=a,e[2]=g,e[3]=b):(g=e[2],b=e[3]),Ge.useEffect(g,b);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=Array.from({length:qf},yk),e[4]=S):S=e[4];const v=S;if(!n)return null;let p;e[5]!==o?(p=ye("fireworks-overlay pointer-events-none",o),e[5]=o,e[6]=p):p=e[6];let m;if(e[7]!==d||e[8]!==h||e[9]!==u){let w;e[11]!==d||e[12]!==u?(w=j=>{const N={"--burst-delay":`${j.delay}ms`,"--burst-x":`${j.x}%`,"--burst-y":`${j.y}%`,"--firework-color":`var(${j.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:N,children:v.map((A,k)=>{const C=A.x*j.radius,P=A.y*j.radius,D={"--translate-x":`${C}px`,"--translate-y":`${P}px`,"--particle-delay":`${A.delay}ms`,color:`var(${j.colorVar})`};return s.jsx("span",{className:"firework-particle",style:D},`${j.id}-${k}-${d}`)})},`${j.id}-${d}`)},e[11]=d,e[12]=u,e[13]=w):w=e[13],m=h.map(w),e[7]=d,e[8]=h,e[9]=u,e[10]=m}else m=e[10];let x;return e[14]!==d||e[15]!==p||e[16]!==m?(x=s.jsx("div",{className:p,"aria-hidden":"true","data-burst-key":d,children:m}),e[14]=d,e[15]=p,e[16]=m,e[17]=x):x=e[17],x};function yk(t,e){const n=Math.PI*2*e/qf;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const vk=t=>{const e=tt.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,o=r===void 0?3400:r;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={isActive:!1,cycle:0},e[2]=i):i=e[2];const[c,a]=Ge.useState(i),d=Ge.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(wk)},e[4]=f):f=e[4];const g=f;let b;e[5]!==o?(b=()=>{h(),a(Sk),d.current=window.setTimeout(()=>{a(jk),d.current=null},o)},e[5]=o,e[6]=b):b=e[6];const S=b;let v,p;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>()=>h(),p=[h],e[7]=v,e[8]=p):(v=e[7],p=e[8]),Ge.useEffect(v,p);let m;return e[9]!==c.cycle||e[10]!==c.isActive||e[11]!==S?(m={isActive:c.isActive,burstKey:c.cycle,triggerFireworks:S,dismissFireworks:g},e[9]=c.cycle,e[10]=c.isActive,e[11]=S,e[12]=m):m=e[12],m};function wk(t){return t.isActive?{...t,isActive:!1}:t}function Sk(t){return{isActive:!0,cycle:t.cycle+1}}function jk(t){return t.isActive?{...t,isActive:!1}:t}const Yf=l.createContext(void 0),kk=t=>{const e=tt.c(10),{children:n}=t,{isActive:r,burstKey:o,triggerFireworks:i,dismissFireworks:c}=vk();let a;e[0]!==c||e[1]!==i?(a={triggerFireworks:i,dismissFireworks:c},e[0]=c,e[1]=i,e[2]=a):a=e[2];const d=a;let u;e[3]!==o||e[4]!==r?(u=s.jsx(bk,{isActive:r,burstKey:o}),e[3]=o,e[4]=r,e[5]=u):u=e[5];let h;return e[6]!==n||e[7]!==u||e[8]!==d?(h=s.jsxs(Yf.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=h):h=e[9],h},WC=()=>{const t=l.useContext(Yf);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Ck=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`},Is=t=>{const e=tt.c(8),{label:n,value:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=o):o=e[0];let i;e[1]!==n?(i=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=i):i=e[2];let c;e[3]!==r?(c=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=c):c=e[4];let a;return e[5]!==i||e[6]!==c?(a=s.jsxs("div",{className:"rounded-md p-2",style:o,children:[i,c]}),e[5]=i,e[6]=c,e[7]=a):a=e[7],a},Ud=t=>{const e=tt.c(43),{title:n,snapshot:r,emptyLabel:o}=t,{t:i}=mt();let c;if(e[0]!==o||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==i||e[6]!==n){const a=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(Dk,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]!==i?(f=r.startedAt?Ck(r.durationMs):i("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=i,e[15]=f):f=e[15];let g;e[16]!==f?(g=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=g):g=e[17];let b;e[18]!==h||e[19]!==g?(b=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h,g]}),e[18]=h,e[19]=g,e[20]=b):b=e[20];let S;e[21]!==i?(S=i("memoryDebugPanel.metric.metrics"),e[21]=i,e[22]=S):S=e[22];let v;e[23]!==r.entries.length||e[24]!==S?(v=s.jsx(Is,{label:S,value:r.entries.length}),e[23]=r.entries.length,e[24]=S,e[25]=v):v=e[25];let p;e[26]!==i?(p=i("memoryDebugPanel.metric.samples"),e[26]=i,e[27]=p):p=e[27];let m;e[28]!==p||e[29]!==u?(m=s.jsx(Is,{label:p,value:u}),e[28]=p,e[29]=u,e[30]=m):m=e[30];let x;e[31]!==i?(x=i("memoryDebugPanel.metric.lastUpdate"),e[31]=i,e[32]=x):x=e[32];let w;e[33]!==r.lastUpdatedAt||e[34]!==i?(w=r.lastUpdatedAt?i("memoryDebugPanel.common.live"):i("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=i,e[35]=w):w=e[35];let j;e[36]!==x||e[37]!==w?(j=s.jsx(Is,{label:x,value:w}),e[36]=x,e[37]=w,e[38]=j):j=e[38];let N;e[39]!==m||e[40]!==j||e[41]!==v?(N=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[v,m,j]}),e[39]=m,e[40]=j,e[41]=v,e[42]=N):N=e[42],c=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[b,N,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:o}):s.jsx(Yn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:a.map(A=>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:A.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:i("memoryDebugPanel.metric.countValue",{value:A.count})}),s.jsx("span",{children:i("memoryDebugPanel.metric.avgValue",{value:A.avg})}),s.jsx("span",{children:i("memoryDebugPanel.metric.maxValue",{value:A.max})}),s.jsx("span",{children:i("memoryDebugPanel.metric.totalValue",{value:A.total})})]})]},A.metric))})})]}),e[0]=o,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=i,e[6]=n,e[7]=c}else c=e[7];return c},Nk=t=>{const e=tt.c(99),{onClose:n}=t,{t:r}=mt(),[o,i]=l.useState("memory"),[c,a]=l.useState("idle"),d=Je(Pk),u=Eu(Ek),h=bu(),f=Vp(Tk),g=hn(Ik),[b,S]=l.useState(Rk),[v,p]=l.useState(Mk);let m;e[0]!==b.entries?(m=new Map,b.entries.forEach(ae=>{m.set(ae.metric,ae.count)}),e[0]=b.entries,e[1]=m):m=e[1];let x;e[2]!==m?(x=m.get("ui.message_list.render")??0,e[2]=m,e[3]=x):x=e[3];let w;e[4]!==m?(w=m.get("ui.message_list.render.streaming")??0,e[4]=m,e[5]=w):w=e[5];let j;e[6]!==m?(j=m.get("ui.chat_message.render")??0,e[6]=m,e[7]=j):j=e[7];let N;e[8]!==m?(N=m.get("ui.chat_message.render.streaming")??0,e[8]=m,e[9]=N):N=e[9];let A;e[10]!==m?(A=m.get("ui.chat_message.render.static_during_stream")??0,e[10]=m,e[11]=A):A=e[11];let k;e[12]!==m?(k=m.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[12]=m,e[13]=k):k=e[13];let C;e[14]!==x||e[15]!==w||e[16]!==j||e[17]!==N||e[18]!==A||e[19]!==k?(C={messageListRender:x,messageListRenderStreaming:w,chatMessageRender:j,chatMessageRenderStreaming:N,chatMessageRenderStaticDuringStream:A,chatMessageRenderStaticOutsideActiveTurnDuringStream:k},e[14]=x,e[15]=w,e[16]=j,e[17]=N,e[18]=A,e[19]=k,e[20]=C):C=e[20];const P=C;let D,F;e[21]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{const ae=()=>{S(si()),p(ni())};ae();const de=window.setInterval(ae,500);return()=>window.clearInterval(de)},F=[],e[21]=D,e[22]=F):(D=e[21],F=e[22]),l.useEffect(D,F);let B,E;e[23]!==c?(B=()=>{if(c==="idle")return;const ae=window.setTimeout(()=>{a("idle")},1500);return()=>window.clearTimeout(ae)},E=[c],e[23]=c,e[24]=B,e[25]=E):(B=e[24],E=e[25]),l.useEffect(B,E);let _=0,W=0,V=0;for(const ae of Object.keys(f)){const de=f[ae]??[];W=W+de.length;for(const H of de)H.role==="user"?V=V+1:H.role==="assistant"&&(_=_+1)}let K;e[26]!==_||e[27]!==W||e[28]!==V?(K={assistant:_,total:W,user:V},e[26]=_,e[27]=W,e[28]=V,e[29]=K):K=e[29];const y=K;let I;if(e[30]!==d||e[31]!==f||e[32]!==u||e[33]!==h||e[34]!==r){let ae;e[36]!==d||e[37]!==f||e[38]!==u||e[39]!==r?(ae=de=>{const H=f[de.id]??[];let ge=0,ue=0;for(const oe of H)oe.role==="user"?ue=ue+1:oe.role==="assistant"&&(ge=ge+1);const M=u.get(de.id);return{id:de.id,title:de.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:ge,messageCount:H.length,userMessageCount:ue,isStreaming:M?.isStreaming||!1,isZombie:M?.isZombie||!1,backgroundCount:M?.backgroundMessageCount||0,lastAccessed:M?.lastAccessedAt||0,isCurrent:de.id===d}},e[36]=d,e[37]=f,e[38]=u,e[39]=r,e[40]=ae):ae=e[40],I=h.map(ae).sort(Ok),e[30]=d,e[31]=f,e[32]=u,e[33]=h,e[34]=r,e[35]=I}else I=e[35];const $=I;let z;e[41]!==f?(z=Object.keys(f),e[41]=f,e[42]=z):z=e[42];const G=z.length;let J;e[43]===Symbol.for("react.memo_cache_sentinel")?(J=async()=>{try{const ae={generatedAt:new Date().toISOString(),ui:si(),vscode:ni()};await navigator.clipboard.writeText(JSON.stringify(ae,null,2)),a("copied")}catch{a("error")}},e[43]=J):J=e[43];const Z=J;let re;e[44]===Symbol.for("react.memo_cache_sentinel")?(re={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[44]=re):re=e[44];let ee;e[45]!==o?(ee=o==="memory"?s.jsx(R,{name:"database-2",className:"h-4 w-4 text-[var(--surface-foreground)]"}):s.jsx(R,{name:"bar-chart-box",className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[45]=o,e[46]=ee):ee=e[46];let he;e[47]!==r?(he=r("memoryDebugPanel.title"),e[47]=r,e[48]=he):he=e[48];let be;e[49]!==he?(be=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:he}),e[49]=he,e[50]=be):be=e[50];let Y;e[51]!==ee||e[52]!==be?(Y=s.jsxs("div",{className:"flex items-center gap-2",children:[ee,be]}),e[51]=ee,e[52]=be,e[53]=Y):Y=e[53];let we;e[54]!==o?(we=o==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx(nt,{size:"xs",variant:"ghost",onClick:Z,children:s.jsx(R,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx(nt,{size:"xs",variant:"ghost",onClick:()=>{zm(),S(si()),p(ni())},children:s.jsx(R,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[54]=o,e[55]=we):we=e[55];let me;e[56]!==n?(me=n?s.jsx(nt,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(R,{name:"close",className:"h-4 w-4"})}):null,e[56]=n,e[57]=me):me=e[57];let Q;e[58]!==we||e[59]!==me?(Q=s.jsxs("div",{className:"flex items-center gap-1",children:[we,me]}),e[58]=we,e[59]=me,e[60]=Q):Q=e[60];let pe;e[61]!==Y||e[62]!==Q?(pe=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[Y,Q]}),e[61]=Y,e[62]=Q,e[63]=pe):pe=e[63];let ve;e[64]===Symbol.for("react.memo_cache_sentinel")?(ve={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[64]=ve):ve=e[64];const Te=o==="memory"?"secondary":"ghost";let ke;e[65]===Symbol.for("react.memo_cache_sentinel")?(ke=()=>i("memory"),e[65]=ke):ke=e[65];let Ie;e[66]!==r?(Ie=r("memoryDebugPanel.tabs.memory"),e[66]=r,e[67]=Ie):Ie=e[67];let Ne;e[68]!==Te||e[69]!==Ie?(Ne=s.jsx(nt,{size:"sm",variant:Te,className:"flex-1",onClick:ke,children:Ie}),e[68]=Te,e[69]=Ie,e[70]=Ne):Ne=e[70];const Ae=o==="streaming"?"secondary":"ghost";let Se;e[71]===Symbol.for("react.memo_cache_sentinel")?(Se=()=>i("streaming"),e[71]=Se):Se=e[71];let Oe;e[72]!==r?(Oe=r("memoryDebugPanel.tabs.streaming"),e[72]=r,e[73]=Oe):Oe=e[73];let ne;e[74]!==Ae||e[75]!==Oe?(ne=s.jsx(nt,{size:"sm",variant:Ae,className:"flex-1",onClick:Se,children:Oe}),e[74]=Ae,e[75]=Oe,e[76]=ne):ne=e[76];let ce;e[77]!==Ne||e[78]!==ne?(ce=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ve,children:[Ne,ne]}),e[77]=Ne,e[78]=ne,e[79]=ce):ce=e[79];let Re;e[80]!==o||e[81]!==G||e[82]!==c||e[83]!==d||e[84]!==f||e[85]!==y||e[86]!==u||e[87]!==$||e[88]!==h||e[89]!==P||e[90]!==b||e[91]!==r||e[92]!==g||e[93]!==v?(Re=o==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(Is,{label:r("memoryDebugPanel.metric.totalMessages"),value:y.total}),s.jsx(Is,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${G} / ${dc.MAX_SESSIONS}`}),s.jsx(Is,{label:r("memoryDebugPanel.metric.userMessages"),value:y.user}),s.jsx(Is,{label:r("memoryDebugPanel.metric.assistantMessages"),value:y.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:Hp()})})]}),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:dc.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:g})]})]}),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:$.map(ae=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:ae.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:ae.title}),ae.isStreaming?s.jsx(R,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,ae.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:ae.assistantMessageCount,user:ae.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:ae.messageCount})}),ae.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",ae.backgroundCount]}):null]})]},ae.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(dt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx(nt,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:h.map(Fk),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:y,sessionMessageRoleCounts:$.map(Bk),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(ft,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):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(c==="copied"?"memoryDebugPanel.streaming.copy.copied":c==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx(nt,{size:"xs",variant:"outline",onClick:Z,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(Is,{label:r("memoryDebugPanel.metric.uiMetrics"),value:b.entries.length}),s.jsx(Is,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:v.entries.length}),s.jsx(Is,{label:r("memoryDebugPanel.metric.messageListRenders"),value:P.messageListRender}),s.jsx(Is,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:P.messageListRenderStreaming}),s.jsx(Is,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:P.chatMessageRender}),s.jsx(Is,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:P.chatMessageRenderStreaming}),s.jsx(Is,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:P.chatMessageRenderStaticDuringStream}),s.jsx(Is,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:P.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Ud,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),v.entries.length>0?s.jsx(Ud,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:v,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}),e[80]=o,e[81]=G,e[82]=c,e[83]=d,e[84]=f,e[85]=y,e[86]=u,e[87]=$,e[88]=h,e[89]=P,e[90]=b,e[91]=r,e[92]=g,e[93]=v,e[94]=Re):Re=e[94];let te;return e[95]!==pe||e[96]!==ce||e[97]!==Re?(te=s.jsxs(Kp,{className:"fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area",style:re,children:[pe,ce,Re]}),e[95]=pe,e[96]=ce,e[97]=Re,e[98]=te):te=e[98],te},Ak=Nk;function Dk(t,e){return t+e.count}function Pk(t){return t.currentSessionId}function Ek(t){return t.sessionMemoryState}function Tk(t){return t.message}function Ik(t){return t.totalRequestCount}function Rk(){return si()}function Mk(){return ni()}function Ok(t,e){return e.lastAccessed-t.lastAccessed}function Fk(t){return{id:t.id,title:t.title}}function Bk(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}const Lk=()=>{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()??"":""},_k=async()=>{const t=Lk()||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")},Wd="openchamber:menu-action",Na="openchamber:check-for-updates",$k=t=>{const e=Je(x=>x.openNewSessionDraft),n=xe(x=>x.toggleCommandPalette),r=xe(x=>x.setCommandPaletteOpen),o=xe(x=>x.toggleHelpDialog),i=xe(x=>x.toggleSidebar),c=xe(x=>x.setSessionSwitcherOpen),a=xe(x=>x.setActiveMainTab),d=xe(x=>x.setSettingsDialogOpen),u=xe(x=>x.setAboutDialogOpen),h=vo(x=>x.checkForUpdates),{setThemeMode:f}=_r(),g=l.useRef(!1),b=l.useCallback(()=>{g.current||(g.current=!0,h().then(()=>{const{available:x,error:w}=vo.getState();if(w){Ee.error("Failed to check for updates",{description:w});return}x||Ee.success("You are on the latest version")}).finally(()=>{g.current=!1}))},[h]),S=l.useCallback(()=>{_n.requestDirectoryDialog()},[]),v=l.useCallback(x=>{const w=Gp();if(w.length===0)return;const j=Je.getState().currentSessionId,N=w.findIndex(C=>C.id===j);let A=x>0?0:w.length-1;N>=0&&(A=(N+x+w.length)%w.length);const k=w[A];k&&(a("chat"),c(!1),Je.getState().setCurrentSession(k.id))},[a,c]),p=l.useCallback(x=>{const{activeProjectId:w,projects:j,setActiveProject:N}=qt.getState();if(j.length===0)return;const A=j.findIndex(P=>P.id===w);let k=x>0?0:j.length-1;A>=0&&(k=(A+x+j.length)%j.length);const C=j[k];C&&N(C.id)},[]),m=l.useCallback(x=>{switch(x){case"about":u(!0);break;case"settings":d(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":a("chat"),c(!1),e();break;case"new-worktree-session":a("chat"),c(!1),ju();break;case"change-workspace":S();break;case"toggle-right-sidebar":{const w=ls.getState().currentDirectory;if(!w)break;const j=xe.getState(),N=Vr(w),A=j.contextPanelByDirectory[N];A?.isOpen?j.closeContextPanel(N):A?.activeTabId?j.setActiveContextPanelTab(N,A.activeTabId):j.openContextSurface(N,"git");break}case"open-right-sidebar-git":{const w=ls.getState().currentDirectory;if(!w)break;xe.getState().openContextSurface(Vr(w),"git");break}case"open-right-sidebar-files":{const w=ls.getState().currentDirectory;if(!w)break;xe.getState().openContextSurface(Vr(w),"file");break}case"toggle-terminal":{const w=ls.getState().currentDirectory;if(!w)break;xe.getState().openContextSurface(Vr(w),"terminal");break}case"toggle-terminal-expanded":{const w=ls.getState().currentDirectory;if(!w)break;const j=Vr(w),N=xe.getState(),A=N.contextPanelByDirectory[j];(A?.isOpen?A.tabs.find(C=>C.id===A.activeTabId)?.mode:null)!=="terminal"&&N.openContextSurface(j,"terminal"),N.toggleContextPanelExpanded(j);break}case"copy":{const w=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(w)||_k();break}case"theme-light":f("light");break;case"theme-dark":f("dark");break;case"theme-system":f("system");break;case"add-selection-to-chat":Yp();break;case"toggle-sidebar":i();break;case"toggle-memory-debug":t?.();break;case"go-back":ls.getState().goBack();break;case"go-forward":ls.getState().goForward();break;case"previous-session":v(-1);break;case"next-session":v(1);break;case"previous-project":p(-1);break;case"next-project":p(1);break;case"help-dialog":o();break;case"download-logs":{qp().catch(()=>{Ee.error("Failed to collect OpenCode status")});break}}},[S,p,v,t,e,u,a,c,r,d,f,n,o,i]);l.useEffect(()=>{const x=j=>{const N=j.detail;N&&m(N)},w=()=>{b()};return window.addEventListener(Wd,x),window.addEventListener(Na,w),()=>{window.removeEventListener(Wd,x),window.removeEventListener(Na,w)}},[m,b]),l.useEffect(()=>{if(typeof window>"u")return;const w=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof w!="function")return;let j=null,N=null;return w("openchamber:menu-action",A=>{const k=A?.payload;typeof k=="string"&&m(k)}).then(A=>{j=A}).catch(()=>{}),w("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(Na))}).then(A=>{N=A}).catch(()=>{}),()=>{(async()=>{try{const k=j?.();k instanceof Promise&&await k}catch{}try{const k=N?.();k instanceof Promise&&await k}catch{}})()}},[m])},zk="openchamber:tray-action",Vd=5e3,Uk=500,Wk=45e3,Qf=20,Hd=()=>{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,Vk=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},Hk=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},Xf=(t,e)=>to(t,e,No.getState().ids,zi.getState().rankById),Kk=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},Gk=(t,e,n,r,o)=>{if(!t)return"";const i=eg(n,r,t),c=e.project?.name,a=i?.label?.trim()||c?.trim()||Kk(t),d=ii(t);let u=d&&o.get(d)||"";if(!u){for(const[h,f]of mr.getState().directories)if(ii(h)===d){u=f.status?.current??"";break}}if(!u)for(const h of r.values()){const f=h.find(g=>ii(g.path)===d);if(f?.branch){u=f.branch;break}}return u?`${a} · ${u}`:a},qk=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=Cs.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(c=>[c.providerId,c])),i=[];for(const c of du){if(!e.includes(c.id))continue;const a=o.get(c.id);if(!a||a.configured!==!0)continue;const d=[];for(const[h,f]of Object.entries(a.usage?.windows??{})){const g=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:hu(h),value:Ta(f.valueLabel,g)})}const u=!a.ok&&a.error?a.error:d.length===0?"No rate limits reported":null;i.push({provider:c.name,rows:d,status:u})}return{mode:r,groups:i}},Yk=async()=>{try{if(Ti())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=fr();if(e&&Kl(e,t))return"Local OpenChamber";const r=(await Zd()).hosts.find(o=>e?Kl(e,Um(o)):!1);return r?.label?.trim()?eu(r.label.trim()):"Instance"}catch{return""}},Qk=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=bi()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[i,c]of o.children.entries()){const a=c.getState();a.vcs?.branch&&e.set(ii(i)??i,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",g=t.get(d);(!g||g==="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:Vk(h),directory:i})}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:Hk(h),directory:i})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},Xk=()=>{const t=Rs.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort(Xf).slice(0,Qf).forEach(r=>{const o=Us(r);o&&e.add(o)});const n=new Map;for(const r of t){if(!r?.id)continue;const o=Us(r);if(!o||!e.has(o))continue;const i=n.get(o)??[];i.push(r.id),n.set(o,i)}return n},Jk=t=>{const e=Qk(),n=Wi.getState().index.session,r=Rs.getState().activeSessions,o=new Map(e.titleById),i=new Map;for(const p of r)if(p?.id&&(p.title&&o.set(p.id,p.title),p.parentID)){const m=i.get(p.parentID)??[];m.push(p.id),i.set(p.parentID,m)}const c=p=>{const m=[],x=[...i.get(p)??[]],w=new Set;for(;x.length;){const j=x.pop();w.has(j)||(w.add(j),m.push(j),x.push(...i.get(j)??[]))}return m},a=Ui.getState().statusById,d=p=>{const m=e.statusById.get(p);return m&&m!=="idle"?m:a.get(p)?.status.type??m??"idle"},u=p=>{const m=p.map(x=>d(x));return m.includes("busy")?"busy":m.includes("retry")?"retry":"idle"},h=qt.getState().projects,f=Je.getState().availableWorktreesByProject,g=r.filter(p=>p?.id&&!p.parentID).slice().sort(Xf).slice(0,Qf).map(p=>{const m=[p.id,...c(p.id)],x=Us(p)??"";return{id:p.id,title:p.title||"Untitled session",status:u(m),branch:x?e.branchByDirectory.get(x)??"":"",unseen:m.reduce((w,j)=>w+(n.unseenCount[j]??0),0),hasError:m.some(w=>n.unseenHasError[w]??!1),directory:x,subtitle:Gk(x,p,h,f,e.branchByDirectory)}}),b=e.approvals.map(p=>({...p,sessionTitle:o.get(p.sessionId)||""})),S=xe.getState();let v=0;if(S.dockBadgeEnabled)for(const p of r){if(!p?.id||p.parentID)continue;let m=n.unseenCount[p.id]??0;m===0&&S.notifyOnSubtasks&&(m=c(p.id).reduce((x,w)=>x+(n.unseenCount[w]??0),0)),m>0&&(v+=1)}return{sessions:g,approvals:b,instanceName:t,usage:qk(),dockBadgeCount:v}},Zk=()=>{l.useEffect(()=>{if(!Hd()||!Kd()||!Ri())return;let t=!1,e="",n=null,r="";const o=()=>{if(t)return;const k=Jk(r),C=JSON.stringify(k);C!==e&&(e=C,ur("desktop_tray_update",k))};Yk().then(k=>{t||(r=k,o())});const i=async()=>{const k=Xk();await Promise.all([...k.entries()].map(async([C,P])=>{const D=await Xs.getSessionStatusForDirectory(C).catch(()=>null);t||D===null||Jp(C,D,P)}))},c=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,o()},Uk))},a=new Map,d=()=>{if(t)return;let k;try{k=bi()}catch{return}const C=new Set;for(const[P,D]of k.children.entries())C.add(P),a.has(P)||a.set(P,D.subscribe(()=>c()));for(const[P,D]of a)C.has(P)||(D(),a.delete(P))};let u=null;try{u=bi().subscribeRegistry(()=>{d(),c()})}catch{}d();const h=Wi.subscribe(()=>c()),f=Rs.subscribe(()=>c()),g=qt.subscribe(()=>c()),b=Je.subscribe(()=>c()),S=mr.subscribe(()=>c()),v=xe.subscribe(()=>c()),p=Ui.subscribe(()=>c()),m=zi.subscribe(()=>c()),x=No.subscribe(()=>c());Qp(Xp());const w=window.setInterval(()=>{xi()},Wk);i();const j=window.setInterval(()=>{i()},Vd),N=Cs.subscribe(()=>c());Cs.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:k,results:C}=Cs.getState();k.length>0&&k.some(D=>!C.some(F=>F.providerId===D))&&Cs.getState().fetchQuotas(k)});const A=window.setInterval(()=>{d(),o()},Vd);return o(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(A),window.clearInterval(w),window.clearInterval(j),h(),f(),g(),b(),S(),v(),p(),m(),x(),N(),u?.();for(const k of a.values())k();a.clear()}},[]),l.useEffect(()=>{if(!Hd()||!Kd()||typeof window>"u")return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=o=>{o.type==="respond-permission"&&Zp(o.sessionId,o.id,o.response).catch(()=>{Ee.error("Failed to respond to permission request")})};let r=null;return e(zk,o=>{const i=o?.payload;!i||typeof i!="object"||typeof i.type!="string"||n(i)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},eC="/api/notifications/stream",tC=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),sC=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}},nC=t=>{const e=tt.c(3),n=t?.enabled??!0;let r,o;e[0]!==n?(r=()=>{if(!n||$n()||!rl()||typeof window>"u"||typeof EventSource>"u")return;const i=new EventSource(nu().sse(eC));return i.onmessage=rC,()=>{i.close()}},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),l.useEffect(r,o)};function rC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=xe.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&tC())return;const r=sC(e);if(!r)return;Ii()?.notifications?.notifyAgentCompletion(r)}const Gd="pwa-install-toast-shown",qd="pwa-install-toast-dismissed",oC=()=>{const t=tt.c(6),{browserTab:e}=Fg(),{t:n}=mt(),r=l.useRef(n);let o,i;t[0]!==n?(o=()=>{r.current=n},i=[n],t[0]=n,t[1]=o,t[2]=i):(o=t[1],i=t[2]),l.useEffect(o,i);let c,a;t[3]!==e?(c=()=>{if(typeof window>"u"||!rl()||!e)return;let d=null,u=null;const h=()=>{u!==null&&(Ee.dismiss(u),u=null)},f=async()=>{if(!d)return;const S=d;d=null,h(),await S.prompt();const{outcome:v}=await S.userChoice;v==="accepted"&&Ee.success(r.current("pwa.installPrompt.started"))},g=S=>{const v=S;if(typeof v.prompt!="function")return;v.preventDefault(),d=v;const p=Hr(),m=Wm();Bg({dismissed:p.getItem(qd),sessionShown:m.getItem(Gd),hasActiveToast:u!==null})&&(m.setItem(Gd,"true"),u=Ee.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:()=>{Hr().setItem(qd,"true"),h()}}}))},b=()=>{d=null,h(),Ee.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",g),window.addEventListener("appinstalled",b),()=>{h(),window.removeEventListener("beforeinstallprompt",g),window.removeEventListener("appinstalled",b)}},a=[e],t[3]=e,t[4]=c,t[5]=a):(c=t[4],a=t[5]),l.useEffect(c,a)},iC=({open:t,onOpenChange:e})=>{const{t:n}=mt(),r=!1,[o,i]=l.useState(null),[c,a]=l.useState(null),[d,u]=l.useState(!1),[h,f]=l.useState(!1),[g,b]=l.useState(null),[S,v]=l.useState(!1);l.useCallback(async()=>{},[g,d,r,n]),l.useEffect(()=>{if(!t)return;(async()=>{try{const x=await ms("/api/system/info");if(x.ok){const w=await x.json();if(typeof w.openchamberVersion=="string"&&w.openchamberVersion.trim()){i(w.openchamberVersion);return}}}catch{}i(await tg())})()},[t]),l.useEffect(()=>{if(!t)return;let m=!1;return(async()=>{try{const w=await ms("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!w.ok)return;const j=await w.json().catch(()=>null),N=typeof j?.currentVersion=="string"?j.currentVersion.trim():"";!m&&N&&a(N)}catch{}})(),()=>{m=!0}},[t]),l.useEffect(()=>{{b(null),v(!1);return}},[t,r]);const p=o;return s.jsx(Ws,{open:t,onOpenChange:e,children:s.jsx(Vs,{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:[p&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:p})}),c&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:c})})]})]}),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(R,{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(R,{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(R,{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")})]})})})},Yd=t=>{if(!(typeof window>"u")){if(t){window.location.href="openchamber://focus/mcp-auth";return}window.location.replace("/")}},Aa=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},aC=(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},lC=()=>{const t=sg(a=>a.completeAuth),[e,n]=l.useState("working"),[r,o]=l.useState(!1),[i,c]=l.useState("Completing MCP authorization...");return l.useEffect(()=>{if(typeof window>"u"){n("error"),c("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),d=Aa(a,"code"),u=ng(a),h=rg(a),f=Aa(a,"error"),g=Aa(a,"error_description");if(f){h&&ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),c(g??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,S=!1;if(h){const v=await ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`);if(v.ok){const p=await v.json().catch(()=>null);S=p?.origin===og,o(S),!b&&p?.name?.trim()&&(b={name:p.name.trim(),directory:typeof p.directory=="string"&&p.directory.trim()?p.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 ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("success"),S&&Yd(!0),c("Authorization completed. You can close this tab and return to OpenChamber.")}catch(b){h&&await ms(`/api/mcp/auth/pending?state=${encodeURIComponent(h)}`,{method:"DELETE"}).catch(()=>{}),n("error"),c(aC(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:ig,children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"}),s.jsx("p",{className:ye("typography-body",e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]"),children:i})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx(nt,{type:"button",onClick:()=>Yd(r),children:"Return to OpenChamber"})})]})})},Qd=Zs(()=>Js(()=>import("./OnboardingScreen-D2Y6djMw.js"),__vite__mapDeps([141,1,2,4,5,6,7,8,3,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])).then(t=>({default:t.OnboardingScreen}))),cC=()=>{const t=tt.c(3),e=xe(pC),n=xe(gC);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(iC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},dC=t=>{const e=tt.c(21),{onRetry:n,isRetrying:r}=t,{t:o}=mt();let i;e[0]!==o?(i=o("startup.initRecovery.title"),e[0]=o,e[1]=i):i=e[1];let c;e[2]!==i?(c=s.jsx("h1",{className:"typography-title text-foreground",children:i}),e[2]=i,e[3]=c):c=e[3];let a;e[4]!==o?(a=o("startup.initRecovery.description"),e[4]=o,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]!==c||e[9]!==d?(u=s.jsxs("div",{className:"flex flex-col gap-2",children:[c,d]}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let h;e[11]!==r||e[12]!==o?(h=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=o,e[13]=h):h=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==h?(f=s.jsx(nt,{type:"button",onClick:n,disabled:r,children:h}),e[14]=r,e[15]=n,e[16]=h,e[17]=f):f=e[17];let g;return e[18]!==u||e[19]!==f?(g=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]=g):g=e[20],g},Xd=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",uC=()=>{if(typeof window>"u"||!Jg())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"),o=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:o,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true",allowPromptingSubagentSessions:t.has("allowPromptingSubagentSessions")?t.get("allowPromptingSubagentSessions")==="1":void 0}},fC=()=>typeof window>"u"?!1:window.location.pathname===ug,mC=t=>{const e=tt.c(25),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:o}=t,i=ls(xC),c=Je(bC),a=Je(yC),d=Fi(),u=l.useRef(null);let h;e[0]!==n.directory?(h=Xd(n.directory),e[0]=n.directory,e[1]=h):h=e[1];const f=h;let g;e[2]!==i?(g=Xd(i),e[2]=i,e[3]=g):g=e[3];const b=g;let S,v;if(e[4]!==b||e[5]!==c||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==a||e[11]!==d?(S=()=>{if(r||f&&b!==f)return;const N=`${f}
|
|
915
915
|
${n.sessionId}`;u.current===N&&c||(u.current=N,a(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},v=[b,c,n.directory,n.sessionId,f,r,a,d],e[4]=b,e[5]=c,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=a,e[11]=d,e[12]=S,e[13]=v):(S=e[12],v=e[13]),l.useEffect(S,v),f&&b!==f)return null;let p;e[14]!==o?(p=s.jsx(Fu,{embeddedBackgroundWorkEnabled:o}),e[14]=o,e[15]=p):p=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx(Hu,{}),e[16]=m):m=e[16];let x;e[17]!==o||e[18]!==n.allowPromptingSubagentSessions||e[19]!==n.readOnly?(x=s.jsx(Fa,{active:o,readOnly:n.readOnly,initialAllowPromptingSubagentSessions:n.allowPromptingSubagentSessions}),e[17]=o,e[18]=n.allowPromptingSubagentSessions,e[19]=n.readOnly,e[20]=x):x=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(Bu,{}),e[21]=w):w=e[21];let j;return e[22]!==p||e[23]!==x?(j=s.jsxs(s.Fragment,{children:[p,m,x,w]}),e[22]=p,e[23]=x,e[24]=j):j=e[24],j};function hC({apis:t}){l.useEffect(()=>{Vm("App:mounted"),Hm()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=Vt(Q=>Q.initializeApp),n=Vt(Q=>Q.isInitialized),r=Vt(Q=>Q.isConnected),o=Vt(Q=>Q.providers.length),i=Vt(Q=>Q.agents.length),c=Vt(Q=>Q.loadProviders),a=Vt(Q=>Q.loadAgents),d=Je(Q=>Q.error),u=Je(Q=>Q.clearError),h=ls(Q=>Q.currentDirectory),f=ls(Q=>Q.setDirectory),g=ls(Q=>Q.isSwitchingDirectory),[b,S]=l.useState(!1),v=Lr(Q=>Q.refreshStatus),[p,m]=l.useState(()=>t.runtime.isVSCode),[x,w]=l.useState(!1),[j,N]=l.useState(!1),[A,k]=l.useState(0),[C,P]=l.useState(0),[D,F]=l.useState(!1),B=xe(Q=>Q.wideChatLayoutEnabled),E=xe(Q=>Q.mobileKeyboardMode),_=l.useMemo(()=>$n(),[]),W=il(Q=>Q.setPlanModeEnabled),[V,K]=l.useState(()=>Gl()),[y,I]=l.useState(()=>{const Q=ql();return Q!==null?Yl({isDesktopShell:!0,bootOutcome:Q}):null}),$=l.useRef(!1),z=l.useMemo(()=>uC(),[]),G=!z||x,J=l.useMemo(()=>fC(),[]);l.useEffect(()=>(Ql(b),()=>{Ql(!1)}),[b]),l.useEffect(()=>{Km(E)},[E]),l.useEffect(()=>{m(t.runtime.isVSCode)},[t.runtime.isVSCode]),l.useEffect(()=>Mi(Q=>{Lg(Q),P(pe=>pe+1),N(!1),k(pe=>pe+1)}),[]);const Z=uc(Q=>{const pe=xn();return Object.values(Q.runsByOriginalSessionID).filter(ve=>ve.status==="running"&&ve.runtimeKey===pe).map(ve=>`${ve.originalSessionID}:${ve.phase}:${ve.lastForwardedMessageID??""}:${ve.expectedAssistantParentID??""}`).sort().join("|")});l.useEffect(()=>{if(z)return;const Q=xn(),pe=Object.values(uc.getState().runsByOriginalSessionID).filter(ve=>ve.status==="running"&&ve.runtimeKey===Q);for(const ve of pe)ag(ve.originalSessionID)},[Z,z,C]),l.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",B),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[B]),l.useEffect(()=>(Xl(t),()=>Xl(null)),[t]),l.useEffect(()=>{z||v(t.github,{force:!0})},[t.github,z,v]),lg();const re=V==="valid",ee=y?.screen==="main";l.useEffect(()=>{if(!Gm({isDesktopShell:_,isInitialized:n,bootOutcomeKnown:re,bootViewIsMain:ee}))return;const Q=setTimeout(()=>{const pe=document.getElementById("initial-loading");pe&&(pe.classList.add("fade-out"),setTimeout(()=>{pe.remove()},300))},150);return()=>clearTimeout(Q)},[_,n,re,ee]),l.useEffect(()=>{if(!_||V!=="malformed")return;const Q=document.getElementById("initial-loading");Q&&(Q.textContent="Desktop startup failed — please restart the app.")},[_,V]),l.useEffect(()=>{if(_)return;const Q=setTimeout(()=>{const pe=document.getElementById("initial-loading");pe&&!n&&(pe.classList.add("fade-out"),setTimeout(()=>{pe.remove()},300))},5e3);return()=>clearTimeout(Q)},[_,n]),l.useEffect(()=>{let Q=!1;return(async()=>{const ve=await ms("/health",{method:"GET"}).catch(()=>null);if(!ve||!ve.ok||Q)return;const Te=await ve.json().catch(()=>null);if(!Te||Q)return;const ke=Te.planModeExperimentalEnabled;W(ke===!0||ke===1||ke==="1"||ke==="true")})(),()=>{Q=!0}},[W]),l.useEffect(()=>{p||e()},[e,p]),l.useEffect(()=>{if(p||n)return;let Q=!0,pe,ve=0;const Te=10,ke=1e3,Ie=async()=>{if(!Q)return;if(ve>=Te){N(!0);return}const Ne=Vt.getState();if(Ne.isInitialized){N(!1);return}ve+=1,await Ne.initializeApp();const Ae=Vt.getState();if(!Q)return;if(Ae.isInitialized){N(!1);return}if(ve>=Te){N(!0);return}const Se=Math.min(ke*Math.pow(2,ve-1),16e3);pe=setTimeout(Ie,Se)};return pe=setTimeout(Ie,ke),()=>{Q=!1,pe&&clearTimeout(pe)}},[A,n,p]),l.useEffect(()=>{n&&N(!1)},[n]),l.useEffect(()=>{if(!j)return;const Q=document.getElementById("initial-loading");Q&&(Q.classList.add("fade-out"),setTimeout(()=>{Q.remove()},300))},[j]),l.useEffect(()=>{if(p||!r||o>0&&i>0)return;let Q=!0,pe=0;const ve=15,Te=async()=>{const Ie=Vt.getState();if(!(Ie.providers.length>0&&Ie.agents.length>0))try{Ie.providers.length===0&&await c({source:"startupRecovery"}),Vt.getState().agents.length===0&&await a({source:"startupRecovery"})}catch{}};Te();const ke=setInterval(()=>{if(Q){if(++pe>=ve){clearInterval(ke);return}Te()}},2e3);return()=>{Q=!1,clearInterval(ke)}},[r,p,a,c,o,i]),l.useEffect(()=>{g||p||r&&Xs.setDirectory(h)},[h,g,r,p]),l.useEffect(()=>{if(!z||typeof window>"u")return;const Q=Te=>{const ke=Te?.visible===!0;w(ke)},pe=Te=>{if(Te.origin!==window.location.origin)return;const ke=Te.data;ke?.type==="openchamber:embedded-visibility"&&Q(ke.payload)},ve=window;return ve.__openchamberSetEmbeddedVisibility=Q,window.addEventListener("message",pe),()=>{window.removeEventListener("message",pe),ve.__openchamberSetEmbeddedVisibility===Q&&delete ve.__openchamberSetEmbeddedVisibility}},[z]),l.useEffect(()=>{!z?.directory||p||h!==z.directory&&f(z.directory,{showOverlay:!1})},[h,z,p,f]),l.useEffect(()=>{if(!z||typeof window>"u")return;const Q=pe=>{pe.storageArea===window.localStorage&&pe.key==="ui-store"&&xe.persist.rehydrate()};return window.addEventListener("storage",Q),()=>{window.removeEventListener("storage",Q)}},[z]),l.useEffect(()=>{if(typeof window>"u")return;const Q=pe=>{const ve=pe.detail,Te=typeof ve?.sessionId=="string"?ve.sessionId.trim():"";if(!Te)return;const ke=typeof ve?.directory=="string"&&ve.directory.trim().length>0?ve.directory.trim():null;xe.getState().setActiveMainTab("chat"),Je.getState().setCurrentSession(Te,ke)};return window.addEventListener("openchamber:open-session",Q),()=>window.removeEventListener("openchamber:open-session",Q)},[]),l.useEffect(()=>{if(typeof window>"u")return;const Q=()=>{const pe=ls.getState().currentDirectory,{activeProjectId:ve,projects:Te}=qt.getState(),ke=Te.find(Ie=>Ie.id===ve)??null;ur("desktop_open_draft_mini_chat_window",{directory:pe||ke?.path||"",projectId:ke?.id??null})};return window.addEventListener("openchamber:open-mini-chat",Q),()=>window.removeEventListener("openchamber:open-mini-chat",Q)},[]),l.useEffect(()=>{if(typeof window>"u")return;const Q=()=>{const pe=Je.getState().currentSessionId;pe&&vu(pe)};return window.addEventListener("focus",Q),()=>window.removeEventListener("focus",Q)},[]),l.useEffect(()=>{if(typeof window>"u")return;const Q=pe=>{const ve=pe.detail,Te=typeof ve?.directory=="string"&&ve.directory.trim().length>0?ve.directory.trim():null,ke=typeof ve?.projectId=="string"&&ve.projectId.trim().length>0?ve.projectId.trim():null;xe.getState().setActiveMainTab("chat"),xe.getState().setSessionSwitcherOpen(!1),Je.getState().openNewSessionDraft({selectedProjectId:ke,directoryOverride:Te,preserveDirectoryOverride:!!Te})};return window.addEventListener("openchamber:open-draft-session",Q),()=>window.removeEventListener("openchamber:open-draft-session",Q)},[]),l.useEffect(()=>{typeof window>"u"||!n||g||$.current||($.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,g]),cg({enabled:G}),nC({enabled:G}),oC(),dg(),_g();const he=l.useCallback(()=>{S(Q=>!Q)},[]);$k(he),Zk(),l.useEffect(()=>{if(z)return;const Q=pe=>{mu(pe)&&pe.shiftKey&&!pe.altKey&&(pe.code==="KeyD"||pe.key.toLowerCase()==="d")&&(pe.preventDefault(),S(Te=>!Te))};return window.addEventListener("keydown",Q,!0),()=>window.removeEventListener("keydown",Q,!0)},[z]),l.useEffect(()=>{z||d&&setTimeout(()=>u(),5e3)},[u,z,d]),l.useEffect(()=>{if(!_||V!=="not-injected")return;let Q=!1,pe=0;const ve=200,Te=2e3,ke=50,Ie=()=>{if(Q)return;pe++;const Ne=Gl();if(Ne!=="not-injected"){if(Q=!0,K(Ne),Ne==="valid"){const Se=ql();Se&&I(Yl({isDesktopShell:!0,bootOutcome:Se}))}return}const Ae=Math.min(ve*Math.pow(1.1,pe),Te);if(pe>=ke){const Se=document.getElementById("initial-loading");Se&&!Se.textContent?.includes("taking longer")&&(Se.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Ie,Ae)};return window.setTimeout(Ie,ve),()=>{Q=!0}},[_,V]);const be=l.useCallback(async()=>{if(qm({isDesktopShell:$n(),isDesktopLocalOriginActive:Ti()})){await Ym();return}window.location.reload()},[]),Y=l.useCallback(async()=>{if(!D){N(!1),F(!0);try{await Vt.getState().initializeApp()}finally{F(!1)}Vt.getState().isInitialized||k(Q=>Q+1)}},[D]),we=Q=>{if(Q.screen==="recovery")return Q.variant};if(_&&y&&y.screen!=="main"){if(y.screen==="chooser")return s.jsx(cs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Qd,{mode:"first-launch",localAvailable:y.localAvailable!==!1,onCliAvailable:be,onChooseRemote:()=>{}})})})});const Q=we(y),pe=y.screen==="recovery"&&"url"in y?y.url:void 0;return s.jsx(cs,{children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(l.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Qd,{mode:"recovery",recoveryVariant:Q,recoveryHostUrl:pe,recoveryHostLabel:void 0,localAvailable:y.localAvailable!==!1,onCliAvailable:be})})})})}if(z)return s.jsx(cs,{children:s.jsx(fc,{sdk:Xs.getSdkClient(),directory:h||"",children:s.jsx(mc,{apis:t,children:s.jsx(Oa,{delayDuration:300,skipDelayDuration:150,children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(mC,{embeddedSessionChat:z,isVSCodeRuntime:p,embeddedBackgroundWorkEnabled:G})})})})},C)});if(J)return s.jsx(cs,{children:s.jsx(lC,{})});if(j&&!n&&!p&&!z)return s.jsx(cs,{children:s.jsx(dC,{onRetry:()=>{Y()},isRetrying:D})});const me=!n&&!_;return s.jsx(cs,{children:s.jsx(fc,{sdk:Xs.getSdkClient(),directory:h||"",children:s.jsx(mc,{apis:t,children:s.jsx(kk,{children:s.jsx(Oa,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:_?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(Fu,{embeddedBackgroundWorkEnabled:G}),s.jsx(Hu,{}),s.jsx(gk,{}),s.jsx(Bu,{}),!me&&s.jsxs(s.Fragment,{children:[s.jsx($g,{}),s.jsx(cC,{}),b&&s.jsx(Ak,{onClose:()=>S(!1)})]})]})})})})},C)})}function pC(t){return t.isAboutDialogOpen}function gC(t){return t.setAboutDialogOpen}function xC(t){return t.currentDirectory}function bC(t){return t.currentSessionId}function yC(t){return t.setCurrentSession}const vC=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();fg();Qm().then(()=>{Promise.all([Xm(),mg()]).catch(t=>{console.error("[main] settings init failed:",t)}),hg(),pg(),gg()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Jf=document.getElementById("root");if(!Jf)throw new Error("Root element not found");Dm.createRoot(Jf).render(s.jsx(Ge.StrictMode,{children:s.jsx(xg,{children:s.jsx(bg,{children:s.jsx(yg,{children:s.jsx(vg,{children:s.jsx(hC,{apis:vC})})})})})}));const VC=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{kb as W,WC as a,jb as b,Lb as d,gf as g,UC as h,VC as m,hb as u,pf as v};
|