@puddle-code/cli 0.0.19 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/CHANGELOG.md +7 -8
  2. package/dist/index.js +1 -1
  3. package/dist/public/assets/{Dashboard-pA2IWfaK.js → Dashboard-Sq34AFXs.js} +1 -1
  4. package/dist/public/assets/{EditorTabClose-CNtmnz_W.js → EditorTabClose-C5BL8wr0.js} +1 -1
  5. package/dist/public/assets/{LazyTerminal-BVbNrjnw.js → LazyTerminal-CeLHCKsO.js} +2 -2
  6. package/dist/public/assets/{ModelRefcount-DvPjg3Ns.js → ModelRefcount-sJruf69B.js} +1 -1
  7. package/dist/public/assets/{PaneEditorBody-JXep35cg.js → PaneEditorBody-CbwKaj3E.js} +1 -1
  8. package/dist/public/assets/SettingsDialog-BuTx8DF2.js +1 -0
  9. package/dist/public/assets/{Terminal-DdMmi23H.js → Terminal-CN5FGN0_.js} +1 -1
  10. package/dist/public/assets/{Workspace-BQfCu-Oy.js → Workspace-NHcfAFZP.js} +4 -4
  11. package/dist/public/assets/{buffer-store-BrujywTq.js → buffer-store-CiF8VU5A.js} +2 -2
  12. package/dist/public/assets/{context-menu-DPd00x5d.js → context-menu-Bitp8sY-.js} +1 -1
  13. package/dist/public/assets/{cssMode-DxLTtqXU.js → cssMode-cJJRRtLZ.js} +1 -1
  14. package/dist/public/assets/{htmlMode-BkTm4vcY.js → htmlMode-Caw-2LOw.js} +1 -1
  15. package/dist/public/assets/index-CRUVuFoo.css +2 -0
  16. package/dist/public/assets/{index-C0rwYhwD.js → index-iPj6x3rM.js} +3 -3
  17. package/dist/public/assets/{jsonMode-DRxywuJy.js → jsonMode-CijUS1dz.js} +1 -1
  18. package/dist/public/assets/{session-seed-QMKYXZTo.js → session-seed-B2YmPsU-.js} +1 -1
  19. package/dist/public/assets/ssh-mode-CAA0-mpZ.js +1 -0
  20. package/dist/public/assets/{tsMode-yXwQVEEv.js → tsMode-_wbIu1Es.js} +1 -1
  21. package/dist/public/index.html +3 -3
  22. package/package.json +1 -1
  23. package/dist/public/assets/SettingsDialog-BghuULx0.js +0 -1
  24. package/dist/public/assets/index-DuiUHuMe.css +0 -2
  25. package/dist/public/assets/ssh-mode-DZa3UGPR.js +0 -1
@@ -1,7 +1,7 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PaneEditorBody-JXep35cg.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/profile-store-D2pB4wB-.js","assets/api-CZDct42i.js","assets/editor-tabs-3ilPGolh.js","assets/preload-helper-Czpn1I53.js","assets/createLucideIcon-DyMAgLa3.js","assets/index-C0rwYhwD.js","assets/dialog-B43iKmfK.js","assets/utils-B6KiDbIe.js","assets/LazyTerminal-BVbNrjnw.js","assets/index-DuiUHuMe.css","assets/editor.api2-4X9Vh9Zw.js","assets/editor-Br_kD0ds.css","assets/buffer-store-BrujywTq.js","assets/buffer-logic-BrpRsL1b.js","assets/debounce-B9DrqirV.js","assets/editor-sync-f1V6Wuxn.js","assets/PaneEditorBody-Dz-67XSV.css","assets/ModelRefcount-DvPjg3Ns.js","assets/EditorTabClose-CNtmnz_W.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{l as i,r as a}from"./profile-store-D2pB4wB-.js";import{A as o,M as s,N as c,O as l,S as u,T as d,_ as f,a as p,b as m,c as h,d as g,f as _,j as v,n as y,p as b,r as x,s as S,t as C,v as w,w as T,x as E,y as D}from"./editor-tabs-3ilPGolh.js";import{t as O}from"./preload-helper-Czpn1I53.js";import{S as k,c as ee,l as A,n as j,t as te,u as ne,y as re}from"./api-CZDct42i.js";import{A as M,O as N,_ as P,a as ie,b as F,g as I,h as ae,i as oe,j as L,n as R,o as z,r as se,t as ce,w as le}from"./dialog-B43iKmfK.js";import{$ as B,C as ue,E as de,G as fe,H as pe,J as me,K as he,M as V,P as ge,Q as _e,W as ve,X as ye,Y as be,a as xe,c as Se,ct as Ce,et as we,f as Te,g as Ee,h as De,i as Oe,it as ke,j as Ae,l as je,lt as Me,m as Ne,n as Pe,nt as Fe,o as Ie,q as Le,r as Re,rt as ze,t as Be,u as Ve,w as He}from"./LazyTerminal-BVbNrjnw.js";import{t as H}from"./utils-B6KiDbIe.js";import{t as U}from"./createLucideIcon-DyMAgLa3.js";import{A as Ue,C as We,D as Ge,E as Ke,O as qe,S as Je,T as Ye,_ as Xe,a as Ze,b as Qe,c as $e,d as et,f as tt,g as nt,h as rt,i as it,j as at,l as ot,m as st,n as ct,o as lt,p as ut,r as W,s as dt,t as ft,u as pt,v as mt,w as ht,x as gt,y as _t}from"./context-menu-DPd00x5d.js";import{a as vt,i as yt,n as bt,o as xt,r as St,s as Ct,t as wt}from"./session-seed-QMKYXZTo.js";import{r as Tt}from"./dist-i-QevsUb.js";import{$ as Et,B as Dt,C as Ot,F as kt,G as At,I as jt,J as Mt,K as Nt,M as Pt,Q as Ft,R as It,T as Lt,_ as Rt,a as zt,dt as Bt,et as Vt,ft as Ht,i as Ut,n as Wt,nt as Gt,pt as Kt,q as qt,rt as Jt,s as Yt,t as Xt,tt as Zt,v as Qt}from"./index-C0rwYhwD.js";import{t as $t}from"./debounce-B9DrqirV.js";import{i as en}from"./buffer-logic-BrpRsL1b.js";import{t as tn}from"./ssh-mode-DZa3UGPR.js";var nn=U(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),rn=U(`case-sensitive`,[[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M22 9v7`,key:`pvm9v3`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}],[`circle`,{cx:`18.5`,cy:`12.5`,r:`3.5`,key:`z97x68`}]]),an=U(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),on=U(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),sn=U(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]),cn=U(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),ln=U(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),un=U(`file-archive`,[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]),dn=U(`file-braces`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),G=U(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),fn=U(`file-cog`,[[`path`,{d:`M15 8a1 1 0 0 1-1-1V2a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8z`,key:`1ckgky`}],[`path`,{d:`M20 8v12a2 2 0 0 1-2 2h-4.182`,key:`1726p0`}],[`path`,{d:`m3.305 19.53.923-.382`,key:`ao1pio`}],[`path`,{d:`M4 10.592V4a2 2 0 0 1 2-2h8`,key:`1foop0`}],[`path`,{d:`m4.228 16.852-.924-.383`,key:`1fv9zy`}],[`path`,{d:`m5.852 15.228-.383-.923`,key:`1a9hc2`}],[`path`,{d:`m5.852 20.772-.383.924`,key:`1sh9ke`}],[`path`,{d:`m8.148 15.228.383-.923`,key:`4yu6lf`}],[`path`,{d:`m8.53 21.696-.382-.924`,key:`18b0s9`}],[`path`,{d:`m9.773 16.852.922-.383`,key:`ti6xop`}],[`path`,{d:`m9.773 19.148.922.383`,key:`rws47d`}],[`circle`,{cx:`7`,cy:`18`,r:`3`,key:`lvkj7j`}]]),pn=U(`file-headphone`,[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]]),mn=U(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),hn=U(`file-key`,[[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M4 12v6`,key:`bg1pfk`}],[`path`,{d:`M4 14h2`,key:`1sf9f8`}],[`path`,{d:`M9.65 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v4`,key:`d56i0q`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),gn=U(`file-lock`,[[`path`,{d:`M4 9.8V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3`,key:`1432pc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 17v-2a2 2 0 0 0-4 0v2`,key:`168m41`}],[`rect`,{width:`8`,height:`5`,x:`3`,y:`17`,rx:`1`,key:`o8vfew`}]]),_n=U(`file-play`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z`,key:`1tzo1f`}]]),vn=U(`file-spreadsheet`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),yn=U(`file-terminal`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m8 16 2-2-2-2`,key:`10vzyd`}],[`path`,{d:`M12 18h4`,key:`1wd2n7`}]]),bn=U(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),xn=U(`file-type`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M11 18h2`,key:`12mj7e`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`M9 13v-.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 .5.5v.5`,key:`qbrxap`}]]),Sn=U(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Cn=U(`folder-closed`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M2 10h20`,key:`1ir3d8`}]]),wn=U(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),Tn=U(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),En=U(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Dn=U(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),On=U(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),kn=U(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),An=U(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),jn=U(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),Mn=U(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),Nn=U(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),Pn=U(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Fn=U(`regex`,[[`path`,{d:`M17 3v10`,key:`15fgeh`}],[`path`,{d:`m12.67 5.5 8.66 5`,key:`1gpheq`}],[`path`,{d:`m12.67 10.5 8.66-5`,key:`1dkfa6`}],[`path`,{d:`M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z`,key:`swwfx4`}]]),In=U(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Ln=U(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Rn=U(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),zn=U(`user-round-cog`,[[`path`,{d:`m14.305 19.53.923-.382`,key:`3m78fa`}],[`path`,{d:`m15.228 16.852-.923-.383`,key:`npixar`}],[`path`,{d:`m16.852 15.228-.383-.923`,key:`5xggr7`}],[`path`,{d:`m16.852 20.772-.383.924`,key:`dpfhf9`}],[`path`,{d:`m19.148 15.228.383-.923`,key:`1reyyz`}],[`path`,{d:`m19.53 21.696-.382-.924`,key:`1goivc`}],[`path`,{d:`M2 21a8 8 0 0 1 10.434-7.62`,key:`1yezr2`}],[`path`,{d:`m20.772 16.852.924-.383`,key:`htqkph`}],[`path`,{d:`m20.772 19.148.924.383`,key:`9w9pjp`}],[`circle`,{cx:`10`,cy:`8`,r:`5`,key:`o932ke`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]]),Bn=U(`whole-word`,[[`circle`,{cx:`7`,cy:`12`,r:`3`,key:`12clwm`}],[`path`,{d:`M10 9v6`,key:`17i7lo`}],[`circle`,{cx:`17`,cy:`12`,r:`3`,key:`gl7c2s`}],[`path`,{d:`M14 7v8`,key:`dl84cr`}],[`path`,{d:`M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1`,key:`lt2kga`}]]),K=r(),q=e(t(),1);function Vn(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Hn(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function Un(e){return e/100*window.innerHeight}function Wn(e){return e/100*window.innerWidth}function Gn(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function Kn({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Gn(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Hn(t,i);break;case`em`:r=Vn(t,i);break;case`vh`:r=Un(i);break;case`vw`:r=Wn(i);break}return r}function qn(e){return parseFloat(e.toFixed(3))}function Jn({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function Yn(e){let{panels:t}=e,n=Jn({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=qn(Kn({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=qn(Kn({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=qn(Kn({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=qn(Kn({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function J(e,t=`Assertion error`){if(!e)throw Error(t)}function Xn(e,t){return Array.from(t).sort(e===`horizontal`?Zn:Qn)}function Zn(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Qn(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function $n(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function er(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function tr({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=er(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return J(i,`No rect found`),i}var nr;function rr(){return nr===void 0&&(nr=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),nr}function ir(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Xn(n,Array.from(t.children).filter($n).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,tr({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=rr()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:Jn({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var ar=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},or={cursorFlags:0,state:`inactive`},sr=new ar;function cr(){return or}function lr(e){return sr.addListener(`change`,e)}function ur(e){let t=or,n={...or};n.cursorFlags=e,or=n,sr.emit(`change`,{prev:t,next:n})}function dr(e){let t=or;or=e,sr.emit(`change`,{prev:t,next:e})}var fr=e=>e,pr=()=>{},mr=1,hr=2,gr=4,_r=8,vr=3,yr=12,br;function xr(){return br===void 0&&(br=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(br=!0)),br}function Sr({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&xr()){let t=(e&mr)!==0,n=(e&hr)!==0,r=(e&gr)!==0,i=(e&_r)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return xr()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var Cr=new WeakMap;function wr(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Cr.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=cr();switch(r.state){case`active`:case`hover`:{let e=Sr({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}Cr.set(e,{prevStyle:t,styleSheet:n})}var Tr=new Map,Er=new ar;function Dr(e){Tr=new Map(Tr),Tr.delete(e)}function Or(e,t){for(let[t]of Tr)if(t.id===e)return t}function kr(e,t){for(let[t,n]of Tr)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Ar(){return Tr}function jr(e,t){return Er.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function Mr(e,t,n){let r=Tr.get(e);Tr=new Map(Tr),Tr.set(e,t),Er.emit(`groupChange`,{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function Nr(e){let t=cr(),n=!1;switch(t.state){case`active`:dr({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(wr(e),n=!0,t.hitRegions.forEach(e=>{let t=kr(e.group.id,!0);Mr(e.group,t,{isUserInteraction:!0})}))}return n}function Pr(e){e.defaultPrevented||Nr(e.currentTarget)}function Fr(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=er(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function Ir(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Lr(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:Ur(e),b:Ur(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();J(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:Hr(Vr(n.a)),b:Hr(Vr(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var Rr=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function zr(e){let t=getComputedStyle(Wr(e)??e).display;return t===`flex`||t===`inline-flex`}function Br(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||zr(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||Rr.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Vr(e){let t=e.length;for(;t--;){let n=e[t];if(J(n,`Missing node`),Br(n))return n}return null}function Hr(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ur(e){let t=[];for(;e;)t.push(e),e=Wr(e);return t}function Wr(e){let{parentNode:t}=e;return Ir(t)?t.host:t}function Gr(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Kr({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!$n(n)||n.contains(e)||e.contains(n))return!0;if(Lr(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Gr(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function qr(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=ir(r),a=Fr(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Kr({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Jr(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Y(e,t,n=0){return Math.abs(qn(e)-qn(t))<=n}function Yr(e,t){return Y(e,t)?0:e>t?1:-1}function Xr({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(Yr(r,c)<0)if(a){let e=(i+c)/2;r=Yr(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=qn(r),r}function Zr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Y(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;J(u!=null,`Invalid first pivot index`),J(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];J(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(J(n!=null,`Previous layout not found for panel index ${t}`),Y(n,i)){let t=o-n;Yr(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];J(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(J(n!=null,`Previous layout not found for panel index ${t}`),Y(n,o)){let t=n-i;Yr(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];J(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&Yr(i,c)<0)if(e>0){let t=c-o,n=t/2;Yr(i+e,c)<0&&(e=Yr(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;Yr(i-e,c)<0&&(e=Yr(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];J(e!=null,`Previous layout not found for panel index ${r}`);let a=Xr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];J(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=Xr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!Y(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(Jr(c,l))return i;{let t=e<0?d:u,r=s[t];J(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=Xr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!Y(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];J(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=Xr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(Y(i,s)||(t-=s-i,l[r]=s),Y(t,0))break;e>0?r--:r++}}}if(!Y(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function Qr(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||Yr(e[n],t[n])!==0)return!1;return!0}function $r({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!Y(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];J(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];J(i!=null,`No layout data found for index ${e}`);let o=r[e];J(o!=null,`No layout data found for index ${e}`);let s=Xr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!Y(a,0))for(let e=0;e<t.length;e++){let n=r[e];J(n!=null,`No layout data found for index ${e}`);let i=n+a,o=Xr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,Y(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function ei({groupId:e,panelId:t}){let n=()=>{let t=Ar();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:e,panels:n,prevLayout:r,derivedPanelConstraints:i})=>{let o=a(),s=n.findIndex(e=>e.id===t),c=s===0,l=s===n.length-1;if(l&&e<o&&(c||n.slice(0,s).every((e,t)=>{let n=i[t];return n?.collapsible&&Y(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:qn(100-e)}}return Zr({delta:l?o-e:e-o,initialLayout:r,panelConstraints:i,pivotIndices:l?[s-1,s]:[s,s+1],prevLayout:r,trigger:`imperative-api`})},s=e=>{if(e===a())return;let{defaultLayoutDeferred:t,derivedPanelConstraints:r,group:i,groupSize:s,layout:c,separatorToPanels:l}=n(),u=$r({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});Qr(c,u)||Mr(i,{defaultLayoutDeferred:t,derivedPanelConstraints:r,groupSize:s,layout:u,separatorToPanels:l})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),o=a();e&&o!==t&&(n.expandToSize=o,s(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:o}=i(),c=a();if(e&&c===t){let e=o.expandToSize??n;e===0&&(e=1),s(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&Y(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Jn({group:t}),o=qn(Kn({groupSize:a,panelElement:r,styleProp:e})/a*100);s(o)}}}function ti(e){e.defaultPrevented||qr(e,Ar()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=ei({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function ni(e){let t=Ar();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function ri({groupId:e}){let t=()=>{let t=Ar();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=$r({layout:e,panelConstraints:r});return n?o:(Qr(o,c)||Mr(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function ii(e,t){let n=ni(e),r=kr(n.id,!0),i=n.separators.find(t=>t.element===e);J(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);J(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=ri({groupId:n.id}).getLayout(),c=$r({layout:Zr({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});Qr(s,c)||Mr(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function ai(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=ni(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&ii(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&ii(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&ii(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&ii(t,-5);break;case`End`:e.preventDefault(),ii(t,100);break;case`Enter`:{e.preventDefault();let n=ni(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=kr(n.id,!0),o=n.separators.find(e=>e.element===t);J(o,`Matching separator not found`);let s=a.get(o);J(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(J(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];ii(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=ni(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);J(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),ii(t,-100);break}}function oi(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Ar(),n=qr(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),dr({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}function si({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=Zr({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(Qr(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?mr:hr;break;case`vertical`:s|=d<0?gr:_r;break}}else Mr(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&vr:c|=s&vr,t.movementY===0?c|=o&yr:c|=s&yr,ur(c),wr(e)}function ci(e){let t=Ar(),n=cr();switch(n.state){case`active`:si({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function li(e){if(e.defaultPrevented)return;let t=cr(),n=Ar();switch(t.state){case`active`:if(e.buttons===0){dr({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=kr(e.group.id,!0);Mr(e.group,t,{isUserInteraction:!0})});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}si({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=qr(e,n);r.length===0?t.state!==`inactive`&&dr({cursorFlags:0,state:`inactive`}):dr({cursorFlags:0,hitRegions:r,state:`hover`}),wr(e.currentTarget);break}}}function ui(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(cr().state){case`hover`:dr({cursorFlags:0,state:`inactive`})}}function di(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||Nr(e.currentTarget)&&e.preventDefault()}function fi(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=qn(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=qn((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function pi(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Jn({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:qn(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function mi(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function hi({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=qn(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=qn((r[e]??0)/a*l);else{let e=qn(l/c.length);for(let t of c)u[t]=e}return u}function gi(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var _i=new Map;function vi(e){let t=!0;J(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=Jn({group:e});if(t===0)return;let n=kr(e.id);if(!n)return;let r=Yn(e),i=n.defaultLayoutDeferred?fi(r):n.layout,a=$r({layout:hi({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&Qr(n.layout,a)&&mi(n.derivedPanelConstraints,r)&&n.groupSize===t)return;Mr(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else pi(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{J(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Jn({group:e}),s=Yn(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(gi(e.panels,l)||(l=void 0));let u=$r({layout:e.mutableState.layouts[c]??l??fi(s),panelConstraints:s}),d=e.element.ownerDocument;_i.set(d,(_i.get(d)??0)+1);let f=new Map;return ir(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),Mr(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{J(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,ai)}),_i.get(d)===1&&(d.addEventListener(`contextmenu`,Pr,!0),d.addEventListener(`dblclick`,ti,!0),d.addEventListener(`pointerdown`,oi,!0),d.addEventListener(`pointerleave`,ci),d.addEventListener(`pointermove`,li),d.addEventListener(`pointerout`,ui),d.addEventListener(`pointerup`,di,!0)),function(){t=!1,_i.set(d,Math.max(0,(_i.get(d)??0)-1)),Dr(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,ai)}),_i.get(d)||(d.removeEventListener(`contextmenu`,Pr,!0),d.removeEventListener(`dblclick`,ti,!0),d.removeEventListener(`pointerdown`,oi,!0),d.removeEventListener(`pointerleave`,ci),d.removeEventListener(`pointermove`,li),d.removeEventListener(`pointerout`,ui),d.removeEventListener(`pointerup`,di,!0)),a.disconnect()}}function yi(){let[e,t]=(0,q.useState)({});return[e,(0,q.useCallback)(()=>t({}),[])]}function bi(e){let t=(0,q.useId)();return`${e??t}`}var xi=typeof window<`u`?q.useLayoutEffect:q.useEffect;function Si(e){let t=(0,q.useRef)(e);return xi(()=>{t.current=e},[e]),(0,q.useCallback)((...e)=>t.current?.(...e),[t])}function Ci(...e){return Si(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function wi(e){let t=(0,q.useRef)({...e});return xi(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var Ti=(0,q.createContext)(null);function Ei(e,t){let n=(0,q.useRef)({getLayout:()=>({}),setLayout:fr});(0,q.useImperativeHandle)(t,()=>n.current,[]),xi(()=>{Object.assign(n.current,ri({groupId:e}))})}function Di({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,q.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=Si(e=>{Qr(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=Si((e,t)=>{Qr(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t}))}),_=bi(s),v=(0,q.useRef)(null),[y,b]=yi(),x=(0,q.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=Ci(v,a);Ei(_,o);let C=Si((e,t)=>{let r=cr(),i=Or(e),a=kr(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=wi({defaultLayout:n,disableCursor:r}),T=(0,q.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=Xn(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Xn(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=Or(_),i=kr(_);r&&i&&Mr(r,{...i,derivedPanelConstraints:Yn(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,q.useRef)(null);return xi(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=vi(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=kr(r.id,!0);!o&&s.length>0&&(h(c),g(c,!1));let l=jr(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=Y(t.collapsedSize,i[t.panelId]),a=Y(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=cr().state!==`active`;h(i),o&&g(i,e.isUserInteraction)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,q.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,K.jsx)(Ti.Provider,{value:T,children:(0,K.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}Di.displayName=`Group`;function Oi(){let e=(0,q.useContext)(Ti);return J(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function ki(e,t){let{id:n}=Oi(),r=(0,q.useRef)({collapse:pr,expand:pr,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:pr});(0,q.useImperativeHandle)(t,()=>r.current,[]),xi(()=>{Object.assign(r.current,ei({groupId:n,panelId:e}))})}function Ai({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=bi(c),_=wi({disabled:a}),v=(0,q.useRef)(null),y=Ci(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=Oi(),T=d!==null,E=Si((e,t,n)=>{d?.(e,c,n)});xi(()=>{let e=v.current;if(e!==null){let t={element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}};return C(t)}},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,q.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),ki(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,q.useSyncExternalStore)(e=>jr(x,e),D,D),k;return k=O?JSON.parse(O):i===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:i},(0,K.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...ji,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,K.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}Ai.displayName=`Panel`;var ji={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function Mi({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=$r({layout:Zr({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=$r({layout:Zr({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Ni({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=bi(a),l=wi({disabled:n,disableDoubleClick:r}),[u,d]=(0,q.useState)({}),[f,p]=(0,q.useState)(`inactive`),[m,h]=(0,q.useState)(!1),g=(0,q.useRef)(null),_=Ci(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=Oi(),C=b===`horizontal`?`vertical`:`horizontal`;xi(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=lr(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=jr(y,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(Mi({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,q.useEffect)(()=>{S(c,{disabled:n,disableDoubleClick:r})},[n,r,c,S]);let w;n&&!v&&(w=`not-allowed`);let T;if(n)T=`disabled`;else switch(f){case`active`:T=`active`;break;default:T=m?`focus`:f}return(0,K.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":C,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":T,"data-testid":c,id:c,onBlur:()=>h(!1),onFocus:()=>h(!0),ref:_,role:`separator`,style:{flexBasis:`auto`,cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}Ni.displayName=`Separator`;function Pi({request:e,targetSession:t,profileId:n,onClose:r,onSaved:i}){let[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(!1);(0,q.useEffect)(()=>{e&&(o(e.name),c(null))},[e]);let d=async()=>{if(!e||!t)return;let r=a.trim().replace(/^\/+/,``).replace(/\/+$/,``);if(r===``){c(`Give the file a path.`);return}u(!0),c(null);try{let a=!0;try{await j(`GET`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(r)}`)}catch(e){if(e instanceof te&&e.status===404)a=!1;else if(e instanceof te&&e.status===413)a=!0;else throw e}if(a){c(`${r} already exists in this worktree.`);return}await j(`PUT`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(r)}`,{content:e.content}),n!==void 0&&await b(n,e.name).catch(()=>void 0),h(e.name),i(e.name,t.id,r)}catch(e){c(e instanceof Error?e.message:`Save failed`)}finally{u(!1)}};return(0,K.jsx)(ce,{open:e!==null,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:`Save draft into the worktree`}),(0,K.jsx)(se,{children:t?(0,K.jsxs)(K.Fragment,{children:[`Saves into `,(0,K.jsx)(`span`,{className:`font-mono`,children:t.branch}),` — the worktree the sidebar is bound to.`]}):`No worktree is bound — open or focus a session first.`})]}),(0,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),d()},children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(ze,{htmlFor:`untitled-path`,children:`Worktree-relative path`}),(0,K.jsx)(ke,{id:`untitled-path`,placeholder:`docs/notes.md`,value:a,onChange:e=>o(e.target.value),className:`font-mono`,autoFocus:!0})]}),s&&(0,K.jsx)(`p`,{className:`text-xs text-danger`,children:s}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{type:`button`,variant:`ghost`,onClick:r,children:`Cancel`}),(0,K.jsx)(I,{type:`submit`,disabled:l||!t,children:`Save`})]})]})]})})}function Fi(e,t,n){let r=n.snapshot.explorer_pin,i=r===null?null:e.find(e=>e.id===r&&e.status!==`archived`)??null;return{session:i??e.find(e=>e.id===t)??null,pinned:i!==null,pin(e){n.update({explorer_pin:e})},unpin(){n.update({explorer_pin:null})}}}var Ii=null,Li=null;async function Ri(){let[e,t]=await Promise.all([O(()=>import(`./PaneEditorBody-JXep35cg.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])),O(()=>import(`./ModelRefcount-DvPjg3Ns.js`),__vite__mapDeps([21,1,2,16,7,9,3,4,5,10,11,8,12,13,14,15,17]))]);Ii=e.PaneEditorBody,Li=t.ModelRefcount}var zi=(0,q.lazy)(()=>O(()=>import(`./PaneEditorBody-JXep35cg.js`).then(e=>({default:e.PaneEditorBody})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])));function Bi(e){return Ii?(0,K.jsx)(Ii,{...e}):(0,K.jsx)(q.Suspense,{fallback:(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-xs text-fg-muted`,children:`Loading editor…`}),children:(0,K.jsx)(zi,{...e})})}var Vi=(0,q.lazy)(()=>O(()=>import(`./ModelRefcount-DvPjg3Ns.js`).then(e=>({default:e.ModelRefcount})),__vite__mapDeps([21,1,2,16,7,9,3,4,5,10,11,8,12,13,14,15,17])));function Hi({buffers:e}){return Li?(0,K.jsx)(Li,{buffers:e}):(0,K.jsx)(q.Suspense,{fallback:null,children:(0,K.jsx)(Vi,{buffers:e})})}var Ui=(0,q.lazy)(()=>O(()=>import(`./EditorTabClose-CNtmnz_W.js`).then(e=>({default:e.EditorTabClose})),__vite__mapDeps([22,1,2,3,10,11,8,16,7,9,4,5,12,13,14,15,17,19,18])));function Wi(e){return(0,K.jsx)(q.Suspense,{fallback:(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e.onClose()},className:`hidden size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg group-hover:flex pointer-coarse:flex`,"aria-label":`Close ${e.label}`,children:`×`}),children:(0,K.jsx)(Ui,{...e})})}var Gi=e(n(),1);function Ki(){return crypto.randomUUID()}function X(e){return e.type===`terminal`?`term:${e.session}`:`editor:${C(e.tab)}`}function qi(e,t){return X(e)===X(t)}function Ji(e){return e.type===`terminal`}function Yi(e=[],t){let n=e.map(X),r=t&&n.includes(t)?t:n.length>0?n[0]:null;return{kind:`leaf`,id:Ki(),tabs:e,activeKey:r,previewKey:null}}function Xi(e,t,n){return{kind:`split`,id:Ki(),direction:e,children:t,sizes:n??t.map(()=>100/Math.max(1,t.length))}}function Zi(e,t){if(e.kind===`leaf`)return e.id===t?e:null;for(let n of e.children){let e=Zi(n,t);if(e)return e}return null}function Qi(e,t){if(e.kind===`leaf`)return e.tabs.some(e=>X(e)===t)?e:null;for(let n of e.children){let e=Qi(n,t);if(e)return e}return null}function $i(e){return e.kind===`leaf`?[e]:e.children.flatMap($i)}function ea(e){return $i(e).flatMap(e=>e.tabs)}function ta(e){let t=e.tabs.map(X),n=e.activeKey&&t.includes(e.activeKey)?e.activeKey:t[0]??null,r=e.previewKey&&t.includes(e.previewKey)?e.previewKey:null;return n===e.activeKey&&r===(e.previewKey??null)?e:{...e,activeKey:n,previewKey:r}}function na(e){if(e.kind===`leaf`)return ta(e);let t=e.children.map(na),n=[],r=[];t.forEach((t,i)=>{let a=e.sizes[i]??1;if(t.kind===`split`&&t.direction===e.direction){let e=t.sizes.reduce((e,t)=>e+t,0)||t.children.length;t.children.forEach((i,o)=>{n.push(i),r.push(a*(t.sizes[o]??1)/e)})}else n.push(t),r.push(a)});let i=[],a=[];return n.forEach((e,t)=>{e.kind===`leaf`&&e.tabs.length===0||(i.push(e),a.push(r[t]??1))}),i.length===0?Yi([]):i.length===1?i[0]:{...e,children:i,sizes:a}}function ra(e,t,n){return e.kind===`leaf`?e.id===t?n(e):e:{...e,children:e.children.map(e=>ra(e,t,n))}}function ia(e,t){if(e.kind===`leaf`){if(!e.tabs.some(e=>X(e)===t))return e;let n=e.tabs.filter(e=>X(e)!==t),r=e.activeKey===t?aa(e,t):e.activeKey;return{...e,tabs:n,activeKey:r}}return{...e,children:e.children.map(e=>ia(e,t))}}function aa(e,t){let n=e.tabs.findIndex(e=>X(e)===t);if(n===-1)return e.activeKey;let r=e.tabs.filter(e=>X(e)!==t);return r.length===0?null:X(r[Math.min(n,r.length-1)])}function oa(e,t,n){let r=e.tabs.filter(e=>!qi(e,t)),i=n===void 0?r.length:Math.max(0,Math.min(n,r.length)),a=[...r.slice(0,i),t,...r.slice(i)];return{...e,tabs:a,activeKey:X(t)}}function sa(e,t,n,r){let i=n===`left`||n===`right`?`row`:`col`,a=n===`left`||n===`top`;return na(ra(e,t,e=>{let t=Yi([r]);return Xi(i,a?[t,e]:[e,t],[50,50])}))}function ca(e,t){let{ref:n,toLeafId:r,edge:i}=t,a=X(n),o=t.index;if(i===`center`&&o!==void 0){let t=Zi(e,r)?.tabs.findIndex(e=>X(e)===a)??-1;t!==-1&&t<o&&--o}let s=ia(e,a);if(i===`center`){let e=ra(s,r,e=>oa(e,n,o));return!Zi(e,r)&&!Qi(e,a)?pa(na(la(e,n)),a):pa(na(e),a)}return Zi(s,r)?pa(sa(s,r,i,n),a):na(Yi([n]))}function la(e,t){let n=$i(e)[0];return n?ra(e,n.id,e=>oa(e,t)):Yi([t])}function ua(e,t,n){return na(ra(e,t,e=>e.tabs.some(e=>X(e)===n)?{...e,tabs:e.tabs.filter(e=>X(e)!==n),activeKey:e.activeKey===n?aa(e,n):e.activeKey}:e))}function da(e,t,n){let r=X(n);return na(ra(e,t,e=>{let t=e.previewKey===r?null:e.previewKey;return e.tabs.some(e=>qi(e,n))?{...e,activeKey:r,previewKey:t}:{...e,tabs:[...e.tabs,n],activeKey:r,previewKey:t}}))}function fa(e,t,n){let r=X(n);return na(ra(e,t,e=>{if(e.tabs.some(e=>qi(e,n)))return{...e,activeKey:r};let t=e.previewKey?e.tabs.findIndex(t=>X(t)===e.previewKey):-1,i=t>=0&&!Ji(e.tabs[t])?e.tabs.map((e,r)=>r===t?n:e):[...e.tabs,n];return{...e,tabs:i,activeKey:r,previewKey:r}}))}function pa(e,t){let n=e=>e.kind===`leaf`?e.previewKey===t?{...e,previewKey:null}:e:{...e,children:e.children.map(n)};return n(e)}function ma(e,t,n){let r=e=>e.kind===`leaf`?{...e,tabs:e.tabs.map(e=>e.type===`editor`&&X(e)===t?{...e,tab:{...e.tab,view:n}}:e)}:{...e,children:e.children.map(r)};return r(e)}function ha(e,t,n){return ra(e,t,e=>e.tabs.some(e=>X(e)===n)?{...e,activeKey:n}:e)}function ga(e,t,n){function r(e){return e.kind===`leaf`?e:e.id===t&&n.length===e.children.length?{...e,children:e.children.map(r),sizes:[...n]}:{...e,children:e.children.map(r)}}return r(e)}function _a(e,t){let n=e=>e.kind===`leaf`?{...e,tabs:e.tabs.filter(t)}:{...e,children:e.children.map(n)};return na(n(e))}function va(e){let t=e.editor_tabs.map(e=>({type:`editor`,tab:e})),n=e.session_tabs.map(e=>({type:`terminal`,session:e})),r=e.active_editor_tab?X({type:`editor`,tab:e.active_editor_tab}):null,i=e.active_session?`term:${e.active_session}`:null;if(t.length===0&&n.length===0)return Yi([]);if(t.length===0)return Yi(n,i);if(n.length===0)return Yi(t,r);let a=e.layout,o=typeof a.editor==`number`?a.editor:40,s=typeof a.session==`number`?a.session:60;return na(Xi(`col`,[Yi(t,r),Yi(n,i)],[o,s]))}var ya=(0,q.createContext)(null);function ba({tree:e,onOpenFile:t,children:n}){let r=(0,q.useRef)(null),i=(0,q.useRef)(new Map).current,[a,o]=(0,q.useState)(()=>new Set),s=(0,q.useCallback)((e,t)=>{o(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),c=(0,q.useMemo)(()=>{let t=new Set;for(let n of $i(e))for(let e of n.tabs)e.type===`terminal`&&t.add(e.session);return[...t]},[e]),l=e=>{let t=`term:${e}`,n=i.get(t);return n||(n=document.createElement(`div`),n.className=`size-full`,i.set(t,n)),n};(0,q.useEffect)(()=>{let e=new Set(c.map(e=>`term:${e}`));for(let e of c){let t=i.get(`term:${e}`);t&&!t.parentElement&&r.current?.appendChild(t)}for(let[t,n]of[...i])e.has(t)||(n.remove(),i.delete(t))},[c,i]);let u=(0,q.useMemo)(()=>({parkingRef:r,containers:i,setAdopted:s}),[i,s]);return(0,K.jsxs)(ya.Provider,{value:u,children:[(0,K.jsx)(`div`,{ref:r,className:`hidden`,"aria-hidden":!0}),c.map(e=>(0,Gi.createPortal)((0,K.jsx)(Be,{stream:e,paused:!a.has(`term:${e}`),onOpenFile:(n,r,i)=>t(e,n,r,i)}),l(e),e)),n]})}function xa(e){let t=(0,q.useContext)(ya),n=(0,q.useRef)(null);return(0,q.useEffect)(()=>{let r=n.current;if(!t||!e||!r)return;let i=t.containers.get(e);return i&&(r.appendChild(i),t.setAdopted(e,!0)),()=>{let n=t.parkingRef.current;i&&n&&i.parentElement===r&&n.appendChild(i),i&&t.setAdopted(e,!1)}},[t,e]),n}function Sa(e){let[t,n]=(0,q.useState)(()=>window.matchMedia(e).matches);return(0,q.useEffect)(()=>{let t=window.matchMedia(e),r=e=>n(e.matches);return n(t.matches),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var Ca=`(max-width: 767px)`;function wa(e,t){let n={};for(let r of t){let t=e[r];if(typeof t!=`number`)return;n[r]=t}return n}function Ta({text:e,hoverClass:t,className:n,title:r}){let i=(0,q.useRef)(null),[a,o]=(0,q.useState)(0);return(0,q.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>o(Math.max(0,e.scrollWidth-e.clientWidth));t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]),(0,K.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:(0,K.jsx)(`span`,{ref:i,title:r,className:H(`block whitespace-nowrap transition-transform duration-[900ms] ease-linear`,n,a>0&&t),style:a>0?{"--tail":`-${a}px`}:void 0,children:e})})}var Ea={added:{letter:`A`,label:`added`,colourClass:`text-success`},modified:{letter:`M`,label:`modified`,colourClass:`text-fg-secondary`},deleted:{letter:`D`,label:`deleted`,colourClass:`text-interrupted`},renamed:{letter:`R`,label:`renamed`,colourClass:`text-warning`}};function Da(e){return Ea[e]}var Oa=[`modified`,`added`,`deleted`,`renamed`];function ka(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return Oa.filter(e=>t.has(e)).map(e=>`${t.get(e)} ${Ea[e].label}`).join(` · `)}var Aa=[`var(--accent)`,`var(--status-running)`,`var(--status-waiting)`,`var(--ansi-magenta)`,`var(--ansi-cyan)`,`var(--status-interrupted)`];function ja(e){return Aa[e%Aa.length]}function Ma(e){let t=[],n=0,r=0,i=()=>{let e=t.indexOf(null);return e===-1?t.length:e},a=()=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];r&&e.push({col:n,sha:r.sha,colour:ja(r.colourIdx)})}return e},o=[],s=[];for(let c of e){let e=c.parents??[],l=[];for(let e=0;e<t.length;e++)t[e]?.sha===c.sha&&l.push(e);let u,d;l.length>0?(u=l[0],d=t[u].colourIdx):(u=i(),d=n++);let f=ja(d);for(let e of l)t[e]=null;for(;t.length<=u;)t.push(null);let p=[];if(e.length>0){t[u]={sha:e[0],colourIdx:d},p.push(u);for(let r=1;r<e.length;r++){let a=e[r],o=t.findIndex(e=>e?.sha===a);if(o===-1){for(o=i();t.length<=o;)t.push(null);t[o]={sha:a,colourIdx:n++}}p.push(o)}}else t[u]=null;let m=a();o.push({sha:c.sha,col:u,colour:f,above:s,below:m,created:p}),s=m,r=Math.max(r,t.length)}return{rows:o,laneCount:r}}var Na=7,Pa=14,Fa=4,Ia=1.5,La=40,Ra=22,za=`group-hover:[transform:translateX(var(--tail))]`;function Ba(e){return e*Pa+Pa/2}function Va(e,t,n,r){if(e===n)return`M ${e} ${t} L ${n} ${r}`;let i=(t+r)/2;return`M ${e} ${t} C ${e} ${i}, ${n} ${i}, ${n} ${r}`}function Ha({row:e,width:t}){let n=La,r=n/2,i=Ba(e.col),a=new Set(e.created),o=[];for(let t of e.above){let n=Ba(t.col);t.sha===e.sha?o.push({d:Va(n,0,i,r),colour:t.colour}):o.push({d:Va(n,0,n,r),colour:t.colour})}for(let t of e.below){let e=Ba(t.col);a.has(t.col)?o.push({d:Va(i,r,e,n),colour:t.colour}):o.push({d:Va(e,r,e,n),colour:t.colour})}return(0,K.jsxs)(`svg`,{width:t,height:n,className:`shrink-0`,"aria-hidden":!0,children:[o.map((e,t)=>(0,K.jsx)(`path`,{d:e.d,fill:`none`,stroke:e.colour,strokeWidth:Ia},t)),(0,K.jsx)(`circle`,{cx:i,cy:r,r:Fa,fill:`var(--bg-surface)`,stroke:e.colour,strokeWidth:Ia})]})}function Ua({lanes:e,width:t}){return(0,K.jsx)(`svg`,{width:t,height:Ra,className:`shrink-0`,"aria-hidden":!0,children:e.map(e=>{let t=Ba(e.col);return(0,K.jsx)(`path`,{d:`M ${t} 0 L ${t} ${Ra}`,fill:`none`,stroke:e.colour,strokeWidth:Ia},e.col)})})}function Wa({session:e,sha:t,lanes:n,gutterW:r,onOpen:i}){let a=d(e,t),o=e=>(0,K.jsxs)(`div`,{className:`flex items-center`,style:{height:Ra},children:[(0,K.jsx)(Ua,{lanes:n,width:r}),(0,K.jsx)(`span`,{className:`px-2 text-2xs text-fg-muted`,children:e})]});return a.isPending?o(`…`):a.error?o(a.error instanceof Error?a.error.message:`Failed to load commit`):a.data.files.length===0?o(`No file changes.`):(0,K.jsx)(K.Fragment,{children:a.data.files.map(e=>{let a=Da(e.status),o=e.status===`renamed`&&e.old_path?`${e.old_path} → ${e.path}`:e.path;return(0,K.jsxs)(`button`,{type:`button`,title:o,onClick:()=>i(e.path,t),className:`flex w-full items-center text-left transition-colors hover:bg-elevated`,style:{height:Ra},children:[(0,K.jsx)(Ua,{lanes:n,width:r}),(0,K.jsx)(`span`,{className:H(`mr-1.5 w-3 shrink-0 text-center font-mono text-xs`,a.colourClass),children:a.letter}),(0,K.jsx)(`span`,{className:`truncate pr-3 font-mono text-2xs text-fg`,children:o})]},`${e.status}:${e.old_path??``}:${e.path}`)})})}function Ga({session:e,onOpenCommitFile:t}){let n=v(e),[r,i]=(0,q.useState)(null),a=(0,q.useMemo)(()=>n.data?.pages.flatMap(e=>e.commits)??[],[n.data]),o=(0,q.useMemo)(()=>Ma(a),[a]),s=Math.max(1,o.laneCount)*Pa+Pa/2;return n.isPending?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading history…`}):n.error?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:n.error instanceof Error?n.error.message:`Failed to load history`}):a.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No commits yet.`}):(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[o.rows.map((n,o)=>{let c=a[o],l=r===n.sha;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(l?null:n.sha),className:H(`group flex w-full items-center text-left transition-colors hover:bg-elevated`,l&&`bg-selection`),style:{height:La},children:[(0,K.jsx)(Ha,{row:n,width:s}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 pr-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-2xs text-fg-muted`,children:n.sha.slice(0,Na)}),(0,K.jsx)(Ta,{text:c.subject,className:`text-xs text-fg`,hoverClass:za})]}),(0,K.jsxs)(`span`,{className:`truncate text-2xs text-fg-muted`,children:[c.author_name,` ·`,` `,(0,K.jsx)(`span`,{className:`tabular-nums`,children:f(c.authored_at)})]})]})]}),l&&(0,K.jsx)(Wa,{session:e,sha:n.sha,lanes:n.below,gutterW:s,onOpen:t})]},n.sha)}),n.hasNextPage&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>void n.fetchNextPage(),disabled:n.isFetchingNextPage,className:`px-3 py-2 text-left font-mono text-xs text-fg-muted transition-colors hover:bg-elevated`,children:n.isFetchingNextPage?`Loading…`:`Show more`})]})}function Ka(){return{dirs:new Map,files:[]}}function qa(e){return e.path}function Ja(e,t){let n=[];for(let[r,i]of e.dirs){let e=t?`${t}/${r}`:r,a={type:`dir`,name:r,path:e,children:Ja(i,e)};for(;a.children.length===1&&a.children[0].type===`dir`;){let e=a.children[0];a={type:`dir`,name:`${a.name}/${e.name}`,path:e.path,children:e.children}}n.push(a)}n.sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}));let r=[...e.files].sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}));return[...n,...r]}function Ya(e){let t=Ka();for(let n of e){let e=qa(n),r=e.split(`/`),i=r.pop(),a=t;for(let e of r){let t=a.dirs.get(e);t||(t=Ka(),a.dirs.set(e,t)),a=t}a.files.push({type:`file`,name:i,path:e,entry:n})}return Ja(t,``)}function Xa(e){return e.map(e=>({type:`file`,name:qa(e).split(`/`).pop()??qa(e),path:qa(e),entry:e})).sort((e,t)=>e.path.localeCompare(t.path,void 0,{sensitivity:`base`}))}function Za({name:e,fullPath:t,status:n,depth:r,active:i,onOpen:a}){let o=Da(n);return(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:H(`flex w-full items-center gap-1.5 py-1 pr-3 text-left transition-colors hover:bg-elevated`,i&&`bg-selection`),style:{paddingLeft:8+r*12},children:[(0,K.jsx)(`span`,{className:H(`w-3 shrink-0 text-center font-mono text-xs`,o.colourClass),children:o.letter}),(0,K.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:e})]})}function Qa({nodes:e,depth:t,activePath:n,onOpen:r}){let[i,a]=(0,q.useState)(new Set);return(0,K.jsx)(K.Fragment,{children:e.map(e=>{if(e.type===`file`)return(0,K.jsx)(Za,{name:e.name,fullPath:e.path,status:e.entry.status,depth:t,active:n===e.path,onOpen:r},e.path);let o=i.has(e.path);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),className:`flex w-full items-center gap-1 py-1 pr-3 text-left transition-colors hover:bg-elevated`,style:{paddingLeft:8+t*12},children:[o?(0,K.jsx)(Tt,{className:`size-3.5 shrink-0 text-fg-gold`}):(0,K.jsx)(Ct,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,K.jsx)(`span`,{className:`truncate font-mono text-xs text-fg-secondary`,children:e.name})]}),!o&&(0,K.jsx)(Qa,{nodes:e.children,depth:t+1,activePath:n,onOpen:r})]},e.path)})})}function $a({session:e,activePath:t,onOpen:n}){let[r,i]=(0,q.useState)(!1),a=l(e,{against:`head`}),o=a.data?.entries??[],s=(0,q.useMemo)(()=>r?null:Ya(o),[r,o]),c=(0,q.useMemo)(()=>r?Xa(o):null,[r,o]);return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex h-7 shrink-0 items-center gap-2 px-3`,children:[(0,K.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Uncommitted`}),o.length>0&&(0,K.jsx)(`span`,{className:`truncate font-mono text-2xs text-fg-muted`,children:ka(o)}),(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":!r,onClick:()=>i(e=>!e),className:`ml-auto rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[r?(0,K.jsx)(On,{className:`size-3.5`}):(0,K.jsx)(wn,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:r?`Show as tree`:`Show as flat list`})]})}),(0,K.jsx)(Gt,{children:r?`Show as tree`:`Show as flat list`})]})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-1`,children:a.isPending?(0,K.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`Loading changes…`}):a.error?(0,K.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:a.error instanceof Error?a.error.message:`Failed to load changes`}):o.length===0?(0,K.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`No uncommitted changes.`}):r?c.map(e=>(0,K.jsx)(Za,{name:e.path,fullPath:e.path,status:e.entry.status,depth:0,active:t===e.path,onOpen:n},e.path)):(0,K.jsx)(Qa,{nodes:s,depth:0,activePath:t,onOpen:n})})]})}function eo({session:e,activeDiffPath:t,onOpenDiff:n,onOpenCommitFile:r}){return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsx)(`section`,{className:`flex max-h-[45%] min-h-0 flex-col`,children:(0,K.jsx)($a,{session:e,activePath:t,onOpen:n})}),(0,K.jsx)(`div`,{className:`h-px shrink-0 bg-border`}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsx)(`div`,{className:`flex h-7 shrink-0 items-center px-3`,children:(0,K.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`History`})}),(0,K.jsx)(Ga,{session:e,onOpenCommitFile:r})]})]})}var to={"package.json":dn,"package-lock.json":gn,"pnpm-lock.yaml":gn,"yarn.lock":gn,"pnpm-workspace.yaml":fn,dockerfile:G,".gitignore":fn,".gitattributes":fn,"readme.md":bn,license:bn,licence:bn},no={ts:G,tsx:G,mts:G,cts:G,js:G,jsx:G,mjs:G,cjs:G,py:G,rs:G,go:G,rb:G,php:G,java:G,kt:G,c:G,h:G,cpp:G,hpp:G,cc:G,html:G,htm:G,xml:G,vue:G,sql:G,json:dn,jsonc:dn,yml:fn,yaml:fn,toml:fn,ini:fn,cfg:fn,conf:fn,env:hn,lock:gn,csv:vn,tsv:vn,xlsx:vn,xls:vn,md:bn,mdx:bn,markdown:bn,txt:bn,rtf:bn,log:bn,pdf:bn,css:xn,scss:xn,sass:xn,less:xn,sh:yn,bash:yn,zsh:yn,fish:yn,svg:mn,png:mn,jpg:mn,jpeg:mn,gif:mn,webp:mn,bmp:mn,ico:mn,avif:mn,mp4:_n,mov:_n,webm:_n,mkv:_n,avi:_n,mp3:pn,wav:pn,flac:pn,ogg:pn,m4a:pn,zip:un,tar:un,gz:un,tgz:un,rar:un,"7z":un};function ro(e){let t=e.toLowerCase(),n=to[t];if(n)return{Icon:n,generic:!1};let r=t.lastIndexOf(`.`);if(r>0){let e=no[t.slice(r+1)];if(e)return{Icon:e,generic:!1}}return{Icon:Sn,generic:!0}}function io({name:e,dimmed:t}){let{Icon:n,generic:r}=ro(e);return(0,K.jsx)(n,{className:H(`size-3.5 shrink-0`,t||r?`text-fg-muted`:`text-fg`)})}function ao(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function oo(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function so(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n<=0?`/`:t.slice(0,n)}function co(e,t){return e===``?t:`${e}/${t}`}function lo(e){let t=new Set(e);return e.filter(e=>{if(e===``)return!0;for(let n=oo(e);;n=oo(n)){if(t.has(n))return!1;if(n===``)return!0}})}var uo=`application/x-puddle-paths`;function fo(e){return JSON.stringify(e)}function po(e){try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function mo(e,t){let n=[],r=(i,a)=>{let o=e(i);if(o)for(let e of o.entries){let o=co(i,e.name);n.push({path:o,name:e.name,type:e.type,depth:a,parentDir:i}),e.type===`dir`&&t.has(o)&&r(o,a+1)}};return r(``,0),n}function ho(e,t,n){let r=e.findIndex(e=>e.path===t),i=e.findIndex(e=>e.path===n);if(r===-1||i===-1)return n?[n]:[];let[a,o]=r<=i?[r,i]:[i,r];return e.slice(a,o+1).map(e=>e.path)}function go({sid:e,root:t,onNavigateUp:n,onReset:r,onOpenFile:i}){let a=V();return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-1 px-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:n,disabled:t===`/`,title:`Parent directory`,className:`shrink-0 rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg disabled:pointer-events-none disabled:opacity-40`,children:[(0,K.jsx)(Et,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Parent directory`})]}),(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-fg-secondary`,title:t,children:kt(t,a.data?.home)}),(0,K.jsxs)(`button`,{type:`button`,onClick:r,title:`Back to the worktree`,className:`ml-auto shrink-0 rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(Rn,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Back to the worktree`})]})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:(0,K.jsx)(_o,{sid:e,root:t,dir:``,depth:0,onOpenFile:i})})]})}function _o({sid:e,root:t,dir:n,depth:r,onOpenFile:i}){let a=c(e,n,t),[o,s]=(0,q.useState)(new Set);return a.isPending?(0,K.jsx)(`div`,{className:`px-3 py-1 text-2xs text-fg-muted`,style:{paddingLeft:r*12+12},children:`…`}):a.error?(0,K.jsx)(`div`,{className:`px-3 py-1 text-2xs text-fg-muted`,style:{paddingLeft:r*12+12},children:a.error instanceof Error?a.error.message:`Unreadable`}):(0,K.jsxs)(K.Fragment,{children:[a.data.entries.map(a=>{let c=co(n,a.name),l=a.type===`dir`,u=o.has(c);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{l?s(e=>{let t=new Set(e);return t.has(c)?t.delete(c):t.add(c),t}):i(c)},onDoubleClick:()=>{l||i(c,{preview:!1})},className:`flex w-full items-center gap-1.5 py-0.5 pr-2 text-left transition-colors hover:bg-elevated`,style:{paddingLeft:r*12+8},children:[(0,K.jsx)(Tt,{className:H(`size-3 shrink-0 text-fg-muted transition-transform`,u&&`rotate-90`,!l&&`invisible`)}),l?u?(0,K.jsx)(Ft,{className:`size-3.5 shrink-0 text-fg`}):(0,K.jsx)(Cn,{className:`size-3.5 shrink-0 text-fg`}):(0,K.jsx)(io,{name:a.name}),(0,K.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:a.name}),a.symlink&&(0,K.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:`→`})]}),l&&u&&(0,K.jsx)(_o,{sid:e,root:t,dir:c,depth:r+1,onOpenFile:i})]},c)}),a.data.entries.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-1 text-2xs text-fg-muted`,style:{paddingLeft:r*12+12},children:`Empty.`})]})}async function vo(e){let t=e.createReader(),n=[];for(;;){let e=await new Promise((e,n)=>t.readEntries(e,n));if(e.length===0)return n;n.push(...e)}}function yo(e){return new Promise((t,n)=>e.file(t,n))}async function bo(e,t,n){if(e.isFile){let r=await yo(e);n.push(t?new File([r],`${t}/${e.name}`,{type:r.type,lastModified:r.lastModified}):r)}else if(e.isDirectory){let r=await vo(e),i=t?`${t}/${e.name}`:e.name;for(let e of r)await bo(e,i,n)}}function xo(e,t,n){let r=Array.from(e??[]).map(e=>({entry:e.webkitGetAsEntry?.()??null,file:e.kind===`file`?e.getAsFile():null})),i=Array.from(t);return(async()=>{if(r.every(({entry:e,file:t})=>e===null&&t===null))return i;if(!n)return r.some(({entry:e})=>e?.isDirectory)&&k.error(`This daemon can't take folders — update it, or zip them first`),r.filter(({entry:e})=>e?.isDirectory!==!0).map(({file:e})=>e).filter(e=>e!==null);let e=[];for(let{entry:t,file:n}of r)t?.isDirectory?await bo(t,``,e):n&&e.push(n);return e})()}var So={untracked:{letter:`U`,colourClass:`text-success`},added:{letter:`A`,colourClass:`text-success`},modified:{letter:`M`,colourClass:`text-warning`},renamed:{letter:`R`,colourClass:`text-warning`},deleted:{letter:`D`,colourClass:`text-interrupted`},conflicted:{letter:`C`,colourClass:`text-interrupted`},ignored:{letter:``,colourClass:`text-fg-muted`}};function Co(e){return So[e]}function wo(e){let t=new Map;for(let n of e)t.set(n.path,n.status);return t}var To={conflicted:0,modified:1,renamed:2,deleted:3,added:4,untracked:5,ignored:6};function Eo(e,t){let n=t===``?``:`${t}/`,r=null;for(let[t,i]of e)n!==``&&!t.startsWith(n)||i!==`ignored`&&(r===null||To[i]<To[r])&&(r=i);return r}var Do=(e,t)=>e instanceof Error?e.message:t;function Oo(e){let t=i(),n=(0,q.useCallback)(()=>{t.invalidateQueries({queryKey:[`wt-tree`,e]}),t.invalidateQueries({queryKey:[`wt-git-status`,e]})},[t,e]);return(0,q.useMemo)(()=>({async create(t,r,i){try{let a=await D(e,co(t,r),i);return n(),a.path}catch(e){return k.error(Do(e,`Couldn't create ${r}`)),null}},async rename(t,r){let i=co(t.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)):``,r);try{let r=await u(e,t,i);return n(),r.path}catch(e){return k.error(Do(e,`Couldn't rename ${ao(t)}`)),null}},async move(t,r){let i=await Promise.allSettled(t.map(t=>u(e,t,co(r,ao(t)))));n();let a=i.filter(e=>e.status===`rejected`);a.length>0&&k.error(t.length===1?Do(a[0].reason,`Couldn't move ${ao(t[0])}`):`Couldn't move ${a.length} item${a.length>1?`s`:``}`)},async remove(t){let r=await Promise.allSettled(t.map(t=>m(e,t)));n();let i=r.filter(e=>e.status===`rejected`).length;i>0?k.error(`Couldn't delete ${i} item${i>1?`s`:``}`):k.success(t.length===1?`Deleted ${ao(t[0])}`:`Deleted ${t.length} items`)},async paste(t,r){let i=t.mode===`cut`?u:w,a=await Promise.allSettled(t.paths.map(t=>i(e,t,co(r,ao(t)))));n();let o=a.filter(e=>e.status===`rejected`).length;o>0&&k.error(`Couldn't paste ${o} item${o>1?`s`:``}`)}}),[e,n])}function ko(e,t,n){return n&&n.type!==`dir`||(e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``)===t?!1:t===``||!`${t}/`.startsWith(`${e}/`)}var Ao=(0,q.createContext)(null);function jo(){let e=(0,q.useContext)(Ao);if(!e)throw Error(`explorer components must render inside <ExplorerProvider>`);return e}function Mo(){return(0,q.useContext)(Ao)}function No({session:e,onOpenFile:t,onOpenTerminal:n,activePath:r,children:a}){let s=e.id,c=i(),l=Oo(s),u=(0,q.useCallback)((e,t)=>{t.length!==0&&T(s,e,t).then(()=>{c.invalidateQueries({queryKey:[`wt-tree`,s,e]}),c.invalidateQueries({queryKey:[`wt-git-status`,s]}),k.success(t.length===1?`Uploaded ${t[0].name}`:`Uploaded ${t.length} files`)}).catch(e=>k.error(e instanceof Error?e.message:`Upload failed`))},[s,c]),d=He().data?.protocol,f=!d||d.major>9||d.major===9&&d.minor>=2,p=(0,q.useCallback)((e,t,n)=>{xo(t,n,f).then(t=>u(e,t)).catch(e=>k.error(e instanceof Error?e.message:`Couldn't read the dropped folder`))},[u,f]),[m,h]=(0,q.useState)(new Set),[g,_]=(0,q.useState)(new Set),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(null),[w,D]=(0,q.useState)(null),[O,ee]=(0,q.useState)(null),A=(0,q.useRef)(null),j=o(s),te=(0,q.useMemo)(()=>wo(j.data?.entries??[]),[j.data]),[ne,re]=(0,q.useState)(0);(0,q.useEffect)(()=>c.getQueryCache().subscribe(e=>{if(e.type!==`added`&&e.type!==`removed`&&e.type!==`updated`)return;let t=e.query.queryKey;Array.isArray(t)&&t[0]===`wt-tree`&&t[1]===s&&re(e=>e+1)}),[c,s]);let M=(0,q.useMemo)(()=>mo(e=>c.getQueryData([`wt-tree`,s,e]),m),[c,s,m,ne]),N=(0,q.useCallback)(e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),P=(0,q.useCallback)(e=>{h(t=>t.has(e)?t:new Set(t).add(e))},[]),ie=(0,q.useCallback)(()=>h(new Set),[]),F=(0,q.useCallback)((e,n)=>{if(y(e.path),n.metaKey||n.ctrlKey){_(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),A.current=e.path;return}if(n.shiftKey&&A.current){_(new Set(ho(M,A.current,e.path)));return}_(new Set([e.path])),A.current=e.path,e.type===`dir`?N(e.path):t?.(s,e.path)},[M,N,t,s]),I=(0,q.useCallback)(e=>{e.type!==`dir`&&t?.(s,e.path,{preview:!1})},[t,s]),ae=(0,q.useCallback)(e=>{_(new Set([e])),y(e),A.current=e},[]),oe=(0,q.useCallback)(e=>x({paths:lo(e),mode:`cut`}),[]),L=(0,q.useCallback)(e=>x({paths:lo(e),mode:`copy`}),[]),R=(0,q.useCallback)(e=>{b&&l.paste(b,e).then(()=>{b.mode===`cut`&&x(null)})},[b,l]),z=(0,q.useCallback)(e=>C({mode:`rename`,path:e}),[]),se=(0,q.useCallback)((e,t)=>{e!==``&&P(e),C({mode:`create`,parentDir:e,kind:t})},[P]),ce=(0,q.useCallback)(()=>C(null),[]),le=(0,q.useCallback)(e=>{let n=e.trim(),r=S;if(C(null),!(!r||n===``))if(r.mode===`rename`){if(n===ao(r.path))return;l.rename(r.path,n)}else l.create(r.parentDir,n,r.kind).then(e=>{e&&r.kind===`file`&&t?.(s,e)})},[S,l,t,s]),B=(0,q.useCallback)(e=>{let t=lo(e);t.length>0&&ee(t)},[]),ue=(0,q.useCallback)(()=>{let e=O;ee(null),e&&l.remove(e)},[O,l]),de=(0,q.useCallback)(()=>ee(null),[]),fe=(0,q.useCallback)((t,n)=>{let r=t.map(t=>n?t:co(e.worktree_path,t)).join(`
3
- `);navigator.clipboard.writeText(r);let i=n?`Relative path`:`Path`;k.success(t.length>1?`${t.length} ${i.toLowerCase()}s copied`:`${i} copied`)},[e.worktree_path]),pe=(0,q.useCallback)(e=>{(async()=>{for(let t of lo(e))await E(s,t)})().catch(e=>k.error(e instanceof Error?e.message:`Download failed`))},[s]),me=(0,q.useCallback)(()=>{c.invalidateQueries({queryKey:[`wt-tree`,s]}),c.invalidateQueries({queryKey:[`wt-git-status`,s]})},[c,s]),he=(0,q.useCallback)((e,t)=>{let n=lo(t).filter(t=>ko(t,e));n.length>0&&l.move(n,e)},[l]),V=(0,q.useCallback)(()=>v&&g.has(v)?[...g]:v?[v]:[...g],[v,g]),ge=(0,q.useRef)({buffer:``,at:0}),_e=(0,q.useCallback)(e=>{if(S)return;let n=M;if(n.length===0)return;let r=v?n.findIndex(e=>e.path===v):-1,i=(e,t)=>{let r=n[Math.max(0,Math.min(n.length-1,e))];r&&(y(r.path),t&&A.current?_(new Set(ho(n,A.current,r.path))):(_(new Set([r.path])),A.current=r.path))},a=r>=0?n[r]:void 0,o=e.metaKey||e.ctrlKey;switch(e.key){case`ArrowDown`:e.preventDefault(),i(r+1,e.shiftKey);return;case`ArrowUp`:e.preventDefault(),i(r<=0?0:r-1,e.shiftKey);return;case`ArrowRight`:e.preventDefault(),a?.type===`dir`&&!m.has(a.path)?P(a.path):a?.type===`dir`&&i(r+1,!1);return;case`ArrowLeft`:if(e.preventDefault(),a?.type===`dir`&&m.has(a.path))N(a.path);else if(a){let e=n.findIndex(e=>e.path===a.parentDir);e>=0&&i(e,!1)}return;case`Enter`:case` `:if(e.preventDefault(),!a)return;a.type===`dir`?N(a.path):t?.(s,a.path);return;case`F2`:e.preventDefault(),a&&z(a.path);return;case`Delete`:e.preventDefault(),B(V());return;case`Backspace`:o&&(e.preventDefault(),B(V()));return}if(o&&(e.key===`c`||e.key===`C`)){e.preventDefault();let t=V();e.altKey?fe(t,e.shiftKey):L(t);return}if(o&&(e.key===`x`||e.key===`X`)){e.preventDefault(),oe(V());return}if(o&&(e.key===`v`||e.key===`V`)){e.preventDefault();let t=a?a.type===`dir`?a.path:a.parentDir:``;R(t);return}if(!o&&!e.altKey&&e.key.length===1&&/\S/.test(e.key)){let t=Date.now(),a=ge.current;a.buffer=t-a.at>700?e.key:a.buffer+e.key,a.at=t;let o=a.buffer.toLowerCase(),s=r+1;for(let e=0;e<n.length;e++){let t=n[(s+e)%n.length];if(t.name.toLowerCase().startsWith(o)){i(n.findIndex(e=>e.path===t.path),!1);break}}}},[S,M,v,m,P,N,t,s,z,B,V,L,oe,R,fe]),ve={sid:s,worktreePath:e.worktree_path,onOpenFile:t,onOpenTerminal:n,activePath:r,expanded:m,toggle:N,collapseAll:ie,statusMap:te,visibleRows:M,selection:g,focusedPath:v,onRowClick:F,onRowDoubleClick:I,selectOnly:ae,clipboard:b,cut:oe,copy:L,paste:R,editing:S,beginRename:z,beginCreate:se,cancelEdit:ce,commitEdit:le,requestDelete:B,copyPathToClipboard:fe,download:pe,refresh:me,onUpload:u,onDropUpload:p,dropTarget:w,setDropTarget:D,onInternalDrop:he,handleKeyDown:_e,pendingDelete:O,confirmDelete:ue,cancelDelete:de};return(0,K.jsx)(Ao.Provider,{value:ve,children:a})}var Po=`application/x-puddle-tab`;function Fo(e){return JSON.stringify(e)}function Io(e){try{return A.parse(JSON.parse(e))}catch{return null}}function Lo(e){return e.includes(Po)}var Ro=14;function zo(e,t){let n=document.createElement(`div`);n.textContent=`${t} items`,n.className=`fixed -top-12 left-0 rounded-md bg-elevated px-2 py-1 font-mono text-xs text-fg`,document.body.appendChild(n),e.dataTransfer.setDragImage(n,12,12),requestAnimationFrame(()=>n.remove())}function Bo({children:e}){return(0,K.jsx)(`span`,{className:`ml-auto pl-6 text-2xs text-fg-muted tabular-nums`,children:e})}function Vo({depth:e,initial:t,icon:n,onCommit:r,onCancel:i}){let a=(0,q.useRef)(null),o=(0,q.useRef)(!1);(0,q.useEffect)(()=>{let e=a.current;if(!e)return;let n=()=>{e.focus();let n=t.lastIndexOf(`.`);e.setSelectionRange(0,n>0?n:t.length)};n();let r=requestAnimationFrame(()=>{document.activeElement!==e&&n()});return()=>cancelAnimationFrame(r)},[t]);let s=()=>{o.current||(o.current=!0,r(a.current?.value??``))};return(0,K.jsxs)(`div`,{className:`flex h-6 items-center gap-1 pr-2`,style:{paddingLeft:e*Ro+8},children:[(0,K.jsx)(`span`,{className:`size-3.5 shrink-0`}),n,(0,K.jsx)(`input`,{ref:a,defaultValue:t,spellCheck:!1,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?s():e.key===`Escape`&&(o.current=!0,i())},onBlur:s,className:`min-w-0 flex-1 bg-surface font-mono text-sm text-fg outline-none`})]})}function Ho({path:e,entry:t,depth:n}){let r=jo(),i=t.type===`dir`,a=i&&r.expanded.has(e),o=i&&r.dropTarget===e,s=!i&&e===r.activePath,c=r.selection.has(e),l=r.clipboard?.mode===`cut`&&r.clipboard.paths.includes(e),u={path:e,name:t.name,type:t.type,depth:n,parentDir:oo(e)},d=r.statusMap.get(e),f=i?Eo(r.statusMap,e):null,p=d?Co(d):f?Co(f):null,m=p?p.colourClass:t.name.startsWith(`.`)?`text-fg-muted`:`text-fg`,h=c&&r.selection.size>1?[...r.selection]:[e],g=i?e:oo(e),_=r.clipboard!==null;return r.editing?.mode===`rename`&&r.editing.path===e?(0,K.jsx)(Vo,{depth:n,initial:t.name,icon:i?(0,K.jsx)(Cn,{className:`size-3.5 shrink-0 text-fg`}):(0,K.jsx)(io,{name:t.name}),onCommit:r.commitEdit,onCancel:r.cancelEdit}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(ft,{children:[(0,K.jsx)($e,{asChild:!0,children:(0,K.jsxs)(`div`,{role:`treeitem`,"data-path":e,"aria-expanded":i?a:void 0,"aria-selected":c,tabIndex:-1,draggable:!0,onClick:e=>{e.currentTarget.closest(`[data-explorer-root]`)?.focus(),r.onRowClick(u,e)},onDoubleClick:()=>r.onRowDoubleClick(u),onContextMenu:()=>{c||r.selectOnly(e)},onDragStart:t=>{let n=lo(h);t.dataTransfer.setData(uo,fo(n)),n.length>1&&zo(t,n.length),!i&&n.length===1&&t.dataTransfer.setData(Po,Fo({type:`editor`,tab:{kind:`file`,session:r.sid,path:e}})),t.dataTransfer.effectAllowed=`copyMove`},onDragOver:t=>{i&&(t.preventDefault(),t.stopPropagation(),r.setDropTarget(e))},onDragLeave:e=>{i&&e.currentTarget===e.target&&r.setDropTarget(null)},onDrop:t=>{if(!i)return;t.preventDefault(),t.stopPropagation(),r.setDropTarget(null);let n=po(t.dataTransfer.getData(uo));n.length>0?r.onInternalDrop(e,n):r.onDropUpload(e,t.dataTransfer.items,t.dataTransfer.files)},style:{paddingLeft:n*Ro+8},className:H(`flex h-6 cursor-pointer items-center gap-1 pr-2 text-sm transition-colors hover:bg-elevated`,c?`bg-selection`:s&&`bg-elevated`,o&&`bg-selection`,l&&`opacity-50`),children:[i?(0,K.jsx)(Tt,{className:H(`size-3.5 shrink-0 text-fg-gold transition-transform duration-150`,a&&`rotate-90`)}):(0,K.jsx)(`span`,{className:`size-3.5 shrink-0`}),t.symlink||t.type===`symlink`?(0,K.jsx)(Dn,{className:`size-3.5 shrink-0 text-fg`}):i?a?(0,K.jsx)(Ft,{className:H(`size-3.5 shrink-0`,f?p?.colourClass:`text-fg`)}):(0,K.jsx)(Cn,{className:H(`size-3.5 shrink-0`,f?p?.colourClass:`text-fg`)}):(0,K.jsx)(io,{name:t.name,dimmed:d===`ignored`}),(0,K.jsx)(`span`,{className:H(`min-w-0 flex-1 truncate font-mono`,m),children:t.name}),d&&p&&p.letter&&(0,K.jsx)(`span`,{className:H(`shrink-0 font-mono text-2xs`,p.colourClass),children:p.letter})]})}),(0,K.jsxs)(ct,{onCloseAutoFocus:e=>{r.editing&&e.preventDefault()},children:[i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(W,{onSelect:()=>r.beginCreate(e,`file`),children:`New File…`}),(0,K.jsx)(W,{onSelect:()=>r.beginCreate(e,`dir`),children:`New Folder…`}),r.onOpenTerminal&&(0,K.jsx)(W,{onSelect:()=>r.onOpenTerminal?.(e),children:`Open Terminal in Directory`}),(0,K.jsx)(it,{})]}),(0,K.jsxs)(W,{onSelect:()=>r.cut(h),children:[`Cut `,(0,K.jsx)(Bo,{children:`⌘X`})]}),(0,K.jsxs)(W,{onSelect:()=>r.copy(h),children:[`Copy `,(0,K.jsx)(Bo,{children:`⌘C`})]}),(0,K.jsxs)(W,{disabled:!_,onSelect:()=>r.paste(g),children:[`Paste `,(0,K.jsx)(Bo,{children:`⌘V`})]}),(0,K.jsx)(it,{}),(0,K.jsxs)(W,{onSelect:()=>r.copyPathToClipboard(h,!1),children:[`Copy Path `,(0,K.jsx)(Bo,{children:`⌥⌘C`})]}),(0,K.jsxs)(W,{onSelect:()=>r.copyPathToClipboard(h,!0),children:[`Copy Relative Path `,(0,K.jsx)(Bo,{children:`⌥⇧⌘C`})]}),(0,K.jsx)(it,{}),(0,K.jsxs)(W,{onSelect:()=>r.beginRename(e),children:[`Rename… `,(0,K.jsx)(Bo,{children:`F2`})]}),(0,K.jsxs)(W,{onSelect:()=>r.requestDelete(h),children:[`Delete `,(0,K.jsx)(Bo,{children:`⌘⌫`})]}),(0,K.jsx)(it,{}),(0,K.jsx)(W,{onSelect:()=>r.download(h),children:`Download`})]})]}),i&&a&&(0,K.jsx)(Uo,{sid:r.sid,path:e,depth:n+1})]})}function Uo({sid:e,path:t,depth:n}){let r=jo(),i=c(e,t),a={paddingLeft:n*Ro+8},o=r.editing,s=o?.mode===`create`&&o.parentDir===t?(0,K.jsx)(Wo,{depth:n,kind:o.kind}):null;if(i.isLoading)return(0,K.jsxs)(K.Fragment,{children:[s,(0,K.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:`Loading…`})]});if(i.isError)return(0,K.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Couldn't load this folder.`});let l=i.data?.entries??[];return l.length===0&&!s?(0,K.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:`Empty`}):(0,K.jsxs)(K.Fragment,{children:[s,l.map(e=>(0,K.jsx)(Ho,{path:co(t,e.name),entry:e,depth:n},e.name))]})}function Wo({depth:e,kind:t}){let n=jo(),[r,i]=(0,q.useState)(``);return(0,K.jsx)(Vo,{depth:e,initial:r,icon:t===`dir`?(0,K.jsx)(Cn,{className:`size-3.5 shrink-0 text-fg`}):(0,K.jsx)(io,{name:r||`file`}),onCommit:e=>{i(e),n.commitEdit(e)},onCancel:n.cancelEdit})}function Go(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ko,{}),(0,K.jsx)(qo,{})]})}function Ko(){let e=jo(),t=(0,q.useRef)(null);(0,q.useEffect)(()=>{!e.focusedPath||!t.current||t.current.querySelector(`[data-path="${CSS.escape(e.focusedPath)}"]`)?.scrollIntoView({block:`nearest`})},[e.focusedPath]);let n=e.clipboard!==null;return(0,K.jsxs)(ft,{children:[(0,K.jsx)($e,{asChild:!0,children:(0,K.jsx)(`div`,{ref:t,"data-explorer-root":!0,role:`tree`,tabIndex:0,onKeyDown:e.handleKeyDown,onPaste:t=>e.onDropUpload(``,t.clipboardData.items,t.clipboardData.files),onDragOver:t=>{t.preventDefault(),e.setDropTarget(``)},onDragLeave:t=>{t.currentTarget===t.target&&e.setDropTarget(null)},onDrop:t=>{t.preventDefault(),e.setDropTarget(null);let n=po(t.dataTransfer.getData(uo));n.length>0?e.onInternalDrop(``,n):e.onDropUpload(``,t.dataTransfer.items,t.dataTransfer.files)},className:H(`h-full overflow-y-auto py-1 outline-none`,e.dropTarget===``&&`bg-selection`),children:(0,K.jsx)(Uo,{sid:e.sid,path:``,depth:0})})}),(0,K.jsxs)(ct,{onCloseAutoFocus:t=>{e.editing&&t.preventDefault()},children:[(0,K.jsx)(W,{onSelect:()=>e.beginCreate(``,`file`),children:`New File…`}),(0,K.jsx)(W,{onSelect:()=>e.beginCreate(``,`dir`),children:`New Folder…`}),(0,K.jsx)(it,{}),(0,K.jsx)(W,{disabled:!n,onSelect:()=>e.paste(``),children:`Paste`}),(0,K.jsx)(it,{}),(0,K.jsx)(W,{onSelect:()=>e.copyPathToClipboard([``],!1),children:`Copy Path`}),(0,K.jsx)(W,{onSelect:()=>e.download([``]),children:`Download worktree`})]})]})}function qo(){let e=jo(),t=e.pendingDelete;return(0,K.jsx)(ce,{open:t!==null,onOpenChange:t=>!t&&e.cancelDelete(),children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsxs)(z,{children:[`Delete `,t&&t.length===1?`“${ao(t[0])}”`:`${t?.length??0} items`,`?`]}),(0,K.jsxs)(se,{children:[`This permanently removes `,t&&t.length>1?`them`:`it`,` from the worktree. There is no undo.`]})]}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{variant:`ghost`,onClick:e.cancelDelete,children:`Cancel`}),(0,K.jsx)(I,{variant:`danger`,onClick:e.confirmDelete,children:`Delete`})]})]})})}var Jo=/[.*+?^${}()|[\]\\]/g;function Yo(e){if(e.query.length===0)return null;try{let t=e.regex?e.query:e.query.replace(Jo,`\\$&`);return e.wholeWord&&(t=`\\b(?:${t})\\b`),new RegExp(t,e.caseSensitive?`g`:`gi`)}catch{return null}}function Xo(e,t){if(!t)return[{text:e,hit:!1}];let n=[],r=0;t.lastIndex=0;let i;for(;(i=t.exec(e))!==null;){if(i[0].length===0){t.lastIndex++;continue}i.index>r&&n.push({text:e.slice(r,i.index),hit:!1}),n.push({text:i[0],hit:!0}),r=i.index+i[0].length}return r<e.length&&n.push({text:e.slice(r),hit:!1}),n.length>0?n:[{text:e,hit:!1}]}var Zo=240;function Qo(e){let t=e.replace(/^\s+/,``);return t.length>Zo?`${t.slice(0,Zo)}…`:t}var $o=250;function es({active:e,label:t,onClick:n,children:r}){return(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:n,className:H(`rounded-sm p-1 transition-colors`,e?`bg-elevated text-accent`:`text-fg-muted hover:bg-elevated hover:text-fg`),children:[r,(0,K.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,K.jsx)(Gt,{children:t})]})}function ts({session:e,onOpen:t}){let[n,r]=(0,q.useState)(``),[i,a]=(0,q.useState)(``),[o,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let e=setTimeout(()=>a(n),$o);return()=>clearTimeout(e)},[n]);let p={query:i,regex:o,caseSensitive:l,wholeWord:d},m=s(e,p),h=(0,q.useMemo)(()=>Yo(p),[i,o,l,d]),g=m.data,_=!!g&&(g.files.length>0||g.content.length>0);return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 px-2 py-1.5`,children:[(0,K.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Search files and contents`,spellCheck:!1,autoComplete:`off`,className:`rounded-md bg-elevated px-2 py-1 font-mono text-xs text-fg outline-none placeholder:text-fg-muted`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(es,{active:l,label:`Match case`,onClick:()=>u(e=>!e),children:(0,K.jsx)(rn,{className:`size-3.5`})}),(0,K.jsx)(es,{active:d,label:`Match whole word`,onClick:()=>f(e=>!e),children:(0,K.jsx)(Bn,{className:`size-3.5`})}),(0,K.jsx)(es,{active:o,label:`Use regular expression`,onClick:()=>c(e=>!e),children:(0,K.jsx)(Fn,{className:`size-3.5`})})]})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:i.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Search file names and contents.`}):m.isPending?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Searching…`}):m.error?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:m.error instanceof Error?m.error.message:`Search failed`}):_?(0,K.jsxs)(K.Fragment,{children:[g.files.length>0&&(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`div`,{className:`px-3 pb-0.5 pt-1.5 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Files`}),g.files.map(e=>(0,K.jsxs)(`button`,{type:`button`,title:e,onClick:()=>t(e),className:`flex w-full items-center gap-1.5 px-3 py-1 text-left transition-colors hover:bg-elevated`,children:[(0,K.jsx)(Sn,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,K.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:e})]},e))]}),g.content.length>0&&(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`div`,{className:`px-3 pb-0.5 pt-2 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Contents`}),g.content.map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`truncate px-3 py-1 font-mono text-2xs text-fg-secondary`,title:e.path,children:e.path}),e.matches.map((n,r)=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(e.path,n.line),className:`flex w-full items-baseline gap-2 py-0.5 pl-6 pr-3 text-left transition-colors hover:bg-elevated`,children:[(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-2xs tabular-nums text-fg-muted`,children:n.line}),(0,K.jsx)(`span`,{className:`truncate font-mono text-2xs text-fg-secondary`,children:Xo(Qo(n.text),h).map((e,t)=>e.hit?(0,K.jsx)(`span`,{className:`text-accent`,children:e.text},t):(0,K.jsx)(`span`,{children:e.text},t))})]},`${n.line}:${r}`))]},e.path))]}),g.truncated&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-2xs text-fg-muted`,children:`Showing the first results — refine the query for more.`})]}):(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No results.`})})]})}var ns=new Set([`starting`,`running`,`waiting_input`]),rs=`group-hover:[transform:translateX(var(--tail))]`;function is(e){return e.split(`/`).filter(Boolean).pop()??e}function as({children:e,className:t,title:n}){return(0,K.jsx)(`span`,{title:n,className:H(`shrink-0 text-2xs`,t),children:e})}function os({label:e,blockReason:t,onClick:n}){return(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,disabled:t!==null,onClick:n,className:H(`-my-1 rounded-sm p-1 text-fg-gold transition-colors hover:text-danger`,t===null?`hidden group-hover:inline-flex pointer-coarse:inline-flex`:`hidden`),children:[(0,K.jsx)(At,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:e})]})}),(0,K.jsx)(Gt,{children:t?`Can't ${e.toLowerCase()} — ${t}`:e})]})}function ss({repoId:e,projectId:t,sessions:n}){let r=be(e),i=he(e,t),a=de(e,t),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),u=i.isPending||a.isPending,d=(0,q.useMemo)(()=>{let e=new Map;for(let t of n)ns.has(t.status)&&e.set(t.worktree_path,(e.get(t.worktree_path)??0)+1);return e},[n]),f=(0,q.useMemo)(()=>{let e=new Map;for(let t of r.data?.worktrees??[]){let n=t.branch??`(detached)`;(e.get(n)??e.set(n,[]).get(n)).push(t)}return[...e.entries()].sort(([,e],[,t])=>!e.some(e=>e.is_primary)-+!t.some(e=>e.is_primary)||(e[0]?.branch??``).localeCompare(t[0]?.branch??``))},[r.data]),p=(0,q.useMemo)(()=>[...r.data?.orphan_branches??[]].sort((e,t)=>e.name.localeCompare(t.name)),[r.data]);return r.isPending?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading worktrees…`}):r.error?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load worktrees`}):(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[f.length===0&&p.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktrees.`}),f.map(([e,t])=>(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`group flex items-center gap-1.5 px-3 pb-0.5 pt-2 text-2xs text-fg-muted`,children:[(0,K.jsx)(En,{className:`size-3 shrink-0 text-fg-gold`}),(0,K.jsx)(Ta,{text:e,className:`font-mono`,hoverClass:rs})]}),t.map(e=>{let t=d.get(e.path)??0,n=e.is_primary?`the repository clone`:e.dirty?`uncommitted changes`:t>0?`${t} running session${t>1?`s`:``}`:null;return(0,K.jsxs)(`div`,{className:`group flex items-center gap-2 px-3 py-1 pl-6 transition-colors hover:bg-elevated`,children:[(0,K.jsx)(Ta,{text:is(e.path),title:e.path,className:`font-mono text-xs text-fg`,hoverClass:rs}),e.is_primary&&(0,K.jsx)(as,{className:`text-fg-muted`,children:`clone`}),e.dirty&&(0,K.jsx)(as,{className:`text-warning`,title:`Modified — uncommitted changes`,children:`M`}),t>0&&(0,K.jsx)(as,{className:`text-running`,title:`${t} running session${t>1?`s`:``}`,children:t}),(0,K.jsx)(os,{label:`Prune`,blockReason:n,onClick:()=>{l(null),s({kind:`worktree`,path:e.path,branch:e.branch})}})]},e.path)})]},`wt:${e}`)),p.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`px-3 pb-0.5 pt-3 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Branches without a worktree`}),p.map(e=>(0,K.jsxs)(`div`,{className:`group flex items-center gap-2 px-3 py-1 transition-colors hover:bg-elevated`,children:[(0,K.jsx)(En,{className:`size-3 shrink-0 text-fg-gold`}),(0,K.jsx)(Ta,{text:e.name,className:`font-mono text-xs text-fg`,hoverClass:rs}),e.local_only&&(0,K.jsx)(as,{className:`text-warning`,children:`local only`}),(0,K.jsx)(os,{label:`Delete branch`,blockReason:null,onClick:()=>{l(null),s({kind:`branch`,name:e.name,localOnly:e.local_only})}})]},`br:${e.name}`))]}),(0,K.jsx)(ce,{open:o!==null,onOpenChange:e=>{e||s(null)},children:(0,K.jsxs)(R,{children:[o?.kind===`branch`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:`Delete branch`}),(0,K.jsxs)(se,{children:[`Delete branch `,(0,K.jsx)(`span`,{className:`font-mono`,children:o.name}),`? This removes the branch from the repository.`]})]}),o.localOnly&&(0,K.jsxs)(`p`,{className:`text-xs text-warning`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:o.name}),` has commits on no remote — deleting it discards that work permanently.`]})]}):(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:`Prune worktree`}),(0,K.jsxs)(se,{children:[`Remove `,(0,K.jsx)(`span`,{className:`font-mono`,children:o?is(o.path):``}),`? The working directory is deleted; the branch`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:o?.branch??``}),` is kept.`]})]}),c&&(0,K.jsx)(`p`,{className:`text-xs text-danger`,children:c}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{type:`button`,variant:`ghost`,onClick:()=>s(null),children:`Cancel`}),(0,K.jsx)(I,{type:`button`,variant:`danger`,disabled:u,onClick:()=>{if(!o)return;l(null);let e=e=>l(e.message),t=()=>s(null);o.kind===`worktree`?i.mutate(o.path,{onSuccess:t,onError:e}):a.mutate({name:o.name,confirm:!0},{onSuccess:t,onError:e})},children:o?.kind===`branch`?`Delete`:`Prune`})]})]})})]})}var cs=`DropdownMenu`,[ls,us]=N(cs,[Ye]),ds=Ye(),[fs,ps]=ls(cs),ms=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=ds(t),l=q.useRef(null),[u,d]=P({prop:i,defaultProp:a??!1,onChange:o,caller:cs});return(0,K.jsx)(fs,{scope:t,triggerId:F(),triggerRef:l,contentId:F(),open:u,onOpenChange:d,onOpenToggle:q.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,K.jsx)(Qe,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};ms.displayName=cs;var hs=`DropdownMenuTrigger`,gs=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ps(hs,n),o=ds(n),s=M(t,a.triggerRef);return(0,K.jsx)(ot,{asChild:!0,...o,children:(0,K.jsx)(le.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:L(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:L(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});gs.displayName=hs;var _s=`DropdownMenuPortal`,vs=e=>{let{__scopeDropdownMenu:t,...n}=e,r=ds(t);return(0,K.jsx)(Xe,{...r,...n})};vs.displayName=_s;var ys=`DropdownMenuContent`,bs=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ps(ys,n),a=ds(n),o=q.useRef(!1);return(0,K.jsx)(tt,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:L(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:L(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});bs.displayName=ys;var xs=`DropdownMenuGroup`,Ss=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(ut,{...i,...r,ref:t})});Ss.displayName=xs;var Cs=`DropdownMenuLabel`,ws=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(nt,{...i,...r,ref:t})});ws.displayName=Cs;var Ts=`DropdownMenuItem`,Es=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(st,{...i,...r,ref:t})});Es.displayName=Ts;var Ds=`DropdownMenuCheckboxItem`,Os=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(et,{...i,...r,ref:t})});Os.displayName=Ds;var ks=`DropdownMenuRadioGroup`,As=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(mt,{...i,...r,ref:t})});As.displayName=ks;var js=`DropdownMenuRadioItem`,Ms=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(_t,{...i,...r,ref:t})});Ms.displayName=js;var Ns=`DropdownMenuItemIndicator`,Ps=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(rt,{...i,...r,ref:t})});Ps.displayName=Ns;var Fs=`DropdownMenuSeparator`,Is=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(gt,{...i,...r,ref:t})});Is.displayName=Fs;var Ls=`DropdownMenuArrow`,Rs=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(pt,{...i,...r,ref:t})});Rs.displayName=Ls;var zs=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=ds(t),[s,c]=P({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,K.jsx)(Je,{...o,open:s,onOpenChange:c,children:n})},Bs=`DropdownMenuSubTrigger`,Vs=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(ht,{...i,...r,ref:t})});Vs.displayName=Bs;var Hs=`DropdownMenuSubContent`,Us=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(We,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Us.displayName=Hs;var Ws=ms,Gs=gs,Ks=vs,qs=bs,Js=Es,Ys=Is,Xs=zs,Zs=Vs,Qs=Us,$s=Ws,ec=Gs,tc=Xs;function nc({className:e,sideOffset:t=4,...n}){return(0,K.jsx)(Ks,{children:(0,K.jsx)(qs,{sideOffset:t,className:H(`z-50 min-w-36 overflow-hidden rounded-md bg-elevated p-1 shadow-xl`,e),...n})})}function rc({className:e,...t}){return(0,K.jsx)(Js,{className:H(Me,Ce,`[&_svg]:size-3.5`,e),...t})}function ic({className:e,children:t,...n}){return(0,K.jsxs)(Zs,{className:H(Me,Ce,`data-[state=open]:bg-action data-[state=open]:text-action-ink [&_svg]:size-3.5`,e),...n,children:[t,(0,K.jsx)(Tt,{className:`ml-auto`})]})}function ac({className:e,...t}){return(0,K.jsx)(Ks,{children:(0,K.jsx)(Qs,{className:H(`z-50 min-w-36 overflow-hidden rounded-md bg-elevated p-1 shadow-xl`,e),...t})})}function oc({className:e,...t}){return(0,K.jsx)(Ys,{className:H(`-mx-1 my-1 h-px bg-border`,e),...t})}function sc({text:e,className:t}){let n=(0,q.useRef)(null);return(0,q.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{e.scrollLeft=e.scrollWidth};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[e]),(0,K.jsx)(`div`,{ref:n,className:`no-scrollbar min-w-0 flex-1 overflow-x-auto`,children:(0,K.jsx)(`span`,{className:H(`inline-block whitespace-nowrap`,t),children:e})})}function cc({sessions:e,target:t,showFileActions:n=!1,showPath:r=!1}){let{session:i,pinned:a,pin:o,unpin:s}=t,c=V().data?.home,l=e.filter(e=>e.status!==`archived`),u=i?i.branch||Lt(i):`No worktree`,d=i?kt(i.worktree_path,c):`No worktree`;return(0,K.jsxs)(`div`,{className:`group relative flex h-8 shrink-0 items-center px-2`,children:[(0,K.jsx)(sc,{text:r?d:u,className:`font-mono text-xs text-fg-secondary`}),(0,K.jsxs)(`div`,{className:H(`absolute inset-y-0 right-1 flex items-center gap-1 bg-surface pl-2 opacity-0 transition-opacity`,`pointer-events-none focus-within:pointer-events-auto focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`,a&&`pointer-events-auto opacity-100`),children:[n&&i&&(0,K.jsx)(uc,{}),(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":a,disabled:!i,title:a?`Unpin — follow the active session`:`Pin the sidebar to this worktree`,onClick:()=>a?s():i&&o(i.id),className:H(`shrink-0 rounded-sm p-1 transition-colors disabled:pointer-events-none disabled:opacity-40`,a?`text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(Nn,{className:H(`size-3.5`,a&&`fill-current`)}),(0,K.jsx)(`span`,{className:`sr-only`,children:a?`Unpin sidebar`:`Pin sidebar`})]}),(0,K.jsxs)($s,{children:[(0,K.jsx)(ec,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,title:`Bind a different worktree`,className:`shrink-0 rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(Ct,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose a worktree`})]})}),(0,K.jsx)(nc,{align:`end`,children:l.length===0?(0,K.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-fg-muted`,children:`No sessions yet`}):l.map(e=>(0,K.jsx)(rc,{onSelect:()=>o(e.id),children:(0,K.jsxs)(`span`,{className:`truncate font-mono`,children:[e.branch,` — `,Lt(e)]})},e.id))})]})]})]})}var lc=[{key:`refresh`,label:`Refresh`,icon:Mt},{key:`collapse`,label:`Collapse Folders`,icon:an}];function uc(){let e=Mo();if(!e)return null;let t=t=>{t===`refresh`?e.refresh():t===`collapse`&&e.collapseAll()};return(0,K.jsx)(`div`,{className:`hidden shrink-0 items-center gap-0.5 group-hover:flex group-focus-within:flex`,children:lc.map(({key:e,label:n,icon:r})=>(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(r,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:n})]})}),(0,K.jsx)(Gt,{children:n})]},e))})}var dc=[{key:`files`,label:`Files`,icon:wn},{key:`search`,label:`Search`,icon:qt},{key:`changes`,label:`Changes`,icon:En},{key:`worktrees`,label:`Worktrees`,icon:Ie}];function fc(e){return e===`diff`||e===`history`||e===`changes`?`changes`:e===`search`?`search`:e===`worktrees`?`worktrees`:`files`}function pc({mode:e,onExpand:t,onSelect:n}){return(0,K.jsxs)(`div`,{className:`flex h-full w-9 shrink-0 flex-col items-center gap-1 bg-surface py-1.5`,children:[(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center rounded-md p-1.5 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(An,{className:`size-4`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Show sidebar`})]})}),(0,K.jsx)(Gt,{side:`right`,children:`Show sidebar`})]}),dc.map(({key:t,label:r,icon:i})=>(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"aria-current":e===t?`page`:void 0,onClick:()=>n(t),className:H(`flex items-center rounded-md p-1.5 transition-colors`,e===t?`bg-elevated text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(i,{className:`size-4`}),(0,K.jsx)(`span`,{className:`sr-only`,children:r})]})}),(0,K.jsx)(Gt,{side:`right`,children:r})]},t))]})}function mc({mode:e,onModeChange:t,onCollapse:n,projectId:r,repoId:i,sessions:a,target:o,onOpenFile:s,onOpenExternalFile:c,onOpenTerminalIn:l,activeFilePath:u,activeDiffPath:d,onOpenDiff:f,onOpenCommitFile:p,onOpenSearchFile:m}){let{session:h}=o,[g,_]=(0,q.useState)(null),v=He().data?.protocol,y=!v||v.major>10||v.major===10&&v.minor>=2,b=y&&g!==null&&g.forSession===h?.id?g.root:null,x=e=>{h&&(o.pinned||o.pin(h.id),_({forSession:h.id,root:e}))},S={...o,unpin(){_(null),o.unpin()}};return(0,K.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5`,children:[dc.map(({key:n,label:r,icon:i})=>(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"aria-current":e===n?`page`:void 0,onClick:()=>t(n),className:H(`flex items-center rounded-md p-1.5 transition-colors`,e===n?`bg-elevated text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(i,{className:`size-4`}),(0,K.jsx)(`span`,{className:`sr-only`,children:r})]})}),(0,K.jsx)(Gt,{children:r})]},n)),(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,onClick:n,className:`ml-auto flex items-center rounded-md p-1.5 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(kn,{className:`size-4`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Hide sidebar`})]})}),(0,K.jsx)(Gt,{children:`Hide sidebar`})]})]}),e!==`worktrees`&&e!==`files`&&(0,K.jsx)(cc,{sessions:a,target:S,showPath:e===`search`}),e===`worktrees`&&(0,K.jsx)(ss,{repoId:i,projectId:r,sessions:a}),e===`files`&&(h&&b!==null?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cc,{sessions:a,target:S,showPath:!0}),(0,K.jsx)(go,{sid:h.id,root:b,onNavigateUp:()=>x(so(b)),onReset:()=>_(null),onOpenFile:(e,t)=>c(h.id,e,b,t)})]}):h?(0,K.jsxs)(No,{session:h,onOpenFile:s,onOpenTerminal:e=>l(h.id,e),activePath:u,children:[(0,K.jsx)(cc,{sessions:a,target:S,showFileActions:!0,showPath:!0}),y&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>x(so(h.worktree_path)),title:`Browse the parent directory`,className:`flex shrink-0 items-center gap-1.5 px-3 py-1 text-left transition-colors hover:bg-elevated`,children:[(0,K.jsx)(Et,{className:`size-3 shrink-0 text-fg-gold`}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:`..`})]}),(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,K.jsx)(Go,{})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cc,{sessions:a,target:S}),(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to show.`})]})),e===`changes`&&(h?(0,K.jsx)(eo,{session:h.id,activeDiffPath:d,onOpenDiff:f,onOpenCommitFile:p},h.id):(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to show.`})),e===`search`&&(h?(0,K.jsx)(ts,{session:h.id,onOpen:m},h.id):(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to search.`}))]})}function hc({projectId:e,repoId:t,open:n,kind:r=`agent`,seedAccountId:i,onOpenChange:o,onCreated:s}){let c=r===`terminal`,l=a(),u=Te(l??void 0),d=pe(l??void 0),f=ye(),p=V(),m=ue(),[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(``),[y,b]=(0,q.useState)(!0),[x,S]=(0,q.useState)(!0),[C,w]=(0,q.useState)(``),[T,E]=(0,q.useState)(``),[D,O]=(0,q.useState)(!1),[k,ee]=(0,q.useState)(null),A=f.data?.find(e=>e.id===t),j=me(n?t:void 0),te=be(n?t:void 0),ne=u.data?.find(e=>String(e.id)===h),re=d.data?.allowSkipPermissions===!0,M=!c&&re&&ne?.skip_permissions_default===!0,N=_.trim()||A?.default_base_branch||``,P=(0,q.useMemo)(()=>(te.data?.worktrees??[]).filter(e=>e.branch===N).map(e=>({path:e.path,is_primary:e.is_primary,label:e.is_primary?`${e.path.split(`/`).filter(Boolean).pop()??e.path} (clone)`:e.path.split(`/`).filter(Boolean).pop()??e.path})),[te.data,N]),F=!y&&!x,ae=P.find(e=>e.is_primary)?.path??P[0]?.path??``,L=T||ae,le=(0,q.useMemo)(()=>{let e=d.data?.default_account_id;return u.data?.find(e=>e.id===i)??u.data?.find(t=>typeof e==`number`&&t.id===e)??u.data?.[0]},[u.data,d.data,i]),B=h||(le?String(le.id):``);(0,q.useEffect)(()=>{n&&i!==void 0&&g(String(i))},[n,i]);let de=(0,q.useRef)(d.data);de.current=d.data,(0,q.useEffect)(()=>{if(n){let e=wt(c?`terminal`:`agent`,de.current);v(e.baseBranch),b(e.separateBranch),S(e.separateWorktree),E(``)}},[n,c]);let fe=()=>{ee(null),m.mutate({project_id:e,...c?{kind:`terminal`}:{account_id:Number(B)},..._.trim()?{base_branch:_.trim()}:{},separate_branch:y,...y&&C.trim()?{branch:C.trim()}:{},...y?{}:{separate_worktree:x},...F&&L?{join_worktree:L}:{},...M&&D?{skip_permissions:!0}:{}},{onSuccess:e=>{o(!1),w(``),O(!1),s(e)},onError:e=>ee(e.message)})},he=c?`a shell`:`an agent`,ge=y?`on a new branch off ${N||`…`}, in its own directory`:F?`on ${N||`…`}, sharing an existing directory`:`on ${N||`…`}, in its own directory`;return(0,K.jsx)(ce,{open:n,onOpenChange:o,children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:c?`New terminal`:`New agent`}),(0,K.jsxs)(se,{children:[c?`Opens`:`Spawns`,` `,he,` `,ge,`.`]})]}),(0,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),(c||B)&&fe()},children:[!c&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(ze,{children:`Account`}),u.data?.length===0?(0,K.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No accounts yet —`,` `,(0,K.jsx)(`button`,{type:`button`,className:`text-accent underline`,onClick:()=>It(`accounts`),children:`add one in settings`}),`.`]}):(0,K.jsxs)(bt,{value:B,onValueChange:g,children:[(0,K.jsx)(vt,{children:(0,K.jsx)(xt,{placeholder:`pick an account`})}),(0,K.jsx)(St,{children:u.data?.map(e=>(0,K.jsxs)(yt,{value:String(e.id),children:[(0,K.jsxs)(`span`,{className:`font-mono`,children:[e.agent_type,`/`,e.label]}),!e.logged_in&&(0,K.jsx)(`span`,{className:`ml-2 text-2xs text-warning`,children:`not logged in`})]},e.id))})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,K.jsx)(ze,{htmlFor:`base-branch`,children:`Base branch`}),(0,K.jsx)(Oe,{id:`base-branch`,placeholder:A?.default_base_branch??`main`,value:_,onValueChange:v,hints:(j.data?.branches??[]).filter(e=>e.name.toLowerCase().includes(_.trim().toLowerCase())).slice(0,20).map(e=>({value:e.name,badge:e.name===A?.default_base_branch?`default`:e.is_session?`session: ${e.session_title??`untitled`}`:void 0})),className:`font-mono`,hintsClassName:`w-max min-w-full max-w-[36rem]`})]}),y&&(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,K.jsx)(ze,{htmlFor:`session-branch`,children:`New branch`}),(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`optional`})]}),(0,K.jsx)(ke,{id:`session-branch`,placeholder:`leave blank for auto`,value:C,onChange:e=>w(e.target.value),className:`font-mono`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(zt,{id:`separate-branch`,checked:y,onCheckedChange:e=>{b(e),e&&S(!0)}}),(0,K.jsx)(ze,{htmlFor:`separate-branch`,children:`Use separate branch`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(zt,{id:`separate-worktree`,checked:y?!0:x,disabled:y,onCheckedChange:S}),(0,K.jsx)(ze,{htmlFor:`separate-worktree`,className:H(y&&`text-fg-muted`),children:`Use separate directory`})]})]}),F&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(ze,{htmlFor:`join-dir`,children:`Directory to join`}),P.length===0?(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`No existing directory on `,(0,K.jsx)(`span`,{className:`font-mono`,children:N||`…`}),` — a shared one will be created for later sessions to join.`]}):(0,K.jsxs)(bt,{value:L,onValueChange:E,children:[(0,K.jsx)(vt,{id:`join-dir`,children:(0,K.jsx)(xt,{})}),(0,K.jsx)(St,{children:P.map(e=>(0,K.jsx)(yt,{value:e.path,title:e.path,detail:(0,K.jsx)(`span`,{className:`ml-auto min-w-0 truncate font-mono text-2xs text-fg-muted`,children:kt(e.path,p.data?.home)}),children:e.label},e.path))})]})]}),!y&&!c&&(0,K.jsxs)(`p`,{className:`text-xs text-warning`,children:[`The `,c?`shell`:`agent`,` commits straight to`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:N||`…`}),F?` and shares its working directory with concurrent sessions — they can trample each other’s edits.`:`.`]}),M&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-surface px-3 py-2`,children:[(0,K.jsx)(zt,{id:`skip-permissions`,checked:D,onCheckedChange:O}),(0,K.jsx)(ze,{htmlFor:`skip-permissions`,className:`text-warning`,children:`Skip permission prompts for this session`})]}),k&&(0,K.jsx)(`p`,{className:`text-xs text-danger`,children:k}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{type:`button`,variant:`ghost`,onClick:()=>o(!1),children:`Cancel`}),(0,K.jsx)(I,{type:`submit`,disabled:!c&&!B||m.isPending,children:c?`Open terminal`:`Start agent`})]})]})]})})}function gc({status:e,kind:t=`agent`,stale:n=!1,className:r}){let i=`${t===`terminal`?`terminal `:``}status: ${e.replace(`_`,` `)}${n?` (no agent activity for over an hour — possibly stalled)`:``}`;return(0,K.jsx)(`span`,{className:H(`status-dot`,r),"data-status":e,"data-kind":t,"data-stale":n||void 0,role:`img`,title:n?`No agent activity for over an hour — possibly stalled`:void 0,"aria-label":i})}var _c=[`starting`,`running`,`waiting_input`],vc=[`exited`,`interrupted`],yc={Item:rc,Separator:oc,Sub:tc,SubTrigger:ic,SubContent:ac},bc={Item:W,Separator:it,Sub:Ze,SubTrigger:dt,SubContent:lt};function xc(e,t){let n=_e(`resume`),r=_e(`kill`),i=De(),o=Fe(),s=Le(),c=ge(),l=Ae(),u=Ee(),d=ue(),f=Ht(),p=a(),m=Te(p??void 0),h=pe(p??void 0),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(e.title??``),[S,C]=(0,q.useState)(null),[w,T]=(0,q.useState)(null),E=(m.data??[]).filter(t=>t.agent_type===e.agent_type),D=!e.worktree_missing&&e.status!==`archived`&&E.some(t=>t.id!==e.account_id),O=(m.data??[]).filter(t=>t.agent_type!==e.agent_type&&t.logged_in),ee=h.data?.default_account_id,A=typeof ee==`number`?ee:null,j=(m.data??[]).filter(e=>e.logged_in),te=A===null?j:[...j.filter(e=>e.id===A),...j.filter(e=>e.id!==A)];return{menu:{session:e,resumable:vc.includes(e.status),live:_c.includes(e.status),archived:e.status===`archived`,canMigrate:D,sameAgent:E,handoffTargets:!e.worktree_missing&&e.status!==`archived`?O:[],setHandoffTo:T,resume:()=>n.mutate(e.id,{onError:e=>Re(e)}),kill:()=>r.mutate(e.id,{onError:e=>Re(e)}),openClearEnv:()=>_(`clear-env`),openTerminal:()=>d.mutate({project_id:e.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void f(`/project/${e.project_id}/session/${e.id}`),onError:e=>Re(e)}),spawnAccounts:te,defaultAccountId:A,spawnAgent:t=>d.mutate({project_id:e.project_id,account_id:t,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void f(`/project/${e.project_id}/session/${e.id}`),onError:e=>Re(e)}),openRename:()=>{x(e.title??``),y(!0)},archive:()=>i.mutate(e.id,{onSuccess:()=>t?.(e.id),onError:e=>Re(e)}),unarchive:()=>o.mutate(e.id,{onError:e=>Re(e)}),setMigrateTo:C},dialogs:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ce,{open:g===`clear-env`,onOpenChange:e=>{e||_(null)},children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:`Clear captured environment?`}),(0,K.jsx)(se,{children:`Variables exported in this session’s terminals will no longer be injected into new shells or agent restarts.`})]}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{variant:`ghost`,onClick:()=>_(null),children:`Cancel`}),(0,K.jsx)(I,{variant:`danger`,disabled:u.isPending,onClick:()=>u.mutate(e.id,{onSuccess:e=>{_(null),k.success(e.cleared===0?`Nothing was captured`:`Cleared ${e.cleared} captured var${e.cleared===1?``:`s`}`)},onError:e=>{_(null),Re(e)}}),children:`Clear captured env`})]})]})}),(0,K.jsx)(ce,{open:v,onOpenChange:y,children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:`Rename session`}),(0,K.jsx)(se,{children:`Leave it empty to use the agent’s own session name.`})]}),(0,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:t=>{t.preventDefault(),s.mutate({sessionId:e.id,title:b.trim()},{onSuccess:()=>y(!1),onError:e=>Re(e)})},children:[(0,K.jsx)(ke,{value:b,onChange:e=>x(e.target.value),placeholder:e.agent_title??e.osc_title??e.id.slice(0,8),autoFocus:!0}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{type:`button`,variant:`ghost`,onClick:()=>y(!1),children:`Cancel`}),(0,K.jsx)(I,{type:`submit`,disabled:s.isPending,children:`Rename`})]})]})]})}),(0,K.jsx)(ce,{open:S!==null,onOpenChange:e=>!e&&C(null),children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsxs)(z,{children:[`Move this session to `,S?.label,`?`]}),(0,K.jsx)(se,{children:`The conversation continues under that account’s credentials. If the session is running it is stopped first, then resumed on the new account.`})]}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{variant:`ghost`,onClick:()=>C(null),children:`Cancel`}),(0,K.jsx)(I,{disabled:c.isPending,onClick:()=>{S&&c.mutate({sessionId:e.id,accountId:S.id},{onSuccess:()=>{C(null),k.success(`Moved to ${S.label}`)},onError:e=>{C(null),Re(e)}})},children:`Move session`})]})]})}),(0,K.jsx)(ce,{open:w!==null,onOpenChange:e=>!e&&T(null),children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsxs)(z,{children:[`Hand off to `,w?.agent_type,`?`]}),(0,K.jsxs)(se,{children:[`A new session starts in this worktree and branch on`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:w?.label}),`, opening with a summary of the conversation so far plus the branch’s commits and status. The conversation itself is summarised, not moved — the new agent will not have the old one’s reasoning. This session is left as it is.`]})]}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{variant:`ghost`,onClick:()=>T(null),children:`Cancel`}),(0,K.jsx)(I,{disabled:l.isPending,onClick:()=>{w&&l.mutate({sessionId:e.id,accountId:w.id},{onSuccess:e=>{T(null),k.success(`Handed off to ${w.agent_type}`),f(`/session/${e.id}`)},onError:e=>{T(null),Re(e)}})},children:`Hand off`})]})]})})]})}}function Sc({kit:e,menu:t}){let{Item:n,Separator:r,Sub:i,SubTrigger:a,SubContent:o}=e,{session:s}=t;return(0,K.jsxs)(K.Fragment,{children:[t.resumable&&!s.worktree_missing&&(0,K.jsxs)(n,{onSelect:t.resume,children:[(0,K.jsx)(Pn,{}),` Resume`]}),t.live&&(0,K.jsxs)(n,{onSelect:t.kill,children:[(0,K.jsx)(Ln,{}),` Kill`]}),(0,K.jsxs)(n,{onSelect:t.openRename,children:[(0,K.jsx)(xe,{}),` Rename`]}),!t.archived&&(0,K.jsxs)(n,{onSelect:t.openClearEnv,children:[(0,K.jsx)(sn,{}),` Clear captured env`]}),t.canMigrate&&(0,K.jsxs)(i,{children:[(0,K.jsxs)(a,{children:[(0,K.jsx)(zn,{}),` Move to account…`]}),(0,K.jsx)(o,{children:t.sameAgent.map(e=>{let r=e.id===s.account_id;return(0,K.jsxs)(n,{disabled:r,onSelect:()=>t.setMigrateTo(e),children:[e.label,r&&(0,K.jsx)(`span`,{className:`ml-auto text-fg-muted`,children:`current`})]},e.id)})})]}),t.handoffTargets.length>0&&(0,K.jsxs)(i,{children:[(0,K.jsxs)(a,{children:[(0,K.jsx)(nn,{}),` Hand off to agent…`]}),(0,K.jsx)(o,{children:t.handoffTargets.map(e=>(0,K.jsxs)(n,{onSelect:()=>t.setHandoffTo(e),children:[(0,K.jsx)(Yt,{type:e.agent_type,className:`size-4`}),e.agent_type,(0,K.jsx)(`span`,{className:`ml-auto font-mono text-fg-muted`,children:e.label})]},e.id))})]}),!s.worktree_missing&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(r,{}),(0,K.jsxs)(n,{onSelect:t.openTerminal,children:[(0,K.jsx)(Nt,{}),` Open terminal in worktree`]}),t.spawnAccounts.length>0&&(0,K.jsxs)(i,{children:[(0,K.jsxs)(a,{children:[(0,K.jsx)(Vt,{}),` Spawn agent in worktree`]}),(0,K.jsx)(o,{children:t.spawnAccounts.map(e=>(0,K.jsxs)(n,{onSelect:()=>t.spawnAgent(e.id),children:[(0,K.jsx)(Yt,{type:e.agent_type,className:`size-4 shrink-0`}),e.agent_type,`/`,e.label,e.id===t.defaultAccountId&&(0,K.jsx)(`span`,{className:`ml-auto pl-3 text-fg-muted`,children:`default`})]},e.id))})]}),(0,K.jsxs)(n,{onSelect:()=>{window.location.href=Xt(`vscode`,s.worktree_path,Wt())},children:[(0,K.jsx)(cn,{}),` Open in VS Code`]}),(0,K.jsxs)(n,{onSelect:()=>{window.location.href=Xt(`cursor`,s.worktree_path,Wt())},children:[(0,K.jsx)(cn,{}),` Open in Cursor`]})]}),!t.archived&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(r,{}),(0,K.jsxs)(n,{onSelect:t.archive,children:[(0,K.jsx)(Ue,{}),` Archive`]})]}),t.archived&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(r,{}),(0,K.jsxs)(n,{onSelect:t.unarchive,children:[(0,K.jsx)(at,{}),` Unarchive`]})]})]})}function Cc({menu:e}){return(0,K.jsxs)($s,{children:[(0,K.jsx)(ec,{asChild:!0,children:(0,K.jsxs)(I,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:e=>e.preventDefault(),children:[(0,K.jsx)(on,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Session actions`})]})}),(0,K.jsx)(nc,{align:`end`,children:(0,K.jsx)(Sc,{kit:yc,menu:e})})]})}function wc({session:e,onArchived:t,children:n}){let{menu:r,dialogs:i}=xc(e,t);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(ft,{children:[(0,K.jsx)($e,{asChild:!0,children:typeof n==`function`?n(r):n}),(0,K.jsx)(ct,{children:(0,K.jsx)(Sc,{kit:bc,menu:r})})]}),i]})}function Tc({menu:e}){return(0,K.jsx)(ct,{children:(0,K.jsx)(Sc,{kit:bc,menu:e})})}function Ec({icon:e,label:t,onClick:n,active:r=!1,tooltipSide:i}){return(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":r,className:H(`flex items-center rounded-md p-1.5 transition-colors`,r?`bg-elevated text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(e,{className:`size-4`}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,K.jsx)(Gt,{side:i,children:t})]})}function Dc({session:e,accountLabel:t}){return(0,K.jsxs)(`span`,{className:`flex flex-col`,children:[(0,K.jsx)(`span`,{children:Ot()(e)}),(0,K.jsx)(`span`,{className:`font-mono text-2xs text-fg-muted`,children:e.branch}),(0,K.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1 font-mono text-2xs text-fg-muted`,children:e.kind===`terminal`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Nt,{className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{children:`terminal`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Yt,{type:e.agent_type??``,className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{children:e.agent_type}),t&&(0,K.jsxs)(`span`,{children:[` · `,t]})]})})]})}function Oc({session:e,accountLabel:t,activeSessionId:n,onPromote:r,onArchived:i}){let{menu:a,dialogs:o}=xc(e,i),s=Ot();return(0,K.jsxs)(ft,{children:[(0,K.jsxs)(Zt,{children:[(0,K.jsx)($e,{asChild:!0,children:(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(Bt,{draggable:!1,"aria-current":e.id===n?`true`:void 0,onDoubleClick:()=>r(e.id),to:`/project/${e.project_id}/session/${e.id}`,className:H(`flex items-center rounded-md p-1.5 transition-colors hover:bg-elevated`,e.id===n&&`bg-elevated`),children:[(0,K.jsx)(gc,{status:e.status,kind:e.kind,stale:e.stale_running,className:`[--puddle-ripple-scale:2.3]`}),(0,K.jsx)(`span`,{className:`sr-only`,children:s(e)})]})})}),(0,K.jsx)(Gt,{side:`left`,children:(0,K.jsx)(Dc,{session:e,accountLabel:t})})]}),(0,K.jsx)(Tc,{menu:a}),o]})}function kc({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,onExpand:a,onNewTerminal:o,onNewSession:s,onArchived:c}){let[l,u]=(0,q.useState)(null),d=new Map(t.map(e=>[e.id,e.label])),f=e.filter(e=>e.sessions.length>0),p=(e,t)=>{let n=Ge(f,e,t);n&&r(n)};return(0,K.jsxs)(`div`,{className:`flex h-full w-9 shrink-0 flex-col items-center bg-surface py-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,K.jsx)(Ec,{icon:Mn,label:`Show sessions`,onClick:a,tooltipSide:`left`}),(0,K.jsx)(Ec,{icon:Vt,label:`New agent`,onClick:s,tooltipSide:`left`}),(0,K.jsx)(Ec,{icon:Nt,label:`New terminal`,onClick:o,tooltipSide:`left`})]}),(0,K.jsx)(`div`,{className:`no-scrollbar flex min-h-0 flex-1 flex-col items-center gap-1 overflow-y-auto`,children:f.map(e=>(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,K.jsx)(`div`,{className:`my-0.5 h-px w-5 shrink-0 bg-border`}),e.sessions.map(e=>(0,K.jsx)(`div`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(Po,Fo({type:`terminal`,session:e.id})),u(e.id)},onDragEnd:()=>u(null),onDragOver:t=>{t.preventDefault(),l&&l!==e.id&&p(l,e.id)},className:H(`transition-opacity`,l===e.id&&`opacity-50`),children:(0,K.jsx)(Oc,{session:e,accountLabel:e.account_id===null?void 0:d.get(e.account_id),activeSessionId:n,onPromote:i,onArchived:c})},e.id))]},e.projectId))})]})}function Ac({session:e,activeSessionId:t,accountLabel:n,onPromote:r,onArchived:i,ellipsis:a}){let o=Ot();return(0,K.jsx)(wc,{session:e,onArchived:i,children:i=>(0,K.jsxs)(Bt,{draggable:!1,onDoubleClick:r&&(()=>r(e.id)),to:`/project/${e.project_id}/session/${e.id}`,className:H(`group flex items-center gap-2 px-3 py-1.5 transition-colors hover:bg-elevated`,e.id===t&&`bg-elevated`),children:[(0,K.jsx)(gc,{status:e.status,kind:e.kind,stale:e.stale_running}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate font-sans text-xs text-fg`,children:o(e)}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 truncate font-mono text-2xs text-fg-muted`,children:[(0,K.jsx)(En,{className:`size-3 shrink-0 text-fg-gold`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.branch})]}),e.account_id!==null&&n.has(e.account_id)&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 truncate font-mono text-2xs text-fg-muted`,children:[(0,K.jsx)(Yt,{type:e.agent_type??``,className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:n.get(e.account_id)})]})]}),e.skip_permissions&&(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsx)(In,{className:`size-3.5 shrink-0 text-warning`})}),(0,K.jsx)(Gt,{children:`Running with permission prompts skipped`})]}),e.worktree_missing&&(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsx)(Tn,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,K.jsx)(Gt,{children:`Worktree directory is gone — archive only`})]}),a&&(0,K.jsx)(`span`,{className:`hidden group-hover:inline-flex has-[[data-state=open]]:inline-flex pointer-coarse:inline-flex`,children:(0,K.jsx)(Cc,{menu:i})})]})})}function jc({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onNewSession:o,onNewTerminal:s,onCollapse:c,onArchived:l}){return(0,K.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 px-2 py-1.5`,children:[(0,K.jsx)(Ec,{icon:jn,label:`Hide sessions`,onClick:c}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,K.jsx)(Ec,{icon:Vt,label:`New agent`,onClick:o}),(0,K.jsx)(Ec,{icon:Nt,label:`New terminal`,onClick:s})]})]}),(0,K.jsx)(Mc,{groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:l})]})}function Mc({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:o}){let[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(!1),d=new Map(t.map(e=>[e.id,e.label])),f=e.filter(e=>e.sessions.length>0),p=f.reduce((e,t)=>e+t.sessions.length,0),m=(e,t)=>{let n=Ge(f,e,t);n&&r(n)};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto py-1.5`,children:[p===0&&a.length===0&&(0,K.jsx)(`p`,{className:`px-3 py-3 text-xs text-fg-muted`,children:`No sessions yet — press ⌘K to start one.`}),f.map(e=>(0,K.jsxs)(`div`,{children:[e.name!==null&&(0,K.jsx)(`div`,{className:`truncate px-3 pb-1 pt-2 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e.name}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.sessions.map(e=>(0,K.jsx)(`li`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(Po,Fo({type:`terminal`,session:e.id})),c(e.id)},onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&m(s,e.id)},className:H(`transition-opacity`,s===e.id&&`opacity-50`),children:(0,K.jsx)(Ac,{session:e,activeSessionId:n,accountLabel:d,onPromote:i,onArchived:o,ellipsis:!0})},e.id))})]},e.projectId))]}),a.length>0&&(0,K.jsxs)(`div`,{className:`shrink-0 pb-1.5`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`flex w-full items-center gap-1.5 px-3 py-1.5 text-2xs uppercase tracking-wide text-fg-gold transition-colors hover:text-fg`,children:[(0,K.jsx)(Tt,{className:H(`size-3 transition-transform`,l&&`rotate-90`)}),(0,K.jsx)(Ue,{className:`size-3`}),(0,K.jsx)(`span`,{children:`Archived`}),(0,K.jsx)(`span`,{className:`ml-auto tabular-nums`,children:a.length})]}),l&&(0,K.jsx)(`ul`,{className:`no-scrollbar flex max-h-48 flex-col gap-0.5 overflow-y-auto`,children:a.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(Ac,{session:e,activeSessionId:n,accountLabel:d,onArchived:o,ellipsis:!0})},e.id))})]})]})}var Nc=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Pc(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Fc(e){return`nodeType`in e}function Ic(e){return e?Pc(e)?e:Fc(e)?e.ownerDocument?.defaultView??window:window:window}function Lc(e){let{Document:t}=Ic(e);return e instanceof t}function Rc(e){return!Pc(e)&&e instanceof Ic(e).HTMLElement}function zc(e){return e instanceof Ic(e).SVGElement}function Bc(e){return e?Pc(e)?e.document:Fc(e)?Lc(e)?e:Rc(e)||zc(e)?e.ownerDocument:document:document:document}var Vc=Nc?q.useLayoutEffect:q.useEffect;function Hc(e){let t=(0,q.useRef)(e);return Vc(()=>{t.current=e}),(0,q.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Uc(){let e=(0,q.useRef)(null);return[(0,q.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,q.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function Wc(e,t){t===void 0&&(t=[e]);let n=(0,q.useRef)(e);return Vc(()=>{n.current!==e&&(n.current=e)},t),n}function Gc(e,t){let n=(0,q.useRef)();return(0,q.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function Kc(e){let t=Hc(e),n=(0,q.useRef)(null);return[n,(0,q.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function qc(e){let t=(0,q.useRef)();return(0,q.useEffect)(()=>{t.current=e},[e]),t.current}var Jc={};function Yc(e,t){return(0,q.useMemo)(()=>{if(t)return t;let n=Jc[e]==null?0:Jc[e]+1;return Jc[e]=n,e+`-`+n},[e,t])}function Xc(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var Zc=Xc(1),Qc=Xc(-1);function $c(e){return`clientX`in e&&`clientY`in e}function el(e){if(!e)return!1;let{KeyboardEvent:t}=Ic(e.target);return t&&e instanceof t}function tl(e){if(!e)return!1;let{TouchEvent:t}=Ic(e.target);return t&&e instanceof t}function nl(e){if(tl(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return $c(e)?{x:e.clientX,y:e.clientY}:null}var rl=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[rl.Translate.toString(e),rl.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),il=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function al(e){return e.matches(il)?e:e.querySelector(il)}var ol={display:`none`};function sl(e){let{id:t,value:n}=e;return q.createElement(`div`,{id:t,style:ol},n)}function cl(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return q.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function ll(){let[e,t]=(0,q.useState)(``);return{announce:(0,q.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var ul=(0,q.createContext)(null);function dl(e){let t=(0,q.useContext)(ul);(0,q.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function fl(){let[e]=(0,q.useState)(()=>new Set),t=(0,q.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,q.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var pl={draggable:`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PaneEditorBody-CbwKaj3E.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/profile-store-D2pB4wB-.js","assets/api-CZDct42i.js","assets/editor-tabs-3ilPGolh.js","assets/preload-helper-Czpn1I53.js","assets/createLucideIcon-DyMAgLa3.js","assets/index-iPj6x3rM.js","assets/dialog-B43iKmfK.js","assets/utils-B6KiDbIe.js","assets/LazyTerminal-CeLHCKsO.js","assets/index-CRUVuFoo.css","assets/editor.api2-4X9Vh9Zw.js","assets/editor-Br_kD0ds.css","assets/buffer-store-CiF8VU5A.js","assets/buffer-logic-BrpRsL1b.js","assets/debounce-B9DrqirV.js","assets/editor-sync-f1V6Wuxn.js","assets/PaneEditorBody-Dz-67XSV.css","assets/ModelRefcount-sJruf69B.js","assets/EditorTabClose-C5BL8wr0.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{l as i,r as a}from"./profile-store-D2pB4wB-.js";import{A as o,M as s,N as c,O as l,S as u,T as d,_ as f,a as p,b as m,c as h,d as g,f as _,j as v,n as y,p as b,r as x,s as S,t as C,v as w,w as T,x as E,y as D}from"./editor-tabs-3ilPGolh.js";import{t as O}from"./preload-helper-Czpn1I53.js";import{S as k,c as ee,l as A,n as j,t as te,u as ne,y as re}from"./api-CZDct42i.js";import{A as M,O as N,_ as P,a as ie,b as F,g as I,h as ae,i as oe,j as L,n as R,o as z,r as se,t as ce,w as le}from"./dialog-B43iKmfK.js";import{$ as B,C as ue,E as de,G as fe,H as pe,J as me,K as he,M as V,P as ge,Q as _e,W as ve,X as ye,Y as be,a as xe,c as Se,ct as Ce,et as we,f as Te,g as Ee,h as De,i as Oe,it as ke,j as Ae,l as je,lt as Me,m as Ne,n as Pe,nt as Fe,o as Ie,q as Le,r as Re,rt as ze,t as Be,u as Ve,w as He}from"./LazyTerminal-CeLHCKsO.js";import{t as H}from"./utils-B6KiDbIe.js";import{t as U}from"./createLucideIcon-DyMAgLa3.js";import{A as Ue,C as We,D as Ge,E as Ke,O as qe,S as Je,T as Ye,_ as Xe,a as Ze,b as Qe,c as $e,d as et,f as tt,g as nt,h as rt,i as it,j as at,l as ot,m as st,n as ct,o as lt,p as ut,r as W,s as dt,t as ft,u as pt,v as mt,w as ht,x as gt,y as _t}from"./context-menu-Bitp8sY-.js";import{a as vt,i as yt,n as bt,o as xt,r as St,s as Ct,t as wt}from"./session-seed-B2YmPsU-.js";import{r as Tt}from"./dist-i-QevsUb.js";import{$ as Et,B as Dt,C as Ot,F as kt,G as At,I as jt,J as Mt,K as Nt,M as Pt,Q as Ft,R as It,T as Lt,_ as Rt,a as zt,dt as Bt,et as Vt,ft as Ht,i as Ut,n as Wt,nt as Gt,pt as Kt,q as qt,rt as Jt,s as Yt,t as Xt,tt as Zt,v as Qt}from"./index-iPj6x3rM.js";import{t as $t}from"./debounce-B9DrqirV.js";import{i as en}from"./buffer-logic-BrpRsL1b.js";import{t as tn}from"./ssh-mode-CAA0-mpZ.js";var nn=U(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),rn=U(`case-sensitive`,[[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M22 9v7`,key:`pvm9v3`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}],[`circle`,{cx:`18.5`,cy:`12.5`,r:`3.5`,key:`z97x68`}]]),an=U(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),on=U(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),sn=U(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]),cn=U(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),ln=U(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),un=U(`file-archive`,[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]),dn=U(`file-braces`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),G=U(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),fn=U(`file-cog`,[[`path`,{d:`M15 8a1 1 0 0 1-1-1V2a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8z`,key:`1ckgky`}],[`path`,{d:`M20 8v12a2 2 0 0 1-2 2h-4.182`,key:`1726p0`}],[`path`,{d:`m3.305 19.53.923-.382`,key:`ao1pio`}],[`path`,{d:`M4 10.592V4a2 2 0 0 1 2-2h8`,key:`1foop0`}],[`path`,{d:`m4.228 16.852-.924-.383`,key:`1fv9zy`}],[`path`,{d:`m5.852 15.228-.383-.923`,key:`1a9hc2`}],[`path`,{d:`m5.852 20.772-.383.924`,key:`1sh9ke`}],[`path`,{d:`m8.148 15.228.383-.923`,key:`4yu6lf`}],[`path`,{d:`m8.53 21.696-.382-.924`,key:`18b0s9`}],[`path`,{d:`m9.773 16.852.922-.383`,key:`ti6xop`}],[`path`,{d:`m9.773 19.148.922.383`,key:`rws47d`}],[`circle`,{cx:`7`,cy:`18`,r:`3`,key:`lvkj7j`}]]),pn=U(`file-headphone`,[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]]),mn=U(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),hn=U(`file-key`,[[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M4 12v6`,key:`bg1pfk`}],[`path`,{d:`M4 14h2`,key:`1sf9f8`}],[`path`,{d:`M9.65 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v4`,key:`d56i0q`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),gn=U(`file-lock`,[[`path`,{d:`M4 9.8V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3`,key:`1432pc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 17v-2a2 2 0 0 0-4 0v2`,key:`168m41`}],[`rect`,{width:`8`,height:`5`,x:`3`,y:`17`,rx:`1`,key:`o8vfew`}]]),_n=U(`file-play`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z`,key:`1tzo1f`}]]),vn=U(`file-spreadsheet`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),yn=U(`file-terminal`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m8 16 2-2-2-2`,key:`10vzyd`}],[`path`,{d:`M12 18h4`,key:`1wd2n7`}]]),bn=U(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),xn=U(`file-type`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M11 18h2`,key:`12mj7e`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`M9 13v-.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 .5.5v.5`,key:`qbrxap`}]]),Sn=U(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Cn=U(`folder-closed`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M2 10h20`,key:`1ir3d8`}]]),wn=U(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),Tn=U(`folder-x`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),En=U(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),Dn=U(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),On=U(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),kn=U(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),An=U(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),jn=U(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),Mn=U(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),Nn=U(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),Pn=U(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Fn=U(`regex`,[[`path`,{d:`M17 3v10`,key:`15fgeh`}],[`path`,{d:`m12.67 5.5 8.66 5`,key:`1gpheq`}],[`path`,{d:`m12.67 10.5 8.66-5`,key:`1dkfa6`}],[`path`,{d:`M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z`,key:`swwfx4`}]]),In=U(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Ln=U(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Rn=U(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),zn=U(`user-round-cog`,[[`path`,{d:`m14.305 19.53.923-.382`,key:`3m78fa`}],[`path`,{d:`m15.228 16.852-.923-.383`,key:`npixar`}],[`path`,{d:`m16.852 15.228-.383-.923`,key:`5xggr7`}],[`path`,{d:`m16.852 20.772-.383.924`,key:`dpfhf9`}],[`path`,{d:`m19.148 15.228.383-.923`,key:`1reyyz`}],[`path`,{d:`m19.53 21.696-.382-.924`,key:`1goivc`}],[`path`,{d:`M2 21a8 8 0 0 1 10.434-7.62`,key:`1yezr2`}],[`path`,{d:`m20.772 16.852.924-.383`,key:`htqkph`}],[`path`,{d:`m20.772 19.148.924.383`,key:`9w9pjp`}],[`circle`,{cx:`10`,cy:`8`,r:`5`,key:`o932ke`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]]),Bn=U(`whole-word`,[[`circle`,{cx:`7`,cy:`12`,r:`3`,key:`12clwm`}],[`path`,{d:`M10 9v6`,key:`17i7lo`}],[`circle`,{cx:`17`,cy:`12`,r:`3`,key:`gl7c2s`}],[`path`,{d:`M14 7v8`,key:`dl84cr`}],[`path`,{d:`M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1`,key:`lt2kga`}]]),K=r(),q=e(t(),1);function Vn(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Hn(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function Un(e){return e/100*window.innerHeight}function Wn(e){return e/100*window.innerWidth}function Gn(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function Kn({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Gn(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Hn(t,i);break;case`em`:r=Vn(t,i);break;case`vh`:r=Un(i);break;case`vw`:r=Wn(i);break}return r}function qn(e){return parseFloat(e.toFixed(3))}function Jn({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function Yn(e){let{panels:t}=e,n=Jn({group:e});return n===0?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=qn(Kn({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=qn(Kn({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=qn(Kn({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=qn(Kn({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function J(e,t=`Assertion error`){if(!e)throw Error(t)}function Xn(e,t){return Array.from(t).sort(e===`horizontal`?Zn:Qn)}function Zn(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Qn(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function $n(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function er(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function tr({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=er(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return J(i,`No rect found`),i}var nr;function rr(){return nr===void 0&&(nr=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),nr}function ir(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Xn(n,Array.from(t.children).filter($n).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,tr({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=rr()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:Jn({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var ar=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},or={cursorFlags:0,state:`inactive`},sr=new ar;function cr(){return or}function lr(e){return sr.addListener(`change`,e)}function ur(e){let t=or,n={...or};n.cursorFlags=e,or=n,sr.emit(`change`,{prev:t,next:n})}function dr(e){let t=or;or=e,sr.emit(`change`,{prev:t,next:e})}var fr=e=>e,pr=()=>{},mr=1,hr=2,gr=4,_r=8,vr=3,yr=12,br;function xr(){return br===void 0&&(br=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(br=!0)),br}function Sr({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&xr()){let t=(e&mr)!==0,n=(e&hr)!==0,r=(e&gr)!==0,i=(e&_r)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return xr()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var Cr=new WeakMap;function wr(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Cr.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=cr();switch(r.state){case`active`:case`hover`:{let e=Sr({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(e=>e.group),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}Cr.set(e,{prevStyle:t,styleSheet:n})}var Tr=new Map,Er=new ar;function Dr(e){Tr=new Map(Tr),Tr.delete(e)}function Or(e,t){for(let[t]of Tr)if(t.id===e)return t}function kr(e,t){for(let[t,n]of Tr)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Ar(){return Tr}function jr(e,t){return Er.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function Mr(e,t,n){let r=Tr.get(e);Tr=new Map(Tr),Tr.set(e,t),Er.emit(`groupChange`,{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function Nr(e){let t=cr(),n=!1;switch(t.state){case`active`:dr({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(wr(e),n=!0,t.hitRegions.forEach(e=>{let t=kr(e.group.id,!0);Mr(e.group,t,{isUserInteraction:!0})}))}return n}function Pr(e){e.defaultPrevented||Nr(e.currentTarget)}function Fr(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=er(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function Ir(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Lr(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:Ur(e),b:Ur(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();J(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:Hr(Vr(n.a)),b:Hr(Vr(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var Rr=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function zr(e){let t=getComputedStyle(Wr(e)??e).display;return t===`flex`||t===`inline-flex`}function Br(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||zr(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||Rr.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Vr(e){let t=e.length;for(;t--;){let n=e[t];if(J(n,`Missing node`),Br(n))return n}return null}function Hr(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ur(e){let t=[];for(;e;)t.push(e),e=Wr(e);return t}function Wr(e){let{parentNode:t}=e;return Ir(t)?t.host:t}function Gr(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Kr({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!$n(n)||n.contains(e)||e.contains(n))return!0;if(Lr(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Gr(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function qr(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=ir(r),a=Fr(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Kr({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Jr(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Y(e,t,n=0){return Math.abs(qn(e)-qn(t))<=n}function Yr(e,t){return Y(e,t)?0:e>t?1:-1}function Xr({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(Yr(r,c)<0)if(a){let e=(i+c)/2;r=Yr(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=qn(r),r}function Zr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Y(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;J(u!=null,`Invalid first pivot index`),J(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];J(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(J(n!=null,`Previous layout not found for panel index ${t}`),Y(n,i)){let t=o-n;Yr(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];J(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(J(n!=null,`Previous layout not found for panel index ${t}`),Y(n,o)){let t=n-i;Yr(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];J(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&Yr(i,c)<0)if(e>0){let t=c-o,n=t/2;Yr(i+e,c)<0&&(e=Yr(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;Yr(i-e,c)<0&&(e=Yr(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];J(e!=null,`Previous layout not found for panel index ${r}`);let a=Xr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];J(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=Xr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!Y(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(Jr(c,l))return i;{let t=e<0?d:u,r=s[t];J(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=Xr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!Y(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];J(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=Xr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(Y(i,s)||(t-=s-i,l[r]=s),Y(t,0))break;e>0?r--:r++}}}if(!Y(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function Qr(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||Yr(e[n],t[n])!==0)return!1;return!0}function $r({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!Y(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];J(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];J(i!=null,`No layout data found for index ${e}`);let o=r[e];J(o!=null,`No layout data found for index ${e}`);let s=Xr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!Y(a,0))for(let e=0;e<t.length;e++){let n=r[e];J(n!=null,`No layout data found for index ${e}`);let i=n+a,o=Xr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,Y(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function ei({groupId:e,panelId:t}){let n=()=>{let t=Ar();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,groupSize:o,separatorToPanels:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,groupSize:o,layout:a,separatorToPanels:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:e,panels:n,prevLayout:r,derivedPanelConstraints:i})=>{let o=a(),s=n.findIndex(e=>e.id===t),c=s===0,l=s===n.length-1;if(l&&e<o&&(c||n.slice(0,s).every((e,t)=>{let n=i[t];return n?.collapsible&&Y(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:qn(100-e)}}return Zr({delta:l?o-e:e-o,initialLayout:r,panelConstraints:i,pivotIndices:l?[s-1,s]:[s,s+1],prevLayout:r,trigger:`imperative-api`})},s=e=>{if(e===a())return;let{defaultLayoutDeferred:t,derivedPanelConstraints:r,group:i,groupSize:s,layout:c,separatorToPanels:l}=n(),u=$r({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});Qr(c,u)||Mr(i,{defaultLayoutDeferred:t,derivedPanelConstraints:r,groupSize:s,layout:u,separatorToPanels:l})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),o=a();e&&o!==t&&(n.expandToSize=o,s(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:o}=i(),c=a();if(e&&c===t){let e=o.expandToSize??n;e===0&&(e=1),s(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&Y(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Jn({group:t}),o=qn(Kn({groupSize:a,panelElement:r,styleProp:e})/a*100);s(o)}}}function ti(e){e.defaultPrevented||qr(e,Ar()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=ei({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function ni(e){let t=Ar();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function ri({groupId:e}){let t=()=>{let t=Ar();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,groupSize:a,layout:o,separatorToPanels:s}=t(),c=$r({layout:e,panelConstraints:r});return n?o:(Qr(o,c)||Mr(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function ii(e,t){let n=ni(e),r=kr(n.id,!0),i=n.separators.find(t=>t.element===e);J(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);J(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=ri({groupId:n.id}).getLayout(),c=$r({layout:Zr({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});Qr(s,c)||Mr(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function ai(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=ni(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&ii(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&ii(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&ii(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&ii(t,-5);break;case`End`:e.preventDefault(),ii(t,100);break;case`Enter`:{e.preventDefault();let n=ni(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=kr(n.id,!0),o=n.separators.find(e=>e.element===t);J(o,`Matching separator not found`);let s=a.get(o);J(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(J(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];ii(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=ni(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);J(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),ii(t,-100);break}}function oi(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Ar(),n=qr(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),dr({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}function si({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0;n.forEach(e=>{let{group:n,groupSize:o}=e,{orientation:c,panels:l}=n,{disableCursor:u}=n.mutableState,d=0;d=a?c===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:c===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let f=r.get(n),p=i.get(n);if(!f||!p)return;let{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:_,separatorToPanels:v}=p;if(h&&_&&v){let t=Zr({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(Qr(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?mr:hr;break;case`vertical`:s|=d<0?gr:_r;break}}else Mr(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&vr:c|=s&vr,t.movementY===0?c|=o&yr:c|=s&yr,ur(c),wr(e)}function ci(e){let t=Ar(),n=cr();switch(n.state){case`active`:si({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function li(e){if(e.defaultPrevented)return;let t=cr(),n=Ar();switch(t.state){case`active`:if(e.buttons===0){dr({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=kr(e.group.id,!0);Mr(e.group,t,{isUserInteraction:!0})});return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.hasPointerCapture?.(e.pointerId)||t.setPointerCapture?.(e.pointerId)}si({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=qr(e,n);r.length===0?t.state!==`inactive`&&dr({cursorFlags:0,state:`inactive`}):dr({cursorFlags:0,hitRegions:r,state:`hover`}),wr(e.currentTarget);break}}}function ui(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(cr().state){case`hover`:dr({cursorFlags:0,state:`inactive`})}}function di(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||Nr(e.currentTarget)&&e.preventDefault()}function fi(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=qn(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=qn((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function pi(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Jn({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:qn(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function mi(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function hi({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.panels){let e=r[l.id]??0;switch(l.panelConstraints.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=qn(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=qn((r[e]??0)/a*l);else{let e=qn(l/c.length);for(let t of c)u[t]=e}return u}function gi(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var _i=new Map;function vi(e){let t=!0;J(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=Jn({group:e});if(t===0)return;let n=kr(e.id);if(!n)return;let r=Yn(e),i=n.defaultLayoutDeferred?fi(r):n.layout,a=$r({layout:hi({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&Qr(n.layout,a)&&mi(n.derivedPanelConstraints,r)&&n.groupSize===t)return;Mr(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else pi(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{J(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=Jn({group:e}),s=Yn(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(gi(e.panels,l)||(l=void 0));let u=$r({layout:e.mutableState.layouts[c]??l??fi(s),panelConstraints:s}),d=e.element.ownerDocument;_i.set(d,(_i.get(d)??0)+1);let f=new Map;return ir(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),Mr(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{J(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,ai)}),_i.get(d)===1&&(d.addEventListener(`contextmenu`,Pr,!0),d.addEventListener(`dblclick`,ti,!0),d.addEventListener(`pointerdown`,oi,!0),d.addEventListener(`pointerleave`,ci),d.addEventListener(`pointermove`,li),d.addEventListener(`pointerout`,ui),d.addEventListener(`pointerup`,di,!0)),function(){t=!1,_i.set(d,Math.max(0,(_i.get(d)??0)-1)),Dr(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,ai)}),_i.get(d)||(d.removeEventListener(`contextmenu`,Pr,!0),d.removeEventListener(`dblclick`,ti,!0),d.removeEventListener(`pointerdown`,oi,!0),d.removeEventListener(`pointerleave`,ci),d.removeEventListener(`pointermove`,li),d.removeEventListener(`pointerout`,ui),d.removeEventListener(`pointerup`,di,!0)),a.disconnect()}}function yi(){let[e,t]=(0,q.useState)({});return[e,(0,q.useCallback)(()=>t({}),[])]}function bi(e){let t=(0,q.useId)();return`${e??t}`}var xi=typeof window<`u`?q.useLayoutEffect:q.useEffect;function Si(e){let t=(0,q.useRef)(e);return xi(()=>{t.current=e},[e]),(0,q.useCallback)((...e)=>t.current?.(...e),[t])}function Ci(...e){return Si(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function wi(e){let t=(0,q.useRef)({...e});return xi(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var Ti=(0,q.createContext)(null);function Ei(e,t){let n=(0,q.useRef)({getLayout:()=>({}),setLayout:fr});(0,q.useImperativeHandle)(t,()=>n.current,[]),xi(()=>{Object.assign(n.current,ri({groupId:e}))})}function Di({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,q.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=Si(e=>{Qr(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=Si((e,t)=>{Qr(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t}))}),_=bi(s),v=(0,q.useRef)(null),[y,b]=yi(),x=(0,q.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=Ci(v,a);Ei(_,o);let C=Si((e,t)=>{let r=cr(),i=Or(e),a=kr(e);if(a){let e=!1;switch(r.state){case`active`:e=r.hitRegions.some(e=>e.group===i);break}return{flexGrow:a.layout[t]??1,pointerEvents:e?`none`:void 0}}if(n?.[t])return{flexGrow:n?.[t]}}),w=wi({defaultLayout:n,disableCursor:r}),T=(0,q.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=Xn(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Xn(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},updatePanelProps:(e,{disabled:t})=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let r=Or(_),i=kr(_);r&&i&&Mr(r,{...i,derivedPanelConstraints:Yn(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=x.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[C,_,b,u,w]),E=(0,q.useRef)(null);return xi(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:_,mutableState:{defaultLayout:n,disableCursor:!!w.disableCursor,expandedPanelSizes:x.current.lastExpandedPanelSizes,layouts:x.current.layouts},orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=vi(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=kr(r.id,!0);!o&&s.length>0&&(h(c),g(c,!1));let l=jr(_,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:n,layout:i}=e.next;if(t||n.length===0)return;let a=r.panels.map(({id:e})=>e).join(`,`);r.mutableState.layouts[a]=i,n.forEach(t=>{if(t.collapsible){let{layout:n}=e.prev??{};if(n){let e=Y(t.collapsedSize,i[t.panelId]),a=Y(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=cr().state!==`active`;h(i),o&&g(i,e.isUserInteraction)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,q.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,K.jsx)(Ti.Provider,{value:T,children:(0,K.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}Di.displayName=`Group`;function Oi(){let e=(0,q.useContext)(Ti);return J(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function ki(e,t){let{id:n}=Oi(),r=(0,q.useRef)({collapse:pr,expand:pr,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:pr});(0,q.useImperativeHandle)(t,()=>r.current,[]),xi(()=>{Object.assign(r.current,ei({groupId:n,panelId:e}))})}function Ai({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,groupResizeBehavior:s=`preserve-relative-size`,id:c,maxSize:l=`100%`,minSize:u=`0%`,onResize:d,panelRef:f,style:p,...m}){let h=!!c,g=bi(c),_=wi({disabled:a}),v=(0,q.useRef)(null),y=Ci(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=Oi(),T=d!==null,E=Si((e,t,n)=>{d?.(e,c,n)});xi(()=>{let e=v.current;if(e!==null){let t={element:e,id:g,idIsStable:h,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:T?E:void 0,panelConstraints:{groupResizeBehavior:s,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:l,minSize:u}};return C(t)}},[s,n,r,i,T,g,h,l,u,E,C,_]),(0,q.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),ki(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,q.useSyncExternalStore)(e=>jr(x,e),D,D),k;return k=O?JSON.parse(O):i===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:i},(0,K.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...ji,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,K.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}Ai.displayName=`Panel`;var ji={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function Mi({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=$r({layout:Zr({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=$r({layout:Zr({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Ni({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=bi(a),l=wi({disabled:n,disableDoubleClick:r}),[u,d]=(0,q.useState)({}),[f,p]=(0,q.useState)(`inactive`),[m,h]=(0,q.useState)(!1),g=(0,q.useRef)(null),_=Ci(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=Oi(),C=b===`horizontal`?`vertical`:`horizontal`;xi(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=lr(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=jr(y,e=>{let{derivedPanelConstraints:n,layout:r,separatorToPanels:i}=e.next,a=i.get(t);if(a){let e=a[0],t=a.indexOf(e);d(Mi({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,q.useEffect)(()=>{S(c,{disabled:n,disableDoubleClick:r})},[n,r,c,S]);let w;n&&!v&&(w=`not-allowed`);let T;if(n)T=`disabled`;else switch(f){case`active`:T=`active`;break;default:T=m?`focus`:f}return(0,K.jsx)(`div`,{...s,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":C,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":T,"data-testid":c,id:c,onBlur:()=>h(!1),onFocus:()=>h(!0),ref:_,role:`separator`,style:{flexBasis:`auto`,cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}Ni.displayName=`Separator`;function Pi({request:e,targetSession:t,profileId:n,onClose:r,onSaved:i}){let[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(!1);(0,q.useEffect)(()=>{e&&(o(e.name),c(null))},[e]);let d=async()=>{if(!e||!t)return;let r=a.trim().replace(/^\/+/,``).replace(/\/+$/,``);if(r===``){c(`Give the file a path.`);return}u(!0),c(null);try{let a=!0;try{await j(`GET`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(r)}`)}catch(e){if(e instanceof te&&e.status===404)a=!1;else if(e instanceof te&&e.status===413)a=!0;else throw e}if(a){c(`${r} already exists in this worktree.`);return}await j(`PUT`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(r)}`,{content:e.content}),n!==void 0&&await b(n,e.name).catch(()=>void 0),h(e.name),i(e.name,t.id,r)}catch(e){c(e instanceof Error?e.message:`Save failed`)}finally{u(!1)}};return(0,K.jsx)(ce,{open:e!==null,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:`Save draft into the worktree`}),(0,K.jsx)(se,{children:t?(0,K.jsxs)(K.Fragment,{children:[`Saves into `,(0,K.jsx)(`span`,{className:`font-mono`,children:t.branch}),` — the worktree the sidebar is bound to.`]}):`No worktree is bound — open or focus a session first.`})]}),(0,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),d()},children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(ze,{htmlFor:`untitled-path`,children:`Worktree-relative path`}),(0,K.jsx)(ke,{id:`untitled-path`,placeholder:`docs/notes.md`,value:a,onChange:e=>o(e.target.value),className:`font-mono`,autoFocus:!0})]}),s&&(0,K.jsx)(`p`,{className:`text-xs text-danger`,children:s}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{type:`button`,variant:`ghost`,onClick:r,children:`Cancel`}),(0,K.jsx)(I,{type:`submit`,disabled:l||!t,children:`Save`})]})]})]})})}function Fi(e,t,n){let r=n.snapshot.explorer_pin,i=r===null?null:e.find(e=>e.id===r&&e.status!==`archived`)??null;return{session:i??e.find(e=>e.id===t)??null,pinned:i!==null,pin(e){n.update({explorer_pin:e})},unpin(){n.update({explorer_pin:null})}}}var Ii=null,Li=null;async function Ri(){let[e,t]=await Promise.all([O(()=>import(`./PaneEditorBody-CbwKaj3E.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])),O(()=>import(`./ModelRefcount-sJruf69B.js`),__vite__mapDeps([21,1,2,16,7,9,3,4,5,10,11,8,12,13,14,15,17]))]);Ii=e.PaneEditorBody,Li=t.ModelRefcount}var zi=(0,q.lazy)(()=>O(()=>import(`./PaneEditorBody-CbwKaj3E.js`).then(e=>({default:e.PaneEditorBody})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])));function Bi(e){return Ii?(0,K.jsx)(Ii,{...e}):(0,K.jsx)(q.Suspense,{fallback:(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-xs text-fg-muted`,children:`Loading editor…`}),children:(0,K.jsx)(zi,{...e})})}var Vi=(0,q.lazy)(()=>O(()=>import(`./ModelRefcount-sJruf69B.js`).then(e=>({default:e.ModelRefcount})),__vite__mapDeps([21,1,2,16,7,9,3,4,5,10,11,8,12,13,14,15,17])));function Hi({buffers:e}){return Li?(0,K.jsx)(Li,{buffers:e}):(0,K.jsx)(q.Suspense,{fallback:null,children:(0,K.jsx)(Vi,{buffers:e})})}var Ui=(0,q.lazy)(()=>O(()=>import(`./EditorTabClose-C5BL8wr0.js`).then(e=>({default:e.EditorTabClose})),__vite__mapDeps([22,1,2,3,10,11,8,16,7,9,4,5,12,13,14,15,17,19,18])));function Wi(e){return(0,K.jsx)(q.Suspense,{fallback:(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e.onClose()},className:`hidden size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg group-hover:flex pointer-coarse:flex`,"aria-label":`Close ${e.label}`,children:`×`}),children:(0,K.jsx)(Ui,{...e})})}var Gi=e(n(),1);function Ki(){return crypto.randomUUID()}function X(e){return e.type===`terminal`?`term:${e.session}`:`editor:${C(e.tab)}`}function qi(e,t){return X(e)===X(t)}function Ji(e){return e.type===`terminal`}function Yi(e=[],t){let n=e.map(X),r=t&&n.includes(t)?t:n.length>0?n[0]:null;return{kind:`leaf`,id:Ki(),tabs:e,activeKey:r,previewKey:null}}function Xi(e,t,n){return{kind:`split`,id:Ki(),direction:e,children:t,sizes:n??t.map(()=>100/Math.max(1,t.length))}}function Zi(e,t){if(e.kind===`leaf`)return e.id===t?e:null;for(let n of e.children){let e=Zi(n,t);if(e)return e}return null}function Qi(e,t){if(e.kind===`leaf`)return e.tabs.some(e=>X(e)===t)?e:null;for(let n of e.children){let e=Qi(n,t);if(e)return e}return null}function $i(e){return e.kind===`leaf`?[e]:e.children.flatMap($i)}function ea(e){return $i(e).flatMap(e=>e.tabs)}function ta(e){let t=e.tabs.map(X),n=e.activeKey&&t.includes(e.activeKey)?e.activeKey:t[0]??null,r=e.previewKey&&t.includes(e.previewKey)?e.previewKey:null;return n===e.activeKey&&r===(e.previewKey??null)?e:{...e,activeKey:n,previewKey:r}}function na(e){if(e.kind===`leaf`)return ta(e);let t=e.children.map(na),n=[],r=[];t.forEach((t,i)=>{let a=e.sizes[i]??1;if(t.kind===`split`&&t.direction===e.direction){let e=t.sizes.reduce((e,t)=>e+t,0)||t.children.length;t.children.forEach((i,o)=>{n.push(i),r.push(a*(t.sizes[o]??1)/e)})}else n.push(t),r.push(a)});let i=[],a=[];return n.forEach((e,t)=>{e.kind===`leaf`&&e.tabs.length===0||(i.push(e),a.push(r[t]??1))}),i.length===0?Yi([]):i.length===1?i[0]:{...e,children:i,sizes:a}}function ra(e,t,n){return e.kind===`leaf`?e.id===t?n(e):e:{...e,children:e.children.map(e=>ra(e,t,n))}}function ia(e,t){if(e.kind===`leaf`){if(!e.tabs.some(e=>X(e)===t))return e;let n=e.tabs.filter(e=>X(e)!==t),r=e.activeKey===t?aa(e,t):e.activeKey;return{...e,tabs:n,activeKey:r}}return{...e,children:e.children.map(e=>ia(e,t))}}function aa(e,t){let n=e.tabs.findIndex(e=>X(e)===t);if(n===-1)return e.activeKey;let r=e.tabs.filter(e=>X(e)!==t);return r.length===0?null:X(r[Math.min(n,r.length-1)])}function oa(e,t,n){let r=e.tabs.filter(e=>!qi(e,t)),i=n===void 0?r.length:Math.max(0,Math.min(n,r.length)),a=[...r.slice(0,i),t,...r.slice(i)];return{...e,tabs:a,activeKey:X(t)}}function sa(e,t,n,r){let i=n===`left`||n===`right`?`row`:`col`,a=n===`left`||n===`top`;return na(ra(e,t,e=>{let t=Yi([r]);return Xi(i,a?[t,e]:[e,t],[50,50])}))}function ca(e,t){let{ref:n,toLeafId:r,edge:i}=t,a=X(n),o=t.index;if(i===`center`&&o!==void 0){let t=Zi(e,r)?.tabs.findIndex(e=>X(e)===a)??-1;t!==-1&&t<o&&--o}let s=ia(e,a);if(i===`center`){let e=ra(s,r,e=>oa(e,n,o));return!Zi(e,r)&&!Qi(e,a)?pa(na(la(e,n)),a):pa(na(e),a)}return Zi(s,r)?pa(sa(s,r,i,n),a):na(Yi([n]))}function la(e,t){let n=$i(e)[0];return n?ra(e,n.id,e=>oa(e,t)):Yi([t])}function ua(e,t,n){return na(ra(e,t,e=>e.tabs.some(e=>X(e)===n)?{...e,tabs:e.tabs.filter(e=>X(e)!==n),activeKey:e.activeKey===n?aa(e,n):e.activeKey}:e))}function da(e,t,n){let r=X(n);return na(ra(e,t,e=>{let t=e.previewKey===r?null:e.previewKey;return e.tabs.some(e=>qi(e,n))?{...e,activeKey:r,previewKey:t}:{...e,tabs:[...e.tabs,n],activeKey:r,previewKey:t}}))}function fa(e,t,n){let r=X(n);return na(ra(e,t,e=>{if(e.tabs.some(e=>qi(e,n)))return{...e,activeKey:r};let t=e.previewKey?e.tabs.findIndex(t=>X(t)===e.previewKey):-1,i=t>=0&&!Ji(e.tabs[t])?e.tabs.map((e,r)=>r===t?n:e):[...e.tabs,n];return{...e,tabs:i,activeKey:r,previewKey:r}}))}function pa(e,t){let n=e=>e.kind===`leaf`?e.previewKey===t?{...e,previewKey:null}:e:{...e,children:e.children.map(n)};return n(e)}function ma(e,t,n){let r=e=>e.kind===`leaf`?{...e,tabs:e.tabs.map(e=>e.type===`editor`&&X(e)===t?{...e,tab:{...e.tab,view:n}}:e)}:{...e,children:e.children.map(r)};return r(e)}function ha(e,t,n){return ra(e,t,e=>e.tabs.some(e=>X(e)===n)?{...e,activeKey:n}:e)}function ga(e,t,n){function r(e){return e.kind===`leaf`?e:e.id===t&&n.length===e.children.length?{...e,children:e.children.map(r),sizes:[...n]}:{...e,children:e.children.map(r)}}return r(e)}function _a(e,t){let n=e=>e.kind===`leaf`?{...e,tabs:e.tabs.filter(t)}:{...e,children:e.children.map(n)};return na(n(e))}function va(e){let t=e.editor_tabs.map(e=>({type:`editor`,tab:e})),n=e.session_tabs.map(e=>({type:`terminal`,session:e})),r=e.active_editor_tab?X({type:`editor`,tab:e.active_editor_tab}):null,i=e.active_session?`term:${e.active_session}`:null;if(t.length===0&&n.length===0)return Yi([]);if(t.length===0)return Yi(n,i);if(n.length===0)return Yi(t,r);let a=e.layout,o=typeof a.editor==`number`?a.editor:40,s=typeof a.session==`number`?a.session:60;return na(Xi(`col`,[Yi(t,r),Yi(n,i)],[o,s]))}var ya=(0,q.createContext)(null);function ba({tree:e,onOpenFile:t,children:n}){let r=(0,q.useRef)(null),i=(0,q.useRef)(new Map).current,[a,o]=(0,q.useState)(()=>new Set),s=(0,q.useCallback)((e,t)=>{o(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),c=(0,q.useMemo)(()=>{let t=new Set;for(let n of $i(e))for(let e of n.tabs)e.type===`terminal`&&t.add(e.session);return[...t]},[e]),l=e=>{let t=`term:${e}`,n=i.get(t);return n||(n=document.createElement(`div`),n.className=`size-full`,i.set(t,n)),n};(0,q.useEffect)(()=>{let e=new Set(c.map(e=>`term:${e}`));for(let e of c){let t=i.get(`term:${e}`);t&&!t.parentElement&&r.current?.appendChild(t)}for(let[t,n]of[...i])e.has(t)||(n.remove(),i.delete(t))},[c,i]);let u=(0,q.useMemo)(()=>({parkingRef:r,containers:i,setAdopted:s}),[i,s]);return(0,K.jsxs)(ya.Provider,{value:u,children:[(0,K.jsx)(`div`,{ref:r,className:`hidden`,"aria-hidden":!0}),c.map(e=>(0,Gi.createPortal)((0,K.jsx)(Be,{stream:e,paused:!a.has(`term:${e}`),onOpenFile:(n,r,i)=>t(e,n,r,i)}),l(e),e)),n]})}function xa(e){let t=(0,q.useContext)(ya),n=(0,q.useRef)(null);return(0,q.useEffect)(()=>{let r=n.current;if(!t||!e||!r)return;let i=t.containers.get(e);return i&&(r.appendChild(i),t.setAdopted(e,!0)),()=>{let n=t.parkingRef.current;i&&n&&i.parentElement===r&&n.appendChild(i),i&&t.setAdopted(e,!1)}},[t,e]),n}function Sa(e){let[t,n]=(0,q.useState)(()=>window.matchMedia(e).matches);return(0,q.useEffect)(()=>{let t=window.matchMedia(e),r=e=>n(e.matches);return n(t.matches),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var Ca=`(max-width: 767px)`;function wa(e,t){let n={};for(let r of t){let t=e[r];if(typeof t!=`number`)return;n[r]=t}return n}function Ta({text:e,hoverClass:t,className:n,title:r}){let i=(0,q.useRef)(null),[a,o]=(0,q.useState)(0);return(0,q.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>o(Math.max(0,e.scrollWidth-e.clientWidth));t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]),(0,K.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:(0,K.jsx)(`span`,{ref:i,title:r,className:H(`block whitespace-nowrap transition-transform duration-[900ms] ease-linear`,n,a>0&&t),style:a>0?{"--tail":`-${a}px`}:void 0,children:e})})}var Ea={added:{letter:`A`,label:`added`,colourClass:`text-success`},modified:{letter:`M`,label:`modified`,colourClass:`text-fg-secondary`},deleted:{letter:`D`,label:`deleted`,colourClass:`text-interrupted`},renamed:{letter:`R`,label:`renamed`,colourClass:`text-warning`}};function Da(e){return Ea[e]}var Oa=[`modified`,`added`,`deleted`,`renamed`];function ka(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return Oa.filter(e=>t.has(e)).map(e=>`${t.get(e)} ${Ea[e].label}`).join(` · `)}var Aa=[`var(--accent)`,`var(--status-running)`,`var(--status-waiting)`,`var(--ansi-magenta)`,`var(--ansi-cyan)`,`var(--status-interrupted)`];function ja(e){return Aa[e%Aa.length]}function Ma(e){let t=[],n=0,r=0,i=()=>{let e=t.indexOf(null);return e===-1?t.length:e},a=()=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];r&&e.push({col:n,sha:r.sha,colour:ja(r.colourIdx)})}return e},o=[],s=[];for(let c of e){let e=c.parents??[],l=[];for(let e=0;e<t.length;e++)t[e]?.sha===c.sha&&l.push(e);let u,d;l.length>0?(u=l[0],d=t[u].colourIdx):(u=i(),d=n++);let f=ja(d);for(let e of l)t[e]=null;for(;t.length<=u;)t.push(null);let p=[];if(e.length>0){t[u]={sha:e[0],colourIdx:d},p.push(u);for(let r=1;r<e.length;r++){let a=e[r],o=t.findIndex(e=>e?.sha===a);if(o===-1){for(o=i();t.length<=o;)t.push(null);t[o]={sha:a,colourIdx:n++}}p.push(o)}}else t[u]=null;let m=a();o.push({sha:c.sha,col:u,colour:f,above:s,below:m,created:p}),s=m,r=Math.max(r,t.length)}return{rows:o,laneCount:r}}var Na=7,Pa=14,Fa=4,Ia=1.5,La=40,Ra=22,za=`group-hover:[transform:translateX(var(--tail))]`;function Ba(e){return e*Pa+Pa/2}function Va(e,t,n,r){if(e===n)return`M ${e} ${t} L ${n} ${r}`;let i=(t+r)/2;return`M ${e} ${t} C ${e} ${i}, ${n} ${i}, ${n} ${r}`}function Ha({row:e,width:t}){let n=La,r=n/2,i=Ba(e.col),a=new Set(e.created),o=[];for(let t of e.above){let n=Ba(t.col);t.sha===e.sha?o.push({d:Va(n,0,i,r),colour:t.colour}):o.push({d:Va(n,0,n,r),colour:t.colour})}for(let t of e.below){let e=Ba(t.col);a.has(t.col)?o.push({d:Va(i,r,e,n),colour:t.colour}):o.push({d:Va(e,r,e,n),colour:t.colour})}return(0,K.jsxs)(`svg`,{width:t,height:n,className:`shrink-0`,"aria-hidden":!0,children:[o.map((e,t)=>(0,K.jsx)(`path`,{d:e.d,fill:`none`,stroke:e.colour,strokeWidth:Ia},t)),(0,K.jsx)(`circle`,{cx:i,cy:r,r:Fa,fill:`var(--bg-surface)`,stroke:e.colour,strokeWidth:Ia})]})}function Ua({lanes:e,width:t}){return(0,K.jsx)(`svg`,{width:t,height:Ra,className:`shrink-0`,"aria-hidden":!0,children:e.map(e=>{let t=Ba(e.col);return(0,K.jsx)(`path`,{d:`M ${t} 0 L ${t} ${Ra}`,fill:`none`,stroke:e.colour,strokeWidth:Ia},e.col)})})}function Wa({session:e,sha:t,lanes:n,gutterW:r,onOpen:i}){let a=d(e,t),o=e=>(0,K.jsxs)(`div`,{className:`flex items-center`,style:{height:Ra},children:[(0,K.jsx)(Ua,{lanes:n,width:r}),(0,K.jsx)(`span`,{className:`px-2 text-2xs text-fg-muted`,children:e})]});return a.isPending?o(`…`):a.error?o(a.error instanceof Error?a.error.message:`Failed to load commit`):a.data.files.length===0?o(`No file changes.`):(0,K.jsx)(K.Fragment,{children:a.data.files.map(e=>{let a=Da(e.status),o=e.status===`renamed`&&e.old_path?`${e.old_path} → ${e.path}`:e.path;return(0,K.jsxs)(`button`,{type:`button`,title:o,onClick:()=>i(e.path,t),className:`flex w-full items-center text-left transition-colors hover:bg-elevated`,style:{height:Ra},children:[(0,K.jsx)(Ua,{lanes:n,width:r}),(0,K.jsx)(`span`,{className:H(`mr-1.5 w-3 shrink-0 text-center font-mono text-xs`,a.colourClass),children:a.letter}),(0,K.jsx)(`span`,{className:`truncate pr-3 font-mono text-2xs text-fg`,children:o})]},`${e.status}:${e.old_path??``}:${e.path}`)})})}function Ga({session:e,onOpenCommitFile:t}){let n=v(e),[r,i]=(0,q.useState)(null),a=(0,q.useMemo)(()=>n.data?.pages.flatMap(e=>e.commits)??[],[n.data]),o=(0,q.useMemo)(()=>Ma(a),[a]),s=Math.max(1,o.laneCount)*Pa+Pa/2;return n.isPending?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading history…`}):n.error?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:n.error instanceof Error?n.error.message:`Failed to load history`}):a.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No commits yet.`}):(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[o.rows.map((n,o)=>{let c=a[o],l=r===n.sha;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(l?null:n.sha),className:H(`group flex w-full items-center text-left transition-colors hover:bg-elevated`,l&&`bg-selection`),style:{height:La},children:[(0,K.jsx)(Ha,{row:n,width:s}),(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 pr-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-2xs text-fg-muted`,children:n.sha.slice(0,Na)}),(0,K.jsx)(Ta,{text:c.subject,className:`text-xs text-fg`,hoverClass:za})]}),(0,K.jsxs)(`span`,{className:`truncate text-2xs text-fg-muted`,children:[c.author_name,` ·`,` `,(0,K.jsx)(`span`,{className:`tabular-nums`,children:f(c.authored_at)})]})]})]}),l&&(0,K.jsx)(Wa,{session:e,sha:n.sha,lanes:n.below,gutterW:s,onOpen:t})]},n.sha)}),n.hasNextPage&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>void n.fetchNextPage(),disabled:n.isFetchingNextPage,className:`px-3 py-2 text-left font-mono text-xs text-fg-muted transition-colors hover:bg-elevated`,children:n.isFetchingNextPage?`Loading…`:`Show more`})]})}function Ka(){return{dirs:new Map,files:[]}}function qa(e){return e.path}function Ja(e,t){let n=[];for(let[r,i]of e.dirs){let e=t?`${t}/${r}`:r,a={type:`dir`,name:r,path:e,children:Ja(i,e)};for(;a.children.length===1&&a.children[0].type===`dir`;){let e=a.children[0];a={type:`dir`,name:`${a.name}/${e.name}`,path:e.path,children:e.children}}n.push(a)}n.sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}));let r=[...e.files].sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`}));return[...n,...r]}function Ya(e){let t=Ka();for(let n of e){let e=qa(n),r=e.split(`/`),i=r.pop(),a=t;for(let e of r){let t=a.dirs.get(e);t||(t=Ka(),a.dirs.set(e,t)),a=t}a.files.push({type:`file`,name:i,path:e,entry:n})}return Ja(t,``)}function Xa(e){return e.map(e=>({type:`file`,name:qa(e).split(`/`).pop()??qa(e),path:qa(e),entry:e})).sort((e,t)=>e.path.localeCompare(t.path,void 0,{sensitivity:`base`}))}function Za({name:e,fullPath:t,status:n,depth:r,active:i,onOpen:a}){let o=Da(n);return(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:H(`flex w-full items-center gap-1.5 py-1 pr-3 text-left transition-colors hover:bg-elevated`,i&&`bg-selection`),style:{paddingLeft:8+r*12},children:[(0,K.jsx)(`span`,{className:H(`w-3 shrink-0 text-center font-mono text-xs`,o.colourClass),children:o.letter}),(0,K.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:e})]})}function Qa({nodes:e,depth:t,activePath:n,onOpen:r}){let[i,a]=(0,q.useState)(new Set);return(0,K.jsx)(K.Fragment,{children:e.map(e=>{if(e.type===`file`)return(0,K.jsx)(Za,{name:e.name,fullPath:e.path,status:e.entry.status,depth:t,active:n===e.path,onOpen:r},e.path);let o=i.has(e.path);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),className:`flex w-full items-center gap-1 py-1 pr-3 text-left transition-colors hover:bg-elevated`,style:{paddingLeft:8+t*12},children:[o?(0,K.jsx)(Tt,{className:`size-3.5 shrink-0 text-fg-gold`}):(0,K.jsx)(Ct,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,K.jsx)(`span`,{className:`truncate font-mono text-xs text-fg-secondary`,children:e.name})]}),!o&&(0,K.jsx)(Qa,{nodes:e.children,depth:t+1,activePath:n,onOpen:r})]},e.path)})})}function $a({session:e,activePath:t,onOpen:n}){let[r,i]=(0,q.useState)(!1),a=l(e,{against:`head`}),o=a.data?.entries??[],s=(0,q.useMemo)(()=>r?null:Ya(o),[r,o]),c=(0,q.useMemo)(()=>r?Xa(o):null,[r,o]);return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex h-7 shrink-0 items-center gap-2 px-3`,children:[(0,K.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Uncommitted`}),o.length>0&&(0,K.jsx)(`span`,{className:`truncate font-mono text-2xs text-fg-muted`,children:ka(o)}),(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":!r,onClick:()=>i(e=>!e),className:`ml-auto rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[r?(0,K.jsx)(On,{className:`size-3.5`}):(0,K.jsx)(wn,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:r?`Show as tree`:`Show as flat list`})]})}),(0,K.jsx)(Gt,{children:r?`Show as tree`:`Show as flat list`})]})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-1`,children:a.isPending?(0,K.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`Loading changes…`}):a.error?(0,K.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:a.error instanceof Error?a.error.message:`Failed to load changes`}):o.length===0?(0,K.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`No uncommitted changes.`}):r?c.map(e=>(0,K.jsx)(Za,{name:e.path,fullPath:e.path,status:e.entry.status,depth:0,active:t===e.path,onOpen:n},e.path)):(0,K.jsx)(Qa,{nodes:s,depth:0,activePath:t,onOpen:n})})]})}function eo({session:e,activeDiffPath:t,onOpenDiff:n,onOpenCommitFile:r}){return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsx)(`section`,{className:`flex max-h-[45%] min-h-0 flex-col`,children:(0,K.jsx)($a,{session:e,activePath:t,onOpen:n})}),(0,K.jsx)(`div`,{className:`h-px shrink-0 bg-border`}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsx)(`div`,{className:`flex h-7 shrink-0 items-center px-3`,children:(0,K.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`History`})}),(0,K.jsx)(Ga,{session:e,onOpenCommitFile:r})]})]})}var to={"package.json":dn,"package-lock.json":gn,"pnpm-lock.yaml":gn,"yarn.lock":gn,"pnpm-workspace.yaml":fn,dockerfile:G,".gitignore":fn,".gitattributes":fn,"readme.md":bn,license:bn,licence:bn},no={ts:G,tsx:G,mts:G,cts:G,js:G,jsx:G,mjs:G,cjs:G,py:G,rs:G,go:G,rb:G,php:G,java:G,kt:G,c:G,h:G,cpp:G,hpp:G,cc:G,html:G,htm:G,xml:G,vue:G,sql:G,json:dn,jsonc:dn,yml:fn,yaml:fn,toml:fn,ini:fn,cfg:fn,conf:fn,env:hn,lock:gn,csv:vn,tsv:vn,xlsx:vn,xls:vn,md:bn,mdx:bn,markdown:bn,txt:bn,rtf:bn,log:bn,pdf:bn,css:xn,scss:xn,sass:xn,less:xn,sh:yn,bash:yn,zsh:yn,fish:yn,svg:mn,png:mn,jpg:mn,jpeg:mn,gif:mn,webp:mn,bmp:mn,ico:mn,avif:mn,mp4:_n,mov:_n,webm:_n,mkv:_n,avi:_n,mp3:pn,wav:pn,flac:pn,ogg:pn,m4a:pn,zip:un,tar:un,gz:un,tgz:un,rar:un,"7z":un};function ro(e){let t=e.toLowerCase(),n=to[t];if(n)return{Icon:n,generic:!1};let r=t.lastIndexOf(`.`);if(r>0){let e=no[t.slice(r+1)];if(e)return{Icon:e,generic:!1}}return{Icon:Sn,generic:!0}}function io({name:e,dimmed:t}){let{Icon:n,generic:r}=ro(e);return(0,K.jsx)(n,{className:H(`size-3.5 shrink-0`,t||r?`text-fg-muted`:`text-fg`)})}function ao(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function oo(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function so(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n<=0?`/`:t.slice(0,n)}function co(e,t){return e===``?t:`${e}/${t}`}function lo(e){let t=new Set(e);return e.filter(e=>{if(e===``)return!0;for(let n=oo(e);;n=oo(n)){if(t.has(n))return!1;if(n===``)return!0}})}var uo=`application/x-puddle-paths`;function fo(e){return JSON.stringify(e)}function po(e){try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function mo(e,t){let n=[],r=(i,a)=>{let o=e(i);if(o)for(let e of o.entries){let o=co(i,e.name);n.push({path:o,name:e.name,type:e.type,depth:a,parentDir:i}),e.type===`dir`&&t.has(o)&&r(o,a+1)}};return r(``,0),n}function ho(e,t,n){let r=e.findIndex(e=>e.path===t),i=e.findIndex(e=>e.path===n);if(r===-1||i===-1)return n?[n]:[];let[a,o]=r<=i?[r,i]:[i,r];return e.slice(a,o+1).map(e=>e.path)}function go({sid:e,root:t,onNavigateUp:n,onReset:r,onOpenFile:i}){let a=V();return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-1 px-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:n,disabled:t===`/`,title:`Parent directory`,className:`shrink-0 rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg disabled:pointer-events-none disabled:opacity-40`,children:[(0,K.jsx)(Et,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Parent directory`})]}),(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-fg-secondary`,title:t,children:kt(t,a.data?.home)}),(0,K.jsxs)(`button`,{type:`button`,onClick:r,title:`Back to the worktree`,className:`ml-auto shrink-0 rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(Rn,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Back to the worktree`})]})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:(0,K.jsx)(_o,{sid:e,root:t,dir:``,depth:0,onOpenFile:i})})]})}function _o({sid:e,root:t,dir:n,depth:r,onOpenFile:i}){let a=c(e,n,t),[o,s]=(0,q.useState)(new Set);return a.isPending?(0,K.jsx)(`div`,{className:`px-3 py-1 text-2xs text-fg-muted`,style:{paddingLeft:r*12+12},children:`…`}):a.error?(0,K.jsx)(`div`,{className:`px-3 py-1 text-2xs text-fg-muted`,style:{paddingLeft:r*12+12},children:a.error instanceof Error?a.error.message:`Unreadable`}):(0,K.jsxs)(K.Fragment,{children:[a.data.entries.map(a=>{let c=co(n,a.name),l=a.type===`dir`,u=o.has(c);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{l?s(e=>{let t=new Set(e);return t.has(c)?t.delete(c):t.add(c),t}):i(c)},onDoubleClick:()=>{l||i(c,{preview:!1})},className:`flex w-full items-center gap-1.5 py-0.5 pr-2 text-left transition-colors hover:bg-elevated`,style:{paddingLeft:r*12+8},children:[(0,K.jsx)(Tt,{className:H(`size-3 shrink-0 text-fg-muted transition-transform`,u&&`rotate-90`,!l&&`invisible`)}),l?u?(0,K.jsx)(Ft,{className:`size-3.5 shrink-0 text-fg`}):(0,K.jsx)(Cn,{className:`size-3.5 shrink-0 text-fg`}):(0,K.jsx)(io,{name:a.name}),(0,K.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:a.name}),a.symlink&&(0,K.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:`→`})]}),l&&u&&(0,K.jsx)(_o,{sid:e,root:t,dir:c,depth:r+1,onOpenFile:i})]},c)}),a.data.entries.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-1 text-2xs text-fg-muted`,style:{paddingLeft:r*12+12},children:`Empty.`})]})}async function vo(e){let t=e.createReader(),n=[];for(;;){let e=await new Promise((e,n)=>t.readEntries(e,n));if(e.length===0)return n;n.push(...e)}}function yo(e){return new Promise((t,n)=>e.file(t,n))}async function bo(e,t,n){if(e.isFile){let r=await yo(e);n.push(t?new File([r],`${t}/${e.name}`,{type:r.type,lastModified:r.lastModified}):r)}else if(e.isDirectory){let r=await vo(e),i=t?`${t}/${e.name}`:e.name;for(let e of r)await bo(e,i,n)}}function xo(e,t,n){let r=Array.from(e??[]).map(e=>({entry:e.webkitGetAsEntry?.()??null,file:e.kind===`file`?e.getAsFile():null})),i=Array.from(t);return(async()=>{if(r.every(({entry:e,file:t})=>e===null&&t===null))return i;if(!n)return r.some(({entry:e})=>e?.isDirectory)&&k.error(`This daemon can't take folders — update it, or zip them first`),r.filter(({entry:e})=>e?.isDirectory!==!0).map(({file:e})=>e).filter(e=>e!==null);let e=[];for(let{entry:t,file:n}of r)t?.isDirectory?await bo(t,``,e):n&&e.push(n);return e})()}var So={untracked:{letter:`U`,colourClass:`text-success`},added:{letter:`A`,colourClass:`text-success`},modified:{letter:`M`,colourClass:`text-warning`},renamed:{letter:`R`,colourClass:`text-warning`},deleted:{letter:`D`,colourClass:`text-interrupted`},conflicted:{letter:`C`,colourClass:`text-interrupted`},ignored:{letter:``,colourClass:`text-fg-muted`}};function Co(e){return So[e]}function wo(e){let t=new Map;for(let n of e)t.set(n.path,n.status);return t}var To={conflicted:0,modified:1,renamed:2,deleted:3,added:4,untracked:5,ignored:6};function Eo(e,t){let n=t===``?``:`${t}/`,r=null;for(let[t,i]of e)n!==``&&!t.startsWith(n)||i!==`ignored`&&(r===null||To[i]<To[r])&&(r=i);return r}var Do=(e,t)=>e instanceof Error?e.message:t;function Oo(e){let t=i(),n=(0,q.useCallback)(()=>{t.invalidateQueries({queryKey:[`wt-tree`,e]}),t.invalidateQueries({queryKey:[`wt-git-status`,e]})},[t,e]);return(0,q.useMemo)(()=>({async create(t,r,i){try{let a=await D(e,co(t,r),i);return n(),a.path}catch(e){return k.error(Do(e,`Couldn't create ${r}`)),null}},async rename(t,r){let i=co(t.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)):``,r);try{let r=await u(e,t,i);return n(),r.path}catch(e){return k.error(Do(e,`Couldn't rename ${ao(t)}`)),null}},async move(t,r){let i=await Promise.allSettled(t.map(t=>u(e,t,co(r,ao(t)))));n();let a=i.filter(e=>e.status===`rejected`);a.length>0&&k.error(t.length===1?Do(a[0].reason,`Couldn't move ${ao(t[0])}`):`Couldn't move ${a.length} item${a.length>1?`s`:``}`)},async remove(t){let r=await Promise.allSettled(t.map(t=>m(e,t)));n();let i=r.filter(e=>e.status===`rejected`).length;i>0?k.error(`Couldn't delete ${i} item${i>1?`s`:``}`):k.success(t.length===1?`Deleted ${ao(t[0])}`:`Deleted ${t.length} items`)},async paste(t,r){let i=t.mode===`cut`?u:w,a=await Promise.allSettled(t.paths.map(t=>i(e,t,co(r,ao(t)))));n();let o=a.filter(e=>e.status===`rejected`).length;o>0&&k.error(`Couldn't paste ${o} item${o>1?`s`:``}`)}}),[e,n])}function ko(e,t,n){return n&&n.type!==`dir`||(e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``)===t?!1:t===``||!`${t}/`.startsWith(`${e}/`)}var Ao=(0,q.createContext)(null);function jo(){let e=(0,q.useContext)(Ao);if(!e)throw Error(`explorer components must render inside <ExplorerProvider>`);return e}function Mo(){return(0,q.useContext)(Ao)}function No({session:e,onOpenFile:t,onOpenTerminal:n,activePath:r,children:a}){let s=e.id,c=i(),l=Oo(s),u=(0,q.useCallback)((e,t)=>{t.length!==0&&T(s,e,t).then(()=>{c.invalidateQueries({queryKey:[`wt-tree`,s,e]}),c.invalidateQueries({queryKey:[`wt-git-status`,s]}),k.success(t.length===1?`Uploaded ${t[0].name}`:`Uploaded ${t.length} files`)}).catch(e=>k.error(e instanceof Error?e.message:`Upload failed`))},[s,c]),d=He().data?.protocol,f=!d||d.major>9||d.major===9&&d.minor>=2,p=(0,q.useCallback)((e,t,n)=>{xo(t,n,f).then(t=>u(e,t)).catch(e=>k.error(e instanceof Error?e.message:`Couldn't read the dropped folder`))},[u,f]),[m,h]=(0,q.useState)(new Set),[g,_]=(0,q.useState)(new Set),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(null),[w,D]=(0,q.useState)(null),[O,ee]=(0,q.useState)(null),A=(0,q.useRef)(null),j=o(s),te=(0,q.useMemo)(()=>wo(j.data?.entries??[]),[j.data]),[ne,re]=(0,q.useState)(0);(0,q.useEffect)(()=>c.getQueryCache().subscribe(e=>{if(e.type!==`added`&&e.type!==`removed`&&e.type!==`updated`)return;let t=e.query.queryKey;Array.isArray(t)&&t[0]===`wt-tree`&&t[1]===s&&re(e=>e+1)}),[c,s]);let M=(0,q.useMemo)(()=>mo(e=>c.getQueryData([`wt-tree`,s,e]),m),[c,s,m,ne]),N=(0,q.useCallback)(e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),P=(0,q.useCallback)(e=>{h(t=>t.has(e)?t:new Set(t).add(e))},[]),ie=(0,q.useCallback)(()=>h(new Set),[]),F=(0,q.useCallback)((e,n)=>{if(y(e.path),n.metaKey||n.ctrlKey){_(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),A.current=e.path;return}if(n.shiftKey&&A.current){_(new Set(ho(M,A.current,e.path)));return}_(new Set([e.path])),A.current=e.path,e.type===`dir`?N(e.path):t?.(s,e.path)},[M,N,t,s]),I=(0,q.useCallback)(e=>{e.type!==`dir`&&t?.(s,e.path,{preview:!1})},[t,s]),ae=(0,q.useCallback)(e=>{_(new Set([e])),y(e),A.current=e},[]),oe=(0,q.useCallback)(e=>x({paths:lo(e),mode:`cut`}),[]),L=(0,q.useCallback)(e=>x({paths:lo(e),mode:`copy`}),[]),R=(0,q.useCallback)(e=>{b&&l.paste(b,e).then(()=>{b.mode===`cut`&&x(null)})},[b,l]),z=(0,q.useCallback)(e=>C({mode:`rename`,path:e}),[]),se=(0,q.useCallback)((e,t)=>{e!==``&&P(e),C({mode:`create`,parentDir:e,kind:t})},[P]),ce=(0,q.useCallback)(()=>C(null),[]),le=(0,q.useCallback)(e=>{let n=e.trim(),r=S;if(C(null),!(!r||n===``))if(r.mode===`rename`){if(n===ao(r.path))return;l.rename(r.path,n)}else l.create(r.parentDir,n,r.kind).then(e=>{e&&r.kind===`file`&&t?.(s,e)})},[S,l,t,s]),B=(0,q.useCallback)(e=>{let t=lo(e);t.length>0&&ee(t)},[]),ue=(0,q.useCallback)(()=>{let e=O;ee(null),e&&l.remove(e)},[O,l]),de=(0,q.useCallback)(()=>ee(null),[]),fe=(0,q.useCallback)((t,n)=>{let r=t.map(t=>n?t:co(e.worktree_path,t)).join(`
3
+ `);navigator.clipboard.writeText(r);let i=n?`Relative path`:`Path`;k.success(t.length>1?`${t.length} ${i.toLowerCase()}s copied`:`${i} copied`)},[e.worktree_path]),pe=(0,q.useCallback)(e=>{(async()=>{for(let t of lo(e))await E(s,t)})().catch(e=>k.error(e instanceof Error?e.message:`Download failed`))},[s]),me=(0,q.useCallback)(()=>{c.invalidateQueries({queryKey:[`wt-tree`,s]}),c.invalidateQueries({queryKey:[`wt-git-status`,s]})},[c,s]),he=(0,q.useCallback)((e,t)=>{let n=lo(t).filter(t=>ko(t,e));n.length>0&&l.move(n,e)},[l]),V=(0,q.useCallback)(()=>v&&g.has(v)?[...g]:v?[v]:[...g],[v,g]),ge=(0,q.useRef)({buffer:``,at:0}),_e=(0,q.useCallback)(e=>{if(S)return;let n=M;if(n.length===0)return;let r=v?n.findIndex(e=>e.path===v):-1,i=(e,t)=>{let r=n[Math.max(0,Math.min(n.length-1,e))];r&&(y(r.path),t&&A.current?_(new Set(ho(n,A.current,r.path))):(_(new Set([r.path])),A.current=r.path))},a=r>=0?n[r]:void 0,o=e.metaKey||e.ctrlKey;switch(e.key){case`ArrowDown`:e.preventDefault(),i(r+1,e.shiftKey);return;case`ArrowUp`:e.preventDefault(),i(r<=0?0:r-1,e.shiftKey);return;case`ArrowRight`:e.preventDefault(),a?.type===`dir`&&!m.has(a.path)?P(a.path):a?.type===`dir`&&i(r+1,!1);return;case`ArrowLeft`:if(e.preventDefault(),a?.type===`dir`&&m.has(a.path))N(a.path);else if(a){let e=n.findIndex(e=>e.path===a.parentDir);e>=0&&i(e,!1)}return;case`Enter`:case` `:if(e.preventDefault(),!a)return;a.type===`dir`?N(a.path):t?.(s,a.path);return;case`F2`:e.preventDefault(),a&&z(a.path);return;case`Delete`:e.preventDefault(),B(V());return;case`Backspace`:o&&(e.preventDefault(),B(V()));return}if(o&&(e.key===`c`||e.key===`C`)){e.preventDefault();let t=V();e.altKey?fe(t,e.shiftKey):L(t);return}if(o&&(e.key===`x`||e.key===`X`)){e.preventDefault(),oe(V());return}if(o&&(e.key===`v`||e.key===`V`)){e.preventDefault();let t=a?a.type===`dir`?a.path:a.parentDir:``;R(t);return}if(!o&&!e.altKey&&e.key.length===1&&/\S/.test(e.key)){let t=Date.now(),a=ge.current;a.buffer=t-a.at>700?e.key:a.buffer+e.key,a.at=t;let o=a.buffer.toLowerCase(),s=r+1;for(let e=0;e<n.length;e++){let t=n[(s+e)%n.length];if(t.name.toLowerCase().startsWith(o)){i(n.findIndex(e=>e.path===t.path),!1);break}}}},[S,M,v,m,P,N,t,s,z,B,V,L,oe,R,fe]),ve={sid:s,worktreePath:e.worktree_path,onOpenFile:t,onOpenTerminal:n,activePath:r,expanded:m,toggle:N,collapseAll:ie,statusMap:te,visibleRows:M,selection:g,focusedPath:v,onRowClick:F,onRowDoubleClick:I,selectOnly:ae,clipboard:b,cut:oe,copy:L,paste:R,editing:S,beginRename:z,beginCreate:se,cancelEdit:ce,commitEdit:le,requestDelete:B,copyPathToClipboard:fe,download:pe,refresh:me,onUpload:u,onDropUpload:p,dropTarget:w,setDropTarget:D,onInternalDrop:he,handleKeyDown:_e,pendingDelete:O,confirmDelete:ue,cancelDelete:de};return(0,K.jsx)(Ao.Provider,{value:ve,children:a})}var Po=`application/x-puddle-tab`;function Fo(e){return JSON.stringify(e)}function Io(e){try{return A.parse(JSON.parse(e))}catch{return null}}function Lo(e){return e.includes(Po)}var Ro=14;function zo(e,t){let n=document.createElement(`div`);n.textContent=`${t} items`,n.className=`fixed -top-12 left-0 rounded-md bg-elevated px-2 py-1 font-mono text-xs text-fg`,document.body.appendChild(n),e.dataTransfer.setDragImage(n,12,12),requestAnimationFrame(()=>n.remove())}function Bo({children:e}){return(0,K.jsx)(`span`,{className:`ml-auto pl-6 text-2xs text-fg-muted tabular-nums`,children:e})}function Vo({depth:e,initial:t,icon:n,onCommit:r,onCancel:i}){let a=(0,q.useRef)(null),o=(0,q.useRef)(!1);(0,q.useEffect)(()=>{let e=a.current;if(!e)return;let n=()=>{e.focus();let n=t.lastIndexOf(`.`);e.setSelectionRange(0,n>0?n:t.length)};n();let r=requestAnimationFrame(()=>{document.activeElement!==e&&n()});return()=>cancelAnimationFrame(r)},[t]);let s=()=>{o.current||(o.current=!0,r(a.current?.value??``))};return(0,K.jsxs)(`div`,{className:`flex h-6 items-center gap-1 pr-2`,style:{paddingLeft:e*Ro+8},children:[(0,K.jsx)(`span`,{className:`size-3.5 shrink-0`}),n,(0,K.jsx)(`input`,{ref:a,defaultValue:t,spellCheck:!1,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?s():e.key===`Escape`&&(o.current=!0,i())},onBlur:s,className:`min-w-0 flex-1 bg-surface font-mono text-sm text-fg outline-none`})]})}function Ho({path:e,entry:t,depth:n}){let r=jo(),i=t.type===`dir`,a=i&&r.expanded.has(e),o=i&&r.dropTarget===e,s=!i&&e===r.activePath,c=r.selection.has(e),l=r.clipboard?.mode===`cut`&&r.clipboard.paths.includes(e),u={path:e,name:t.name,type:t.type,depth:n,parentDir:oo(e)},d=r.statusMap.get(e),f=i?Eo(r.statusMap,e):null,p=d?Co(d):f?Co(f):null,m=p?p.colourClass:t.name.startsWith(`.`)?`text-fg-muted`:`text-fg`,h=c&&r.selection.size>1?[...r.selection]:[e],g=i?e:oo(e),_=r.clipboard!==null;return r.editing?.mode===`rename`&&r.editing.path===e?(0,K.jsx)(Vo,{depth:n,initial:t.name,icon:i?(0,K.jsx)(Cn,{className:`size-3.5 shrink-0 text-fg`}):(0,K.jsx)(io,{name:t.name}),onCommit:r.commitEdit,onCancel:r.cancelEdit}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(ft,{children:[(0,K.jsx)($e,{asChild:!0,children:(0,K.jsxs)(`div`,{role:`treeitem`,"data-path":e,"aria-expanded":i?a:void 0,"aria-selected":c,tabIndex:-1,draggable:!0,onClick:e=>{e.currentTarget.closest(`[data-explorer-root]`)?.focus(),r.onRowClick(u,e)},onDoubleClick:()=>r.onRowDoubleClick(u),onContextMenu:()=>{c||r.selectOnly(e)},onDragStart:t=>{let n=lo(h);t.dataTransfer.setData(uo,fo(n)),n.length>1&&zo(t,n.length),!i&&n.length===1&&t.dataTransfer.setData(Po,Fo({type:`editor`,tab:{kind:`file`,session:r.sid,path:e}})),t.dataTransfer.effectAllowed=`copyMove`},onDragOver:t=>{i&&(t.preventDefault(),t.stopPropagation(),r.setDropTarget(e))},onDragLeave:e=>{i&&e.currentTarget===e.target&&r.setDropTarget(null)},onDrop:t=>{if(!i)return;t.preventDefault(),t.stopPropagation(),r.setDropTarget(null);let n=po(t.dataTransfer.getData(uo));n.length>0?r.onInternalDrop(e,n):r.onDropUpload(e,t.dataTransfer.items,t.dataTransfer.files)},style:{paddingLeft:n*Ro+8},className:H(`flex h-6 cursor-pointer items-center gap-1 pr-2 text-sm transition-colors hover:bg-elevated`,c?`bg-selection`:s&&`bg-elevated`,o&&`bg-selection`,l&&`opacity-50`),children:[i?(0,K.jsx)(Tt,{className:H(`size-3.5 shrink-0 text-fg-gold transition-transform duration-150`,a&&`rotate-90`)}):(0,K.jsx)(`span`,{className:`size-3.5 shrink-0`}),t.symlink||t.type===`symlink`?(0,K.jsx)(Dn,{className:`size-3.5 shrink-0 text-fg`}):i?a?(0,K.jsx)(Ft,{className:H(`size-3.5 shrink-0`,f?p?.colourClass:`text-fg`)}):(0,K.jsx)(Cn,{className:H(`size-3.5 shrink-0`,f?p?.colourClass:`text-fg`)}):(0,K.jsx)(io,{name:t.name,dimmed:d===`ignored`}),(0,K.jsx)(`span`,{className:H(`min-w-0 flex-1 truncate font-mono`,m),children:t.name}),d&&p&&p.letter&&(0,K.jsx)(`span`,{className:H(`shrink-0 font-mono text-2xs`,p.colourClass),children:p.letter})]})}),(0,K.jsxs)(ct,{onCloseAutoFocus:e=>{r.editing&&e.preventDefault()},children:[i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(W,{onSelect:()=>r.beginCreate(e,`file`),children:`New File…`}),(0,K.jsx)(W,{onSelect:()=>r.beginCreate(e,`dir`),children:`New Folder…`}),r.onOpenTerminal&&(0,K.jsx)(W,{onSelect:()=>r.onOpenTerminal?.(e),children:`Open Terminal in Directory`}),(0,K.jsx)(it,{})]}),(0,K.jsxs)(W,{onSelect:()=>r.cut(h),children:[`Cut `,(0,K.jsx)(Bo,{children:`⌘X`})]}),(0,K.jsxs)(W,{onSelect:()=>r.copy(h),children:[`Copy `,(0,K.jsx)(Bo,{children:`⌘C`})]}),(0,K.jsxs)(W,{disabled:!_,onSelect:()=>r.paste(g),children:[`Paste `,(0,K.jsx)(Bo,{children:`⌘V`})]}),(0,K.jsx)(it,{}),(0,K.jsxs)(W,{onSelect:()=>r.copyPathToClipboard(h,!1),children:[`Copy Path `,(0,K.jsx)(Bo,{children:`⌥⌘C`})]}),(0,K.jsxs)(W,{onSelect:()=>r.copyPathToClipboard(h,!0),children:[`Copy Relative Path `,(0,K.jsx)(Bo,{children:`⌥⇧⌘C`})]}),(0,K.jsx)(it,{}),(0,K.jsxs)(W,{onSelect:()=>r.beginRename(e),children:[`Rename… `,(0,K.jsx)(Bo,{children:`F2`})]}),(0,K.jsxs)(W,{onSelect:()=>r.requestDelete(h),children:[`Delete `,(0,K.jsx)(Bo,{children:`⌘⌫`})]}),(0,K.jsx)(it,{}),(0,K.jsx)(W,{onSelect:()=>r.download(h),children:`Download`})]})]}),i&&a&&(0,K.jsx)(Uo,{sid:r.sid,path:e,depth:n+1})]})}function Uo({sid:e,path:t,depth:n}){let r=jo(),i=c(e,t),a={paddingLeft:n*Ro+8},o=r.editing,s=o?.mode===`create`&&o.parentDir===t?(0,K.jsx)(Wo,{depth:n,kind:o.kind}):null;if(i.isLoading)return(0,K.jsxs)(K.Fragment,{children:[s,(0,K.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:`Loading…`})]});if(i.isError)return(0,K.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Couldn't load this folder.`});let l=i.data?.entries??[];return l.length===0&&!s?(0,K.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:`Empty`}):(0,K.jsxs)(K.Fragment,{children:[s,l.map(e=>(0,K.jsx)(Ho,{path:co(t,e.name),entry:e,depth:n},e.name))]})}function Wo({depth:e,kind:t}){let n=jo(),[r,i]=(0,q.useState)(``);return(0,K.jsx)(Vo,{depth:e,initial:r,icon:t===`dir`?(0,K.jsx)(Cn,{className:`size-3.5 shrink-0 text-fg`}):(0,K.jsx)(io,{name:r||`file`}),onCommit:e=>{i(e),n.commitEdit(e)},onCancel:n.cancelEdit})}function Go(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ko,{}),(0,K.jsx)(qo,{})]})}function Ko(){let e=jo(),t=(0,q.useRef)(null);(0,q.useEffect)(()=>{!e.focusedPath||!t.current||t.current.querySelector(`[data-path="${CSS.escape(e.focusedPath)}"]`)?.scrollIntoView({block:`nearest`})},[e.focusedPath]);let n=e.clipboard!==null;return(0,K.jsxs)(ft,{children:[(0,K.jsx)($e,{asChild:!0,children:(0,K.jsx)(`div`,{ref:t,"data-explorer-root":!0,role:`tree`,tabIndex:0,onKeyDown:e.handleKeyDown,onPaste:t=>e.onDropUpload(``,t.clipboardData.items,t.clipboardData.files),onDragOver:t=>{t.preventDefault(),e.setDropTarget(``)},onDragLeave:t=>{t.currentTarget===t.target&&e.setDropTarget(null)},onDrop:t=>{t.preventDefault(),e.setDropTarget(null);let n=po(t.dataTransfer.getData(uo));n.length>0?e.onInternalDrop(``,n):e.onDropUpload(``,t.dataTransfer.items,t.dataTransfer.files)},className:H(`h-full overflow-y-auto py-1 outline-none`,e.dropTarget===``&&`bg-selection`),children:(0,K.jsx)(Uo,{sid:e.sid,path:``,depth:0})})}),(0,K.jsxs)(ct,{onCloseAutoFocus:t=>{e.editing&&t.preventDefault()},children:[(0,K.jsx)(W,{onSelect:()=>e.beginCreate(``,`file`),children:`New File…`}),(0,K.jsx)(W,{onSelect:()=>e.beginCreate(``,`dir`),children:`New Folder…`}),(0,K.jsx)(it,{}),(0,K.jsx)(W,{disabled:!n,onSelect:()=>e.paste(``),children:`Paste`}),(0,K.jsx)(it,{}),(0,K.jsx)(W,{onSelect:()=>e.copyPathToClipboard([``],!1),children:`Copy Path`}),(0,K.jsx)(W,{onSelect:()=>e.download([``]),children:`Download worktree`})]})]})}function qo(){let e=jo(),t=e.pendingDelete;return(0,K.jsx)(ce,{open:t!==null,onOpenChange:t=>!t&&e.cancelDelete(),children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsxs)(z,{children:[`Delete `,t&&t.length===1?`“${ao(t[0])}”`:`${t?.length??0} items`,`?`]}),(0,K.jsxs)(se,{children:[`This permanently removes `,t&&t.length>1?`them`:`it`,` from the worktree. There is no undo.`]})]}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{variant:`ghost`,onClick:e.cancelDelete,children:`Cancel`}),(0,K.jsx)(I,{variant:`danger`,onClick:e.confirmDelete,children:`Delete`})]})]})})}var Jo=/[.*+?^${}()|[\]\\]/g;function Yo(e){if(e.query.length===0)return null;try{let t=e.regex?e.query:e.query.replace(Jo,`\\$&`);return e.wholeWord&&(t=`\\b(?:${t})\\b`),new RegExp(t,e.caseSensitive?`g`:`gi`)}catch{return null}}function Xo(e,t){if(!t)return[{text:e,hit:!1}];let n=[],r=0;t.lastIndex=0;let i;for(;(i=t.exec(e))!==null;){if(i[0].length===0){t.lastIndex++;continue}i.index>r&&n.push({text:e.slice(r,i.index),hit:!1}),n.push({text:i[0],hit:!0}),r=i.index+i[0].length}return r<e.length&&n.push({text:e.slice(r),hit:!1}),n.length>0?n:[{text:e,hit:!1}]}var Zo=240;function Qo(e){let t=e.replace(/^\s+/,``);return t.length>Zo?`${t.slice(0,Zo)}…`:t}var $o=250;function es({active:e,label:t,onClick:n,children:r}){return(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:n,className:H(`rounded-sm p-1 transition-colors`,e?`bg-elevated text-accent`:`text-fg-muted hover:bg-elevated hover:text-fg`),children:[r,(0,K.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,K.jsx)(Gt,{children:t})]})}function ts({session:e,onOpen:t}){let[n,r]=(0,q.useState)(``),[i,a]=(0,q.useState)(``),[o,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let e=setTimeout(()=>a(n),$o);return()=>clearTimeout(e)},[n]);let p={query:i,regex:o,caseSensitive:l,wholeWord:d},m=s(e,p),h=(0,q.useMemo)(()=>Yo(p),[i,o,l,d]),g=m.data,_=!!g&&(g.files.length>0||g.content.length>0);return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 px-2 py-1.5`,children:[(0,K.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Search files and contents`,spellCheck:!1,autoComplete:`off`,className:`rounded-md bg-elevated px-2 py-1 font-mono text-xs text-fg outline-none placeholder:text-fg-muted`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(es,{active:l,label:`Match case`,onClick:()=>u(e=>!e),children:(0,K.jsx)(rn,{className:`size-3.5`})}),(0,K.jsx)(es,{active:d,label:`Match whole word`,onClick:()=>f(e=>!e),children:(0,K.jsx)(Bn,{className:`size-3.5`})}),(0,K.jsx)(es,{active:o,label:`Use regular expression`,onClick:()=>c(e=>!e),children:(0,K.jsx)(Fn,{className:`size-3.5`})})]})]}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:i.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Search file names and contents.`}):m.isPending?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Searching…`}):m.error?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:m.error instanceof Error?m.error.message:`Search failed`}):_?(0,K.jsxs)(K.Fragment,{children:[g.files.length>0&&(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`div`,{className:`px-3 pb-0.5 pt-1.5 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Files`}),g.files.map(e=>(0,K.jsxs)(`button`,{type:`button`,title:e,onClick:()=>t(e),className:`flex w-full items-center gap-1.5 px-3 py-1 text-left transition-colors hover:bg-elevated`,children:[(0,K.jsx)(Sn,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,K.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:e})]},e))]}),g.content.length>0&&(0,K.jsxs)(`section`,{children:[(0,K.jsx)(`div`,{className:`px-3 pb-0.5 pt-2 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Contents`}),g.content.map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`truncate px-3 py-1 font-mono text-2xs text-fg-secondary`,title:e.path,children:e.path}),e.matches.map((n,r)=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(e.path,n.line),className:`flex w-full items-baseline gap-2 py-0.5 pl-6 pr-3 text-left transition-colors hover:bg-elevated`,children:[(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-2xs tabular-nums text-fg-muted`,children:n.line}),(0,K.jsx)(`span`,{className:`truncate font-mono text-2xs text-fg-secondary`,children:Xo(Qo(n.text),h).map((e,t)=>e.hit?(0,K.jsx)(`span`,{className:`text-accent`,children:e.text},t):(0,K.jsx)(`span`,{children:e.text},t))})]},`${n.line}:${r}`))]},e.path))]}),g.truncated&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-2xs text-fg-muted`,children:`Showing the first results — refine the query for more.`})]}):(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No results.`})})]})}var ns=new Set([`starting`,`running`,`waiting_input`]),rs=`group-hover:[transform:translateX(var(--tail))]`;function is(e){return e.split(`/`).filter(Boolean).pop()??e}function as({children:e,className:t,title:n}){return(0,K.jsx)(`span`,{title:n,className:H(`shrink-0 text-2xs`,t),children:e})}function os({label:e,blockReason:t,onClick:n}){return(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,disabled:t!==null,onClick:n,className:H(`-my-1 rounded-sm p-1 text-fg-gold transition-colors hover:text-danger`,t===null?`hidden group-hover:inline-flex pointer-coarse:inline-flex`:`hidden`),children:[(0,K.jsx)(At,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:e})]})}),(0,K.jsx)(Gt,{children:t?`Can't ${e.toLowerCase()} — ${t}`:e})]})}function ss({repoId:e,projectId:t,sessions:n}){let r=be(e),i=he(e,t),a=de(e,t),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),u=i.isPending||a.isPending,d=(0,q.useMemo)(()=>{let e=new Map;for(let t of n)ns.has(t.status)&&e.set(t.worktree_path,(e.get(t.worktree_path)??0)+1);return e},[n]),f=(0,q.useMemo)(()=>{let e=new Map;for(let t of r.data?.worktrees??[]){let n=t.branch??`(detached)`;(e.get(n)??e.set(n,[]).get(n)).push(t)}return[...e.entries()].sort(([,e],[,t])=>!e.some(e=>e.is_primary)-+!t.some(e=>e.is_primary)||(e[0]?.branch??``).localeCompare(t[0]?.branch??``))},[r.data]),p=(0,q.useMemo)(()=>[...r.data?.orphan_branches??[]].sort((e,t)=>e.name.localeCompare(t.name)),[r.data]);return r.isPending?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading worktrees…`}):r.error?(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load worktrees`}):(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[f.length===0&&p.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktrees.`}),f.map(([e,t])=>(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`group flex items-center gap-1.5 px-3 pb-0.5 pt-2 text-2xs text-fg-muted`,children:[(0,K.jsx)(En,{className:`size-3 shrink-0 text-fg-gold`}),(0,K.jsx)(Ta,{text:e,className:`font-mono`,hoverClass:rs})]}),t.map(e=>{let t=d.get(e.path)??0,n=e.is_primary?`the repository clone`:e.dirty?`uncommitted changes`:t>0?`${t} running session${t>1?`s`:``}`:null;return(0,K.jsxs)(`div`,{className:`group flex items-center gap-2 px-3 py-1 pl-6 transition-colors hover:bg-elevated`,children:[(0,K.jsx)(Ta,{text:is(e.path),title:e.path,className:`font-mono text-xs text-fg`,hoverClass:rs}),e.is_primary&&(0,K.jsx)(as,{className:`text-fg-muted`,children:`clone`}),e.dirty&&(0,K.jsx)(as,{className:`text-warning`,title:`Modified — uncommitted changes`,children:`M`}),t>0&&(0,K.jsx)(as,{className:`text-running`,title:`${t} running session${t>1?`s`:``}`,children:t}),(0,K.jsx)(os,{label:`Prune`,blockReason:n,onClick:()=>{l(null),s({kind:`worktree`,path:e.path,branch:e.branch})}})]},e.path)})]},`wt:${e}`)),p.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`px-3 pb-0.5 pt-3 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Branches without a worktree`}),p.map(e=>(0,K.jsxs)(`div`,{className:`group flex items-center gap-2 px-3 py-1 transition-colors hover:bg-elevated`,children:[(0,K.jsx)(En,{className:`size-3 shrink-0 text-fg-gold`}),(0,K.jsx)(Ta,{text:e.name,className:`font-mono text-xs text-fg`,hoverClass:rs}),e.local_only&&(0,K.jsx)(as,{className:`text-warning`,children:`local only`}),(0,K.jsx)(os,{label:`Delete branch`,blockReason:null,onClick:()=>{l(null),s({kind:`branch`,name:e.name,localOnly:e.local_only})}})]},`br:${e.name}`))]}),(0,K.jsx)(ce,{open:o!==null,onOpenChange:e=>{e||s(null)},children:(0,K.jsxs)(R,{children:[o?.kind===`branch`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:`Delete branch`}),(0,K.jsxs)(se,{children:[`Delete branch `,(0,K.jsx)(`span`,{className:`font-mono`,children:o.name}),`? This removes the branch from the repository.`]})]}),o.localOnly&&(0,K.jsxs)(`p`,{className:`text-xs text-warning`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:o.name}),` has commits on no remote — deleting it discards that work permanently.`]})]}):(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:`Prune worktree`}),(0,K.jsxs)(se,{children:[`Remove `,(0,K.jsx)(`span`,{className:`font-mono`,children:o?is(o.path):``}),`? The working directory is deleted; the branch`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:o?.branch??``}),` is kept.`]})]}),c&&(0,K.jsx)(`p`,{className:`text-xs text-danger`,children:c}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{type:`button`,variant:`ghost`,onClick:()=>s(null),children:`Cancel`}),(0,K.jsx)(I,{type:`button`,variant:`danger`,disabled:u,onClick:()=>{if(!o)return;l(null);let e=e=>l(e.message),t=()=>s(null);o.kind===`worktree`?i.mutate(o.path,{onSuccess:t,onError:e}):a.mutate({name:o.name,confirm:!0},{onSuccess:t,onError:e})},children:o?.kind===`branch`?`Delete`:`Prune`})]})]})})]})}var cs=`DropdownMenu`,[ls,us]=N(cs,[Ye]),ds=Ye(),[fs,ps]=ls(cs),ms=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=ds(t),l=q.useRef(null),[u,d]=P({prop:i,defaultProp:a??!1,onChange:o,caller:cs});return(0,K.jsx)(fs,{scope:t,triggerId:F(),triggerRef:l,contentId:F(),open:u,onOpenChange:d,onOpenToggle:q.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,K.jsx)(Qe,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};ms.displayName=cs;var hs=`DropdownMenuTrigger`,gs=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ps(hs,n),o=ds(n),s=M(t,a.triggerRef);return(0,K.jsx)(ot,{asChild:!0,...o,children:(0,K.jsx)(le.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:L(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:L(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});gs.displayName=hs;var _s=`DropdownMenuPortal`,vs=e=>{let{__scopeDropdownMenu:t,...n}=e,r=ds(t);return(0,K.jsx)(Xe,{...r,...n})};vs.displayName=_s;var ys=`DropdownMenuContent`,bs=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ps(ys,n),a=ds(n),o=q.useRef(!1);return(0,K.jsx)(tt,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:L(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:L(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});bs.displayName=ys;var xs=`DropdownMenuGroup`,Ss=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(ut,{...i,...r,ref:t})});Ss.displayName=xs;var Cs=`DropdownMenuLabel`,ws=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(nt,{...i,...r,ref:t})});ws.displayName=Cs;var Ts=`DropdownMenuItem`,Es=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(st,{...i,...r,ref:t})});Es.displayName=Ts;var Ds=`DropdownMenuCheckboxItem`,Os=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(et,{...i,...r,ref:t})});Os.displayName=Ds;var ks=`DropdownMenuRadioGroup`,As=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(mt,{...i,...r,ref:t})});As.displayName=ks;var js=`DropdownMenuRadioItem`,Ms=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(_t,{...i,...r,ref:t})});Ms.displayName=js;var Ns=`DropdownMenuItemIndicator`,Ps=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(rt,{...i,...r,ref:t})});Ps.displayName=Ns;var Fs=`DropdownMenuSeparator`,Is=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(gt,{...i,...r,ref:t})});Is.displayName=Fs;var Ls=`DropdownMenuArrow`,Rs=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(pt,{...i,...r,ref:t})});Rs.displayName=Ls;var zs=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=ds(t),[s,c]=P({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,K.jsx)(Je,{...o,open:s,onOpenChange:c,children:n})},Bs=`DropdownMenuSubTrigger`,Vs=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(ht,{...i,...r,ref:t})});Vs.displayName=Bs;var Hs=`DropdownMenuSubContent`,Us=q.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ds(n);return(0,K.jsx)(We,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Us.displayName=Hs;var Ws=ms,Gs=gs,Ks=vs,qs=bs,Js=Es,Ys=Is,Xs=zs,Zs=Vs,Qs=Us,$s=Ws,ec=Gs,tc=Xs;function nc({className:e,sideOffset:t=4,...n}){return(0,K.jsx)(Ks,{children:(0,K.jsx)(qs,{sideOffset:t,className:H(`z-50 min-w-36 overflow-hidden rounded-md bg-elevated p-1 shadow-xl`,e),...n})})}function rc({className:e,...t}){return(0,K.jsx)(Js,{className:H(Me,Ce,`[&_svg]:size-3.5`,e),...t})}function ic({className:e,children:t,...n}){return(0,K.jsxs)(Zs,{className:H(Me,Ce,`data-[state=open]:bg-action data-[state=open]:text-action-ink [&_svg]:size-3.5`,e),...n,children:[t,(0,K.jsx)(Tt,{className:`ml-auto`})]})}function ac({className:e,...t}){return(0,K.jsx)(Ks,{children:(0,K.jsx)(Qs,{className:H(`z-50 min-w-36 overflow-hidden rounded-md bg-elevated p-1 shadow-xl`,e),...t})})}function oc({className:e,...t}){return(0,K.jsx)(Ys,{className:H(`-mx-1 my-1 h-px bg-border`,e),...t})}function sc({text:e,className:t}){let n=(0,q.useRef)(null);return(0,q.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{e.scrollLeft=e.scrollWidth};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[e]),(0,K.jsx)(`div`,{ref:n,className:`no-scrollbar min-w-0 flex-1 overflow-x-auto`,children:(0,K.jsx)(`span`,{className:H(`inline-block whitespace-nowrap`,t),children:e})})}function cc({sessions:e,target:t,showFileActions:n=!1,showPath:r=!1}){let{session:i,pinned:a,pin:o,unpin:s}=t,c=V().data?.home,l=e.filter(e=>e.status!==`archived`),u=i?i.branch||Lt(i):`No worktree`,d=i?kt(i.worktree_path,c):`No worktree`;return(0,K.jsxs)(`div`,{className:`group relative flex h-8 shrink-0 items-center px-2`,children:[(0,K.jsx)(sc,{text:r?d:u,className:`font-mono text-xs text-fg-secondary`}),(0,K.jsxs)(`div`,{className:H(`absolute inset-y-0 right-1 flex items-center gap-1 bg-surface pl-2 opacity-0 transition-opacity`,`pointer-events-none focus-within:pointer-events-auto focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`,a&&`pointer-events-auto opacity-100`),children:[n&&i&&(0,K.jsx)(uc,{}),(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":a,disabled:!i,title:a?`Unpin — follow the active session`:`Pin the sidebar to this worktree`,onClick:()=>a?s():i&&o(i.id),className:H(`shrink-0 rounded-sm p-1 transition-colors disabled:pointer-events-none disabled:opacity-40`,a?`text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(Nn,{className:H(`size-3.5`,a&&`fill-current`)}),(0,K.jsx)(`span`,{className:`sr-only`,children:a?`Unpin sidebar`:`Pin sidebar`})]}),(0,K.jsxs)($s,{children:[(0,K.jsx)(ec,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,title:`Bind a different worktree`,className:`shrink-0 rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(Ct,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose a worktree`})]})}),(0,K.jsx)(nc,{align:`end`,children:l.length===0?(0,K.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-fg-muted`,children:`No sessions yet`}):l.map(e=>(0,K.jsx)(rc,{onSelect:()=>o(e.id),children:(0,K.jsxs)(`span`,{className:`truncate font-mono`,children:[e.branch,` — `,Lt(e)]})},e.id))})]})]})]})}var lc=[{key:`refresh`,label:`Refresh`,icon:Mt},{key:`collapse`,label:`Collapse Folders`,icon:an}];function uc(){let e=Mo();if(!e)return null;let t=t=>{t===`refresh`?e.refresh():t===`collapse`&&e.collapseAll()};return(0,K.jsx)(`div`,{className:`hidden shrink-0 items-center gap-0.5 group-hover:flex group-focus-within:flex`,children:lc.map(({key:e,label:n,icon:r})=>(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(r,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:n})]})}),(0,K.jsx)(Gt,{children:n})]},e))})}var dc=[{key:`files`,label:`Files`,icon:wn},{key:`search`,label:`Search`,icon:qt},{key:`changes`,label:`Changes`,icon:En},{key:`worktrees`,label:`Worktrees`,icon:Ie}];function fc(e){return e===`diff`||e===`history`||e===`changes`?`changes`:e===`search`?`search`:e===`worktrees`?`worktrees`:`files`}function pc({mode:e,onExpand:t,onSelect:n}){return(0,K.jsxs)(`div`,{className:`flex h-full w-9 shrink-0 flex-col items-center gap-1 bg-surface py-1.5`,children:[(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center rounded-md p-1.5 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(An,{className:`size-4`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Show sidebar`})]})}),(0,K.jsx)(Gt,{side:`right`,children:`Show sidebar`})]}),dc.map(({key:t,label:r,icon:i})=>(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"aria-current":e===t?`page`:void 0,onClick:()=>n(t),className:H(`flex items-center rounded-md p-1.5 transition-colors`,e===t?`bg-elevated text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(i,{className:`size-4`}),(0,K.jsx)(`span`,{className:`sr-only`,children:r})]})}),(0,K.jsx)(Gt,{side:`right`,children:r})]},t))]})}function mc({mode:e,onModeChange:t,onCollapse:n,projectId:r,repoId:i,sessions:a,target:o,onOpenFile:s,onOpenExternalFile:c,onOpenTerminalIn:l,activeFilePath:u,activeDiffPath:d,onOpenDiff:f,onOpenCommitFile:p,onOpenSearchFile:m}){let{session:h}=o,[g,_]=(0,q.useState)(null),v=He().data?.protocol,y=!v||v.major>10||v.major===10&&v.minor>=2,b=y&&g!==null&&g.forSession===h?.id?g.root:null,x=e=>{h&&(o.pinned||o.pin(h.id),_({forSession:h.id,root:e}))},S={...o,unpin(){_(null),o.unpin()}};return(0,K.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5`,children:[dc.map(({key:n,label:r,icon:i})=>(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"aria-current":e===n?`page`:void 0,onClick:()=>t(n),className:H(`flex items-center rounded-md p-1.5 transition-colors`,e===n?`bg-elevated text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(i,{className:`size-4`}),(0,K.jsx)(`span`,{className:`sr-only`,children:r})]})}),(0,K.jsx)(Gt,{children:r})]},n)),(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,onClick:n,className:`ml-auto flex items-center rounded-md p-1.5 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(kn,{className:`size-4`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Hide sidebar`})]})}),(0,K.jsx)(Gt,{children:`Hide sidebar`})]})]}),e!==`worktrees`&&e!==`files`&&(0,K.jsx)(cc,{sessions:a,target:S,showPath:e===`search`}),e===`worktrees`&&(0,K.jsx)(ss,{repoId:i,projectId:r,sessions:a}),e===`files`&&(h&&b!==null?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cc,{sessions:a,target:S,showPath:!0}),(0,K.jsx)(go,{sid:h.id,root:b,onNavigateUp:()=>x(so(b)),onReset:()=>_(null),onOpenFile:(e,t)=>c(h.id,e,b,t)})]}):h?(0,K.jsxs)(No,{session:h,onOpenFile:s,onOpenTerminal:e=>l(h.id,e),activePath:u,children:[(0,K.jsx)(cc,{sessions:a,target:S,showFileActions:!0,showPath:!0}),y&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>x(so(h.worktree_path)),title:`Browse the parent directory`,className:`flex shrink-0 items-center gap-1.5 px-3 py-1 text-left transition-colors hover:bg-elevated`,children:[(0,K.jsx)(Et,{className:`size-3 shrink-0 text-fg-gold`}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:`..`})]}),(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,K.jsx)(Go,{})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(cc,{sessions:a,target:S}),(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to show.`})]})),e===`changes`&&(h?(0,K.jsx)(eo,{session:h.id,activeDiffPath:d,onOpenDiff:f,onOpenCommitFile:p},h.id):(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to show.`})),e===`search`&&(h?(0,K.jsx)(ts,{session:h.id,onOpen:m},h.id):(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to search.`}))]})}function hc({projectId:e,repoId:t,open:n,kind:r=`agent`,seedAccountId:i,onOpenChange:o,onCreated:s}){let c=r===`terminal`,l=a(),u=Te(l??void 0),d=pe(l??void 0),f=ye(),p=V(),m=ue(),[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(``),[y,b]=(0,q.useState)(!0),[x,S]=(0,q.useState)(!0),[C,w]=(0,q.useState)(``),[T,E]=(0,q.useState)(``),[D,O]=(0,q.useState)(!1),[k,ee]=(0,q.useState)(null),A=f.data?.find(e=>e.id===t),j=me(n?t:void 0),te=be(n?t:void 0),ne=u.data?.find(e=>String(e.id)===h),re=d.data?.allowSkipPermissions===!0,M=!c&&re&&ne?.skip_permissions_default===!0,N=_.trim()||A?.default_base_branch||``,P=(0,q.useMemo)(()=>(te.data?.worktrees??[]).filter(e=>e.branch===N).map(e=>({path:e.path,is_primary:e.is_primary,label:e.is_primary?`${e.path.split(`/`).filter(Boolean).pop()??e.path} (clone)`:e.path.split(`/`).filter(Boolean).pop()??e.path})),[te.data,N]),F=!y&&!x,ae=P.find(e=>e.is_primary)?.path??P[0]?.path??``,L=T||ae,le=(0,q.useMemo)(()=>{let e=d.data?.default_account_id;return u.data?.find(e=>e.id===i)??u.data?.find(t=>typeof e==`number`&&t.id===e)??u.data?.[0]},[u.data,d.data,i]),B=h||(le?String(le.id):``);(0,q.useEffect)(()=>{n&&i!==void 0&&g(String(i))},[n,i]);let de=(0,q.useRef)(d.data);de.current=d.data,(0,q.useEffect)(()=>{if(n){let e=wt(c?`terminal`:`agent`,de.current);v(e.baseBranch),b(e.separateBranch),S(e.separateWorktree),E(``)}},[n,c]);let fe=()=>{ee(null),m.mutate({project_id:e,...c?{kind:`terminal`}:{account_id:Number(B)},..._.trim()?{base_branch:_.trim()}:{},separate_branch:y,...y&&C.trim()?{branch:C.trim()}:{},...y?{}:{separate_worktree:x},...F&&L?{join_worktree:L}:{},...M&&D?{skip_permissions:!0}:{}},{onSuccess:e=>{o(!1),w(``),O(!1),s(e)},onError:e=>ee(e.message)})},he=c?`a shell`:`an agent`,ge=y?`on a new branch off ${N||`…`}, in its own directory`:F?`on ${N||`…`}, sharing an existing directory`:`on ${N||`…`}, in its own directory`;return(0,K.jsx)(ce,{open:n,onOpenChange:o,children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:c?`New terminal`:`New agent`}),(0,K.jsxs)(se,{children:[c?`Opens`:`Spawns`,` `,he,` `,ge,`.`]})]}),(0,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),(c||B)&&fe()},children:[!c&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(ze,{children:`Account`}),u.data?.length===0?(0,K.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No accounts yet —`,` `,(0,K.jsx)(`button`,{type:`button`,className:`text-accent underline`,onClick:()=>It(`accounts`),children:`add one in settings`}),`.`]}):(0,K.jsxs)(bt,{value:B,onValueChange:g,children:[(0,K.jsx)(vt,{children:(0,K.jsx)(xt,{placeholder:`pick an account`})}),(0,K.jsx)(St,{children:u.data?.map(e=>(0,K.jsxs)(yt,{value:String(e.id),children:[(0,K.jsxs)(`span`,{className:`font-mono`,children:[e.agent_type,`/`,e.label]}),!e.logged_in&&(0,K.jsx)(`span`,{className:`ml-2 text-2xs text-warning`,children:`not logged in`})]},e.id))})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,K.jsx)(ze,{htmlFor:`base-branch`,children:`Base branch`}),(0,K.jsx)(Oe,{id:`base-branch`,placeholder:A?.default_base_branch??`main`,value:_,onValueChange:v,hints:(j.data?.branches??[]).filter(e=>e.name.toLowerCase().includes(_.trim().toLowerCase())).slice(0,20).map(e=>({value:e.name,badge:e.name===A?.default_base_branch?`default`:e.is_session?`session: ${e.session_title??`untitled`}`:void 0})),className:`font-mono`,hintsClassName:`w-max min-w-full max-w-[36rem]`})]}),y&&(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,K.jsx)(ze,{htmlFor:`session-branch`,children:`New branch`}),(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`optional`})]}),(0,K.jsx)(ke,{id:`session-branch`,placeholder:`leave blank for auto`,value:C,onChange:e=>w(e.target.value),className:`font-mono`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(zt,{id:`separate-branch`,checked:y,onCheckedChange:e=>{b(e),e&&S(!0)}}),(0,K.jsx)(ze,{htmlFor:`separate-branch`,children:`Use separate branch`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(zt,{id:`separate-worktree`,checked:y?!0:x,disabled:y,onCheckedChange:S}),(0,K.jsx)(ze,{htmlFor:`separate-worktree`,className:H(y&&`text-fg-muted`),children:`Use separate directory`})]})]}),F&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(ze,{htmlFor:`join-dir`,children:`Directory to join`}),P.length===0?(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`No existing directory on `,(0,K.jsx)(`span`,{className:`font-mono`,children:N||`…`}),` — a shared one will be created for later sessions to join.`]}):(0,K.jsxs)(bt,{value:L,onValueChange:E,children:[(0,K.jsx)(vt,{id:`join-dir`,children:(0,K.jsx)(xt,{})}),(0,K.jsx)(St,{children:P.map(e=>(0,K.jsx)(yt,{value:e.path,title:e.path,detail:(0,K.jsx)(`span`,{className:`ml-auto min-w-0 truncate font-mono text-2xs text-fg-muted`,children:kt(e.path,p.data?.home)}),children:e.label},e.path))})]})]}),!y&&!c&&(0,K.jsxs)(`p`,{className:`text-xs text-warning`,children:[`The `,c?`shell`:`agent`,` commits straight to`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:N||`…`}),F?` and shares its working directory with concurrent sessions — they can trample each other’s edits.`:`.`]}),M&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-surface px-3 py-2`,children:[(0,K.jsx)(zt,{id:`skip-permissions`,checked:D,onCheckedChange:O}),(0,K.jsx)(ze,{htmlFor:`skip-permissions`,className:`text-warning`,children:`Skip permission prompts for this session`})]}),k&&(0,K.jsx)(`p`,{className:`text-xs text-danger`,children:k}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{type:`button`,variant:`ghost`,onClick:()=>o(!1),children:`Cancel`}),(0,K.jsx)(I,{type:`submit`,disabled:!c&&!B||m.isPending,children:c?`Open terminal`:`Start agent`})]})]})]})})}function gc({status:e,kind:t=`agent`,agentType:n,stale:r=!1,className:i}){let a=`${t===`terminal`?`terminal`:n??`agent`} — status: ${e.replace(`_`,` `)}${r?` (no agent activity for over an hour — possibly stalled)`:``}`;return(0,K.jsx)(`span`,{className:H(`status-glyph`,i),"data-status":e,"data-kind":t,"data-stale":r||void 0,role:`img`,title:r?`No agent activity for over an hour — possibly stalled`:void 0,"aria-label":a,children:t===`terminal`?(0,K.jsx)(Nt,{className:`size-3`}):(0,K.jsx)(Yt,{type:n??``,className:`size-3`})})}function _c({status:e,kind:t=`agent`,stale:n=!1,className:r}){let i=`${t===`terminal`?`terminal `:``}status: ${e.replace(`_`,` `)}${n?` (no agent activity for over an hour — possibly stalled)`:``}`;return(0,K.jsx)(`span`,{className:H(`status-dot`,r),"data-status":e,"data-kind":t,"data-stale":n||void 0,role:`img`,title:n?`No agent activity for over an hour — possibly stalled`:void 0,"aria-label":i})}var vc=[`starting`,`running`,`waiting_input`],yc=[`exited`,`interrupted`],bc={Item:rc,Separator:oc,Sub:tc,SubTrigger:ic,SubContent:ac},xc={Item:W,Separator:it,Sub:Ze,SubTrigger:dt,SubContent:lt};function Sc(e,t){let n=_e(`resume`),r=_e(`kill`),i=De(),o=Fe(),s=Le(),c=ge(),l=Ae(),u=Ee(),d=ue(),f=Ht(),p=a(),m=Te(p??void 0),h=pe(p??void 0),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(e.title??``),[S,C]=(0,q.useState)(null),[w,T]=(0,q.useState)(null),E=(m.data??[]).filter(t=>t.agent_type===e.agent_type),D=!e.worktree_missing&&e.status!==`archived`&&E.some(t=>t.id!==e.account_id),O=(m.data??[]).filter(t=>t.agent_type!==e.agent_type&&t.logged_in),ee=h.data?.default_account_id,A=typeof ee==`number`?ee:null,j=(m.data??[]).filter(e=>e.logged_in),te=A===null?j:[...j.filter(e=>e.id===A),...j.filter(e=>e.id!==A)];return{menu:{session:e,resumable:yc.includes(e.status),live:vc.includes(e.status),archived:e.status===`archived`,canMigrate:D,sameAgent:E,handoffTargets:!e.worktree_missing&&e.status!==`archived`?O:[],setHandoffTo:T,resume:()=>n.mutate(e.id,{onError:e=>Re(e)}),kill:()=>r.mutate(e.id,{onError:e=>Re(e)}),openClearEnv:()=>_(`clear-env`),openTerminal:()=>d.mutate({project_id:e.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void f(`/project/${e.project_id}/session/${e.id}`),onError:e=>Re(e)}),spawnAccounts:te,defaultAccountId:A,spawnAgent:t=>d.mutate({project_id:e.project_id,account_id:t,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void f(`/project/${e.project_id}/session/${e.id}`),onError:e=>Re(e)}),openRename:()=>{x(e.title??``),y(!0)},archive:()=>i.mutate(e.id,{onSuccess:()=>t?.(e.id),onError:e=>Re(e)}),unarchive:()=>o.mutate(e.id,{onError:e=>Re(e)}),setMigrateTo:C},dialogs:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ce,{open:g===`clear-env`,onOpenChange:e=>{e||_(null)},children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:`Clear captured environment?`}),(0,K.jsx)(se,{children:`Variables exported in this session’s terminals will no longer be injected into new shells or agent restarts.`})]}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{variant:`ghost`,onClick:()=>_(null),children:`Cancel`}),(0,K.jsx)(I,{variant:`danger`,disabled:u.isPending,onClick:()=>u.mutate(e.id,{onSuccess:e=>{_(null),k.success(e.cleared===0?`Nothing was captured`:`Cleared ${e.cleared} captured var${e.cleared===1?``:`s`}`)},onError:e=>{_(null),Re(e)}}),children:`Clear captured env`})]})]})}),(0,K.jsx)(ce,{open:v,onOpenChange:y,children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:`Rename session`}),(0,K.jsx)(se,{children:`Leave it empty to use the agent’s own session name.`})]}),(0,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:t=>{t.preventDefault(),s.mutate({sessionId:e.id,title:b.trim()},{onSuccess:()=>y(!1),onError:e=>Re(e)})},children:[(0,K.jsx)(ke,{value:b,onChange:e=>x(e.target.value),placeholder:e.agent_title??e.osc_title??e.id.slice(0,8),autoFocus:!0}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{type:`button`,variant:`ghost`,onClick:()=>y(!1),children:`Cancel`}),(0,K.jsx)(I,{type:`submit`,disabled:s.isPending,children:`Rename`})]})]})]})}),(0,K.jsx)(ce,{open:S!==null,onOpenChange:e=>!e&&C(null),children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsxs)(z,{children:[`Move this session to `,S?.label,`?`]}),(0,K.jsx)(se,{children:`The conversation continues under that account’s credentials. If the session is running it is stopped first, then resumed on the new account.`})]}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{variant:`ghost`,onClick:()=>C(null),children:`Cancel`}),(0,K.jsx)(I,{disabled:c.isPending,onClick:()=>{S&&c.mutate({sessionId:e.id,accountId:S.id},{onSuccess:()=>{C(null),k.success(`Moved to ${S.label}`)},onError:e=>{C(null),Re(e)}})},children:`Move session`})]})]})}),(0,K.jsx)(ce,{open:w!==null,onOpenChange:e=>!e&&T(null),children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsxs)(z,{children:[`Hand off to `,w?.agent_type,`?`]}),(0,K.jsxs)(se,{children:[`A new session starts in this worktree and branch on`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:w?.label}),`, opening with a summary of the conversation so far plus the branch’s commits and status. The conversation itself is summarised, not moved — the new agent will not have the old one’s reasoning. This session is left as it is.`]})]}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{variant:`ghost`,onClick:()=>T(null),children:`Cancel`}),(0,K.jsx)(I,{disabled:l.isPending,onClick:()=>{w&&l.mutate({sessionId:e.id,accountId:w.id},{onSuccess:e=>{T(null),k.success(`Handed off to ${w.agent_type}`),f(`/session/${e.id}`)},onError:e=>{T(null),Re(e)}})},children:`Hand off`})]})]})})]})}}function Cc({kit:e,menu:t}){let{Item:n,Separator:r,Sub:i,SubTrigger:a,SubContent:o}=e,{session:s}=t;return(0,K.jsxs)(K.Fragment,{children:[t.resumable&&!s.worktree_missing&&(0,K.jsxs)(n,{onSelect:t.resume,children:[(0,K.jsx)(Pn,{}),` Resume`]}),t.live&&(0,K.jsxs)(n,{onSelect:t.kill,children:[(0,K.jsx)(Ln,{}),` Kill`]}),(0,K.jsxs)(n,{onSelect:t.openRename,children:[(0,K.jsx)(xe,{}),` Rename`]}),!t.archived&&(0,K.jsxs)(n,{onSelect:t.openClearEnv,children:[(0,K.jsx)(sn,{}),` Clear captured env`]}),t.canMigrate&&(0,K.jsxs)(i,{children:[(0,K.jsxs)(a,{children:[(0,K.jsx)(zn,{}),` Move to account…`]}),(0,K.jsx)(o,{children:t.sameAgent.map(e=>{let r=e.id===s.account_id;return(0,K.jsxs)(n,{disabled:r,onSelect:()=>t.setMigrateTo(e),children:[e.label,r&&(0,K.jsx)(`span`,{className:`ml-auto text-fg-muted`,children:`current`})]},e.id)})})]}),t.handoffTargets.length>0&&(0,K.jsxs)(i,{children:[(0,K.jsxs)(a,{children:[(0,K.jsx)(nn,{}),` Hand off to agent…`]}),(0,K.jsx)(o,{children:t.handoffTargets.map(e=>(0,K.jsxs)(n,{onSelect:()=>t.setHandoffTo(e),children:[(0,K.jsx)(Yt,{type:e.agent_type,className:`size-4`}),e.agent_type,(0,K.jsx)(`span`,{className:`ml-auto font-mono text-fg-muted`,children:e.label})]},e.id))})]}),!s.worktree_missing&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(r,{}),(0,K.jsxs)(n,{onSelect:t.openTerminal,children:[(0,K.jsx)(Nt,{}),` Open terminal in worktree`]}),t.spawnAccounts.length>0&&(0,K.jsxs)(i,{children:[(0,K.jsxs)(a,{children:[(0,K.jsx)(Vt,{}),` Spawn agent in worktree`]}),(0,K.jsx)(o,{children:t.spawnAccounts.map(e=>(0,K.jsxs)(n,{onSelect:()=>t.spawnAgent(e.id),children:[(0,K.jsx)(Yt,{type:e.agent_type,className:`size-4 shrink-0`}),e.agent_type,`/`,e.label,e.id===t.defaultAccountId&&(0,K.jsx)(`span`,{className:`ml-auto pl-3 text-fg-muted`,children:`default`})]},e.id))})]}),(0,K.jsxs)(n,{onSelect:()=>{window.location.href=Xt(`vscode`,s.worktree_path,Wt())},children:[(0,K.jsx)(cn,{}),` Open in VS Code`]}),(0,K.jsxs)(n,{onSelect:()=>{window.location.href=Xt(`cursor`,s.worktree_path,Wt())},children:[(0,K.jsx)(cn,{}),` Open in Cursor`]})]}),!t.archived&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(r,{}),(0,K.jsxs)(n,{onSelect:t.archive,children:[(0,K.jsx)(Ue,{}),` Archive`]})]}),t.archived&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(r,{}),(0,K.jsxs)(n,{onSelect:t.unarchive,children:[(0,K.jsx)(at,{}),` Unarchive`]})]})]})}function wc({menu:e}){return(0,K.jsxs)($s,{children:[(0,K.jsx)(ec,{asChild:!0,children:(0,K.jsxs)(I,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:e=>e.preventDefault(),children:[(0,K.jsx)(on,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Session actions`})]})}),(0,K.jsx)(nc,{align:`end`,children:(0,K.jsx)(Cc,{kit:bc,menu:e})})]})}function Tc({session:e,onArchived:t,children:n}){let{menu:r,dialogs:i}=Sc(e,t);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(ft,{children:[(0,K.jsx)($e,{asChild:!0,children:typeof n==`function`?n(r):n}),(0,K.jsx)(ct,{children:(0,K.jsx)(Cc,{kit:xc,menu:r})})]}),i]})}function Ec({menu:e}){return(0,K.jsx)(ct,{children:(0,K.jsx)(Cc,{kit:xc,menu:e})})}function Dc({icon:e,label:t,onClick:n,active:r=!1,tooltipSide:i}){return(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":r,className:H(`flex items-center rounded-md p-1.5 transition-colors`,r?`bg-elevated text-fg`:`text-fg-gold hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(e,{className:`size-4`}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,K.jsx)(Gt,{side:i,children:t})]})}function Oc({session:e,accountLabel:t}){return(0,K.jsxs)(`span`,{className:`flex flex-col`,children:[(0,K.jsx)(`span`,{children:Ot()(e)}),(0,K.jsx)(`span`,{className:`font-mono text-2xs text-fg-muted`,children:e.branch}),(0,K.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1 font-mono text-2xs text-fg-muted`,children:e.kind===`terminal`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Nt,{className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{children:`terminal`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Yt,{type:e.agent_type??``,className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{children:e.agent_type}),t&&(0,K.jsxs)(`span`,{children:[` · `,t]})]})})]})}function kc({session:e,accountLabel:t,activeSessionId:n,onPromote:r,onArchived:i}){let{menu:a,dialogs:o}=Sc(e,i),s=Ot();return(0,K.jsxs)(ft,{children:[(0,K.jsxs)(Zt,{children:[(0,K.jsx)($e,{asChild:!0,children:(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsxs)(Bt,{draggable:!1,"aria-current":e.id===n?`true`:void 0,onDoubleClick:()=>r(e.id),to:`/project/${e.project_id}/session/${e.id}`,className:H(`flex items-center rounded-md p-1.5 transition-colors hover:bg-elevated`,e.id===n&&`bg-elevated`),children:[(0,K.jsx)(_c,{status:e.status,kind:e.kind,stale:e.stale_running}),(0,K.jsx)(`span`,{className:`sr-only`,children:s(e)})]})})}),(0,K.jsx)(Gt,{side:`left`,children:(0,K.jsx)(Oc,{session:e,accountLabel:t})})]}),(0,K.jsx)(Ec,{menu:a}),o]})}function Ac({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,onExpand:a,onNewTerminal:o,onNewSession:s,onArchived:c}){let[l,u]=(0,q.useState)(null),d=new Map(t.map(e=>[e.id,e.label])),f=e.filter(e=>e.sessions.length>0),p=(e,t)=>{let n=Ge(f,e,t);n&&r(n)};return(0,K.jsxs)(`div`,{className:`flex h-full w-9 shrink-0 flex-col items-center bg-surface py-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,K.jsx)(Dc,{icon:Mn,label:`Show sessions`,onClick:a,tooltipSide:`left`}),(0,K.jsx)(Dc,{icon:Vt,label:`New agent`,onClick:s,tooltipSide:`left`}),(0,K.jsx)(Dc,{icon:Nt,label:`New terminal`,onClick:o,tooltipSide:`left`})]}),(0,K.jsx)(`div`,{className:`no-scrollbar flex min-h-0 flex-1 flex-col items-center gap-1 overflow-y-auto`,children:f.map(e=>(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,K.jsx)(`div`,{className:`my-0.5 h-px w-5 shrink-0 bg-border`}),e.sessions.map(e=>(0,K.jsx)(`div`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(Po,Fo({type:`terminal`,session:e.id})),u(e.id)},onDragEnd:()=>u(null),onDragOver:t=>{t.preventDefault(),l&&l!==e.id&&p(l,e.id)},className:H(`transition-opacity`,l===e.id&&`opacity-50`),children:(0,K.jsx)(kc,{session:e,accountLabel:e.account_id===null?void 0:d.get(e.account_id),activeSessionId:n,onPromote:i,onArchived:c})},e.id))]},e.projectId))})]})}function jc({session:e,activeSessionId:t,accountLabel:n,onPromote:r,onArchived:i,ellipsis:a}){let o=Ot();return(0,K.jsx)(Tc,{session:e,onArchived:i,children:i=>(0,K.jsxs)(Bt,{draggable:!1,onDoubleClick:r&&(()=>r(e.id)),to:`/project/${e.project_id}/session/${e.id}`,className:H(`group flex items-center gap-2 px-3 py-1.5 transition-colors hover:bg-elevated`,e.id===t&&`bg-elevated`),children:[(0,K.jsx)(gc,{status:e.status,kind:e.kind,agentType:e.agent_type,stale:e.stale_running}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate font-sans text-xs text-fg`,children:o(e)}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 truncate font-mono text-2xs text-fg-muted`,children:[(0,K.jsx)(En,{className:`size-3 shrink-0 text-fg-gold`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.branch})]}),e.account_id!==null&&n.has(e.account_id)&&(0,K.jsx)(`span`,{className:`flex items-center gap-1 truncate font-mono text-2xs text-fg-muted`,children:(0,K.jsx)(`span`,{className:`truncate`,children:n.get(e.account_id)})})]}),e.skip_permissions&&(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsx)(In,{className:`size-3.5 shrink-0 text-warning`})}),(0,K.jsx)(Gt,{children:`Running with permission prompts skipped`})]}),e.worktree_missing&&(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsx)(Tn,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,K.jsx)(Gt,{children:`Worktree directory is gone — archive only`})]}),a&&(0,K.jsx)(`span`,{className:`hidden group-hover:inline-flex has-[[data-state=open]]:inline-flex pointer-coarse:inline-flex`,children:(0,K.jsx)(wc,{menu:i})})]})})}function Mc({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onNewSession:o,onNewTerminal:s,onCollapse:c,onArchived:l}){return(0,K.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 px-2 py-1.5`,children:[(0,K.jsx)(Dc,{icon:jn,label:`Hide sessions`,onClick:c}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,K.jsx)(Dc,{icon:Vt,label:`New agent`,onClick:o}),(0,K.jsx)(Dc,{icon:Nt,label:`New terminal`,onClick:s})]})]}),(0,K.jsx)(Nc,{groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:l})]})}function Nc({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:o}){let[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(!1),d=new Map(t.map(e=>[e.id,e.label])),f=e.filter(e=>e.sessions.length>0),p=f.reduce((e,t)=>e+t.sessions.length,0),m=(e,t)=>{let n=Ge(f,e,t);n&&r(n)};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto py-1.5`,children:[p===0&&a.length===0&&(0,K.jsx)(`p`,{className:`px-3 py-3 text-xs text-fg-muted`,children:`No sessions yet — press ⌘K to start one.`}),f.map(e=>(0,K.jsxs)(`div`,{children:[e.name!==null&&(0,K.jsx)(`div`,{className:`truncate px-3 pb-1 pt-2 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e.name}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.sessions.map(e=>(0,K.jsx)(`li`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(Po,Fo({type:`terminal`,session:e.id})),c(e.id)},onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&m(s,e.id)},className:H(`transition-opacity`,s===e.id&&`opacity-50`),children:(0,K.jsx)(jc,{session:e,activeSessionId:n,accountLabel:d,onPromote:i,onArchived:o,ellipsis:!0})},e.id))})]},e.projectId))]}),a.length>0&&(0,K.jsxs)(`div`,{className:`shrink-0 pb-1.5`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`flex w-full items-center gap-1.5 px-3 py-1.5 text-2xs uppercase tracking-wide text-fg-gold transition-colors hover:text-fg`,children:[(0,K.jsx)(Tt,{className:H(`size-3 transition-transform`,l&&`rotate-90`)}),(0,K.jsx)(Ue,{className:`size-3`}),(0,K.jsx)(`span`,{children:`Archived`}),(0,K.jsx)(`span`,{className:`ml-auto tabular-nums`,children:a.length})]}),l&&(0,K.jsx)(`ul`,{className:`no-scrollbar flex max-h-48 flex-col gap-0.5 overflow-y-auto`,children:a.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsx)(jc,{session:e,activeSessionId:n,accountLabel:d,onArchived:o,ellipsis:!0})},e.id))})]})]})}var Pc=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Fc(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Ic(e){return`nodeType`in e}function Lc(e){return e?Fc(e)?e:Ic(e)?e.ownerDocument?.defaultView??window:window:window}function Rc(e){let{Document:t}=Lc(e);return e instanceof t}function zc(e){return!Fc(e)&&e instanceof Lc(e).HTMLElement}function Bc(e){return e instanceof Lc(e).SVGElement}function Vc(e){return e?Fc(e)?e.document:Ic(e)?Rc(e)?e:zc(e)||Bc(e)?e.ownerDocument:document:document:document}var Hc=Pc?q.useLayoutEffect:q.useEffect;function Uc(e){let t=(0,q.useRef)(e);return Hc(()=>{t.current=e}),(0,q.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Wc(){let e=(0,q.useRef)(null);return[(0,q.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,q.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function Gc(e,t){t===void 0&&(t=[e]);let n=(0,q.useRef)(e);return Hc(()=>{n.current!==e&&(n.current=e)},t),n}function Kc(e,t){let n=(0,q.useRef)();return(0,q.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function qc(e){let t=Uc(e),n=(0,q.useRef)(null);return[n,(0,q.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function Jc(e){let t=(0,q.useRef)();return(0,q.useEffect)(()=>{t.current=e},[e]),t.current}var Yc={};function Xc(e,t){return(0,q.useMemo)(()=>{if(t)return t;let n=Yc[e]==null?0:Yc[e]+1;return Yc[e]=n,e+`-`+n},[e,t])}function Zc(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var Qc=Zc(1),$c=Zc(-1);function el(e){return`clientX`in e&&`clientY`in e}function tl(e){if(!e)return!1;let{KeyboardEvent:t}=Lc(e.target);return t&&e instanceof t}function nl(e){if(!e)return!1;let{TouchEvent:t}=Lc(e.target);return t&&e instanceof t}function rl(e){if(nl(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return el(e)?{x:e.clientX,y:e.clientY}:null}var il=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[il.Translate.toString(e),il.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),al=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function ol(e){return e.matches(al)?e:e.querySelector(al)}var sl={display:`none`};function cl(e){let{id:t,value:n}=e;return q.createElement(`div`,{id:t,style:sl},n)}function ll(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return q.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function ul(){let[e,t]=(0,q.useState)(``);return{announce:(0,q.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var dl=(0,q.createContext)(null);function fl(e){let t=(0,q.useContext)(dl);(0,q.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function pl(){let[e]=(0,q.useState)(()=>new Set),t=(0,q.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,q.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var ml={draggable:`
4
4
  To pick up a draggable item, press the space bar.
5
5
  While dragging, use the arrow keys to move the item.
6
6
  Press space again to drop the item in its new position, or press escape to cancel.
7
- `},ml={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function hl(e){let{announcements:t=ml,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=pl}=e,{announce:a,announcement:o}=ll(),s=Yc(`DndLiveRegion`),[c,l]=(0,q.useState)(!1);if((0,q.useEffect)(()=>{l(!0)},[]),dl((0,q.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=q.createElement(q.Fragment,null,q.createElement(sl,{id:r,value:i.draggable}),q.createElement(cl,{id:s,announcement:o}));return n?(0,Gi.createPortal)(u,n):u}var Z;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(Z||={});function gl(){}function _l(e,t){return(0,q.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function vl(){var e=[...arguments];return(0,q.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var yl=Object.freeze({x:0,y:0});function bl(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function xl(e,t){let n=nl(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function Sl(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Cl(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function wl(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function Tl(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function El(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var Dl=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=El(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Cl)};function Ol(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var kl=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&Ol(r,a)){let n=wl(a).reduce((e,t)=>e+bl(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(Sl)};function Al(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function jl(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:yl}function Ml(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var Nl=Ml(1);function Pl(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Fl(e,t,n){let r=Pl(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var Il={ignoreTransform:!1};function Ll(e,t){t===void 0&&(t=Il);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=Ic(e).getComputedStyle(e);t&&(n=Fl(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function Rl(e){return Ll(e,{ignoreTransform:!0})}function zl(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Bl(e,t){return t===void 0&&(t=Ic(e).getComputedStyle(e)),t.position===`fixed`}function Vl(e,t){t===void 0&&(t=Ic(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`&&n.test(r)})}function Hl(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Lc(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Rc(i)||zc(i)||n.includes(i))return n;let a=Ic(e).getComputedStyle(i);return i!==e&&Vl(i,a)&&n.push(i),Bl(i,a)?n:r(i.parentNode)}return e?r(e):n}function Ul(e){let[t]=Hl(e,1);return t??null}function Wl(e){return!Nc||!e?null:Pc(e)?e:Fc(e)?Lc(e)||e===Bc(e).scrollingElement?window:Rc(e)?e:null:null}function Gl(e){return Pc(e)?e.scrollX:e.scrollLeft}function Kl(e){return Pc(e)?e.scrollY:e.scrollTop}function ql(e){return{x:Gl(e),y:Kl(e)}}var Q;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Q||={});function Jl(e){return!Nc||!e?!1:e===document.scrollingElement}function Yl(e){let t={x:0,y:0},n=Jl(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var Xl={x:.2,y:.2};function Zl(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Xl);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Yl(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Q.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Q.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Q.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Q.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Ql(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function $l(e){return e.reduce((e,t)=>Zc(e,ql(t)),yl)}function eu(e){return e.reduce((e,t)=>e+Gl(t),0)}function tu(e){return e.reduce((e,t)=>e+Kl(t),0)}function nu(e,t){if(t===void 0&&(t=Ll),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Ul(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var ru=[[`x`,[`left`,`right`],eu],[`y`,[`top`,`bottom`],tu]],iu=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=Hl(t),r=$l(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of ru)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},au=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function ou(e){let{EventTarget:t}=Ic(e);return e instanceof t?e:Bc(e)}function su(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t&&r>t.y}var cu;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(cu||={});function lu(e){e.preventDefault()}function uu(e){e.stopPropagation()}var $;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})($||={});var du={start:[$.Space,$.Enter],cancel:[$.Esc],end:[$.Space,$.Enter,$.Tab]},fu=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case $.Right:return{...n,x:n.x+25};case $.Left:return{...n,x:n.x-25};case $.Down:return{...n,y:n.y+25};case $.Up:return{...n,y:n.y-25}}},pu=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new au(Bc(t)),this.windowListeners=new au(Ic(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(cu.Resize,this.handleCancel),this.windowListeners.add(cu.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(cu.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&nu(n),t(yl)}handleKeyDown(e){if(el(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=du,coordinateGetter:a=fu,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:yl;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Qc(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Yl(n),p=Ql(n),m={x:Math.min(i===$.Right?p.right-p.width/2:p.right,Math.max(i===$.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===$.Down?p.bottom-p.height/2:p.bottom,Math.max(i===$.Down?p.top:p.top+p.height/2,u.y))},h=i===$.Right&&!s||i===$.Left&&!c,g=i===$.Down&&!l||i===$.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===$.Right&&e<=d.x||i===$.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===$.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===$.Down&&e<=d.y||i===$.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===$.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Zc(Qc(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};pu.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=du,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function mu(e){return!!(e&&`distance`in e)}function hu(e){return!!(e&&`delay`in e)}var gu=class{constructor(e,t,n){n===void 0&&(n=ou(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=Bc(i),this.documentListeners=new au(this.document),this.listeners=new au(n),this.windowListeners=new au(Ic(i)),this.initialCoordinates=nl(r)??yl,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(cu.Resize,this.handleCancel),this.windowListeners.add(cu.DragStart,lu),this.windowListeners.add(cu.VisibilityChange,this.handleCancel),this.windowListeners.add(cu.ContextMenu,lu),this.documentListeners.add(cu.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(hu(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(mu(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(cu.Click,uu,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(cu.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=nl(e)??yl,s=Qc(n,o);if(!t&&a){if(mu(a)){if(a.tolerance!=null&&su(s,a.tolerance))return this.handleCancel();if(su(s,a.distance))return this.handleStart()}if(hu(a)&&su(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===$.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},_u={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},vu=class extends gu{constructor(e){let{event:t}=e,n=Bc(t.target);super(e,_u,n)}};vu.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var yu={move:{name:`mousemove`},end:{name:`mouseup`}},bu;(function(e){e[e.RightClick=2]=`RightClick`})(bu||={});var xu=class extends gu{constructor(e){super(e,yu,Bc(e.event.target))}};xu.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===bu.RightClick?!1:(r?.({event:n}),!0)}}];var Su={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Cu=class extends gu{constructor(e){super(e,Su)}static setup(){return window.addEventListener(Su.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Su.move.name,e)};function e(){}}};Cu.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var wu;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(wu||={});var Tu;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Tu||={});function Eu(e){let{acceleration:t,activator:n=wu.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Tu.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Ou({delta:d,disabled:!a}),[m,h]=Uc(),g=(0,q.useRef)({x:0,y:0}),_=(0,q.useRef)({x:0,y:0}),v=(0,q.useMemo)(()=>{switch(n){case wu.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case wu.DraggableRect:return i}},[n,i,c]),y=(0,q.useRef)(null),b=(0,q.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,q.useMemo)(()=>s===Tu.TreeOrder?[...l].reverse():l,[s,l]);(0,q.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=l.indexOf(e),i=u[n];if(!i)continue;let{direction:a,speed:s}=Zl(e,i,v,t,f);for(let e of[`x`,`y`])p[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){h(),y.current=e,m(b,o),g.current=s,_.current=a;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var Du={x:{[Q.Backward]:!1,[Q.Forward]:!1},y:{[Q.Backward]:!1,[Q.Forward]:!1}};function Ou(e){let{delta:t,disabled:n}=e,r=qc(t);return Gc(e=>{if(n||!r||!e)return Du;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Q.Backward]:e.x[Q.Backward]||i.x===-1,[Q.Forward]:e.x[Q.Forward]||i.x===1},y:{[Q.Backward]:e.y[Q.Backward]||i.y===-1,[Q.Forward]:e.y[Q.Forward]||i.y===1}}},[n,t,r])}function ku(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Gc(e=>t==null?null:r??e??null,[r,t])}function Au(e,t){return(0,q.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var ju;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(ju||={});var Mu;(function(e){e.Optimized=`optimized`})(Mu||={});var Nu=new Map;function Pu(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,q.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,q.useRef)(e),d=g(),f=Wc(d),p=(0,q.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,q.useRef)(null),h=Gc(t=>{if(d&&!n)return Nu;if(!t||t===Nu||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new iu(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,q.useEffect)(()=>{u.current=e},[e]),(0,q.useEffect)(()=>{d||p()},[n,d]),(0,q.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,q.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case ju.Always:return!1;case ju.BeforeDragging:return n;default:return!n}}}function Fu(e,t){return Gc(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Iu(e,t){return Fu(e,t)}function Lu(e){let{callback:t,disabled:n}=e,r=Hc(t),i=(0,q.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,q.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Ru(e){let{callback:t,disabled:n}=e,r=Hc(t),i=(0,q.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,q.useEffect)(()=>()=>i?.disconnect(),[i]),i}function zu(e){return new iu(Ll(e),e)}function Bu(e,t,n){t===void 0&&(t=zu);let[r,i]=(0,q.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=Lu({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=Ru({callback:a});return Vc(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Vu(e){return jl(e,Fu(e))}var Hu=[];function Uu(e){let t=(0,q.useRef)(e),n=Gc(n=>e?n&&n!==Hu&&e&&t.current&&e.parentNode===t.current.parentNode?n:Hl(e):Hu,[e]);return(0,q.useEffect)(()=>{t.current=e},[e]),n}function Wu(e){let[t,n]=(0,q.useState)(null),r=(0,q.useRef)(e),i=(0,q.useCallback)(e=>{let t=Wl(e.target);t&&n(e=>e?(e.set(t,ql(t)),new Map(e)):null)},[]);return(0,q.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Wl(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,ql(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{Wl(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,q.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Zc(e,t),yl):$l(e):yl,[e,t])}function Gu(e,t){t===void 0&&(t=[]);let n=(0,q.useRef)(null);return(0,q.useEffect)(()=>{n.current=null},t),(0,q.useEffect)(()=>{let t=e!==yl;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Qc(e,n.current):yl}function Ku(e){(0,q.useEffect)(()=>{if(!Nc)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function qu(e,t){return(0,q.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Ju(e){return(0,q.useMemo)(()=>e?zl(e):null,[e])}var Yu=[];function Xu(e,t){t===void 0&&(t=Ll);let[n]=e,r=Ju(n?Ic(n):null),[i,a]=(0,q.useState)(Yu);function o(){a(()=>e.length?e.map(e=>Jl(e)?r:new iu(t(e),e)):Yu)}let s=Ru({callback:o});return Vc(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Zu(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Rc(t)?t:e}function Qu(e){let{measure:t}=e,[n,r]=(0,q.useState)(null),i=Ru({callback:(0,q.useCallback)(e=>{for(let{target:n}of e)if(Rc(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=Kc((0,q.useCallback)(e=>{let n=Zu(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,q.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var $u=[{sensor:vu,options:{}},{sensor:pu,options:{}}],ed={current:{}},td={draggable:{measure:Rl},droppable:{measure:Rl,strategy:ju.WhileDragging,frequency:Mu.Optimized},dragOverlay:{measure:Ll}},nd=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},rd={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new nd,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:gl},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:td,measureDroppableContainers:gl,windowRect:null,measuringScheduled:!1},id={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:gl,draggableNodes:new Map,over:null,measureDroppableContainers:gl},ad=(0,q.createContext)(id),od=(0,q.createContext)(rd);function sd(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new nd}}}function cd(e,t){switch(t.type){case Z.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Z.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Z.DragEnd:case Z.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Z.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new nd(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Z.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new nd(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Z.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new nd(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function ld(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,q.useContext)(ad),a=qc(r),o=qc(n?.id);return(0,q.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!el(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=al(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function ud(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function dd(e){return(0,q.useMemo)(()=>({draggable:{...td.draggable,...e?.draggable},droppable:{...td.droppable,...e?.droppable},dragOverlay:{...td.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function fd(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,q.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Vc(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=jl(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=Ul(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var pd=(0,q.createContext)({...yl,scaleX:1,scaleY:1}),md;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(md||={});var hd=(0,q.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=$u,collisionDetection:o=Dl,measuring:s,modifiers:c,...l}=e,[u,d]=(0,q.useReducer)(cd,void 0,sd),[f,p]=fl(),[m,h]=(0,q.useState)(md.Uninitialized),g=m===md.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,q.useRef)({initial:null,translated:null}),C=(0,q.useMemo)(()=>_==null?null:{id:_,data:x?.data??ed,rect:S},[_,x]),w=(0,q.useRef)(null),[T,E]=(0,q.useState)(null),[D,O]=(0,q.useState)(null),k=Wc(l,Object.values(l)),ee=Yc(`DndDescribedBy`,t),A=(0,q.useMemo)(()=>b.getEnabled(),[b]),j=dd(s),{droppableRects:te,measureDroppableContainers:ne,measuringScheduled:re}=Pu(A,{dragging:g,dependencies:[y.x,y.y],config:j.droppable}),M=ku(v,_),N=(0,q.useMemo)(()=>D?nl(D):null,[D]),P=De(),ie=Iu(M,j.draggable.measure);fd({activeNode:_==null?null:v.get(_),config:P.layoutShiftCompensation,initialRect:ie,measure:j.draggable.measure});let F=Bu(M,j.draggable.measure,ie),I=Bu(M?M.parentElement:null),ae=(0,q.useRef)({activatorEvent:null,active:null,activeNode:M,collisionRect:null,collisions:null,droppableRects:te,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=b.getNodeFor(ae.current.over?.id),L=Qu({measure:j.dragOverlay.measure}),R=L.nodeRef.current??M,z=g?L.rect??F:null,se=!!(L.nodeRef.current&&L.rect),ce=Vu(se?null:F),le=Ju(R?Ic(R):null),B=Uu(g?oe??M:null),ue=Xu(B),de=ud(c,{transform:{x:y.x-ce.x,y:y.y-ce.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:F,containerNodeRect:I,draggingNodeRect:z,over:ae.current.over,overlayNodeRect:L.rect,scrollableAncestors:B,scrollableAncestorRects:ue,windowRect:le}),fe=N?Zc(N,y):null,pe=Wu(B),me=Gu(pe),he=Gu(pe,[F]),V=Zc(de,me),ge=z?Nl(z,de):null,_e=C&&ge?o({active:C,collisionRect:ge,droppableRects:te,droppableContainers:A,pointerCoordinates:fe}):null,ve=Tl(_e,`id`),[ye,be]=(0,q.useState)(null),xe=Al(se?de:Zc(de,he),ye?.rect??null,F),Se=(0,q.useRef)(null),Ce=(0,q.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent,o=new n({active:w.current,activeNode:i,event:a,options:r,context:ae,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,Gi.unstable_batchedUpdates)(()=>{r?.(i),h(md.Initializing),d({type:Z.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Se.current),O(a)})},onMove(e){d({type:Z.DragMove,coordinates:e})},onEnd:s(Z.DragEnd),onCancel:s(Z.DragCancel)});Se.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=ae.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Z.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Z.DragCancel)}w.current=null,(0,Gi.unstable_batchedUpdates)(()=>{d({type:e}),h(md.Uninitialized),be(null),E(null),O(null),Se.current=null;let t=e===Z.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),we=Au(a,(0,q.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,Ce(n,t))},[v,Ce]));Ku(a),Vc(()=>{F&&m===md.Initializing&&h(md.Initialized)},[F,m]),(0,q.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=ae.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:V.x,y:V.y},over:i};(0,Gi.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[V.x,V.y]),(0,q.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=ae.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(ve),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,Gi.unstable_batchedUpdates)(()=>{be(s),a?.(c),f({type:`onDragOver`,event:c})})},[ve]),Vc(()=>{ae.current={activatorEvent:D,active:C,activeNode:M,collisionRect:ge,collisions:_e,droppableRects:te,draggableNodes:v,draggingNode:R,draggingNodeRect:z,droppableContainers:b,over:ye,scrollableAncestors:B,scrollAdjustedTranslate:V},S.current={initial:z,translated:ge}},[C,M,_e,ge,v,R,z,te,b,ye,B,V]),Eu({...P,delta:y,draggingRect:ge,pointerCoordinates:fe,scrollableAncestors:B,scrollableAncestorRects:ue});let Te=(0,q.useMemo)(()=>({active:C,activeNode:M,activeNodeRect:F,activatorEvent:D,collisions:_e,containerNodeRect:I,dragOverlay:L,draggableNodes:v,droppableContainers:b,droppableRects:te,over:ye,measureDroppableContainers:ne,scrollableAncestors:B,scrollableAncestorRects:ue,measuringConfiguration:j,measuringScheduled:re,windowRect:le}),[C,M,F,D,_e,I,L,v,b,te,ye,ne,B,ue,j,re,le]),Ee=(0,q.useMemo)(()=>({activatorEvent:D,activators:we,active:C,activeNodeRect:F,ariaDescribedById:{draggable:ee},dispatch:d,draggableNodes:v,over:ye,measureDroppableContainers:ne}),[D,we,C,F,d,ee,v,ye,ne]);return q.createElement(ul.Provider,{value:p},q.createElement(ad.Provider,{value:Ee},q.createElement(od.Provider,{value:Te},q.createElement(pd.Provider,{value:xe},i)),q.createElement(ld,{disabled:n?.restoreFocus===!1})),q.createElement(hl,{...n,hiddenTextDescribedById:ee}));function De(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),gd=(0,q.createContext)(null),_d=`button`,vd=`Draggable`;function yd(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Yc(vd),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,q.useContext)(ad),{role:p=_d,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,q.useContext)(g?pd:gd),[v,y]=Kc(),[b,x]=Kc(),S=qu(o,t),C=Wc(n);return Vc(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,q.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===_d?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function bd(){return(0,q.useContext)(od)}var xd=`Droppable`,Sd={timeout:25};function Cd(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Yc(xd),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,q.useContext)(ad),u=(0,q.useRef)({disabled:n}),d=(0,q.useRef)(!1),f=(0,q.useRef)(null),p=(0,q.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Sd,...i},_=Wc(h??r),v=Ru({callback:(0,q.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=Kc((0,q.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Wc(t);return(0,q.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,q.useEffect)(()=>(s({type:Z.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:Z.UnregisterDroppable,key:a,id:r})),[r]),(0,q.useEffect)(()=>{n!==u.current.disabled&&(s({type:Z.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function wd(e){let{animation:t,children:n}=e,[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(null),s=qc(n);return!n&&!r&&s&&i(s),Vc(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),q.createElement(q.Fragment,null,n,r?(0,q.cloneElement)(r,{ref:o}):null)}var Td={x:0,y:0,scaleX:1,scaleY:1};function Ed(e){let{children:t}=e;return q.createElement(ad.Provider,{value:id},q.createElement(pd.Provider,{value:Td},t))}var Dd={position:`fixed`,touchAction:`none`},Od=e=>el(e)?`transform 250ms ease`:void 0,kd=(0,q.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=Od}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Dd,width:s.width,height:s.height,top:s.top,left:s.left,transform:rl.Transform.toString(d),transformOrigin:i&&r?xl(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return q.createElement(n,{className:o,style:f,ref:t},a)}),Ad={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:rl.Transform.toString(t)},{transform:rl.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function jd(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return Hc((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=Zu(a);if(!c)return;let{transform:l}=Ic(a).getComputedStyle(a),u=Pl(l);if(!u)return;let d=typeof t==`function`?t:Md(t);return nu(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function Md(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...Ad,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var Nd=0;function Pd(e){return(0,q.useMemo)(()=>{if(e!=null)return Nd++,Nd},[e])}var Fd=q.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=bd(),S=(0,q.useContext)(pd),C=Pd(d?.id),w=ud(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=Fu(f),E=jd({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return q.createElement(Ed,null,q.createElement(wd,{animation:E},d&&C?q.createElement(kd,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))});function Id({className:e}){return(0,K.jsx)(`svg`,{viewBox:`0 0 2000 2000`,fill:`none`,"aria-hidden":`true`,className:e,children:(0,K.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:110,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`line`,{x1:`491.66`,y1:`1916.78`,x2:`1558.47`,y2:`83.22`}),(0,K.jsx)(`path`,{d:`M491.66,1916.78c-329.28-191.58-441.36-613.07-250.32-941.41,191.04-328.34,612.84-439.21,942.13-247.62`}),(0,K.jsx)(`path`,{d:`M1558.47,83.22c279.53,162.64,376.25,517.72,216.03,793.09-160.22,275.38-516.71,366.77-796.24,204.13`}),(0,K.jsx)(`path`,{d:`M497.55,1881.96c-222.81-129.63-298.64-414.83-169.38-637,129.26-222.17,414.67-297.19,637.48-167.55`})]})})}var Ld=[`running`,`waiting_input`];function Rd({sessionId:e,status:t}){let n=Ld.includes(t),{data:r}=B(e,n),i=r?.vars??[];return!n||i.length===0?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1 font-mono text-xs`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:`env`}),(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:i.map(e=>(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsx)(`span`,{className:`cursor-default rounded px-1.5 py-0.5 text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,children:e.name})}),(0,K.jsxs)(Gt,{children:[e.bytes,` B · captured from this session's shell — re-injected into new shells and agent restarts`]})]},e.name))})]})}function zd(e,t,n){return`ssh -L ${e}:127.0.0.1:${e} ${t}@${n}`}var Bd=[`running`,`waiting_input`];function Vd({sessionId:e,status:t}){let n=Bd.includes(t),{data:r}=we(e,n),i=r?.ports??[];return!n||i.length===0?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1 font-mono text-xs`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:`ports`}),(0,K.jsx)(`div`,{className:`flex items-center gap-1`,children:i.map(t=>(0,K.jsx)(Hd,{sessionId:e,port:t},t.port))})]})}function Hd({sessionId:e,port:t}){let n=V().data;return(0,K.jsxs)($s,{children:[(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsx)(ec,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,className:`cursor-pointer rounded px-1.5 py-0.5 tabular-nums text-fg-secondary outline-none transition-colors hover:bg-elevated hover:text-fg focus-visible:bg-elevated focus-visible:text-fg`,children:t.port})})}),(0,K.jsxs)(Gt,{children:[t.command,` · pid `,t.pid]})]}),(0,K.jsxs)(nc,{align:`start`,children:[tn()===null?(0,K.jsx)(rc,{asChild:!0,children:(0,K.jsx)(`a`,{href:`http://localhost:${t.port}`,target:`_blank`,rel:`noopener noreferrer`,children:`Open localhost`})}):(0,K.jsx)(rc,{onSelect:()=>{window.open(`/proxy/${e}/${t.port}/?puddle_token=${re.get()??``}`,`_blank`,`noopener,noreferrer`)},children:`Open via proxy`}),(0,K.jsx)(rc,{onSelect:()=>{n&&navigator.clipboard.writeText(zd(t.port,n.username,n.hostname)).then(()=>k.success(`Copied`))},children:`Copy ssh -L`})]})]})}function Ud(e,t,n=.25){if(e.width<=0||e.height<=0)return`center`;let r=Wd(t.x/e.width),i=Wd(t.y/e.height);if(r>n&&r<1-n&&i>n&&i<1-n)return`center`;let a=r,o=1-r,s=i,c=1-i,l=Math.min(a,o,s,c);return l===s?`top`:l===c?`bottom`:l===a?`left`:`right`}function Wd(e){return e<0?0:e>1?1:e}var Gd=[`interrupted`,`exited`];function Kd({session:e}){let t=_e(`resume`);return Gd.includes(e.status)&&!e.worktree_missing?(0,K.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 right-3 z-10`,children:(0,K.jsxs)(I,{size:`sm`,className:`pointer-events-auto`,disabled:t.isPending,onClick:()=>t.mutate(e.id,{onError:e=>Re(e)}),children:[(0,K.jsx)(Pn,{}),`Resume`]})}):null}var qd=(0,q.createContext)(null);function Jd(){return(0,q.useContext)(qd)}var Yd=`leaf:`,Xd=`tabdrop:`,Zd=`strip:`,Qd=e=>{let t=kl(e);for(let e of[Xd,Zd]){let n=t.filter(t=>String(t.id).startsWith(e));if(n.length>0)return n}return t.length>0?t:Dl(e)};function $d({onDrop:e,renderOverlay:t,children:n}){let r=vl(_l(vu,{activationConstraint:{distance:4}})),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(null),c=(0,q.useRef)(null),l=()=>{a(null),s(null),c.current=null};return(0,K.jsxs)(hd,{sensors:r,collisionDetection:Qd,onDragStart:e=>s(e.active.data.current?.ref??null),onDragMove:e=>{let t=e.over,n=ef(e),r=t&&n?nf(String(t.id),t.rect,t.data.current,n):null;tf(c.current,r)||(c.current=r,a(r))},onDragEnd:t=>{let n=c.current,r=t.active.data.current?.ref,i=t.active.data.current?.fromLeafId;l(),n&&r&&i&&e({ref:r,fromLeafId:i,toLeafId:n.leafId,edge:n.zone,index:n.index})},onDragCancel:l,children:[(0,K.jsx)(qd.Provider,{value:i,children:n}),(0,K.jsx)(Fd,{dropAnimation:null,children:o?t(o):null})]})}function ef(e){let t=e.activatorEvent;return typeof t.clientX!=`number`||typeof t.clientY!=`number`?null:{x:t.clientX+e.delta.x,y:t.clientY+e.delta.y}}function tf(e,t){return e===null||t===null?e===t:e.leafId===t.leafId&&e.zone===t.zone&&e.index===t.index}function nf(e,t,n,r){if(e.startsWith(Xd)){let e=n;if(!e)return null;let i=r.x>t.left+t.width/2;return{leafId:e.leafId,zone:`center`,index:e.index+ +!!i}}if(e.startsWith(Zd)){let e=n;return e?{leafId:e.leafId,zone:`center`,index:e.count}:null}if(e.startsWith(Yd)){let n=Ud({width:t.width,height:t.height},{x:r.x-t.left,y:r.y-t.top});return{leafId:e.slice(5),zone:n}}return null}var rf=`group relative flex min-w-16 max-w-52 cursor-pointer items-center gap-1.5 rounded-t-md px-2.5 text-xs transition-colors`;function af({leaf:e,sessions:t,onActivate:n,onClose:r,onPromote:i,onArchived:a,onSetView:o,onNewFile:s}){let c=new Map(t.map(e=>[e.id,e.branch])),l=e.tabs.flatMap(e=>e.type===`editor`?[e.tab]:[]),u=Jd(),d=u?.leafId===e.id&&u.index!==void 0?u.index:null,{setNodeRef:f}=Cd({id:`strip:${e.id}`,data:{leafId:e.id,count:e.tabs.length}}),p=e=>{let t=en(e.path,e.session,l,c);return y(e)===`diff`?`${t} (diff)`:y(e)===`commit`?`${t} @${(e.sha??``).slice(0,7)}`:t};return(0,K.jsxs)(`div`,{ref:f,className:`flex h-9 shrink-0 items-stretch gap-0.5 overflow-x-auto bg-surface px-1 pt-1`,onDoubleClick:e=>{e.target===e.currentTarget&&s()},children:[e.tabs.map((s,c)=>(0,K.jsxs)(q.Fragment,{children:[d===c&&(0,K.jsx)(of,{}),(0,K.jsx)(lf,{tab:s,leafId:e.id,index:c,active:X(s)===e.activeKey,preview:X(s)===e.previewKey,session:s.type===`terminal`?t.find(e=>e.id===s.session):void 0,label:s.type===`editor`?p(s.tab):``,onActivate:()=>n(s),onClose:()=>r(s),onPromote:()=>i(s),onArchived:a,onSetView:e=>o(s,e)})]},X(s))),d===e.tabs.length&&(0,K.jsx)(of,{})]})}function of(){return(0,K.jsx)(`div`,{className:`w-0.5 shrink-0 self-stretch rounded-full bg-accent`})}function sf({active:e,children:t}){return(0,K.jsx)(`span`,{className:H(`pointer-events-none absolute inset-y-0 right-0 flex items-center gap-1 pl-5 pr-2.5`,`[&>*]:pointer-events-auto`,e?`group-hover:bg-[linear-gradient(to_right,transparent,var(--color-ground)_1.25rem)]`:`group-hover:bg-[linear-gradient(to_right,transparent,var(--color-elevated)_1.25rem)]`),children:t})}function cf({view:e,onSetView:t}){let n=e===`preview`;return(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),t(n?`source`:`preview`)},className:`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg group-hover:inline-flex pointer-coarse:inline-flex`,"aria-label":n?`Show source`:`Show preview`,title:n?`Show source`:`Show preview`,children:n?(0,K.jsx)(G,{className:`size-3`}):(0,K.jsx)(ln,{className:`size-3`})})}function lf({tab:e,leafId:t,index:n,active:r,preview:i,session:a,label:o,onActivate:s,onClose:c,onPromote:l,onArchived:u,onSetView:d}){let f=Ot(),p=X(e),{attributes:m,listeners:h,setNodeRef:g,isDragging:_}=yd({id:`drag:${t}:${p}`,data:{ref:e,fromLeafId:t}}),{setNodeRef:v}=Cd({id:`tabdrop:${t}:${p}`,data:{leafId:t,index:n}}),b=e=>{g(e),v(e)},S=H(rf,r?`bg-ground text-fg`:`text-fg-secondary hover:bg-elevated`,i&&`italic`,_&&`opacity-40`),C=(0,K.jsx)(`div`,{ref:b,...m,...h,onClick:s,onDoubleClick:l,className:S,children:e.type===`terminal`?(0,K.jsxs)(K.Fragment,{children:[a&&(0,K.jsx)(gc,{status:a.status,kind:a.kind,stale:a.stale_running}),a?.agent_type!=null&&(0,K.jsx)(Yt,{type:a.agent_type,className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate font-mono`,children:a?f(a):e.session.slice(0,8)}),(0,K.jsx)(sf,{active:r,children:(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),c()},className:`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg group-hover:inline-flex pointer-coarse:inline-flex`,"aria-label":`Close tab`,children:(0,K.jsx)(ae,{className:`size-3`})})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`truncate font-mono`,children:o}),(0,K.jsxs)(sf,{active:r,children:[y(e.tab)===`file`&&x(e.tab.path)!==null&&(0,K.jsx)(cf,{view:e.tab.view??`source`,onSetView:d}),(0,K.jsx)(Wi,{session:e.tab.session,path:e.tab.path,kind:y(e.tab),root:e.tab.root,label:o,onClose:c})]})]})});return e.type===`terminal`&&a?(0,K.jsx)(wc,{session:a,onArchived:()=>u(e.session),children:C}):C}function uf({leaf:e,sessions:t,reveal:n,onActivateTab:r,onCloseTab:i,onPromoteTab:a,onArchived:o,onFocusLeaf:s,onDropTab:c,onSetTabView:l,onNewUntitled:u}){let d=e.tabs.find(t=>X(t)===e.activeKey)??null,f=d?.type===`terminal`?X(d):null,p=d?.type===`terminal`?t.find(e=>e.id===d.session)??null:null,m=xa(f),{setNodeRef:h}=Cd({id:`leaf:${e.id}`}),g=Jd(),_=(0,q.useRef)(null),v=(0,q.useRef)(()=>void 0);v.current=()=>{d&&r(e.id,d)},(0,q.useEffect)(()=>{let e=_.current;if(!e)return;let t=()=>v.current();return e.addEventListener(`mousedown`,t,!0),()=>e.removeEventListener(`mousedown`,t,!0)},[]);let[y,b]=(0,q.useState)(null),x=e=>{let t=e.currentTarget.getBoundingClientRect();return Ud({width:t.width,height:t.height},{x:e.clientX-t.left,y:e.clientY-t.top})};return(0,K.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,onMouseDownCapture:()=>s(e.id),children:[e.tabs.length>0&&(0,K.jsx)(af,{leaf:e,sessions:t,onActivate:t=>r(e.id,t),onClose:t=>i(e.id,t),onPromote:a,onArchived:o,onSetView:l,onNewFile:()=>u(e)}),(0,K.jsxs)(`div`,{ref:e=>{_.current=e,h(e)},className:`relative min-h-0 flex-1`,onDragOver:e=>{Lo(e.dataTransfer.types)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,b(x(e)))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||b(null)},onDrop:t=>{if(!Lo(t.dataTransfer.types))return;t.preventDefault(),b(null);let n=Io(t.dataTransfer.getData(Po));n&&c(e.id,n,x(t))},children:[d?.type===`editor`&&(0,K.jsx)(`div`,{className:`absolute inset-0`,children:(0,K.jsx)(Bi,{tab:d.tab,reveal:n})}),(0,K.jsx)(`div`,{ref:m,className:H(`absolute inset-0 py-1 pl-4 pr-2`,!f&&`hidden`)}),g?.leafId===e.id&&g.index===void 0&&(0,K.jsx)(ff,{zone:g.zone}),y!==null&&(0,K.jsx)(ff,{zone:y}),p&&(0,K.jsx)(Kd,{session:p}),!d&&(0,K.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-6 text-center`,children:[(0,K.jsx)(Id,{className:`size-24 text-fg-muted/40`}),(0,K.jsx)(`button`,{type:`button`,onClick:Dt,className:`rounded-md bg-elevated px-3 py-1.5 font-mono text-xs text-fg-muted transition-colors hover:bg-border hover:text-fg-secondary`,children:`⌘K`})]})]}),p&&(0,K.jsx)(Rd,{sessionId:p.id,status:p.status}),p&&(0,K.jsx)(Vd,{sessionId:p.id,status:p.status})]})}var df={center:`inset-0`,left:`inset-y-0 left-0 w-1/2`,right:`inset-y-0 right-0 w-1/2`,top:`inset-x-0 top-0 h-1/2`,bottom:`inset-x-0 bottom-0 h-1/2`};function ff({zone:e}){return(0,K.jsx)(`div`,{className:H(`pointer-events-none absolute z-20 bg-accent/20`,df[e])})}var pf=`bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`;function mf({tree:e,...t}){let n=(0,q.useMemo)(()=>{let t=new Set,n=[];for(let r of ea(e)){if(r.type!==`editor`||![`file`,`diff`].includes(y(r.tab)))continue;let e=`${r.tab.session}${r.tab.path}`;t.has(e)||(t.add(e),n.push({session:r.tab.session,path:r.tab.path}))}return n},[e]);return(0,K.jsxs)(K.Fragment,{children:[n.length>0&&(0,K.jsx)(Hi,{buffers:n}),(0,K.jsx)(hf,{node:e,...t})]})}function hf({node:e,...t}){if(e.kind===`leaf`)return(0,K.jsx)(uf,{leaf:e,sessions:t.sessions,reveal:t.reveal,onActivateTab:t.onActivateTab,onCloseTab:t.onCloseTab,onPromoteTab:t.onPromoteTab,onArchived:t.onArchived,onFocusLeaf:t.onFocusLeaf,onDropTab:t.onDropTab,onSetTabView:t.onSetTabView,onNewUntitled:t.onNewUntitled});let n=e.direction===`row`?`horizontal`:`vertical`;return(0,K.jsx)(Di,{orientation:n,className:`size-full`,defaultLayout:Object.fromEntries(e.children.map((t,n)=>[t.id,e.sizes[n]??100/e.children.length])),onLayoutChanged:n=>t.onResize(e.id,e.children.map(e=>n[e.id]??0)),children:e.children.map((e,r)=>(0,K.jsxs)(q.Fragment,{children:[r>0&&(0,K.jsx)(Ni,{className:n===`horizontal`?`w-px ${pf}`:`h-px ${pf}`}),(0,K.jsx)(Ai,{id:e.id,minSize:64,children:(0,K.jsx)(hf,{node:e,...t})})]},e.id))},e.id)}function gf(e){let t=e.snapshot,n=(0,q.useRef)(null);!t.layout_tree&&!n.current&&(n.current=va(t));let r=t.layout_tree??n.current??Yi([]),i=(0,q.useCallback)(t=>e.update({layout_tree:t}),[e]),a=(0,q.useRef)(i);a.current=i;let o=(0,q.useRef)(!1);(0,q.useEffect)(()=>{o.current||e.loaded&&!t.layout_tree&&n.current&&(o.current=!0,ea(n.current).length>0&&a.current(n.current))},[e.loaded,t.layout_tree]);let[s,c]=(0,q.useState)(null),l=(s?Zi(r,s):null)??$i(r)[0]??Yi([]),u=l.tabs.find(e=>X(e)===l.activeKey)??null,d=u?.type===`editor`?u.tab:null;return(0,q.useMemo)(()=>({tree:r,focusedLeaf:l,activeEditorTab:d,focusLeaf:e=>c(e),activate:(e,t)=>{c(e);let n=X(t),a=Zi(r,e);a&&a.activeKey===n||i(ha(r,e,n))},close:(e,t)=>i(ua(r,e,X(t))),openEditor:(e,t)=>{let n=l.id;c(n);let a={type:`editor`,tab:e};i(t?.preview?fa(r,n,a):da(r,n,a))},ensureTerminal:(e,t)=>{let n=`term:${e}`,a=Qi(r,n);if(a){c(a.id);let e=a.activeKey!==n,o=!t?.preview&&a.previewKey===n;if(e||o){let t=r;e&&(t=ha(t,a.id,n)),o&&(t=pa(t,n)),i(t)}}else{let n=l.id;c(n);let a={type:`terminal`,session:e};i(t?.preview?fa(r,n,a):da(r,n,a))}},promote:e=>i(pa(r,X(e))),setView:(e,t)=>i(ma(r,X(e),t)),removeTerminal:e=>{let t=Qi(r,`term:${e}`);t&&i(ua(r,t.id,`term:${e}`))},pruneSessions:e=>i(_a(r,t=>t.type===`terminal`?e.has(t.session):e.has(t.tab.session))),resize:(e,t)=>i(ga(r,e,t)),drop:e=>{c(e.toLeafId),i(ca(r,e))}}),[r,l,d,i])}var _f=2e3,vf=ne.parse({});function yf(e){return`puddle.ws.${e}`}function bf(e){if(e===null)return{kind:`absent`};try{return{kind:`present`,snapshot:ne.parse(JSON.parse(e))}}catch{return{kind:`corrupt`}}}function xf(){let e=a(),[t,n]=(0,q.useState)(!1),[r,i]=(0,q.useState)(vf),o=(0,q.useRef)(r);o.current=r;let s=(0,q.useRef)(null),c=(0,q.useMemo)(()=>$t((e,t)=>{Ve(e,t).catch(e=>console.warn(`ui-state save failed: ${e.message}`))},_f),[]);return(0,q.useEffect)(()=>{if(e===null){s.current=null;return}let t=yf(e);s.current=t;let r=!1;n(!1),i(vf);let a;try{a=bf(sessionStorage.getItem(t)),a.kind===`corrupt`&&sessionStorage.removeItem(t)}catch(e){console.warn(`ui-state read failed: ${e.message}`),a={kind:`absent`}}return a.kind===`present`?(i(a.snapshot),n(!0)):Se(e).then(e=>{r||(e&&i(e.ui_state),n(!0))}).catch(e=>{console.warn(`ui-state load failed: ${e.message}`),r||n(!0)}),()=>{r=!0,c.flush()}},[e,c]),{loaded:t,snapshot:r,update(t){if(e===null)return;let n={...o.current,...t};o.current=n,i(n);let r=s.current??yf(e);c(e,n);try{sessionStorage.setItem(r,JSON.stringify(n))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}}}}function Sf(){return(0,K.jsx)(p,{children:(0,K.jsx)(Cf,{})})}function Cf(){let e=Kt(),t=Ht(),n=ue(),r=e.id??``,a=/^[0-9a-f]{10}$/.test(r),o=e.sid??null,s=ve(a?r:void 0),c=(0,q.useMemo)(()=>s.data?.sessions??[],[s.data]),l=Te(s.data?.project.profile_id).data??[],u=Ot(),d=xf(),f=Ne(),p=f.data??c,m=s.data?.project.profile_id,v=Rt().showAllProjectSessions,x=fe(v?m:void 0),C=pe(v?m:void 0),w=(0,q.useMemo)(()=>{let e=e=>e.status!==`archived`;if(!v)return[{projectId:r,name:null,sessions:qe(c.filter(e),d.snapshot.session_order)}];let t=qe((x.data??[]).filter(e=>!e.archived),C.data?.projectOrder??[]),n=f.data??c;return t.map(t=>({projectId:t.id,name:t.name,sessions:qe(n.filter(n=>n.project_id===t.id&&e(n)),d.snapshot.session_order)}))},[v,c,r,d.snapshot.session_order,x.data,C.data,f.data]),T=(0,q.useMemo)(()=>c.filter(e=>e.status===`archived`),[c]),E=gf(d),D=(0,q.useRef)(E);D.current=E;let O=(0,q.useRef)(d);O.current=d;let A=(0,q.useCallback)(e=>O.current.update({session_order:Ke(e,O.current.snapshot.session_order)}),[]),j=Sa(Ca),te=(0,q.useRef)(j);te.current=j;let[ne,re]=(0,q.useState)(!1),[M,N]=(0,q.useState)(!1),[P,F]=(0,q.useState)(!1),[ae,L]=(0,q.useState)(!1),[le,B]=(0,q.useState)(`agent`),[de,me]=(0,q.useState)(void 0),he=(0,q.useCallback)((e=`agent`)=>{me(void 0),B(e),L(!0)},[]),ge=(0,q.useRef)(null),{setHandler:_e}=Qt(),[ye,be]=(0,q.useState)(null),xe=(0,q.useCallback)((e,t,n)=>{E.openEditor(e,{preview:n?.preview}),te.current&&re(!1),t&&(e.kind??`file`)===`file`&&be({session:e.session,path:e.path,line:t.line,column:t.column,nonce:Date.now()})},[E]),Se=(0,q.useCallback)((e,t,n,r)=>xe({kind:`file`,session:e,path:t,...r?.view?{view:r.view}:{}},n,r),[xe]);S(Se);let Ce=(0,q.useCallback)((e,t,n)=>Se(e,t,void 0,{preview:n?.preview??!0}),[Se]),we=(0,q.useCallback)((e,r)=>{let i=c.find(t=>t.id===e);i&&n.mutate({project_id:i.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:i.worktree_path,cwd:r},{onSuccess:e=>void t(`/project/${e.project_id}/session/${e.id}`),onError:e=>Re(e)})},[c,n,t]),Ee=(0,q.useCallback)(e=>E.promote(e),[E]),De=(0,q.useCallback)((e,t,n,r)=>xe({kind:`external`,session:e,path:t,root:n},void 0,{preview:r?.preview??!0}),[xe]),Oe=i(),ke=He().data?.protocol,Ae=!ke||ke.major>10||ke.major===10&&ke.minor>=3,Me=(0,q.useCallback)(e=>{if(m!==void 0){if(!Ae){k.error(`Untitled drafts need a newer daemon — refresh the connection to update it`);return}_(m).then(({name:e})=>xe({kind:`untitled`,session:ee,path:e})).catch(e=>k.error(e instanceof Error?e.message:`Could not create a draft`))}},[xe,m,Ae]),[Fe,Ie]=(0,q.useState)(null);(0,q.useEffect)(()=>(g(Ie),()=>g(null)),[]);let[Le,ze]=(0,q.useState)(null),Be=()=>{let e=Le;if(ze(null),!e||e.ref.type!==`editor`)return;let t=e.ref.tab.path;m!==void 0&&b(m,t).catch(()=>void 0),h(t),E.close(e.leafId,e.ref)},Ve=(e,t,n)=>{Ie(null);let r={type:`editor`,tab:{kind:`untitled`,session:ee,path:e}},i=X(r);for(let e of $i(D.current.tree))e.tabs.some(e=>X(e)===i)&&D.current.close(e.id,r);Oe.invalidateQueries({queryKey:[`wt-tree`,t]}),setTimeout(()=>{D.current.openEditor({kind:`file`,session:t,path:n})},0)};(0,q.useEffect)(()=>(_e(e=>{me(e?.accountId),B(e?.kind??`agent`),L(!0)}),()=>_e(null)),[_e]);let[H,U]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!d.loaded||H)return;let e=ea(D.current.tree);Promise.all([e.some(e=>e.type===`terminal`)?Pe():void 0,e.some(e=>e.type===`editor`)?Ri():void 0]).finally(()=>U(!0))},[d.loaded,H]),(0,q.useEffect)(()=>{if(P||!d.loaded||!s.data)return;F(!0);let e=d.snapshot.active_session,n=c.find(t=>t.id===e);!o&&n&&n.status!==`archived`&&t(`/project/${r}/session/${n.id}`,{replace:!0})},[P,d,s.data,c,o,t,r]);let Ue=(0,q.useRef)(!1);(0,q.useEffect)(()=>{if(Ue.current||!d.loaded||!f.data)return;Ue.current=!0;let e=new Set(f.data.filter(e=>e.status!==`archived`).map(e=>e.id));D.current.pruneSessions(e);let t=O.current.snapshot.session_order,n=t.filter(t=>e.has(t));n.length!==t.length&&O.current.update({session_order:n})},[d.loaded,f.data]),(0,q.useEffect)(()=>{if(!P)return;if(N(!1),!o){ge.current=null;return}if(o===ge.current)return;ge.current=null,D.current.ensureTerminal(o,{preview:!0});let e=O.current;e.snapshot.active_session!==o&&e.update({active_session:o})},[P,o]);let We=V();(0,q.useEffect)(()=>{let e=je(We.data)??`puddle`,t=c.filter(e=>e.status===`waiting_input`).length,n=s.data?.project.name??`puddle`;return document.title=t>0?`● ${t} waiting — ${n}`:`${n} — ${e}`,()=>{document.title=e}},[c,s.data?.project.name,We.data]);let Ge=(0,q.useCallback)(e=>{let n=o===e;n&&(ge.current=e),E.removeTerminal(e),n&&(d.update({active_session:null}),t(`/project/${r}`))},[E,d,o,t,r]),Je=(0,q.useCallback)((e,n)=>{if(E.activate(e,n),n.type===`terminal`&&n.session!==o){let e=p.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[E,t,p,o]),Ye=(0,q.useCallback)((e,n)=>{if(n.type===`editor`&&y(n.tab)===`untitled`){ze({leafId:e,ref:n});return}E.close(e,n),n.type===`terminal`&&n.session===o&&(ge.current=n.session,d.update({active_session:null}),t(`/project/${r}`))},[E,o,d,t,r]),Xe=(0,q.useCallback)((e,n,r)=>{if(E.drop({ref:n,fromLeafId:e,toLeafId:e,edge:r}),n.type===`terminal`&&n.session!==o){let e=p.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[E,o,p,t]),Ze=E.focusedLeaf.tabs.find(e=>X(e)===E.focusedLeaf.activeKey)??null,Qe=Ze===null?null:Ze.type===`terminal`?Ze.session:Ze.tab.session,$e=Fi(p,(Qe===`00000000-0000-0000-0000-000000000000`?null:Qe)??o,d),et=$e.session,tt=fc(d.snapshot.sidebar_mode),nt=d.snapshot.sidebar_collapsed,rt=d.snapshot.sessions_collapsed,it=(0,q.useCallback)(e=>{let t=E.focusedLeaf,n=t.tabs.find(e=>X(e)===t.activeKey)??null;if(!n||n.type!==`terminal`){k.error(`Focus a terminal or agent to insert`);return}jt.write(n.session,`agent`,`\x1b[200~${e}\x1b[201~`)},[E]);(0,q.useEffect)(()=>(Ut(it),()=>Ut(null)),[it]);let at=(0,q.useRef)({}),ot=e=>{j?(d.update({sidebar_mode:e}),re(!0)):d.update({sidebar_mode:e,sidebar_collapsed:!1})};at.current={"tab.close":()=>{let e=E.focusedLeaf,t=e.tabs.find(t=>X(t)===e.activeKey);t&&Ye(e.id,t)},"sidebar.left":()=>j?re(e=>!e):d.update({sidebar_collapsed:!d.snapshot.sidebar_collapsed}),"sidebar.right":()=>j?N(e=>!e):d.update({sessions_collapsed:!d.snapshot.sessions_collapsed}),"nav.files":()=>ot(`files`),"nav.search":()=>ot(`search`),"nav.changes":()=>ot(`changes`),"nav.worktrees":()=>ot(`worktrees`),"session.newAgent":()=>he(`agent`),"session.newTerminal":()=>he(`terminal`)},(0,q.useEffect)(()=>{let e=Object.keys(at.current).map(e=>Pt(e,()=>at.current[e]?.()));return()=>e.forEach(e=>e())},[]);let st=E.activeEditorTab,ct=st?.kind===`diff`&&et&&st.session===et.id?st.path:null,lt=st&&(st.kind??`file`)===`file`&&et&&st.session===et.id?st.path:null,ut=e=>{et&&xe({kind:`diff`,session:et.id,path:e})},W=(e,t)=>{et&&xe({kind:`commit`,session:et.id,path:e,sha:t})},dt=(e,t)=>{et&&Se(et.id,e,t===void 0?void 0:{line:t,column:1})},ft=(0,q.useCallback)(e=>d.update({layout:{...d.snapshot.layout,...e}}),[d]),pt=wa(d.snapshot.layout,[...nt?[]:[`nav`],`main`,...rt?[]:[`sessions`]]);if(!a)return null;if(!d.loaded||!s.data||!H)return(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-fg-muted`,children:`…`});let mt=e=>(0,K.jsx)(mc,{mode:tt,onModeChange:e=>d.update({sidebar_mode:e}),onCollapse:e,projectId:r,repoId:s.data.project.repo_id,sessions:c,target:$e,onOpenFile:Ce,onOpenExternalFile:De,onOpenTerminalIn:we,activeFilePath:lt,activeDiffPath:ct,onOpenDiff:ut,onOpenCommitFile:W,onOpenSearchFile:dt}),ht=e=>(0,K.jsx)(jc,{groups:w,accounts:l,activeSessionId:o,onReorder:A,onPromote:e=>E.ensureTerminal(e),archived:T,onNewSession:()=>he(`agent`),onNewTerminal:()=>he(`terminal`),onCollapse:e,onArchived:Ge}),gt=(0,K.jsx)(`div`,{className:`flex h-full flex-col bg-ground`,children:(0,K.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,K.jsx)($d,{onDrop:E.drop,renderOverlay:e=>{let t=e.type===`terminal`?p.find(t=>t.id===e.session):void 0;return(0,K.jsx)(`div`,{className:`rounded-md bg-elevated px-2.5 py-1 text-xs font-mono text-fg shadow-lg`,children:e.type===`terminal`?t?u(t):e.session.slice(0,8):e.tab.path.split(`/`).pop()??e.tab.path})},children:(0,K.jsx)(mf,{tree:E.tree,sessions:p,reveal:ye,onActivateTab:Je,onCloseTab:Ye,onPromoteTab:Ee,onArchived:Ge,onFocusLeaf:E.focusLeaf,onResize:E.resize,onDropTab:Xe,onSetTabView:E.setView,onNewUntitled:Me})})})});return(0,K.jsx)(ba,{tree:E.tree,onOpenFile:(e,t,n,r)=>Se(e,t,n===void 0?void 0:{line:n,column:r}),children:(0,K.jsxs)(`div`,{className:`relative flex h-full`,children:[j?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(pc,{mode:tt,onExpand:()=>re(!0),onSelect:e=>{d.update({sidebar_mode:e}),re(!0)}}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:gt}),(0,K.jsx)(kc,{groups:w,accounts:l,activeSessionId:o,onReorder:A,onPromote:e=>E.ensureTerminal(e),onExpand:()=>N(!0),onNewTerminal:()=>he(`terminal`),onNewSession:()=>he(`agent`),onArchived:Ge}),ne&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,"aria-label":`Close the navigator`,className:`absolute inset-0 z-30 bg-ground/60`,onClick:()=>re(!1)}),(0,K.jsx)(`div`,{className:`absolute inset-y-0 left-9 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:mt(()=>re(!1))})]}),M&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,"aria-label":`Close the session list`,className:`absolute inset-0 z-30 bg-ground/60`,onClick:()=>N(!1)}),(0,K.jsx)(`div`,{className:`absolute inset-y-0 right-9 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:ht(()=>N(!1))})]})]}):(0,K.jsxs)(K.Fragment,{children:[nt&&(0,K.jsx)(pc,{mode:tt,onExpand:()=>d.update({sidebar_collapsed:!1}),onSelect:e=>d.update({sidebar_collapsed:!1,sidebar_mode:e})}),(0,K.jsxs)(Di,{orientation:`horizontal`,className:`h-full min-w-0 flex-1`,defaultLayout:pt,onLayoutChanged:ft,children:[!nt&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ai,{id:`nav`,defaultSize:280,minSize:200,maxSize:560,children:mt(()=>d.update({sidebar_collapsed:!0}))}),(0,K.jsx)(Ni,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`})]}),(0,K.jsx)(Ai,{id:`main`,children:gt}),!rt&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ni,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`}),(0,K.jsx)(Ai,{id:`sessions`,defaultSize:260,minSize:180,maxSize:480,children:ht(()=>d.update({sessions_collapsed:!0}))})]})]}),rt&&(0,K.jsx)(kc,{groups:w,accounts:l,activeSessionId:o,onReorder:A,onPromote:e=>E.ensureTerminal(e),onExpand:()=>d.update({sessions_collapsed:!1}),onNewTerminal:()=>he(`terminal`),onNewSession:()=>he(`agent`),onArchived:Ge})]}),(0,K.jsx)(hc,{projectId:r,repoId:s.data.project.repo_id,open:ae,kind:le,seedAccountId:de,onOpenChange:L,onCreated:e=>void t(`/project/${r}/session/${e.id}`)}),(0,K.jsx)(Pi,{request:Fe,targetSession:et,profileId:m,onClose:()=>Ie(null),onSaved:Ve}),(0,K.jsx)(ce,{open:Le!==null,onOpenChange:e=>!e&&ze(null),children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:`Discard this draft?`}),(0,K.jsx)(se,{children:`Closing an untitled tab deletes its draft — ⌘S saves it into the worktree instead.`})]}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{variant:`ghost`,onClick:()=>ze(null),children:`Keep editing`}),(0,K.jsx)(I,{variant:`danger`,onClick:Be,children:`Discard`})]})]})})]})})}export{Sf as Workspace};
7
+ `},hl={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function gl(e){let{announcements:t=hl,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=ml}=e,{announce:a,announcement:o}=ul(),s=Xc(`DndLiveRegion`),[c,l]=(0,q.useState)(!1);if((0,q.useEffect)(()=>{l(!0)},[]),fl((0,q.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=q.createElement(q.Fragment,null,q.createElement(cl,{id:r,value:i.draggable}),q.createElement(ll,{id:s,announcement:o}));return n?(0,Gi.createPortal)(u,n):u}var Z;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(Z||={});function _l(){}function vl(e,t){return(0,q.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function yl(){var e=[...arguments];return(0,q.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var bl=Object.freeze({x:0,y:0});function xl(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Sl(e,t){let n=rl(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function Cl(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function wl(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Tl(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function El(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Dl(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var Ol=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=Dl(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(wl)};function kl(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var Al=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&kl(r,a)){let n=Tl(a).reduce((e,t)=>e+xl(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(Cl)};function jl(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Ml(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:bl}function Nl(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var Pl=Nl(1);function Fl(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Il(e,t,n){let r=Fl(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var Ll={ignoreTransform:!1};function Rl(e,t){t===void 0&&(t=Ll);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=Lc(e).getComputedStyle(e);t&&(n=Il(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function zl(e){return Rl(e,{ignoreTransform:!0})}function Bl(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Vl(e,t){return t===void 0&&(t=Lc(e).getComputedStyle(e)),t.position===`fixed`}function Hl(e,t){t===void 0&&(t=Lc(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`&&n.test(r)})}function Ul(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Rc(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!zc(i)||Bc(i)||n.includes(i))return n;let a=Lc(e).getComputedStyle(i);return i!==e&&Hl(i,a)&&n.push(i),Vl(i,a)?n:r(i.parentNode)}return e?r(e):n}function Wl(e){let[t]=Ul(e,1);return t??null}function Gl(e){return!Pc||!e?null:Fc(e)?e:Ic(e)?Rc(e)||e===Vc(e).scrollingElement?window:zc(e)?e:null:null}function Kl(e){return Fc(e)?e.scrollX:e.scrollLeft}function ql(e){return Fc(e)?e.scrollY:e.scrollTop}function Jl(e){return{x:Kl(e),y:ql(e)}}var Q;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Q||={});function Yl(e){return!Pc||!e?!1:e===document.scrollingElement}function Xl(e){let t={x:0,y:0},n=Yl(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var Zl={x:.2,y:.2};function Ql(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Zl);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Xl(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Q.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Q.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Q.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Q.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function $l(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function eu(e){return e.reduce((e,t)=>Qc(e,Jl(t)),bl)}function tu(e){return e.reduce((e,t)=>e+Kl(t),0)}function nu(e){return e.reduce((e,t)=>e+ql(t),0)}function ru(e,t){if(t===void 0&&(t=Rl),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Wl(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var iu=[[`x`,[`left`,`right`],tu],[`y`,[`top`,`bottom`],nu]],au=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=Ul(t),r=eu(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of iu)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},ou=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function su(e){let{EventTarget:t}=Lc(e);return e instanceof t?e:Vc(e)}function cu(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t&&r>t.y}var lu;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(lu||={});function uu(e){e.preventDefault()}function du(e){e.stopPropagation()}var $;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})($||={});var fu={start:[$.Space,$.Enter],cancel:[$.Esc],end:[$.Space,$.Enter,$.Tab]},pu=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case $.Right:return{...n,x:n.x+25};case $.Left:return{...n,x:n.x-25};case $.Down:return{...n,y:n.y+25};case $.Up:return{...n,y:n.y-25}}},mu=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new ou(Vc(t)),this.windowListeners=new ou(Lc(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(lu.Resize,this.handleCancel),this.windowListeners.add(lu.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(lu.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&ru(n),t(bl)}handleKeyDown(e){if(tl(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=fu,coordinateGetter:a=pu,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:bl;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=$c(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Xl(n),p=$l(n),m={x:Math.min(i===$.Right?p.right-p.width/2:p.right,Math.max(i===$.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===$.Down?p.bottom-p.height/2:p.bottom,Math.max(i===$.Down?p.top:p.top+p.height/2,u.y))},h=i===$.Right&&!s||i===$.Left&&!c,g=i===$.Down&&!l||i===$.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===$.Right&&e<=d.x||i===$.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===$.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===$.Down&&e<=d.y||i===$.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===$.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Qc($c(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};mu.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=fu,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function hu(e){return!!(e&&`distance`in e)}function gu(e){return!!(e&&`delay`in e)}var _u=class{constructor(e,t,n){n===void 0&&(n=su(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=Vc(i),this.documentListeners=new ou(this.document),this.listeners=new ou(n),this.windowListeners=new ou(Lc(i)),this.initialCoordinates=rl(r)??bl,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(lu.Resize,this.handleCancel),this.windowListeners.add(lu.DragStart,uu),this.windowListeners.add(lu.VisibilityChange,this.handleCancel),this.windowListeners.add(lu.ContextMenu,uu),this.documentListeners.add(lu.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(gu(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(hu(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(lu.Click,du,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(lu.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=rl(e)??bl,s=$c(n,o);if(!t&&a){if(hu(a)){if(a.tolerance!=null&&cu(s,a.tolerance))return this.handleCancel();if(cu(s,a.distance))return this.handleStart()}if(gu(a)&&cu(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===$.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},vu={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},yu=class extends _u{constructor(e){let{event:t}=e,n=Vc(t.target);super(e,vu,n)}};yu.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var bu={move:{name:`mousemove`},end:{name:`mouseup`}},xu;(function(e){e[e.RightClick=2]=`RightClick`})(xu||={});var Su=class extends _u{constructor(e){super(e,bu,Vc(e.event.target))}};Su.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===xu.RightClick?!1:(r?.({event:n}),!0)}}];var Cu={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},wu=class extends _u{constructor(e){super(e,Cu)}static setup(){return window.addEventListener(Cu.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Cu.move.name,e)};function e(){}}};wu.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Tu;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Tu||={});var Eu;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Eu||={});function Du(e){let{acceleration:t,activator:n=Tu.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Eu.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=ku({delta:d,disabled:!a}),[m,h]=Wc(),g=(0,q.useRef)({x:0,y:0}),_=(0,q.useRef)({x:0,y:0}),v=(0,q.useMemo)(()=>{switch(n){case Tu.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Tu.DraggableRect:return i}},[n,i,c]),y=(0,q.useRef)(null),b=(0,q.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,q.useMemo)(()=>s===Eu.TreeOrder?[...l].reverse():l,[s,l]);(0,q.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=l.indexOf(e),i=u[n];if(!i)continue;let{direction:a,speed:s}=Ql(e,i,v,t,f);for(let e of[`x`,`y`])p[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){h(),y.current=e,m(b,o),g.current=s,_.current=a;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var Ou={x:{[Q.Backward]:!1,[Q.Forward]:!1},y:{[Q.Backward]:!1,[Q.Forward]:!1}};function ku(e){let{delta:t,disabled:n}=e,r=Jc(t);return Kc(e=>{if(n||!r||!e)return Ou;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Q.Backward]:e.x[Q.Backward]||i.x===-1,[Q.Forward]:e.x[Q.Forward]||i.x===1},y:{[Q.Backward]:e.y[Q.Backward]||i.y===-1,[Q.Forward]:e.y[Q.Forward]||i.y===1}}},[n,t,r])}function Au(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Kc(e=>t==null?null:r??e??null,[r,t])}function ju(e,t){return(0,q.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var Mu;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Mu||={});var Nu;(function(e){e.Optimized=`optimized`})(Nu||={});var Pu=new Map;function Fu(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,q.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,q.useRef)(e),d=g(),f=Gc(d),p=(0,q.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,q.useRef)(null),h=Kc(t=>{if(d&&!n)return Pu;if(!t||t===Pu||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new au(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,q.useEffect)(()=>{u.current=e},[e]),(0,q.useEffect)(()=>{d||p()},[n,d]),(0,q.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,q.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case Mu.Always:return!1;case Mu.BeforeDragging:return n;default:return!n}}}function Iu(e,t){return Kc(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Lu(e,t){return Iu(e,t)}function Ru(e){let{callback:t,disabled:n}=e,r=Uc(t),i=(0,q.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,q.useEffect)(()=>()=>i?.disconnect(),[i]),i}function zu(e){let{callback:t,disabled:n}=e,r=Uc(t),i=(0,q.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,q.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Bu(e){return new au(Rl(e),e)}function Vu(e,t,n){t===void 0&&(t=Bu);let[r,i]=(0,q.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=Ru({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=zu({callback:a});return Hc(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Hu(e){return Ml(e,Iu(e))}var Uu=[];function Wu(e){let t=(0,q.useRef)(e),n=Kc(n=>e?n&&n!==Uu&&e&&t.current&&e.parentNode===t.current.parentNode?n:Ul(e):Uu,[e]);return(0,q.useEffect)(()=>{t.current=e},[e]),n}function Gu(e){let[t,n]=(0,q.useState)(null),r=(0,q.useRef)(e),i=(0,q.useCallback)(e=>{let t=Gl(e.target);t&&n(e=>e?(e.set(t,Jl(t)),new Map(e)):null)},[]);return(0,q.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Gl(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Jl(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{Gl(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,q.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Qc(e,t),bl):eu(e):bl,[e,t])}function Ku(e,t){t===void 0&&(t=[]);let n=(0,q.useRef)(null);return(0,q.useEffect)(()=>{n.current=null},t),(0,q.useEffect)(()=>{let t=e!==bl;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?$c(e,n.current):bl}function qu(e){(0,q.useEffect)(()=>{if(!Pc)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Ju(e,t){return(0,q.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Yu(e){return(0,q.useMemo)(()=>e?Bl(e):null,[e])}var Xu=[];function Zu(e,t){t===void 0&&(t=Rl);let[n]=e,r=Yu(n?Lc(n):null),[i,a]=(0,q.useState)(Xu);function o(){a(()=>e.length?e.map(e=>Yl(e)?r:new au(t(e),e)):Xu)}let s=zu({callback:o});return Hc(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Qu(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return zc(t)?t:e}function $u(e){let{measure:t}=e,[n,r]=(0,q.useState)(null),i=zu({callback:(0,q.useCallback)(e=>{for(let{target:n}of e)if(zc(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=qc((0,q.useCallback)(e=>{let n=Qu(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,q.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var ed=[{sensor:yu,options:{}},{sensor:mu,options:{}}],td={current:{}},nd={draggable:{measure:zl},droppable:{measure:zl,strategy:Mu.WhileDragging,frequency:Nu.Optimized},dragOverlay:{measure:Rl}},rd=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},id={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new rd,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:_l},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:nd,measureDroppableContainers:_l,windowRect:null,measuringScheduled:!1},ad={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:_l,draggableNodes:new Map,over:null,measureDroppableContainers:_l},od=(0,q.createContext)(ad),sd=(0,q.createContext)(id);function cd(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new rd}}}function ld(e,t){switch(t.type){case Z.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Z.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Z.DragEnd:case Z.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Z.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new rd(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Z.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new rd(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Z.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new rd(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function ud(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,q.useContext)(od),a=Jc(r),o=Jc(n?.id);return(0,q.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!tl(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=ol(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function dd(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function fd(e){return(0,q.useMemo)(()=>({draggable:{...nd.draggable,...e?.draggable},droppable:{...nd.droppable,...e?.droppable},dragOverlay:{...nd.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function pd(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,q.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Hc(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=Ml(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=Wl(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var md=(0,q.createContext)({...bl,scaleX:1,scaleY:1}),hd;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(hd||={});var gd=(0,q.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=ed,collisionDetection:o=Ol,measuring:s,modifiers:c,...l}=e,[u,d]=(0,q.useReducer)(ld,void 0,cd),[f,p]=pl(),[m,h]=(0,q.useState)(hd.Uninitialized),g=m===hd.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,q.useRef)({initial:null,translated:null}),C=(0,q.useMemo)(()=>_==null?null:{id:_,data:x?.data??td,rect:S},[_,x]),w=(0,q.useRef)(null),[T,E]=(0,q.useState)(null),[D,O]=(0,q.useState)(null),k=Gc(l,Object.values(l)),ee=Xc(`DndDescribedBy`,t),A=(0,q.useMemo)(()=>b.getEnabled(),[b]),j=fd(s),{droppableRects:te,measureDroppableContainers:ne,measuringScheduled:re}=Fu(A,{dragging:g,dependencies:[y.x,y.y],config:j.droppable}),M=Au(v,_),N=(0,q.useMemo)(()=>D?rl(D):null,[D]),P=De(),ie=Lu(M,j.draggable.measure);pd({activeNode:_==null?null:v.get(_),config:P.layoutShiftCompensation,initialRect:ie,measure:j.draggable.measure});let F=Vu(M,j.draggable.measure,ie),I=Vu(M?M.parentElement:null),ae=(0,q.useRef)({activatorEvent:null,active:null,activeNode:M,collisionRect:null,collisions:null,droppableRects:te,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=b.getNodeFor(ae.current.over?.id),L=$u({measure:j.dragOverlay.measure}),R=L.nodeRef.current??M,z=g?L.rect??F:null,se=!!(L.nodeRef.current&&L.rect),ce=Hu(se?null:F),le=Yu(R?Lc(R):null),B=Wu(g?oe??M:null),ue=Zu(B),de=dd(c,{transform:{x:y.x-ce.x,y:y.y-ce.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:F,containerNodeRect:I,draggingNodeRect:z,over:ae.current.over,overlayNodeRect:L.rect,scrollableAncestors:B,scrollableAncestorRects:ue,windowRect:le}),fe=N?Qc(N,y):null,pe=Gu(B),me=Ku(pe),he=Ku(pe,[F]),V=Qc(de,me),ge=z?Pl(z,de):null,_e=C&&ge?o({active:C,collisionRect:ge,droppableRects:te,droppableContainers:A,pointerCoordinates:fe}):null,ve=El(_e,`id`),[ye,be]=(0,q.useState)(null),xe=jl(se?de:Qc(de,he),ye?.rect??null,F),Se=(0,q.useRef)(null),Ce=(0,q.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent,o=new n({active:w.current,activeNode:i,event:a,options:r,context:ae,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,Gi.unstable_batchedUpdates)(()=>{r?.(i),h(hd.Initializing),d({type:Z.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Se.current),O(a)})},onMove(e){d({type:Z.DragMove,coordinates:e})},onEnd:s(Z.DragEnd),onCancel:s(Z.DragCancel)});Se.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=ae.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Z.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Z.DragCancel)}w.current=null,(0,Gi.unstable_batchedUpdates)(()=>{d({type:e}),h(hd.Uninitialized),be(null),E(null),O(null),Se.current=null;let t=e===Z.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),we=ju(a,(0,q.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,Ce(n,t))},[v,Ce]));qu(a),Hc(()=>{F&&m===hd.Initializing&&h(hd.Initialized)},[F,m]),(0,q.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=ae.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:V.x,y:V.y},over:i};(0,Gi.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[V.x,V.y]),(0,q.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=ae.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(ve),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,Gi.unstable_batchedUpdates)(()=>{be(s),a?.(c),f({type:`onDragOver`,event:c})})},[ve]),Hc(()=>{ae.current={activatorEvent:D,active:C,activeNode:M,collisionRect:ge,collisions:_e,droppableRects:te,draggableNodes:v,draggingNode:R,draggingNodeRect:z,droppableContainers:b,over:ye,scrollableAncestors:B,scrollAdjustedTranslate:V},S.current={initial:z,translated:ge}},[C,M,_e,ge,v,R,z,te,b,ye,B,V]),Du({...P,delta:y,draggingRect:ge,pointerCoordinates:fe,scrollableAncestors:B,scrollableAncestorRects:ue});let Te=(0,q.useMemo)(()=>({active:C,activeNode:M,activeNodeRect:F,activatorEvent:D,collisions:_e,containerNodeRect:I,dragOverlay:L,draggableNodes:v,droppableContainers:b,droppableRects:te,over:ye,measureDroppableContainers:ne,scrollableAncestors:B,scrollableAncestorRects:ue,measuringConfiguration:j,measuringScheduled:re,windowRect:le}),[C,M,F,D,_e,I,L,v,b,te,ye,ne,B,ue,j,re,le]),Ee=(0,q.useMemo)(()=>({activatorEvent:D,activators:we,active:C,activeNodeRect:F,ariaDescribedById:{draggable:ee},dispatch:d,draggableNodes:v,over:ye,measureDroppableContainers:ne}),[D,we,C,F,d,ee,v,ye,ne]);return q.createElement(dl.Provider,{value:p},q.createElement(od.Provider,{value:Ee},q.createElement(sd.Provider,{value:Te},q.createElement(md.Provider,{value:xe},i)),q.createElement(ud,{disabled:n?.restoreFocus===!1})),q.createElement(gl,{...n,hiddenTextDescribedById:ee}));function De(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),_d=(0,q.createContext)(null),vd=`button`,yd=`Draggable`;function bd(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Xc(yd),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,q.useContext)(od),{role:p=vd,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,q.useContext)(g?md:_d),[v,y]=qc(),[b,x]=qc(),S=Ju(o,t),C=Gc(n);return Hc(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,q.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===vd?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function xd(){return(0,q.useContext)(sd)}var Sd=`Droppable`,Cd={timeout:25};function wd(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Xc(Sd),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,q.useContext)(od),u=(0,q.useRef)({disabled:n}),d=(0,q.useRef)(!1),f=(0,q.useRef)(null),p=(0,q.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Cd,...i},_=Gc(h??r),v=zu({callback:(0,q.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=qc((0,q.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Gc(t);return(0,q.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,q.useEffect)(()=>(s({type:Z.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:Z.UnregisterDroppable,key:a,id:r})),[r]),(0,q.useEffect)(()=>{n!==u.current.disabled&&(s({type:Z.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function Td(e){let{animation:t,children:n}=e,[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(null),s=Jc(n);return!n&&!r&&s&&i(s),Hc(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),q.createElement(q.Fragment,null,n,r?(0,q.cloneElement)(r,{ref:o}):null)}var Ed={x:0,y:0,scaleX:1,scaleY:1};function Dd(e){let{children:t}=e;return q.createElement(od.Provider,{value:ad},q.createElement(md.Provider,{value:Ed},t))}var Od={position:`fixed`,touchAction:`none`},kd=e=>tl(e)?`transform 250ms ease`:void 0,Ad=(0,q.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=kd}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Od,width:s.width,height:s.height,top:s.top,left:s.left,transform:il.Transform.toString(d),transformOrigin:i&&r?Sl(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return q.createElement(n,{className:o,style:f,ref:t},a)}),jd={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:il.Transform.toString(t)},{transform:il.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function Md(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return Uc((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=Qu(a);if(!c)return;let{transform:l}=Lc(a).getComputedStyle(a),u=Fl(l);if(!u)return;let d=typeof t==`function`?t:Nd(t);return ru(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function Nd(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...jd,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var Pd=0;function Fd(e){return(0,q.useMemo)(()=>{if(e!=null)return Pd++,Pd},[e])}var Id=q.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=xd(),S=(0,q.useContext)(md),C=Fd(d?.id),w=dd(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=Iu(f),E=Md({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return q.createElement(Dd,null,q.createElement(Td,{animation:E},d&&C?q.createElement(Ad,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))});function Ld({className:e}){return(0,K.jsx)(`svg`,{viewBox:`0 0 2000 2000`,fill:`none`,"aria-hidden":`true`,className:e,children:(0,K.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:110,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`line`,{x1:`491.66`,y1:`1916.78`,x2:`1558.47`,y2:`83.22`}),(0,K.jsx)(`path`,{d:`M491.66,1916.78c-329.28-191.58-441.36-613.07-250.32-941.41,191.04-328.34,612.84-439.21,942.13-247.62`}),(0,K.jsx)(`path`,{d:`M1558.47,83.22c279.53,162.64,376.25,517.72,216.03,793.09-160.22,275.38-516.71,366.77-796.24,204.13`}),(0,K.jsx)(`path`,{d:`M497.55,1881.96c-222.81-129.63-298.64-414.83-169.38-637,129.26-222.17,414.67-297.19,637.48-167.55`})]})})}var Rd=[`running`,`waiting_input`];function zd({sessionId:e,status:t}){let n=Rd.includes(t),{data:r}=B(e,n),i=r?.vars??[];return!n||i.length===0?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1 font-mono text-xs`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:`env`}),(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:i.map(e=>(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsx)(`span`,{className:`cursor-default rounded px-1.5 py-0.5 text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,children:e.name})}),(0,K.jsxs)(Gt,{children:[e.bytes,` B · captured from this session's shell — re-injected into new shells and agent restarts`]})]},e.name))})]})}function Bd(e,t,n){return`ssh -L ${e}:127.0.0.1:${e} ${t}@${n}`}var Vd=[`running`,`waiting_input`];function Hd({sessionId:e,status:t}){let n=Vd.includes(t),{data:r}=we(e,n),i=r?.ports??[];return!n||i.length===0?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1 font-mono text-xs`,children:[(0,K.jsx)(`span`,{className:`text-fg-muted`,children:`ports`}),(0,K.jsx)(`div`,{className:`flex items-center gap-1`,children:i.map(t=>(0,K.jsx)(Ud,{sessionId:e,port:t},t.port))})]})}function Ud({sessionId:e,port:t}){let n=V().data;return(0,K.jsxs)($s,{children:[(0,K.jsxs)(Zt,{children:[(0,K.jsx)(Jt,{asChild:!0,children:(0,K.jsx)(ec,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,className:`cursor-pointer rounded px-1.5 py-0.5 tabular-nums text-fg-secondary outline-none transition-colors hover:bg-elevated hover:text-fg focus-visible:bg-elevated focus-visible:text-fg`,children:t.port})})}),(0,K.jsxs)(Gt,{children:[t.command,` · pid `,t.pid]})]}),(0,K.jsxs)(nc,{align:`start`,children:[tn()===null?(0,K.jsx)(rc,{asChild:!0,children:(0,K.jsx)(`a`,{href:`http://localhost:${t.port}`,target:`_blank`,rel:`noopener noreferrer`,children:`Open localhost`})}):(0,K.jsx)(rc,{onSelect:()=>{window.open(`/proxy/${e}/${t.port}/?puddle_token=${re.get()??``}`,`_blank`,`noopener,noreferrer`)},children:`Open via proxy`}),(0,K.jsx)(rc,{onSelect:()=>{n&&navigator.clipboard.writeText(Bd(t.port,n.username,n.hostname)).then(()=>k.success(`Copied`))},children:`Copy ssh -L`})]})]})}function Wd(e,t,n=.25){if(e.width<=0||e.height<=0)return`center`;let r=Gd(t.x/e.width),i=Gd(t.y/e.height);if(r>n&&r<1-n&&i>n&&i<1-n)return`center`;let a=r,o=1-r,s=i,c=1-i,l=Math.min(a,o,s,c);return l===s?`top`:l===c?`bottom`:l===a?`left`:`right`}function Gd(e){return e<0?0:e>1?1:e}var Kd=[`interrupted`,`exited`];function qd({session:e}){let t=_e(`resume`);return Kd.includes(e.status)&&!e.worktree_missing?(0,K.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 right-3 z-10`,children:(0,K.jsxs)(I,{size:`sm`,className:`pointer-events-auto`,disabled:t.isPending,onClick:()=>t.mutate(e.id,{onError:e=>Re(e)}),children:[(0,K.jsx)(Pn,{}),`Resume`]})}):null}var Jd=(0,q.createContext)(null);function Yd(){return(0,q.useContext)(Jd)}var Xd=`leaf:`,Zd=`tabdrop:`,Qd=`strip:`,$d=e=>{let t=Al(e);for(let e of[Zd,Qd]){let n=t.filter(t=>String(t.id).startsWith(e));if(n.length>0)return n}return t.length>0?t:Ol(e)};function ef({onDrop:e,renderOverlay:t,children:n}){let r=yl(vl(yu,{activationConstraint:{distance:4}})),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(null),c=(0,q.useRef)(null),l=()=>{a(null),s(null),c.current=null};return(0,K.jsxs)(gd,{sensors:r,collisionDetection:$d,onDragStart:e=>s(e.active.data.current?.ref??null),onDragMove:e=>{let t=e.over,n=tf(e),r=t&&n?rf(String(t.id),t.rect,t.data.current,n):null;nf(c.current,r)||(c.current=r,a(r))},onDragEnd:t=>{let n=c.current,r=t.active.data.current?.ref,i=t.active.data.current?.fromLeafId;l(),n&&r&&i&&e({ref:r,fromLeafId:i,toLeafId:n.leafId,edge:n.zone,index:n.index})},onDragCancel:l,children:[(0,K.jsx)(Jd.Provider,{value:i,children:n}),(0,K.jsx)(Id,{dropAnimation:null,children:o?t(o):null})]})}function tf(e){let t=e.activatorEvent;return typeof t.clientX!=`number`||typeof t.clientY!=`number`?null:{x:t.clientX+e.delta.x,y:t.clientY+e.delta.y}}function nf(e,t){return e===null||t===null?e===t:e.leafId===t.leafId&&e.zone===t.zone&&e.index===t.index}function rf(e,t,n,r){if(e.startsWith(Zd)){let e=n;if(!e)return null;let i=r.x>t.left+t.width/2;return{leafId:e.leafId,zone:`center`,index:e.index+ +!!i}}if(e.startsWith(Qd)){let e=n;return e?{leafId:e.leafId,zone:`center`,index:e.count}:null}if(e.startsWith(Xd)){let n=Wd({width:t.width,height:t.height},{x:r.x-t.left,y:r.y-t.top});return{leafId:e.slice(5),zone:n}}return null}var af=`group relative flex min-w-16 max-w-52 cursor-pointer items-center gap-1.5 rounded-t-md px-2.5 text-xs transition-colors`;function of({leaf:e,sessions:t,onActivate:n,onClose:r,onPromote:i,onArchived:a,onSetView:o,onNewFile:s}){let c=new Map(t.map(e=>[e.id,e.branch])),l=e.tabs.flatMap(e=>e.type===`editor`?[e.tab]:[]),u=Yd(),d=u?.leafId===e.id&&u.index!==void 0?u.index:null,{setNodeRef:f}=wd({id:`strip:${e.id}`,data:{leafId:e.id,count:e.tabs.length}}),p=e=>{let t=en(e.path,e.session,l,c);return y(e)===`diff`?`${t} (diff)`:y(e)===`commit`?`${t} @${(e.sha??``).slice(0,7)}`:t};return(0,K.jsxs)(`div`,{ref:f,className:`flex h-9 shrink-0 items-stretch gap-0.5 overflow-x-auto bg-surface px-1 pt-1`,onDoubleClick:e=>{e.target===e.currentTarget&&s()},children:[e.tabs.map((s,c)=>(0,K.jsxs)(q.Fragment,{children:[d===c&&(0,K.jsx)(sf,{}),(0,K.jsx)(uf,{tab:s,leafId:e.id,index:c,active:X(s)===e.activeKey,preview:X(s)===e.previewKey,session:s.type===`terminal`?t.find(e=>e.id===s.session):void 0,label:s.type===`editor`?p(s.tab):``,onActivate:()=>n(s),onClose:()=>r(s),onPromote:()=>i(s),onArchived:a,onSetView:e=>o(s,e)})]},X(s))),d===e.tabs.length&&(0,K.jsx)(sf,{})]})}function sf(){return(0,K.jsx)(`div`,{className:`w-0.5 shrink-0 self-stretch rounded-full bg-accent`})}function cf({active:e,children:t}){return(0,K.jsx)(`span`,{className:H(`pointer-events-none absolute inset-y-0 right-0 flex items-center gap-1 pl-5 pr-2.5`,`[&>*]:pointer-events-auto`,e?`group-hover:bg-[linear-gradient(to_right,transparent,var(--color-ground)_1.25rem)]`:`group-hover:bg-[linear-gradient(to_right,transparent,var(--color-elevated)_1.25rem)]`),children:t})}function lf({view:e,onSetView:t}){let n=e===`preview`;return(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),t(n?`source`:`preview`)},className:`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg group-hover:inline-flex pointer-coarse:inline-flex`,"aria-label":n?`Show source`:`Show preview`,title:n?`Show source`:`Show preview`,children:n?(0,K.jsx)(G,{className:`size-3`}):(0,K.jsx)(ln,{className:`size-3`})})}function uf({tab:e,leafId:t,index:n,active:r,preview:i,session:a,label:o,onActivate:s,onClose:c,onPromote:l,onArchived:u,onSetView:d}){let f=Ot(),p=X(e),{attributes:m,listeners:h,setNodeRef:g,isDragging:_}=bd({id:`drag:${t}:${p}`,data:{ref:e,fromLeafId:t}}),{setNodeRef:v}=wd({id:`tabdrop:${t}:${p}`,data:{leafId:t,index:n}}),b=e=>{g(e),v(e)},S=H(af,r?`bg-ground text-fg`:`text-fg-secondary hover:bg-elevated`,i&&`italic`,_&&`opacity-40`),C=(0,K.jsx)(`div`,{ref:b,...m,...h,onClick:s,onDoubleClick:l,className:S,children:e.type===`terminal`?(0,K.jsxs)(K.Fragment,{children:[a&&(0,K.jsx)(gc,{status:a.status,kind:a.kind,agentType:a.agent_type,stale:a.stale_running}),(0,K.jsx)(`span`,{className:`truncate font-mono`,children:a?f(a):e.session.slice(0,8)}),(0,K.jsx)(cf,{active:r,children:(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),c()},className:`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg group-hover:inline-flex pointer-coarse:inline-flex`,"aria-label":`Close tab`,children:(0,K.jsx)(ae,{className:`size-3`})})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`truncate font-mono`,children:o}),(0,K.jsxs)(cf,{active:r,children:[y(e.tab)===`file`&&x(e.tab.path)!==null&&(0,K.jsx)(lf,{view:e.tab.view??`source`,onSetView:d}),(0,K.jsx)(Wi,{session:e.tab.session,path:e.tab.path,kind:y(e.tab),root:e.tab.root,label:o,onClose:c})]})]})});return e.type===`terminal`&&a?(0,K.jsx)(Tc,{session:a,onArchived:()=>u(e.session),children:C}):C}function df({leaf:e,sessions:t,reveal:n,onActivateTab:r,onCloseTab:i,onPromoteTab:a,onArchived:o,onFocusLeaf:s,onDropTab:c,onSetTabView:l,onNewUntitled:u}){let d=e.tabs.find(t=>X(t)===e.activeKey)??null,f=d?.type===`terminal`?X(d):null,p=d?.type===`terminal`?t.find(e=>e.id===d.session)??null:null,m=xa(f),{setNodeRef:h}=wd({id:`leaf:${e.id}`}),g=Yd(),_=(0,q.useRef)(null),v=(0,q.useRef)(()=>void 0);v.current=()=>{d&&r(e.id,d)},(0,q.useEffect)(()=>{let e=_.current;if(!e)return;let t=()=>v.current();return e.addEventListener(`mousedown`,t,!0),()=>e.removeEventListener(`mousedown`,t,!0)},[]);let[y,b]=(0,q.useState)(null),x=e=>{let t=e.currentTarget.getBoundingClientRect();return Wd({width:t.width,height:t.height},{x:e.clientX-t.left,y:e.clientY-t.top})};return(0,K.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,onMouseDownCapture:()=>s(e.id),children:[e.tabs.length>0&&(0,K.jsx)(of,{leaf:e,sessions:t,onActivate:t=>r(e.id,t),onClose:t=>i(e.id,t),onPromote:a,onArchived:o,onSetView:l,onNewFile:()=>u(e)}),(0,K.jsxs)(`div`,{ref:e=>{_.current=e,h(e)},className:`relative min-h-0 flex-1`,onDragOver:e=>{Lo(e.dataTransfer.types)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,b(x(e)))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||b(null)},onDrop:t=>{if(!Lo(t.dataTransfer.types))return;t.preventDefault(),b(null);let n=Io(t.dataTransfer.getData(Po));n&&c(e.id,n,x(t))},children:[d?.type===`editor`&&(0,K.jsx)(`div`,{className:`absolute inset-0`,children:(0,K.jsx)(Bi,{tab:d.tab,reveal:n})}),(0,K.jsx)(`div`,{ref:m,className:H(`absolute inset-0 py-1 pl-4 pr-2`,!f&&`hidden`)}),g?.leafId===e.id&&g.index===void 0&&(0,K.jsx)(pf,{zone:g.zone}),y!==null&&(0,K.jsx)(pf,{zone:y}),p&&(0,K.jsx)(qd,{session:p}),!d&&(0,K.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-6 text-center`,children:[(0,K.jsx)(Ld,{className:`size-24 text-fg-muted/40`}),(0,K.jsx)(`button`,{type:`button`,onClick:Dt,className:`rounded-md bg-elevated px-3 py-1.5 font-mono text-xs text-fg-muted transition-colors hover:bg-border hover:text-fg-secondary`,children:`⌘K`})]})]}),p&&(0,K.jsx)(zd,{sessionId:p.id,status:p.status}),p&&(0,K.jsx)(Hd,{sessionId:p.id,status:p.status})]})}var ff={center:`inset-0`,left:`inset-y-0 left-0 w-1/2`,right:`inset-y-0 right-0 w-1/2`,top:`inset-x-0 top-0 h-1/2`,bottom:`inset-x-0 bottom-0 h-1/2`};function pf({zone:e}){return(0,K.jsx)(`div`,{className:H(`pointer-events-none absolute z-20 bg-accent/20`,ff[e])})}var mf=`bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`;function hf({tree:e,...t}){let n=(0,q.useMemo)(()=>{let t=new Set,n=[];for(let r of ea(e)){if(r.type!==`editor`||![`file`,`diff`].includes(y(r.tab)))continue;let e=`${r.tab.session}${r.tab.path}`;t.has(e)||(t.add(e),n.push({session:r.tab.session,path:r.tab.path}))}return n},[e]);return(0,K.jsxs)(K.Fragment,{children:[n.length>0&&(0,K.jsx)(Hi,{buffers:n}),(0,K.jsx)(gf,{node:e,...t})]})}function gf({node:e,...t}){if(e.kind===`leaf`)return(0,K.jsx)(df,{leaf:e,sessions:t.sessions,reveal:t.reveal,onActivateTab:t.onActivateTab,onCloseTab:t.onCloseTab,onPromoteTab:t.onPromoteTab,onArchived:t.onArchived,onFocusLeaf:t.onFocusLeaf,onDropTab:t.onDropTab,onSetTabView:t.onSetTabView,onNewUntitled:t.onNewUntitled});let n=e.direction===`row`?`horizontal`:`vertical`;return(0,K.jsx)(Di,{orientation:n,className:`size-full`,defaultLayout:Object.fromEntries(e.children.map((t,n)=>[t.id,e.sizes[n]??100/e.children.length])),onLayoutChanged:n=>t.onResize(e.id,e.children.map(e=>n[e.id]??0)),children:e.children.map((e,r)=>(0,K.jsxs)(q.Fragment,{children:[r>0&&(0,K.jsx)(Ni,{className:n===`horizontal`?`w-px ${mf}`:`h-px ${mf}`}),(0,K.jsx)(Ai,{id:e.id,minSize:64,children:(0,K.jsx)(gf,{node:e,...t})})]},e.id))},e.id)}function _f(e){let t=e.snapshot,n=(0,q.useRef)(null);!t.layout_tree&&!n.current&&(n.current=va(t));let r=t.layout_tree??n.current??Yi([]),i=(0,q.useCallback)(t=>e.update({layout_tree:t}),[e]),a=(0,q.useRef)(i);a.current=i;let o=(0,q.useRef)(!1);(0,q.useEffect)(()=>{o.current||e.loaded&&!t.layout_tree&&n.current&&(o.current=!0,ea(n.current).length>0&&a.current(n.current))},[e.loaded,t.layout_tree]);let[s,c]=(0,q.useState)(null),l=(s?Zi(r,s):null)??$i(r)[0]??Yi([]),u=l.tabs.find(e=>X(e)===l.activeKey)??null,d=u?.type===`editor`?u.tab:null;return(0,q.useMemo)(()=>({tree:r,focusedLeaf:l,activeEditorTab:d,focusLeaf:e=>c(e),activate:(e,t)=>{c(e);let n=X(t),a=Zi(r,e);a&&a.activeKey===n||i(ha(r,e,n))},close:(e,t)=>i(ua(r,e,X(t))),openEditor:(e,t)=>{let n=l.id;c(n);let a={type:`editor`,tab:e};i(t?.preview?fa(r,n,a):da(r,n,a))},ensureTerminal:(e,t)=>{let n=`term:${e}`,a=Qi(r,n);if(a){c(a.id);let e=a.activeKey!==n,o=!t?.preview&&a.previewKey===n;if(e||o){let t=r;e&&(t=ha(t,a.id,n)),o&&(t=pa(t,n)),i(t)}}else{let n=l.id;c(n);let a={type:`terminal`,session:e};i(t?.preview?fa(r,n,a):da(r,n,a))}},promote:e=>i(pa(r,X(e))),setView:(e,t)=>i(ma(r,X(e),t)),removeTerminal:e=>{let t=Qi(r,`term:${e}`);t&&i(ua(r,t.id,`term:${e}`))},pruneSessions:e=>i(_a(r,t=>t.type===`terminal`?e.has(t.session):e.has(t.tab.session))),resize:(e,t)=>i(ga(r,e,t)),drop:e=>{c(e.toLeafId),i(ca(r,e))}}),[r,l,d,i])}var vf=2e3,yf=ne.parse({});function bf(e){return`puddle.ws.${e}`}function xf(e){if(e===null)return{kind:`absent`};try{return{kind:`present`,snapshot:ne.parse(JSON.parse(e))}}catch{return{kind:`corrupt`}}}function Sf(){let e=a(),[t,n]=(0,q.useState)(!1),[r,i]=(0,q.useState)(yf),o=(0,q.useRef)(r);o.current=r;let s=(0,q.useRef)(null),c=(0,q.useMemo)(()=>$t((e,t)=>{Ve(e,t).catch(e=>console.warn(`ui-state save failed: ${e.message}`))},vf),[]);return(0,q.useEffect)(()=>{if(e===null){s.current=null;return}let t=bf(e);s.current=t;let r=!1;n(!1),i(yf);let a;try{a=xf(sessionStorage.getItem(t)),a.kind===`corrupt`&&sessionStorage.removeItem(t)}catch(e){console.warn(`ui-state read failed: ${e.message}`),a={kind:`absent`}}return a.kind===`present`?(i(a.snapshot),n(!0)):Se(e).then(e=>{r||(e&&i(e.ui_state),n(!0))}).catch(e=>{console.warn(`ui-state load failed: ${e.message}`),r||n(!0)}),()=>{r=!0,c.flush()}},[e,c]),{loaded:t,snapshot:r,update(t){if(e===null)return;let n={...o.current,...t};o.current=n,i(n);let r=s.current??bf(e);c(e,n);try{sessionStorage.setItem(r,JSON.stringify(n))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}}}}function Cf(){return(0,K.jsx)(p,{children:(0,K.jsx)(wf,{})})}function wf(){let e=Kt(),t=Ht(),n=ue(),r=e.id??``,a=/^[0-9a-f]{10}$/.test(r),o=e.sid??null,s=ve(a?r:void 0),c=(0,q.useMemo)(()=>s.data?.sessions??[],[s.data]),l=Te(s.data?.project.profile_id).data??[],u=Ot(),d=Sf(),f=Ne(),p=f.data??c,m=s.data?.project.profile_id,v=Rt().showAllProjectSessions,x=fe(v?m:void 0),C=pe(v?m:void 0),w=(0,q.useMemo)(()=>{let e=e=>e.status!==`archived`;if(!v)return[{projectId:r,name:null,sessions:qe(c.filter(e),d.snapshot.session_order)}];let t=qe((x.data??[]).filter(e=>!e.archived),C.data?.projectOrder??[]),n=f.data??c;return t.map(t=>({projectId:t.id,name:t.name,sessions:qe(n.filter(n=>n.project_id===t.id&&e(n)),d.snapshot.session_order)}))},[v,c,r,d.snapshot.session_order,x.data,C.data,f.data]),T=(0,q.useMemo)(()=>c.filter(e=>e.status===`archived`),[c]),E=_f(d),D=(0,q.useRef)(E);D.current=E;let O=(0,q.useRef)(d);O.current=d;let A=(0,q.useCallback)(e=>O.current.update({session_order:Ke(e,O.current.snapshot.session_order)}),[]),j=Sa(Ca),te=(0,q.useRef)(j);te.current=j;let[ne,re]=(0,q.useState)(!1),[M,N]=(0,q.useState)(!1),[P,F]=(0,q.useState)(!1),[ae,L]=(0,q.useState)(!1),[le,B]=(0,q.useState)(`agent`),[de,me]=(0,q.useState)(void 0),he=(0,q.useCallback)((e=`agent`)=>{me(void 0),B(e),L(!0)},[]),ge=(0,q.useRef)(null),{setHandler:_e}=Qt(),[ye,be]=(0,q.useState)(null),xe=(0,q.useCallback)((e,t,n)=>{E.openEditor(e,{preview:n?.preview}),te.current&&re(!1),t&&(e.kind??`file`)===`file`&&be({session:e.session,path:e.path,line:t.line,column:t.column,nonce:Date.now()})},[E]),Se=(0,q.useCallback)((e,t,n,r)=>xe({kind:`file`,session:e,path:t,...r?.view?{view:r.view}:{}},n,r),[xe]);S(Se);let Ce=(0,q.useCallback)((e,t,n)=>Se(e,t,void 0,{preview:n?.preview??!0}),[Se]),we=(0,q.useCallback)((e,r)=>{let i=c.find(t=>t.id===e);i&&n.mutate({project_id:i.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:i.worktree_path,cwd:r},{onSuccess:e=>void t(`/project/${e.project_id}/session/${e.id}`),onError:e=>Re(e)})},[c,n,t]),Ee=(0,q.useCallback)(e=>E.promote(e),[E]),De=(0,q.useCallback)((e,t,n,r)=>xe({kind:`external`,session:e,path:t,root:n},void 0,{preview:r?.preview??!0}),[xe]),Oe=i(),ke=He().data?.protocol,Ae=!ke||ke.major>10||ke.major===10&&ke.minor>=3,Me=(0,q.useCallback)(e=>{if(m!==void 0){if(!Ae){k.error(`Untitled drafts need a newer daemon — refresh the connection to update it`);return}_(m).then(({name:e})=>xe({kind:`untitled`,session:ee,path:e})).catch(e=>k.error(e instanceof Error?e.message:`Could not create a draft`))}},[xe,m,Ae]),[Fe,Ie]=(0,q.useState)(null);(0,q.useEffect)(()=>(g(Ie),()=>g(null)),[]);let[Le,ze]=(0,q.useState)(null),Be=()=>{let e=Le;if(ze(null),!e||e.ref.type!==`editor`)return;let t=e.ref.tab.path;m!==void 0&&b(m,t).catch(()=>void 0),h(t),E.close(e.leafId,e.ref)},Ve=(e,t,n)=>{Ie(null);let r={type:`editor`,tab:{kind:`untitled`,session:ee,path:e}},i=X(r);for(let e of $i(D.current.tree))e.tabs.some(e=>X(e)===i)&&D.current.close(e.id,r);Oe.invalidateQueries({queryKey:[`wt-tree`,t]}),setTimeout(()=>{D.current.openEditor({kind:`file`,session:t,path:n})},0)};(0,q.useEffect)(()=>(_e(e=>{me(e?.accountId),B(e?.kind??`agent`),L(!0)}),()=>_e(null)),[_e]);let[H,U]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!d.loaded||H)return;let e=ea(D.current.tree);Promise.all([e.some(e=>e.type===`terminal`)?Pe():void 0,e.some(e=>e.type===`editor`)?Ri():void 0]).finally(()=>U(!0))},[d.loaded,H]),(0,q.useEffect)(()=>{if(P||!d.loaded||!s.data)return;F(!0);let e=d.snapshot.active_session,n=c.find(t=>t.id===e);!o&&n&&n.status!==`archived`&&t(`/project/${r}/session/${n.id}`,{replace:!0})},[P,d,s.data,c,o,t,r]);let Ue=(0,q.useRef)(!1);(0,q.useEffect)(()=>{if(Ue.current||!d.loaded||!f.data)return;Ue.current=!0;let e=new Set(f.data.filter(e=>e.status!==`archived`).map(e=>e.id));D.current.pruneSessions(e);let t=O.current.snapshot.session_order,n=t.filter(t=>e.has(t));n.length!==t.length&&O.current.update({session_order:n})},[d.loaded,f.data]),(0,q.useEffect)(()=>{if(!P)return;if(N(!1),!o){ge.current=null;return}if(o===ge.current)return;ge.current=null,D.current.ensureTerminal(o,{preview:!0});let e=O.current;e.snapshot.active_session!==o&&e.update({active_session:o})},[P,o]);let We=V();(0,q.useEffect)(()=>{let e=je(We.data)??`puddle`,t=c.filter(e=>e.status===`waiting_input`).length,n=s.data?.project.name??`puddle`;return document.title=t>0?`● ${t} waiting — ${n}`:`${n} — ${e}`,()=>{document.title=e}},[c,s.data?.project.name,We.data]);let Ge=(0,q.useCallback)(e=>{let n=o===e;n&&(ge.current=e),E.removeTerminal(e),n&&(d.update({active_session:null}),t(`/project/${r}`))},[E,d,o,t,r]),Je=(0,q.useCallback)((e,n)=>{if(E.activate(e,n),n.type===`terminal`&&n.session!==o){let e=p.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[E,t,p,o]),Ye=(0,q.useCallback)((e,n)=>{if(n.type===`editor`&&y(n.tab)===`untitled`){ze({leafId:e,ref:n});return}E.close(e,n),n.type===`terminal`&&n.session===o&&(ge.current=n.session,d.update({active_session:null}),t(`/project/${r}`))},[E,o,d,t,r]),Xe=(0,q.useCallback)((e,n,r)=>{if(E.drop({ref:n,fromLeafId:e,toLeafId:e,edge:r}),n.type===`terminal`&&n.session!==o){let e=p.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[E,o,p,t]),Ze=E.focusedLeaf.tabs.find(e=>X(e)===E.focusedLeaf.activeKey)??null,Qe=Ze===null?null:Ze.type===`terminal`?Ze.session:Ze.tab.session,$e=Fi(p,(Qe===`00000000-0000-0000-0000-000000000000`?null:Qe)??o,d),et=$e.session,tt=fc(d.snapshot.sidebar_mode),nt=d.snapshot.sidebar_collapsed,rt=d.snapshot.sessions_collapsed,it=(0,q.useCallback)(e=>{let t=E.focusedLeaf,n=t.tabs.find(e=>X(e)===t.activeKey)??null;if(!n||n.type!==`terminal`){k.error(`Focus a terminal or agent to insert`);return}jt.write(n.session,`agent`,`\x1b[200~${e}\x1b[201~`)},[E]);(0,q.useEffect)(()=>(Ut(it),()=>Ut(null)),[it]);let at=(0,q.useRef)({}),ot=e=>{j?(d.update({sidebar_mode:e}),re(!0)):d.update({sidebar_mode:e,sidebar_collapsed:!1})};at.current={"tab.close":()=>{let e=E.focusedLeaf,t=e.tabs.find(t=>X(t)===e.activeKey);t&&Ye(e.id,t)},"sidebar.left":()=>j?re(e=>!e):d.update({sidebar_collapsed:!d.snapshot.sidebar_collapsed}),"sidebar.right":()=>j?N(e=>!e):d.update({sessions_collapsed:!d.snapshot.sessions_collapsed}),"nav.files":()=>ot(`files`),"nav.search":()=>ot(`search`),"nav.changes":()=>ot(`changes`),"nav.worktrees":()=>ot(`worktrees`),"session.newAgent":()=>he(`agent`),"session.newTerminal":()=>he(`terminal`)},(0,q.useEffect)(()=>{let e=Object.keys(at.current).map(e=>Pt(e,()=>at.current[e]?.()));return()=>e.forEach(e=>e())},[]);let st=E.activeEditorTab,ct=st?.kind===`diff`&&et&&st.session===et.id?st.path:null,lt=st&&(st.kind??`file`)===`file`&&et&&st.session===et.id?st.path:null,ut=e=>{et&&xe({kind:`diff`,session:et.id,path:e})},W=(e,t)=>{et&&xe({kind:`commit`,session:et.id,path:e,sha:t})},dt=(e,t)=>{et&&Se(et.id,e,t===void 0?void 0:{line:t,column:1})},ft=(0,q.useCallback)(e=>d.update({layout:{...d.snapshot.layout,...e}}),[d]),pt=wa(d.snapshot.layout,[...nt?[]:[`nav`],`main`,...rt?[]:[`sessions`]]);if(!a)return null;if(!d.loaded||!s.data||!H)return(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-fg-muted`,children:`…`});let mt=e=>(0,K.jsx)(mc,{mode:tt,onModeChange:e=>d.update({sidebar_mode:e}),onCollapse:e,projectId:r,repoId:s.data.project.repo_id,sessions:c,target:$e,onOpenFile:Ce,onOpenExternalFile:De,onOpenTerminalIn:we,activeFilePath:lt,activeDiffPath:ct,onOpenDiff:ut,onOpenCommitFile:W,onOpenSearchFile:dt}),ht=e=>(0,K.jsx)(Mc,{groups:w,accounts:l,activeSessionId:o,onReorder:A,onPromote:e=>E.ensureTerminal(e),archived:T,onNewSession:()=>he(`agent`),onNewTerminal:()=>he(`terminal`),onCollapse:e,onArchived:Ge}),gt=(0,K.jsx)(`div`,{className:`flex h-full flex-col bg-ground`,children:(0,K.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,K.jsx)(ef,{onDrop:E.drop,renderOverlay:e=>{let t=e.type===`terminal`?p.find(t=>t.id===e.session):void 0;return(0,K.jsx)(`div`,{className:`rounded-md bg-elevated px-2.5 py-1 text-xs font-mono text-fg shadow-lg`,children:e.type===`terminal`?t?u(t):e.session.slice(0,8):e.tab.path.split(`/`).pop()??e.tab.path})},children:(0,K.jsx)(hf,{tree:E.tree,sessions:p,reveal:ye,onActivateTab:Je,onCloseTab:Ye,onPromoteTab:Ee,onArchived:Ge,onFocusLeaf:E.focusLeaf,onResize:E.resize,onDropTab:Xe,onSetTabView:E.setView,onNewUntitled:Me})})})});return(0,K.jsx)(ba,{tree:E.tree,onOpenFile:(e,t,n,r)=>Se(e,t,n===void 0?void 0:{line:n,column:r}),children:(0,K.jsxs)(`div`,{className:`relative flex h-full`,children:[j?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(pc,{mode:tt,onExpand:()=>re(!0),onSelect:e=>{d.update({sidebar_mode:e}),re(!0)}}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:gt}),(0,K.jsx)(Ac,{groups:w,accounts:l,activeSessionId:o,onReorder:A,onPromote:e=>E.ensureTerminal(e),onExpand:()=>N(!0),onNewTerminal:()=>he(`terminal`),onNewSession:()=>he(`agent`),onArchived:Ge}),ne&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,"aria-label":`Close the navigator`,className:`absolute inset-0 z-30 bg-ground/60`,onClick:()=>re(!1)}),(0,K.jsx)(`div`,{className:`absolute inset-y-0 left-9 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:mt(()=>re(!1))})]}),M&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,"aria-label":`Close the session list`,className:`absolute inset-0 z-30 bg-ground/60`,onClick:()=>N(!1)}),(0,K.jsx)(`div`,{className:`absolute inset-y-0 right-9 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:ht(()=>N(!1))})]})]}):(0,K.jsxs)(K.Fragment,{children:[nt&&(0,K.jsx)(pc,{mode:tt,onExpand:()=>d.update({sidebar_collapsed:!1}),onSelect:e=>d.update({sidebar_collapsed:!1,sidebar_mode:e})}),(0,K.jsxs)(Di,{orientation:`horizontal`,className:`h-full min-w-0 flex-1`,defaultLayout:pt,onLayoutChanged:ft,children:[!nt&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ai,{id:`nav`,defaultSize:280,minSize:200,maxSize:560,children:mt(()=>d.update({sidebar_collapsed:!0}))}),(0,K.jsx)(Ni,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`})]}),(0,K.jsx)(Ai,{id:`main`,children:gt}),!rt&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ni,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`}),(0,K.jsx)(Ai,{id:`sessions`,defaultSize:260,minSize:180,maxSize:480,children:ht(()=>d.update({sessions_collapsed:!0}))})]})]}),rt&&(0,K.jsx)(Ac,{groups:w,accounts:l,activeSessionId:o,onReorder:A,onPromote:e=>E.ensureTerminal(e),onExpand:()=>d.update({sessions_collapsed:!1}),onNewTerminal:()=>he(`terminal`),onNewSession:()=>he(`agent`),onArchived:Ge})]}),(0,K.jsx)(hc,{projectId:r,repoId:s.data.project.repo_id,open:ae,kind:le,seedAccountId:de,onOpenChange:L,onCreated:e=>void t(`/project/${r}/session/${e.id}`)}),(0,K.jsx)(Pi,{request:Fe,targetSession:et,profileId:m,onClose:()=>Ie(null),onSaved:Ve}),(0,K.jsx)(ce,{open:Le!==null,onOpenChange:e=>!e&&ze(null),children:(0,K.jsxs)(R,{children:[(0,K.jsxs)(ie,{children:[(0,K.jsx)(z,{children:`Discard this draft?`}),(0,K.jsx)(se,{children:`Closing an untitled tab deletes its draft — ⌘S saves it into the worktree instead.`})]}),(0,K.jsxs)(oe,{children:[(0,K.jsx)(I,{variant:`ghost`,onClick:()=>ze(null),children:`Keep editing`}),(0,K.jsx)(I,{variant:`danger`,onClick:Be,children:`Discard`})]})]})})]})})}export{Cf as Workspace};