@puddle-code/cli 0.0.9 → 0.0.10

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 (31) hide show
  1. package/CHANGELOG.md +22 -14
  2. package/dist/index.js +26 -3
  3. package/dist/public/assets/{Dashboard-CAM3cXGU.js → Dashboard-Botzm-4a.js} +1 -1
  4. package/dist/public/assets/{EditorTabClose-CnJvqROE.js → EditorTabClose-DXG0-8LG.js} +1 -1
  5. package/dist/public/assets/{ModelRefcount-DxceM9Ni.js → ModelRefcount-Cr0OdhVF.js} +1 -1
  6. package/dist/public/assets/PaneEditorBody-BzhoRYgd.js +66 -0
  7. package/dist/public/assets/SettingsDialog-Cd6rZoyo.js +1 -0
  8. package/dist/public/assets/{Terminal-DwGMsU4j.js → Terminal-DogmkohW.js} +2 -2
  9. package/dist/public/assets/Workspace-BDettW-h.js +7 -0
  10. package/dist/public/assets/{api-MnOKfpqf.js → api-BHwI7sYX.js} +1 -1
  11. package/dist/public/assets/{buffer-store-BLJJ5bBb.js → buffer-store-DF2zMOcz.js} +3 -3
  12. package/dist/public/assets/context-menu-CHZoXuDL.js +1 -0
  13. package/dist/public/assets/{cssMode-BRkqXiJB.js → cssMode-DYb85Jum.js} +1 -1
  14. package/dist/public/assets/{editor-tabs-DHrvhXUq.js → editor-tabs-BaSR99_-.js} +1 -1
  15. package/dist/public/assets/{htmlMode-BqZkTR1f.js → htmlMode-DyXrW8ZC.js} +1 -1
  16. package/dist/public/assets/index-BgfBBLZx.js +10 -0
  17. package/dist/public/assets/index-szwjDL7m.css +2 -0
  18. package/dist/public/assets/{jsonMode-CyukyrLW.js → jsonMode-B5kO-8PP.js} +1 -1
  19. package/dist/public/assets/session-seed-Dy0HnELo.js +1 -0
  20. package/dist/public/assets/ssh-mode-CY9J7nfI.js +1 -0
  21. package/dist/public/assets/{tsMode-ClBkYZNn.js → tsMode-BnA0oGE5.js} +1 -1
  22. package/dist/public/index.html +3 -3
  23. package/package.json +1 -1
  24. package/dist/public/assets/PaneEditorBody-Xz_NA7oS.js +0 -1
  25. package/dist/public/assets/SettingsDialog-CGLXP6AW.js +0 -1
  26. package/dist/public/assets/Workspace-vM9qSoWV.js +0 -7
  27. package/dist/public/assets/context-menu-DDQiarCp.js +0 -1
  28. package/dist/public/assets/index-B3xVOA2-.css +0 -2
  29. package/dist/public/assets/index-QU4DiDhV.js +0 -10
  30. package/dist/public/assets/session-seed-CRfTF2sq.js +0 -1
  31. package/dist/public/assets/ssh-mode-d5hq-vUb.js +0 -1
@@ -0,0 +1,7 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PaneEditorBody-BzhoRYgd.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/editor-tabs-BaSR99_-.js","assets/useMutation-Da9b4jwS.js","assets/api-BHwI7sYX.js","assets/createLucideIcon-DyMAgLa3.js","assets/index-BgfBBLZx.js","assets/preload-helper-Czpn1I53.js","assets/dialog-B43iKmfK.js","assets/utils-B6KiDbIe.js","assets/index-szwjDL7m.css","assets/editor.api2-4X9Vh9Zw.js","assets/editor-Br_kD0ds.css","assets/buffer-store-DF2zMOcz.js","assets/buffer-logic-BrpRsL1b.js","assets/editor-sync-F3Wyveaa.js","assets/debounce-B9DrqirV.js","assets/ModelRefcount-Cr0OdhVF.js","assets/EditorTabClose-DXG0-8LG.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{a as i}from"./useMutation-Da9b4jwS.js";import{b as a,c as o,d as s,f as c,g as l,l as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,x as y,y as b}from"./editor-tabs-BaSR99_-.js";import{t as x}from"./preload-helper-Czpn1I53.js";import{_ as S,b as C,c as w,s as T}from"./api-BHwI7sYX.js";import{A as E,O as D,_ as ee,a as O,b as te,g as k,h as A,i as j,j as ne,n as re,o as M,r as N,t as ie,w as ae}from"./dialog-B43iKmfK.js";import{t as P}from"./utils-B6KiDbIe.js";import{t as F}from"./createLucideIcon-DyMAgLa3.js";import{A as I,C as oe,D as se,E as ce,O as le,S as ue,T as de,_ as fe,a as pe,b as L,c as me,d as he,f as ge,g as _e,h as ve,i as R,j as ye,l as be,m as xe,n as Se,o as Ce,p as we,r as z,s as Te,t as Ee,u as De,v as Oe,w as ke,x as Ae,y as je}from"./context-menu-CHZoXuDL.js";import{a as Me,c as Ne,i as Pe,l as Fe,n as Ie,o as Le,r as Re,s as ze,t as Be,u as Ve}from"./session-seed-Dy0HnELo.js";import{i as He,r as Ue}from"./dist-VDiYuPKw.js";import{$ as We,A as Ge,At as Ke,B as qe,Bt as Je,Ct as Ye,D as Xe,Dt as Ze,Et as Qe,Ft as $e,H as et,Ht as B,It as tt,J as nt,K as rt,Lt as it,M as at,Mt as ot,Nt as st,O as ct,Ot as lt,P as ut,Q as dt,R as ft,Rt as pt,Tt as mt,U as ht,Ut as V,V as gt,Vt as _t,Wt as H,X as vt,Y as yt,Z as bt,_ as xt,an as St,bt as Ct,c as wt,ct as Tt,d as Et,dt as Dt,et as Ot,h as kt,in as At,it as jt,jt as Mt,kt as Nt,n as Pt,on as Ft,ot as It,pt as Lt,q as Rt,rt as zt,s as Bt,t as Vt,u as Ht,w as Ut,wt as Wt,xt as Gt,z as Kt}from"./index-BgfBBLZx.js";import{t as qt}from"./debounce-B9DrqirV.js";import{i as Jt}from"./buffer-logic-BrpRsL1b.js";import{t as Yt}from"./ssh-mode-CY9J7nfI.js";var Xt=F(`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`}]]),Zt=F(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),Qt=F(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),$t=F(`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`}]]),en=F(`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`}]]),tn=F(`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`}]]),nn=F(`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`}]]),rn=F(`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`}]]),an=F(`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`}]]),U=F(`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`}]]),on=F(`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`}]]),sn=F(`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`}]]),cn=F(`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`}]]),ln=F(`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`}]]),un=F(`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`}]]),dn=F(`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`}]]),fn=F(`file-plus`,[[`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:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),pn=F(`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`}]]),mn=F(`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`}]]),hn=F(`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`}]]),gn=F(`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`}]]),_n=F(`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`}]]),vn=F(`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`}]]),yn=F(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`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`}]]),bn=F(`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`}]]),xn=F(`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`}]]),Sn=F(`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`}]]),Cn=F(`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`}]]),wn=F(`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`}]]),Tn=F(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),En=F(`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`}]]),Dn=F(`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`}]]),On=F(`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`}]]),kn=F(`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`}]]),An=F(`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`}]]),jn=F(`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`}]]),Mn=F(`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`}]]),Nn=F(`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`}]]),Pn=F(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Fn=F(`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`}]]),In=F(`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`}]]),W=r(),G=e(t(),1);function Ln(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Rn(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function zn(e){return e/100*window.innerHeight}function Bn(e){return e/100*window.innerWidth}function Vn(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 Hn({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Vn(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Rn(t,i);break;case`em`:r=Ln(t,i);break;case`vh`:r=zn(i);break;case`vw`:r=Bn(i);break}return r}function K(e){return parseFloat(e.toFixed(3))}function Un({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 Wn(e){let{panels:t}=e,n=Un({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=K(Hn({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=K(Hn({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=K(Hn({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=K(Hn({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 q(e,t=`Assertion error`){if(!e)throw Error(t)}function Gn(e,t){return Array.from(t).sort(e===`horizontal`?Kn:qn)}function Kn(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 Jn(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Yn(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 Xn({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}=Yn(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return q(i,`No rect found`),i}var Zn;function Qn(){return Zn===void 0&&(Zn=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),Zn}function $n(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Gn(n,Array.from(t.children).filter(Jn).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,Xn({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=Qn()?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:Un({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 er=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)}}},tr={cursorFlags:0,state:`inactive`},nr=new er;function rr(){return tr}function ir(e){return nr.addListener(`change`,e)}function ar(e){let t=tr,n={...tr};n.cursorFlags=e,tr=n,nr.emit(`change`,{prev:t,next:n})}function or(e){let t=tr;tr=e,nr.emit(`change`,{prev:t,next:e})}var sr=e=>e,cr=()=>{},lr=1,ur=2,dr=4,fr=8,pr=3,mr=12,hr;function gr(){return hr===void 0&&(hr=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(hr=!0)),hr}function _r({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&&gr()){let t=(e&lr)!==0,n=(e&ur)!==0,r=(e&dr)!==0,i=(e&fr)!==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 gr()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var vr=new WeakMap;function yr(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=vr.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=rr();switch(r.state){case`active`:case`hover`:{let e=_r({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}vr.set(e,{prevStyle:t,styleSheet:n})}var br=new Map,xr=new er;function Sr(e){br=new Map(br),br.delete(e)}function Cr(e,t){for(let[t]of br)if(t.id===e)return t}function wr(e,t){for(let[t,n]of br)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Tr(){return br}function Er(e,t){return xr.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function Dr(e,t,n){let r=br.get(e);br=new Map(br),br.set(e,t),xr.emit(`groupChange`,{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function Or(e){let t=rr(),n=!1;switch(t.state){case`active`:or({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(yr(e),n=!0,t.hitRegions.forEach(e=>{let t=wr(e.group.id,!0);Dr(e.group,t,{isUserInteraction:!0})}))}return n}function kr(e){e.defaultPrevented||Or(e.currentTarget)}function Ar(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Yn(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 jr(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Mr(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:Rr(e),b:Rr(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();q(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:Lr(Ir(n.a)),b:Lr(Ir(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 Nr=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Pr(e){let t=getComputedStyle(zr(e)??e).display;return t===`flex`||t===`inline-flex`}function Fr(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Pr(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`||Nr.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Ir(e){let t=e.length;for(;t--;){let n=e[t];if(q(n,`Missing node`),Fr(n))return n}return null}function Lr(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Rr(e){let t=[];for(;e;)t.push(e),e=zr(e);return t}function zr(e){let{parentNode:t}=e;return jr(t)?t.host:t}function Br(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 Vr({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Jn(n)||n.contains(e)||e.contains(n))return!0;if(Mr(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Br(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Hr(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=$n(r),a=Ar(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Vr({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Ur(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 J(e,t,n=0){return Math.abs(K(e)-K(t))<=n}function Wr(e,t){return J(e,t)?0:e>t?1:-1}function Gr({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(Wr(r,c)<0)if(a){let e=(i+c)/2;r=Wr(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=K(r),r}function Kr({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(J(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;q(u!=null,`Invalid first pivot index`),q(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];q(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(q(n!=null,`Previous layout not found for panel index ${t}`),J(n,i)){let t=o-n;Wr(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];q(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(q(n!=null,`Previous layout not found for panel index ${t}`),J(n,o)){let t=n-i;Wr(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];q(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&Wr(i,c)<0)if(e>0){let t=c-o,n=t/2;Wr(i+e,c)<0&&(e=Wr(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;Wr(i-e,c)<0&&(e=Wr(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];q(e!=null,`Previous layout not found for panel index ${r}`);let a=Gr({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];q(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=Gr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!J(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(Ur(c,l))return i;{let t=e<0?d:u,r=s[t];q(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=Gr({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!J(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];q(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=Gr({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(J(i,s)||(t-=s-i,l[r]=s),J(t,0))break;e>0?r--:r++}}}if(!J(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||Wr(e[n],t[n])!==0)return!1;return!0}function Jr({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(!J(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];q(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];q(i!=null,`No layout data found for index ${e}`);let o=r[e];q(o!=null,`No layout data found for index ${e}`);let s=Gr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!J(a,0))for(let e=0;e<t.length;e++){let n=r[e];q(n!=null,`No layout data found for index ${e}`);let i=n+a,o=Gr({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,J(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function Yr({groupId:e,panelId:t}){let n=()=>{let t=Tr();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&&J(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:K(100-e)}}return Kr({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=Jr({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});qr(c,u)||Dr(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&&J(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Un({group:t}),o=K(Hn({groupSize:a,panelElement:r,styleProp:e})/a*100);s(o)}}}function Xr(e){e.defaultPrevented||Hr(e,Tr()).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=Yr({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Zr(e){let t=Tr();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 Qr({groupId:e}){let t=()=>{let t=Tr();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=Jr({layout:e,panelConstraints:r});return n?o:(qr(o,c)||Dr(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function $r(e,t){let n=Zr(e),r=wr(n.id,!0),i=n.separators.find(t=>t.element===e);q(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);q(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=Qr({groupId:n.id}).getLayout(),c=Jr({layout:Kr({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});qr(s,c)||Dr(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function ei(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Zr(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&$r(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&$r(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&$r(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&$r(t,-5);break;case`End`:e.preventDefault(),$r(t,100);break;case`Enter`:{e.preventDefault();let n=Zr(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=wr(n.id,!0),o=n.separators.find(e=>e.element===t);q(o,`Matching separator not found`);let s=a.get(o);q(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(q(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];$r(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=Zr(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);q(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(),$r(t,-100);break}}function ti(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Tr(),n=Hr(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)}),or({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}function ni({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=Kr({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?lr:ur;break;case`vertical`:s|=d<0?dr:fr;break}}else Dr(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&pr:c|=s&pr,t.movementY===0?c|=o&mr:c|=s&mr,ar(c),yr(e)}function ri(e){let t=Tr(),n=rr();switch(n.state){case`active`:ni({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function ii(e){if(e.defaultPrevented)return;let t=rr(),n=Tr();switch(t.state){case`active`:if(e.buttons===0){or({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=wr(e.group.id,!0);Dr(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)}ni({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=Hr(e,n);r.length===0?t.state!==`inactive`&&or({cursorFlags:0,state:`inactive`}):or({cursorFlags:0,hitRegions:r,state:`hover`}),yr(e.currentTarget);break}}}function ai(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(rr().state){case`hover`:or({cursorFlags:0,state:`inactive`})}}function oi(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||Or(e.currentTarget)&&e.preventDefault()}function si(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=K(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=K((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function ci(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Un({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:K(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function li(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 ui({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=K(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]=K((r[e]??0)/a*l);else{let e=K(l/c.length);for(let t of c)u[t]=e}return u}function di(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 fi=new Map;function pi(e){let t=!0;q(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=Un({group:e});if(t===0)return;let n=wr(e.id);if(!n)return;let r=Wn(e),i=n.defaultLayoutDeferred?si(r):n.layout,a=Jr({layout:ui({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&qr(n.layout,a)&&li(n.derivedPanelConstraints,r)&&n.groupSize===t)return;Dr(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else ci(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{q(!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=Un({group:e}),s=Wn(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(di(e.panels,l)||(l=void 0));let u=Jr({layout:e.mutableState.layouts[c]??l??si(s),panelConstraints:s}),d=e.element.ownerDocument;fi.set(d,(fi.get(d)??0)+1);let f=new Map;return $n(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),Dr(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,groupSize:o,layout:u,separatorToPanels:f}),e.separators.forEach(e=>{q(!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`,ei)}),fi.get(d)===1&&(d.addEventListener(`contextmenu`,kr,!0),d.addEventListener(`dblclick`,Xr,!0),d.addEventListener(`pointerdown`,ti,!0),d.addEventListener(`pointerleave`,ri),d.addEventListener(`pointermove`,ii),d.addEventListener(`pointerout`,ai),d.addEventListener(`pointerup`,oi,!0)),function(){t=!1,fi.set(d,Math.max(0,(fi.get(d)??0)-1)),Sr(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,ei)}),fi.get(d)||(d.removeEventListener(`contextmenu`,kr,!0),d.removeEventListener(`dblclick`,Xr,!0),d.removeEventListener(`pointerdown`,ti,!0),d.removeEventListener(`pointerleave`,ri),d.removeEventListener(`pointermove`,ii),d.removeEventListener(`pointerout`,ai),d.removeEventListener(`pointerup`,oi,!0)),a.disconnect()}}function mi(){let[e,t]=(0,G.useState)({});return[e,(0,G.useCallback)(()=>t({}),[])]}function hi(e){let t=(0,G.useId)();return`${e??t}`}var gi=typeof window<`u`?G.useLayoutEffect:G.useEffect;function _i(e){let t=(0,G.useRef)(e);return gi(()=>{t.current=e},[e]),(0,G.useCallback)((...e)=>t.current?.(...e),[t])}function vi(...e){return _i(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function yi(e){let t=(0,G.useRef)({...e});return gi(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var bi=(0,G.createContext)(null);function xi(e,t){let n=(0,G.useRef)({getLayout:()=>({}),setLayout:sr});(0,G.useImperativeHandle)(t,()=>n.current,[]),gi(()=>{Object.assign(n.current,Qr({groupId:e}))})}function Si({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,G.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=_i(e=>{qr(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=_i((e,t)=>{qr(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t}))}),_=hi(s),v=(0,G.useRef)(null),[y,b]=mi(),x=(0,G.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=vi(v,a);xi(_,o);let C=_i((e,t)=>{let r=rr(),i=Cr(e),a=wr(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=yi({defaultLayout:n,disableCursor:r}),T=(0,G.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=Gn(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Gn(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=Cr(_),i=wr(_);r&&i&&Dr(r,{...i,derivedPanelConstraints:Wn(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,G.useRef)(null);return gi(()=>{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=pi(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=wr(r.id,!0);!o&&s.length>0&&(h(c),g(c,!1));let l=Er(_,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=J(t.collapsedSize,i[t.panelId]),a=J(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=rr().state!==`active`;h(i),o&&g(i,e.isUserInteraction)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,G.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,W.jsx)(bi.Provider,{value:T,children:(0,W.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})})}Si.displayName=`Group`;function Ci(){let e=(0,G.useContext)(bi);return q(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function wi(e,t){let{id:n}=Ci(),r=(0,G.useRef)({collapse:cr,expand:cr,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:cr});(0,G.useImperativeHandle)(t,()=>r.current,[]),gi(()=>{Object.assign(r.current,Yr({groupId:n,panelId:e}))})}function Ti({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=hi(c),_=yi({disabled:a}),v=(0,G.useRef)(null),y=vi(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=Ci(),T=d!==null,E=_i((e,t,n)=>{d?.(e,c,n)});gi(()=>{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,G.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),wi(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},ee=(0,G.useSyncExternalStore)(e=>Er(x,e),D,D),O;return O=ee?JSON.parse(ee):i===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:i},(0,W.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...Ei,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...O},children:(0,W.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}Ti.displayName=`Panel`;var Ei={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function Di({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=Jr({layout:Kr({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Jr({layout:Kr({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Oi({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=hi(a),l=yi({disabled:n,disableDoubleClick:r}),[u,d]=(0,G.useState)({}),[f,p]=(0,G.useState)(`inactive`),[m,h]=(0,G.useState)(!1),g=(0,G.useRef)(null),_=vi(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=Ci(),C=b===`horizontal`?`vertical`:`horizontal`;gi(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=ir(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=Er(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(Di({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,G.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,W.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})}Oi.displayName=`Separator`;function ki(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 Ai=(0,G.createContext)({openFile:()=>void 0,handler:null,setHandler:()=>void 0});function ji({children:e}){let[t,n]=(0,G.useState)(null),r=(0,G.useCallback)(e=>n(()=>e),[]),i=(0,G.useCallback)((e,n,r)=>{if(!t){C(`The editor is not ready yet.`);return}t(e,n,r)},[t]),a=(0,G.useMemo)(()=>({openFile:i,handler:t,setHandler:r}),[i,t,r]);return(0,W.jsx)(Ai.Provider,{value:a,children:e})}function Mi(e){let{setHandler:t}=(0,G.useContext)(Ai),n=(0,G.useRef)(e);n.current=e,(0,G.useEffect)(()=>(t((e,t,r)=>n.current(e,t,r)),()=>t(null)),[t])}var Ni=null,Pi=null;async function Fi(){let[e,t]=await Promise.all([x(()=>import(`./PaneEditorBody-BzhoRYgd.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])),x(()=>import(`./ModelRefcount-Cr0OdhVF.js`),__vite__mapDeps([19,1,2,15,9,8,3,5,6,10,11,7,12,13,14,16]))]);Ni=e.PaneEditorBody,Pi=t.ModelRefcount}var Ii=(0,G.lazy)(()=>x(()=>import(`./PaneEditorBody-BzhoRYgd.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])));function Li(e){return Ni?(0,W.jsx)(Ni,{...e}):(0,W.jsx)(G.Suspense,{fallback:(0,W.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-xs text-fg-muted`,children:`Loading editor…`}),children:(0,W.jsx)(Ii,{...e})})}var Ri=(0,G.lazy)(()=>x(()=>import(`./ModelRefcount-Cr0OdhVF.js`).then(e=>({default:e.ModelRefcount})),__vite__mapDeps([19,1,2,15,9,8,3,5,6,10,11,7,12,13,14,16])));function zi({buffers:e}){return Pi?(0,W.jsx)(Pi,{buffers:e}):(0,W.jsx)(G.Suspense,{fallback:null,children:(0,W.jsx)(Ri,{buffers:e})})}var Bi=(0,G.lazy)(()=>x(()=>import(`./EditorTabClose-DXG0-8LG.js`).then(e=>({default:e.EditorTabClose})),__vite__mapDeps([20,1,2,3,10,11,7,15,9,8,5,6,12,13,14,16,17,18])));function Vi(e){return(0,W.jsx)(G.Suspense,{fallback:(0,W.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e.onClose()},className:`flex size-4 items-center justify-center rounded-sm text-fg-muted opacity-0 transition-opacity hover:text-fg group-hover:opacity-100`,"aria-label":`Close ${e.label}`,children:`×`}),children:(0,W.jsx)(Bi,{...e})})}var Hi=e(n(),1);function Ui(){return crypto.randomUUID()}function Y(e){return e.type===`terminal`?`term:${e.session}`:`editor:${g(e.tab)}`}function Wi(e,t){return Y(e)===Y(t)}function Gi(e){return e.type===`terminal`}function Ki(e=[],t){let n=e.map(Y),r=t&&n.includes(t)?t:n.length>0?n[0]:null;return{kind:`leaf`,id:Ui(),tabs:e,activeKey:r,previewKey:null}}function qi(e,t,n){return{kind:`split`,id:Ui(),direction:e,children:t,sizes:n??t.map(()=>100/Math.max(1,t.length))}}function Ji(e,t){if(e.kind===`leaf`)return e.id===t?e:null;for(let n of e.children){let e=Ji(n,t);if(e)return e}return null}function Yi(e,t){if(e.kind===`leaf`)return e.tabs.some(e=>Y(e)===t)?e:null;for(let n of e.children){let e=Yi(n,t);if(e)return e}return null}function Xi(e){return e.kind===`leaf`?[e]:e.children.flatMap(Xi)}function Zi(e){return Xi(e).flatMap(e=>e.tabs)}function Qi(e){let t=e.tabs.map(Y),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 $i(e){if(e.kind===`leaf`)return Qi(e);let t=e.children.map($i),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?Ki([]):i.length===1?i[0]:{...e,children:i,sizes:a}}function ea(e,t,n){return e.kind===`leaf`?e.id===t?n(e):e:{...e,children:e.children.map(e=>ea(e,t,n))}}function ta(e,t){if(e.kind===`leaf`){if(!e.tabs.some(e=>Y(e)===t))return e;let n=e.tabs.filter(e=>Y(e)!==t),r=e.activeKey===t?na(e,t):e.activeKey;return{...e,tabs:n,activeKey:r}}return{...e,children:e.children.map(e=>ta(e,t))}}function na(e,t){let n=e.tabs.findIndex(e=>Y(e)===t);if(n===-1)return e.activeKey;let r=e.tabs.filter(e=>Y(e)!==t);return r.length===0?null:Y(r[Math.min(n,r.length-1)])}function ra(e,t,n){let r=e.tabs.filter(e=>!Wi(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:Y(t)}}function ia(e,t,n,r){let i=n===`left`||n===`right`?`row`:`col`,a=n===`left`||n===`top`;return $i(ea(e,t,e=>{let t=Ki([r]);return qi(i,a?[t,e]:[e,t],[50,50])}))}function aa(e,t){let{ref:n,toLeafId:r,edge:i}=t,a=Y(n),o=t.index;if(i===`center`&&o!==void 0){let t=Ji(e,r)?.tabs.findIndex(e=>Y(e)===a)??-1;t!==-1&&t<o&&--o}let s=ta(e,a);if(i===`center`){let e=ea(s,r,e=>ra(e,n,o));return!Ji(e,r)&&!Yi(e,a)?ua($i(oa(e,n)),a):ua($i(e),a)}return Ji(s,r)?ua(ia(s,r,i,n),a):$i(Ki([n]))}function oa(e,t){let n=Xi(e)[0];return n?ea(e,n.id,e=>ra(e,t)):Ki([t])}function sa(e,t,n){return $i(ea(e,t,e=>e.tabs.some(e=>Y(e)===n)?{...e,tabs:e.tabs.filter(e=>Y(e)!==n),activeKey:e.activeKey===n?na(e,n):e.activeKey}:e))}function ca(e,t,n){let r=Y(n);return $i(ea(e,t,e=>{let t=e.previewKey===r?null:e.previewKey;return e.tabs.some(e=>Wi(e,n))?{...e,activeKey:r,previewKey:t}:{...e,tabs:[...e.tabs,n],activeKey:r,previewKey:t}}))}function la(e,t,n){let r=Y(n);return $i(ea(e,t,e=>{if(e.tabs.some(e=>Wi(e,n)))return{...e,activeKey:r};let t=e.previewKey?e.tabs.findIndex(t=>Y(t)===e.previewKey):-1,i=t>=0&&!Gi(e.tabs[t])?e.tabs.map((e,r)=>r===t?n:e):[...e.tabs,n];return{...e,tabs:i,activeKey:r,previewKey:r}}))}function ua(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 da(e,t,n){let r=e=>e.kind===`leaf`?{...e,tabs:e.tabs.map(e=>e.type===`editor`&&Y(e)===t?{...e,tab:{...e.tab,view:n}}:e)}:{...e,children:e.children.map(r)};return r(e)}function fa(e,t,n){return ea(e,t,e=>e.tabs.some(e=>Y(e)===n)?{...e,activeKey:n}:e)}function pa(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 ma(e,t){let n=e=>e.kind===`leaf`?{...e,tabs:e.tabs.filter(t)}:{...e,children:e.children.map(n)};return $i(n(e))}function ha(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?Y({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 Ki([]);if(t.length===0)return Ki(n,i);if(n.length===0)return Ki(t,r);let a=e.layout,o=typeof a.editor==`number`?a.editor:40,s=typeof a.session==`number`?a.session:60;return $i(qi(`col`,[Ki(t,r),Ki(n,i)],[o,s]))}var ga=(0,G.createContext)(null);function _a({tree:e,onOpenFile:t,children:n}){let r=(0,G.useRef)(null),i=(0,G.useRef)(new Map).current,a=(0,G.useMemo)(()=>{let t=new Set;for(let n of Xi(e))for(let e of n.tabs)e.type===`terminal`&&t.add(e.session);return[...t]},[e]),o=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,G.useEffect)(()=>{let e=new Set(a.map(e=>`term:${e}`));for(let e of a){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))},[a,i]);let s=(0,G.useMemo)(()=>({parkingRef:r,containers:i}),[i]);return(0,W.jsxs)(ga.Provider,{value:s,children:[(0,W.jsx)(`div`,{ref:r,className:`hidden`,"aria-hidden":!0}),a.map(e=>(0,Hi.createPortal)((0,W.jsx)(Ht,{stream:e,onOpenFile:(n,r,i)=>t(e,n,r,i)}),o(e),e)),n]})}function va(e){let t=(0,G.useContext)(ga),n=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let r=n.current;if(!t||!e||!r)return;let i=t.containers.get(e);return i&&r.appendChild(i),()=>{let e=t.parkingRef.current;i&&e&&i.parentElement===r&&e.appendChild(i)}},[t,e]),n}function ya(e,t){let n={};for(let r of t){let t=e[r];if(typeof t!=`number`)return;n[r]=t}return n}var ba={added:{letter:`A`,label:`added`,colourClass:`text-running`},modified:{letter:`M`,label:`modified`,colourClass:`text-fg-secondary`},deleted:{letter:`D`,label:`deleted`,colourClass:`text-interrupted`},renamed:{letter:`R`,label:`renamed`,colourClass:`text-waiting`}};function xa(e){return ba[e]}var Sa=[`modified`,`added`,`deleted`,`renamed`];function Ca(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return Sa.filter(e=>t.has(e)).map(e=>`${t.get(e)} ${ba[e].label}`).join(` · `)}var wa=[`var(--accent)`,`var(--status-running)`,`var(--status-waiting)`,`var(--ansi-magenta)`,`var(--ansi-cyan)`,`var(--status-interrupted)`];function Ta(e){return wa[e%wa.length]}function Ea(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:Ta(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=Ta(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 Da=7,Oa=14,ka=4,Aa=1.5,ja=40,Ma=22;function Na(e){return e*Oa+Oa/2}function Pa(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 Fa({row:e,width:t}){let n=ja,r=n/2,i=Na(e.col),a=new Set(e.created),o=[];for(let t of e.above){let n=Na(t.col);t.sha===e.sha?o.push({d:Pa(n,0,i,r),colour:t.colour}):o.push({d:Pa(n,0,n,r),colour:t.colour})}for(let t of e.below){let e=Na(t.col);a.has(t.col)?o.push({d:Pa(i,r,e,n),colour:t.colour}):o.push({d:Pa(e,r,e,n),colour:t.colour})}return(0,W.jsxs)(`svg`,{width:t,height:n,className:`shrink-0`,"aria-hidden":!0,children:[o.map((e,t)=>(0,W.jsx)(`path`,{d:e.d,fill:`none`,stroke:e.colour,strokeWidth:Aa},t)),(0,W.jsx)(`circle`,{cx:i,cy:r,r:ka,fill:`var(--bg-surface)`,stroke:e.colour,strokeWidth:Aa})]})}function Ia({lanes:e,width:t}){return(0,W.jsx)(`svg`,{width:t,height:Ma,className:`shrink-0`,"aria-hidden":!0,children:e.map(e=>{let t=Na(e.col);return(0,W.jsx)(`path`,{d:`M ${t} 0 L ${t} ${Ma}`,fill:`none`,stroke:e.colour,strokeWidth:Aa},e.col)})})}function La({session:e,sha:t,lanes:n,gutterW:r,onOpen:i}){let a=p(e,t),o=e=>(0,W.jsxs)(`div`,{className:`flex items-center`,style:{height:Ma},children:[(0,W.jsx)(Ia,{lanes:n,width:r}),(0,W.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,W.jsx)(W.Fragment,{children:a.data.files.map(e=>{let a=xa(e.status),o=e.status===`renamed`&&e.old_path?`${e.old_path} → ${e.path}`:e.path;return(0,W.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:Ma},children:[(0,W.jsx)(Ia,{lanes:n,width:r}),(0,W.jsx)(`span`,{className:P(`mr-1.5 w-3 shrink-0 text-center font-mono text-xs`,a.colourClass),children:a.letter}),(0,W.jsx)(`span`,{className:`truncate pr-3 font-mono text-2xs text-fg`,children:o})]},`${e.status}:${e.old_path??``}:${e.path}`)})})}function Ra({session:e,onOpenCommitFile:t}){let n=b(e),[r,i]=(0,G.useState)(null),a=(0,G.useMemo)(()=>n.data?.pages.flatMap(e=>e.commits)??[],[n.data]),o=(0,G.useMemo)(()=>Ea(a),[a]),s=Math.max(1,o.laneCount)*Oa+Oa/2;return n.isPending?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading history…`}):n.error?(0,W.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,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No commits yet.`}):(0,W.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,W.jsxs)(`div`,{children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>i(l?null:n.sha),className:P(`flex w-full items-center text-left transition-colors hover:bg-elevated`,l&&`bg-selection`),style:{height:ja},children:[(0,W.jsx)(Fa,{row:n,width:s}),(0,W.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 pr-3`,children:[(0,W.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,W.jsx)(`span`,{className:`shrink-0 font-mono text-2xs text-fg-muted`,children:n.sha.slice(0,Da)}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg`,children:c.subject})]}),(0,W.jsxs)(`span`,{className:`truncate text-2xs text-fg-muted`,children:[c.author_name,` ·`,` `,(0,W.jsx)(`span`,{className:`tabular-nums`,children:f(c.authored_at)})]})]})]}),l&&(0,W.jsx)(La,{session:e,sha:n.sha,lanes:n.below,gutterW:s,onOpen:t})]},n.sha)}),n.hasNextPage&&(0,W.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 za(){return{dirs:new Map,files:[]}}function Ba(e){return e.path}function Va(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:Va(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 Ha(e){let t=za();for(let n of e){let e=Ba(n),r=e.split(`/`),i=r.pop(),a=t;for(let e of r){let t=a.dirs.get(e);t||(t=za(),a.dirs.set(e,t)),a=t}a.files.push({type:`file`,name:i,path:e,entry:n})}return Va(t,``)}function Ua(e){return e.map(e=>({type:`file`,name:Ba(e).split(`/`).pop()??Ba(e),path:Ba(e),entry:e})).sort((e,t)=>e.path.localeCompare(t.path,void 0,{sensitivity:`base`}))}function Wa({name:e,fullPath:t,status:n,depth:r,active:i,onOpen:a}){let o=xa(n);return(0,W.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:P(`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,W.jsx)(`span`,{className:P(`w-3 shrink-0 text-center font-mono text-xs`,o.colourClass),children:o.letter}),(0,W.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:e})]})}function Ga({nodes:e,depth:t,activePath:n,onOpen:r}){let[i,a]=(0,G.useState)(new Set);return(0,W.jsx)(W.Fragment,{children:e.map(e=>{if(e.type===`file`)return(0,W.jsx)(Wa,{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,W.jsxs)(`div`,{children:[(0,W.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,W.jsx)(He,{className:`size-3.5 shrink-0 text-fg-gold`}):(0,W.jsx)(Ve,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,W.jsx)(`span`,{className:`truncate font-mono text-xs text-fg-secondary`,children:e.name})]}),!o&&(0,W.jsx)(Ga,{nodes:e.children,depth:t+1,activePath:n,onOpen:r})]},e.path)})})}function Ka({session:e,activePath:t,onOpen:n}){let[r,i]=(0,G.useState)(!1),a=l(e,{against:`head`}),o=a.data?.entries??[],s=(0,G.useMemo)(()=>r?null:Ha(o),[r,o]),c=(0,G.useMemo)(()=>r?Ua(o):null,[r,o]);return(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,W.jsxs)(`div`,{className:`flex h-7 shrink-0 items-center gap-2 px-3`,children:[(0,W.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Uncommitted`}),o.length>0&&(0,W.jsx)(`span`,{className:`truncate font-mono text-2xs text-fg-muted`,children:Ca(o)}),(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.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,W.jsx)(wn,{className:`size-3.5`}):(0,W.jsx)(bn,{className:`size-3.5`}),(0,W.jsx)(`span`,{className:`sr-only`,children:r?`Show as tree`:`Show as flat list`})]})}),(0,W.jsx)(V,{children:r?`Show as tree`:`Show as flat list`})]})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-1`,children:a.isPending?(0,W.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`Loading changes…`}):a.error?(0,W.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,W.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`No uncommitted changes.`}):r?c.map(e=>(0,W.jsx)(Wa,{name:e.path,fullPath:e.path,status:e.entry.status,depth:0,active:t===e.path,onOpen:n},e.path)):(0,W.jsx)(Ga,{nodes:s,depth:0,activePath:t,onOpen:n})})]})}function qa({session:e,activeDiffPath:t,onOpenDiff:n,onOpenCommitFile:r}){return(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,W.jsx)(`section`,{className:`flex max-h-[45%] min-h-0 flex-col`,children:(0,W.jsx)(Ka,{session:e,activePath:t,onOpen:n})}),(0,W.jsx)(`div`,{className:`h-px shrink-0 bg-border`}),(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,W.jsx)(`div`,{className:`flex h-7 shrink-0 items-center px-3`,children:(0,W.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`History`})}),(0,W.jsx)(Ra,{session:e,onOpenCommitFile:r})]})]})}var Ja={untracked:{letter:`U`,colourClass:`text-running`},added:{letter:`A`,colourClass:`text-running`},modified:{letter:`M`,colourClass:`text-waiting`},renamed:{letter:`R`,colourClass:`text-waiting`},deleted:{letter:`D`,colourClass:`text-interrupted`},conflicted:{letter:`C`,colourClass:`text-interrupted`},ignored:{letter:``,colourClass:`text-fg-muted`}};function Ya(e){return Ja[e]}function Xa(e){let t=new Map;for(let n of e)t.set(n.path,n.status);return t}var Za={conflicted:0,modified:1,renamed:2,deleted:3,added:4,untracked:5,ignored:6};function Qa(e,t){let n=t===``?``:`${t}/`,r=null;for(let[t,i]of e)n!==``&&!t.startsWith(n)||i!==`ignored`&&(r===null||Za[i]<Za[r])&&(r=i);return r}function $a(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function eo(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function to(e,t){return e===``?t:`${e}/${t}`}function no(e,t){let n=[],r=(i,a)=>{let o=e(i);if(o)for(let e of o.entries){let o=to(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 ro(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)}var io=(e,t)=>e instanceof Error?e.message:t;function ao(e){let t=i(),n=(0,G.useCallback)(()=>{t.invalidateQueries({queryKey:[`wt-tree`,e]}),t.invalidateQueries({queryKey:[`wt-git-status`,e]})},[t,e]);return(0,G.useMemo)(()=>({async create(t,r,i){try{let a=await o(e,to(t,r),i);return n(),a.path}catch(e){return C.error(io(e,`Couldn't create ${r}`)),null}},async rename(t,r){let i=to(t.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)):``,r);try{let r=await s(e,t,i);return n(),r.path}catch(e){return C.error(io(e,`Couldn't rename ${$a(t)}`)),null}},async move(t,r){try{let i=await s(e,t,to(r,$a(t)));return n(),i.path}catch(e){return C.error(io(e,`Couldn't move ${$a(t)}`)),null}},async remove(t){let r=await Promise.allSettled(t.map(t=>u(e,t)));n();let i=r.filter(e=>e.status===`rejected`).length;i>0?C.error(`Couldn't delete ${i} item${i>1?`s`:``}`):C.success(t.length===1?`Deleted ${$a(t[0])}`:`Deleted ${t.length} items`)},async paste(t,r){let i=t.mode===`cut`?s:h,a=await Promise.allSettled(t.paths.map(t=>i(e,t,to(r,$a(t)))));n();let o=a.filter(e=>e.status===`rejected`).length;o>0&&C.error(`Couldn't paste ${o} item${o>1?`s`:``}`)}}),[e,n])}function oo(e,t,n){return n&&n.type!==`dir`||(e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``)===t?!1:t===``||!`${t}/`.startsWith(`${e}/`)}var so=(0,G.createContext)(null);function co(){let e=(0,G.useContext)(so);if(!e)throw Error(`explorer components must render inside <ExplorerProvider>`);return e}function lo(){return(0,G.useContext)(so)}function uo({session:e,onOpenFile:t,activePath:n,children:r}){let a=e.id,o=i(),s=ao(a),l=(0,G.useCallback)((e,t)=>{t.length!==0&&c(a,e,t).then(()=>{o.invalidateQueries({queryKey:[`wt-tree`,a,e]}),o.invalidateQueries({queryKey:[`wt-git-status`,a]}),C.success(t.length===1?`Uploaded ${t[0].name}`:`Uploaded ${t.length} files`)}).catch(e=>C.error(e instanceof Error?e.message:`Upload failed`))},[a,o]),[u,d]=(0,G.useState)(new Set),[f,p]=(0,G.useState)(new Set),[m,h]=(0,G.useState)(null),[g,y]=(0,G.useState)(null),[b,x]=(0,G.useState)(null),[S,w]=(0,G.useState)(null),[T,E]=(0,G.useState)(null),D=(0,G.useRef)(null),ee=v(a),O=(0,G.useMemo)(()=>Xa(ee.data?.entries??[]),[ee.data]),[te,k]=(0,G.useState)(0);(0,G.useEffect)(()=>o.getQueryCache().subscribe(e=>{let t=e.query.queryKey;Array.isArray(t)&&t[0]===`wt-tree`&&t[1]===a&&k(e=>e+1)}),[o,a]);let A=(0,G.useMemo)(()=>no(e=>o.getQueryData([`wt-tree`,a,e]),u),[o,a,u,te]),j=(0,G.useCallback)(e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ne=(0,G.useCallback)(e=>{d(t=>t.has(e)?t:new Set(t).add(e))},[]),re=(0,G.useCallback)(()=>d(new Set),[]),M=(0,G.useCallback)((e,n)=>{if(h(e.path),n.metaKey||n.ctrlKey){p(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),D.current=e.path;return}if(n.shiftKey&&D.current){p(new Set(ro(A,D.current,e.path)));return}p(new Set([e.path])),D.current=e.path,e.type===`dir`?j(e.path):t?.(a,e.path)},[A,j,t,a]),N=(0,G.useCallback)(e=>{e.type!==`dir`&&t?.(a,e.path,{preview:!1})},[t,a]),ie=(0,G.useCallback)(e=>{p(new Set([e])),h(e),D.current=e},[]),ae=(0,G.useCallback)(e=>y({paths:e,mode:`cut`}),[]),P=(0,G.useCallback)(e=>y({paths:e,mode:`copy`}),[]),F=(0,G.useCallback)(e=>{g&&s.paste(g,e).then(()=>{g.mode===`cut`&&y(null)})},[g,s]),I=(0,G.useCallback)(e=>x({mode:`rename`,path:e}),[]),oe=(0,G.useCallback)((e,t)=>{e!==``&&ne(e),x({mode:`create`,parentDir:e,kind:t})},[ne]),se=(0,G.useCallback)(()=>x(null),[]),ce=(0,G.useCallback)(e=>{let n=e.trim(),r=b;if(x(null),!(!r||n===``))if(r.mode===`rename`){if(n===$a(r.path))return;s.rename(r.path,n)}else s.create(r.parentDir,n,r.kind).then(e=>{e&&r.kind===`file`&&t?.(a,e)})},[b,s,t,a]),le=(0,G.useCallback)(e=>{e.length>0&&E(e)},[]),ue=(0,G.useCallback)(()=>{let e=T;E(null),e&&s.remove(e)},[T,s]),de=(0,G.useCallback)(()=>E(null),[]),fe=(0,G.useCallback)((t,n)=>{let r=n?t:to(e.worktree_path,t);navigator.clipboard.writeText(r),C.success(n?`Relative path copied`:`Path copied`)},[e.worktree_path]),pe=(0,G.useCallback)(e=>{_(a,e).catch(e=>C.error(e instanceof Error?e.message:`Download failed`))},[a]),L=(0,G.useCallback)(()=>{o.invalidateQueries({queryKey:[`wt-tree`,a]}),o.invalidateQueries({queryKey:[`wt-git-status`,a]})},[o,a]),me=(0,G.useCallback)((e,t)=>{oo(t,e)&&s.move(t,e)},[s]),he=(0,G.useCallback)(()=>m&&f.has(m)?[...f]:m?[m]:[...f],[m,f]),ge=(0,G.useRef)({buffer:``,at:0}),_e=(0,G.useCallback)(e=>{if(b)return;let n=A;if(n.length===0)return;let r=m?n.findIndex(e=>e.path===m):-1,i=(e,t)=>{let r=n[Math.max(0,Math.min(n.length-1,e))];r&&(h(r.path),t&&D.current?p(new Set(ro(n,D.current,r.path))):(p(new Set([r.path])),D.current=r.path))},o=r>=0?n[r]:void 0,s=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(),o?.type===`dir`&&!u.has(o.path)?ne(o.path):o?.type===`dir`&&i(r+1,!1);return;case`ArrowLeft`:if(e.preventDefault(),o?.type===`dir`&&u.has(o.path))j(o.path);else if(o){let e=n.findIndex(e=>e.path===o.parentDir);e>=0&&i(e,!1)}return;case`Enter`:case` `:if(e.preventDefault(),!o)return;o.type===`dir`?j(o.path):t?.(a,o.path);return;case`F2`:e.preventDefault(),o&&I(o.path);return;case`Delete`:e.preventDefault(),le(he());return;case`Backspace`:s&&(e.preventDefault(),le(he()));return}if(s&&(e.key===`c`||e.key===`C`)){e.preventDefault();let t=he();e.altKey?fe(t[0]??``,e.shiftKey):P(t);return}if(s&&(e.key===`x`||e.key===`X`)){e.preventDefault(),ae(he());return}if(s&&(e.key===`v`||e.key===`V`)){e.preventDefault();let t=o?o.type===`dir`?o.path:o.parentDir:``;F(t);return}if(!s&&!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}}}},[b,A,m,u,ne,j,t,a,I,le,he,P,ae,F,fe]),ve={sid:a,worktreePath:e.worktree_path,onOpenFile:t,activePath:n,expanded:u,toggle:j,collapseAll:re,statusMap:O,visibleRows:A,selection:f,focusedPath:m,onRowClick:M,onRowDoubleClick:N,selectOnly:ie,clipboard:g,cut:ae,copy:P,paste:F,editing:b,beginRename:I,beginCreate:oe,cancelEdit:se,commitEdit:ce,requestDelete:le,copyPathToClipboard:fe,download:pe,refresh:L,onUpload:l,dropTarget:S,setDropTarget:w,onInternalDrop:me,handleKeyDown:_e,pendingDelete:T,confirmDelete:ue,cancelDelete:de};return(0,W.jsx)(so.Provider,{value:ve,children:r})}var fo=`application/x-puddle-tab`;function po(e){return JSON.stringify(e)}function mo(e){try{return T.parse(JSON.parse(e))}catch{return null}}function ho(e){return e.includes(fo)}var go={"package.json":an,"package-lock.json":un,"pnpm-lock.yaml":un,"yarn.lock":un,"pnpm-workspace.yaml":on,dockerfile:U,".gitignore":on,".gitattributes":on,"readme.md":hn,license:hn,licence:hn},_o={ts:U,tsx:U,mts:U,cts:U,js:U,jsx:U,mjs:U,cjs:U,py:U,rs:U,go:U,rb:U,php:U,java:U,kt:U,c:U,h:U,cpp:U,hpp:U,cc:U,html:U,htm:U,xml:U,vue:U,sql:U,json:an,jsonc:an,yml:on,yaml:on,toml:on,ini:on,cfg:on,conf:on,env:ln,lock:un,csv:pn,tsv:pn,xlsx:pn,xls:pn,md:hn,mdx:hn,markdown:hn,txt:hn,rtf:hn,log:hn,pdf:hn,css:gn,scss:gn,sass:gn,less:gn,sh:mn,bash:mn,zsh:mn,fish:mn,svg:cn,png:cn,jpg:cn,jpeg:cn,gif:cn,webp:cn,bmp:cn,ico:cn,avif:cn,mp4:dn,mov:dn,webm:dn,mkv:dn,avi:dn,mp3:sn,wav:sn,flac:sn,ogg:sn,m4a:sn,zip:rn,tar:rn,gz:rn,tgz:rn,rar:rn,"7z":rn};function vo(e){let t=e.toLowerCase(),n=go[t];if(n)return{Icon:n,generic:!1};let r=t.lastIndexOf(`.`);if(r>0){let e=_o[t.slice(r+1)];if(e)return{Icon:e,generic:!1}}return{Icon:_n,generic:!0}}function yo({name:e,dimmed:t}){let{Icon:n,generic:r}=vo(e);return(0,W.jsx)(n,{className:P(`size-3.5 shrink-0`,t||r?`text-fg-muted`:`text-fg`)})}var bo=14,xo=`application/x-puddle-path`;function So(e,t){let n=Array.from(e??[]).map(e=>e.webkitGetAsEntry?.()??null);return n.some(e=>e?.isDirectory)&&C.error(`Folders can't be uploaded yet — zip them first`),Array.from(t).filter((e,t)=>n[t]?.isDirectory!==!0)}function Co({children:e}){return(0,W.jsx)(`span`,{className:`ml-auto pl-6 text-2xs text-fg-muted tabular-nums`,children:e})}function wo({depth:e,initial:t,icon:n,onCommit:r,onCancel:i}){let a=(0,G.useRef)(null),o=(0,G.useRef)(!1);(0,G.useEffect)(()=>{let e=a.current;if(!e)return;e.focus();let n=t.lastIndexOf(`.`);e.setSelectionRange(0,n>0?n:t.length)},[t]);let s=()=>{o.current||(o.current=!0,r(a.current?.value??``))};return(0,W.jsxs)(`div`,{className:`flex h-6 items-center gap-1 pr-2`,style:{paddingLeft:e*bo+8},children:[(0,W.jsx)(`span`,{className:`size-3.5 shrink-0`}),n,(0,W.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 To({path:e,entry:t,depth:n}){let r=co(),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:eo(e)},d=r.statusMap.get(e),f=i?Qa(r.statusMap,e):null,p=d?Ya(d):f?Ya(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:eo(e),_=r.clipboard!==null;return r.editing?.mode===`rename`&&r.editing.path===e?(0,W.jsx)(wo,{depth:n,initial:t.name,icon:i?(0,W.jsx)(vn,{className:`size-3.5 shrink-0 text-fg`}):(0,W.jsx)(yo,{name:t.name}),onCommit:r.commitEdit,onCancel:r.cancelEdit}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Ee,{children:[(0,W.jsx)(me,{asChild:!0,children:(0,W.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=>{t.dataTransfer.setData(xo,e),i||t.dataTransfer.setData(fo,po({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=t.dataTransfer.getData(xo);n?r.onInternalDrop(e,n):r.onUpload(e,So(t.dataTransfer.items,t.dataTransfer.files))},style:{paddingLeft:n*bo+8},className:P(`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,W.jsx)(He,{className:P(`size-3.5 shrink-0 text-fg-gold transition-transform duration-150`,a&&`rotate-90`)}):(0,W.jsx)(`span`,{className:`size-3.5 shrink-0`}),t.symlink||t.type===`symlink`?(0,W.jsx)(Cn,{className:`size-3.5 shrink-0 text-fg`}):i?a?(0,W.jsx)(rt,{className:P(`size-3.5 shrink-0`,f?p?.colourClass:`text-fg`)}):(0,W.jsx)(vn,{className:P(`size-3.5 shrink-0`,f?p?.colourClass:`text-fg`)}):(0,W.jsx)(yo,{name:t.name,dimmed:d===`ignored`}),(0,W.jsx)(`span`,{className:P(`min-w-0 flex-1 truncate font-mono`,m),children:t.name}),d&&p&&p.letter&&(0,W.jsx)(`span`,{className:P(`shrink-0 font-mono text-2xs`,p.colourClass),children:p.letter})]})}),(0,W.jsxs)(Se,{children:[i&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(z,{onSelect:()=>r.beginCreate(e,`file`),children:`New File…`}),(0,W.jsx)(z,{onSelect:()=>r.beginCreate(e,`dir`),children:`New Folder…`}),(0,W.jsx)(R,{})]}),(0,W.jsxs)(z,{onSelect:()=>r.cut(h),children:[`Cut `,(0,W.jsx)(Co,{children:`⌘X`})]}),(0,W.jsxs)(z,{onSelect:()=>r.copy(h),children:[`Copy `,(0,W.jsx)(Co,{children:`⌘C`})]}),(0,W.jsxs)(z,{disabled:!_,onSelect:()=>r.paste(g),children:[`Paste `,(0,W.jsx)(Co,{children:`⌘V`})]}),(0,W.jsx)(R,{}),(0,W.jsxs)(z,{onSelect:()=>r.copyPathToClipboard(e,!1),children:[`Copy Path `,(0,W.jsx)(Co,{children:`⌥⌘C`})]}),(0,W.jsxs)(z,{onSelect:()=>r.copyPathToClipboard(e,!0),children:[`Copy Relative Path `,(0,W.jsx)(Co,{children:`⌥⇧⌘C`})]}),(0,W.jsx)(R,{}),(0,W.jsxs)(z,{onSelect:()=>r.beginRename(e),children:[`Rename… `,(0,W.jsx)(Co,{children:`F2`})]}),(0,W.jsxs)(z,{onSelect:()=>r.requestDelete(h),children:[`Delete `,(0,W.jsx)(Co,{children:`⌘⌫`})]}),(0,W.jsx)(R,{}),(0,W.jsx)(z,{onSelect:()=>r.download(e),children:`Download`})]})]}),i&&a&&(0,W.jsx)(Eo,{sid:r.sid,path:e,depth:n+1})]})}function Eo({sid:e,path:t,depth:n}){let r=co(),i=y(e,t),a={paddingLeft:n*bo+8},o=r.editing,s=o?.mode===`create`&&o.parentDir===t?(0,W.jsx)(Do,{depth:n,kind:o.kind}):null;if(i.isLoading)return(0,W.jsxs)(W.Fragment,{children:[s,(0,W.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:`Loading…`})]});if(i.isError)return(0,W.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 c=i.data?.entries??[];return c.length===0&&!s?(0,W.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:`Empty`}):(0,W.jsxs)(W.Fragment,{children:[s,c.map(e=>(0,W.jsx)(To,{path:to(t,e.name),entry:e,depth:n},e.name))]})}function Do({depth:e,kind:t}){let n=co(),[r,i]=(0,G.useState)(``);return(0,W.jsx)(wo,{depth:e,initial:r,icon:t===`dir`?(0,W.jsx)(vn,{className:`size-3.5 shrink-0 text-fg`}):(0,W.jsx)(yo,{name:r||`file`}),onCommit:e=>{i(e),n.commitEdit(e)},onCancel:n.cancelEdit})}function Oo(){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ko,{}),(0,W.jsx)(Ao,{})]})}function ko(){let e=co(),t=(0,G.useRef)(null);(0,G.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,W.jsxs)(Ee,{children:[(0,W.jsx)(me,{asChild:!0,children:(0,W.jsx)(`div`,{ref:t,"data-explorer-root":!0,role:`tree`,tabIndex:0,onKeyDown:e.handleKeyDown,onPaste:t=>e.onUpload(``,So(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=t.dataTransfer.getData(`application/x-puddle-path`);n?e.onInternalDrop(``,n):e.onUpload(``,So(t.dataTransfer.items,t.dataTransfer.files))},className:P(`h-full overflow-y-auto py-1 outline-none`,e.dropTarget===``&&`bg-selection`),children:(0,W.jsx)(Eo,{sid:e.sid,path:``,depth:0})})}),(0,W.jsxs)(Se,{children:[(0,W.jsx)(z,{onSelect:()=>e.beginCreate(``,`file`),children:`New File…`}),(0,W.jsx)(z,{onSelect:()=>e.beginCreate(``,`dir`),children:`New Folder…`}),(0,W.jsx)(R,{}),(0,W.jsx)(z,{disabled:!n,onSelect:()=>e.paste(``),children:`Paste`}),(0,W.jsx)(R,{}),(0,W.jsx)(z,{onSelect:()=>e.copyPathToClipboard(``,!1),children:`Copy Path`}),(0,W.jsx)(z,{onSelect:()=>e.download(``),children:`Download worktree`})]})]})}function Ao(){let e=co(),t=e.pendingDelete;return(0,W.jsx)(ie,{open:t!==null,onOpenChange:t=>!t&&e.cancelDelete(),children:(0,W.jsxs)(re,{children:[(0,W.jsxs)(O,{children:[(0,W.jsxs)(M,{children:[`Delete `,t&&t.length===1?`“${$a(t[0])}”`:`${t?.length??0} items`,`?`]}),(0,W.jsxs)(N,{children:[`This permanently removes `,t&&t.length>1?`them`:`it`,` from the worktree. There is no undo.`]})]}),(0,W.jsxs)(j,{children:[(0,W.jsx)(k,{variant:`ghost`,onClick:e.cancelDelete,children:`Cancel`}),(0,W.jsx)(k,{variant:`danger`,onClick:e.confirmDelete,children:`Delete`})]})]})})}var jo=/[.*+?^${}()|[\]\\]/g;function Mo(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 No(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 Po=240;function Fo(e){let t=e.replace(/^\s+/,``);return t.length>Po?`${t.slice(0,Po)}…`:t}var Io=250;function Lo({active:e,label:t,onClick:n,children:r}){return(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:n,className:P(`rounded-sm p-1 transition-colors`,e?`bg-elevated text-accent`:`text-fg-muted hover:bg-elevated hover:text-fg`),children:[r,(0,W.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,W.jsx)(V,{children:t})]})}function Ro({session:e,onOpen:t}){let[n,r]=(0,G.useState)(``),[i,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let e=setTimeout(()=>o(n),Io);return()=>clearTimeout(e)},[n]);let p={query:i,regex:s,caseSensitive:l,wholeWord:d},m=a(e,p),h=(0,G.useMemo)(()=>Mo(p),[i,s,l,d]),g=m.data,_=!!g&&(g.files.length>0||g.content.length>0);return(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 px-2 py-1.5`,children:[(0,W.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,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(Lo,{active:l,label:`Match case`,onClick:()=>u(e=>!e),children:(0,W.jsx)(Xt,{className:`size-3.5`})}),(0,W.jsx)(Lo,{active:d,label:`Match whole word`,onClick:()=>f(e=>!e),children:(0,W.jsx)(In,{className:`size-3.5`})}),(0,W.jsx)(Lo,{active:s,label:`Use regular expression`,onClick:()=>c(e=>!e),children:(0,W.jsx)(Mn,{className:`size-3.5`})})]})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:i.length===0?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Search file names and contents.`}):m.isPending?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Searching…`}):m.error?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:m.error instanceof Error?m.error.message:`Search failed`}):_?(0,W.jsxs)(W.Fragment,{children:[g.files.length>0&&(0,W.jsxs)(`section`,{children:[(0,W.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,W.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,W.jsx)(_n,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,W.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:e})]},e))]}),g.content.length>0&&(0,W.jsxs)(`section`,{children:[(0,W.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,W.jsxs)(`div`,{children:[(0,W.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,W.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,W.jsx)(`span`,{className:`shrink-0 font-mono text-2xs tabular-nums text-fg-muted`,children:n.line}),(0,W.jsx)(`span`,{className:`truncate font-mono text-2xs text-fg-secondary`,children:No(Fo(n.text),h).map((e,t)=>e.hit?(0,W.jsx)(`span`,{className:`text-accent`,children:e.text},t):(0,W.jsx)(`span`,{children:e.text},t))})]},`${n.line}:${r}`))]},e.path))]}),g.truncated&&(0,W.jsx)(`div`,{className:`px-3 py-2 text-2xs text-fg-muted`,children:`Showing the first results — refine the query for more.`})]}):(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No results.`})})]})}function zo({text:e,hoverClass:t,className:n,title:r}){let i=(0,G.useRef)(null),[a,o]=(0,G.useState)(0);return(0,G.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,W.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:(0,W.jsx)(`span`,{ref:i,title:r,className:P(`block whitespace-nowrap transition-transform duration-[900ms] ease-linear`,n,a>0&&t),style:a>0?{"--tail":`-${a}px`}:void 0,children:e})})}var Bo=new Set([`starting`,`running`,`waiting_input`]),Vo=`group-hover:[transform:translateX(var(--tail))]`;function Ho(e){return e.split(`/`).filter(Boolean).pop()??e}function Uo({children:e,className:t,title:n}){return(0,W.jsx)(`span`,{title:n,className:P(`shrink-0 text-2xs`,t),children:e})}function Wo({label:e,blockReason:t,onClick:n}){return(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,disabled:t!==null,onClick:n,className:P(`-my-1 rounded-sm p-1 text-fg-gold transition-colors hover:text-danger`,t===null?`hidden group-hover:inline-flex`:`hidden`),children:[(0,W.jsx)(Ne,{className:`size-3.5`}),(0,W.jsx)(`span`,{className:`sr-only`,children:e})]})}),(0,W.jsx)(V,{children:t?`Can't ${e.toLowerCase()} — ${t}`:e})]})}function Go({repoId:e,projectId:t,sessions:n}){let r=lt(e),i=mt(e,t),a=It(e,t),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),u=i.isPending||a.isPending,d=(0,G.useMemo)(()=>{let e=new Map;for(let t of n)Bo.has(t.status)&&e.set(t.worktree_path,(e.get(t.worktree_path)??0)+1);return e},[n]),f=(0,G.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,G.useMemo)(()=>[...r.data?.orphan_branches??[]].sort((e,t)=>e.name.localeCompare(t.name)),[r.data]);return r.isPending?(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading worktrees…`}):r.error?(0,W.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,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[f.length===0&&p.length===0&&(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktrees.`}),f.map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`div`,{className:`group flex items-center gap-1.5 px-3 pb-0.5 pt-2 text-2xs text-fg-muted`,children:[(0,W.jsx)(Sn,{className:`size-3 shrink-0 text-fg-gold`}),(0,W.jsx)(zo,{text:e,className:`font-mono`,hoverClass:Vo})]}),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,W.jsxs)(`div`,{className:`group flex items-center gap-2 px-3 py-1 pl-6 transition-colors hover:bg-elevated`,children:[(0,W.jsx)(zo,{text:Ho(e.path),title:e.path,className:`font-mono text-xs text-fg`,hoverClass:Vo}),e.is_primary&&(0,W.jsx)(Uo,{className:`text-fg-muted`,children:`clone`}),e.dirty&&(0,W.jsx)(Uo,{className:`text-waiting`,title:`Modified — uncommitted changes`,children:`M`}),t>0&&(0,W.jsx)(Uo,{className:`text-running`,title:`${t} running session${t>1?`s`:``}`,children:t}),(0,W.jsx)(Wo,{label:`Prune`,blockReason:n,onClick:()=>{l(null),s({kind:`worktree`,path:e.path,branch:e.branch})}})]},e.path)})]},`wt:${e}`)),p.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.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,W.jsxs)(`div`,{className:`group flex items-center gap-2 px-3 py-1 transition-colors hover:bg-elevated`,children:[(0,W.jsx)(Sn,{className:`size-3 shrink-0 text-fg-gold`}),(0,W.jsx)(zo,{text:e.name,className:`font-mono text-xs text-fg`,hoverClass:Vo}),e.local_only&&(0,W.jsx)(Uo,{className:`text-waiting`,children:`local only`}),(0,W.jsx)(Wo,{label:`Delete branch`,blockReason:null,onClick:()=>{l(null),s({kind:`branch`,name:e.name,localOnly:e.local_only})}})]},`br:${e.name}`))]}),(0,W.jsx)(ie,{open:o!==null,onOpenChange:e=>{e||s(null)},children:(0,W.jsxs)(re,{children:[o?.kind===`branch`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(O,{children:[(0,W.jsx)(M,{children:`Delete branch`}),(0,W.jsxs)(N,{children:[`Delete branch `,(0,W.jsx)(`span`,{className:`font-mono`,children:o.name}),`? This removes the branch from the repository.`]})]}),o.localOnly&&(0,W.jsxs)(`p`,{className:`text-xs text-waiting`,children:[(0,W.jsx)(`span`,{className:`font-mono`,children:o.name}),` has commits on no remote — deleting it discards that work permanently.`]})]}):(0,W.jsxs)(O,{children:[(0,W.jsx)(M,{children:`Prune worktree`}),(0,W.jsxs)(N,{children:[`Remove `,(0,W.jsx)(`span`,{className:`font-mono`,children:o?Ho(o.path):``}),`? The working directory is deleted; the branch`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:o?.branch??``}),` is kept.`]})]}),c&&(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:c}),(0,W.jsxs)(j,{children:[(0,W.jsx)(k,{type:`button`,variant:`ghost`,onClick:()=>s(null),children:`Cancel`}),(0,W.jsx)(k,{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 Ko=`DropdownMenu`,[qo,Jo]=D(Ko,[de]),X=de(),[Yo,Xo]=qo(Ko),Zo=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=X(t),l=G.useRef(null),[u,d]=ee({prop:i,defaultProp:a??!1,onChange:o,caller:Ko});return(0,W.jsx)(Yo,{scope:t,triggerId:te(),triggerRef:l,contentId:te(),open:u,onOpenChange:d,onOpenToggle:G.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,W.jsx)(L,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};Zo.displayName=Ko;var Qo=`DropdownMenuTrigger`,$o=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Xo(Qo,n),o=X(n),s=E(t,a.triggerRef);return(0,W.jsx)(be,{asChild:!0,...o,children:(0,W.jsx)(ae.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:ne(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:ne(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});$o.displayName=Qo;var es=`DropdownMenuPortal`,ts=e=>{let{__scopeDropdownMenu:t,...n}=e,r=X(t);return(0,W.jsx)(fe,{...r,...n})};ts.displayName=es;var ns=`DropdownMenuContent`,rs=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Xo(ns,n),a=X(n),o=G.useRef(!1);return(0,W.jsx)(ge,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:ne(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:ne(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)`}})});rs.displayName=ns;var is=`DropdownMenuGroup`,as=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,W.jsx)(we,{...i,...r,ref:t})});as.displayName=is;var os=`DropdownMenuLabel`,ss=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,W.jsx)(_e,{...i,...r,ref:t})});ss.displayName=os;var cs=`DropdownMenuItem`,ls=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,W.jsx)(xe,{...i,...r,ref:t})});ls.displayName=cs;var us=`DropdownMenuCheckboxItem`,ds=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,W.jsx)(he,{...i,...r,ref:t})});ds.displayName=us;var fs=`DropdownMenuRadioGroup`,ps=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,W.jsx)(Oe,{...i,...r,ref:t})});ps.displayName=fs;var ms=`DropdownMenuRadioItem`,hs=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,W.jsx)(je,{...i,...r,ref:t})});hs.displayName=ms;var gs=`DropdownMenuItemIndicator`,_s=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,W.jsx)(ve,{...i,...r,ref:t})});_s.displayName=gs;var vs=`DropdownMenuSeparator`,ys=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,W.jsx)(Ae,{...i,...r,ref:t})});ys.displayName=vs;var bs=`DropdownMenuArrow`,xs=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,W.jsx)(De,{...i,...r,ref:t})});xs.displayName=bs;var Ss=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=X(t),[s,c]=ee({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,W.jsx)(ue,{...o,open:s,onOpenChange:c,children:n})},Cs=`DropdownMenuSubTrigger`,ws=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,W.jsx)(ke,{...i,...r,ref:t})});ws.displayName=Cs;var Ts=`DropdownMenuSubContent`,Es=G.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=X(n);return(0,W.jsx)(oe,{...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)`}})});Es.displayName=Ts;var Ds=Zo,Os=$o,ks=ts,As=rs,js=ls,Ms=ys,Ns=Ss,Ps=ws,Fs=Es,Is=Ds,Ls=Os,Rs=Ns;function zs({className:e,sideOffset:t=4,...n}){return(0,W.jsx)(ks,{children:(0,W.jsx)(As,{sideOffset:t,className:P(`z-50 min-w-36 overflow-hidden rounded-md bg-elevated p-1 shadow-xl`,e),...n})})}function Bs({className:e,...t}){return(0,W.jsx)(js,{className:P(_t,Je,`[&_svg]:size-3.5`,e),...t})}function Vs({className:e,children:t,...n}){return(0,W.jsxs)(Ps,{className:P(_t,Je,`data-[state=open]:bg-action data-[state=open]:text-action-ink [&_svg]:size-3.5`,e),...n,children:[t,(0,W.jsx)(He,{className:`ml-auto`})]})}function Hs({className:e,...t}){return(0,W.jsx)(ks,{children:(0,W.jsx)(Fs,{className:P(`z-50 min-w-36 overflow-hidden rounded-md bg-elevated p-1 shadow-xl`,e),...t})})}function Us({className:e,...t}){return(0,W.jsx)(Ms,{className:P(`-mx-1 my-1 h-px bg-border`,e),...t})}function Ws(e,t){if(!t)return e;let n=t.endsWith(`/`)?t.slice(0,-1):t;return n===``||n===`/`?e:e===n?`~`:e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function Gs({text:e,className:t}){let n=(0,G.useRef)(null);return(0,G.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,W.jsx)(`div`,{ref:n,className:`no-scrollbar min-w-0 flex-1 overflow-x-auto`,children:(0,W.jsx)(`span`,{className:P(`inline-block whitespace-nowrap`,t),children:e})})}function Ks({sessions:e,target:t,showFileActions:n=!1,showPath:r=!1}){let{session:i,pinned:a,pin:o,unpin:s}=t,c=Dt().data?.home,l=e.filter(e=>e.status!==`archived`),u=i?i.branch||xt(i):`No worktree`,d=i?Ws(i.worktree_path,c):`No worktree`;return(0,W.jsxs)(`div`,{className:`group relative flex h-8 shrink-0 items-center px-2`,children:[(0,W.jsx)(Gs,{text:r?d:u,className:`font-mono text-xs text-fg-secondary`}),(0,W.jsxs)(`div`,{className:P(`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,W.jsx)(Js,{}),(0,W.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:P(`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,W.jsx)(An,{className:P(`size-3.5`,a&&`fill-current`)}),(0,W.jsx)(`span`,{className:`sr-only`,children:a?`Unpin sidebar`:`Pin sidebar`})]}),(0,W.jsxs)(Is,{children:[(0,W.jsx)(Ls,{asChild:!0,children:(0,W.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,W.jsx)(Ve,{className:`size-3.5`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Choose a worktree`})]})}),(0,W.jsx)(zs,{align:`end`,children:l.length===0?(0,W.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-fg-muted`,children:`No sessions yet`}):l.map(e=>(0,W.jsx)(Bs,{onSelect:()=>o(e.id),children:(0,W.jsxs)(`span`,{className:`truncate font-mono`,children:[e.branch,` — `,xt(e)]})},e.id))})]})]})]})}var qs=[{key:`new-file`,label:`New File`,icon:fn},{key:`new-folder`,label:`New Folder`,icon:yn},{key:`refresh`,label:`Refresh`,icon:gt},{key:`collapse`,label:`Collapse Folders`,icon:Zt}];function Js(){let e=lo();if(!e)return null;let t=t=>{t===`new-file`?e.beginCreate(``,`file`):t===`new-folder`?e.beginCreate(``,`dir`):t===`refresh`?e.refresh():t===`collapse`&&e.collapseAll()};return(0,W.jsx)(`div`,{className:`hidden shrink-0 items-center gap-0.5 group-hover:flex group-focus-within:flex`,children:qs.map(({key:e,label:n,icon:r})=>(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.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,W.jsx)(r,{className:`size-3.5`}),(0,W.jsx)(`span`,{className:`sr-only`,children:n})]})}),(0,W.jsx)(V,{children:n})]},e))})}var Ys=[{key:`files`,label:`Files`,icon:bn},{key:`search`,label:`Search`,icon:qe},{key:`changes`,label:`Changes`,icon:Sn},{key:`worktrees`,label:`Worktrees`,icon:Ue}];function Xs(e){return e===`diff`||e===`history`||e===`changes`?`changes`:e===`search`?`search`:e===`worktrees`?`worktrees`:`files`}function Zs({mode:e,onExpand:t,onSelect:n}){return(0,W.jsxs)(`div`,{className:`flex h-full w-9 shrink-0 flex-col items-center gap-1 bg-surface py-1.5`,children:[(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.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,W.jsx)(Dn,{className:`size-4`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Show sidebar`})]})}),(0,W.jsx)(V,{side:`right`,children:`Show sidebar`})]}),Ys.map(({key:t,label:r,icon:i})=>(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,"aria-current":e===t?`page`:void 0,onClick:()=>n(t),className:P(`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,W.jsx)(i,{className:`size-4`}),(0,W.jsx)(`span`,{className:`sr-only`,children:r})]})}),(0,W.jsx)(V,{side:`right`,children:r})]},t))]})}function Qs({mode:e,onModeChange:t,onCollapse:n,projectId:r,repoId:i,sessions:a,target:o,onOpenFile:s,activeFilePath:c,activeDiffPath:l,onOpenDiff:u,onOpenCommitFile:d,onOpenSearchFile:f}){let{session:p}=o;return(0,W.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5`,children:[Ys.map(({key:n,label:r,icon:i})=>(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,"aria-current":e===n?`page`:void 0,onClick:()=>t(n),className:P(`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,W.jsx)(i,{className:`size-4`}),(0,W.jsx)(`span`,{className:`sr-only`,children:r})]})}),(0,W.jsx)(V,{children:r})]},n)),(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.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,W.jsx)(En,{className:`size-4`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Hide sidebar`})]})}),(0,W.jsx)(V,{children:`Hide sidebar`})]})]}),e!==`worktrees`&&e!==`files`&&(0,W.jsx)(Ks,{sessions:a,target:o,showPath:e===`search`}),e===`worktrees`&&(0,W.jsx)(Go,{repoId:i,projectId:r,sessions:a}),e===`files`&&(p?(0,W.jsxs)(uo,{session:p,onOpenFile:s,activePath:c,children:[(0,W.jsx)(Ks,{sessions:a,target:o,showFileActions:!0,showPath:!0}),(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,W.jsx)(Oo,{})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ks,{sessions:a,target:o}),(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to show.`})]})),e===`changes`&&(p?(0,W.jsx)(qa,{session:p.id,activeDiffPath:l,onOpenDiff:u,onOpenCommitFile:d},p.id):(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to show.`})),e===`search`&&(p?(0,W.jsx)(Ro,{session:p.id,onOpen:f},p.id):(0,W.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to search.`}))]})}function $s({projectId:e,repoId:t,open:n,kind:r=`agent`,seedAccountId:i,onOpenChange:a,onCreated:o}){let s=r===`terminal`,c=ut(),l=vt(c??void 0),u=Gt(c??void 0),d=Nt(),f=jt(),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(!0),[y,b]=(0,G.useState)(!0),[x,S]=(0,G.useState)(``),[C,w]=(0,G.useState)(``),[T,E]=(0,G.useState)(!1),[D,ee]=(0,G.useState)(null),te=d.data?.find(e=>e.id===t),A=Ze(n?t:void 0),ne=lt(n?t:void 0),ae=l.data?.find(e=>String(e.id)===p),F=u.data?.allowSkipPermissions===!0,I=!s&&F&&ae?.skip_permissions_default===!0,oe=h.trim()||te?.default_base_branch||``,se=(0,G.useMemo)(()=>(ne.data?.worktrees??[]).filter(e=>e.branch===oe).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})),[ne.data,oe]),ce=!_&&!y,le=se.find(e=>e.is_primary)?.path??se[0]?.path??``,ue=C||le,de=(0,G.useMemo)(()=>{let e=u.data?.default_account_id;return l.data?.find(e=>e.id===i)??l.data?.find(t=>typeof e==`number`&&t.id===e)??l.data?.[0]},[l.data,u.data,i]),fe=p||(de?String(de.id):``);(0,G.useEffect)(()=>{n&&i!==void 0&&m(String(i))},[n,i]);let pe=(0,G.useRef)(u.data);pe.current=u.data,(0,G.useEffect)(()=>{if(n){let e=Be(s?`terminal`:`agent`,pe.current);g(e.baseBranch),v(e.separateBranch),b(e.separateWorktree),w(``)}},[n,s]);let L=()=>{ee(null),f.mutate({project_id:e,...s?{kind:`terminal`}:{account_id:Number(fe)},...h.trim()?{base_branch:h.trim()}:{},separate_branch:_,..._&&x.trim()?{branch:x.trim()}:{},..._?{}:{separate_worktree:y},...ce&&ue?{join_worktree:ue}:{},...I&&T?{skip_permissions:!0}:{}},{onSuccess:e=>{a(!1),S(``),E(!1),o(e)},onError:e=>ee(e.message)})},me=s?`a shell`:`an agent`,he=_?`on a new branch off ${oe||`…`}, in its own directory`:ce?`on ${oe||`…`}, sharing an existing directory`:`on ${oe||`…`}, in its own directory`;return(0,W.jsx)(ie,{open:n,onOpenChange:a,children:(0,W.jsxs)(re,{children:[(0,W.jsxs)(O,{children:[(0,W.jsx)(M,{children:s?`New terminal`:`New agent`}),(0,W.jsxs)(N,{children:[s?`Opens`:`Spawns`,` `,me,` `,he,`.`]})]}),(0,W.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),(s||fe)&&L()},children:[!s&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(tt,{children:`Account`}),l.data?.length===0?(0,W.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No accounts yet —`,` `,(0,W.jsx)(`button`,{type:`button`,className:`text-accent underline`,onClick:()=>Ge(`accounts`),children:`add one in settings`}),`.`]}):(0,W.jsxs)(Re,{value:fe,onValueChange:m,children:[(0,W.jsx)(Le,{children:(0,W.jsx)(ze,{placeholder:`pick an account`})}),(0,W.jsx)(Pe,{children:l.data?.map(e=>(0,W.jsxs)(Me,{value:String(e.id),children:[(0,W.jsxs)(`span`,{className:`font-mono`,children:[e.agent_type,`/`,e.label]}),!e.logged_in&&(0,W.jsx)(`span`,{className:`ml-2 text-2xs text-waiting`,children:`not logged in`})]},e.id))})]})]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,W.jsx)(tt,{htmlFor:`base-branch`,children:`Base branch`}),(0,W.jsx)(Xe,{id:`base-branch`,placeholder:te?.default_base_branch??`main`,value:h,onValueChange:g,hints:(A.data?.branches??[]).filter(e=>e.name.toLowerCase().includes(h.trim().toLowerCase())).slice(0,20).map(e=>({value:e.name,badge:e.name===te?.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]`})]}),_&&(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,W.jsx)(tt,{htmlFor:`session-branch`,children:`New branch`}),(0,W.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`optional`})]}),(0,W.jsx)(it,{id:`session-branch`,placeholder:`leave blank for auto`,value:x,onChange:e=>S(e.target.value),className:`font-mono`})]})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Ie,{id:`separate-branch`,checked:_,onCheckedChange:e=>{v(e),e&&b(!0)}}),(0,W.jsx)(tt,{htmlFor:`separate-branch`,children:`Use separate branch`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(Ie,{id:`separate-worktree`,checked:_?!0:y,disabled:_,onCheckedChange:b}),(0,W.jsx)(tt,{htmlFor:`separate-worktree`,className:P(_&&`text-fg-muted`),children:`Use separate directory`})]})]}),ce&&(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(tt,{htmlFor:`join-dir`,children:`Directory to join`}),se.length===0?(0,W.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`No existing directory on `,(0,W.jsx)(`span`,{className:`font-mono`,children:oe||`…`}),` — a shared one will be created for later sessions to join.`]}):(0,W.jsxs)(Re,{value:ue,onValueChange:w,children:[(0,W.jsx)(Le,{id:`join-dir`,children:(0,W.jsx)(ze,{})}),(0,W.jsx)(Pe,{children:se.map(e=>(0,W.jsxs)(Me,{value:e.path,children:[(0,W.jsx)(`span`,{className:`truncate`,children:e.label}),(0,W.jsx)(`span`,{className:`ml-2 truncate font-mono text-2xs text-fg-muted`,children:e.path})]},e.path))})]})]}),!_&&!s&&(0,W.jsxs)(`p`,{className:`text-xs text-waiting`,children:[`The `,s?`shell`:`agent`,` commits straight to`,` `,(0,W.jsx)(`span`,{className:`font-mono`,children:oe||`…`}),ce?` and shares its working directory with concurrent sessions — they can trample each other’s edits.`:`.`]}),I&&(0,W.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-surface px-3 py-2`,children:[(0,W.jsx)(Ie,{id:`skip-permissions`,checked:T,onCheckedChange:E}),(0,W.jsx)(tt,{htmlFor:`skip-permissions`,className:`text-waiting`,children:`Skip permission prompts for this session`})]}),D&&(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:D}),(0,W.jsxs)(j,{children:[(0,W.jsx)(k,{type:`button`,variant:`ghost`,onClick:()=>a(!1),children:`Cancel`}),(0,W.jsx)(k,{type:`submit`,disabled:!s&&!fe||f.isPending,children:s?`Open terminal`:`Start agent`})]})]})]})})}function ec({className:e}){return(0,W.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:e,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,"aria-hidden":!0,children:[(0,W.jsx)(`line`,{x1:`12`,y1:`12`,x2:`22`,y2:`12`}),(0,W.jsx)(`line`,{x1:`12`,y1:`12`,x2:`17`,y2:`20.66`}),(0,W.jsx)(`line`,{x1:`12`,y1:`12`,x2:`7`,y2:`20.66`}),(0,W.jsx)(`line`,{x1:`12`,y1:`12`,x2:`2`,y2:`12`}),(0,W.jsx)(`line`,{x1:`12`,y1:`12`,x2:`7`,y2:`3.34`}),(0,W.jsx)(`line`,{x1:`12`,y1:`12`,x2:`17`,y2:`3.34`}),(0,W.jsx)(`line`,{x1:`12`,y1:`12`,x2:`17.63`,y2:`15.25`}),(0,W.jsx)(`line`,{x1:`12`,y1:`12`,x2:`12`,y2:`18.5`}),(0,W.jsx)(`line`,{x1:`12`,y1:`12`,x2:`6.37`,y2:`15.25`}),(0,W.jsx)(`line`,{x1:`12`,y1:`12`,x2:`6.37`,y2:`8.75`}),(0,W.jsx)(`line`,{x1:`12`,y1:`12`,x2:`12`,y2:`5.5`}),(0,W.jsx)(`line`,{x1:`12`,y1:`12`,x2:`17.63`,y2:`8.75`})]})}function tc({className:e}){return(0,W.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:e,fill:`none`,stroke:`currentColor`,strokeWidth:1.6,"aria-hidden":!0,children:[(0,W.jsx)(`ellipse`,{cx:`12`,cy:`12`,rx:`4`,ry:`9`}),(0,W.jsx)(`ellipse`,{cx:`12`,cy:`12`,rx:`4`,ry:`9`,transform:`rotate(60 12 12)`}),(0,W.jsx)(`ellipse`,{cx:`12`,cy:`12`,rx:`4`,ry:`9`,transform:`rotate(120 12 12)`})]})}function nc({type:e,className:t}){switch(e){case`claude-code`:return(0,W.jsx)(ec,{className:t});case`codex`:return(0,W.jsx)(tc,{className:t});default:return(0,W.jsx)(ft,{className:t})}}function rc({initial:e,defaultScope:t,agents:n,onSave:r,onCancel:i}){let[a,o]=(0,G.useState)(e?.title??``),[s,c]=(0,G.useState)(e?.body??``),[l,u]=(0,G.useState)(e?.scope??t),[d,f]=(0,G.useState)((e?.tags??[]).join(`, `)),[p,m]=(0,G.useState)(e?.agent_type??null),h=()=>{let e=s.trim();e&&r({title:a.trim()||null,body:e,scope:l,tags:d.split(`,`).map(e=>e.trim()).filter(Boolean),agent_type:p})};return(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsx)(it,{value:a,placeholder:`Title (optional)`,spellCheck:!1,onChange:e=>o(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`text-sm`}),(0,W.jsx)(pt,{autoFocus:!0,value:s,placeholder:`Prompt or note…`,spellCheck:!1,rows:4,onChange:e=>c(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`?i():e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&h()},className:`resize-y text-xs`}),(0,W.jsx)(it,{value:d,placeholder:`tags, comma, separated`,spellCheck:!1,onChange:e=>f(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-7 text-xs`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-2xs text-fg-secondary`,children:[(0,W.jsx)(Ie,{checked:l===`profile`,onCheckedChange:e=>u(e?`profile`:`project`)}),`Profile-wide`]}),(0,W.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:n.map(e=>(0,W.jsxs)(`button`,{type:`button`,title:e.display_name,"aria-pressed":p===e.id,onClick:()=>m(t=>t===e.id?null:e.id),className:P(`rounded-md p-1 transition-colors`,p===e.id?`bg-surface text-fg`:`text-fg-gold hover:bg-surface hover:text-fg`),children:[(0,W.jsx)(nc,{type:e.id,className:`size-3.5`}),(0,W.jsx)(`span`,{className:`sr-only`,children:e.display_name})]},e.id))})]}),(0,W.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,W.jsx)(k,{variant:`ghost`,size:`sm`,onClick:i,children:`Cancel`}),(0,W.jsx)(k,{size:`sm`,disabled:!s.trim(),onClick:h,children:`Save`})]})]})}function ic({profileId:e,projectId:t,onInsert:n}){let r=Ke(e??void 0,t).data??[],i=bt().data??[],a=zt(),o=Ct(),s=Tt(),[c,l]=(0,G.useState)(null),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(null),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(null),v=(0,G.useMemo)(()=>[...new Set(r.flatMap(e=>e.tags))].sort((e,t)=>e.localeCompare(t)),[r]),y=(0,G.useMemo)(()=>[...new Set(r.map(e=>e.agent_type).filter(e=>e!==null))],[r]),b=u!==null||f!==null,x=r.filter(e=>(u===null||e.tags.includes(u))&&(f===null||e.agent_type===f)),S=b?x:g??r,w=typeof c==`number`?r.find(e=>e.id===c):void 0,T=n=>{e&&(a.mutate({profile_id:e,scope:n.scope,project_id:n.scope===`project`?t:void 0,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0}),l(null))},E=(e,n)=>{o.mutate({id:e,scope:n.scope,project_id:n.scope===`project`?t:null,title:n.title,body:n.body,tags:n.tags,agent_type:n.agent_type}),l(null)},D=(e,t)=>{let n=g??r,i=n.findIndex(t=>t.id===e),a=n.findIndex(e=>e.id===t);if(i===-1||a===-1||i===a)return;let o=n.slice(),[s]=o.splice(i,1);o.splice(a,0,s),_(o)},ee=()=>{let e=m,t=g;if(h(null),_(null),e===null||!t)return;let n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t[n-1],i=t[n+1],a=r?i?(r.position+i.position)/2:r.position+1:(i?i.position:0)-1;o.mutate({id:e,position:a})},te=e=>{navigator.clipboard?.writeText(e.body),C.success(`Copied to clipboard`)};return(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 px-3 pb-1 pt-2`,children:[(0,W.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Scratchpad`}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>l(c===`new`?null:`new`),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,W.jsx)(et,{className:`size-4`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`New entry`})]})]}),(v.length>0||y.length>0)&&(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-3 pb-2`,children:[v.map(e=>(0,W.jsx)(`button`,{type:`button`,onClick:()=>d(t=>t===e?null:e),className:P(`rounded-full px-2 py-0.5 text-2xs transition-colors`,u===e?`bg-action text-action-ink`:`bg-elevated text-fg-secondary hover:text-fg`),children:e},e)),y.map(e=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":f===e,onClick:()=>p(t=>t===e?null:e),className:P(`rounded-md p-1 transition-colors`,f===e?`bg-action text-action-ink`:`text-fg-gold hover:bg-elevated`),children:(0,W.jsx)(nc,{type:e,className:`size-3.5`})},e))]}),(0,W.jsxs)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto pb-2`,children:[S.length===0&&(0,W.jsx)(`p`,{className:`px-3 py-3 text-xs text-fg-muted`,children:b?`Nothing matches this filter.`:`No entries yet — press + to add one.`}),(0,W.jsx)(`ul`,{className:`flex flex-col`,children:S.map(e=>(0,W.jsx)(`li`,{draggable:!b,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,h(e.id)},onDragOver:t=>{m!==null&&(t.preventDefault(),m!==e.id&&D(m,e.id))},onDragEnd:ee,onClick:t=>{t.target.closest(`button`)||l(e.id)},className:P(`transition-opacity`,m===e.id&&`opacity-50`),children:(0,W.jsx)(ac,{entry:e,onInsert:()=>n(e.body),onCopy:()=>te(e),onEdit:()=>l(e.id),onDelete:()=>s.mutate(e.id)})},e.id))})]}),(0,W.jsx)(ie,{open:c!==null,onOpenChange:e=>!e&&l(null),children:(0,W.jsxs)(re,{className:`max-w-md`,children:[(0,W.jsx)(O,{children:(0,W.jsx)(M,{children:c===`new`?`New entry`:`Edit entry`})}),c!==null&&(0,W.jsx)(rc,{initial:w,defaultScope:`project`,agents:i,onSave:e=>c===`new`?T(e):E(c,e),onCancel:()=>l(null)})]})})]})}function ac({entry:e,onInsert:t,onCopy:n,onEdit:r,onDelete:i}){let a=e.title||e.body.split(`
3
+ `,1)[0],[o,s]=(0,G.useState)(!1);return(0,W.jsx)(`div`,{className:`group flex cursor-pointer gap-1.5 px-3 py-1.5 transition-colors hover:bg-elevated`,children:(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg`,children:a}),(0,W.jsx)(`span`,{className:`shrink-0 text-2xs uppercase tracking-wide text-fg-muted`,children:e.scope===`profile`?`Profile`:`Project`}),e.agent_type&&(0,W.jsx)(nc,{type:e.agent_type,className:`size-3 text-fg-gold`})]}),e.title&&(0,W.jsx)(`p`,{className:`mt-0.5 line-clamp-2 whitespace-pre-wrap text-2xs text-fg-muted`,children:e.body}),e.tags.length>0&&(0,W.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.tags.map(e=>(0,W.jsx)(`span`,{className:`rounded-full bg-elevated px-1.5 text-2xs text-fg-secondary`,children:e},e))}),o?(0,W.jsxs)(`div`,{className:`mt-1 flex flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:`Delete this entry? This can’t be undone.`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>{s(!1),i()},className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:`Delete`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]})]}):(0,W.jsxs)(`div`,{className:`mt-1 hidden items-center gap-1 group-hover:flex`,children:[(0,W.jsx)(oc,{icon:Qt,label:`Insert into focused terminal`,onClick:t}),(0,W.jsx)(oc,{icon:Fe,label:`Copy`,onClick:n}),(0,W.jsx)(oc,{icon:ht,label:`Edit`,onClick:r}),(0,W.jsx)(oc,{icon:Ne,label:`Delete`,onClick:()=>s(!0)})]})]})})}function oc({icon:e,label:t,onClick:n}){return(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,W.jsx)(e,{className:`size-3.5`}),(0,W.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,W.jsx)(V,{children:t})]})}function sc({status:e,kind:t=`agent`,className:n}){return(0,W.jsx)(`span`,{className:P(`status-dot`,n),"data-status":e,"data-kind":t,role:`img`,"aria-label":`${t===`terminal`?`terminal `:``}status: ${e.replace(`_`,` `)}`})}var cc=[`starting`,`running`,`waiting_input`],lc=[`exited`,`interrupted`],uc={Item:Bs,Separator:Us,Sub:Rs,SubTrigger:Vs,SubContent:Hs},dc={Item:z,Separator:R,Sub:pe,SubTrigger:Te,SubContent:Ce};function fc(e,t){let n=Mt(`resume`),r=Mt(`kill`),i=We(),a=$e(),o=Qe(),s=Lt(),c=Ot(),l=jt(),u=St(),d=ut(),f=vt(d??void 0),p=Gt(d??void 0),[m,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(e.title??``),[b,x]=(0,G.useState)(null),S=(f.data??[]).filter(t=>t.agent_type===e.agent_type),w=!e.worktree_missing&&e.status!==`archived`&&S.some(t=>t.id!==e.account_id),T=p.data?.default_account_id,E=typeof T==`number`?T:null,D=(f.data??[]).filter(e=>e.logged_in),ee=E===null?D:[...D.filter(e=>e.id===E),...D.filter(e=>e.id!==E)];return{menu:{session:e,resumable:lc.includes(e.status),live:cc.includes(e.status),archived:e.status===`archived`,canMigrate:w,sameAgent:S,resume:()=>n.mutate(e.id,{onError:e=>C.error(e.message)}),openKill:()=>h(`kill`),openClearEnv:()=>h(`clear-env`),openTerminal:()=>l.mutate({project_id:e.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void u(`/project/${e.project_id}/session/${e.id}`),onError:e=>C.error(e.message)}),spawnAccounts:ee,defaultAccountId:E,spawnAgent:t=>l.mutate({project_id:e.project_id,account_id:t,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void u(`/project/${e.project_id}/session/${e.id}`),onError:e=>C.error(e.message)}),openRename:()=>{y(e.title??``),_(!0)},archive:()=>i.mutate(e.id,{onSuccess:()=>t?.(e.id),onError:e=>C.error(e.message)}),unarchive:()=>a.mutate(e.id,{onError:e=>C.error(e.message)}),setMigrateTo:x},dialogs:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ie,{open:m===`clear-env`,onOpenChange:e=>{e||h(null)},children:(0,W.jsxs)(re,{children:[(0,W.jsxs)(O,{children:[(0,W.jsx)(M,{children:`Clear captured environment?`}),(0,W.jsx)(N,{children:`Variables exported in this session’s terminals will no longer be injected into new shells or agent restarts.`})]}),(0,W.jsxs)(j,{children:[(0,W.jsx)(k,{variant:`ghost`,onClick:()=>h(null),children:`Cancel`}),(0,W.jsx)(k,{variant:`danger`,disabled:c.isPending,onClick:()=>c.mutate(e.id,{onSuccess:e=>{h(null),C.success(e.cleared===0?`Nothing was captured`:`Cleared ${e.cleared} captured var${e.cleared===1?``:`s`}`)},onError:e=>{h(null),C.error(e.message)}}),children:`Clear captured env`})]})]})}),(0,W.jsx)(ie,{open:m===`kill`,onOpenChange:e=>{e||h(null)},children:(0,W.jsxs)(re,{children:[(0,W.jsxs)(O,{children:[(0,W.jsx)(M,{children:`Kill this session?`}),(0,W.jsx)(N,{children:`The agent process stops (SIGTERM, then SIGKILL). The conversation stays resumable.`})]}),(0,W.jsxs)(j,{children:[(0,W.jsx)(k,{variant:`ghost`,onClick:()=>h(null),children:`Cancel`}),(0,W.jsx)(k,{variant:`danger`,disabled:r.isPending,onClick:()=>r.mutate(e.id,{onSuccess:()=>h(null),onError:e=>{h(null),C.error(e.message)}}),children:`Kill session`})]})]})}),(0,W.jsx)(ie,{open:g,onOpenChange:_,children:(0,W.jsxs)(re,{children:[(0,W.jsxs)(O,{children:[(0,W.jsx)(M,{children:`Rename session`}),(0,W.jsx)(N,{children:`Leave it empty to use the agent’s own session name.`})]}),(0,W.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:t=>{t.preventDefault(),o.mutate({sessionId:e.id,title:v.trim()},{onSuccess:()=>_(!1),onError:e=>C.error(e.message)})},children:[(0,W.jsx)(it,{value:v,onChange:e=>y(e.target.value),placeholder:e.agent_title??e.osc_title??e.id.slice(0,8),autoFocus:!0}),(0,W.jsxs)(j,{children:[(0,W.jsx)(k,{type:`button`,variant:`ghost`,onClick:()=>_(!1),children:`Cancel`}),(0,W.jsx)(k,{type:`submit`,disabled:o.isPending,children:`Rename`})]})]})]})}),(0,W.jsx)(ie,{open:b!==null,onOpenChange:e=>!e&&x(null),children:(0,W.jsxs)(re,{children:[(0,W.jsxs)(O,{children:[(0,W.jsxs)(M,{children:[`Move this session to `,b?.label,`?`]}),(0,W.jsx)(N,{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,W.jsxs)(j,{children:[(0,W.jsx)(k,{variant:`ghost`,onClick:()=>x(null),children:`Cancel`}),(0,W.jsx)(k,{disabled:s.isPending,onClick:()=>{b&&s.mutate({sessionId:e.id,accountId:b.id},{onSuccess:()=>{x(null),C.success(`Moved to ${b.label}`)},onError:e=>{x(null),C.error(e.message)}})},children:`Move session`})]})]})})]})}}function pc({kit:e,menu:t}){let{Item:n,Separator:r,Sub:i,SubTrigger:a,SubContent:o}=e,{session:s}=t;return(0,W.jsxs)(W.Fragment,{children:[t.resumable&&!s.worktree_missing&&(0,W.jsxs)(n,{onSelect:t.resume,children:[(0,W.jsx)(jn,{}),` Resume`]}),t.live&&(0,W.jsxs)(n,{onSelect:t.openKill,children:[(0,W.jsx)(Pn,{}),` Kill`]}),(0,W.jsxs)(n,{onSelect:t.openRename,children:[(0,W.jsx)(ht,{}),` Rename`]}),!t.archived&&(0,W.jsxs)(n,{onSelect:t.openClearEnv,children:[(0,W.jsx)(en,{}),` Clear captured env`]}),t.canMigrate&&(0,W.jsxs)(i,{children:[(0,W.jsxs)(a,{children:[(0,W.jsx)(Fn,{}),` Move to account…`]}),(0,W.jsx)(o,{children:t.sameAgent.map(e=>{let r=e.id===s.account_id;return(0,W.jsxs)(n,{disabled:r,onSelect:()=>t.setMigrateTo(e),children:[e.label,r&&(0,W.jsx)(`span`,{className:`ml-auto text-fg-muted`,children:`current`})]},e.id)})})]}),!s.worktree_missing&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(r,{}),(0,W.jsxs)(n,{onSelect:t.openTerminal,children:[(0,W.jsx)(Kt,{}),` Open terminal in worktree`]}),t.spawnAccounts.length>0&&(0,W.jsxs)(i,{children:[(0,W.jsxs)(a,{children:[(0,W.jsx)(Rt,{}),` Spawn agent in worktree`]}),(0,W.jsx)(o,{children:t.spawnAccounts.map(e=>(0,W.jsxs)(n,{onSelect:()=>t.spawnAgent(e.id),children:[(0,W.jsx)(nc,{type:e.agent_type,className:`size-4 shrink-0`}),e.agent_type,`/`,e.label,e.id===t.defaultAccountId&&(0,W.jsx)(`span`,{className:`ml-auto pl-3 text-fg-muted`,children:`default`})]},e.id))})]}),(0,W.jsxs)(n,{onSelect:()=>{window.location.href=Vt(`vscode`,s.worktree_path,Pt())},children:[(0,W.jsx)(tn,{}),` Open in VS Code`]}),(0,W.jsxs)(n,{onSelect:()=>{window.location.href=Vt(`cursor`,s.worktree_path,Pt())},children:[(0,W.jsx)(tn,{}),` Open in Cursor`]})]}),t.resumable&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(r,{}),(0,W.jsxs)(n,{onSelect:t.archive,children:[(0,W.jsx)(I,{}),` Archive`]})]}),t.archived&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(r,{}),(0,W.jsxs)(n,{onSelect:t.unarchive,children:[(0,W.jsx)(ye,{}),` Unarchive`]})]})]})}function mc({menu:e}){return(0,W.jsxs)(Is,{children:[(0,W.jsx)(Ls,{asChild:!0,children:(0,W.jsxs)(k,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:e=>e.preventDefault(),children:[(0,W.jsx)($t,{}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Session actions`})]})}),(0,W.jsx)(zs,{align:`end`,children:(0,W.jsx)(pc,{kit:uc,menu:e})})]})}function hc({session:e,onArchived:t,children:n}){let{menu:r,dialogs:i}=fc(e,t);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Ee,{children:[(0,W.jsx)(me,{asChild:!0,children:typeof n==`function`?n(r):n}),(0,W.jsx)(Se,{children:(0,W.jsx)(pc,{kit:dc,menu:r})})]}),i]})}function gc({menu:e}){return(0,W.jsx)(Se,{children:(0,W.jsx)(pc,{kit:dc,menu:e})})}function _c({icon:e,label:t,onClick:n,active:r=!1}){return(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":r,className:P(`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,W.jsx)(e,{className:`size-4`}),(0,W.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,W.jsx)(V,{children:t})]})}function vc({session:e}){return(0,W.jsxs)(`span`,{className:`flex flex-col`,children:[(0,W.jsx)(`span`,{children:kt()(e)}),(0,W.jsx)(`span`,{className:`font-mono text-2xs text-fg-muted`,children:e.branch})]})}function yc({session:e,activeSessionId:t,onPromote:n,onArchived:r}){let{menu:i,dialogs:a}=fc(e,r),o=kt();return(0,W.jsxs)(Ee,{children:[(0,W.jsxs)(B,{children:[(0,W.jsx)(me,{asChild:!0,children:(0,W.jsx)(H,{asChild:!0,children:(0,W.jsxs)(At,{draggable:!1,"aria-current":e.id===t?`true`:void 0,onDoubleClick:()=>n(e.id),to:`/project/${e.project_id}/session/${e.id}`,className:P(`flex items-center rounded-md p-1.5 transition-colors hover:bg-elevated`,e.id===t&&`bg-elevated`),children:[(0,W.jsx)(sc,{status:e.status,kind:e.kind,className:`[--puddle-ripple-scale:2.3]`}),(0,W.jsx)(`span`,{className:`sr-only`,children:o(e)})]})})}),(0,W.jsx)(V,{children:(0,W.jsx)(vc,{session:e})})]}),(0,W.jsx)(gc,{menu:i}),a]})}function bc({groups:e,activeSessionId:t,onReorder:n,onPromote:r,onExpand:i,onNewTerminal:a,onNewSession:o,onOpenScratchpad:s,onArchived:c}){let[l,u]=(0,G.useState)(null),d=e.filter(e=>e.sessions.length>0),f=(e,t)=>{let r=se(d,e,t);r&&n(r)};return(0,W.jsxs)(`div`,{className:`flex h-full w-9 shrink-0 flex-col items-center bg-surface py-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,W.jsx)(_c,{icon:kn,label:`Show sessions`,onClick:i}),(0,W.jsx)(_c,{icon:Rt,label:`New agent`,onClick:o}),(0,W.jsx)(_c,{icon:Kt,label:`New terminal`,onClick:a}),(0,W.jsx)(_c,{icon:Tn,label:`Scratchpad`,onClick:s})]}),(0,W.jsx)(`div`,{className:`no-scrollbar flex min-h-0 flex-1 flex-col items-center gap-1 overflow-y-auto`,children:d.map(e=>(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,W.jsx)(`div`,{className:`my-0.5 h-px w-5 shrink-0 bg-border`}),e.sessions.map(e=>(0,W.jsx)(`div`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(fo,po({type:`terminal`,session:e.id})),u(e.id)},onDragEnd:()=>u(null),onDragOver:t=>{t.preventDefault(),l&&l!==e.id&&f(l,e.id)},className:P(`transition-opacity`,l===e.id&&`opacity-50`),children:(0,W.jsx)(yc,{session:e,activeSessionId:t,onPromote:r,onArchived:c})},e.id))]},e.projectId))})]})}function xc({session:e,activeSessionId:t,accountLabel:n,onPromote:r,onArchived:i,ellipsis:a}){let o=kt();return(0,W.jsx)(hc,{session:e,onArchived:i,children:i=>(0,W.jsxs)(At,{draggable:!1,onDoubleClick:r&&(()=>r(e.id)),to:`/project/${e.project_id}/session/${e.id}`,className:P(`group flex items-center gap-2 px-3 py-1.5 transition-colors hover:bg-elevated`,e.id===t&&`bg-elevated`),children:[(0,W.jsx)(sc,{status:e.status,kind:e.kind}),(0,W.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`span`,{className:`block truncate font-sans text-xs text-fg`,children:o(e)}),(0,W.jsxs)(`span`,{className:`flex items-center gap-1 truncate font-mono text-2xs text-fg-muted`,children:[(0,W.jsx)(Sn,{className:`size-3 shrink-0 text-fg-gold`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.branch})]}),e.account_id!==null&&n.has(e.account_id)&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1 truncate font-mono text-2xs text-fg-muted`,children:[(0,W.jsx)(nc,{type:e.agent_type??``,className:`size-3 shrink-0`}),(0,W.jsx)(`span`,{className:`truncate`,children:n.get(e.account_id)})]})]}),e.skip_permissions&&(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.jsx)(Nn,{className:`size-3.5 shrink-0 text-waiting`})}),(0,W.jsx)(V,{children:`Running with permission prompts skipped`})]}),e.worktree_missing&&(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.jsx)(xn,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,W.jsx)(V,{children:`Worktree directory is gone — archive only`})]}),a&&(0,W.jsx)(`span`,{className:`hidden group-hover:inline-flex has-[[data-state=open]]:inline-flex`,children:(0,W.jsx)(mc,{menu:i})})]})})}function Sc({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onNewSession:o,onNewTerminal:s,onCollapse:c,onArchived:l,rightPanel:u,onSelectPanel:d,profileId:f,scratchpadProjectId:p,onInsertPrompt:m}){return(0,W.jsxs)(`div`,{className:`flex h-full flex-col bg-surface`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 px-2 py-1.5`,children:[(0,W.jsx)(_c,{icon:On,label:`Hide sessions`,onClick:c}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,W.jsx)(_c,{icon:Rt,label:`New agent`,onClick:o}),(0,W.jsx)(_c,{icon:Kt,label:`New terminal`,onClick:s}),(0,W.jsx)(_c,{icon:Tn,label:`Scratchpad`,active:u===`scratchpad`,onClick:()=>d(u===`scratchpad`?`sessions`:`scratchpad`)})]})]}),u===`scratchpad`?(0,W.jsx)(ic,{profileId:f,projectId:p,onInsert:m}):(0,W.jsx)(Cc,{groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:l})]})}function Cc({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,archived:a,onArchived:o}){let[s,c]=(0,G.useState)(null),[l,u]=(0,G.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=se(f,e,t);n&&r(n)};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto py-1.5`,children:[p===0&&a.length===0&&(0,W.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,W.jsxs)(`div`,{children:[e.name!==null&&(0,W.jsx)(`div`,{className:`truncate px-3 pb-1 pt-2 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e.name}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.sessions.map(e=>(0,W.jsx)(`li`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(fo,po({type:`terminal`,session:e.id})),c(e.id)},onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&m(s,e.id)},className:P(`transition-opacity`,s===e.id&&`opacity-50`),children:(0,W.jsx)(xc,{session:e,activeSessionId:n,accountLabel:d,onPromote:i,onArchived:o,ellipsis:!0})},e.id))})]},e.projectId))]}),a.length>0&&(0,W.jsxs)(`div`,{className:`shrink-0 pb-1.5`,children:[(0,W.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,W.jsx)(He,{className:P(`size-3 transition-transform`,l&&`rotate-90`)}),(0,W.jsx)(I,{className:`size-3`}),(0,W.jsx)(`span`,{children:`Archived`}),(0,W.jsx)(`span`,{className:`ml-auto tabular-nums`,children:a.length})]}),l&&(0,W.jsx)(`ul`,{className:`no-scrollbar flex max-h-48 flex-col gap-0.5 overflow-y-auto`,children:a.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(xc,{session:e,activeSessionId:n,accountLabel:d,onArchived:o,ellipsis:!0})},e.id))})]})]})}var wc=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Tc(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Ec(e){return`nodeType`in e}function Dc(e){return e?Tc(e)?e:Ec(e)?e.ownerDocument?.defaultView??window:window:window}function Oc(e){let{Document:t}=Dc(e);return e instanceof t}function kc(e){return!Tc(e)&&e instanceof Dc(e).HTMLElement}function Ac(e){return e instanceof Dc(e).SVGElement}function jc(e){return e?Tc(e)?e.document:Ec(e)?Oc(e)?e:kc(e)||Ac(e)?e.ownerDocument:document:document:document}var Mc=wc?G.useLayoutEffect:G.useEffect;function Nc(e){let t=(0,G.useRef)(e);return Mc(()=>{t.current=e}),(0,G.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Pc(){let e=(0,G.useRef)(null);return[(0,G.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,G.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function Fc(e,t){t===void 0&&(t=[e]);let n=(0,G.useRef)(e);return Mc(()=>{n.current!==e&&(n.current=e)},t),n}function Ic(e,t){let n=(0,G.useRef)();return(0,G.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function Lc(e){let t=Nc(e),n=(0,G.useRef)(null);return[n,(0,G.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function Rc(e){let t=(0,G.useRef)();return(0,G.useEffect)(()=>{t.current=e},[e]),t.current}var zc={};function Bc(e,t){return(0,G.useMemo)(()=>{if(t)return t;let n=zc[e]==null?0:zc[e]+1;return zc[e]=n,e+`-`+n},[e,t])}function Vc(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 Hc=Vc(1),Uc=Vc(-1);function Wc(e){return`clientX`in e&&`clientY`in e}function Gc(e){if(!e)return!1;let{KeyboardEvent:t}=Dc(e.target);return t&&e instanceof t}function Kc(e){if(!e)return!1;let{TouchEvent:t}=Dc(e.target);return t&&e instanceof t}function qc(e){if(Kc(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 Wc(e)?{x:e.clientX,y:e.clientY}:null}var Jc=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[Jc.Translate.toString(e),Jc.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),Yc=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Xc(e){return e.matches(Yc)?e:e.querySelector(Yc)}var Zc={display:`none`};function Qc(e){let{id:t,value:n}=e;return G.createElement(`div`,{id:t,style:Zc},n)}function $c(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return G.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 el(){let[e,t]=(0,G.useState)(``);return{announce:(0,G.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var tl=(0,G.createContext)(null);function nl(e){let t=(0,G.useContext)(tl);(0,G.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function rl(){let[e]=(0,G.useState)(()=>new Set),t=(0,G.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,G.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var il={draggable:`
4
+ To pick up a draggable item, press the space bar.
5
+ While dragging, use the arrow keys to move the item.
6
+ Press space again to drop the item in its new position, or press escape to cancel.
7
+ `},al={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 ol(e){let{announcements:t=al,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=il}=e,{announce:a,announcement:o}=el(),s=Bc(`DndLiveRegion`),[c,l]=(0,G.useState)(!1);if((0,G.useEffect)(()=>{l(!0)},[]),nl((0,G.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=G.createElement(G.Fragment,null,G.createElement(Qc,{id:r,value:i.draggable}),G.createElement($c,{id:s,announcement:o}));return n?(0,Hi.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 sl(){}function cl(e,t){return(0,G.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function ll(){var e=[...arguments];return(0,G.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var ul=Object.freeze({x:0,y:0});function dl(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function fl(e,t){let n=qc(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 pl(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function ml(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function hl(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 gl(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function _l(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 vl=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=_l(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(ml)};function yl(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 bl=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&&yl(r,a)){let n=hl(a).reduce((e,t)=>e+dl(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(pl)};function xl(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Sl(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ul}function Cl(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 wl=Cl(1);function Tl(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 El(e,t,n){let r=Tl(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 Dl={ignoreTransform:!1};function Ol(e,t){t===void 0&&(t=Dl);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=Dc(e).getComputedStyle(e);t&&(n=El(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 kl(e){return Ol(e,{ignoreTransform:!0})}function Al(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function jl(e,t){return t===void 0&&(t=Dc(e).getComputedStyle(e)),t.position===`fixed`}function Ml(e,t){t===void 0&&(t=Dc(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 Nl(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Oc(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!kc(i)||Ac(i)||n.includes(i))return n;let a=Dc(e).getComputedStyle(i);return i!==e&&Ml(i,a)&&n.push(i),jl(i,a)?n:r(i.parentNode)}return e?r(e):n}function Pl(e){let[t]=Nl(e,1);return t??null}function Fl(e){return!wc||!e?null:Tc(e)?e:Ec(e)?Oc(e)||e===jc(e).scrollingElement?window:kc(e)?e:null:null}function Il(e){return Tc(e)?e.scrollX:e.scrollLeft}function Ll(e){return Tc(e)?e.scrollY:e.scrollTop}function Rl(e){return{x:Il(e),y:Ll(e)}}var Q;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Q||={});function zl(e){return!wc||!e?!1:e===document.scrollingElement}function Bl(e){let t={x:0,y:0},n=zl(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 Vl={x:.2,y:.2};function Hl(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Vl);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Bl(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 Ul(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 Wl(e){return e.reduce((e,t)=>Hc(e,Rl(t)),ul)}function Gl(e){return e.reduce((e,t)=>e+Il(t),0)}function Kl(e){return e.reduce((e,t)=>e+Ll(t),0)}function ql(e,t){if(t===void 0&&(t=Ol),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Pl(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Jl=[[`x`,[`left`,`right`],Gl],[`y`,[`top`,`bottom`],Kl]],Yl=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=Nl(t),r=Wl(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Jl)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})}},Xl=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 Zl(e){let{EventTarget:t}=Dc(e);return e instanceof t?e:jc(e)}function Ql(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 $l;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})($l||={});function eu(e){e.preventDefault()}function tu(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 nu={start:[$.Space,$.Enter],cancel:[$.Esc],end:[$.Space,$.Enter,$.Tab]},ru=(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}}},iu=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 Xl(jc(t)),this.windowListeners=new Xl(Dc(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add($l.Resize,this.handleCancel),this.windowListeners.add($l.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add($l.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&ql(n),t(ul)}handleKeyDown(e){if(Gc(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=nu,coordinateGetter:a=ru,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}:ul;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Uc(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}=Bl(n),p=Ul(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,Hc(Uc(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()}};iu.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=nu,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 au(e){return!!(e&&`distance`in e)}function ou(e){return!!(e&&`delay`in e)}var su=class{constructor(e,t,n){n===void 0&&(n=Zl(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=jc(i),this.documentListeners=new Xl(this.document),this.listeners=new Xl(n),this.windowListeners=new Xl(Dc(i)),this.initialCoordinates=qc(r)??ul,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($l.Resize,this.handleCancel),this.windowListeners.add($l.DragStart,eu),this.windowListeners.add($l.VisibilityChange,this.handleCancel),this.windowListeners.add($l.ContextMenu,eu),this.documentListeners.add($l.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ou(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(au(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($l.Click,tu,{capture:!0}),this.removeTextSelection(),this.documentListeners.add($l.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=qc(e)??ul,s=Uc(n,o);if(!t&&a){if(au(a)){if(a.tolerance!=null&&Ql(s,a.tolerance))return this.handleCancel();if(Ql(s,a.distance))return this.handleStart()}if(ou(a)&&Ql(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()}},cu={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},lu=class extends su{constructor(e){let{event:t}=e,n=jc(t.target);super(e,cu,n)}};lu.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 uu={move:{name:`mousemove`},end:{name:`mouseup`}},du;(function(e){e[e.RightClick=2]=`RightClick`})(du||={});var fu=class extends su{constructor(e){super(e,uu,jc(e.event.target))}};fu.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===du.RightClick?!1:(r?.({event:n}),!0)}}];var pu={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},mu=class extends su{constructor(e){super(e,pu)}static setup(){return window.addEventListener(pu.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(pu.move.name,e)};function e(){}}};mu.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 hu;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(hu||={});var gu;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(gu||={});function _u(e){let{acceleration:t,activator:n=hu.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=gu.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=yu({delta:d,disabled:!a}),[m,h]=Pc(),g=(0,G.useRef)({x:0,y:0}),_=(0,G.useRef)({x:0,y:0}),v=(0,G.useMemo)(()=>{switch(n){case hu.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case hu.DraggableRect:return i}},[n,i,c]),y=(0,G.useRef)(null),b=(0,G.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,G.useMemo)(()=>s===gu.TreeOrder?[...l].reverse():l,[s,l]);(0,G.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}=Hl(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 vu={x:{[Q.Backward]:!1,[Q.Forward]:!1},y:{[Q.Backward]:!1,[Q.Forward]:!1}};function yu(e){let{delta:t,disabled:n}=e,r=Rc(t);return Ic(e=>{if(n||!r||!e)return vu;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 bu(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Ic(e=>t==null?null:r??e??null,[r,t])}function xu(e,t){return(0,G.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 Su;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Su||={});var Cu;(function(e){e.Optimized=`optimized`})(Cu||={});var wu=new Map;function Tu(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,G.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,G.useRef)(e),d=g(),f=Fc(d),p=(0,G.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,G.useRef)(null),h=Ic(t=>{if(d&&!n)return wu;if(!t||t===wu||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 Yl(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,G.useEffect)(()=>{u.current=e},[e]),(0,G.useEffect)(()=>{d||p()},[n,d]),(0,G.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,G.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 Su.Always:return!1;case Su.BeforeDragging:return n;default:return!n}}}function Eu(e,t){return Ic(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Du(e,t){return Eu(e,t)}function Ou(e){let{callback:t,disabled:n}=e,r=Nc(t),i=(0,G.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,G.useEffect)(()=>()=>i?.disconnect(),[i]),i}function ku(e){let{callback:t,disabled:n}=e,r=Nc(t),i=(0,G.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,G.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Au(e){return new Yl(Ol(e),e)}function ju(e,t,n){t===void 0&&(t=Au);let[r,i]=(0,G.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=Ou({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=ku({callback:a});return Mc(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Mu(e){return Sl(e,Eu(e))}var Nu=[];function Pu(e){let t=(0,G.useRef)(e),n=Ic(n=>e?n&&n!==Nu&&e&&t.current&&e.parentNode===t.current.parentNode?n:Nl(e):Nu,[e]);return(0,G.useEffect)(()=>{t.current=e},[e]),n}function Fu(e){let[t,n]=(0,G.useState)(null),r=(0,G.useRef)(e),i=(0,G.useCallback)(e=>{let t=Fl(e.target);t&&n(e=>e?(e.set(t,Rl(t)),new Map(e)):null)},[]);return(0,G.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Fl(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Rl(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=>{Fl(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,G.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Hc(e,t),ul):Wl(e):ul,[e,t])}function Iu(e,t){t===void 0&&(t=[]);let n=(0,G.useRef)(null);return(0,G.useEffect)(()=>{n.current=null},t),(0,G.useEffect)(()=>{let t=e!==ul;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Uc(e,n.current):ul}function Lu(e){(0,G.useEffect)(()=>{if(!wc)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 Ru(e,t){return(0,G.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function zu(e){return(0,G.useMemo)(()=>e?Al(e):null,[e])}var Bu=[];function Vu(e,t){t===void 0&&(t=Ol);let[n]=e,r=zu(n?Dc(n):null),[i,a]=(0,G.useState)(Bu);function o(){a(()=>e.length?e.map(e=>zl(e)?r:new Yl(t(e),e)):Bu)}let s=ku({callback:o});return Mc(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Hu(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return kc(t)?t:e}function Uu(e){let{measure:t}=e,[n,r]=(0,G.useState)(null),i=ku({callback:(0,G.useCallback)(e=>{for(let{target:n}of e)if(kc(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=Lc((0,G.useCallback)(e=>{let n=Hu(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,G.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Wu=[{sensor:lu,options:{}},{sensor:iu,options:{}}],Gu={current:{}},Ku={draggable:{measure:kl},droppable:{measure:kl,strategy:Su.WhileDragging,frequency:Cu.Optimized},dragOverlay:{measure:Ol}},qu=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}},Ju={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new qu,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:sl},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ku,measureDroppableContainers:sl,windowRect:null,measuringScheduled:!1},Yu={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:sl,draggableNodes:new Map,over:null,measureDroppableContainers:sl},Xu=(0,G.createContext)(Yu),Zu=(0,G.createContext)(Ju);function Qu(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new qu}}}function $u(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 qu(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 qu(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 qu(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function ed(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,G.useContext)(Xu),a=Rc(r),o=Rc(n?.id);return(0,G.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Gc(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=Xc(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function td(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function nd(e){return(0,G.useMemo)(()=>({draggable:{...Ku.draggable,...e?.draggable},droppable:{...Ku.droppable,...e?.droppable},dragOverlay:{...Ku.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function rd(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,G.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Mc(()=>{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=Sl(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=Pl(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var id=(0,G.createContext)({...ul,scaleX:1,scaleY:1}),ad;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(ad||={});var od=(0,G.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Wu,collisionDetection:o=vl,measuring:s,modifiers:c,...l}=e,[u,d]=(0,G.useReducer)($u,void 0,Qu),[f,p]=rl(),[m,h]=(0,G.useState)(ad.Uninitialized),g=m===ad.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,G.useRef)({initial:null,translated:null}),C=(0,G.useMemo)(()=>_==null?null:{id:_,data:x?.data??Gu,rect:S},[_,x]),w=(0,G.useRef)(null),[T,E]=(0,G.useState)(null),[D,ee]=(0,G.useState)(null),O=Fc(l,Object.values(l)),te=Bc(`DndDescribedBy`,t),k=(0,G.useMemo)(()=>b.getEnabled(),[b]),A=nd(s),{droppableRects:j,measureDroppableContainers:ne,measuringScheduled:re}=Tu(k,{dragging:g,dependencies:[y.x,y.y],config:A.droppable}),M=bu(v,_),N=(0,G.useMemo)(()=>D?qc(D):null,[D]),ie=ke(),ae=Du(M,A.draggable.measure);rd({activeNode:_==null?null:v.get(_),config:ie.layoutShiftCompensation,initialRect:ae,measure:A.draggable.measure});let P=ju(M,A.draggable.measure,ae),F=ju(M?M.parentElement:null),I=(0,G.useRef)({activatorEvent:null,active:null,activeNode:M,collisionRect:null,collisions:null,droppableRects:j,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=b.getNodeFor(I.current.over?.id),se=Uu({measure:A.dragOverlay.measure}),ce=se.nodeRef.current??M,le=g?se.rect??P:null,ue=!!(se.nodeRef.current&&se.rect),de=Mu(ue?null:P),fe=zu(ce?Dc(ce):null),pe=Pu(g?oe??M:null),L=Vu(pe),me=td(c,{transform:{x:y.x-de.x,y:y.y-de.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:P,containerNodeRect:F,draggingNodeRect:le,over:I.current.over,overlayNodeRect:se.rect,scrollableAncestors:pe,scrollableAncestorRects:L,windowRect:fe}),he=N?Hc(N,y):null,ge=Fu(pe),_e=Iu(ge),ve=Iu(ge,[P]),R=Hc(me,_e),ye=le?wl(le,me):null,be=C&&ye?o({active:C,collisionRect:ye,droppableRects:j,droppableContainers:k,pointerCoordinates:he}):null,xe=gl(be,`id`),[Se,Ce]=(0,G.useState)(null),we=xl(ue?me:Hc(me,ve),Se?.rect??null,P),z=(0,G.useRef)(null),Te=(0,G.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:I,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=O.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=O.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}=O.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,Hi.unstable_batchedUpdates)(()=>{r?.(i),h(ad.Initializing),d({type:Z.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(z.current),ee(a)})},onMove(e){d({type:Z.DragMove,coordinates:e})},onEnd:s(Z.DragEnd),onCancel:s(Z.DragCancel)});z.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=I.current,o=null;if(t&&i){let{cancelDrop:s}=O.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,Hi.unstable_batchedUpdates)(()=>{d({type:e}),h(ad.Uninitialized),Ce(null),E(null),ee(null),z.current=null;let t=e===Z.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=O.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Ee=xu(a,(0,G.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,Te(n,t))},[v,Te]));Lu(a),Mc(()=>{P&&m===ad.Initializing&&h(ad.Initialized)},[P,m]),(0,G.useEffect)(()=>{let{onDragMove:e}=O.current,{active:t,activatorEvent:n,collisions:r,over:i}=I.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:R.x,y:R.y},over:i};(0,Hi.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[R.x,R.y]),(0,G.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=I.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=O.current,o=r.get(xe),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,Hi.unstable_batchedUpdates)(()=>{Ce(s),a?.(c),f({type:`onDragOver`,event:c})})},[xe]),Mc(()=>{I.current={activatorEvent:D,active:C,activeNode:M,collisionRect:ye,collisions:be,droppableRects:j,draggableNodes:v,draggingNode:ce,draggingNodeRect:le,droppableContainers:b,over:Se,scrollableAncestors:pe,scrollAdjustedTranslate:R},S.current={initial:le,translated:ye}},[C,M,be,ye,v,ce,le,j,b,Se,pe,R]),_u({...ie,delta:y,draggingRect:ye,pointerCoordinates:he,scrollableAncestors:pe,scrollableAncestorRects:L});let De=(0,G.useMemo)(()=>({active:C,activeNode:M,activeNodeRect:P,activatorEvent:D,collisions:be,containerNodeRect:F,dragOverlay:se,draggableNodes:v,droppableContainers:b,droppableRects:j,over:Se,measureDroppableContainers:ne,scrollableAncestors:pe,scrollableAncestorRects:L,measuringConfiguration:A,measuringScheduled:re,windowRect:fe}),[C,M,P,D,be,F,se,v,b,j,Se,ne,pe,L,A,re,fe]),Oe=(0,G.useMemo)(()=>({activatorEvent:D,activators:Ee,active:C,activeNodeRect:P,ariaDescribedById:{draggable:te},dispatch:d,draggableNodes:v,over:Se,measureDroppableContainers:ne}),[D,Ee,C,P,d,te,v,Se,ne]);return G.createElement(tl.Provider,{value:p},G.createElement(Xu.Provider,{value:Oe},G.createElement(Zu.Provider,{value:De},G.createElement(id.Provider,{value:we},i)),G.createElement(ed,{disabled:n?.restoreFocus===!1})),G.createElement(ol,{...n,hiddenTextDescribedById:te}));function ke(){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}}}),sd=(0,G.createContext)(null),cd=`button`,ld=`Draggable`;function ud(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Bc(ld),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,G.useContext)(Xu),{role:p=cd,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,G.useContext)(g?id:sd),[v,y]=Lc(),[b,x]=Lc(),S=Ru(o,t),C=Fc(n);return Mc(()=>(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,G.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===cd?!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 dd(){return(0,G.useContext)(Zu)}var fd=`Droppable`,pd={timeout:25};function md(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Bc(fd),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,G.useContext)(Xu),u=(0,G.useRef)({disabled:n}),d=(0,G.useRef)(!1),f=(0,G.useRef)(null),p=(0,G.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...pd,...i},_=Fc(h??r),v=ku({callback:(0,G.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]=Lc((0,G.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Fc(t);return(0,G.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,G.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,G.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 hd(e){let{animation:t,children:n}=e,[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(null),s=Rc(n);return!n&&!r&&s&&i(s),Mc(()=>{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]),G.createElement(G.Fragment,null,n,r?(0,G.cloneElement)(r,{ref:o}):null)}var gd={x:0,y:0,scaleX:1,scaleY:1};function _d(e){let{children:t}=e;return G.createElement(Xu.Provider,{value:Yu},G.createElement(id.Provider,{value:gd},t))}var vd={position:`fixed`,touchAction:`none`},yd=e=>Gc(e)?`transform 250ms ease`:void 0,bd=(0,G.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=yd}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...vd,width:s.width,height:s.height,top:s.top,left:s.left,transform:Jc.Transform.toString(d),transformOrigin:i&&r?fl(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return G.createElement(n,{className:o,style:f,ref:t},a)}),xd={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Jc.Transform.toString(t)},{transform:Jc.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 Sd(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return Nc((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=Hu(a);if(!c)return;let{transform:l}=Dc(a).getComputedStyle(a),u=Tl(l);if(!u)return;let d=typeof t==`function`?t:Cd(t);return ql(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 Cd(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...xd,...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 wd=0;function Td(e){return(0,G.useMemo)(()=>{if(e!=null)return wd++,wd},[e])}var Ed=G.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}=dd(),S=(0,G.useContext)(id),C=Td(d?.id),w=td(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=Eu(f),E=Sd({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return G.createElement(_d,null,G.createElement(hd,{animation:E},d&&C?G.createElement(bd,{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 Dd({className:e}){return(0,W.jsx)(`svg`,{viewBox:`0 0 2000 2000`,fill:`none`,"aria-hidden":`true`,className:e,children:(0,W.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:110,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,W.jsx)(`line`,{x1:`491.66`,y1:`1916.78`,x2:`1558.47`,y2:`83.22`}),(0,W.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,W.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,W.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 Od=[`running`,`waiting_input`];function kd({sessionId:e,status:t}){let n=Od.includes(t),{data:r}=ot(e,n),i=r?.vars??[];return!n||i.length===0?null:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1 font-mono text-xs`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`env`}),(0,W.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:i.map(e=>(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.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,W.jsxs)(V,{children:[e.bytes,` B · captured from this session's shell — re-injected into new shells and agent restarts`]})]},e.name))})]})}function Ad(e,t,n){return`ssh -L ${e}:127.0.0.1:${e} ${t}@${n}`}var jd=[`running`,`waiting_input`];function Md({sessionId:e,status:t}){let n=jd.includes(t),{data:r}=st(e,n),i=r?.ports??[];return!n||i.length===0?null:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1 font-mono text-xs`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:`ports`}),(0,W.jsx)(`div`,{className:`flex items-center gap-1`,children:i.map(t=>(0,W.jsx)(Nd,{sessionId:e,port:t},t.port))})]})}function Nd({sessionId:e,port:t}){let n=Dt().data;return(0,W.jsxs)(Is,{children:[(0,W.jsxs)(B,{children:[(0,W.jsx)(H,{asChild:!0,children:(0,W.jsx)(Ls,{asChild:!0,children:(0,W.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,W.jsxs)(V,{children:[t.command,` · pid `,t.pid]})]}),(0,W.jsxs)(zs,{align:`start`,children:[Yt()===null?(0,W.jsx)(Bs,{asChild:!0,children:(0,W.jsx)(`a`,{href:`http://localhost:${t.port}`,target:`_blank`,rel:`noopener noreferrer`,children:`Open localhost`})}):(0,W.jsx)(Bs,{onSelect:()=>{window.open(`/proxy/${e}/${t.port}/?puddle_token=${S.get()??``}`,`_blank`,`noopener,noreferrer`)},children:`Open via proxy`}),(0,W.jsx)(Bs,{onSelect:()=>{n&&navigator.clipboard.writeText(Ad(t.port,n.username,n.hostname)).then(()=>C.success(`Copied`))},children:`Copy ssh -L`})]})]})}function Pd(e,t,n=.25){if(e.width<=0||e.height<=0)return`center`;let r=Fd(t.x/e.width),i=Fd(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 Fd(e){return e<0?0:e>1?1:e}var Id=[`interrupted`,`exited`];function Ld({session:e}){let t=Mt(`resume`);return Id.includes(e.status)&&!e.worktree_missing?(0,W.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 right-3 z-10`,children:(0,W.jsxs)(k,{size:`sm`,className:`pointer-events-auto`,disabled:t.isPending,onClick:()=>t.mutate(e.id,{onError:e=>C.error(e.message)}),children:[(0,W.jsx)(jn,{}),`Resume`]})}):null}var Rd=(0,G.createContext)(null);function zd(){return(0,G.useContext)(Rd)}var Bd=`leaf:`,Vd=`tabdrop:`,Hd=`strip:`,Ud=e=>{let t=bl(e);for(let e of[Vd,Hd]){let n=t.filter(t=>String(t.id).startsWith(e));if(n.length>0)return n}return t.length>0?t:vl(e)};function Wd({onDrop:e,renderOverlay:t,children:n}){let r=ll(cl(lu,{activationConstraint:{distance:4}})),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(null),c=(0,G.useRef)(null),l=()=>{a(null),s(null),c.current=null};return(0,W.jsxs)(od,{sensors:r,collisionDetection:Ud,onDragStart:e=>s(e.active.data.current?.ref??null),onDragMove:e=>{let t=e.over,n=Gd(e),r=t&&n?qd(String(t.id),t.rect,t.data.current,n):null;Kd(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,W.jsx)(Rd.Provider,{value:i,children:n}),(0,W.jsx)(Ed,{dropAnimation:null,children:o?t(o):null})]})}function Gd(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 Kd(e,t){return e===null||t===null?e===t:e.leafId===t.leafId&&e.zone===t.zone&&e.index===t.index}function qd(e,t,n,r){if(e.startsWith(Vd)){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(Hd)){let e=n;return e?{leafId:e.leafId,zone:`center`,index:e.count}:null}if(e.startsWith(Bd)){let n=Pd({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 Jd=`group flex min-w-0 max-w-52 cursor-pointer items-center gap-1.5 rounded-t-md px-2.5 text-xs transition-colors`;function Yd({leaf:e,sessions:t,onActivate:n,onClose:r,onPromote:i,onArchived:a,onSetView:o}){let s=new Map(t.map(e=>[e.id,e.branch])),c=e.tabs.flatMap(e=>e.type===`editor`?[e.tab]:[]),l=zd(),u=l?.leafId===e.id&&l.index!==void 0?l.index:null,{setNodeRef:f}=md({id:`strip:${e.id}`,data:{leafId:e.id,count:e.tabs.length}}),p=e=>{let t=Jt(e.path,e.session,c,s);return d(e)===`diff`?`${t} (diff)`:d(e)===`commit`?`${t} @${(e.sha??``).slice(0,7)}`:t};return(0,W.jsxs)(`div`,{ref:f,className:`flex h-9 shrink-0 items-stretch gap-0.5 overflow-x-auto bg-surface px-1 pt-1`,children:[e.tabs.map((s,c)=>(0,W.jsxs)(G.Fragment,{children:[u===c&&(0,W.jsx)(Xd,{}),(0,W.jsx)(Qd,{tab:s,leafId:e.id,index:c,active:Y(s)===e.activeKey,preview:Y(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)})]},Y(s))),u===e.tabs.length&&(0,W.jsx)(Xd,{})]})}function Xd(){return(0,W.jsx)(`div`,{className:`w-0.5 shrink-0 self-stretch rounded-full bg-accent`})}function Zd({view:e,onSetView:t}){let n=e===`preview`;return(0,W.jsx)(`button`,{onClick:e=>{e.stopPropagation(),t(n?`source`:`preview`)},className:`rounded-sm p-0.5 text-fg-muted opacity-0 transition-opacity hover:text-fg group-hover:opacity-100`,"aria-label":n?`Show source`:`Show preview`,title:n?`Show source`:`Show preview`,children:n?(0,W.jsx)(U,{className:`size-3`}):(0,W.jsx)(nn,{className:`size-3`})})}function Qd({tab:e,leafId:t,index:n,active:r,preview:i,session:a,label:o,onActivate:s,onClose:c,onPromote:l,onArchived:u,onSetView:f}){let p=kt(),h=Y(e),{attributes:g,listeners:_,setNodeRef:v,isDragging:y}=ud({id:`drag:${t}:${h}`,data:{ref:e,fromLeafId:t}}),{setNodeRef:b}=md({id:`tabdrop:${t}:${h}`,data:{leafId:t,index:n}}),x=e=>{v(e),b(e)},S=P(Jd,r?`bg-ground text-fg`:`text-fg-secondary hover:bg-elevated`,i&&`italic`,y&&`opacity-40`),C=(0,W.jsx)(`div`,{ref:x,...g,..._,onClick:s,onDoubleClick:l,className:S,children:e.type===`terminal`?(0,W.jsxs)(W.Fragment,{children:[a&&(0,W.jsx)(sc,{status:a.status,kind:a.kind}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:a?p(a):e.session.slice(0,8)}),(0,W.jsx)(`button`,{onClick:e=>{e.stopPropagation(),c()},className:`rounded-sm p-0.5 text-fg-muted opacity-0 transition-opacity hover:text-fg group-hover:opacity-100`,"aria-label":`Close tab`,children:(0,W.jsx)(A,{className:`size-3`})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`truncate font-mono`,children:o}),d(e.tab)===`file`&&m(e.tab.path)!==null&&(0,W.jsx)(Zd,{view:e.tab.view??`source`,onSetView:f}),(0,W.jsx)(Vi,{session:e.tab.session,path:e.tab.path,kind:d(e.tab),label:o,onClose:c})]})});return e.type===`terminal`&&a?(0,W.jsx)(hc,{session:a,onArchived:()=>u(e.session),children:C}):C}function $d({leaf:e,sessions:t,reveal:n,onActivateTab:r,onCloseTab:i,onPromoteTab:a,onArchived:o,onFocusLeaf:s,onDropTab:c,onSetTabView:l}){let u=e.tabs.find(t=>Y(t)===e.activeKey)??null,d=u?.type===`terminal`?Y(u):null,f=u?.type===`terminal`?t.find(e=>e.id===u.session)??null:null,p=va(d),{setNodeRef:m}=md({id:`leaf:${e.id}`}),h=zd(),g=(0,G.useRef)(null),_=(0,G.useRef)(()=>void 0);_.current=()=>{u&&r(e.id,u)},(0,G.useEffect)(()=>{let e=g.current;if(!e)return;let t=()=>_.current();return e.addEventListener(`mousedown`,t,!0),()=>e.removeEventListener(`mousedown`,t,!0)},[]);let[v,y]=(0,G.useState)(null),b=e=>{let t=e.currentTarget.getBoundingClientRect();return Pd({width:t.width,height:t.height},{x:e.clientX-t.left,y:e.clientY-t.top})};return(0,W.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,onMouseDownCapture:()=>s(e.id),children:[e.tabs.length>0&&(0,W.jsx)(Yd,{leaf:e,sessions:t,onActivate:t=>r(e.id,t),onClose:t=>i(e.id,t),onPromote:a,onArchived:o,onSetView:l}),(0,W.jsxs)(`div`,{ref:e=>{g.current=e,m(e)},className:`relative min-h-0 flex-1`,onDragOver:e=>{ho(e.dataTransfer.types)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,y(b(e)))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||y(null)},onDrop:t=>{if(!ho(t.dataTransfer.types))return;t.preventDefault(),y(null);let n=mo(t.dataTransfer.getData(fo));n&&c(e.id,n,b(t))},children:[u?.type===`editor`&&(0,W.jsx)(`div`,{className:`absolute inset-0`,children:(0,W.jsx)(Li,{tab:u.tab,reveal:n})}),(0,W.jsx)(`div`,{ref:p,className:P(`absolute inset-0 py-1 pl-4 pr-2`,!d&&`hidden`)}),h?.leafId===e.id&&h.index===void 0&&(0,W.jsx)(tf,{zone:h.zone}),v!==null&&(0,W.jsx)(tf,{zone:v}),f&&(0,W.jsx)(Ld,{session:f}),!u&&(0,W.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-6 text-center`,children:[(0,W.jsx)(Dd,{className:`size-24 text-fg-muted/40`}),(0,W.jsx)(`button`,{type:`button`,onClick:at,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`})]})]}),f&&(0,W.jsx)(kd,{sessionId:f.id,status:f.status}),f&&(0,W.jsx)(Md,{sessionId:f.id,status:f.status})]})}var ef={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 tf({zone:e}){return(0,W.jsx)(`div`,{className:P(`pointer-events-none absolute z-20 bg-accent/20`,ef[e])})}var nf=`bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`;function rf({tree:e,...t}){let n=(0,G.useMemo)(()=>{let t=new Set,n=[];for(let r of Zi(e)){if(r.type!==`editor`||d(r.tab)===`commit`)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,W.jsxs)(W.Fragment,{children:[n.length>0&&(0,W.jsx)(zi,{buffers:n}),(0,W.jsx)(af,{node:e,...t})]})}function af({node:e,...t}){if(e.kind===`leaf`)return(0,W.jsx)($d,{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});let n=e.direction===`row`?`horizontal`:`vertical`;return(0,W.jsx)(Si,{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,W.jsxs)(G.Fragment,{children:[r>0&&(0,W.jsx)(Oi,{className:n===`horizontal`?`w-px ${nf}`:`h-px ${nf}`}),(0,W.jsx)(Ti,{id:e.id,minSize:64,children:(0,W.jsx)(af,{node:e,...t})})]},e.id))},e.id)}function of(e){let t=e.snapshot,n=(0,G.useRef)(null);!t.layout_tree&&!n.current&&(n.current=ha(t));let r=t.layout_tree??n.current??Ki([]),i=(0,G.useCallback)(t=>e.update({layout_tree:t}),[e]),a=(0,G.useRef)(i);a.current=i;let o=(0,G.useRef)(!1);(0,G.useEffect)(()=>{o.current||e.loaded&&!t.layout_tree&&n.current&&(o.current=!0,Zi(n.current).length>0&&a.current(n.current))},[e.loaded,t.layout_tree]);let[s,c]=(0,G.useState)(null),l=(s?Ji(r,s):null)??Xi(r)[0]??Ki([]),u=l.tabs.find(e=>Y(e)===l.activeKey)??null,d=u?.type===`editor`?u.tab:null;return(0,G.useMemo)(()=>({tree:r,focusedLeaf:l,activeEditorTab:d,focusLeaf:e=>c(e),activate:(e,t)=>{c(e);let n=Y(t),a=Ji(r,e);a&&a.activeKey===n||i(fa(r,e,n))},close:(e,t)=>i(sa(r,e,Y(t))),openEditor:(e,t)=>{let n=l.id;c(n);let a={type:`editor`,tab:e};i(t?.preview?la(r,n,a):ca(r,n,a))},ensureTerminal:(e,t)=>{let n=`term:${e}`,a=Yi(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=fa(t,a.id,n)),o&&(t=ua(t,n)),i(t)}}else{let n=l.id;c(n);let a={type:`terminal`,session:e};i(t?.preview?la(r,n,a):ca(r,n,a))}},promote:e=>i(ua(r,Y(e))),setView:(e,t)=>i(da(r,Y(e),t)),removeTerminal:e=>{let t=Yi(r,`term:${e}`);t&&i(sa(r,t.id,`term:${e}`))},pruneSessions:e=>i(ma(r,t=>t.type===`terminal`?e.has(t.session):e.has(t.tab.session))),resize:(e,t)=>i(pa(r,e,t)),drop:e=>{c(e.toLeafId),i(aa(r,e))}}),[r,l,d,i])}var sf=2e3,cf=w.parse({});function lf(e){return`puddle.ws.${e}`}function uf(e){if(e===null)return{kind:`absent`};try{return{kind:`present`,snapshot:w.parse(JSON.parse(e))}}catch{return{kind:`corrupt`}}}function df(){let e=ut(),[t,n]=(0,G.useState)(!1),[r,i]=(0,G.useState)(cf),a=(0,G.useRef)(r);a.current=r;let o=(0,G.useRef)(null),s=(0,G.useMemo)(()=>qt((e,t)=>{yt(e,t).catch(e=>console.warn(`ui-state save failed: ${e.message}`))},sf),[]);return(0,G.useEffect)(()=>{if(e===null){o.current=null;return}let t=lf(e);o.current=t;let r=!1;n(!1),i(cf);let a;try{a=uf(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)):nt(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,s.flush()}},[e,s]),{loaded:t,snapshot:r,update(t){if(e===null)return;let n={...a.current,...t};a.current=n,i(n);let r=o.current??lf(e);s(e,n);try{sessionStorage.setItem(r,JSON.stringify(n))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}}}}function ff(){return(0,W.jsx)(ji,{children:(0,W.jsx)(pf,{})})}function pf(){let e=Ft(),t=St(),n=e.id??``,r=/^[0-9a-f]{10}$/.test(n),i=e.sid??null,a=Ye(r?n:void 0),o=(0,G.useMemo)(()=>a.data?.sessions??[],[a.data]),s=vt(a.data?.project.profile_id).data??[],c=kt(),l=df(),u=dt(),d=u.data??o,f=a.data?.project.profile_id,p=Bt().showAllProjectSessions,m=Wt(p?f:void 0),h=Gt(p?f:void 0),g=(0,G.useMemo)(()=>{let e=e=>e.status!==`archived`;if(!p)return[{projectId:n,name:null,sessions:le(o.filter(e),l.snapshot.session_order)}];let t=le((m.data??[]).filter(e=>!e.archived),h.data?.projectOrder??[]),r=u.data??o;return t.map(t=>({projectId:t.id,name:t.name,sessions:le(r.filter(n=>n.project_id===t.id&&e(n)),l.snapshot.session_order)}))},[p,o,n,l.snapshot.session_order,m.data,h.data,u.data]),_=(0,G.useMemo)(()=>o.filter(e=>e.status===`archived`),[o]),v=of(l),y=(0,G.useRef)(v);y.current=v;let b=(0,G.useRef)(l);b.current=l;let x=(0,G.useCallback)(e=>b.current.update({session_order:ce(e,b.current.snapshot.session_order)}),[]),[S,w]=(0,G.useState)(!1),[T,E]=(0,G.useState)(!1),[D,ee]=(0,G.useState)(`agent`),[O,te]=(0,G.useState)(void 0),k=(0,G.useCallback)((e=`agent`)=>{te(void 0),ee(e),E(!0)},[]),A=(0,G.useRef)(null),{setHandler:j}=wt(),[ne,re]=(0,G.useState)(null),M=(0,G.useCallback)((e,t,n)=>{v.openEditor(e,{preview:n?.preview}),t&&(e.kind??`file`)===`file`&&re({session:e.session,path:e.path,line:t.line,column:t.column,nonce:Date.now()})},[v]),N=(0,G.useCallback)((e,t,n,r)=>M({kind:`file`,session:e,path:t},n,r),[M]);Mi(N);let ie=(0,G.useCallback)((e,t,n)=>N(e,t,void 0,{preview:n?.preview??!0}),[N]),ae=(0,G.useCallback)(e=>v.promote(e),[v]);(0,G.useEffect)(()=>(j(e=>{te(e?.accountId),ee(e?.kind??`agent`),E(!0)}),()=>j(null)),[j]);let[P,F]=(0,G.useState)(!1);(0,G.useEffect)(()=>{if(!l.loaded||P)return;let e=Zi(y.current.tree);Promise.all([e.some(e=>e.type===`terminal`)?Et():void 0,e.some(e=>e.type===`editor`)?Fi():void 0]).finally(()=>F(!0))},[l.loaded,P]),(0,G.useEffect)(()=>{if(S||!l.loaded||!a.data)return;w(!0);let e=l.snapshot.active_session,r=o.find(t=>t.id===e);!i&&r&&r.status!==`archived`&&t(`/project/${n}/session/${r.id}`,{replace:!0})},[S,l,a.data,o,i,t,n]);let I=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(I.current||!l.loaded||!u.data)return;I.current=!0;let e=new Set(u.data.filter(e=>e.status!==`archived`).map(e=>e.id));y.current.pruneSessions(e);let t=b.current.snapshot.session_order,n=t.filter(t=>e.has(t));n.length!==t.length&&b.current.update({session_order:n})},[l.loaded,u.data]),(0,G.useEffect)(()=>{if(!S)return;if(!i){A.current=null;return}if(i===A.current)return;A.current=null,y.current.ensureTerminal(i,{preview:!0});let e=b.current;e.snapshot.active_session!==i&&e.update({active_session:i})},[S,i]),(0,G.useEffect)(()=>{let e=o.filter(e=>e.status===`waiting_input`).length,t=a.data?.project.name??`puddle`;return document.title=e>0?`● ${e} waiting — ${t}`:`${t} — puddle`,()=>{document.title=`puddle`}},[o,a.data?.project.name]);let oe=(0,G.useCallback)(e=>{let r=i===e;r&&(A.current=e),v.removeTerminal(e),r&&(l.update({active_session:null}),t(`/project/${n}`))},[v,l,i,t,n]),se=(0,G.useCallback)((e,n)=>{if(v.activate(e,n),n.type===`terminal`&&n.session!==i){let e=d.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[v,t,d,i]),ue=(0,G.useCallback)((e,r)=>{v.close(e,r),r.type===`terminal`&&r.session===i&&(A.current=r.session,l.update({active_session:null}),t(`/project/${n}`))},[v,i,l,t,n]),de=(0,G.useCallback)((e,n,r)=>{if(v.drop({ref:n,fromLeafId:e,toLeafId:e,edge:r}),n.type===`terminal`&&n.session!==i){let e=d.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[v,i,d,t]),fe=v.focusedLeaf.tabs.find(e=>Y(e)===v.focusedLeaf.activeKey)??null,pe=ki(d,(fe===null?null:fe.type===`terminal`?fe.session:fe.tab.session)??i,l),L=pe.session,me=Xs(l.snapshot.sidebar_mode),he=l.snapshot.sidebar_collapsed,ge=l.snapshot.sessions_collapsed,_e=l.snapshot.right_panel,ve=(0,G.useCallback)(e=>{let t=v.focusedLeaf,n=t.tabs.find(e=>Y(e)===t.activeKey)??null;if(!n||n.type!==`terminal`){C.error(`Focus a terminal or agent to insert`);return}ct.write(n.session,`agent`,`\x1b[200~${e}\x1b[201~`)},[v]),R=(0,G.useCallback)(e=>{l.update({right_panel:`sessions`}),k(e)},[l,k]),ye=(0,G.useRef)({}),be=e=>l.update({sidebar_mode:e,sidebar_collapsed:!1});ye.current={"tab.close":()=>{let e=v.focusedLeaf,t=e.tabs.find(t=>Y(t)===e.activeKey);t&&ue(e.id,t)},"sidebar.left":()=>l.update({sidebar_collapsed:!l.snapshot.sidebar_collapsed}),"sidebar.right":()=>l.update({sessions_collapsed:!l.snapshot.sessions_collapsed}),"nav.files":()=>be(`files`),"nav.search":()=>be(`search`),"nav.changes":()=>be(`changes`),"nav.worktrees":()=>be(`worktrees`),"session.newAgent":()=>R(`agent`),"session.newTerminal":()=>R(`terminal`),"scratchpad.toggle":()=>l.update({right_panel:l.snapshot.right_panel===`scratchpad`?`sessions`:`scratchpad`,sessions_collapsed:!1})},(0,G.useEffect)(()=>{let e=Object.keys(ye.current).map(e=>Ut(e,()=>ye.current[e]?.()));return()=>e.forEach(e=>e())},[]);let xe=v.activeEditorTab,Se=xe?.kind===`diff`&&L&&xe.session===L.id?xe.path:null,Ce=xe&&(xe.kind??`file`)===`file`&&L&&xe.session===L.id?xe.path:null,we=e=>{L&&M({kind:`diff`,session:L.id,path:e})},z=(e,t)=>{L&&M({kind:`commit`,session:L.id,path:e,sha:t})},Te=(e,t)=>{L&&N(L.id,e,t===void 0?void 0:{line:t,column:1})},Ee=(0,G.useCallback)(e=>l.update({layout:{...l.snapshot.layout,...e}}),[l]),De=ya(l.snapshot.layout,[...he?[]:[`nav`],`main`,...ge?[]:[`sessions`]]);return r?!l.loaded||!a.data||!P?(0,W.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-fg-muted`,children:`…`}):(0,W.jsxs)(`div`,{className:`flex h-full`,children:[he&&(0,W.jsx)(Zs,{mode:me,onExpand:()=>l.update({sidebar_collapsed:!1}),onSelect:e=>l.update({sidebar_collapsed:!1,sidebar_mode:e})}),(0,W.jsxs)(Si,{orientation:`horizontal`,className:`h-full min-w-0 flex-1`,defaultLayout:De,onLayoutChanged:Ee,children:[!he&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ti,{id:`nav`,defaultSize:280,minSize:200,maxSize:560,children:(0,W.jsx)(Qs,{mode:me,onModeChange:e=>l.update({sidebar_mode:e}),onCollapse:()=>l.update({sidebar_collapsed:!0}),projectId:n,repoId:a.data.project.repo_id,sessions:o,target:pe,onOpenFile:ie,activeFilePath:Ce,activeDiffPath:Se,onOpenDiff:we,onOpenCommitFile:z,onOpenSearchFile:Te})}),(0,W.jsx)(Oi,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`})]}),(0,W.jsx)(Ti,{id:`main`,children:(0,W.jsx)(_a,{tree:v.tree,onOpenFile:(e,t,n,r)=>N(e,t,n===void 0?void 0:{line:n,column:r}),children:(0,W.jsx)(`div`,{className:`flex h-full flex-col bg-ground`,children:(0,W.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,W.jsx)(Wd,{onDrop:v.drop,renderOverlay:e=>{let t=e.type===`terminal`?d.find(t=>t.id===e.session):void 0;return(0,W.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?c(t):e.session.slice(0,8):e.tab.path.split(`/`).pop()??e.tab.path})},children:(0,W.jsx)(rf,{tree:v.tree,sessions:d,reveal:ne,onActivateTab:se,onCloseTab:ue,onPromoteTab:ae,onArchived:oe,onFocusLeaf:v.focusLeaf,onResize:v.resize,onDropTab:de,onSetTabView:v.setView})})})})})}),!ge&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Oi,{className:`w-px bg-border transition-colors hover:bg-accent data-[resizing]:bg-accent`}),(0,W.jsx)(Ti,{id:`sessions`,defaultSize:260,minSize:180,maxSize:480,children:(0,W.jsx)(Sc,{groups:g,accounts:s,activeSessionId:i,onReorder:x,onPromote:e=>v.ensureTerminal(e),archived:_,onNewSession:()=>R(`agent`),onNewTerminal:()=>R(`terminal`),onCollapse:()=>l.update({sessions_collapsed:!0}),onArchived:oe,rightPanel:_e,onSelectPanel:e=>l.update({right_panel:e}),profileId:f??null,scratchpadProjectId:n,onInsertPrompt:ve})})]}),(0,W.jsx)($s,{projectId:n,repoId:a.data.project.repo_id,open:T,kind:D,seedAccountId:O,onOpenChange:E,onCreated:e=>void t(`/project/${n}/session/${e.id}`)})]}),ge&&(0,W.jsx)(bc,{groups:g,activeSessionId:i,onReorder:x,onPromote:e=>v.ensureTerminal(e),onExpand:()=>l.update({sessions_collapsed:!1}),onNewTerminal:()=>R(`terminal`),onNewSession:()=>R(`agent`),onOpenScratchpad:()=>l.update({sessions_collapsed:!1,right_panel:`scratchpad`}),onArchived:oe})]}):null}export{ff as Workspace};
@@ -70,4 +70,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
70
70
  3. Apply what the rules above settle without asking. Ask the user about anything they leave open, stating trade-offs where relevant (e.g. a symlinked .venv saves gigabytes per worktree, but parallel sessions then share mutable dependency state).
71
71
  4. If the user states a standing rule for all future worktrees ("always…", "never…", "from now on…"), write the complete updated rules to \`.puddle/onboarding-notes.md\` in this worktree — full replacement, user-owned prose; record their decision, don't invent policy.
72
72
 
73
- Then proceed with the task below (or await instructions if none is given).`,Uo=`[puddle] You are joining an existing branch and worktree that other agents may be working in concurrently. Files can change underneath you, so re-check the working tree before you act, and avoid disruptive git operations (resetting, force-pushing, or deleting the branch) that would disrupt work already in progress by others.`,Wo=`This session was interrupted (daemon or machine restart). Processes you started are gone; re-verify your environment before continuing.`,Go=[[`name`,`the resolved display name: user rename, else agent name, else sequence, else id`],[`title`,`the user rename override only (empty when unset)`],[`agentName`,`the agent's own session name (empty when the agent has not named it)`],[`sequence`,`the terminal-title name the process set (empty when it set none)`],[`branch`,`the git branch`],[`cwd`,`the worktree directory's name`],[`id`,`the first 8 characters of the session id`],[`status`,`the session status (running, waiting_input, …)`],[`agent`,`the agent type (empty for terminal sessions)`],[`separator`,`an em dash that appears only between two non-empty neighbours`]],Ko="${name}",qo=[`navy`,`gold`,`blue`,`green`,`red`,`violet`,`cyan`];J({id:zo,name:Bo,branch_prefix:U(),icon:U().nullable().default(null),icon_colour:U().nullable().default(null),created_at:Z}),J({name:Bo,branch_prefix:U().max(64).optional()}),J({name:Bo.optional(),branch_prefix:U().max(64).optional(),icon:U().max(64).nullable().optional(),icon_colour:U().max(32).nullable().optional()});var Jo=$a({baseBranch:U().optional(),separateBranch:K().optional(),separateWorktree:K().optional()}),Yo=$a({agent:Jo.optional(),terminal:Jo.optional()});$a({allowSkipPermissions:K().default(!1),onboardingTemplate:U().optional(),concurrentTemplate:U().optional(),restartTemplate:U().optional(),tabTitleTemplate:U().optional(),projectOrder:q(U()).optional(),sessionDefaults:Yo.optional(),hotkeys:so(U(),U()).optional()}),so(U(),Ja()),J({id:Q,profile_id:zo,agent_type:U(),label:U(),config_dir:U(),skip_permissions_default:K(),logged_in:K(),created_at:Z}),J({profile_id:zo,agent_type:U().min(1),label:Bo,skip_permissions_default:K().optional(),import_dir:U().min(1).optional()}),J({label:Bo.optional(),skip_permissions_default:K().optional()}),J({stream:U(),term:U()}),$a({account_id:Q,logged_in:K(),session_count:G().int().nonnegative(),active_session_count:G().int().nonnegative(),last_activity_at:Z.nullable(),agent_usage:J({input_tokens:G().int().nonnegative(),output_tokens:G().int().nonnegative(),cache_read_input_tokens:G().int().nonnegative(),cache_creation_input_tokens:G().int().nonnegative(),message_count:G().int().nonnegative()}).nullable(),live_usage:J({captured_at:Z,context_used_percentage:G().nullable(),total_cost_usd:G().nullable(),model:U().nullable()}).nullable(),subscription:J({windows:q(J({key:U(),label:U(),used_percentage:G(),resets:U().nullable()}))}).nullable()}),J({id:U(),display_name:U(),capabilities:J({resume:K(),skip_permissions:K()})}),J({id:Q,path:U(),default_base_branch:U(),onboarding_notes:U().nullable(),fetch_enabled:K(),last_fetched_at:Z.nullable()}).extend({orphan_worktrees:q(U())}),J({path:U().min(1),default_base_branch:U().min(1).optional(),onboarding_notes:U().nullable().optional(),fetch_enabled:K().optional()}),J({branches:q(J({name:U(),is_session:K(),session_title:U().nullable()}))});var Xo=J({path:U(),branch:U().nullable(),is_primary:K(),dirty:K().optional(),local_only:K().optional()}),Zo=J({name:U(),local_only:K()});J({worktrees:q(Xo),orphan_branches:q(Zo)}),J({default_base_branch:U().min(1).optional(),onboarding_notes:U().nullable().optional(),fetch_enabled:K().optional()});var Qo=Y([`starting`,`running`,`waiting_input`,`exited`,`interrupted`,`archived`]),$o=Y([`agent`,`terminal`]),es=J({id:Lo,project_id:Ro,account_id:Q.nullable(),worktree_path:U(),base_branch:U(),branch:U(),separate_branch:K(),kind:$o,agent_type:U().nullable(),agent_session_ref:U().nullable(),title:U().nullable(),agent_title:U().nullable().optional(),osc_title:U().nullable().optional(),status:Qo,skip_permissions:K(),created_at:Z,updated_at:Z,last_activity_at:Z.nullable(),worktree_missing:K().optional(),git_summary:J({ahead:G().int().nonnegative(),behind:G().int().nonnegative(),dirty_files:G().int().nonnegative()}).nullable().optional()});J({project_id:Ro,account_id:Q.optional(),kind:$o.optional(),base_branch:U().min(1).optional(),branch:U().min(1).max(200).optional(),separate_branch:K().optional(),separate_worktree:K().optional(),join_worktree:U().optional(),title:U().min(1).max(200).optional(),prompt:U().optional(),skip_permissions:K().optional()}),J({title:U().max(200)}),J({account_id:Q}),J({force:K().default(!1),delete_branch:K().default(!1)});var ts=J({id:Ro,profile_id:zo,repo_id:Q,name:U(),archived:K().default(!1),created_at:Z,updated_at:Z});J({profile_id:zo,repo_id:Q,name:U().min(1).max(100)}),J({name:U().min(1).max(100).optional(),archived:K().optional()}),J({project:ts,sessions:q(es)});var ns=Y([`project`,`profile`]);J({id:Q,profile_id:zo,scope:ns,project_id:Ro.nullable(),title:U().nullable(),body:U(),tags:q(U()),agent_type:U().nullable(),position:G(),created_at:Z,updated_at:Z}),J({profile_id:zo,scope:ns,project_id:Ro.optional(),title:U().max(200).optional(),body:U().min(1),tags:q(U()).optional(),agent_type:U().optional()}),J({scope:ns.optional(),project_id:Ro.nullable().optional(),title:U().max(200).nullable().optional(),body:U().min(1).optional(),tags:q(U()).optional(),agent_type:U().nullable().optional(),position:G().optional()});var rs=J({session:Lo,path:U(),kind:Y([`file`,`diff`,`commit`]).optional(),sha:U().optional()}),is=ro(`type`,[J({type:X(`editor`),tab:rs}),J({type:X(`terminal`),session:Lo})]),as=J({kind:X(`leaf`),id:U(),tabs:q(is).default([]),activeKey:U().nullable().default(null),previewKey:U().nullable().default(null)}),os=Mo(()=>ro(`kind`,[as,J({kind:X(`split`),id:U(),direction:Y([`row`,`col`]),children:q(os),sizes:q(G())})])),ss=$a({session_tabs:q(Lo).default([]),active_session:Lo.nullable().default(null),editor_tabs:q(rs).default([]),layout:$a({}).default({}),explorer_pin:Lo.nullable().default(null),active_editor_tab:rs.nullable().default(null),explorer_open:K().default(!0),sidebar_mode:Y([`files`,`diff`,`history`,`changes`,`search`,`worktrees`]).default(`files`),sidebar_collapsed:K().default(!1),sessions_collapsed:K().default(!1),right_panel:Y([`sessions`,`scratchpad`]).default(`sessions`),session_order:q(Lo).default([]),layout_tree:os.nullable().default(null)});J({ui_state:ss}),J({ui_state:ss,updated_at:Z});var cs=Y([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);J({mime:cs,data:U().min(1)}),J({path:U()}),J({path:U(),line:G().int().nullable()});var ls=J({name:U(),type:Y([`file`,`dir`,`symlink`]),size:G().int().nonnegative().nullable(),symlink:K().default(!1)});J({path:U(),entries:q(ls)}),J({path:U(),content:U().nullable(),binary:K(),size:G().int().nonnegative(),mtime_ms:G()}),J({content:U(),expected_mtime_ms:G().optional()}),J({path:U(),mtime_ms:G(),size:G().int().nonnegative()}),J({files:q(J({path:U(),size:G().int().nonnegative()}))}),J({path:U().min(1),kind:Y([`file`,`dir`])}),J({from:U().min(1),to:U().min(1)}),J({from:U().min(1),to:U().min(1)}),J({path:U().min(1)}),J({ok:X(!0),path:U()});var us=Y([`added`,`modified`,`deleted`,`renamed`]),ds=J({path:U(),status:us,old_path:U().nullable()});J({against:U(),base_ref:U().nullable(),entries:q(ds)});var fs=Y([`untracked`,`modified`,`added`,`deleted`,`renamed`,`conflicted`,`ignored`]);J({entries:q(J({path:U(),status:fs}))}),J({path:U(),ref:U(),content:U().nullable(),binary:K()});var ps=J({sha:U(),subject:U(),author_name:U(),author_email:U(),authored_at:Z,parents:q(U()).optional()});J({commits:q(ps),has_more:K()}),J({commit:ps.extend({body:U()}),parents:q(U()),files:q(ds)});var ms=J({line:G().int().positive(),text:U()}),hs=J({path:U(),matches:q(ms)});J({query:U(),files:q(U()),content:q(hs),truncated:K()}),J({ports:q(J({port:G().int().min(1).max(65535),pid:G().int(),command:U(),address:U()})),scanned_at:Z});var gs=J({status:X(`refreshing`)}),_s=U().regex(/^(agent|shell-[0-9]+)$/),vs=`home`,ys={cols:G().int().min(2).max(1e3),rows:G().int().min(2).max(500)};ro(`t`,[J({t:X(`auth`),token:U()}),J({t:X(`attach`),session:U(),term:_s,...ys}),J({t:X(`stdin`),session:U(),term:_s,data:U()}),J({t:X(`resize`),session:U(),term:_s,...ys}),J({t:X(`detach`),session:U(),term:_s}),J({t:X(`spawn-shell`),session:U()}),J({t:X(`kill-shell`),session:U(),term:_s}),J({t:X(`subscribe-status`)})]);var bs=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t,this.name=`ApiError`}};async function xs(e,t,n){let r=_e.get(),i=await fetch(t,{method:e,headers:{...r?{authorization:`Bearer ${r}`}:{},...n===void 0?{}:{"content-type":`application/json`}},body:n===void 0?void 0:JSON.stringify(n)});if(i.status===401)throw ve(),new bs(401,`unauthorised`,`invalid or expired token`);if(i.status!==204){if(!i.ok){let n=Io.safeParse(await i.json().catch(()=>null));throw n.success?new bs(i.status,n.data.error.code,n.data.error.message):new bs(i.status,`unknown`,`${e} ${t} failed with ${i.status}`)}return await i.json()}}function Ss(){let e=_e.get();return e?{authorization:`Bearer ${e}`}:{}}async function Cs(e,t,n){let r=await fetch(t,{...n,method:e,headers:{...Ss(),...n?.headers}});if(r.status===401)throw ve(),new bs(401,`unauthorised`,`invalid or expired token`);if(!r.ok){let n=Io.safeParse(await r.json().catch(()=>null));throw n.success?new bs(r.status,n.data.error.code,n.data.error.message):new bs(r.status,`unknown`,`${e} ${t} failed with ${r.status}`)}return r}export{_e as _,gs as a,h as b,ss as c,Ho as d,Wo as f,y as g,Go as h,vs as i,Vo as l,qo as m,xs as n,cs as o,Ko as p,Cs as r,is as s,bs as t,Uo as u,v,_ as y};
73
+ Then proceed with the task below (or await instructions if none is given).`,Uo=`[puddle] You are joining an existing branch and worktree that other agents may be working in concurrently. Files can change underneath you, so re-check the working tree before you act, and avoid disruptive git operations (resetting, force-pushing, or deleting the branch) that would disrupt work already in progress by others.`,Wo=`This session was interrupted (daemon or machine restart). Processes you started are gone; re-verify your environment before continuing.`,Go=[[`name`,`the resolved display name: user rename, else agent name, else sequence, else id`],[`title`,`the user rename override only (empty when unset)`],[`agentName`,`the agent's own session name (empty when the agent has not named it)`],[`sequence`,`the terminal-title name the process set (empty when it set none)`],[`branch`,`the git branch`],[`cwd`,`the worktree directory's name`],[`id`,`the first 8 characters of the session id`],[`status`,`the session status (running, waiting_input, …)`],[`agent`,`the agent type (empty for terminal sessions)`],[`separator`,`an em dash that appears only between two non-empty neighbours`]],Ko="${name}",qo=[`navy`,`gold`,`blue`,`green`,`red`,`violet`,`cyan`];J({id:zo,name:Bo,branch_prefix:U(),icon:U().nullable().default(null),icon_colour:U().nullable().default(null),created_at:Z}),J({name:Bo,branch_prefix:U().max(64).optional()}),J({name:Bo.optional(),branch_prefix:U().max(64).optional(),icon:U().max(64).nullable().optional(),icon_colour:U().max(32).nullable().optional()});var Jo=$a({baseBranch:U().optional(),separateBranch:K().optional(),separateWorktree:K().optional()}),Yo=$a({agent:Jo.optional(),terminal:Jo.optional()});$a({allowSkipPermissions:K().default(!1),captureSessionEnv:K().default(!0),onboardingTemplate:U().optional(),concurrentTemplate:U().optional(),restartTemplate:U().optional(),tabTitleTemplate:U().optional(),projectOrder:q(U()).optional(),sessionDefaults:Yo.optional(),hotkeys:so(U(),U()).optional()}),so(U(),Ja()),J({id:Q,profile_id:zo,agent_type:U(),label:U(),config_dir:U(),skip_permissions_default:K(),logged_in:K(),created_at:Z}),J({profile_id:zo,agent_type:U().min(1),label:Bo,skip_permissions_default:K().optional(),import_dir:U().min(1).optional()}),J({label:Bo.optional(),skip_permissions_default:K().optional()}),J({stream:U(),term:U()}),$a({account_id:Q,logged_in:K(),session_count:G().int().nonnegative(),active_session_count:G().int().nonnegative(),last_activity_at:Z.nullable(),agent_usage:J({input_tokens:G().int().nonnegative(),output_tokens:G().int().nonnegative(),cache_read_input_tokens:G().int().nonnegative(),cache_creation_input_tokens:G().int().nonnegative(),message_count:G().int().nonnegative()}).nullable(),live_usage:J({captured_at:Z,context_used_percentage:G().nullable(),total_cost_usd:G().nullable(),model:U().nullable()}).nullable(),subscription:J({windows:q(J({key:U(),label:U(),used_percentage:G(),resets:U().nullable()}))}).nullable()}),J({id:U(),display_name:U(),capabilities:J({resume:K(),skip_permissions:K()})}),J({id:Q,path:U(),default_base_branch:U(),onboarding_notes:U().nullable(),fetch_enabled:K(),last_fetched_at:Z.nullable()}).extend({orphan_worktrees:q(U())}),J({path:U().min(1),default_base_branch:U().min(1).optional(),onboarding_notes:U().nullable().optional(),fetch_enabled:K().optional()}),J({branches:q(J({name:U(),is_session:K(),session_title:U().nullable()}))});var Xo=J({path:U(),branch:U().nullable(),is_primary:K(),dirty:K().optional(),local_only:K().optional()}),Zo=J({name:U(),local_only:K()});J({worktrees:q(Xo),orphan_branches:q(Zo)}),J({default_base_branch:U().min(1).optional(),onboarding_notes:U().nullable().optional(),fetch_enabled:K().optional()});var Qo=Y([`starting`,`running`,`waiting_input`,`exited`,`interrupted`,`archived`]),$o=Y([`agent`,`terminal`]),es=J({id:Lo,project_id:Ro,account_id:Q.nullable(),worktree_path:U(),base_branch:U(),branch:U(),separate_branch:K(),kind:$o,agent_type:U().nullable(),agent_session_ref:U().nullable(),title:U().nullable(),agent_title:U().nullable().optional(),osc_title:U().nullable().optional(),status:Qo,skip_permissions:K(),created_at:Z,updated_at:Z,last_activity_at:Z.nullable(),worktree_missing:K().optional(),git_summary:J({ahead:G().int().nonnegative(),behind:G().int().nonnegative(),dirty_files:G().int().nonnegative()}).nullable().optional()});J({project_id:Ro,account_id:Q.optional(),kind:$o.optional(),base_branch:U().min(1).optional(),branch:U().min(1).max(200).optional(),separate_branch:K().optional(),separate_worktree:K().optional(),join_worktree:U().optional(),title:U().min(1).max(200).optional(),prompt:U().optional(),skip_permissions:K().optional()}),J({title:U().max(200)}),J({account_id:Q}),J({vars:q(J({name:U(),bytes:G().int().nonnegative()}))}),J({cleared:G().int().nonnegative()}),J({force:K().default(!1),delete_branch:K().default(!1)});var ts=J({id:Ro,profile_id:zo,repo_id:Q,name:U(),archived:K().default(!1),created_at:Z,updated_at:Z});J({profile_id:zo,repo_id:Q,name:U().min(1).max(100)}),J({name:U().min(1).max(100).optional(),archived:K().optional()}),J({project:ts,sessions:q(es)});var ns=Y([`project`,`profile`]);J({id:Q,profile_id:zo,scope:ns,project_id:Ro.nullable(),title:U().nullable(),body:U(),tags:q(U()),agent_type:U().nullable(),position:G(),created_at:Z,updated_at:Z}),J({profile_id:zo,scope:ns,project_id:Ro.optional(),title:U().max(200).optional(),body:U().min(1),tags:q(U()).optional(),agent_type:U().optional()}),J({scope:ns.optional(),project_id:Ro.nullable().optional(),title:U().max(200).nullable().optional(),body:U().min(1).optional(),tags:q(U()).optional(),agent_type:U().nullable().optional(),position:G().optional()});var rs=J({session:Lo,path:U(),kind:Y([`file`,`diff`,`commit`]).optional(),sha:U().optional(),view:Y([`source`,`preview`]).optional()}),is=ro(`type`,[J({type:X(`editor`),tab:rs}),J({type:X(`terminal`),session:Lo})]),as=J({kind:X(`leaf`),id:U(),tabs:q(is).default([]),activeKey:U().nullable().default(null),previewKey:U().nullable().default(null)}),os=Mo(()=>ro(`kind`,[as,J({kind:X(`split`),id:U(),direction:Y([`row`,`col`]),children:q(os),sizes:q(G())})])),ss=$a({session_tabs:q(Lo).default([]),active_session:Lo.nullable().default(null),editor_tabs:q(rs).default([]),layout:$a({}).default({}),explorer_pin:Lo.nullable().default(null),active_editor_tab:rs.nullable().default(null),explorer_open:K().default(!0),sidebar_mode:Y([`files`,`diff`,`history`,`changes`,`search`,`worktrees`]).default(`files`),sidebar_collapsed:K().default(!1),sessions_collapsed:K().default(!1),right_panel:Y([`sessions`,`scratchpad`]).default(`sessions`),session_order:q(Lo).default([]),layout_tree:os.nullable().default(null)});J({ui_state:ss}),J({ui_state:ss,updated_at:Z});var cs=Y([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);J({mime:cs,data:U().min(1)}),J({path:U()}),J({path:U(),line:G().int().nullable()});var ls=J({name:U(),type:Y([`file`,`dir`,`symlink`]),size:G().int().nonnegative().nullable(),symlink:K().default(!1)});J({path:U(),entries:q(ls)}),J({path:U(),content:U().nullable(),binary:K(),size:G().int().nonnegative(),mtime_ms:G()}),J({content:U(),expected_mtime_ms:G().optional()}),J({path:U(),mtime_ms:G(),size:G().int().nonnegative()}),J({files:q(J({path:U(),size:G().int().nonnegative()}))}),J({path:U().min(1),kind:Y([`file`,`dir`])}),J({from:U().min(1),to:U().min(1)}),J({from:U().min(1),to:U().min(1)}),J({path:U().min(1)}),J({ok:X(!0),path:U()});var us=Y([`added`,`modified`,`deleted`,`renamed`]),ds=J({path:U(),status:us,old_path:U().nullable()});J({against:U(),base_ref:U().nullable(),entries:q(ds)});var fs=Y([`untracked`,`modified`,`added`,`deleted`,`renamed`,`conflicted`,`ignored`]);J({entries:q(J({path:U(),status:fs}))}),J({path:U(),ref:U(),content:U().nullable(),binary:K()});var ps=J({sha:U(),subject:U(),author_name:U(),author_email:U(),authored_at:Z,parents:q(U()).optional()});J({commits:q(ps),has_more:K()}),J({commit:ps.extend({body:U()}),parents:q(U()),files:q(ds)});var ms=J({line:G().int().positive(),text:U()}),hs=J({path:U(),matches:q(ms)});J({query:U(),files:q(U()),content:q(hs),truncated:K()}),J({ports:q(J({port:G().int().min(1).max(65535),pid:G().int(),command:U(),address:U()})),scanned_at:Z});var gs=J({status:X(`refreshing`)}),_s=U().regex(/^(agent|shell-[0-9]+)$/),vs=`home`,ys={cols:G().int().min(2).max(1e3),rows:G().int().min(2).max(500)};ro(`t`,[J({t:X(`auth`),token:U()}),J({t:X(`attach`),session:U(),term:_s,...ys}),J({t:X(`stdin`),session:U(),term:_s,data:U()}),J({t:X(`resize`),session:U(),term:_s,...ys}),J({t:X(`detach`),session:U(),term:_s}),J({t:X(`spawn-shell`),session:U()}),J({t:X(`kill-shell`),session:U(),term:_s}),J({t:X(`subscribe-status`)})]);var bs=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t,this.name=`ApiError`}};async function xs(e,t,n){let r=_e.get(),i=await fetch(t,{method:e,headers:{...r?{authorization:`Bearer ${r}`}:{},...n===void 0?{}:{"content-type":`application/json`}},body:n===void 0?void 0:JSON.stringify(n)});if(i.status===401)throw ve(),new bs(401,`unauthorised`,`invalid or expired token`);if(i.status!==204){if(!i.ok){let n=Io.safeParse(await i.json().catch(()=>null));throw n.success?new bs(i.status,n.data.error.code,n.data.error.message):new bs(i.status,`unknown`,`${e} ${t} failed with ${i.status}`)}return await i.json()}}function Ss(){let e=_e.get();return e?{authorization:`Bearer ${e}`}:{}}async function Cs(e,t,n){let r=await fetch(t,{...n,method:e,headers:{...Ss(),...n?.headers}});if(r.status===401)throw ve(),new bs(401,`unauthorised`,`invalid or expired token`);if(!r.ok){let n=Io.safeParse(await r.json().catch(()=>null));throw n.success?new bs(r.status,n.data.error.code,n.data.error.message):new bs(r.status,`unknown`,`${e} ${t} failed with ${r.status}`)}return r}export{_e as _,gs as a,h as b,ss as c,Ho as d,Wo as f,y as g,Go as h,vs as i,Vo as l,qo as m,xs as n,cs as o,Ko as p,Cs as r,is as s,bs as t,Uo as u,v,_ as y};