@puddle-code/cli 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -3
- package/dist/index.js +3 -2
- package/dist/public/assets/App-D-hMqX7b.js +13 -0
- package/dist/public/assets/{CompilationCommandForm-ByQ3n2Av.js → CompilationCommandForm-Csg3VkC6.js} +1 -1
- package/dist/public/assets/{Dashboard-DXufaZFW.js → Dashboard-C0AvtM5m.js} +1 -1
- package/dist/public/assets/EditorTabClose-QgdaqA1X.js +1 -0
- package/dist/public/assets/{LazyTerminal-CQNsHnn5.js → LazyTerminal-Dp2CN0Y8.js} +2 -2
- package/dist/public/assets/{ModelRefcount-CrRz4dBj.js → ModelRefcount-CHKuXiJY.js} +1 -1
- package/dist/public/assets/{NewProjectDialog-CRoDFgh9.js → NewProjectDialog-DMixZDC_.js} +1 -1
- package/dist/public/assets/{NotebookWidget-D_cBVZys.js → NotebookWidget-CCRsiBIE.js} +1 -1
- package/dist/public/assets/{PaneEditorBody-_H5u21rG.js → PaneEditorBody-DD8UshBi.js} +4 -4
- package/dist/public/assets/{PdfViewer-CvbL21Y7.js → PdfViewer-BX025YLW.js} +1 -1
- package/dist/public/assets/{ReleaseNotesDialog-WjdHjwjo.js → ReleaseNotesDialog-CbFYKoYM.js} +1 -1
- package/dist/public/assets/{SettingsDialog-CiDPg9PP.js → SettingsDialog-DgMm212x.js} +1 -1
- package/dist/public/assets/{Terminal-kGAX-Lcx.js → Terminal-CYeh8_uU.js} +3 -3
- package/dist/public/assets/Workspace-Bf0VMnaa.css +1 -0
- package/dist/public/assets/Workspace-CrZkK55U.js +20 -0
- package/dist/public/assets/{buffer-store-BvfE0iGv.js → buffer-store-DIOiWz9q.js} +1 -1
- package/dist/public/assets/button-C_Rvtcwg.js +1 -0
- package/dist/public/assets/{chevron-right-nSpC9bNN.js → chevron-right-BEy-IXEZ.js} +1 -1
- package/dist/public/assets/{command-CrnEVrrI.js → command-BV8ZEhQz.js} +1 -1
- package/dist/public/assets/context-menu-D3ZhKA9s.js +1 -0
- package/dist/public/assets/control-tray-CdoVaVhT.js +1 -0
- package/dist/public/assets/control-tray-DE2RhHP3.css +1 -0
- package/dist/public/assets/dialog-BX0tebJL.css +1 -0
- package/dist/public/assets/{dialog-BIriom7c.js → dialog-D-Axqpzg.js} +1 -1
- package/dist/public/assets/dist-BmSuHjIq.js +1 -0
- package/dist/public/assets/{dist-gLwIpKj2.js → dist-Cq-O0n8n.js} +1 -1
- package/dist/public/assets/{dist-DsLo0ckR.js → dist-Dge3wHdO.js} +1 -1
- package/dist/public/assets/{index-Nd31gVbt.js → index-BqOVeoIr.js} +2 -2
- package/dist/public/assets/index-LpAqnBR3.css +2 -0
- package/dist/public/assets/{markdown-mermaid-ByeNUiyP.js → markdown-mermaid-SyDYdSZz.js} +1 -1
- package/dist/public/assets/media-refresh-store-NSkvkBxN.js +1 -0
- package/dist/public/assets/{notification-delivery-BrgeSks8.js → notification-delivery-BBt_CJ19.js} +1 -1
- package/dist/public/assets/popover-D-jcaKGN.js +1 -0
- package/dist/public/assets/select-p5KTVHbg.js +1 -0
- package/dist/public/assets/{selection-actions-2STnRxD9.js → selection-actions-Cm0Oytya.js} +1 -1
- package/dist/public/assets/{switch-B1LYyDZA.js → switch-OMx-_DY7.js} +1 -1
- package/dist/public/assets/use-ui-state-DdnTFosh.js +1 -0
- package/dist/public/index.html +2 -2
- package/package.json +1 -1
- package/dist/public/assets/App-CiC_hRBz.js +0 -7
- package/dist/public/assets/EditorTabClose-dEi1apPb.js +0 -1
- package/dist/public/assets/Workspace-D8fTPYJv.js +0 -20
- package/dist/public/assets/Workspace-fmUH5XvW.css +0 -1
- package/dist/public/assets/button-q0ardkfx.js +0 -1
- package/dist/public/assets/context-menu-BaamZoTk.js +0 -1
- package/dist/public/assets/control-tray-CHewYBoS.css +0 -1
- package/dist/public/assets/control-tray-D6zVSZF4.js +0 -1
- package/dist/public/assets/dialog-BYIi-VQq.css +0 -1
- package/dist/public/assets/dist-t7ZlsY9S.js +0 -1
- package/dist/public/assets/index-DAZZvnBz.css +0 -2
- package/dist/public/assets/media-refresh-store-1wdl12UC.js +0 -1
- package/dist/public/assets/popover-ChiZqTsE.js +0 -1
- package/dist/public/assets/select-4yfFmU4K.js +0 -1
- package/dist/public/assets/use-ui-state-Bi73JKcr.js +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PaneEditorBody-DD8UshBi.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/protocol-support-BApsXw77.js","assets/auth-olLlgxc3.js","assets/jsx-runtime-By8HlURe.js","assets/api-BOuyloUi.js","assets/context-CSOKgBuW.js","assets/client-settings-DhfHheKR.js","assets/preload-helper-Czpn1I53.js","assets/index-BqOVeoIr.js","assets/react-dom-cJyBB_A4.js","assets/index-LpAqnBR3.css","assets/purify.es-D8QhFVkO.js","assets/katex.min-ZqdHjttS.js","assets/katex-Dz-67XSV.css","assets/editor.api2-4X9Vh9Zw.js","assets/editor-Br_kD0ds.css","assets/hotkeys-Cu0t6sbz.js","assets/media-refresh-store-NSkvkBxN.js","assets/dist-BOS6OKSE.js","assets/dialog-D-Axqpzg.js","assets/x-Dq6POV20.js","assets/createLucideIcon-C9A1vLE-.js","assets/dialog-BX0tebJL.css","assets/chevron-right-BEy-IXEZ.js","assets/dist-BmSuHjIq.js","assets/dist-Cq-O0n8n.js","assets/dist-Dge3wHdO.js","assets/motion-OSLfKoC0.js","assets/select-p5KTVHbg.js","assets/chevron-down-HQLVE6o5.js","assets/FindWidget-DG1YP6Zx.js","assets/copy-D0Theg4Q.js","assets/rotate-ccw-BI2k_h3A.js","assets/preview-kind-CPkO-rSz.js","assets/control-tray-CdoVaVhT.js","assets/control-tray-DE2RhHP3.css","assets/command-BV8ZEhQz.js","assets/popover-D-jcaKGN.js","assets/markdown-it-CWoG9_Dn.js","assets/debounce-B9DrqirV.js","assets/buffer-store-DIOiWz9q.js","assets/workers-Ck67TJT4.js","assets/monaco.contribution-C0TYpF88.js","assets/buffer-logic-BAkSBQT7.js","assets/view-state-store-Cy9sQJoZ.js","assets/markdown-CMSzQtLp.js","assets/math-CSw6sgCC.js","assets/math-delimiters-BCnTi7Ii.js","assets/drafts-B_tChlzR.js","assets/editor-sync-W1bamxAP.js","assets/markdown-mermaid-SyDYdSZz.js","assets/ModelRefcount-CHKuXiJY.js","assets/EditorTabClose-QgdaqA1X.js","assets/button-C_Rvtcwg.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./react-dom-cJyBB_A4.js";import{B as r,C as i,D as a,K as o,L as s,O as c,R as l,St as u,T as d,Tt as f,X as p,_ as m,_t as h,a as g,at as _,ct as v,dt as y,ft as b,g as x,gt as S,h as C,ht as w,i as T,k as E,l as D,lt as O,nt as k,pt as A,q as ee,r as j,s as M,st as N,t as te,tt as P,ut as ne,v as re,x as ie,xt as ae,yt as oe}from"./protocol-support-BApsXw77.js";import{D as se,E as ce,I as F,L as le,N as ue,O as de,P as fe,R as I,a as L,nt as pe,o as me,s as he,st as ge,w as R}from"./auth-olLlgxc3.js";import{a as _e,c as ve,d as ye,i as z,n as be,o as xe,r as Se,s as Ce,t as we,u as Te}from"./LazyTerminal-Dp2CN0Y8.js";import{i as Ee,r as De,t as Oe}from"./client-settings-DhfHheKR.js";import{t as ke}from"./jsx-runtime-By8HlURe.js";import{t as Ae}from"./preload-helper-Czpn1I53.js";import{l as je,u as Me}from"./index-BqOVeoIr.js";import{n as Ne,t as Pe}from"./api-BOuyloUi.js";import{g as Fe,p as Ie,u as Le}from"./hotkeys-Cu0t6sbz.js";import{n as Re}from"./forward-link-DMvLf0Xw.js";import{$ as ze,A as Be,B as Ve,D as He,F as Ue,G as We,H as B,I as Ge,L as Ke,M as qe,N as Je,Q as Ye,R as Xe,S as Ze,U as Qe,V as $e,X as et,a as tt,at as nt,b as rt,c as it,et as at,f as ot,g as st,h as ct,i as lt,it as ut,j as dt,k as ft,l as pt,nt as mt,o as ht,ot as gt,p as _t,q as vt,r as yt,rt as bt,s as xt,st as St,t as Ct,tt as wt,u as Tt,v as Et,x as Dt,y as Ot,z as kt}from"./media-refresh-store-NSkvkBxN.js";import{a as At,c as jt,f as Mt,i as Nt,m as Pt,n as Ft,o as It,p as Lt,r as Rt,t as zt}from"./session-order-2oedrwDu.js";import{n as V}from"./dist-BOS6OKSE.js";import{a as Bt,i as Vt,o as Ht,r as Ut,s as Wt,t as Gt}from"./dialog-D-Axqpzg.js";import{t as Kt}from"./x-Dq6POV20.js";import{n as qt,o as Jt,r as Yt,t as Xt}from"./chevron-right-BEy-IXEZ.js";import{n as Zt,r as Qt}from"./dist-Dge3wHdO.js";import{$ as $t,A as en,B as H,C as tn,D as nn,E as rn,F as an,H as on,I as sn,L as cn,M as ln,N as un,O as dn,P as fn,Q as pn,R as mn,S as hn,T as gn,V as _n,X as vn,Y as yn,_ as bn,a as xn,at as U,b as Sn,c as Cn,g as wn,h as Tn,i as En,it as W,j as Dn,k as On,l as kn,n as An,o as jn,q as Mn,rt as Nn,s as Pn,st as G,tt as Fn,u as In,v as Ln,w as Rn,x as zn,y as Bn,z as Vn}from"./use-ui-state-DdnTFosh.js";import{n as K,t as q}from"./createLucideIcon-C9A1vLE-.js";import{t as J}from"./button-C_Rvtcwg.js";import{a as Hn,c as Un,d as Wn,i as Gn,l as Kn,n as qn,o as Jn,r as Y,s as Yn,t as Xn,u as Zn}from"./context-menu-D3ZhKA9s.js";import{d as Qn,i as $n,l as er,o as tr,s as nr,t as rr,u as ir}from"./switch-OMx-_DY7.js";import{a as ar,i as or,r as sr,t as cr}from"./motion-OSLfKoC0.js";import{a as lr,i as ur,n as dr,r as fr,t as pr}from"./select-p5KTVHbg.js";import{t as mr}from"./chevron-down-HQLVE6o5.js";import{b as hr,c as gr,d as _r,g as vr,h as yr,l as br,o as xr,p as Sr,r as Cr,s as wr,t as Tr,u as Er,y as Dr}from"./selection-actions-Cm0Oytya.js";import{n as Or,o as kr,s as Ar}from"./preview-kind-CPkO-rSz.js";import{i as jr,n as Mr,r as Nr,t as Pr}from"./control-tray-CdoVaVhT.js";import{n as Fr,r as Ir,t as Lr}from"./ws-Dgc69_w8.js";import{n as Rr,r as zr}from"./view-state-store-Cy9sQJoZ.js";import{a as Br,t as Vr}from"./drafts-B_tChlzR.js";import{i as Hr}from"./buffer-logic-BAkSBQT7.js";import{t as Ur}from"./scroll-restoration-CwXbvZvT.js";import{a as Wr,c as Gr,i as Kr,l as qr,n as Jr,s as Yr,t as Xr,u as Zr}from"./CompilationCommandForm-Csg3VkC6.js";var Qr=q(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),$r=q(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),ei=q(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),ti=q(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),ni=q(`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`}]]),ri=q(`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`}]]),ii=q(`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`}]]),ai=q(`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`}]]),oi=q(`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`}]]),si=q(`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`}]]),ci=q(`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`}]]),li=q(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),ui=q(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),di=q(`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`}]]),fi=q(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),pi=q(`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`}]]),mi=q(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),hi=q(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),gi=q(`message-circle-x`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),_i=q(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),vi=q(`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`}]]),yi=q(`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`}]]),bi=q(`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`}]]),xi=q(`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`}]]),Si=q(`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`}]]),Ci=q(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),wi=q(`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`}]]),Ti=q(`text-cursor-input`,[[`path`,{d:`M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6`,key:`1528k5`}],[`path`,{d:`M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7`,key:`13ksps`}],[`path`,{d:`M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1`,key:`1n9rhb`}],[`path`,{d:`M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1`,key:`1mj8rg`}],[`path`,{d:`M9 6v12`,key:`velyjx`}]]),Ei=q(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Di=q(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Oi=q(`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`}]]),ki=e(n(),1),Ai;function ji(){let e=new Map;for(let t of document.querySelectorAll(`[data-sidebar-motion]`)){let n=t.querySelector(`.status-glyph`)??t,r=n.getBoundingClientRect();if(!r.width||!r.height)continue;let i=Math.max(0,r.left),a=Math.min(innerWidth,r.right),o=Math.max(0,r.top),s=Math.min(innerHeight,r.bottom);for(let e=n.parentElement;e;e=e.parentElement){let t=getComputedStyle(e),n=e.getBoundingClientRect();/(auto|scroll|hidden|clip)/.test(t.overflowX)&&(i=Math.max(i,n.left),a=Math.min(a,n.right)),/(auto|scroll|hidden|clip)/.test(t.overflowY)&&(o=Math.max(o,n.top),s=Math.min(s,n.bottom))}if(i>=a||o>=s)continue;let c=t.dataset.sidebarMotion;e.set(c,n)}let t=[];for(let[n,r]of e){let e=r.style.viewTransitionName,i=r.style.getPropertyValue(`view-transition-class`);r.style.viewTransitionName=`sidebar-${Array.from(n,e=>e.codePointAt(0).toString(16)).join(`-`)}`,r.style.setProperty(`view-transition-class`,`sidebar-item`),t.push(()=>{r.style.viewTransitionName=e,r.style.setProperty(`view-transition-class`,i)})}return()=>t.forEach(e=>e())}function Mi(e){if(!document.startViewTransition||cr()){e();return}if(Ai){Ai.skipTransition(),Ai.updateCallbackDone.then(()=>(0,ki.flushSync)(e)).catch(()=>{});return}document.documentElement.classList.add(`sidebar-transition`);let t=ji(),n=document.querySelector(`[data-sidebar-main]`),r=n?.getBoundingClientRect(),i,a=()=>{},o=()=>{},s=document.startViewTransition(()=>{if(t(),(0,ki.flushSync)(e),!cr()){if(n?.isConnected&&r){let e=n.getBoundingClientRect(),t=n.parentElement,o=t.style.overflow;t.style.overflow=`visible`,a=()=>{t.style.overflow=o},i=n.animate([{width:`${r.width}px`,height:`${r.height}px`,transform:`translate(${r.x-e.x}px, ${r.y-e.y}px)`},{width:`${e.width}px`,height:`${e.height}px`,transform:`translate(0, 0)`}],{duration:280,easing:`ease-out`})}o=ji()}});Ai=s;let c=new MutationObserver(()=>{cr()&&(i?.cancel(),s.skipTransition())});c.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-reduce-motion`]}),s.finished.finally(()=>{c.disconnect(),Ai===s&&(t(),o(),i?.cancel(),a(),Ai=void 0,document.documentElement.classList.remove(`sidebar-transition`))}).catch(()=>{})}var X=ke(),Z=e(t(),1);function Ni(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Pi(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function Fi(e){return e/100*window.innerHeight}function Ii(e){return e/100*window.innerWidth}function Li(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 Ri({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=Li(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Pi(t,i);break;case`em`:r=Ni(t,i);break;case`vh`:r=Fi(i);break;case`vw`:r=Ii(i);break}return r}function zi(e){return parseFloat(e.toFixed(3))}function Bi({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 Vi(e){let{panels:t}=e,n=Bi({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=zi(Ri({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=zi(Ri({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=zi(Ri({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=zi(Ri({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 Hi(e,t){return Array.from(t).sort(e===`horizontal`?Ui:Wi)}function Ui(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function Wi(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function Gi(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function Ki(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 qi({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}=Ki(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return Q(i,`No rect found`),i}var Ji;function Yi(){return Ji===void 0&&(Ji=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),Ji}function Xi(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=Hi(n,Array.from(t.children).filter(Gi).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,qi({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=Yi()?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:Bi({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 Zi=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)}}},Qi={cursorFlags:0,state:`inactive`},$i=new Zi;function ea(){return Qi}function ta(e){return $i.addListener(`change`,e)}function na(e){let t=Qi,n={...Qi};n.cursorFlags=e,Qi=n,$i.emit(`change`,{prev:t,next:n})}function ra(e){let t=Qi;Qi=e,$i.emit(`change`,{prev:t,next:e})}var ia=e=>e,aa=()=>{},oa=1,sa=2,ca=4,la=8,ua=3,da=12,fa;function pa(){return fa===void 0&&(fa=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(fa=!0)),fa}function ma({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&&pa()){let t=(e&oa)!==0,n=(e&sa)!==0,r=(e&ca)!==0,i=(e&la)!==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 pa()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var ha=new WeakMap;function ga(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=ha.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=ea();switch(r.state){case`active`:case`hover`:{let e=ma({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}ha.set(e,{prevStyle:t,styleSheet:n})}var _a=new Map,va=new Zi;function ya(e){_a=new Map(_a),_a.delete(e)}function ba(e,t){for(let[t]of _a)if(t.id===e)return t}function xa(e,t){for(let[t,n]of _a)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Sa(){return _a}function Ca(e,t){return va.addListener(`groupChange`,n=>{n.group.id===e&&t(n)})}function wa(e,t,n){let r=_a.get(e);_a=new Map(_a),_a.set(e,t),va.emit(`groupChange`,{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function Ta(e){let t=ea(),n=!1;switch(t.state){case`active`:ra({cursorFlags:0,state:`inactive`}),t.hitRegions.length>0&&(ga(e),n=!0,t.hitRegions.forEach(e=>{let t=xa(e.group.id,!0);wa(e.group,t,{isUserInteraction:!0})}))}return n}function Ea(e){e.defaultPrevented||Ta(e.currentTarget)}function Da(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=Ki(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 Oa(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function ka(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:Fa(e),b:Fa(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:Pa(Na(n.a)),b:Pa(Na(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 Aa=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function ja(e){let t=getComputedStyle(Ia(e)??e).display;return t===`flex`||t===`inline-flex`}function Ma(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||ja(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`||Aa.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Na(e){let t=e.length;for(;t--;){let n=e[t];if(Q(n,`Missing node`),Ma(n))return n}return null}function Pa(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Fa(e){let t=[];for(;e;)t.push(e),e=Ia(e);return t}function Ia(e){let{parentNode:t}=e;return Oa(t)?t.host:t}function La(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 Ra({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Gi(n)||n.contains(e)||e.contains(n))return!0;if(ka(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(La(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function za(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=Xi(r),a=Da(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Ra({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Ba(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 Va(e,t,n=0){return Math.abs(zi(e)-zi(t))<=n}function Ha(e,t){return Va(e,t)?0:e>t?1:-1}function Ua({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(Ha(r,c)<0)if(a){let e=(i+c)/2;r=Ha(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=zi(r),r}function Wa({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Va(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}`),Va(n,i)){let t=o-n;Ha(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}`),Va(n,o)){let t=n-i;Ha(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&&Ha(i,c)<0)if(e>0){let t=c-o,n=t/2;Ha(i+e,c)<0&&(e=Ha(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;Ha(i-e,c)<0&&(e=Ha(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=Ua({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=Ua({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!Va(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(Ba(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=Ua({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!Va(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=Ua({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(Va(i,s)||(t-=s-i,l[r]=s),Va(t,0))break;e>0?r--:r++}}}if(!Va(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 Ga(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||Ha(e[n],t[n])!==0)return!1;return!0}function Ka({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(!Va(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=Ua({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!Va(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=Ua({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,Va(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function qa({groupId:e,panelId:t}){let n=()=>{let t=Sa();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&&Va(n.collapsedSize,r[n.panelId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:zi(100-e)}}return Wa({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=Ka({layout:o({nextSize:e,panels:i.panels,prevLayout:c,derivedPanelConstraints:r}),panelConstraints:r});Ga(c,u)||wa(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&&Va(t,n)},resize:e=>{let{group:t}=n(),{element:r}=i(),a=Bi({group:t}),o=zi(Ri({groupSize:a,panelElement:r,styleProp:e})/a*100);s(o)}}}function Ja(e){e.defaultPrevented||za(e,Sa()).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=qa({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Ya(e){let t=Sa();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 Xa({groupId:e}){let t=()=>{let t=Sa();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=Ka({layout:e,panelConstraints:r});return n?o:(Ga(o,c)||wa(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:s}),c)}}}function Za(e,t){let n=Ya(e),r=xa(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=Xa({groupId:n.id}).getLayout(),c=Ka({layout:Wa({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});Ga(s,c)||wa(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function Qa(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Ya(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&Za(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&Za(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&Za(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&Za(t,-5);break;case`End`:e.preventDefault(),Za(t,100);break;case`Enter`:{e.preventDefault();let n=Ya(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=xa(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];Za(t,(l.collapsedSize===e?n.mutableState.expandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=Ya(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(),Za(t,-100);break}}function $a(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Sa(),n=za(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)}),ra({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}),n.length&&e.preventDefault()}function eo({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=Wa({delta:d,initialLayout:f,panelConstraints:h,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:_,trigger:`mouse-or-touch`});if(Ga(t,_)){if(d!==0&&!u)switch(c){case`horizontal`:s|=d<0?oa:sa;break;case`vertical`:s|=d<0?ca:la;break}}else wa(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,groupSize:g,layout:t,separatorToPanels:v})}});let c=0;t.movementX===0?c|=o&ua:c|=s&ua,t.movementY===0?c|=o&da:c|=s&da,na(c),ga(e)}function to(e){let t=Sa(),n=ea();switch(n.state){case`active`:eo({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function no(e){if(e.defaultPrevented)return;let t=ea(),n=Sa();switch(t.state){case`active`:if(e.buttons===0){ra({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{let t=xa(e.group.id,!0);wa(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)}eo({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=za(e,n);r.length===0?t.state!==`inactive`&&ra({cursorFlags:0,state:`inactive`}):ra({cursorFlags:0,hitRegions:r,state:`hover`}),ga(e.currentTarget);break}}}function ro(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(ea().state){case`hover`:ra({cursorFlags:0,state:`inactive`})}}function io(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||Ta(e.currentTarget)&&e.preventDefault()}function ao(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=zi(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=zi((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function oo(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=Bi({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:zi(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function so(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 co({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=zi(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]=zi((r[e]??0)/a*l);else{let e=zi(l/c.length);for(let t of c)u[t]=e}return u}function lo(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 uo=new Map;function fo(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=Bi({group:e});if(t===0)return;let n=xa(e.id);if(!n)return;let r=Vi(e),i=n.defaultLayoutDeferred?ao(r):n.layout,a=Ka({layout:co({group:e,nextGroupSize:t,prevGroupSize:n.groupSize,prevLayout:i}),panelConstraints:r});if(!n.defaultLayoutDeferred&&Ga(n.layout,a)&&so(n.derivedPanelConstraints,r)&&n.groupSize===t)return;wa(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:t,layout:a,separatorToPanels:n.separatorToPanels})}}else oo(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=Bi({group:e}),s=Vi(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.mutableState.defaultLayout;l&&(lo(e.panels,l)||(l=void 0));let u=Ka({layout:e.mutableState.layouts[c]??l??ao(s),panelConstraints:s}),d=e.element.ownerDocument;uo.set(d,(uo.get(d)??0)+1);let f=new Map;return Xi(e).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),wa(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`,Qa)}),uo.get(d)===1&&(d.addEventListener(`contextmenu`,Ea,!0),d.addEventListener(`dblclick`,Ja,!0),d.addEventListener(`pointerdown`,$a,!0),d.addEventListener(`pointerleave`,to),d.addEventListener(`pointermove`,no),d.addEventListener(`pointerout`,ro),d.addEventListener(`pointerup`,io,!0)),function(){t=!1,uo.set(d,Math.max(0,(uo.get(d)??0)-1)),ya(e),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Qa)}),uo.get(d)||(d.removeEventListener(`contextmenu`,Ea,!0),d.removeEventListener(`dblclick`,Ja,!0),d.removeEventListener(`pointerdown`,$a,!0),d.removeEventListener(`pointerleave`,to),d.removeEventListener(`pointermove`,no),d.removeEventListener(`pointerout`,ro),d.removeEventListener(`pointerup`,io,!0)),a.disconnect()}}function po(){let[e,t]=(0,Z.useState)({});return[e,(0,Z.useCallback)(()=>t({}),[])]}function mo(e){let t=(0,Z.useId)();return`${e??t}`}var ho=typeof window<`u`?Z.useLayoutEffect:Z.useEffect;function go(e){let t=(0,Z.useRef)(e);return ho(()=>{t.current=e},[e]),(0,Z.useCallback)((...e)=>t.current?.(...e),[t])}function _o(...e){return go(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function vo(e){let t=(0,Z.useRef)({...e});return ho(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var yo=(0,Z.createContext)(null);function bo(e,t){let n=(0,Z.useRef)({getLayout:()=>({}),setLayout:ia});(0,Z.useImperativeHandle)(t,()=>n.current,[]),ho(()=>{Object.assign(n.current,Xa({groupId:e}))})}function xo({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,Z.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=go(e=>{Ga(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=go((e,t)=>{Ga(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t}))}),_=mo(s),v=(0,Z.useRef)(null),[y,b]=po(),x=(0,Z.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=_o(v,a);bo(_,o);let C=go((e,t)=>{let r=ea(),i=ba(e),a=xa(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=vo({defaultLayout:n,disableCursor:r}),T=(0,Z.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=Hi(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=Hi(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=ba(_),i=xa(_);r&&i&&wa(r,{...i,derivedPanelConstraints:Vi(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,Z.useRef)(null);return ho(()=>{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=fo(r),{defaultLayoutDeferred:o,derivedPanelConstraints:s,layout:c}=xa(r.id,!0);!o&&s.length>0&&(h(c),g(c,!1));let l=Ca(_,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=Va(t.collapsedSize,i[t.panelId]),a=Va(t.collapsedSize,n[t.panelId]);e&&!a&&(r.mutableState.expandedPanelSizes[t.panelId]=n[t.panelId])}}});let o=ea().state!==`active`;h(i),o&&g(i,e.isUserInteraction)});return()=>{E.current=null,a(),l()}},[i,_,g,h,u,y,w]),(0,Z.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,X.jsx)(yo.Provider,{value:T,children:(0,X.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})})}xo.displayName=`Group`;function So(){let e=(0,Z.useContext)(yo);return Q(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Co(e,t){let{id:n}=So(),r=(0,Z.useRef)({collapse:aa,expand:aa,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:aa});(0,Z.useImperativeHandle)(t,()=>r.current,[]),ho(()=>{Object.assign(r.current,qa({groupId:n,panelId:e}))})}function wo({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=mo(c),_=vo({disabled:a}),v=(0,Z.useRef)(null),y=_o(v,o),{getPanelStyles:b,id:x,orientation:S,registerPanel:C,updatePanelProps:w}=So(),T=d!==null,E=go((e,t,n)=>{d?.(e,c,n)});ho(()=>{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,Z.useEffect)(()=>{w(g,{disabled:a})},[a,g,w]),Co(g,f);let D=()=>{let e=b(x,g);if(e)return JSON.stringify(e)},O=(0,Z.useSyncExternalStore)(e=>Ca(x,e),D,D),k;return k=O?JSON.parse(O):i===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:i},(0,X.jsx)(`div`,{...m,"data-disabled":a||void 0,"data-panel":!0,"data-testid":g,id:g,ref:y,style:{...To,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...k},children:(0,X.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...p,touchAction:S===`horizontal`?`pan-y`:`pan-x`},children:e})})}wo.displayName=`Panel`;var To={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function Eo({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=Ka({layout:Wa({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Ka({layout:Wa({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function Do({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,style:o,...s}){let c=mo(a),l=vo({disabled:n,disableDoubleClick:r}),[u,d]=(0,Z.useState)({}),[f,p]=(0,Z.useState)(`inactive`),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(null),_=_o(g,i),{disableCursor:v,id:y,orientation:b,registerSeparator:x,updateSeparatorProps:S}=So(),C=b===`horizontal`?`vertical`:`horizontal`;ho(()=>{let e=g.current;if(e!==null){let t={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:e,id:c},n=x(t),r=ta(e=>{p(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===t)?e.next.state:`inactive`)}),i=Ca(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(Eo({layout:r,panelConstraints:n,panelId:e.id,panelIndex:t}))}});return()=>{r(),i(),n()}}},[y,c,x,l]),(0,Z.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,X.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})}Do.displayName=`Separator`;function Oo({separatorRef:e,vertical:t}){let[n,r]=(0,Z.useState)([]);return(0,Z.useEffect)(()=>{let n=e.current;if(!n)return;let i=[n.previousElementSibling,n.nextElementSibling],a=0,o=()=>{if(!(n.matches(`:hover, :focus-visible`)||n.dataset.separator===`active`)){r([]);return}let e=[];i.forEach((n,r)=>{if(!n)return;let i=n.getBoundingClientRect(),a=t?r===0?`right`:`left`:r===0?`bottom`:`top`,o=`.workspace-surface.island-outline`,s=[...n.querySelectorAll(o)];n instanceof HTMLElement&&n.matches(o)&&s.unshift(n);for(let t of s){let n=t.getBoundingClientRect();if(!n.width||!n.height||Math.abs(n[a]-i[a])>1)continue;let r=getComputedStyle(t).borderRadius;e.push({left:n.left,top:n.top,width:n.width,height:n.height,borderRadius:r,maskImage:`linear-gradient(to ${a}, transparent calc(100% - 2 * ${parseFloat(r)||0}px), black)`})}}),r(e)},s=()=>{cancelAnimationFrame(a),a=requestAnimationFrame(o)},c=new ResizeObserver(s);i.forEach(e=>{e&&(c.observe(e),e.querySelectorAll(`.workspace-surface.island-outline`).forEach(e=>c.observe(e)))});let l=new MutationObserver(s);l.observe(n,{attributes:!0,attributeFilter:[`data-separator`]});for(let e of[`pointerenter`,`pointerleave`,`focus`,`blur`])n.addEventListener(e,s);return window.addEventListener(`resize`,s),window.addEventListener(`scroll`,s,!0),()=>{cancelAnimationFrame(a),c.disconnect(),l.disconnect();for(let e of[`pointerenter`,`pointerleave`,`focus`,`blur`])n.removeEventListener(e,s);window.removeEventListener(`resize`,s),window.removeEventListener(`scroll`,s,!0)}},[t,e]),(0,ki.createPortal)(n.map((e,t)=>(0,X.jsx)(`div`,{"aria-hidden":!0,className:`island-resize-edge`,style:e},t)),document.body)}function ko({className:e}){let t=(0,Z.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Do,{elementRef:t,className:e}),(0,X.jsx)(Oo,{separatorRef:t,vertical:e===`workspace-divider-vertical`})]})}function Ao(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function jo(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function Mo(e){let t=e.split(`/`).filter(e=>e!==``);t.pop();let n=[];for(let e of t)n.push(Po(n[n.length-1]??``,e));return n}function No(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n<=0?`/`:t.slice(0,n)}function Po(e,t){return e===``?t:`${e}/${t}`}function Fo(e,t){return t===``?e:`${e.replace(/\/+$/,``)}/${t}`}function Io(e,t){let n=e=>{let t=e.replaceAll(`\\`,`/`).replace(/\/+$/,``);return t===``?`/`:t},r=n(e),i=n(t),a=/^[A-Za-z]:($|\/)/.test(r),o=a?r.toLocaleLowerCase(`en-US`):r,s=a?i.toLocaleLowerCase(`en-US`):i;if(s===o)return``;let c=o===`/`?`/`:`${o}/`;return s.startsWith(c)?i.slice(c.length):null}function Lo(e){let t=new Set(e);return e.filter(e=>{if(e===``)return!0;for(let n=jo(e);;n=jo(n)){if(t.has(n))return!1;if(n===``)return!0}})}var Ro=`application/x-puddle-paths`;function zo(e){return JSON.stringify(e)}function Bo(e){try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Vo(e,t){let n=[],r=(i,a)=>{let o=e(i);if(o)for(let e of o.entries){let o=Po(i,e.name);n.push({path:o,name:e.name,type:e.type,depth:a,parentDir:i}),e.type===`dir`&&t.has(o)&&r(o,a+1)}};return r(``,0),n}function Ho(e,t,n){let r=e.findIndex(e=>e.path===t),i=e.findIndex(e=>e.path===n);if(r===-1||i===-1)return n?[n]:[];let[a,o]=r<=i?[r,i]:[i,r];return e.slice(a,o+1).map(e=>e.path)}function Uo(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():null}function Wo(e,t){let n=Uo(e);return n!==null&&t.has(n)}function Go(e,t,n){return`${e}\0${n??``}\0${t}`}function Ko(e,t){let n=qo(t);Je(n.source?Go(n.source.session,n.source.path,n.source.root):e,n.diagnostics??[]);let r=Jo(n);return V.error(n.message,{id:`err:${n.message}`,duration:2e4,...r?{description:(0,X.jsx)(tr,{summary:(n.diagnostics?.length?`${n.diagnostics.length} source diagnostic${n.diagnostics.length===1?``:`s`} · `:``)+`Show compiler output`,children:(0,X.jsx)(`pre`,{className:`mt-2 max-h-52 overflow-auto whitespace-pre-wrap break-words font-mono text-2xs leading-snug text-fg-secondary`,children:r})})}:{}}),n}function qo(e){let t=le.safeParse(e);if(t.success)return t.data;if(e instanceof Pe){let t=F.safeParse(e.details);return t.success?{message:e.message,...t.data}:{message:e.message}}return{message:e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Compilation failed`}}function Jo(e){return e.output?.trim()?e.output.trim():(e.diagnostics??[]).map(e=>`${e.source.path}:${e.line}${e.column?`:${e.column}`:``}: ${e.message}`).join(`
|
|
3
|
+
`)}function Yo({target:e,sourceKey:t,leafId:n,onResult:r,onError:i,onRunningChange:a}){let[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(-1),l=(0,Z.useRef)(-1),u=(0,Z.useMemo)(()=>({source:{session:e.source.session,path:e.source.path,...e.source.root===void 0?{}:{root:e.source.root}},...e.provider===void 0?{}:{provider:e.provider},...e.profile_id===void 0?{}:{profile_id:e.profile_id},...e.project_id===void 0?{}:{project_id:e.project_id}}),[e.provider,e.profile_id,e.project_id,e.source.session,e.source.path,e.source.root]);(0,Z.useEffect)(()=>{let e=!1;return s(!1),a(t,!0),Jr({...u,mode:`eager`}).then(i=>{e||(a(t,i.state===`running`),s(!0),i.result&&i.result.revision>c.current&&(c.current=i.result.revision,r(t,n,i.result)))}).catch(n=>{e||(a(t,!1),s(!0),i(t,qo(n)))}),()=>{e=!0,a(t,!1),Jr({...u,mode:`on_demand`}).catch(()=>void 0)}},[u,t,n,r,i,a]);let d=Gr(u,o).data;return(0,Z.useEffect)(()=>{d&&(a(t,d.state===`running`),d.result&&d.result.revision>c.current&&(c.current=d.result.revision,r(t,n,d.result)),d.state===`failed`&&d.error&&d.revision>l.current&&(l.current=d.revision,i(t,d.error)))},[d,t,n,r,i,a]),null}function Xo({request:e,onOpenChange:t}){let n=Yr(e),r=f();return(0,X.jsx)(Gt,{open:e!==null,onOpenChange:t,children:(0,X.jsxs)(Ut,{className:`max-w-xl`,children:[(0,X.jsxs)(Ht,{children:[(0,X.jsxs)(Wt,{children:[n.data?.display_name??`Compilation`,` settings`]}),(0,X.jsxs)(Vt,{children:[e?Ao(e.source.path):`This file`,` · overrides the language defaults for this file in this project.`]})]}),n.isLoading?(0,X.jsx)(`p`,{className:`py-4 text-sm text-fg-muted`,children:`Loading commands…`}):n.isError?(0,X.jsx)(`p`,{role:`alert`,className:`py-4 text-sm text-danger`,children:n.error instanceof Error?n.error.message:`Couldn’t load commands`}):n.data&&e?(0,X.jsx)(Xr,{settings:n.data,onCancel:()=>t(!1),onSave:async n=>{for(let t of n){let n=await Kr({...e,...t});r.setQueryData([`compilation-settings`,e],n)}t(!1)}},JSON.stringify(e)):null]})})}function Zo(e){if(e===null)return!1;if(kr(e)===`untitled`){let t=rt(e.path);return t===void 0?!1:(Et({name:e.path,content:t}),!0)}return ft(dt(e.session,e.path,e.root))}function Qo({request:e,targetSession:t,targetRoot:n,targetLabel:r,profileId:i,onClose:a,onSaved:o}){let[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{e&&(c(e.name),u(null))},[e]);let p=async()=>{if(!e||!t)return;let a=s.trim().replace(/^\/+/,``).replace(/\/+$/,``);if(a===``){u(`Give the file a path.`);return}f(!0),u(null);try{let s=!0;try{await Ne(`GET`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(a)}${Ve(n)}`)}catch(e){if(e instanceof Pe&&e.status===404)s=!1;else if(e instanceof Pe&&e.status===413)s=!0;else throw e}if(s){u(`${a} already exists in ${r}.`);return}await Ne(`PUT`,`/api/worktrees/${t.id}/file?path=${encodeURIComponent(a)}${Ve(n)}`,{content:e.content}),i!==void 0&&await Ze(i,e.name).catch(()=>void 0),st(e.name),o(e.name,t.id,a,n)}catch(e){u(e instanceof Error?e.message:`Save failed`)}finally{f(!1)}};return(0,X.jsx)(Gt,{open:e!==null,onOpenChange:e=>!e&&a(),children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(Ht,{children:[(0,X.jsx)(Wt,{children:`Save draft into the worktree`}),(0,X.jsx)(Vt,{children:t?(0,X.jsxs)(X.Fragment,{children:[`Saves into `,(0,X.jsx)(`span`,{className:`text-fg-secondary`,children:r}),` — what the sidebar is bound to.`]}):`No worktree is bound — open or focus a session first.`})]}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(ve,{htmlFor:`untitled-path`,children:`Worktree-relative path`}),(0,X.jsx)(qt,{id:`untitled-path`,placeholder:`docs/notes.md`,value:s,onChange:e=>c(e.target.value),autoFocus:!0})]}),l&&(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:l}),(0,X.jsxs)(Bt,{children:[(0,X.jsx)(J,{type:`button`,variant:`ghost`,onClick:a,children:`Cancel`}),(0,X.jsx)(J,{type:`submit`,disabled:d||!t,children:`Save`})]})]})]})})}function $o(e,t){return t??e.root??e.session?.worktree_path??null}function es(e,t){return{...e,unpin(){t(),e.unpin()}}}function ts(e){return{id:ue,project_id:e.projectId,account_id:null,worktree_path:e.path,base_branch:e.defaultBranch,branch:e.defaultBranch,separate_branch:!1,kind:`terminal`,agent_type:null,agent_session_ref:null,title:e.name,status:`exited`,skip_permissions:!1,created_at:`1970-01-01T00:00:00.000Z`,updated_at:`1970-01-01T00:00:00.000Z`,last_activity_at:null}}function ns(e,t,n,r=null){let i=n.snapshot.explorer_pin,a=i===null?null:e.find(e=>e.id===i&&e.status!==`archived`)??null,o=a??e.find(e=>e.id===t)??null,s=o===null&&r!==null;return{session:s?ts(r):o,root:s?r.path:void 0,isProjectDirectory:s,pinned:a!==null,pin(e){n.update({explorer_pin:e})},unpin(){n.update({explorer_pin:null})}}}function rs(e,t,n){let r=Fo(e.root??t,e.path);if(n!==null){let e=Io(n,r);if(e!==null)return{directory:n,path:e}}if(e.root===void 0)return{directory:t,path:e.path};let i=Fo(e.root,jo(e.path));return{directory:i,path:Ao(e.path),browseRoot:i}}var is=null,as=null;async function os(){let[e,t]=await Promise.all([Ae(()=>import(`./PaneEditorBody-DD8UshBi.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52])),Ae(()=>import(`./ModelRefcount-CHKuXiJY.js`),__vite__mapDeps([53,1,2,42,9,10,11,4,8,5,12,16,17,43,44,45]))]);is=e.PaneEditorBody,as=t.ModelRefcount}var ss=(0,Z.lazy)(()=>Ae(()=>import(`./PaneEditorBody-DD8UshBi.js`).then(e=>({default:e.PaneEditorBody})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52])));function cs(e){return is?(0,X.jsx)(is,{...e}):(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-xs text-fg-muted`,children:`Loading editor…`}),children:(0,X.jsx)(ss,{...e})})}var ls=(0,Z.lazy)(()=>Ae(()=>import(`./ModelRefcount-CHKuXiJY.js`).then(e=>({default:e.ModelRefcount})),__vite__mapDeps([53,1,2,42,9,10,11,4,8,5,12,16,17,43,44,45])));function us({buffers:e}){return as?(0,X.jsx)(as,{buffers:e}):(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(ls,{buffers:e})})}var ds=(0,Z.lazy)(()=>Ae(()=>import(`./EditorTabClose-QgdaqA1X.js`).then(e=>({default:e.EditorDirtyDot})),__vite__mapDeps([54,1,2,5,21,11,22,23,24,55,42,9,10,4,8,12,16,17,43,44,45,50,41,51])));function fs(e){return(0,X.jsx)(Z.Suspense,{fallback:null,children:(0,X.jsx)(ds,{...e})})}var ps=(0,Z.lazy)(()=>Ae(()=>import(`./EditorTabClose-QgdaqA1X.js`).then(e=>({default:e.EditorTabClose})),__vite__mapDeps([54,1,2,5,21,11,22,23,24,55,42,9,10,4,8,12,16,17,43,44,45,50,41,51])));function ms(e){return(0,X.jsx)(Z.Suspense,{fallback:(0,X.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e.onClose()},className:`hidden size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg group-hover:flex pointer-coarse:flex`,"aria-label":`Close ${e.label}`,children:`×`}),children:(0,X.jsx)(ps,{...e})})}var hs=(0,Z.createContext)(null);function gs({tree:e,parked:t=[],onOpenFile:n,children:r}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(new Map).current,[o,s]=(0,Z.useState)(()=>new Set),c=(0,Z.useCallback)((e,t)=>{s(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),l=[...t].sort().join(`,`),u=(0,Z.useMemo)(()=>{let t=new Set;for(let n of Ln(e))for(let e of n.tabs)e.type===`terminal`&&t.add(e.session);for(let e of l===``?[]:l.split(`,`))t.add(e);return[...t].sort()},[e,l]),d=e=>{let t=`term:${e}`,n=a.get(t);return n||(n=document.createElement(`div`),n.className=`size-full`,a.set(t,n)),n};(0,Z.useEffect)(()=>{let e=new Set(u.map(e=>`term:${e}`));for(let e of u){let t=a.get(`term:${e}`);t&&!t.parentElement&&i.current?.appendChild(t)}for(let[t,n]of[...a])e.has(t)||(n.remove(),a.delete(t))},[u,a]);let f=(0,Z.useMemo)(()=>({parkingRef:i,containers:a,setAdopted:c}),[a,c]);return(0,X.jsxs)(hs.Provider,{value:f,children:[(0,X.jsx)(`div`,{ref:i,className:`hidden`,"aria-hidden":!0}),u.map(e=>(0,ki.createPortal)((0,X.jsx)(we,{stream:e,paused:!o.has(`term:${e}`),onOpenFile:t=>n(e,t)}),d(e),e)),r]})}function _s(e){let t=(0,Z.useContext)(hs),n=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{let r=n.current;if(!t||!e||!r)return;let i=t.containers.get(e);return i&&(r.appendChild(i),t.setAdopted(e,!0)),()=>{let n=t.parkingRef.current;i&&n&&i.parentElement===r&&n.appendChild(i),i&&t.setAdopted(e,!1)}},[t,e]),n}function vs({session:e,term:t,ready:n,insertTarget:r}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(null),[o,s]=(0,Z.useState)(null),c=o!==null;(0,Z.useEffect)(()=>()=>a.current?.abort(),[e,t,n]);let l=o?.stage===`uploading`?Math.floor(o.received/o.total*100):void 0,u=o?.stage===`uploading`?`${l}%`:o?.stage===`saving`?`Saving…`:o?.stage===`inserting`?`Inserting…`:`Preparing…`,d=async i=>{if(!n||a.current)return;let o=new AbortController;a.current=o;let c=r?.();s({stage:`preparing`});try{let{resized:n}=await yr(i,e,t,{signal:o.signal,onProgress:s,insert:c});n&&V(`Image resized for remote access`)}catch(e){o.signal.aborted||V.error(e instanceof Error?e.message:`Could not insert the image.`)}finally{a.current=null,s(null)}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{ref:i,className:`hidden`,type:`file`,accept:vr,"aria-label":`Choose image`,disabled:!n||c,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&d(t)}}),(0,X.jsx)(J,{variant:`ghost`,"aria-label":c?`Cancel image upload`:`Insert image`,title:c?`Cancel image upload`:`Insert image`,"aria-busy":c,disabled:!n||o?.stage===`inserting`,onClick:()=>c?a.current?.abort():i.current?.click(),children:c?(0,X.jsxs)(X.Fragment,{children:[o.stage===`inserting`?(0,X.jsx)(mi,{className:`animate-spin`}):(0,X.jsx)(Kt,{}),(0,X.jsx)(`span`,{role:`progressbar`,"aria-label":`Image upload`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":l,"aria-valuetext":u,className:`text-xs`,children:u})]}):(0,X.jsx)(li,{})})]})}function ys({activate:e,...t}){let n=(0,Z.useRef)(null),r=(0,Z.useRef)(-1/0);return(0,X.jsx)(J,{...t,"data-terminal-key":``,onPointerDown:e=>{e.preventDefault(),e.pointerType!==`touch`&&(r.current=-1/0)},onTouchStart:e=>{let t=e.touches[0];n.current=t&&e.touches.length===1?{x:t.clientX,y:t.clientY,moved:!1}:null},onTouchMove:e=>{let t=e.touches[0];n.current&&(!t||e.touches.length!==1||Math.hypot(t.clientX-n.current.x,t.clientY-n.current.y)>8)&&(n.current.moved=!0)},onTouchCancel:()=>{n.current=null},onTouchEnd:i=>{let a=n.current;n.current=null,!(!a||a.moved||t.disabled)&&(i.preventDefault(),r.current=performance.now(),e())},onClick:t=>{t.detail!==0&&performance.now()-r.current<700||e()}})}function bs(e){return t=>{t.target.closest(`button:not([data-terminal-key])`)||(t.cancelable&&t.preventDefault(),e())}}function xs({session:e,term:t,connected:n,composing:r,toggleComposer:i,insertTarget:a}){let o=gr(e,t)&&n,s=br(e,t),[c,l]=(0,Z.useState)(``),u=n=>{Cr(e,t),xr(e,t,n).catch(e=>l(e.message))};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`phone-keys`,role:`toolbar`,"aria-label":`Terminal keys`,onTouchEnd:bs(()=>Cr(e,t)),children:[(0,X.jsx)(vs,{session:e,term:t,ready:o,insertTarget:a}),(0,X.jsx)(ys,{variant:`ghost`,disabled:!o,activate:()=>u(`\x1B`),children:`Esc`}),[[`Control`,`⌃`,Er.ctrl],[`Option`,`⌥`,Er.alt],[`Shift`,`⇧`,Er.shift]].map(([n,r,i])=>(0,X.jsx)(ys,{variant:`ghost`,disabled:!o,"aria-label":n,title:n,"aria-pressed":(s&i)!==0,activate:()=>{wr(e,t,i),Cr(e,t)},children:(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`text-base leading-none`,children:r})},i)),[{label:`Left`,icon:Qr,data:`\x1B[D`},{label:`Down`,icon:St,data:`\x1B[B`},{label:`Up`,icon:gt,data:`\x1B[A`},{label:`Right`,icon:ei,data:`\x1B[C`}].map(({label:e,icon:t,data:n})=>(0,X.jsx)(ys,{variant:`ghost`,"aria-label":e,disabled:!o,activate:()=>u(n),children:(0,X.jsx)(t,{})},e)),(0,X.jsx)(ys,{variant:`ghost`,disabled:!o,activate:()=>u(` `),children:`Tab`}),(0,X.jsx)(ys,{variant:`ghost`,disabled:!o,activate:()=>u(`\r`),children:`Enter`}),(0,X.jsx)(ys,{variant:`ghost`,disabled:!o,activate:()=>u(``),children:`Ctrl-C`}),(0,X.jsx)(J,{variant:`ghost`,"aria-label":`Compose prompt`,"aria-pressed":r,onClick:i,children:(0,X.jsx)(Ti,{})})]}),c&&(0,X.jsx)(`p`,{role:`alert`,className:`px-2 text-xs text-danger`,children:c})]})}function Ss({session:e,term:t,connected:n,compact:r=!1}){let i=gr(e,t)&&n,a=L(`puddle.phone.draft:${e}:${t}`),[o,s]=(0,Z.useState)(()=>{try{return sessionStorage.getItem(a)??``}catch{return``}}),c=(0,Z.useRef)(o),l=(0,Z.useRef)(null),u=(0,Z.useRef)(`terminal`);(0,Z.useEffect)(()=>{let e=e=>{e.target.classList?.contains(`xterm-helper-textarea`)&&(u.current=`terminal`)};return document.addEventListener(`focusin`,e),()=>document.removeEventListener(`focusin`,e)},[]);let[d,f]=(0,Z.useState)(!r||!!o),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(``),_=e=>{c.current=e,s(e);try{e?sessionStorage.setItem(a,e):sessionStorage.removeItem(a)}catch{}},v=e=>{let t=c.current,n=t.slice(0,l.current?.selectionStart??t.length),r=t.slice(l.current?.selectionEnd??t.length);/\S$/.test(n)&&(n+=` `),/^\s/.test(r)&&(e=e.trimEnd()),_(n+e+r);let i=n.length+e.length;requestAnimationFrame(()=>l.current?.setSelectionRange(i,i))},y=async(n,r=!1)=>{if(!(!i||p)){m(!0),g(``);try{await xr(e,t,n,r),r&&_(``)}catch(e){g(e instanceof Error?e.message:`Delivery is uncertain. Check the terminal before resending.`)}finally{m(!1)}}};return(0,X.jsxs)(`div`,{className:`phone-composer`,children:[(0,X.jsx)(xs,{session:e,term:t,connected:n,composing:d,toggleComposer:()=>f(!d),insertTarget:()=>d&&u.current===`prompt`?v:void 0}),d&&(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),o&&y(o,!0)},children:[(0,X.jsx)(Yt,{ref:l,onFocus:()=>u.current=`prompt`,className:`text-base`,"aria-label":`Prompt`,rows:2,value:o,onChange:e=>_(e.target.value),placeholder:`Write a prompt…`,autoCapitalize:`sentences`,autoCorrect:`on`,spellCheck:!0}),(0,X.jsx)(J,{type:`submit`,disabled:!i||p||!o,children:p?`Sending…`:`Send`})]}),h&&(0,X.jsx)(`p`,{role:`alert`,children:h})]})}var Cs=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends Cs{};function ws(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Ts(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function Es(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function Ds(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function Os(e,t){return Es(e,t,``)}function ks(e,t){return Ds(e,t,``)}function As(e,t){return t.slice(0,js(e,t))}function js(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Ms(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function Ns(e,t){if(t)return Fs(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function Ps(e,t){if(t)return Fs(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function Fs(e,t){if(!t)return[Ps(e),Ns(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=Ms(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var Is=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,Ls=RegExp(`[${Is}]+|\\s+|[^${Is}]`,`ug`);new class extends Cs{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Ms(e,r)}else n=e.match(Ls)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&Rs(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&Rs(n,i,r,null,t.intlSegmenter),e}};function Rs(e,t,n,r,i){if(t&&n){let[a,o]=Fs(t.value,i),[s,c]=Fs(n.value,i);if(e){let r=ws(a,s);e.value=Ds(e.value,s,r),t.value=Os(t.value,r),n.value=Os(n.value,r)}if(r){let e=Ts(o,c);r.value=Es(r.value,c,e),t.value=ks(t.value,e),n.value=ks(n.value,e)}}else if(n){if(e){let e=Ps(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=Ps(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=Ps(r.value,i),[a,o]=Fs(t.value,i),s=ws(n,a);t.value=Os(t.value,s);let c=Ts(Os(n,s),o);t.value=ks(t.value,c),r.value=Es(r.value,n,c),e.value=Ds(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=Ps(r.value,i),n=As(Ns(t.value,i),e);t.value=ks(t.value,n)}else if(e){let n=As(Ns(e.value,i),Ps(t.value,i));t.value=Os(t.value,n)}}var zs=new class extends Cs{tokenize(e){let t=RegExp(`(\\r?\\n)|[${Is}]+|[^\\S\\n\\r]+|[^${Is}]`,`ug`);return e.match(t)||[]}};function Bs(e,t,n){return zs.diff(e,t,n)}var Vs=new class extends Cs{constructor(){super(...arguments),this.tokenize=Us}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
4
|
+
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
5
|
+
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
6
|
+
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
7
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function Hs(e,t,n){return Vs.diff(e,t,n)}function Us(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
8
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function Ws(e){return e==`.`||e==`!`||e==`?`}new class extends Cs{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(Ws(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends Cs{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends Cs{constructor(){super(...arguments),this.tokenize=Us}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(Gs(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function Gs(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Gs(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=Gs(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends Cs{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};function Ks(e,t,n,r,i,a,o){let s;s=o?typeof o==`function`?{callback:o}:o:{},s.context===void 0&&(s.context=4);let c=s.context;if(s.newlineIsToken)throw Error(`newlineIsToken may not be used with patch-generation functions, only with diffing functions`);if(s.callback){let{callback:e}=s;Hs(n,r,Object.assign(Object.assign({},s),{callback:t=>{let n=l(t);e(n)}}))}else return l(Hs(n,r,s));function l(n){if(!n)return;n.push({value:``,lines:[]});function r(e){return e.map(function(e){return` `+e})}let o=[],s=0,l=0,u=[],d=1,f=1;for(let e=0;e<n.length;e++){let t=n[e],i=t.lines||qs(t.value);if(t.lines=i,t.added||t.removed){if(!s){let t=n[e-1];s=d,l=f,t&&(u=c>0?r(t.lines.slice(-c)):[],s-=u.length,l-=u.length)}for(let e of i)u.push((t.added?`+`:`-`)+e);t.added?f+=i.length:d+=i.length}else{if(s)if(i.length<=c*2&&e<n.length-2)for(let e of r(i))u.push(e);else{let e=Math.min(i.length,c);for(let t of r(i.slice(0,e)))u.push(t);let t={oldStart:s,oldLines:d-s+e,newStart:l,newLines:f-l+e,lines:u};o.push(t),s=0,l=0,u=[]}d+=i.length,f+=i.length}}for(let e of o)for(let t=0;t<e.lines.length;t++)e.lines[t].endsWith(`
|
|
9
|
+
`)?e.lines[t]=e.lines[t].slice(0,-1):(e.lines.splice(t+1,0,`\`),t++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:a,hunks:o}}}function qs(e){let t=e.endsWith(`
|
|
10
|
+
`),n=e.split(`
|
|
11
|
+
`).map(e=>e+`
|
|
12
|
+
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}function Js(e,t){let n=Ks(``,``,e,t,``,``,{context:3,timeout:100});if(!n||n.hunks.reduce((e,t)=>e+t.lines.length,0)>5e3)return null;let r=performance.now()+30,i=0,a=0;return{hunks:n.hunks.map(e=>{let t=e.oldStart,n=e.newStart,o=[],s=[],c=[],l=[],u=()=>{for(let e=0;e<Math.min(c.length,l.length);e++){let t=c[e],n=l[e],i=t.spans[0].text,a=n.spans[0].text;if(i.length+a.length>4e3||performance.now()>=r)continue;let o=Bs(i,a,{timeout:5});o&&(t.spans=o.filter(e=>!e.added).map(e=>({text:e.value,changed:e.removed})),n.spans=o.filter(e=>!e.removed).map(e=>({text:e.value,changed:e.added})))}c=[],l=[]};for(let r of e.lines){let e=r[0];if(e===`\\`)continue;e===` `&&u();let d=(e,t)=>({number:e,changed:t,spans:[{text:r.slice(1),changed:t}]});if(e!==`+`){let n=d(t++,e===`-`);o.push(n),n.changed&&(c.push(n),a++)}if(e!==`-`){let t=d(n++,e===`+`);s.push(t),t.changed&&(l.push(t),i++)}}return u(),{before:o,after:s}}),additions:i,deletions:a}}function Ys({before:e,after:t}){let n=(0,Z.useMemo)(()=>Js(e,t),[e,t]);return n?n.hunks.length?(0,X.jsxs)(`div`,{className:`phone-diff`,"aria-label":`File diff`,children:[(0,X.jsxs)(`p`,{className:`mb-3 flex gap-3 text-xs`,children:[(0,X.jsxs)(`span`,{className:`text-success`,children:[`+`,n.additions,` added`]}),(0,X.jsxs)(`span`,{className:`text-danger`,children:[`−`,n.deletions,` removed`]})]}),n.hunks.map((e,t)=>(0,X.jsxs)(`section`,{className:`phone-diff-hunk`,"aria-label":`Change ${t+1}`,children:[(0,X.jsx)(Xs,{label:`Before`,lines:e.before}),(0,X.jsx)(Xs,{label:`After`,lines:e.after})]},t)),e.length>0&&!e.endsWith(`
|
|
13
|
+
`)&&(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Before: no newline at end of file.`}),t.length>0&&!t.endsWith(`
|
|
14
|
+
`)&&(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`After: no newline at end of file.`})]}):(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No text changes.`}):(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Diff is too large. Use Before and After to review the text.`})}function Xs({label:e,lines:t}){let n=e===`Before`?`removed`:`added`;return(0,X.jsxs)(`div`,{className:`phone-diff-pane`,"aria-label":e,children:[(0,X.jsxs)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:[e,t.length>0&&` · ${t[0].number}–${t.at(-1).number}`]}),t.length===0?(0,X.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:`No lines`}):(0,X.jsx)(`div`,{className:`phone-diff-code`,tabIndex:0,children:t.map(t=>(0,X.jsxs)(`div`,{className:`phone-diff-line`,"data-change":t.changed?n:void 0,children:[(0,X.jsx)(`span`,{className:`phone-diff-number`,"aria-hidden":`true`,children:t.number}),(0,X.jsx)(`span`,{className:`phone-diff-sign`,"aria-hidden":`true`,children:t.changed?e===`Before`?`−`:`+`:` `}),(0,X.jsxs)(`code`,{children:[t.spans.map((e,t)=>e.changed?(0,X.jsx)(`mark`,{children:e.text},t):e.text),`
|
|
15
|
+
`]})]},t.number))})]})}function Zs(e,t){let n=e.parentElement,r,i=null,a=0,o=null,s=0,c=e.firstChild;if(!c||c.nodeType!==Node.TEXT_NODE)return()=>{};let l=(e,t)=>{let r=n.getBoundingClientRect(),i=Math.max(r.left+1,Math.min(r.right-1,e)),a=Math.max(r.top+1,Math.min(r.bottom-1,t)),o=document.caretPositionFromPoint?.(i,a);if(o?.offsetNode===c)return o.offset;let s=document.caretRangeFromPoint?.(i,a);return s?.startContainer===c?s.startOffset:null},u=(e,n)=>{let r=document.createRange();r.setStart(c,e),r.setEnd(c,n);let i=window.getSelection();i?.removeAllRanges(),i?.addRange(r),t(i?.toString()??``)},d=()=>{if(!i?.anchor||!o)return;let e=l(o.x,o.y);e!==null&&u(Math.min(i.anchor.start,e),Math.max(i.anchor.end,e))},f=t=>{if(a=0,!o)return;let r=n.getBoundingClientRect(),i=o.y<r.top?-1:+(o.y>=r.bottom),c=o.x<r.left?-1:+(o.x>=r.right);if((i||c)&&t-s>=50){s=t;let r=parseFloat(getComputedStyle(e).lineHeight);n.scrollBy(c*r,i*r),d()}a=requestAnimationFrame(f)},p=()=>{clearTimeout(r),cancelAnimationFrame(a),a=0,o=null,i=null},m=e=>{if(p(),e.touches.length!==1)return;let t=e.touches[0];i={id:t.identifier,x:t.clientX,y:t.clientY},r=setTimeout(()=>{if(!i)return;let e=l(i.x,i.y);if(e===null)return;let t=c.textContent??``,n=e,r=e;for(;n>0&&/\S/u.test(t[n-1]);)n--;for(;r<t.length&&/\S/u.test(t[r]);)r++;i.anchor={start:n,end:r},u(n,r)},450)},h=e=>{if(!i)return;let t=e.touches[0];if(e.touches.length!==1||t?.identifier!==i.id){p();return}i.anchor?(e.preventDefault(),o={x:t.clientX,y:t.clientY},d(),a||=requestAnimationFrame(f)):Math.hypot(t.clientX-i.x,t.clientY-i.y)>=8&&p()},g=e=>{i?.anchor&&e.preventDefault(),p()},_=e=>{i&&e.preventDefault()},v=()=>{let e=window.getSelection();t(e?.anchorNode===c&&e.focusNode===c?e.toString():``)};return e.addEventListener(`touchstart`,m,{passive:!0}),e.addEventListener(`touchmove`,h,{passive:!1}),e.addEventListener(`touchend`,g,{passive:!1}),e.addEventListener(`touchcancel`,p),e.addEventListener(`contextmenu`,_),document.addEventListener(`selectionchange`,v),()=>{p(),e.removeEventListener(`touchstart`,m),e.removeEventListener(`touchmove`,h),e.removeEventListener(`touchend`,g),e.removeEventListener(`touchcancel`,p),e.removeEventListener(`contextmenu`,_),document.removeEventListener(`selectionchange`,v)}}function Qs({content:e,target:t}){let n=(0,Z.useRef)(null),r=(0,Z.useRef)(null),i=zr(`phone-source`,t),[a,o]=(0,Z.useState)(``);return(0,Z.useLayoutEffect)(()=>{if(!(!r.current||!n.current))return Ur(r.current,n.current,i).dispose},[i,e]),(0,Z.useEffect)(()=>{let e=n.current;if(e)return o(``),Zs(e,o)},[e]),(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,X.jsx)(`div`,{ref:r,className:`h-full overflow-auto overscroll-contain`,children:(0,X.jsx)(`pre`,{ref:n,className:`phone-file-source`,tabIndex:0,children:e})}),a&&(0,X.jsx)(Tr,{label:`Selected file text`,text:a,clear:()=>{window.getSelection()?.removeAllRanges(),o(``)}})]})}function $s({session:e}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(`diff`),a=u({queryKey:[`phone-diff`,e],queryFn:async()=>ce.parse(await Ne(`GET`,`/api/worktrees/${e}/diff?against=base`))}),o=a.data?.entries.find(e=>e.path===t),s=u({queryKey:[`phone-before`,e,t,o?.old_path,a.data?.against],queryFn:async()=>o?.status===`added`?{content:``,binary:!1}:se.parse(await Ne(`GET`,`/api/worktrees/${e}/file-at?ref=${encodeURIComponent(a.data.against)}&path=${encodeURIComponent(o?.old_path??t)}`)),enabled:t!==null&&!!a.data}),c=u({queryKey:[`phone-after`,e,t,o?.status],queryFn:async()=>o?.status===`deleted`?{content:``,binary:!1}:de.parse(await Ne(`GET`,`/api/worktrees/${e}/file?path=${encodeURIComponent(t)}`)),enabled:t!==null&&!!a.data}),l=a.error??(t?s.error??c.error:null),d=r===`diff`?s.data?.binary||c.data?.binary:r===`before`?s.data?.binary:c.data?.binary;return(0,X.jsxs)(`section`,{className:`phone-review`,"aria-label":`Changes`,children:[t===null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`mb-2 text-sm text-fg-muted`,children:[`Changes against `,a.data?.base_ref??`base`]}),a.isPending&&(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading changes…`}),a.data?.entries.map(e=>(0,X.jsxs)(J,{variant:`ghost`,className:`phone-file`,onClick:()=>{n(e.path),i(`diff`)},children:[e.path,` · `,e.status]},e.path)),a.data?.entries.length===0&&(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No changes.`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mb-2 flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(J,{variant:`ghost`,size:`icon`,"aria-label":`Back to changes`,onClick:()=>n(null),children:(0,X.jsx)(Qr,{})}),(0,X.jsxs)(`span`,{className:`min-w-0 break-all font-mono text-xs`,children:[t,` · read only`]})]}),(0,X.jsx)(`nav`,{"aria-label":`Diff view`,children:[`diff`,`before`,`after`].map(e=>(0,X.jsx)(J,{variant:`ghost`,size:`sm`,"aria-pressed":r===e,onClick:()=>i(e),children:e===`diff`?`Diff`:e===`before`?`Before`:`After`},e))}),d?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Binary file; preview unavailable.`}):r===`diff`?s.data&&c.data?(0,X.jsx)(Ys,{before:s.data.content??``,after:c.data.content??``}):!l&&(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading diff…`}):(r===`before`?s.data:c.data)?(0,X.jsx)(Qs,{target:[e,t,a.data?.against,r],content:(r===`before`?s.data?.content:c.data?.content)??``}):!l&&(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading file…`})]}),l&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:l.message})]})}function ec({sessions:e,selected:t,select:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(Lr.isConnected()),s=_s(t&&!r?`term:${t}`:null);return(0,Z.useEffect)(()=>Lr.onConnectionChange(o),[]),(0,X.jsxs)(`div`,{className:`phone-workspace`,children:[(0,X.jsxs)(`nav`,{className:`phone-selectors`,children:[(0,X.jsxs)(`select`,{className:Jt,"aria-label":`Session`,value:t??``,onChange:e=>n(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Choose session`}),e.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.title??e.agent_title??e.osc_title??e.id.slice(0,8),` `,`· `,e.status]},e.id))]}),(0,X.jsx)(J,{variant:`secondary`,"aria-pressed":r,onClick:()=>i(!r),children:r?`Terminal`:`Review`})]}),!a&&(0,X.jsx)(`p`,{role:`status`,children:`Reconnecting… Your draft will stay here.`}),(0,X.jsx)(`div`,{className:`phone-view`,children:r&&t?(0,X.jsx)($s,{session:t},t):(0,X.jsx)(`div`,{ref:s,className:`size-full`})}),t&&!r&&(0,X.jsx)(Ss,{session:t,term:`agent`,connected:a},t)]})}var tc=null,nc=new Set;function rc(e){tc=e,nc.forEach(t=>t(e))}function ic(e){return nc.add(e),tc&&e(tc),()=>nc.delete(e)}function ac(){tc=null}var oc=20,sc=new Map;function cc(e,t){let n=sc.get(e)??[];n.push(t),n.length>oc&&n.shift(),sc.set(e,n)}function lc(e,t){let n=sc.get(e);for(;n&&n.length>0;){let e=n.pop();if(t(e.ref))return e}}function uc(e){let[t,n]=(0,Z.useState)(()=>window.matchMedia(e).matches);return(0,Z.useEffect)(()=>{let t=window.matchMedia(e),r=e=>n(e.matches);return n(t.matches),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var dc=`(max-width: 767px)`;function fc(e,t){let n={};for(let r of t){let t=e[r];if(typeof t!=`number`)return;n[r]=t}return n}var pc=`puddle.pane-height.`;function mc(e){try{let t=localStorage.getItem(`${pc}${e}`);if(t===null)return null;let n=Number(t);return Number.isFinite(n)&&n>0?n:null}catch{return null}}function hc(e,t,{sized:n,min:r=64}){let[i,a]=(0,Z.useState)(()=>mc(e)??t),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(i);return c.current=i,{height:i,handle:{dragging:o,height:i,min:r,onPointerDown:(0,Z.useCallback)(t=>{if(t.button!==0)return;t.preventDefault();let i=t.currentTarget,o=t.clientY,l=c.current,u=i.parentElement?.getBoundingClientRect().height??window.innerHeight,d=Math.max(r,u-96);i.setPointerCapture(t.pointerId),s(!0);let f=e=>{let t=e.clientY-o,i=n===`below`?l-t:l+t;c.current=Math.round(Math.min(d,Math.max(r,i))),a(c.current)},p=()=>{i.removeEventListener(`pointermove`,f),i.removeEventListener(`pointerup`,p),i.removeEventListener(`pointercancel`,p),s(!1);try{localStorage.setItem(`${pc}${e}`,String(c.current))}catch{}};i.addEventListener(`pointermove`,f),i.addEventListener(`pointerup`,p),i.addEventListener(`pointercancel`,p)},[e,r,n]),onKeyDown:t=>{if(![`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(t.key))return;t.preventDefault();let i=t.currentTarget.parentElement?.getBoundingClientRect().height??window.innerHeight,o=Math.max(r,i-96),s=(t.key===`ArrowUp`?-1:1)*(n===`below`?-1:1)*(t.shiftKey?40:10),l=t.key===`Home`?r:t.key===`End`?o:Math.min(o,Math.max(r,c.current+s));c.current=l,a(l);try{localStorage.setItem(`${pc}${e}`,String(l))}catch{}}}}}function gc({handle:e,label:t,className:n}){let r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(Math.max(e.min,window.innerHeight-96));return(0,Z.useLayoutEffect)(()=>{let t=r.current?.parentElement;if(!t)return;let n=()=>a(Math.max(e.min,t.getBoundingClientRect().height-96));n();let i=new ResizeObserver(n);return i.observe(t),()=>i.disconnect()},[e.min]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{ref:r,"data-separator":e.dragging?`active`:`inactive`,role:`separator`,tabIndex:0,"aria-valuenow":Math.min(i,e.height),"aria-valuemax":i,"aria-valuemin":e.min,onKeyDown:e.onKeyDown,"aria-orientation":`horizontal`,"aria-label":t,onPointerDown:e.onPointerDown,className:K(`relative h-[var(--ui-surface-gap)] shrink-0 cursor-row-resize touch-none bg-transparent`,n),children:(0,X.jsx)(`div`,{className:`absolute inset-x-0 top-1/2 h-[9px] -translate-y-1/2`})}),(0,X.jsx)(Oo,{separatorRef:r,vertical:!1})]})}var _c=80,vc=180;function yc(e){return Math.max(vc,Math.round(e/_c*1e3))}function bc({text:e,hoverClass:t,className:n,containerClassName:r,title:i,children:a}){let o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(0);return(0,Z.useEffect)(()=>{let e=o.current;if(!e)return;let t=()=>c(Math.max(0,e.scrollWidth-e.clientWidth));t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]),(0,X.jsx)(`span`,{className:K(`block min-w-0 flex-1 overflow-hidden`,r),children:(0,X.jsx)(`span`,{ref:o,title:i,className:K(`block whitespace-nowrap transition-transform ease-linear`,n,s>0&&t),style:s>0?{"--tail":`-${s}px`,transitionDuration:`${yc(s)}ms`}:void 0,children:a??e})})}var xc={added:{letter:`A`,label:`added`,colourClass:`text-success`},modified:{letter:`M`,label:`modified`,colourClass:`text-fg-secondary`},deleted:{letter:`D`,label:`deleted`,colourClass:`text-interrupted`},renamed:{letter:`R`,label:`renamed`,colourClass:`text-warning`}};function Sc(e){return xc[e]}var Cc=[`modified`,`added`,`deleted`,`renamed`];function wc(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return Cc.filter(e=>t.has(e)).map(e=>`${t.get(e)} ${xc[e].label}`).join(` · `)}var Tc=[`var(--accent)`,`var(--status-running)`,`var(--status-waiting)`,`var(--ansi-magenta)`,`var(--ansi-cyan)`,`var(--status-interrupted)`];function Ec(e){return Tc[e%Tc.length]}function Dc(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:Ec(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=Ec(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 Oc=4,kc=1.5;function Ac(e){return e*14+14/2}function jc(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 Mc({row:e,width:t}){let n=Ac(e.col),r=new Set(e.created),i=[];for(let t of e.above){let r=Ac(t.col);t.sha===e.sha?i.push({d:jc(r,0,n,20),colour:t.colour}):i.push({d:jc(r,0,r,40),colour:t.colour})}for(let t of e.below){let e=Ac(t.col);r.has(t.col)&&i.push({d:jc(n,20,e,40),colour:t.colour})}return(0,X.jsxs)(`svg`,{width:t,height:40,className:`shrink-0`,"aria-hidden":!0,children:[i.map((e,t)=>(0,X.jsx)(`path`,{d:e.d,fill:`none`,stroke:e.colour,strokeWidth:kc},t)),(0,X.jsx)(`circle`,{cx:n,cy:20,r:Oc,fill:`var(--bg-surface)`,stroke:e.colour,strokeWidth:kc})]})}function Nc({lanes:e,width:t}){return(0,X.jsx)(`svg`,{width:t,height:22,className:`shrink-0`,"aria-hidden":!0,children:e.map(e=>{let t=Ac(e.col);return(0,X.jsx)(`path`,{d:`M ${t} 0 L ${t} 22`,fill:`none`,stroke:e.colour,strokeWidth:kc},e.col)})})}var Pc=7,Fc=`group-hover:[transform:translateX(var(--tail))]`;function Ic({session:e,sha:t,root:n,lanes:r,gutterW:i,onOpen:a}){let o=Qe(e,t,n),s=e=>(0,X.jsxs)(`div`,{className:`flex items-center`,style:{height:22},children:[(0,X.jsx)(Nc,{lanes:r,width:i}),(0,X.jsx)(`span`,{className:`px-2 text-2xs text-fg-muted`,children:e})]});return o.isPending?s(`…`):o.error?s(o.error instanceof Error?o.error.message:`Failed to load commit`):o.data.files.length===0?s(`No file changes.`):(0,X.jsx)(X.Fragment,{children:o.data.files.map(e=>{let o=Sc(e.status),s=e.status===`renamed`&&e.old_path?`${e.old_path} → ${e.path}`:e.path;return(0,X.jsxs)(`button`,{type:`button`,title:s,onClick:()=>{a(e.path,t),rc({path:e.path,root:n})},onDoubleClick:()=>a(e.path,t,{preview:!1}),className:`group flex w-full items-center text-left transition-colors hover:bg-elevated`,style:{height:22},children:[(0,X.jsx)(Nc,{lanes:r,width:i}),(0,X.jsx)(`span`,{className:K(`mr-1.5 w-3 shrink-0 text-center font-mono text-xs`,o.colourClass),children:o.letter}),(0,X.jsx)(bc,{text:s,className:`pr-3 text-2xs text-fg`,hoverClass:Fc})]},`${e.status}:${e.old_path??``}:${e.path}`)})})}function Lc({session:e,root:t,onOpenCommitFile:n}){let r=ze(e,{root:t}),[i,a]=(0,Z.useState)(null),o=(0,Z.useMemo)(()=>r.data?.pages.flatMap(e=>e.commits)??[],[r.data]),s=(0,Z.useMemo)(()=>Dc(o),[o]),c=Math.max(1,s.laneCount)*14+14/2;return r.isPending?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading history…`}):r.error?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load history`}):o.length===0?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No commits yet.`}):(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[s.rows.map((r,s)=>{let l=o[s],u=i===r.sha;return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>a(u?null:r.sha),className:K(`group flex w-full items-center text-left transition-colors hover:bg-elevated`,u&&`bg-selection`),style:{height:40},children:[(0,X.jsx)(Mc,{row:r,width:c}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 pr-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-2xs text-fg-muted`,children:r.sha.slice(0,Pc)}),(0,X.jsx)(bc,{text:l.subject,className:`text-xs text-fg`,hoverClass:Fc})]}),(0,X.jsxs)(`span`,{className:`truncate text-2xs text-fg-muted`,children:[l.author_name,` ·`,` `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:He(l.authored_at)})]})]})]}),u&&(0,X.jsx)(Ic,{session:e,sha:r.sha,root:t,lanes:r.below,gutterW:c,onOpen:n})]},r.sha)}),r.hasNextPage&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>void r.fetchNextPage(),disabled:r.isFetchingNextPage,className:`px-3 py-2 text-left text-xs text-fg-muted transition-colors hover:bg-elevated`,children:r.isFetchingNextPage?`Loading…`:`Show more`})]})}var Rc={"package.json":`npm`,"package-lock.json":`npm`,".npmrc":`npm`,"pnpm-lock.yaml":`pnpm`,"pnpm-workspace.yaml":`pnpm`,"yarn.lock":`yarn`,dockerfile:`docker`,".dockerignore":`docker`,"compose.yaml":`docker`,"compose.yml":`docker`,"docker-compose.yml":`docker`,"docker-compose.yaml":`docker`,".gitignore":`git`,".gitattributes":`git`,".gitmodules":`git`,"readme.md":`readme`,license:`license`,licence:`license`,"license.md":`license`,"licence.md":`license`,".prettierignore":`prettier`,".prettierrc":`prettier`,".prettierrc.json":`prettier`,".eslintrc":`eslint`,".eslintrc.json":`eslint`,".eslintignore":`eslint`,".env":`tune`,"go.mod":`go-mod`,"go.sum":`go-mod`,"cargo.toml":`rust`,"cargo.lock":`rust`,"tsconfig.json":`typescript-def`},zc={ts:`typescript`,mts:`typescript`,cts:`typescript`,"d.ts":`typescript-def`,"d.mts":`typescript-def`,"d.cts":`typescript-def`,tsx:`react_ts`,js:`javascript`,mjs:`javascript`,cjs:`javascript`,jsx:`react`,py:`python`,pyi:`python`,pyw:`python`,rs:`rust`,go:`go`,rb:`ruby`,php:`php`,java:`java`,kt:`kotlin`,kts:`kotlin`,c:`c`,h:`h`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`hpp`,hxx:`hpp`,cs:`csharp`,dart:`dart`,swift:`swift`,html:`html`,htm:`html`,xml:`xml`,plist:`xml`,vue:`vue`,svelte:`svelte`,astro:`astro`,sql:`database`,sqlite:`database`,db:`database`,json:`json`,jsonc:`json`,json5:`json`,yml:`yaml`,yaml:`yaml`,toml:`toml`,ini:`settings`,cfg:`settings`,conf:`settings`,env:`tune`,lock:`lock`,csv:`table`,tsv:`table`,xlsx:`table`,xls:`table`,md:`markdown`,mdx:`markdown`,markdown:`markdown`,txt:`document`,rtf:`document`,log:`document`,pdf:`pdf`,css:`css`,scss:`sass`,sass:`sass`,less:`less`,sh:`console`,bash:`console`,zsh:`console`,fish:`console`,svg:`svg`,png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,bmp:`image`,ico:`image`,avif:`image`,heic:`image`,mp4:`video`,mov:`video`,webm:`video`,mkv:`video`,avi:`video`,mp3:`audio`,wav:`audio`,flac:`audio`,ogg:`audio`,m4a:`audio`,zip:`zip`,tar:`zip`,gz:`zip`,tgz:`zip`,rar:`zip`,"7z":`zip`,bz2:`zip`,xz:`zip`,woff:`font`,woff2:`font`,ttf:`font`,otf:`font`,ipynb:`jupyter`},Bc={"eslint.config.":`eslint`,".eslintrc.":`eslint`,"prettier.config.":`prettier`,".prettierrc.":`prettier`,"vite.config.":`vite`,"vitest.config.":`vitest`,"tsconfig.":`typescript-def`,".env.":`tune`,"dockerfile.":`docker`};function Vc(e){let t=e.toLowerCase();if(Object.hasOwn(Rc,t))return Rc[t];for(let[e,n]of Object.entries(Bc))if(t.startsWith(e))return n;let n=t.split(`.`);for(let e=1;e<n.length;e++){let t=n.slice(e).join(`.`);if(Object.hasOwn(zc,t))return zc[t]}}function Hc({name:e,dimmed:t,className:n}){let r=Vc(e);return r?(0,X.jsx)(`img`,{src:`/file-icons/material/${r}.svg`,alt:``,"aria-hidden":`true`,draggable:!1,className:K(`size-4.5 shrink-0`,t&&`opacity-50`,n)}):(0,X.jsx)(ai,{"aria-hidden":`true`,className:K(`size-4.5 shrink-0 text-fg-muted`,n)})}function Uc({open:e=!1,dimmed:t=!1,className:n}){return(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:K(`size-4.5 shrink-0 text-explorer-folder`,t&&`opacity-50`,n),children:[(0,X.jsx)(`path`,{d:`M3 3h5l2 2h11a1 1 0 0 1 1 1v2H2V4a1 1 0 0 1 1-1Z`}),(0,X.jsx)(`path`,{d:e?`M2 9h21l-3 11H3a1 1 0 0 1-1-1Z`:`M2 9h20v10a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1Z`})]})}function Wc(){return{dirs:new Map,files:[]}}function Gc(e){return e.path}function Kc(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:Kc(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 qc(e){let t=Wc();for(let n of e){let e=Gc(n),r=e.split(`/`),i=r.pop(),a=t;for(let e of r){let t=a.dirs.get(e);t||(t=Wc(),a.dirs.set(e,t)),a=t}a.files.push({type:`file`,name:i,path:e,entry:n})}return Kc(t,``)}function Jc(e){return e.map(e=>({type:`file`,name:Gc(e).split(`/`).pop()??Gc(e),path:Gc(e),entry:e})).sort((e,t)=>e.path.localeCompare(t.path,void 0,{sensitivity:`base`}))}function Yc(e){return e.type===`file`?[e.entry]:e.children.flatMap(Yc)}var Xc=`group-hover:[transform:translateX(var(--tail))]`;function Zc({name:e,fullPath:t,status:n,depth:r,active:i,onOpen:a}){let o=Sc(n);return(0,X.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),onDoubleClick:()=>a(t,{preview:!1}),className:K(`sidebar-row group flex items-center gap-2 py-1 pr-2 text-left transition-colors hover:bg-explorer-hover`,i&&`bg-explorer-selection`),style:{paddingLeft:8+r*12},children:[(0,X.jsx)(`span`,{className:K(`w-3 shrink-0 text-center font-mono text-xs`,o.colourClass),children:o.letter}),(0,X.jsx)(Hc,{name:t.split(`/`).pop()??t,className:`size-4`}),(0,X.jsx)(bc,{text:e,className:`text-xs text-fg`,hoverClass:Xc})]})}function Qc({nodes:e,depth:t,activePath:n,onOpen:r}){let[i,a]=(0,Z.useState)(new Set);return(0,X.jsx)(X.Fragment,{children:e.map(e=>{if(e.type===`file`)return(0,X.jsx)(Zc,{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,X.jsxs)(`div`,{children:[(0,X.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:`group flex w-full items-center gap-1 py-1 pr-3 text-left transition-colors hover:bg-elevated`,style:{paddingLeft:8+t*12},title:e.path,children:[o?(0,X.jsx)(Xt,{className:`size-3.5 shrink-0 text-fg-gold`}):(0,X.jsx)(mr,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,X.jsx)(bc,{text:e.name,className:`text-xs text-fg-secondary`,hoverClass:Xc})]}),!o&&(0,X.jsx)(Qc,{nodes:e.children,depth:t+1,activePath:n,onOpen:r})]},e.path)})})}function $c({session:e,root:t,activePath:n,onOpen:r}){let[i,a]=(0,Z.useState)(!1),o=et(e,{against:`head`,root:t}),s=o.data?.entries??[],c=(e,n)=>{r(e,n),rc({path:e,root:t})},l=(0,Z.useMemo)(()=>i?null:qc(s),[i,s]),u=(0,Z.useMemo)(()=>i?Jc(s):null,[i,s]);return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex h-7 shrink-0 items-center gap-2 px-3`,children:[(0,X.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Uncommitted`}),s.length>0&&(0,X.jsx)(`span`,{className:`truncate text-2xs text-fg-muted`,children:wc(s)}),(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":!i,onClick:()=>a(e=>!e),className:`ml-auto rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[i?(0,X.jsx)(pi,{className:`size-3.5`}):(0,X.jsx)(oi,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:i?`Show as tree`:`Show as flat list`})]})}),(0,X.jsx)(U,{children:i?`Show as tree`:`Show as flat list`})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-1`,children:o.isPending?(0,X.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`Loading changes…`}):o.error?(0,X.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:o.error instanceof Error?o.error.message:`Failed to load changes`}):s.length===0?(0,X.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-fg-muted`,children:`No uncommitted changes.`}):i?u.map(e=>(0,X.jsx)(Zc,{name:e.path,fullPath:e.path,status:e.entry.status,depth:0,active:n===e.path,onOpen:c},e.path)):(0,X.jsx)(Qc,{nodes:l,depth:0,activePath:n,onOpen:c})})]})}var el={untracked:{letter:`U`,colourClass:`text-success`},added:{letter:`A`,colourClass:`text-success`},modified:{letter:`M`,colourClass:`text-warning`},renamed:{letter:`R`,colourClass:`text-warning`},deleted:{letter:`D`,colourClass:`text-interrupted`},conflicted:{letter:`C`,colourClass:`text-interrupted`},ignored:{letter:``,colourClass:`text-fg-muted`}};function tl(e){return el[e]}function nl(e){let t=new Map;for(let n of e)t.set(n.path,n.status);return t}var rl={conflicted:0,modified:1,renamed:2,deleted:3,added:4,untracked:5,ignored:6};function il(e,t){let n=t===``?``:`${t}/`,r=null;for(let[t,i]of e)n!==``&&!t.startsWith(n)||i!==`ignored`&&(r===null||rl[i]<rl[r])&&(r=i);return r}function al(e){let t=new Set;for(let n of e)t.add(n.path),n.old_path!==null&&t.add(n.old_path);return[...t]}var ol=`group-hover:[transform:translateX(var(--tail))]`,sl=`group-hover/repository:[transform:translateX(var(--tail))]`,cl=`group-hover:[transform:translateX(var(--tail))]`;function ll({label:e,onClick:t,disabled:n,className:r,children:i}){return(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":e,disabled:n,onClick:e=>{e.stopPropagation(),t()},className:K(`rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-not-allowed disabled:opacity-40`,r),children:i})}),(0,X.jsx)(U,{children:e})]})}function ul({title:e,entries:t,area:n,activePath:r,action:i,busy:a,flat:o,onAction:s,onOpen:c}){let[l,u]=(0,Z.useState)(!1),d=(0,Z.useMemo)(()=>o?null:qc(t),[t,o]);if(t.length===0)return null;let f=i===`stage`;return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`group flex h-7 items-center gap-1 px-3`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`flex min-w-0 flex-1 items-center gap-1 text-left text-2xs font-medium uppercase tracking-wide text-fg-gold transition-colors hover:text-fg`,children:[l?(0,X.jsx)(Xt,{className:`size-3`}):(0,X.jsx)(mr,{className:`size-3`}),(0,X.jsx)(`span`,{className:`truncate`,children:e}),(0,X.jsx)(`span`,{className:`ml-1 text-fg-muted`,children:t.length})]}),(0,X.jsx)(ll,{label:`${f?`Stage`:`Unstage`} all ${e.toLowerCase()}`,disabled:a,onClick:()=>s(al(t)),children:f?(0,X.jsx)(Qt,{className:`size-3.5`}):(0,X.jsx)(_i,{className:`size-3.5`})})]}),!l&&(o?t.map(e=>(0,X.jsx)(dl,{entry:e,name:e.path,depth:0,area:n,active:r===e.path,action:i,busy:a,onAction:s,onOpen:c},`${e.path}:${e.old_path??``}`)):(0,X.jsx)(fl,{nodes:d,depth:0,area:n,activePath:r,action:i,busy:a,onAction:s,onOpen:c}))]})}function dl({entry:e,name:t,depth:n,area:r,active:i,action:a,busy:o,onAction:s,onOpen:c}){let l=tl(e.status),u=a===`stage`;return(0,X.jsxs)(`div`,{className:K(`sidebar-row group flex items-center gap-1 pr-2 transition-colors hover:bg-explorer-hover`,i&&`bg-explorer-selection`),style:{paddingLeft:12+n*12},children:[(0,X.jsxs)(`button`,{type:`button`,title:e.path,onClick:()=>c(e.path,{root:void 0,gitArea:r}),onDoubleClick:()=>c(e.path,{preview:!1,root:void 0,gitArea:r}),className:`flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left`,children:[(0,X.jsx)(`span`,{className:K(`w-3 shrink-0 text-center font-mono text-xs`,l.colourClass),children:l.letter}),(0,X.jsx)(Hc,{name:e.path.split(`/`).pop()??e.path,className:`size-4`}),(0,X.jsx)(bc,{text:t,className:`text-xs text-fg`,hoverClass:cl})]}),(0,X.jsx)(ll,{label:`${u?`Stage`:`Unstage`} ${e.path}`,disabled:o,onClick:()=>s(al([e])),children:u?(0,X.jsx)(Qt,{className:`size-3.5`}):(0,X.jsx)(_i,{className:`size-3.5`})})]})}function fl({nodes:e,depth:t,area:n,activePath:r,action:i,busy:a,onAction:o,onOpen:s}){let[c,l]=(0,Z.useState)(new Set),u=i===`stage`;return(0,X.jsx)(X.Fragment,{children:e.map(e=>{if(e.type===`file`)return(0,X.jsx)(dl,{entry:e.entry,name:e.name,depth:t,area:n,active:r===e.path,action:i,busy:a,onAction:o,onOpen:s},`${e.entry.path}:${e.entry.old_path??``}`);let d=c.has(e.path);return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`sidebar-row group flex items-center gap-1 pr-2 transition-colors hover:bg-explorer-hover`,style:{paddingLeft:12+t*12},children:[(0,X.jsxs)(`button`,{type:`button`,title:e.path,onClick:()=>l(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),className:`flex min-w-0 flex-1 items-center gap-1 py-1 text-left`,children:[d?(0,X.jsx)(Xt,{className:`size-3.5 shrink-0 text-fg-gold`}):(0,X.jsx)(mr,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,X.jsx)(bc,{text:e.name,className:`text-xs text-fg-secondary`,hoverClass:cl})]}),(0,X.jsx)(ll,{label:`${u?`Stage`:`Unstage`} ${e.path}`,disabled:a,onClick:()=>o(al(Yc(e))),children:u?(0,X.jsx)(Qt,{className:`size-3.5`}):(0,X.jsx)(_i,{className:`size-3.5`})})]}),!d&&(0,X.jsx)(fl,{nodes:e.children,depth:t+1,area:n,activePath:r,action:i,busy:a,onAction:o,onOpen:s})]},e.path)})})}function pl(e){return e.detached?`Detached at ${e.head?.slice(0,8)??`HEAD`}`:e.branch??`Unborn branch`}function ml(e){return[pl(e),e.upstream,e.ahead>0?`${e.ahead} ahead`:null,e.behind>0?`${e.behind} behind`:null].filter(e=>e!=null).join(` · `)}function hl({session:e,targetRoot:t,repository:n,selected:r,activePath:i,onSelect:a,onOpen:o}){let[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(``),p=We(e,t),m=[...n.conflicts,...n.staged,...n.unstaged],h=p.isPending,g=async(e,t)=>{try{await p.mutateAsync(e),V.success(t)}catch(e){V.error(e instanceof Error?e.message:`Git operation failed`)}},_=(e,t)=>{g({action:e,repository:n.root,paths:t},e===`stage`?`Staged`:`Unstaged`)},v=async()=>{let e=d.trim();if(!e||h)return;let t=!1;if(n.staged.length===0){if(n.conflicts.length>0){V.error(`Resolve and stage merge changes before committing`);return}if(n.unstaged.length===0){V.error(`There are no changes to commit`);return}if(t=window.confirm(`Nothing is staged. Stage every change and commit it?`),!t)return}try{await p.mutateAsync({action:`commit`,repository:n.root,message:e,stage_all:t}),f(``),V.success(`Committed`)}catch(e){V.error(e instanceof Error?e.message:`Commit failed`)}},y=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),v())},b=(e,t)=>o(e,{...t,root:n.root});return(0,X.jsxs)(`section`,{className:`mx-2 border-t border-border py-1 first:border-t-0`,"data-selected":r||void 0,onFocus:a,children:[(0,X.jsxs)(`div`,{className:`flex h-8 items-center gap-1 pl-2 pr-2`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{a(),c(e=>!e)},className:`group/repository flex min-w-0 flex-1 items-center gap-1.5 text-left transition-colors hover:text-fg`,children:[s?(0,X.jsx)(Xt,{className:`size-3 shrink-0`}):(0,X.jsx)(mr,{className:`size-3 shrink-0`}),(0,X.jsxs)(bc,{text:`${n.name} ${n.relative_path}`,title:`${n.name} ${n.relative_path}`,className:`text-xs`,hoverClass:sl,children:[(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:n.name}),` `,(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:n.relative_path})]}),m.length>0&&(0,X.jsx)(`span`,{className:`ml-auto text-2xs text-fg-muted`,children:m.length})]}),!s&&n.initialised&&m.length>0&&(0,X.jsx)(ll,{label:l?`Show changes as tree`:`Show changes as flat list`,onClick:()=>u(e=>!e),children:l?(0,X.jsx)(pi,{className:`size-3.5`}):(0,X.jsx)(oi,{className:`size-3.5`})})]}),!s&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`group flex min-h-7 items-center px-3 text-2xs text-fg-muted`,children:(0,X.jsx)(bc,{text:ml(n),title:ml(n),hoverClass:ol})}),n.initialised?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`px-3 pb-1.5 pt-1`,children:[(0,X.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),onKeyDown:y,rows:2,placeholder:`Commit message`,"aria-label":`Commit message for ${n.name}`,className:`w-full resize-none rounded-sm bg-elevated px-2 py-1.5 text-xs text-fg outline-none placeholder:text-fg-muted focus:ring-1 focus:ring-focus`}),(0,X.jsxs)(`div`,{className:`mt-1 flex items-center gap-0.5`,children:[n.has_remote&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ll,{label:`Fetch`,disabled:h,className:`flex size-7 shrink-0 items-center justify-center p-0`,onClick:()=>void g({action:`fetch`,repository:n.root},`Fetched`),children:(0,X.jsx)(nt,{className:`size-3.5`})}),n.upstream&&(0,X.jsx)(ll,{label:`Pull`,disabled:h,className:`flex size-7 shrink-0 items-center justify-center p-0`,onClick:()=>void g({action:`pull`,repository:n.root},`Pulled`),children:(0,X.jsx)(Di,{className:`size-3.5 rotate-180`})}),n.branch&&(0,X.jsx)(ll,{label:n.upstream?`Push`:`Publish branch`,disabled:h,className:`flex size-7 shrink-0 items-center justify-center p-0`,onClick:()=>void g({action:`push`,repository:n.root,set_upstream:!n.upstream},n.upstream?`Pushed`:`Branch published`),children:n.upstream?(0,X.jsx)(Ci,{className:`size-3.5`}):(0,X.jsx)(Di,{className:`size-3.5`})})]}),(0,X.jsx)(`button`,{type:`button`,disabled:h||d.trim().length===0,onClick:()=>void v(),className:`flex h-7 min-w-0 flex-1 items-center justify-center rounded-sm bg-action px-2 text-xs text-action-ink transition-colors hover:bg-action-hover disabled:cursor-not-allowed disabled:opacity-40`,children:`Commit`})]})]}),(0,X.jsx)(ul,{title:`Merge Changes`,entries:n.conflicts,area:`unstaged`,activePath:i,action:`stage`,busy:h,flat:l,onAction:e=>_(`stage`,e),onOpen:b}),(0,X.jsx)(ul,{title:`Staged Changes`,entries:n.staged,area:`staged`,activePath:i,action:`unstage`,busy:h,flat:l,onAction:e=>_(`unstage`,e),onOpen:b}),(0,X.jsx)(ul,{title:`Changes`,entries:n.unstaged,area:`unstaged`,activePath:i,action:`stage`,busy:h,flat:l,onAction:e=>_(`stage`,e),onOpen:b}),m.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No changes.`})]}):(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Submodule not initialised.`})]})]})}function gl({header:e,session:t,root:n,activeDiffPath:r,onOpenDiff:i,onOpenCommitFile:a}){let{height:o,handle:s}=hc(`changes-uncommitted`,240,{sized:`above`,min:80}),c=l(),u=c.data!==void 0&&m(c.data.protocol),d=vt(t,{root:n,enabled:u}),[f,p]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!u||!d.data)return;let e=d.data.repositories;(!f||!e.some(e=>e.root===f))&&p(e[0]?.root??null)},[u,d.data,f]);let h=u?f??n:n;return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`section`,{className:`workspace-surface island-outline flex shrink-0 flex-col bg-surface`,style:{height:o,maxHeight:`70%`},children:[e,u?(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-1`,children:d.isPending?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading repositories…`}):d.error?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:d.error instanceof Error?d.error.message:`Failed to load repositories`}):d.data.repositories.length===0?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No Git repositories.`}):d.data.repositories.map(e=>(0,X.jsx)(hl,{session:t,targetRoot:n,repository:e,selected:f===e.root,activePath:r,onSelect:()=>p(e.root),onOpen:i},e.root))}):(0,X.jsx)($c,{session:t,root:n,activePath:r,onOpen:i})]}),(0,X.jsx)(gc,{handle:s,label:`Resize the uncommitted changes`}),(0,X.jsxs)(`div`,{className:`workspace-surface island-outline flex min-h-0 flex-1 flex-col bg-surface`,children:[(0,X.jsx)(`div`,{className:`flex h-7 shrink-0 items-center px-3`,children:(0,X.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`History`})}),(0,X.jsx)(Lc,{session:t,root:h,onOpenCommitFile:(e,t,n)=>a(e,t,{...n,root:h})})]})]})}function _l(e,t,n){return e!==null&&e.id===t&&n-e.at<1500}var vl=`puddle.explorerClipboard.v1`;function yl(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.sid==`string`&&typeof t.directory==`string`&&(t.root===void 0||typeof t.root==`string`)&&(t.host===void 0||typeof t.host==`string`)}function bl(e){if(e===null)return null;try{let t=JSON.parse(e);return typeof t.id!=`string`||t.mode!==`cut`&&t.mode!==`copy`||!Array.isArray(t.paths)||t.paths.length===0||!t.paths.every(e=>typeof e==`string`)||!yl(t.source)?null:t}catch{return null}}function xl(){if(typeof localStorage>`u`)return null;try{return bl(localStorage.getItem(vl))}catch{return null}}var Sl=xl(),Cl=new Set;function wl(e,t){if(Sl=e,t&&typeof localStorage<`u`)try{e===null?localStorage.removeItem(vl):localStorage.setItem(vl,JSON.stringify(e))}catch{}for(let e of Cl)e()}typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===vl&&wl(bl(e.newValue),!1)});function Tl(){return globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`}function El(e){return e?`${e.username}\0${e.hostname}\0${e.home}`:void 0}function Dl(e,t){return e.directory===t.directory}function Ol(e,t){return e.host===void 0||t.host===void 0||e.host===t.host}function kl(e,t){return e.host!==void 0&&e.host===t.host}function Al(e,t,n){e.length!==0&&wl({id:Tl(),paths:e,mode:t,source:n},!0)}function jl(e,t){Sl?.id!==e||Sl.mode!==`cut`||wl(t.length===0?null:{...Sl,paths:t},!0)}function Ml(e){return Cl.add(e),()=>Cl.delete(e)}function Nl(){return Sl}function Pl(){return(0,Z.useSyncExternalStore)(Ml,Nl,()=>null)}var Fl={"image/avif":`avif`,"image/bmp":`bmp`,"image/gif":`gif`,"image/heic":`heic`,"image/heif":`heif`,"image/jpeg":`jpg`,"image/png":`png`,"image/svg+xml":`svg`,"image/tiff":`tiff`,"image/webp":`webp`};function Il(e,t){return{items:Array.from(e??[]).map(e=>({entry:e.webkitGetAsEntry?.()??null,file:e.kind===`file`?e.getAsFile():null,mime:e.type})),fallback:Array.from(t)}}function Ll(e){return e.every(({entry:e,file:t})=>e===null&&t===null)}function Rl(e,t){let n=(e.type||t).toLowerCase().split(`;`,1)[0],r=Fl[n];if(r)return r;let i=e.name.match(/\.([a-z0-9]{1,10})$/i)?.[1];return i?i.toLowerCase():n.slice(6).replace(/^x-/,``).split(`+`,1)[0].replace(/[^a-z0-9-]/g,``)||`image`}function zl(e,t,n,r){let i=(e,t=2)=>String(e).padStart(t,`0`);return`Screenshot ${`${e.getFullYear()}-${i(e.getMonth()+1)}-${i(e.getDate())}`} at ${`${i(e.getHours())}.${i(e.getMinutes())}.${i(e.getSeconds())}.${i(e.getMilliseconds(),3)}`}${r===0?``:` (${r+1})`}.${Rl(t,n)}`}async function Bl(e){let t=e.createReader(),n=[];for(;;){let e=await new Promise((e,n)=>t.readEntries(e,n));if(e.length===0)return n;n.push(...e)}}function Vl(e){return new Promise((t,n)=>e.file(t,n))}async function Hl(e,t,n){if(e.isFile){let r=await Vl(e);n.push(t?new File([r],`${t}/${e.name}`,{type:r.type,lastModified:r.lastModified}):r)}else if(e.isDirectory){let r=await Bl(e),i=t?`${t}/${e.name}`:e.name;for(let e of r)await Hl(e,i,n)}}async function Ul(e,t){let n=e.items;if(Ll(n))return e.fallback;if(!t)return n.some(({entry:e})=>e?.isDirectory)&&V.error(`This daemon can't take folders — update it, or zip them first`),n.filter(({entry:e})=>e?.isDirectory!==!0).map(({file:e})=>e).filter(e=>e!==null);let r=[];for(let{entry:e,file:t}of n)e?.isDirectory?await Hl(e,``,r):t&&r.push(t);return r}function Wl(e,t,n){return Ul(Il(e,t),n)}function Gl(e,t){return t.length>0||Array.from(e??[]).some(e=>e.kind===`file`)}function Kl(e,t,n,r=new Date){let i=Il(e,t),a=Ll(i.items),o=new Map;for(let{file:e,mime:t}of i.items){let n=e?.type||t;e&&n.startsWith(`image/`)&&o.set(e,n)}if(a)for(let e of i.fallback)e.type.startsWith(`image/`)&&o.set(e,e.type);return Ul(i,n).then(e=>{let t=0;return e.map(e=>{let n=o.get(e);if(!n)return e;let i=new File([e],zl(r,e,n,t),{type:e.type||n,lastModified:e.lastModified});return t+=1,i})})}var ql=(e,t)=>e instanceof Error?e.message:t;function Jl(e,t,n=t??``){let r=f(),i=(0,Z.useCallback)(()=>{r.invalidateQueries({queryKey:[`wt-tree`,e]}),r.invalidateQueries({queryKey:[`wt-git-status`,e]})},[r,e]),a=(0,Z.useCallback)(e=>{r.invalidateQueries({queryKey:[`wt-tree`,e.sid]}),r.invalidateQueries({queryKey:[`wt-git-status`,e.sid]})},[r]);return(0,Z.useMemo)(()=>({async create(n,r,a){try{let o=await Ge(e,Po(n,r),a,t);return i(),o.path}catch(e){return V.error(ql(e,`Couldn't create ${r}`)),null}},async rename(n,r){let a=Po(n.includes(`/`)?n.slice(0,n.lastIndexOf(`/`)):``,r);try{let r=await kt(e,n,a,t);return i(),r.path}catch(e){return V.error(ql(e,`Couldn't rename ${Ao(n)}`)),null}},async move(n,r){let a=await Promise.allSettled(n.map(n=>kt(e,n,Po(r,Ao(n)),t)));i();let o=a.filter(e=>e.status===`rejected`);o.length>0&&V.error(n.length===1?ql(o[0].reason,`Couldn't move ${Ao(n[0])}`):`Couldn't move ${o.length} item${o.length>1?`s`:``}`)},async remove(n){let r=await Promise.allSettled(n.map(n=>Ke(e,n,t)));i();let a=r.filter(e=>e.status===`rejected`).length;a>0?V.error(`Couldn't delete ${a} item${a>1?`s`:``}`):V.success(n.length===1?`Deleted ${Ao(n[0])}`:`Deleted ${n.length} items`)},async paste(r,o){let s={sid:e,root:t,directory:n},c=Dl(r.source,s),l=await Promise.allSettled(r.paths.map(n=>{let i=Po(o,Ao(n));return c?(r.mode===`cut`?kt:Ue)(e,n,i,t):$e(e,{operation:r.mode===`cut`?`move`:`copy`,source:{session_id:r.source.sid,root:r.source.root},from:n,to:i},t)}));i(),!c&&r.mode===`cut`&&a(r.source);let u=r.paths.filter((e,t)=>l[t]?.status===`rejected`);return u.length>0&&V.error(`Couldn't paste ${u.length} item${u.length>1?`s`:``}`),u}}),[e,t,n,i,a])}function Yl(e,t,n){return n&&n.type!==`dir`||(e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``)===t?!1:t===``||!`${t}/`.startsWith(`${e}/`)}var Xl=(0,Z.createContext)(null);function Zl(){let e=(0,Z.useContext)(Xl);if(!e)throw Error(`explorer components must render inside <ExplorerProvider>`);return e}function Ql(){return(0,Z.useContext)(Xl)}function $l({session:e,root:t,readOnly:n=!1,onOpenFile:r,onOpenTerminal:i,compilableExtensions:a,onOpenCompilationSettings:o,activePath:s,children:c}){let u=e.id,d=f(),p=t??e.worktree_path,h=Jl(u,t,p),_=(0,Z.useCallback)(e=>t===void 0?[`wt-tree`,u,e]:[`wt-tree`,u,e,t],[u,t]),v=(0,Z.useCallback)((e,r)=>{r.length===0||n||B(u,e,r,t).then(()=>{d.invalidateQueries({queryKey:_(e)}),d.invalidateQueries({queryKey:[`wt-git-status`,u]}),V.success(r.length===1?`Uploaded ${r[0].name}`:`Uploaded ${r.length} files`)}).catch(e=>V.error(e instanceof Error?e.message:`Upload failed`))},[u,t,n,d,_]),y=l().data?.protocol,b=ee(),x=(0,Z.useMemo)(()=>({sid:u,root:t,directory:p,host:El(b.data)}),[u,t,p,b.data]),S=!y||y.major>9||y.major===9&&y.minor>=2,C=(0,Z.useCallback)((e,t,n)=>{Wl(t,n,S).then(t=>v(e,t)).catch(e=>V.error(e instanceof Error?e.message:`Couldn't read the dropped folder`))},[v,S]),[w,T]=(0,Z.useState)(new Set),[E,D]=(0,Z.useState)(new Set),[O,k]=(0,Z.useState)(null),A=Pl(),[j,M]=(0,Z.useState)(null),[N,te]=(0,Z.useState)(null),[P,ne]=(0,Z.useState)(null),re=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let e=()=>te(null);return window.addEventListener(`dragend`,e),()=>window.removeEventListener(`dragend`,e)},[]);let ie=Ye(u,{root:t,enabled:t===void 0||y!==void 0&&m(y)}),ae=(0,Z.useMemo)(()=>nl(ie.data?.entries??[]),[ie.data]),oe=ie.refetch,[se,ce]=(0,Z.useState)(0);(0,Z.useEffect)(()=>d.getQueryCache().subscribe(e=>{if(e.type!==`added`&&e.type!==`removed`&&e.type!==`updated`)return;let t=e.query.queryKey;Array.isArray(t)&&t[0]===`wt-tree`&&t[1]===u&&ce(e=>e+1)}),[d,u]);let F=(0,Z.useMemo)(()=>Vo(e=>d.getQueryData(_(e)),w),[d,_,w,se]),le=(0,Z.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ue=(0,Z.useCallback)(e=>{T(t=>t.has(e)?t:new Set(t).add(e))},[]),de=(0,Z.useCallback)(()=>T(new Set),[]),[fe,I]=(0,Z.useState)(null);(0,Z.useEffect)(()=>ic(e=>{if(!(e.directory===void 0?e.root!==t:e.directory!==p)){ac();for(let t of Mo(e.path))ue(t);e.expandTarget&&e.path!==``&&ue(e.path),D(new Set([e.path])),k(e.path),e.renameTarget&&!n&&M({mode:`rename`,path:e.path}),I(e.path)}}),[t,p,ue,n]),(0,Z.useEffect)(()=>{if(fe===null)return;let e=document.querySelector(`[data-explorer-root] [data-path="${CSS.escape(fe)}"]`);if(e){e.scrollIntoView({block:`nearest`}),I(null);return}let t=window.setTimeout(()=>I(null),4e3);return()=>window.clearTimeout(t)},[fe,F]);let L=(0,Z.useRef)(null),pe=(0,Z.useRef)(null),me=(0,Z.useCallback)(()=>{L.current!==null&&(window.clearTimeout(L.current),L.current=null)},[]);(0,Z.useEffect)(()=>me,[me]);let he=(0,Z.useCallback)((e,t)=>{if(me(),k(e.path),t.metaKey||t.ctrlKey){D(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),re.current=e.path;return}if(t.shiftKey&&re.current){D(new Set(Ho(F,re.current,e.path)));return}let i=Date.now(),a=pe.current;if(pe.current={id:e.path,at:i},e.type!==`dir`&&!n&&!j&&E.size===1&&E.has(e.path)&&_l(a,e.path,i)){L.current=window.setTimeout(()=>{L.current=null,M({mode:`rename`,path:e.path})},500);return}D(new Set([e.path])),re.current=e.path,e.type===`dir`?le(e.path):r?.(u,e.path)},[F,le,r,u,E,j,n,me]),ge=(0,Z.useCallback)(e=>{me(),e.type!==`dir`&&r?.(u,e.path,{preview:!1})},[r,u,me]),R=(0,Z.useCallback)(e=>{D(new Set([e])),k(e),re.current=e},[]),_e=(0,Z.useCallback)(e=>Al(Lo(e),`cut`,x),[x]),ve=(0,Z.useCallback)(e=>Al(Lo(e),`copy`,x),[x]),ye=A!==null&&Ol(A.source,x),z=A!==null&&Dl(A.source,x),be=!n&&(ye&&z||A!==null&&kl(A.source,x)&&g(y)),xe=(0,Z.useCallback)(e=>A?.mode===`cut`&&Ol(A.source,x)&&Dl(A.source,x)&&A.paths.includes(e),[A,x]),Se=(0,Z.useCallback)(e=>{if(!A||n)return;let t=Dl(A.source,x);if(!Ol(A.source,x)){V.error(`That filetree clipboard belongs to another daemon host.`);return}if(!t&&!kl(A.source,x)){V.error(`Copy again after daemon host information finishes loading.`);return}if(!t&&!g(y)){V.error(`Cross-filetree paste requires a daemon with protocol 16.3.`);return}h.paste(A,e).then(e=>{A.mode===`cut`&&jl(A.id,e)})},[A,h,y,n,x]),Ce=(0,Z.useCallback)((e,t)=>{if(n||j)return!1;let r=O?F.find(e=>e.path===O):void 0,i=r?r.type===`dir`?r.path:r.parentDir:``;return Gl(e,t)?(Kl(e,t,S).then(e=>v(i,e)).catch(e=>V.error(e instanceof Error?e.message:`Couldn't read the pasted files`)),!0):be?(Se(i),!0):!1},[n,j,O,F,S,v,be,Se]),we=(0,Z.useCallback)(e=>{n||M({mode:`rename`,path:e})},[n]),Te=(0,Z.useCallback)((e,t)=>{n||(e!==``&&ue(e),M({mode:`create`,parentDir:e,kind:t}))},[ue,n]),Ee=(0,Z.useCallback)(()=>M(null),[]),De=(0,Z.useCallback)(e=>{let t=e.trim(),n=j;if(M(null),!(!n||t===``))if(n.mode===`rename`){if(t===Ao(n.path))return;h.rename(n.path,t)}else h.create(n.parentDir,t,n.kind).then(e=>{e&&n.kind===`file`&&r?.(u,e)})},[j,h,r,u]),Oe=(0,Z.useCallback)(e=>{if(n)return;let t=Lo(e);t.length>0&&ne(t)},[n]),ke=(0,Z.useCallback)(()=>{let e=P;ne(null),e&&h.remove(e)},[P,h]),Ae=(0,Z.useCallback)(()=>ne(null),[]),je=(0,Z.useCallback)((e,t)=>{let n=e.map(e=>t?e:Po(p,e)).join(`
|
|
16
|
+
`);navigator.clipboard.writeText(n);let r=t?`Relative path`:`Path`;V.success(e.length>1?`${e.length} ${r.toLowerCase()}s copied`:`${r} copied`)},[p]),Me=(0,Z.useCallback)(e=>{(async()=>{for(let n of Lo(e))await Xe(u,n,t)})().catch(e=>V.error(e instanceof Error?e.message:`Download failed`))},[u,t]),Ne=(0,Z.useCallback)(()=>{d.invalidateQueries({queryKey:[`wt-tree`,u]}),oe()},[d,u,oe]),Pe=(0,Z.useCallback)((e,t)=>{if(n)return;let r=Lo(t).filter(t=>Yl(t,e));r.length>0&&h.move(r,e)},[h,n]),Fe=(0,Z.useCallback)(()=>O&&E.has(O)?[...E]:O?[O]:[...E],[O,E]),Ie=(0,Z.useRef)({buffer:``,at:0}),Le={sid:u,rootPath:p,root:t,readOnly:n,onOpenFile:r,onOpenTerminal:i,activePath:s,compilableExtensions:a,onOpenCompilationSettings:o,expanded:w,toggle:le,collapseAll:de,statusMap:ae,visibleRows:F,selection:E,focusedPath:O,onRowClick:he,onRowDoubleClick:ge,selectOnly:R,clipboard:A,canPaste:be,isCut:xe,cut:_e,copy:ve,paste:Se,editing:j,beginRename:we,beginCreate:Te,cancelEdit:Ee,commitEdit:De,requestDelete:Oe,copyPathToClipboard:je,download:Me,refresh:Ne,onUpload:v,onDropUpload:C,onClipboardPaste:Ce,dropTarget:N,setDropTarget:te,onInternalDrop:Pe,handleKeyDown:(0,Z.useCallback)(e=>{if(j)return;let t=F;if(t.length===0)return;let n=O?t.findIndex(e=>e.path===O):-1,i=(e,n)=>{let r=t[Math.max(0,Math.min(t.length-1,e))];r&&(k(r.path),n&&re.current?D(new Set(Ho(t,re.current,r.path))):(D(new Set([r.path])),re.current=r.path))},a=n>=0?t[n]:void 0,o=e.metaKey||e.ctrlKey;switch(e.key){case`ArrowDown`:e.preventDefault(),i(n+1,e.shiftKey);return;case`ArrowUp`:e.preventDefault(),i(n<=0?0:n-1,e.shiftKey);return;case`ArrowRight`:e.preventDefault(),a?.type===`dir`&&!w.has(a.path)?ue(a.path):a?.type===`dir`&&i(n+1,!1);return;case`ArrowLeft`:if(e.preventDefault(),a?.type===`dir`&&w.has(a.path))le(a.path);else if(a){let e=t.findIndex(e=>e.path===a.parentDir);e>=0&&i(e,!1)}return;case`Enter`:case` `:if(e.preventDefault(),!a)return;a.type===`dir`?le(a.path):r?.(u,a.path);return;case`F2`:e.preventDefault(),a&&we(a.path);return;case`Delete`:e.preventDefault(),Oe(Fe());return;case`Backspace`:o&&(e.preventDefault(),Oe(Fe()));return}if(o&&(e.key===`c`||e.key===`C`)){e.preventDefault();let t=Fe();e.altKey?je(t,e.shiftKey):ve(t);return}if(o&&(e.key===`x`||e.key===`X`)){e.preventDefault(),_e(Fe());return}if(!o&&!e.altKey&&e.key.length===1&&/\S/.test(e.key)){let r=Date.now(),a=Ie.current;a.buffer=r-a.at>700?e.key:a.buffer+e.key,a.at=r;let o=a.buffer.toLowerCase(),s=n+1;for(let e=0;e<t.length;e++){let n=t[(s+e)%t.length];if(n.name.toLowerCase().startsWith(o)){i(t.findIndex(e=>e.path===n.path),!1);break}}}},[j,F,O,w,ue,le,r,u,we,Oe,Fe,ve,_e,je]),pendingDelete:P,confirmDelete:ke,cancelDelete:Ae};return(0,X.jsx)(Xl.Provider,{value:Le,children:c})}function eu(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}var tu=`application/x-puddle-tab`;function nu(e){return JSON.stringify(e)}function ru(e){try{return fe.parse(JSON.parse(e))}catch{return null}}function iu(e){return e.includes(tu)}function au({path:e}){let t=me(),n=u({queryKey:[`cockpit-file-manager`],queryFn:async()=>R.parse(await Ne(`GET`,`/cockpit/file-manager`)),enabled:!t,staleTime:1/0,retry:!1});return t||!n.data?.name||!e?null:(0,X.jsxs)(Y,{onSelect:()=>{me()||Ne(`POST`,`/cockpit/file-manager`,{path:e}).catch(e=>V.error(e instanceof Error?e.message:`Could not reveal this path.`))},children:[`Reveal in `,n.data.name]})}function ou({children:e}){return(0,X.jsx)(`span`,{className:`ml-auto pl-6 text-2xs text-fg-muted tabular-nums`,children:e})}function su({absolutePath:e,readOnly:t,canPaste:n,onCut:r,onCopy:i,onPaste:a,onCopyPath:o,onCopyRelativePath:s,onReveal:c,onCompilationSettings:l,onRename:u,onDelete:d,onDownload:f}){return(0,X.jsxs)(X.Fragment,{children:[!t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Y,{onSelect:r,children:[`Cut `,(0,X.jsx)(ou,{children:`⌘X`})]}),(0,X.jsxs)(Y,{onSelect:i,children:[`Copy `,(0,X.jsx)(ou,{children:`⌘C`})]}),(0,X.jsxs)(Y,{disabled:!n,onSelect:a,children:[`Paste `,(0,X.jsx)(ou,{children:`⌘V`})]}),(0,X.jsx)(Gn,{})]}),(0,X.jsxs)(Y,{onSelect:o,children:[`Copy Path `,(0,X.jsx)(ou,{children:`⌥⌘C`})]}),(0,X.jsxs)(Y,{onSelect:s,children:[`Copy Relative Path `,(0,X.jsx)(ou,{children:`⌥⇧⌘C`})]}),c&&(0,X.jsx)(Y,{onSelect:c,children:`Reveal in Filetree`}),(0,X.jsx)(au,{path:e}),l&&(0,X.jsx)(Y,{onSelect:l,children:`Compilation Settings…`}),(0,X.jsx)(Gn,{}),!t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Y,{onSelect:u,children:[`Rename… `,(0,X.jsx)(ou,{children:`F2`})]}),(0,X.jsxs)(Y,{onSelect:d,children:[`Delete `,(0,X.jsx)(ou,{children:`⌘⌫`})]}),(0,X.jsx)(Gn,{})]}),(0,X.jsx)(Y,{onSelect:f,children:`Download`})]})}var cu=16,lu=`group-hover/treerow:[transform:translateX(var(--tail))]`;function uu(e,t){let n=document.createElement(`div`);n.textContent=`${t} items`,n.className=`fixed -top-12 left-0 rounded-md bg-elevated px-2 py-1 text-xs text-fg`,document.body.appendChild(n),e.dataTransfer.setDragImage(n,12,12),requestAnimationFrame(()=>n.remove())}function du({depth:e,initial:t,icon:n,onCommit:r,onCancel:i}){let a=(0,Z.useRef)(null),o=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let e=a.current;if(!e)return;let n=()=>{e.focus();let n=t.lastIndexOf(`.`);e.setSelectionRange(0,n>0?n:t.length)};n();let r=requestAnimationFrame(()=>{document.activeElement!==e&&n()});return()=>cancelAnimationFrame(r)},[t]);let s=()=>{o.current||(o.current=!0,r(a.current?.value??``))};return(0,X.jsxs)(`div`,{className:`flex h-[var(--ui-row-height)] items-center gap-[var(--ui-item-gap)] rounded-[var(--ui-radius)] pr-2`,style:{paddingLeft:e*cu+4},children:[(0,X.jsx)(`span`,{className:`size-3.5 shrink-0`}),n,(0,X.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 text-sm text-fg outline-none`})]})}function fu({path:e,entry:t,depth:n}){let r=Zl(),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.isCut(e),u={path:e,name:t.name,type:t.type,depth:n,parentDir:jo(e)},d=r.statusMap.get(e),f=i?il(r.statusMap,e):null,p=d?tl(d):f?tl(f):null,m=p?p.colourClass:t.name.startsWith(`.`)?`text-fg-muted`:`text-explorer-fg`,h=c&&r.selection.size>1?[...r.selection]:[e],g=i?e:jo(e),_=r.editing?.mode===`rename`&&r.editing.path===e,v=!i&&r.onOpenCompilationSettings!==void 0&&Wo(e,r.compilableExtensions)?{session:r.sid,path:e,...r.root===void 0?{}:{root:r.root}}:null;return _?(0,X.jsx)(du,{depth:n,initial:t.name,icon:i?(0,X.jsx)(Uc,{className:p?.colourClass}):(0,X.jsx)(Hc,{name:t.name}),onCommit:r.commitEdit,onCancel:r.cancelEdit}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Xn,{children:[(0,X.jsx)(Un,{asChild:!0,children:(0,X.jsxs)(`div`,{role:`treeitem`,"data-path":e,"aria-expanded":i?a:void 0,"aria-selected":c,tabIndex:-1,draggable:!r.readOnly,onClick:e=>{e.currentTarget.closest(`[data-explorer-root]`)?.focus(),r.onRowClick(u,e)},onDoubleClick:()=>r.onRowDoubleClick(u),onContextMenu:()=>{c||r.selectOnly(e)},onDragStart:t=>{let n=Lo(h);t.dataTransfer.setData(Ro,zo(n)),n.length>1&&uu(t,n.length),!i&&n.length===1&&t.dataTransfer.setData(tu,nu({type:`editor`,tab:r.root===void 0?{kind:`file`,session:r.sid,path:e}:{kind:`external`,session:r.sid,path:e,root:r.root}})),t.dataTransfer.effectAllowed=`copyMove`},onDragOver:t=>{!i||r.readOnly||(t.preventDefault(),t.stopPropagation(),r.setDropTarget(e))},onDragLeave:e=>{i&&e.currentTarget===e.target&&r.setDropTarget(null)},onDrop:t=>{if(!i||r.readOnly)return;t.preventDefault(),t.stopPropagation(),r.setDropTarget(null);let n=Bo(t.dataTransfer.getData(Ro));n.length>0?r.onInternalDrop(e,n):r.onDropUpload(e,t.dataTransfer.items,t.dataTransfer.files)},style:{paddingLeft:n*cu+4},className:K(`group/treerow flex h-[var(--ui-row-height)] cursor-pointer items-center gap-[var(--ui-item-gap)] rounded-[var(--ui-radius)] pr-2 text-sm transition-colors`,c?`bg-explorer-selection`:`hover:bg-explorer-hover`,!c&&s&&`bg-explorer-hover`,o&&`bg-selection`,l&&`opacity-50`),children:[i?(0,X.jsx)(Xt,{className:K(`size-3.5 shrink-0 text-fg-muted transition-transform duration-150`,a&&`rotate-90`)}):(0,X.jsx)(`span`,{className:`size-3.5 shrink-0`}),i?(0,X.jsxs)(`span`,{className:`relative flex shrink-0`,children:[(0,X.jsx)(Uc,{open:a,dimmed:d===`ignored`,className:p?.colourClass}),t.symlink&&(0,X.jsx)(di,{"aria-hidden":`true`,className:`absolute -bottom-0.5 -right-1 size-2.5 text-fg`})]}):t.symlink||t.type===`symlink`?(0,X.jsx)(di,{"aria-hidden":`true`,className:`size-4.5 shrink-0 text-fg-muted`}):(0,X.jsx)(Hc,{name:t.name,dimmed:d===`ignored`}),(0,X.jsx)(bc,{text:t.name,className:m,hoverClass:lu}),d&&p&&p.letter&&(0,X.jsx)(`span`,{className:K(`shrink-0 font-mono text-2xs`,p.colourClass),children:p.letter})]})}),(0,X.jsxs)(qn,{onCloseAutoFocus:e=>{r.editing&&e.preventDefault()},children:[i&&!r.readOnly&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Y,{onSelect:()=>r.beginCreate(e,`file`),children:`New File…`}),(0,X.jsx)(Y,{onSelect:()=>r.beginCreate(e,`dir`),children:`New Folder…`}),r.onOpenTerminal&&(0,X.jsx)(Y,{onSelect:()=>r.onOpenTerminal?.(e),children:`Open Terminal in Directory`}),(0,X.jsx)(Gn,{})]}),(0,X.jsx)(su,{absolutePath:Fo(r.rootPath,e),readOnly:r.readOnly,canPaste:r.canPaste,onCut:()=>r.cut(h),onCopy:()=>r.copy(h),onPaste:()=>r.paste(g),onCopyPath:()=>r.copyPathToClipboard(h,!1),onCopyRelativePath:()=>r.copyPathToClipboard(h,!0),onCompilationSettings:v?()=>r.onOpenCompilationSettings?.(v):void 0,onRename:()=>r.beginRename(e),onDelete:()=>r.requestDelete(h),onDownload:()=>r.download(h)})]})]}),i&&a&&(0,X.jsx)(pu,{sid:r.sid,path:e,depth:n+1})]})}function pu({sid:e,path:t,depth:n}){let r=Zl(),i=wt(e,t,r.root),a={paddingLeft:n*cu+4},o=r.editing,s=o?.mode===`create`&&o.parentDir===t?(0,X.jsx)(mu,{depth:n,kind:o.kind}):null;if(i.isLoading)return(0,X.jsxs)(X.Fragment,{children:[s,(0,X.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:`Loading…`})]});if(i.isError)return(0,X.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,X.jsx)(`div`,{style:a,className:`py-0.5 text-xs text-fg-muted`,children:`Empty`}):(0,X.jsxs)(X.Fragment,{children:[s,c.map(e=>(0,X.jsx)(fu,{path:Po(t,e.name),entry:e,depth:n},e.name))]})}function mu({depth:e,kind:t}){let n=Zl(),[r,i]=(0,Z.useState)(``);return(0,X.jsx)(du,{depth:e,initial:r,icon:t===`dir`?(0,X.jsx)(Uc,{}):(0,X.jsx)(Hc,{name:r||`file`}),onCommit:e=>{i(e),n.commitEdit(e)},onCancel:n.cancelEdit})}function hu(){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(gu,{}),(0,X.jsx)(_u,{})]})}function gu(){let e=Zl(),t=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{!e.focusedPath||!t.current||t.current.querySelector(`[data-path="${CSS.escape(e.focusedPath)}"]`)?.scrollIntoView({block:`nearest`})},[e.focusedPath]),(0,X.jsxs)(Xn,{children:[(0,X.jsx)(Un,{asChild:!0,children:(0,X.jsx)(`div`,{ref:t,"data-explorer-root":!0,role:`tree`,tabIndex:0,onKeyDown:e.handleKeyDown,onPaste:t=>{e.onClipboardPaste(t.clipboardData.items,t.clipboardData.files)&&t.preventDefault()},onDragOver:t=>{e.readOnly||(t.preventDefault(),e.setDropTarget(``))},onDragLeave:t=>{t.currentTarget===t.target&&e.setDropTarget(null)},onDrop:t=>{if(e.readOnly)return;t.preventDefault(),e.setDropTarget(null);let n=Bo(t.dataTransfer.getData(Ro));n.length>0?e.onInternalDrop(``,n):e.onDropUpload(``,t.dataTransfer.items,t.dataTransfer.files)},className:K(`h-full overflow-y-auto px-2 pb-19 pt-1 outline-none compact:pb-16.5`,e.dropTarget===``&&`bg-selection`),children:(0,X.jsx)(pu,{sid:e.sid,path:``,depth:0})})}),(0,X.jsxs)(qn,{onCloseAutoFocus:t=>{e.editing&&t.preventDefault()},children:[!e.readOnly&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Y,{onSelect:()=>e.beginCreate(``,`file`),children:`New File…`}),(0,X.jsx)(Y,{onSelect:()=>e.beginCreate(``,`dir`),children:`New Folder…`}),e.onOpenTerminal&&(0,X.jsx)(Y,{onSelect:()=>e.onOpenTerminal?.(``),children:`Open Terminal in Directory`}),(0,X.jsx)(Gn,{}),(0,X.jsx)(Y,{disabled:!e.canPaste,onSelect:()=>e.paste(``),children:`Paste`}),(0,X.jsx)(Gn,{})]}),(0,X.jsx)(Y,{onSelect:()=>e.copyPathToClipboard([``],!1),children:`Copy Path`}),(0,X.jsx)(au,{path:e.rootPath}),(0,X.jsxs)(Y,{onSelect:()=>e.download([``]),children:[`Download `,Ao(e.rootPath)||`folder`]})]})]})}function _u(){let e=Zl(),t=ee().data?.home,n=e.pendingDelete;return(0,X.jsx)(Gt,{open:n!==null,onOpenChange:t=>!t&&e.cancelDelete(),children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(Ht,{children:[(0,X.jsxs)(Wt,{children:[`Delete `,n&&n.length===1?`“${Ao(n[0])}”`:`${n?.length??0} items`,`?`]}),(0,X.jsxs)(Vt,{children:[`This permanently removes `,n&&n.length>1?`them`:`it`,` from`,` `,(0,X.jsx)(`span`,{className:`text-fg-secondary`,children:eu(e.rootPath,t)}),`. There is no undo.`]})]}),(0,X.jsxs)(Bt,{children:[(0,X.jsx)(J,{variant:`ghost`,onClick:e.cancelDelete,children:`Cancel`}),(0,X.jsx)(J,{variant:`danger`,onClick:e.confirmDelete,children:`Delete`})]})]})})}function vu({session:e,root:t,readOnly:n,boundHeader:r,onNavigateUp:i,onReset:a,onOpenFile:o,activePath:s,compilableExtensions:c,onOpenCompilationSettings:l}){return(0,X.jsxs)($l,{session:e,root:t,readOnly:n,onOpenFile:(e,t,n)=>o(t,n),compilableExtensions:c,onOpenCompilationSettings:l,activePath:s,children:[r,(0,X.jsx)(yu,{root:t,onNavigateUp:i,onReset:a}),(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(hu,{})})]},t)}function yu({root:e,onNavigateUp:t,onReset:n}){return(0,X.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center px-2`,children:[(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:t,disabled:e===`/`,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-sm px-1 py-1 text-left text-fg-gold transition-colors hover:bg-elevated hover:text-fg disabled:pointer-events-none disabled:opacity-40`,children:[(0,X.jsx)(It,{className:`size-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`..`})]})}),(0,X.jsx)(U,{children:e===`/`?e:`Browse the parent directory`})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:`ml-1 shrink-0 rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,X.jsx)(Ei,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Back to the worktree`})]})}),(0,X.jsx)(U,{children:`Back to the worktree`})]})]})}var bu=/[.*+?^${}()|[\]\\]/g;function xu(e){if(e.query.length===0)return null;try{let t=e.regex?e.query:e.query.replace(bu,`\\$&`);return e.wholeWord&&(t=`\\b(?:${t})\\b`),new RegExp(t,e.caseSensitive?`g`:`gi`)}catch{return null}}function Su(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 Cu=240;function wu(e){let t=e.replace(/^\s+/,``);return t.length>Cu?`${t.slice(0,Cu)}…`:t}var Tu=250,Eu=`group-hover:[transform:translateX(var(--tail))]`;function Du({active:e,label:t,onClick:n,children:r}){return(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:n,className:K(`rounded-sm p-1 transition-colors`,e?`bg-elevated text-accent`:`text-fg-muted hover:bg-elevated hover:text-fg`),children:[r,(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(U,{children:t})]})}function Ou({session:e,root:t,onOpen:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let e=setTimeout(()=>o(r),Tu);return()=>clearTimeout(e)},[r]);let p={query:a,regex:s,caseSensitive:l,wholeWord:d},m=at(e,p,t),h=(0,Z.useMemo)(()=>xu(p),[a,s,l,d]),g=m.data,_=!!g&&(g.files.length>0||g.content.length>0),v=(e,r,i=!0)=>{n(e,r,i?void 0:{preview:!1}),rc({path:e,root:t})};return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1 px-2 py-1.5`,children:[(0,X.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Search files and contents`,spellCheck:!1,autoComplete:`off`,className:`rounded-md bg-elevated px-2 py-1 text-xs text-fg outline-none placeholder:text-fg-muted`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(Du,{active:l,label:`Match case`,onClick:()=>u(e=>!e),children:(0,X.jsx)(ar,{className:`size-3.5`})}),(0,X.jsx)(Du,{active:d,label:`Match whole word`,onClick:()=>f(e=>!e),children:(0,X.jsx)(sr,{className:`size-3.5`})}),(0,X.jsx)(Du,{active:s,label:`Use regular expression`,onClick:()=>c(e=>!e),children:(0,X.jsx)(or,{className:`size-3.5`})})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:a.length===0?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Search file names and contents.`}):m.isPending?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Searching…`}):m.error?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:m.error instanceof Error?m.error.message:`Search failed`}):_?(0,X.jsxs)(X.Fragment,{children:[g.files.length>0&&(0,X.jsxs)(`section`,{children:[(0,X.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,X.jsxs)(`button`,{type:`button`,title:e,onClick:()=>v(e),onDoubleClick:()=>v(e,void 0,!1),className:`sidebar-row group flex items-center gap-2 px-2 py-1 text-left transition-colors hover:bg-explorer-hover`,children:[(0,X.jsx)(Hc,{name:e.split(`/`).pop()??e,className:`size-4`}),(0,X.jsx)(bc,{text:e,className:`text-xs text-fg`,hoverClass:Eu})]},e))]}),g.content.length>0&&(0,X.jsxs)(`section`,{children:[(0,X.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,X.jsxs)(`div`,{children:[(0,X.jsxs)(`button`,{type:`button`,title:e.path,onClick:()=>v(e.path),onDoubleClick:()=>v(e.path,void 0,!1),className:`sidebar-row group flex items-center gap-2 px-2 py-1 text-left transition-colors hover:bg-explorer-hover`,children:[(0,X.jsx)(Hc,{name:e.path.split(`/`).pop()??e.path,className:`size-4`}),(0,X.jsx)(bc,{text:e.path,className:`text-2xs text-fg-secondary`,hoverClass:Eu})]}),e.matches.map((t,n)=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>v(e.path,t.line),onDoubleClick:()=>v(e.path,t.line,!1),className:`flex w-full items-baseline gap-2 py-0.5 pl-6 pr-3 text-left transition-colors hover:bg-elevated`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-2xs tabular-nums text-fg-muted`,children:t.line}),(0,X.jsx)(`span`,{className:`truncate font-mono text-2xs text-fg-secondary`,children:Su(wu(t.text),h).map((e,t)=>e.hit?(0,X.jsx)(`span`,{className:`text-accent`,children:e.text},t):(0,X.jsx)(`span`,{children:e.text},t))})]},`${t.line}:${n}`))]},e.path))]}),g.truncated&&(0,X.jsx)(`div`,{className:`px-3 py-2 text-2xs text-fg-muted`,children:`Showing the first results — refine the query for more.`})]}):(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No results.`})})]})}var ku=new Set([`starting`,`running`,`waiting_input`]),Au=`group-hover:[transform:translateX(var(--tail))]`;function ju(e){return e.split(`/`).filter(Boolean).pop()??e}function Mu({children:e,className:t,title:n}){return(0,X.jsx)(`span`,{title:n,className:K(`shrink-0 text-2xs`,t),children:e})}function Nu({label:e,blockReason:t,onClick:n}){return(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,disabled:t!==null,onClick:n,className:K(`-my-1 rounded-sm p-1 text-fg-gold transition-colors hover:text-danger`,t===null?`hidden group-hover:inline-flex pointer-coarse:inline-flex`:`hidden`),children:[(0,X.jsx)(Zt,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:e})]})}),(0,X.jsx)(U,{children:t?`Can't ${e.toLowerCase()} — ${t}`:e})]})}function Pu({repoId:e,projectId:t,sessions:n}){let i=b(e),a=O(e,t),o=r(e,t),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),d=a.isPending||o.isPending,f=(0,Z.useMemo)(()=>{let e=new Map;for(let t of n)ku.has(t.status)&&e.set(t.worktree_path,(e.get(t.worktree_path)??0)+1);return e},[n]),p=(0,Z.useMemo)(()=>{let e=new Map;for(let t of i.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??``))},[i.data]),m=(0,Z.useMemo)(()=>[...i.data?.orphan_branches??[]].sort((e,t)=>e.name.localeCompare(t.name)),[i.data]);return i.isPending?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`Loading worktrees…`}):i.error?(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load worktrees`}):(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-2`,children:[p.length===0&&m.length===0&&(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktrees.`}),p.map(([e,t])=>(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`group flex items-center gap-1.5 px-3 pb-0.5 pt-2 text-2xs text-fg-muted`,children:[(0,X.jsx)(ci,{className:`size-3 shrink-0 text-fg-gold`}),(0,X.jsx)(bc,{text:e,hoverClass:Au})]}),t.map(e=>{let t=f.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,X.jsxs)(`div`,{className:`sidebar-row group flex items-center gap-2 px-2 py-1 pl-4 transition-colors hover:bg-explorer-hover`,children:[(0,X.jsx)(bc,{text:ju(e.path),title:e.path,className:`text-xs text-fg`,hoverClass:Au}),e.is_primary&&(0,X.jsx)(Mu,{className:`text-fg-muted`,children:`clone`}),e.dirty&&(0,X.jsx)(Mu,{className:`text-warning`,title:`Modified — uncommitted changes`,children:`M`}),t>0&&(0,X.jsx)(Mu,{className:`text-running`,title:`${t} running session${t>1?`s`:``}`,children:t}),(0,X.jsx)(Nu,{label:`Prune`,blockReason:n,onClick:()=>{u(null),c({kind:`worktree`,path:e.path,branch:e.branch})}})]},e.path)})]},`wt:${e}`)),m.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.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`}),m.map(e=>(0,X.jsxs)(`div`,{className:`sidebar-row group flex items-center gap-2 px-2 py-1 transition-colors hover:bg-explorer-hover`,children:[(0,X.jsx)(ci,{className:`size-3 shrink-0 text-fg-gold`}),(0,X.jsx)(bc,{text:e.name,className:`text-xs text-fg`,hoverClass:Au}),e.local_only&&(0,X.jsx)(Mu,{className:`text-warning`,children:`local only`}),(0,X.jsx)(Nu,{label:`Delete branch`,blockReason:null,onClick:()=>{u(null),c({kind:`branch`,name:e.name,localOnly:e.local_only})}})]},`br:${e.name}`))]}),(0,X.jsx)(Gt,{open:s!==null,onOpenChange:e=>{e||c(null)},children:(0,X.jsxs)(Ut,{children:[s?.kind===`branch`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ht,{children:[(0,X.jsx)(Wt,{children:`Delete branch`}),(0,X.jsxs)(Vt,{children:[`Delete branch `,(0,X.jsx)(`span`,{className:`text-fg`,children:s.name}),`? This removes the branch from the repository.`]})]}),s.localOnly&&(0,X.jsxs)(`p`,{className:`text-xs text-warning`,children:[(0,X.jsx)(`span`,{children:s.name}),` has commits on no remote — deleting it discards that work permanently.`]})]}):(0,X.jsxs)(Ht,{children:[(0,X.jsx)(Wt,{children:`Prune worktree`}),(0,X.jsxs)(Vt,{children:[`Remove `,(0,X.jsx)(`span`,{className:`text-fg`,children:s?ju(s.path):``}),`? The working directory is deleted; the branch`,` `,(0,X.jsx)(`span`,{className:`text-fg`,children:s?.branch??``}),` is kept.`]})]}),l&&(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:l}),(0,X.jsxs)(Bt,{children:[(0,X.jsx)(J,{type:`button`,variant:`ghost`,onClick:()=>c(null),children:`Cancel`}),(0,X.jsx)(J,{type:`button`,variant:`danger`,disabled:d,onClick:()=>{if(!s)return;u(null);let e=e=>u(e.message),t=()=>c(null);s.kind===`worktree`?a.mutate(s.path,{onSuccess:t,onError:e}):o.mutate({name:s.name,confirm:!0},{onSuccess:t,onError:e})},children:s?.kind===`branch`?`Delete`:`Prune`})]})]})})]})}function Fu({name:e,session:t}){let n=Fe()??void 0,r=Ee().projectBasedLayout,i=v(r?void 0:n),a=t?.kind===`agent`,o=d(a?n:void 0),s=i.data?.find(e=>e.id===t?.project_id)?.name,c=t?.account_id==null?void 0:o.data?.find(e=>e.id===t.account_id)?.label,l=[s,t?.branch].filter(Boolean).join(` · `);return(0,X.jsxs)(`span`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{children:e}),l!==``&&(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:l}),a&&(0,X.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-2xs text-fg-muted`,children:[(0,X.jsx)(Mn,{type:t.agent_type??``,className:`size-3 shrink-0`}),(0,X.jsx)(`span`,{children:t.agent_type}),c!==void 0&&(0,X.jsxs)(`span`,{children:[` · `,c]})]}),t?.kind===`terminal`&&(0,X.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-2xs text-fg-muted`,children:[t.detected_agent_type?(0,X.jsx)(Mn,{type:t.detected_agent_type,className:`size-3 shrink-0`}):(0,X.jsx)(At,{className:`size-3 shrink-0`}),(0,X.jsx)(`span`,{children:t.detected_agent_type?`${t.detected_agent_type} · terminal`:`terminal`})]})]})}function Iu({text:e,path:t}){let n=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{n.current&&(n.current.scrollLeft=0)},[e,t]),(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(`div`,{ref:n,dir:`ltr`,className:`no-scrollbar min-w-0 flex-1 overflow-x-auto`,children:(0,X.jsx)(`span`,{className:`inline-block whitespace-nowrap text-sm font-bold text-fg-secondary`,children:e})})}),(0,X.jsx)(U,{side:`right`,align:`center`,sideOffset:4,children:t??e})]})}function Lu({sessions:e,target:t,showFileActions:n=!1,location:r}){let{session:i,pinned:a,pin:o,unpin:s,isProjectDirectory:c}=t,l=vn(),u=e.filter(e=>e.status!==`archived`),d=r??t.root??i?.worktree_path??null;return(0,X.jsxs)(`div`,{className:`group relative flex h-8 shrink-0 items-center px-2`,children:[(0,X.jsx)(Iu,{text:d?d.split(/[\\/]/).filter(Boolean).at(-1)??d:`No worktree`,path:d}),(0,X.jsxs)(`div`,{className:K(`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,X.jsx)(zu,{}),(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":a,disabled:!i||c,title:c?`The project directory is the fallback binding — nothing to pin`:a?`Unpin — follow the active session`:`Pin the sidebar to this worktree`,onClick:()=>a?s():i&&o(i.id),className:K(`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,X.jsx)(Si,{className:K(`size-3.5`,a&&`fill-current`)}),(0,X.jsx)(`span`,{className:`sr-only`,children:a?`Unpin sidebar`:`Pin sidebar`})]}),(0,X.jsxs)(yt,{children:[(0,X.jsx)(Tt,{asChild:!0,children:(0,X.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,X.jsx)(mr,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Choose a worktree`})]})}),(0,X.jsx)(lt,{align:`end`,children:u.length===0?(0,X.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-fg-muted`,children:`No sessions yet`}):u.map(e=>(0,X.jsx)(tt,{onSelect:()=>o(e.id),className:`min-w-64 items-start`,children:(0,X.jsx)(Fu,{name:l(e),session:e})},e.id))})]})]})]})}var Ru=[{key:`refresh`,label:`Refresh`,icon:er},{key:`collapse`,label:`Collapse Folders`,icon:ti}];function zu(){let e=Ql();if(!e)return null;let t=t=>{t===`refresh`?e.refresh():t===`collapse`&&e.collapseAll()};return(0,X.jsx)(`div`,{className:`hidden shrink-0 items-center gap-0.5 group-hover:flex group-focus-within:flex`,children:Ru.map(({key:e,label:n,icon:r})=>(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.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,X.jsx)(r,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:n})]})}),(0,X.jsx)(U,{children:n})]},e))})}var Bu=[{key:`files`,label:`Files`,icon:oi},{key:`search`,label:`Search`,icon:Ar},{key:`changes`,label:`Changes`,icon:ci},{key:`worktrees`,label:`Worktrees`,icon:Ce}];function Vu(e){return e===`diff`||e===`history`||e===`changes`?`changes`:e===`search`?`search`:e===`worktrees`?`worktrees`:`files`}function Hu({mode:e,onExpand:t,onSelect:n}){return(0,X.jsx)(`div`,{className:`workspace-surface relative flex w-9 shrink-0 self-start flex-col items-center gap-1`,children:(0,X.jsxs)(Pr,{motionId:`workspace-navigators`,label:`Navigators`,variant:`island`,vertical:!0,children:[(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:t,"data-sidebar-motion":`navigator-toggle`,className:`flex items-center rounded-md p-1.5 text-fg transition-colors hover:bg-elevated hover:text-fg`,children:[(0,X.jsx)(yi,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Show sidebar`})]})}),(0,X.jsx)(U,{side:`right`,children:`Show sidebar`})]}),(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`mx-1 h-px self-stretch bg-border`}),Bu.map(({key:t,label:r,icon:i})=>(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-tray-slot":!0,"aria-current":e===t?`page`:void 0,"data-sidebar-motion":`navigator-mode-${t}`,onClick:()=>n(t),className:K(`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,X.jsx)(i,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:r})]})}),(0,X.jsx)(U,{side:`right`,children:r})]},t))]})})}function Uu({mode:e,onModeChange:t,onCollapse:n,projectId:r,repoId:i,sessions:a,target:o,browseRequest:s,onFiletreeRootChange:c,compilableExtensions:u,onOpenCompilationSettings:d,onOpenFile:f,onOpenExternalFile:p,onOpenTerminalIn:m,activeFilePath:h,activeExternalTab:g,activeDiffPath:_,onOpenDiff:v,onOpenCommitFile:y,onOpenSearchFile:b}){let{session:x}=o,S=o.root,[C,w]=(0,Z.useState)(null),T=l().data?.protocol,E=!T||T.major>10||T.major===10&&T.minor>=2,D=!T||T.major>12||T.major===12&&T.minor>=3,O=E&&C!==null&&C.forSession===x?.id?C.root:null,k=O??S,A=$o(o,O);(0,Z.useEffect)(()=>(c?.(A),()=>c?.(null)),[A,c]);let ee=e=>{x&&(o.pinned||o.pin(x.id),w({forSession:x.id,root:e}))};(0,Z.useEffect)(()=>ic(e=>{let t=S??x?.worktree_path,n=e.directory===void 0?e.root===S:e.directory===t;C!==null&&n&&w(null)}),[C,x?.worktree_path,S]);let j=(0,Z.useRef)(0);(0,Z.useEffect)(()=>{!s||!E||j.current!==s.nonce&&(j.current=s.nonce,o.pin(s.session),w({forSession:s.session,root:s.root}))},[s,E,o]);let M=es(o,()=>w(null)),N=`${x?.worktree_path??``}:${k??``}`,te=(0,X.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5`,children:[(0,X.jsx)(Pr,{motionId:`workspace-navigators`,label:`Navigators`,variant:`selection`,children:Bu.map(({key:n,label:r,icon:i})=>(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,"data-tray-slot":!0,"aria-current":e===n?`page`:void 0,"data-sidebar-motion":`navigator-mode-${n}`,onClick:()=>t(n),className:K(`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,X.jsx)(i,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:r})]})}),(0,X.jsx)(U,{side:`bottom`,children:r})]},n))}),(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,"data-sidebar-motion":`navigator-toggle`,className:`ml-auto flex items-center rounded-md p-1.5 text-fg transition-colors hover:bg-elevated hover:text-fg`,children:[(0,X.jsx)(vi,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Hide sidebar`})]})}),(0,X.jsx)(U,{side:`bottom`,children:`Hide sidebar`})]})]});return e===`changes`&&x?(0,X.jsx)(gl,{header:(0,X.jsxs)(X.Fragment,{children:[te,(0,X.jsx)(Lu,{sessions:a,target:M,location:A})]}),session:x.id,root:k,activeDiffPath:_,onOpenDiff:v,onOpenCommitFile:y},N):(0,X.jsxs)(`div`,{className:`workspace-surface island-outline flex h-full flex-col bg-surface`,children:[te,e!==`worktrees`&&e!==`files`&&(0,X.jsx)(Lu,{sessions:a,target:M,location:A}),e===`worktrees`&&(0,X.jsx)(Pu,{repoId:i,projectId:r,sessions:a}),e===`files`&&(x&&O!==null?(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(vu,{session:x,root:O,readOnly:!D,boundHeader:(0,X.jsx)(Lu,{sessions:a,target:M,showFileActions:!0,location:A}),onNavigateUp:()=>ee(No(O)),onReset:M.unpin,onOpenFile:(e,t)=>p(x.id,e,O,t),activePath:g?.root===O?g.path:null,compilableExtensions:u,onOpenCompilationSettings:d})}):x?(0,X.jsxs)($l,{session:x,root:S,onOpenFile:S===void 0?f:(e,t,n)=>p(e,t,S,n),compilableExtensions:u,onOpenCompilationSettings:d,onOpenTerminal:S===void 0?e=>m(x.id,e):void 0,activePath:S===void 0?h:g?.root===S?g.path:null,children:[(0,X.jsx)(Lu,{sessions:a,target:M,showFileActions:!0,location:A}),E&&S===void 0&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>ee(No(x.worktree_path)),title:`Browse the parent directory`,className:`flex shrink-0 items-center gap-1.5 px-3 py-1 text-left transition-colors hover:bg-elevated`,children:[(0,X.jsx)(It,{className:`size-3 shrink-0 text-fg-gold`}),(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`..`})]}),(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(hu,{})})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Lu,{sessions:a,target:M,location:A}),(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to show.`})]})),e===`changes`&&(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to show.`}),e===`search`&&(x?(0,X.jsx)(Ou,{session:x.id,root:k,onOpen:(e,n,r)=>{b(e,n,r),n===void 0&&t(`files`)}},N):(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-muted`,children:`No worktree to search.`}))]})}function Wu(e){return`${e.agent_type}/${e.label}`}function Gu(e){return[...e].sort((e,t)=>Wu(e).localeCompare(Wu(t),void 0,{numeric:!0,sensitivity:`base`}))}function Ku({projectId:e,repoId:t,open:n,kind:r=`agent`,seedAccountId:i,onOpenChange:a,onCreated:o,accountSetup:c}){let l=r===`terminal`,u=Fe(),f=d(u??void 0),p=_(u??void 0),m=A(),h=ee(),g=s(),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)(!0),[k,j]=(0,Z.useState)(!0),[M,N]=(0,Z.useState)(``),[te,P]=(0,Z.useState)(``),[ne,re]=(0,Z.useState)(!1),[ie,ae]=(0,Z.useState)(null),oe=v(u??void 0),se=(0,Z.useMemo)(()=>(oe.data??[]).filter(e=>!e.archived),[oe.data]),ce=x||e,F=se.find(e=>e.id===ce)?.repo_id??t,le=m.data?.find(e=>e.id===F),ue=y(n?F:void 0),de=b(n?F:void 0,0),fe=f.data?.find(e=>String(e.id)===C),I=p.data?.allowSkipPermissions===!0,L=!l&&I&&fe?.skip_permissions_default===!0,pe=le?.default_base_branch===``&&!T.trim(),me=de.data?.worktrees.find(e=>e.is_primary)?.branch,he=le?.default_base_branch||me||(de.data?`main`:``),ge=T.trim()||he;(0,Z.useEffect)(()=>{n&&S(e)},[n,e]);let R=(0,Z.useMemo)(()=>(de.data?.worktrees??[]).filter(e=>e.branch===ge).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})),[de.data,ge]),_e=!D&&!k,ye=R.find(e=>e.is_primary)?.path??R[0]?.path??``,z=te||ye,be=(0,Z.useMemo)(()=>{let e=p.data?.default_account_id;return f.data?.find(e=>e.id===i)??f.data?.find(t=>typeof e==`number`&&t.id===e)??f.data?.[0]},[f.data,p.data,i]),xe=C||(be?String(be.id):``),Ce=(0,Z.useMemo)(()=>Gu(f.data??[]),[f.data]);(0,Z.useEffect)(()=>{n&&i!==void 0&&w(String(i))},[n,i]);let we=(0,Z.useRef)(p.data);we.current=p.data,(0,Z.useEffect)(()=>{if(n){let e=Zr(l?`terminal`:`agent`,we.current);E(e.baseBranch),O(e.separateBranch),j(e.separateWorktree),P(``)}},[n,l,ce]);let Te=le?.default_base_branch;(0,Z.useEffect)(()=>{!n||!Te||E(e=>e===``?Te:e)},[n,ce,Te]);let Ee=()=>{ae(null),g.mutate({project_id:ce,...l?{kind:`terminal`}:{account_id:Number(xe)},...T.trim()?{base_branch:T.trim()}:{},separate_branch:D,...D&&M.trim()?{branch:M.trim()}:{},...D?{}:{separate_worktree:k},..._e&&z&&(!pe||te)?{join_worktree:z}:{},...L&&ne?{skip_permissions:!0}:{}},{onSuccess:e=>{a(!1),N(``),re(!1),o(e)},onError:e=>ae(e.message)})},De=l?`a shell`:`an agent`,Oe=D?`on a new branch off ${ge||`…`}, in its own directory`:_e?`on ${ge||`…`}, sharing an existing directory`:`on ${ge||`…`}, in its own directory`;return(0,X.jsx)(Gt,{open:n,onOpenChange:a,children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(Ht,{children:[(0,X.jsx)(Wt,{children:l?`New terminal`:`New agent`}),(0,X.jsxs)(Vt,{children:[l?`Opens`:`Spawns`,` `,De,` in`,` `,(0,X.jsx)(qu,{projects:se,value:ce,onChange:S}),` `,Oe,`.`]})]}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),(l||xe)&&Ee()},children:[!l&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(ve,{children:`Account`}),f.data?.length===0?(0,X.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:c??(0,X.jsxs)(X.Fragment,{children:[`No accounts yet —`,` `,(0,X.jsx)(`button`,{type:`button`,className:`text-accent underline`,onClick:()=>$n(`accounts`),children:`add one in settings`}),`.`]})}):(0,X.jsxs)(pr,{value:xe,onValueChange:w,children:[(0,X.jsx)(ur,{children:(0,X.jsx)(lr,{placeholder:`pick an account`})}),(0,X.jsx)(dr,{children:Ce.map(e=>(0,X.jsxs)(fr,{value:String(e.id),children:[(0,X.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]}),!e.logged_in&&(0,X.jsx)(`span`,{className:`ml-2 text-2xs text-warning`,children:`not logged in`})]},e.id))})]})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,X.jsx)(ve,{htmlFor:`base-branch`,children:`Base branch`}),(0,X.jsx)(Se,{id:`base-branch`,placeholder:le?.default_base_branch||`current clone branch`,value:T,onValueChange:E,hints:(ue.data?.branches??[]).filter(e=>e.name.toLowerCase().includes(T.trim().toLowerCase())).slice(0,20).map(e=>({value:e.name,badge:e.name===he?`default`:e.is_session?`session: ${e.session_title??`untitled`}`:void 0})),hintsClassName:`w-max min-w-full max-w-[36rem]`}),pe&&(0,X.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Uses the clone’s current branch when created`,ge?` (now ${ge})`:``,`.`]})]}),D&&(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(ve,{htmlFor:`session-branch`,children:`New branch`}),(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`optional`})]}),(0,X.jsx)(qt,{id:`session-branch`,placeholder:`leave blank for auto`,value:M,onChange:e=>N(e.target.value)})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(rr,{id:`separate-branch`,checked:D,onCheckedChange:e=>{O(e),e&&j(!0)}}),(0,X.jsx)(ve,{htmlFor:`separate-branch`,children:`Use separate branch`})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(rr,{id:`separate-worktree`,checked:D?!0:k,disabled:D,onCheckedChange:j}),(0,X.jsx)(ve,{htmlFor:`separate-worktree`,className:K(D&&`text-fg-muted`),children:`Use separate directory`})]})]}),_e&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(ve,{htmlFor:`join-dir`,children:`Directory to join`}),R.length===0?(0,X.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`No existing directory on`,` `,(0,X.jsx)(`span`,{className:`text-fg-secondary`,children:ge||`…`}),` — a shared one will be created for later sessions to join.`]}):(0,X.jsxs)(pr,{value:z,onValueChange:P,children:[(0,X.jsx)(ur,{id:`join-dir`,children:(0,X.jsx)(lr,{})}),(0,X.jsx)(dr,{children:R.map(e=>(0,X.jsx)(fr,{value:e.path,title:e.path,detail:(0,X.jsx)(`span`,{className:`ml-auto min-w-0 truncate text-2xs text-fg-muted`,children:eu(e.path,h.data?.home)}),children:e.label},e.path))})]})]}),!D&&!l&&(0,X.jsxs)(`p`,{className:`text-xs text-warning`,children:[`The `,l?`shell`:`agent`,` commits straight to`,` `,(0,X.jsx)(`span`,{children:ge||`…`}),_e?` and shares its working directory with concurrent sessions — they can trample each other’s edits.`:`.`]}),L&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-surface px-3 py-2`,children:[(0,X.jsx)(rr,{id:`skip-permissions`,checked:ne,onCheckedChange:re}),(0,X.jsx)(ve,{htmlFor:`skip-permissions`,className:`text-warning`,children:`Skip permission prompts for this session`})]}),ie&&(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:ie}),(0,X.jsxs)(Bt,{children:[(0,X.jsx)(J,{type:`button`,variant:`ghost`,onClick:()=>a(!1),children:`Cancel`}),(0,X.jsx)(J,{type:`submit`,disabled:!l&&!xe||g.isPending,children:l?`Open terminal`:`Start agent`})]})]})]})})}function qu({projects:e,value:t,onChange:n}){let r=e.find(e=>e.id===t)?.name??`this project`;return e.length<2?(0,X.jsx)(`span`,{className:`text-fg-secondary`,children:r}):(0,X.jsxs)(yt,{children:[(0,X.jsx)(Tt,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,title:`Choose the project`,className:`inline-flex items-center gap-0.5 text-fg-secondary transition-colors hover:text-fg`,children:[r,(0,X.jsx)(mr,{className:`size-3 shrink-0`})]})}),(0,X.jsx)(lt,{align:`start`,children:e.map(e=>(0,X.jsx)(tt,{onSelect:()=>n(e.id),className:K(`truncate`,e.id===t&&`text-fg`),children:e.name},e.id))})]})}function Ju({children:e,className:t,...n}){let r=(0,Z.useRef)(null),i=Mr(r,{selector:`[data-session-hover]`,direct:!1});return(0,X.jsxs)(`div`,{...n,ref:r,className:K(`session-hover-list relative isolate`,t),children:[(0,X.jsx)(`span`,{ref:i,"aria-hidden":!0,className:`tray-hover-surface session-hover-surface`}),e]})}var Yu=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Xu(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Zu(e){return`nodeType`in e}function Qu(e){return e?Xu(e)?e:Zu(e)?e.ownerDocument?.defaultView??window:window:window}function $u(e){let{Document:t}=Qu(e);return e instanceof t}function ed(e){return!Xu(e)&&e instanceof Qu(e).HTMLElement}function td(e){return e instanceof Qu(e).SVGElement}function nd(e){return e?Xu(e)?e.document:Zu(e)?$u(e)?e:ed(e)||td(e)?e.ownerDocument:document:document:document}var rd=Yu?Z.useLayoutEffect:Z.useEffect;function id(e){let t=(0,Z.useRef)(e);return rd(()=>{t.current=e}),(0,Z.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function ad(){let e=(0,Z.useRef)(null);return[(0,Z.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,Z.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function od(e,t){t===void 0&&(t=[e]);let n=(0,Z.useRef)(e);return rd(()=>{n.current!==e&&(n.current=e)},t),n}function sd(e,t){let n=(0,Z.useRef)();return(0,Z.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function cd(e){let t=id(e),n=(0,Z.useRef)(null);return[n,(0,Z.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function ld(e){let t=(0,Z.useRef)();return(0,Z.useEffect)(()=>{t.current=e},[e]),t.current}var ud={};function dd(e,t){return(0,Z.useMemo)(()=>{if(t)return t;let n=ud[e]==null?0:ud[e]+1;return ud[e]=n,e+`-`+n},[e,t])}function fd(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 pd=fd(1),md=fd(-1);function hd(e){return`clientX`in e&&`clientY`in e}function gd(e){if(!e)return!1;let{KeyboardEvent:t}=Qu(e.target);return t&&e instanceof t}function _d(e){if(!e)return!1;let{TouchEvent:t}=Qu(e.target);return t&&e instanceof t}function vd(e){if(_d(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 hd(e)?{x:e.clientX,y:e.clientY}:null}var yd=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[yd.Translate.toString(e),yd.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),bd=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function xd(e){return e.matches(bd)?e:e.querySelector(bd)}var Sd={display:`none`};function Cd(e){let{id:t,value:n}=e;return Z.createElement(`div`,{id:t,style:Sd},n)}function wd(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return Z.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 Td(){let[e,t]=(0,Z.useState)(``);return{announce:(0,Z.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var Ed=(0,Z.createContext)(null);function Dd(e){let t=(0,Z.useContext)(Ed);(0,Z.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function Od(){let[e]=(0,Z.useState)(()=>new Set),t=(0,Z.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,Z.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var kd={draggable:`
|
|
17
|
+
To pick up a draggable item, press the space bar.
|
|
18
|
+
While dragging, use the arrow keys to move the item.
|
|
19
|
+
Press space again to drop the item in its new position, or press escape to cancel.
|
|
20
|
+
`},Ad={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 jd(e){let{announcements:t=Ad,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=kd}=e,{announce:a,announcement:o}=Td(),s=dd(`DndLiveRegion`),[c,l]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{l(!0)},[]),Dd((0,Z.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=Z.createElement(Z.Fragment,null,Z.createElement(Cd,{id:r,value:i.draggable}),Z.createElement(wd,{id:s,announcement:o}));return n?(0,ki.createPortal)(u,n):u}var Md;(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`})(Md||={});function Nd(){}function Pd(e,t){return(0,Z.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Fd(){var e=[...arguments];return(0,Z.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Id=Object.freeze({x:0,y:0});function Ld(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Rd(e,t){let n=vd(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 zd(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Bd(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Vd(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 Hd(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Ud(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 Wd=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=Ud(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Bd)};function Gd(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 Kd=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&&Gd(r,a)){let n=Vd(a).reduce((e,t)=>e+Ld(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(zd)};function qd(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Jd(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Id}function Yd(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 Xd=Yd(1);function Zd(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 Qd(e,t,n){let r=Zd(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 $d={ignoreTransform:!1};function ef(e,t){t===void 0&&(t=$d);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=Qu(e).getComputedStyle(e);t&&(n=Qd(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 tf(e){return ef(e,{ignoreTransform:!0})}function nf(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function rf(e,t){return t===void 0&&(t=Qu(e).getComputedStyle(e)),t.position===`fixed`}function af(e,t){t===void 0&&(t=Qu(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 of(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if($u(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!ed(i)||td(i)||n.includes(i))return n;let a=Qu(e).getComputedStyle(i);return i!==e&&af(i,a)&&n.push(i),rf(i,a)?n:r(i.parentNode)}return e?r(e):n}function sf(e){let[t]=of(e,1);return t??null}function cf(e){return!Yu||!e?null:Xu(e)?e:Zu(e)?$u(e)||e===nd(e).scrollingElement?window:ed(e)?e:null:null}function lf(e){return Xu(e)?e.scrollX:e.scrollLeft}function uf(e){return Xu(e)?e.scrollY:e.scrollTop}function df(e){return{x:lf(e),y:uf(e)}}var ff;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(ff||={});function pf(e){return!Yu||!e?!1:e===document.scrollingElement}function mf(e){let t={x:0,y:0},n=pf(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 hf={x:.2,y:.2};function gf(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=hf);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=mf(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=ff.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=ff.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=ff.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=ff.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function _f(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 vf(e){return e.reduce((e,t)=>pd(e,df(t)),Id)}function yf(e){return e.reduce((e,t)=>e+lf(t),0)}function bf(e){return e.reduce((e,t)=>e+uf(t),0)}function xf(e,t){if(t===void 0&&(t=ef),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);sf(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Sf=[[`x`,[`left`,`right`],yf],[`y`,[`top`,`bottom`],bf]],Cf=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=of(t),r=vf(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Sf)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})}},wf=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 Tf(e){let{EventTarget:t}=Qu(e);return e instanceof t?e:nd(e)}function Ef(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 Df;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Df||={});function Of(e){e.preventDefault()}function kf(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 Af={start:[$.Space,$.Enter],cancel:[$.Esc],end:[$.Space,$.Enter,$.Tab]},jf=(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}}},Mf=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 wf(nd(t)),this.windowListeners=new wf(Qu(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Df.Resize,this.handleCancel),this.windowListeners.add(Df.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Df.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&xf(n),t(Id)}handleKeyDown(e){if(gd(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Af,coordinateGetter:a=jf,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}:Id;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=md(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}=mf(n),p=_f(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,pd(md(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()}};Mf.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Af,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 Nf(e){return!!(e&&`distance`in e)}function Pf(e){return!!(e&&`delay`in e)}var Ff=class{constructor(e,t,n){n===void 0&&(n=Tf(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=nd(i),this.documentListeners=new wf(this.document),this.listeners=new wf(n),this.windowListeners=new wf(Qu(i)),this.initialCoordinates=vd(r)??Id,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(Df.Resize,this.handleCancel),this.windowListeners.add(Df.DragStart,Of),this.windowListeners.add(Df.VisibilityChange,this.handleCancel),this.windowListeners.add(Df.ContextMenu,Of),this.documentListeners.add(Df.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Pf(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Nf(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(Df.Click,kf,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Df.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=vd(e)??Id,s=md(n,o);if(!t&&a){if(Nf(a)){if(a.tolerance!=null&&Ef(s,a.tolerance))return this.handleCancel();if(Ef(s,a.distance))return this.handleStart()}if(Pf(a)&&Ef(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()}},If={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Lf=class extends Ff{constructor(e){let{event:t}=e,n=nd(t.target);super(e,If,n)}};Lf.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 Rf={move:{name:`mousemove`},end:{name:`mouseup`}},zf;(function(e){e[e.RightClick=2]=`RightClick`})(zf||={});var Bf=class extends Ff{constructor(e){super(e,Rf,nd(e.event.target))}};Bf.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===zf.RightClick?!1:(r?.({event:n}),!0)}}];var Vf={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Hf=class extends Ff{constructor(e){super(e,Vf)}static setup(){return window.addEventListener(Vf.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Vf.move.name,e)};function e(){}}};Hf.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 Uf;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Uf||={});var Wf;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Wf||={});function Gf(e){let{acceleration:t,activator:n=Uf.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Wf.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=qf({delta:d,disabled:!a}),[m,h]=ad(),g=(0,Z.useRef)({x:0,y:0}),_=(0,Z.useRef)({x:0,y:0}),v=(0,Z.useMemo)(()=>{switch(n){case Uf.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Uf.DraggableRect:return i}},[n,i,c]),y=(0,Z.useRef)(null),b=(0,Z.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,Z.useMemo)(()=>s===Wf.TreeOrder?[...l].reverse():l,[s,l]);(0,Z.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}=gf(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 Kf={x:{[ff.Backward]:!1,[ff.Forward]:!1},y:{[ff.Backward]:!1,[ff.Forward]:!1}};function qf(e){let{delta:t,disabled:n}=e,r=ld(t);return sd(e=>{if(n||!r||!e)return Kf;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[ff.Backward]:e.x[ff.Backward]||i.x===-1,[ff.Forward]:e.x[ff.Forward]||i.x===1},y:{[ff.Backward]:e.y[ff.Backward]||i.y===-1,[ff.Forward]:e.y[ff.Forward]||i.y===1}}},[n,t,r])}function Jf(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return sd(e=>t==null?null:r??e??null,[r,t])}function Yf(e,t){return(0,Z.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 Xf;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Xf||={});var Zf;(function(e){e.Optimized=`optimized`})(Zf||={});var Qf=new Map;function $f(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,Z.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,Z.useRef)(e),d=g(),f=od(d),p=(0,Z.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,Z.useRef)(null),h=sd(t=>{if(d&&!n)return Qf;if(!t||t===Qf||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 Cf(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,Z.useEffect)(()=>{u.current=e},[e]),(0,Z.useEffect)(()=>{d||p()},[n,d]),(0,Z.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,Z.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 Xf.Always:return!1;case Xf.BeforeDragging:return n;default:return!n}}}function ep(e,t){return sd(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function tp(e,t){return ep(e,t)}function np(e){let{callback:t,disabled:n}=e,r=id(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function rp(e){let{callback:t,disabled:n}=e,r=id(t),i=(0,Z.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,Z.useEffect)(()=>()=>i?.disconnect(),[i]),i}function ip(e){return new Cf(ef(e),e)}function ap(e,t,n){t===void 0&&(t=ip);let[r,i]=(0,Z.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=np({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=rp({callback:a});return rd(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function op(e){return Jd(e,ep(e))}var sp=[];function cp(e){let t=(0,Z.useRef)(e),n=sd(n=>e?n&&n!==sp&&e&&t.current&&e.parentNode===t.current.parentNode?n:of(e):sp,[e]);return(0,Z.useEffect)(()=>{t.current=e},[e]),n}function lp(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(e),i=(0,Z.useCallback)(e=>{let t=cf(e.target);t&&n(e=>e?(e.set(t,df(t)),new Map(e)):null)},[]);return(0,Z.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=cf(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,df(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=>{cf(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,Z.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>pd(e,t),Id):vf(e):Id,[e,t])}function up(e,t){t===void 0&&(t=[]);let n=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{n.current=null},t),(0,Z.useEffect)(()=>{let t=e!==Id;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?md(e,n.current):Id}function dp(e){(0,Z.useEffect)(()=>{if(!Yu)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 fp(e,t){return(0,Z.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function pp(e){return(0,Z.useMemo)(()=>e?nf(e):null,[e])}var mp=[];function hp(e,t){t===void 0&&(t=ef);let[n]=e,r=pp(n?Qu(n):null),[i,a]=(0,Z.useState)(mp);function o(){a(()=>e.length?e.map(e=>pf(e)?r:new Cf(t(e),e)):mp)}let s=rp({callback:o});return rd(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function gp(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return ed(t)?t:e}function _p(e){let{measure:t}=e,[n,r]=(0,Z.useState)(null),i=rp({callback:(0,Z.useCallback)(e=>{for(let{target:n}of e)if(ed(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=cd((0,Z.useCallback)(e=>{let n=gp(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,Z.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var vp=[{sensor:Lf,options:{}},{sensor:Mf,options:{}}],yp={current:{}},bp={draggable:{measure:tf},droppable:{measure:tf,strategy:Xf.WhileDragging,frequency:Zf.Optimized},dragOverlay:{measure:ef}},xp=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}},Sp={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new xp,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Nd},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:bp,measureDroppableContainers:Nd,windowRect:null,measuringScheduled:!1},Cp={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Nd,draggableNodes:new Map,over:null,measureDroppableContainers:Nd},wp=(0,Z.createContext)(Cp),Tp=(0,Z.createContext)(Sp);function Ep(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new xp}}}function Dp(e,t){switch(t.type){case Md.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Md.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 Md.DragEnd:case Md.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Md.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new xp(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Md.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 xp(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Md.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new xp(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Op(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,Z.useContext)(wp),a=ld(r),o=ld(n?.id);return(0,Z.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!gd(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=xd(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function kp(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Ap(e){return(0,Z.useMemo)(()=>({draggable:{...bp.draggable,...e?.draggable},droppable:{...bp.droppable,...e?.droppable},dragOverlay:{...bp.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function jp(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,Z.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;rd(()=>{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=Jd(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=sf(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Mp=(0,Z.createContext)({...Id,scaleX:1,scaleY:1}),Np;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Np||={});var Pp=(0,Z.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=vp,collisionDetection:o=Wd,measuring:s,modifiers:c,...l}=e,[u,d]=(0,Z.useReducer)(Dp,void 0,Ep),[f,p]=Od(),[m,h]=(0,Z.useState)(Np.Uninitialized),g=m===Np.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,Z.useRef)({initial:null,translated:null}),C=(0,Z.useMemo)(()=>_==null?null:{id:_,data:x?.data??yp,rect:S},[_,x]),w=(0,Z.useRef)(null),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),k=od(l,Object.values(l)),A=dd(`DndDescribedBy`,t),ee=(0,Z.useMemo)(()=>b.getEnabled(),[b]),j=Ap(s),{droppableRects:M,measureDroppableContainers:N,measuringScheduled:te}=$f(ee,{dragging:g,dependencies:[y.x,y.y],config:j.droppable}),P=Jf(v,_),ne=(0,Z.useMemo)(()=>D?vd(D):null,[D]),re=ke(),ie=tp(P,j.draggable.measure);jp({activeNode:_==null?null:v.get(_),config:re.layoutShiftCompensation,initialRect:ie,measure:j.draggable.measure});let ae=ap(P,j.draggable.measure,ie),oe=ap(P?P.parentElement:null),se=(0,Z.useRef)({activatorEvent:null,active:null,activeNode:P,collisionRect:null,collisions:null,droppableRects:M,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ce=b.getNodeFor(se.current.over?.id),F=_p({measure:j.dragOverlay.measure}),le=F.nodeRef.current??P,ue=g?F.rect??ae:null,de=!!(F.nodeRef.current&&F.rect),fe=op(de?null:ae),I=pp(le?Qu(le):null),L=cp(g?ce??P:null),pe=hp(L),me=kp(c,{transform:{x:y.x-fe.x,y:y.y-fe.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:ae,containerNodeRect:oe,draggingNodeRect:ue,over:se.current.over,overlayNodeRect:F.rect,scrollableAncestors:L,scrollableAncestorRects:pe,windowRect:I}),he=ne?pd(ne,y):null,ge=lp(L),R=up(ge),_e=up(ge,[ae]),ve=pd(me,R),ye=ue?Xd(ue,me):null,z=C&&ye?o({active:C,collisionRect:ye,droppableRects:M,droppableContainers:ee,pointerCoordinates:he}):null,be=Hd(z,`id`),[xe,Se]=(0,Z.useState)(null),Ce=qd(de?me:pd(me,_e),xe?.rect??null,ae),we=(0,Z.useRef)(null),Te=(0,Z.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:se,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,ki.unstable_batchedUpdates)(()=>{r?.(i),h(Np.Initializing),d({type:Md.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(we.current),O(a)})},onMove(e){d({type:Md.DragMove,coordinates:e})},onEnd:s(Md.DragEnd),onCancel:s(Md.DragCancel)});we.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=se.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Md.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Md.DragCancel)}w.current=null,(0,ki.unstable_batchedUpdates)(()=>{d({type:e}),h(Np.Uninitialized),Se(null),E(null),O(null),we.current=null;let t=e===Md.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Ee=Yf(a,(0,Z.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]));dp(a),rd(()=>{ae&&m===Np.Initializing&&h(Np.Initialized)},[ae,m]),(0,Z.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=se.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ve.x,y:ve.y},over:i};(0,ki.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ve.x,ve.y]),(0,Z.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=se.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(be),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,ki.unstable_batchedUpdates)(()=>{Se(s),a?.(c),f({type:`onDragOver`,event:c})})},[be]),rd(()=>{se.current={activatorEvent:D,active:C,activeNode:P,collisionRect:ye,collisions:z,droppableRects:M,draggableNodes:v,draggingNode:le,draggingNodeRect:ue,droppableContainers:b,over:xe,scrollableAncestors:L,scrollAdjustedTranslate:ve},S.current={initial:ue,translated:ye}},[C,P,z,ye,v,le,ue,M,b,xe,L,ve]),Gf({...re,delta:y,draggingRect:ye,pointerCoordinates:he,scrollableAncestors:L,scrollableAncestorRects:pe});let De=(0,Z.useMemo)(()=>({active:C,activeNode:P,activeNodeRect:ae,activatorEvent:D,collisions:z,containerNodeRect:oe,dragOverlay:F,draggableNodes:v,droppableContainers:b,droppableRects:M,over:xe,measureDroppableContainers:N,scrollableAncestors:L,scrollableAncestorRects:pe,measuringConfiguration:j,measuringScheduled:te,windowRect:I}),[C,P,ae,D,z,oe,F,v,b,M,xe,N,L,pe,j,te,I]),Oe=(0,Z.useMemo)(()=>({activatorEvent:D,activators:Ee,active:C,activeNodeRect:ae,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:xe,measureDroppableContainers:N}),[D,Ee,C,ae,d,A,v,xe,N]);return Z.createElement(Ed.Provider,{value:p},Z.createElement(wp.Provider,{value:Oe},Z.createElement(Tp.Provider,{value:De},Z.createElement(Mp.Provider,{value:Ce},i)),Z.createElement(Op,{disabled:n?.restoreFocus===!1})),Z.createElement(jd,{...n,hiddenTextDescribedById:A}));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}}}),Fp=(0,Z.createContext)(null),Ip=`button`,Lp=`Draggable`;function Rp(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=dd(Lp),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,Z.useContext)(wp),{role:p=Ip,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,Z.useContext)(g?Mp:Fp),[v,y]=cd(),[b,x]=cd(),S=fp(o,t),C=od(n);return rd(()=>(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,Z.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Ip?!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 zp(){return(0,Z.useContext)(Tp)}var Bp=`Droppable`,Vp={timeout:25};function Hp(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=dd(Bp),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,Z.useContext)(wp),u=(0,Z.useRef)({disabled:n}),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Vp,...i},_=od(h??r),v=rp({callback:(0,Z.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]=cd((0,Z.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=od(t);return(0,Z.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,Z.useEffect)(()=>(s({type:Md.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:Md.UnregisterDroppable,key:a,id:r})),[r]),(0,Z.useEffect)(()=>{n!==u.current.disabled&&(s({type:Md.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 Up(e){let{animation:t,children:n}=e,[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=ld(n);return!n&&!r&&s&&i(s),rd(()=>{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]),Z.createElement(Z.Fragment,null,n,r?(0,Z.cloneElement)(r,{ref:o}):null)}var Wp={x:0,y:0,scaleX:1,scaleY:1};function Gp(e){let{children:t}=e;return Z.createElement(wp.Provider,{value:Cp},Z.createElement(Mp.Provider,{value:Wp},t))}var Kp={position:`fixed`,touchAction:`none`},qp=e=>gd(e)?`transform 250ms ease`:void 0,Jp=(0,Z.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=qp}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Kp,width:s.width,height:s.height,top:s.top,left:s.left,transform:yd.Transform.toString(d),transformOrigin:i&&r?Rd(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return Z.createElement(n,{className:o,style:f,ref:t},a)}),Yp={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:yd.Transform.toString(t)},{transform:yd.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 Xp(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return id((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=gp(a);if(!c)return;let{transform:l}=Qu(a).getComputedStyle(a),u=Zd(l);if(!u)return;let d=typeof t==`function`?t:Zp(t);return xf(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 Zp(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...Yp,...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 Qp=0;function $p(e){return(0,Z.useMemo)(()=>{if(e!=null)return Qp++,Qp},[e])}var em=Z.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}=zp(),S=(0,Z.useContext)(Mp),C=$p(d?.id),w=kp(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=ep(f),E=Xp({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return Z.createElement(Gp,null,Z.createElement(Up,{animation:E},d&&C?Z.createElement(Jp,{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 tm({status:e,kind:t=`agent`,agentType:n,detectedAgentType:r,stale:i=!1,className:a,iconClassName:o=`size-3`,iconStrokeScale:s=1}){let c=t===`terminal`?r:n,l=`${t===`terminal`?c?`${c} in terminal`:`terminal`:c??`agent`} — status: ${e.replace(`_`,` `)}${i?` (no agent activity for over an hour — possibly stalled)`:``}`;return(0,X.jsx)(`span`,{className:K(`status-glyph`,a),"data-status":e,"data-kind":t,"data-stale":i||void 0,role:`img`,title:i?`No agent activity for over an hour — possibly stalled`:void 0,"aria-label":l,children:t===`terminal`&&!c?(0,X.jsx)(At,{className:o,strokeWidth:2*s}):(0,X.jsx)(Mn,{type:c??``,className:o,strokeScale:s})})}var nm={no_live_runtime:`This session has no running persistent runtime.`,runtime_unavailable:`The runtime is unavailable. Reconnect before restarting it.`,runtime_changed:`The runtime moved to another session. Open its current session to inspect it.`,release_unavailable:`The installed runtime software is unavailable.`,conversation_unknown:`The exact native conversation is not available for resuming.`,resume_unsupported:`This agent cannot resume its native conversation.`,worktree_missing:`The session’s working directory is missing.`,state_not_saved:`Runtime state has not finished saving. Refresh before restarting.`};function rm({session:e,onClose:t}){let n=f(),r=[`session-runtime`,e.id],i=`/api/sessions/${e.id}/runtime`,a=u({queryKey:r,queryFn:async()=>he.parse(await Ne(`GET`,i)),retry:!1,staleTime:0,gcTime:0}),o=ae({mutationKey:r,retry:!1,networkMode:`always`,mutationFn:async e=>I.parse(await Ne(`POST`,`${i}/restart`,{fingerprint:e})),onMutate:()=>n.cancelQueries({queryKey:r}),onSettled:async()=>{await Promise.all([n.invalidateQueries({queryKey:r}),n.invalidateQueries({queryKey:[`sessions`]}),n.invalidateQueries({queryKey:[`project`,e.project_id]}),n.invalidateQueries({queryKey:[`cockpit-host-updates`]})])}}),s=a.data,c=s?.restart.available?s.restart.fingerprint:null;return(0,X.jsx)(Gt,{open:!0,onOpenChange:e=>{!e&&!o.isPending&&t()},children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(Wt,{children:[`Runtime · `,e.title||e.agent_title||e.id.slice(0,8)]}),(0,X.jsx)(Vt,{children:`Inspect this session’s running software. Updating the installed default leaves existing runtimes running.`}),s&&(0,X.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,X.jsxs)(`p`,{children:[`Running build: `,s.runtime?.version??`None`,s.runtime&&!s.runtime.connected&&` · disconnected`]}),(0,X.jsxs)(`p`,{children:[`Installed default: `,s.installed?.version??`Unavailable`]}),s.runtime?.lifetime===`host_session`&&(0,X.jsx)(`p`,{className:`text-xs text-warning`,children:`Host-session lifetime: this host may stop the runtime when its login or SSH session ends. Daemon updates are blocked while it is running.`}),s.runtime&&s.runtime.lifetime!==`service`&&s.runtime.lifetime!==`host_session`&&(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Runtime lifetime could not be verified.`}),s.runtime?.terminals&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-fg-secondary`,children:`Affected terminals`}),(0,X.jsx)(`ul`,{className:`mt-1 space-y-1 text-xs text-fg-muted`,children:s.runtime.terminals.map(({term:t})=>(0,X.jsx)(`li`,{children:t===`agent`?e.kind===`agent`?`Main agent (${e.agent_type})`:`Main terminal`:`Shell ${t.replace(`shell-`,``)}`},t))})]}),!s.restart.available&&(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:nm[s.restart.reason]}),c&&(0,X.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Restart stops this runtime and all listed terminals. Shell jobs and in-memory process state are lost; extra shell tabs are closed.`,` `,e.kind===`agent`?`The agent resumes its exact native conversation.`:`A fresh shell opens in the saved directory.`,` `,`Commands and interrupted programmes are not replayed.`]})]}),a.isPending&&(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:`Inspecting runtime…`}),a.isError&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Runtime inspection is unavailable. Refresh before another action.`}),o.isError&&(0,X.jsxs)(`p`,{role:`alert`,className:`text-sm text-warning`,children:[o.error.message,` Inspect the current runtime before another action; the restart was not repeated.`]}),o.isSuccess&&(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-fg-secondary`,children:`The replacement was observed. Its current state is shown above.`}),(0,X.jsxs)(Bt,{children:[(0,X.jsx)(J,{variant:`ghost`,disabled:o.isPending,onClick:t,children:`Close`}),(0,X.jsx)(J,{variant:`ghost`,disabled:a.isFetching||o.isPending,onClick:()=>void a.refetch({cancelRefetch:!1}),children:`Refresh`}),c&&(0,X.jsx)(J,{variant:`danger`,disabled:a.isFetching||a.isError||o.isPending,onClick:()=>{n.isMutating({mutationKey:r})||o.mutate(c)},children:o.isPending?`Restarting…`:`Restart on ${s?.installed?.version}`})]})]})})}var im=[`starting`,`running`,`waiting_input`],am=[`exited`,`interrupted`],om={Item:tt,Separator:ht,Sub:xt,SubTrigger:pt,SubContent:it},sm={Item:Y,Separator:Gn,Sub:Hn,SubTrigger:Yn,SubContent:Jn};function cm(e,t){let n=w(`resume`),r=w(`kill`),i=c(),a=oe(),u=ne(),f=p(),m=o(),h=E(),g=s(),v=Lt(),y=Fe(),b=d(y??void 0),S=_(y??void 0),[C,T]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(e.title??``),[ee,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(null),[te,P]=(0,Z.useState)(!1),re=l().data?.protocol,ie=!me()&&x(re),ae=(b.data??[]).filter(t=>t.agent_type===e.agent_type),se=!e.worktree_missing&&e.status!==`archived`&&ae.some(t=>t.id!==e.account_id),ce=(b.data??[]).filter(t=>t.agent_type!==e.agent_type&&t.logged_in),F=S.data?.default_account_id,le=typeof F==`number`?F:null,ue=(b.data??[]).filter(e=>e.logged_in),de=le===null?ue:[...ue.filter(e=>e.id===le),...ue.filter(e=>e.id!==le)];return{menu:{session:e,...ie?{inspectRuntime:()=>P(!0)}:{},resumable:am.includes(e.status)&&!e.conversation_missing,live:im.includes(e.status),archived:e.status===`archived`,canMigrate:se,sameAgent:ae,handoffTargets:!e.worktree_missing&&e.status!==`archived`?ce:[],setHandoffTo:N,resume:()=>n.mutate(e.id,{onError:e=>{let t=Fr(e);t?v(`/project/${t.projectId}/session/${t.sessionId}`):Ir(e)}}),kill:()=>r.mutate(e.id,{onError:e=>Ir(e)}),openClearEnv:()=>T(`clear-env`),openTerminal:()=>g.mutate({project_id:e.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void v(`/project/${e.project_id}/session/${e.id}`),onError:e=>Ir(e)}),spawnAccounts:de,defaultAccountId:le,spawnAgent:t=>g.mutate({project_id:e.project_id,account_id:t,separate_branch:!1,separate_worktree:!1,join_worktree:e.worktree_path},{onSuccess:e=>void v(`/project/${e.project_id}/session/${e.id}`),onError:e=>Ir(e)}),openRename:()=>{A(e.title??``),O(!0)},archive:()=>i.mutate(e.id,{onSuccess:()=>t?.(e.id),onError:e=>Ir(e)}),unarchive:()=>a.mutate(e.id,{onError:e=>Ir(e)}),setMigrateTo:j},dialogs:(0,X.jsxs)(X.Fragment,{children:[te&&(0,X.jsx)(rm,{session:e,onClose:()=>P(!1)}),(0,X.jsx)(Gt,{open:C===`clear-env`,onOpenChange:e=>{e||T(null)},children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(Ht,{children:[(0,X.jsx)(Wt,{children:`Clear captured environment?`}),(0,X.jsx)(Vt,{children:`Variables exported in this session’s terminals will no longer be injected into new shells or agent restarts.`})]}),(0,X.jsxs)(Bt,{children:[(0,X.jsx)(J,{variant:`ghost`,onClick:()=>T(null),children:`Cancel`}),(0,X.jsx)(J,{variant:`danger`,disabled:h.isPending,onClick:()=>h.mutate(e.id,{onSuccess:e=>{T(null),V.success(e.cleared===0?`Nothing was captured`:`Cleared ${e.cleared} captured var${e.cleared===1?``:`s`}`)},onError:e=>{T(null),Ir(e)}}),children:`Clear captured env`})]})]})}),(0,X.jsx)(Gt,{open:D,onOpenChange:O,children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(Ht,{children:[(0,X.jsx)(Wt,{children:`Rename session`}),(0,X.jsx)(Vt,{children:`Leave it empty to use the agent’s own session name.`})]}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:t=>{t.preventDefault(),u.mutate({sessionId:e.id,title:k.trim()},{onSuccess:()=>O(!1),onError:e=>Ir(e)})},children:[(0,X.jsx)(qt,{value:k,onChange:e=>A(e.target.value),placeholder:e.agent_title??e.osc_title??e.id.slice(0,8),autoFocus:!0}),(0,X.jsxs)(Bt,{children:[(0,X.jsx)(J,{type:`button`,variant:`ghost`,onClick:()=>O(!1),children:`Cancel`}),(0,X.jsx)(J,{type:`submit`,disabled:u.isPending,children:`Rename`})]})]})]})}),(0,X.jsx)(Gt,{open:ee!==null,onOpenChange:e=>!e&&j(null),children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(Ht,{children:[(0,X.jsxs)(Wt,{children:[`Move this session to `,ee?.label,`?`]}),(0,X.jsx)(Vt,{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,X.jsxs)(Bt,{children:[(0,X.jsx)(J,{variant:`ghost`,onClick:()=>j(null),children:`Cancel`}),(0,X.jsx)(J,{disabled:f.isPending,onClick:()=>{ee&&f.mutate({sessionId:e.id,accountId:ee.id},{onSuccess:()=>{j(null),V.success(`Moved to ${ee.label}`)},onError:e=>{j(null),Ir(e)}})},children:`Move session`})]})]})}),(0,X.jsx)(Gt,{open:M!==null,onOpenChange:e=>!e&&N(null),children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(Ht,{children:[(0,X.jsxs)(Wt,{children:[`Hand off to `,M?.agent_type,`?`]}),(0,X.jsxs)(Vt,{children:[`A new session starts in this worktree and branch on`,` `,(0,X.jsx)(`span`,{className:`text-fg`,children:M?.label}),`, opening with a summary of the conversation so far plus the branch’s commits and status. The conversation itself is summarised, not moved — the new agent will not have the old one’s reasoning. This session is left as it is.`]})]}),(0,X.jsxs)(Bt,{children:[(0,X.jsx)(J,{variant:`ghost`,onClick:()=>N(null),children:`Cancel`}),(0,X.jsx)(J,{disabled:m.isPending,onClick:()=>{M&&m.mutate({sessionId:e.id,accountId:M.id},{onSuccess:e=>{N(null),V.success(`Handed off to ${M.agent_type}`),v(`/session/${e.id}`)},onError:e=>{N(null),Ir(e)}})},children:`Hand off`})]})]})})]})}}function lm({kit:e,menu:t}){let{Item:n,Separator:r,Sub:i,SubTrigger:a,SubContent:o}=e,{session:s}=t;return(0,X.jsxs)(X.Fragment,{children:[t.resumable&&!s.worktree_missing&&(0,X.jsxs)(n,{onSelect:t.resume,children:[(0,X.jsx)(bt,{}),` Resume`]}),t.live&&(0,X.jsxs)(n,{onSelect:t.kill,children:[(0,X.jsx)(mt,{}),` Kill`]}),t.inspectRuntime&&(0,X.jsxs)(n,{onSelect:t.inspectRuntime,children:[(0,X.jsx)(ui,{}),` Runtime…`]}),(0,X.jsxs)(n,{onSelect:t.openRename,children:[(0,X.jsx)(xe,{}),` Rename`]}),!t.archived&&(0,X.jsxs)(n,{onSelect:t.openClearEnv,children:[(0,X.jsx)(ni,{}),` Clear captured env`]}),t.canMigrate&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(Oi,{}),` Move to account…`]}),(0,X.jsx)(o,{children:t.sameAgent.map(e=>{let r=e.id===s.account_id;return(0,X.jsxs)(n,{disabled:r,onSelect:()=>t.setMigrateTo(e),children:[e.label,r&&(0,X.jsx)(`span`,{className:`ml-auto text-fg-muted`,children:`current`})]},e.id)})})]}),t.handoffTargets.length>0&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)($r,{}),` Hand off to agent…`]}),(0,X.jsx)(o,{children:t.handoffTargets.map(e=>(0,X.jsxs)(n,{onSelect:()=>t.setHandoffTo(e),children:[(0,X.jsx)(Mn,{type:e.agent_type,className:`size-4`}),e.agent_type,(0,X.jsx)(`span`,{className:`ml-auto text-fg-muted`,children:e.label})]},e.id))})]}),!s.worktree_missing&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{}),(0,X.jsxs)(n,{onSelect:t.openTerminal,children:[(0,X.jsx)(At,{}),` Open terminal in worktree`]}),t.spawnAccounts.length>0&&(0,X.jsxs)(i,{children:[(0,X.jsxs)(a,{children:[(0,X.jsx)(Qn,{}),` Spawn agent in worktree`]}),(0,X.jsx)(o,{children:t.spawnAccounts.map(e=>(0,X.jsxs)(n,{onSelect:()=>t.spawnAgent(e.id),children:[(0,X.jsx)(Mn,{type:e.agent_type,className:`size-4 shrink-0`}),e.agent_type,`/`,e.label,e.id===t.defaultAccountId&&(0,X.jsx)(`span`,{className:`ml-auto pl-3 text-fg-muted`,children:`default`})]},e.id))})]}),(0,X.jsxs)(n,{onSelect:()=>{window.location.href=je(`vscode`,s.worktree_path,Me())},children:[(0,X.jsx)(ri,{}),` Open in VS Code`]}),(0,X.jsxs)(n,{onSelect:()=>{window.location.href=je(`cursor`,s.worktree_path,Me())},children:[(0,X.jsx)(ri,{}),` Open in Cursor`]})]}),!t.archived&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{}),(0,X.jsxs)(n,{onSelect:t.archive,children:[(0,X.jsx)(Zn,{}),` Archive`]})]}),t.archived&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(r,{}),(0,X.jsxs)(n,{onSelect:t.unarchive,children:[(0,X.jsx)(Wn,{}),` Unarchive`]})]})]})}function um({batch:e}){return(0,X.jsxs)(Y,{onSelect:()=>e.archiveAll(e.sessionIds),children:[(0,X.jsx)(Zn,{}),` Archive all`,(0,X.jsx)(`span`,{className:`ml-auto pl-3 tabular-nums text-fg-muted`,children:e.sessionIds.length})]})}function dm({menu:e}){return(0,X.jsxs)(yt,{children:[(0,X.jsx)(Tt,{asChild:!0,children:(0,X.jsxs)(J,{variant:`ghost`,size:`icon`,className:`island-outline size-7 rounded-full bg-elevated shadow-sm hover:bg-surface`,onClick:e=>e.preventDefault(),children:[(0,X.jsx)(ut,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Session actions`})]})}),(0,X.jsx)(lt,{align:`end`,children:(0,X.jsx)(lm,{kit:om,menu:e})})]})}function fm({session:e,onArchived:t,batch:n,children:r}){let{menu:i,dialogs:a}=cm(e,t);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Xn,{children:[(0,X.jsx)(Un,{asChild:!0,children:typeof r==`function`?r(i):r}),(0,X.jsx)(qn,{children:n?(0,X.jsx)(um,{batch:n}):(0,X.jsx)(lm,{kit:sm,menu:i})})]}),a]})}function pm({menu:e,batch:t}){return(0,X.jsx)(qn,{children:t?(0,X.jsx)(um,{batch:t}):(0,X.jsx)(lm,{kit:sm,menu:e})})}var mm=`application/x-puddle-sessions`,hm=pe(ge().uuid()).min(1);function gm(e,t,n,r,i){if(i.toggle){let e=new Set(t);return e.has(r)?e.delete(r):e.add(r),{selection:e,anchor:r}}if(i.shift&&n!==null){let t=e.indexOf(n),i=e.indexOf(r);if(t!==-1&&i!==-1){let r=Math.min(t,i),a=Math.max(t,i);return{selection:new Set(e.slice(r,a+1)),anchor:n}}}return{selection:new Set([r]),anchor:r}}function _m(e,t){let n=new Set(t),r=new Set([...e].filter(e=>n.has(e)));return r.size===e.size&&[...r].every(t=>e.has(t))?e:r}function vm(e,t,n){if(!t.has(n)||t.size<2)return[n];let r=e.filter(e=>t.has(e));return r.length>0?r:[n]}function ym(e){return JSON.stringify(e)}function bm(e){try{return[...new Set(hm.parse(JSON.parse(e)))]}catch{return[]}}function xm(e){return e.includes(mm)}function Sm(e,t,n=.25){if(e.width<=0||e.height<=0)return`center`;let r=Cm(t.x/e.width),i=Cm(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 Cm(e){return e<0?0:e>1?1:e}var wm=(0,Z.createContext)(null);function Tm(){return(0,Z.useContext)(wm)}var Em=(0,Z.createContext)(null),Dm=(0,Z.createContext)(!1);function Om(){return(0,Z.useContext)(Dm)}function km(){return(0,Z.useContext)(Em)}var Am=`leaf:`,jm=`tabdrop:`,Mm=`strip:`,Nm=`archive:`,Pm=e=>{let t=Kd(e);if(e.active.data.current?.paneId&&t.length===0)return[];for(let e of[jm,Mm]){let n=t.filter(t=>String(t.id).startsWith(e));if(n.length>0)return n}return t.length>0?t:Wd(e)};function Fm({onDrop:e,onDropPane:t,onArchive:n,renderOverlay:r,children:i}){let a=Fd(Pd(Lf,{activationConstraint:{distance:4}})),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),f=(0,Z.useRef)(null),p=()=>{s(null),l(null),d(null),f.current=null};return(0,X.jsxs)(Pp,{sensors:a,collisionDetection:Pm,onDragStart:e=>{l(e.active.data.current?.ref??null);let t=e.active.data.current?.paneId;d(t?{id:t,count:e.active.data.current?.tabCount}:null)},onDragMove:e=>{let t=e.over,n=Im(e),r=t&&n?Rm(String(t.id),t.rect,t.data.current,n):null,i=e.active.data.current?.paneId;i&&r&&(r=r.leafId===i?null:{leafId:r.leafId,zone:r.zone}),!Lm(f.current,r)&&(f.current=r,s(r))},onDragEnd:r=>{let i=f.current,a=r.active.data.current?.ref,o=r.active.data.current?.fromLeafId,s=r.over===null?null:String(r.over.id);p();let c=r.active.data.current?.paneId;if(c){i&&s&&!s.startsWith(`archive:`)&&t?.({fromLeafId:c,toLeafId:i.leafId,edge:i.zone});return}if(s!==null&&s.startsWith(`archive:`)){a?.type===`terminal`&&n?.(a.session);return}i&&a&&o&&e({ref:a,fromLeafId:o,toLeafId:i.leafId,edge:i.zone,index:i.index})},onDragCancel:p,children:[(0,X.jsx)(wm.Provider,{value:o,children:(0,X.jsx)(Dm.Provider,{value:c!==null||u!==null,children:(0,X.jsx)(Em.Provider,{value:c,children:i})})}),(0,X.jsx)(em,{dropAnimation:null,children:u?(0,X.jsxs)(`div`,{className:`rounded-md bg-elevated px-3 py-2 text-xs text-fg shadow-lg`,children:[`Move pane · `,u.count,` `,u.count===1?`tab`:`tabs`]}):c?r(c):null})]})}function Im(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 Lm(e,t){return e===null||t===null?e===t:e.leafId===t.leafId&&e.zone===t.zone&&e.index===t.index}function Rm(e,t,n,r){if(e.startsWith(jm)){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(Mm)){let e=n;return e?{leafId:e.leafId,zone:`center`,index:e.count}:null}if(e.startsWith(Am)){let n=Sm({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 zm=`application/x-puddle-project`,Bm=`group-hover:[transform:translateX(var(--tail))]`;function Vm(e,t){let n=document.createElement(`div`);n.textContent=`${t} sessions`,n.className=`fixed -top-12 left-0 rounded-md bg-elevated px-2 py-1 text-xs text-fg`,document.body.appendChild(n),e.dataTransfer.setDragImage(n,12,12),requestAnimationFrame(()=>n.remove())}function Hm({projectId:e,name:t,colour:n,actions:r,editLabel:i}){let[a,o]=(0,Z.useState)(!1),s=k(),c=C(l().data?.protocol);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(qn,{children:[(0,X.jsxs)(Y,{onSelect:()=>r.onNewSessionIn(e),children:[(0,X.jsx)(Qn,{}),`New agent`]}),(0,X.jsxs)(Y,{onSelect:()=>r.onNewTerminalIn(e),children:[(0,X.jsx)(At,{}),`New terminal`]}),(0,X.jsx)(Gn,{}),(0,X.jsxs)(Y,{onSelect:i.onSelect,children:[(0,X.jsx)(xe,{}),i.label]}),c&&(0,X.jsxs)(Y,{onSelect:()=>o(!0),children:[(0,X.jsx)(ir,{}),`Change project colour`]})]}),(0,X.jsx)(Gt,{open:a,onOpenChange:o,children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(Ht,{children:[(0,X.jsx)(Wt,{children:`Project colour`}),(0,X.jsx)(Vt,{className:_e(n),children:t})]}),(0,X.jsx)(z,{value:n,label:`Project colour`,disabled:s.isPending,onChange:t=>s.mutate({id:e,colour:t},{onSuccess:()=>o(!1),onError:e=>Ir(e)})})]})})]})}function Um(e,t){let{isOver:n,setNodeRef:r}=Hp({id:`${Nm}${e}`}),i=km(),[a,o]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{let e=()=>o(!1);return window.addEventListener(`dragend`,e),()=>window.removeEventListener(`dragend`,e)},[]),{setNodeRef:r,armed:a||n&&i?.type===`terminal`,props:{onDragOver:e=>{!xm(e.dataTransfer.types)&&!iu(e.dataTransfer.types)||(e.preventDefault(),o(!0))},onDragLeave:()=>o(!1),onDrop:e=>{o(!1);let n=bm(e.dataTransfer.getData(mm));if(n.length>0){e.preventDefault(),t(n);return}let r=ru(e.dataTransfer.getData(tu));r?.type===`terminal`&&(e.preventDefault(),t([r.session]))}}}}function Wm({onArchiveDrop:e,onExpand:t}){let n=Um(`rail`,e);return(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`button`,{"data-sidebar-motion":`sessions-archive`,ref:n.setNodeRef,type:`button`,onClick:t,...n.props,className:K(`island-outline mt-auto flex min-h-9 w-full shrink-0 items-center justify-center rounded-[var(--ui-surface-radius)] bg-tray p-1.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg compact:p-1`,n.armed&&`bg-selection text-fg`),children:[(0,X.jsx)(Zn,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Archived sessions`})]})}),(0,X.jsx)(U,{side:`left`,children:`Drop selected sessions here to archive them`})]})}function Gm({collapsed:e,children:t}){return(0,X.jsx)(`div`,{className:K(`grid transition-[grid-template-rows] duration-200`,e?`grid-rows-[0fr]`:`grid-rows-[1fr]`),children:t})}function Km({icon:e,label:t,onClick:n,active:r=!1,tooltipSide:i=`bottom`}){return(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,"data-sidebar-motion":`sessions-control-${t===`Show sessions`||t===`Hide sessions`?`toggle`:t}`,"aria-pressed":r,className:K(`flex items-center rounded-md p-1.5 transition-colors`,r?`bg-elevated text-fg`:`text-fg hover:bg-elevated`),children:[(0,X.jsx)(e,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(U,{side:i,children:t})]})}function qm({session:e,accountLabel:t}){return(0,X.jsxs)(`span`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{children:vn()(e)}),(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.branch}),(0,X.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1 text-2xs text-fg-muted`,children:e.kind===`terminal`?(0,X.jsxs)(X.Fragment,{children:[e.detected_agent_type?(0,X.jsx)(Mn,{type:e.detected_agent_type,className:`size-3 shrink-0`}):(0,X.jsx)(At,{className:`size-3 shrink-0`}),(0,X.jsx)(`span`,{children:e.detected_agent_type?`${e.detected_agent_type} · terminal`:`terminal`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Mn,{type:e.agent_type??``,className:`size-3 shrink-0`}),(0,X.jsx)(`span`,{children:e.agent_type}),t&&(0,X.jsxs)(`span`,{children:[` · `,t]})]})})]})}function Jm({session:e,accountLabel:t,activeSessionId:n,onPromote:r,onArchived:i,selectedIds:a,selection:o}){let{menu:s,dialogs:c}=cm(e,i),l=vn(),u=o.ids.has(e.id),d=u&&a.length>1?{sessionIds:a,archiveAll:o.onArchive}:void 0;return(0,X.jsxs)(Xn,{children:[(0,X.jsxs)(W,{children:[(0,X.jsx)(Un,{asChild:!0,children:(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(jt,{draggable:!1,"aria-current":e.id===n?`true`:void 0,onClick:t=>{let n=t.shiftKey||t.metaKey||t.ctrlKey;o.onSelect(e.id,{shift:t.shiftKey,toggle:t.metaKey||t.ctrlKey}),n&&t.preventDefault()},onDoubleClick:()=>r(e.id),onContextMenu:()=>{u||o.onSelectOnly(e.id)},to:`/project/${e.project_id}/session/${e.id}`,"data-sidebar-motion":`sessions-item-${e.id}`,"data-session-hover":!0,"data-session-active":e.id===n||void 0,"aria-selected":u,className:K(`session-hover-row relative flex items-center rounded-[var(--ui-radius)] p-1 transition-colors`,u?`bg-explorer-selection`:e.id===n&&`bg-explorer-hover`),children:[(0,X.jsx)(tm,{status:e.status,kind:e.kind,agentType:e.agent_type,detectedAgentType:e.detected_agent_type,stale:e.stale_running,className:`size-5 shrink-0 compact:size-4`,iconClassName:`size-full`,iconStrokeScale:.75}),(0,X.jsx)(`span`,{className:`sr-only`,children:l(e)})]})})}),(0,X.jsx)(U,{side:`left`,children:(0,X.jsx)(qm,{session:e,accountLabel:t})})]}),(0,X.jsx)(pm,{menu:s,batch:d}),c]})}function Ym({groups:e,accounts:t,activeSessionId:n,onReorder:r,onPromote:i,onExpand:a,onSearch:o,onNewTerminal:s,onNewSession:c,onArchived:l,onArchiveDrop:u,selection:d,projectActions:f}){let[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),y=k(),b=new Map(t.map(e=>[e.id,e.label])),x=(0,Z.useMemo)(()=>e.flatMap(e=>e.sessions.map(e=>e.id)),[e]),S=x.filter(e=>d.ids.has(e)),C=(t,n)=>{let i=Ft(e,t,n);i&&r(i)},w=(e,t)=>{v(null);let n=Te(t);!n||n===e.abbrev||y.mutate({id:e.projectId,abbrev:n},{onError:e=>Ir(e)})};return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 w-9 shrink-0 flex-col items-center gap-[var(--ui-surface-gap)] overflow-hidden`,children:[(0,X.jsx)(`div`,{className:`relative flex w-full shrink-0 flex-col items-center gap-1 compact:gap-0.5`,children:(0,X.jsxs)(Pr,{label:`New sessions`,variant:`island`,vertical:!0,children:[(0,X.jsx)(Km,{icon:xi,label:`Show sessions`,onClick:a,tooltipSide:`left`}),(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`mx-1 h-px self-stretch bg-border`}),(0,X.jsx)(Km,{icon:Qn,label:`New agent`,onClick:c,tooltipSide:`left`}),(0,X.jsx)(Km,{icon:At,label:`New terminal`,onClick:s,tooltipSide:`left`}),(0,X.jsx)(Km,{icon:Ar,label:`Search sessions`,onClick:o,tooltipSide:`left`})]})}),(0,X.jsx)(Ju,{className:`collapsed-session-list workspace-surface island-outline no-scrollbar flex min-h-0 w-full shrink flex-col items-center overflow-y-auto overscroll-contain bg-tray`,children:e.map(e=>(0,X.jsxs)(`div`,{className:`collapsed-session-project relative flex w-full shrink-0 flex-col items-center gap-1 py-1.5 compact:gap-0.5`,onDragOver:t=>{h&&(t.preventDefault(),h!==e.projectId&&f.onMoveProject(h,e.projectId))},children:[_===e.projectId?(0,X.jsx)(Fn,{initial:e.abbrev,maxLength:5,className:`w-7 text-center text-[8px] uppercase leading-3 text-fg`,onCommit:t=>w(e,t),onCancel:()=>v(null)}):(0,X.jsxs)(Xn,{children:[(0,X.jsxs)(W,{children:[(0,X.jsx)(Un,{asChild:!0,children:(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(jt,{to:`/project/${e.projectId}`,"data-sidebar-motion":`sessions-project-${e.projectId}`,...Kn(),draggable:!0,onDragStart:t=>{t.dataTransfer.setData(zm,e.projectId),g(e.projectId)},onDragEnd:()=>g(null),className:K(`w-7 truncate text-center text-[8px] uppercase leading-3 transition-colors`,_e(e.colour)?K(_e(e.colour),`hover:opacity-75`):`text-fg-muted hover:text-fg`,h===e.projectId&&`opacity-50`),children:e.abbrev})})}),(0,X.jsx)(U,{side:`left`,children:e.name})]}),(0,X.jsx)(Hm,{projectId:e.projectId,name:e.name,colour:e.colour,actions:f,editLabel:{label:`Change project abbreviation`,onSelect:()=>v(e.projectId)}})]}),e.sessions.length>0&&(0,X.jsx)(Gm,{collapsed:h!==null,children:(0,X.jsx)(`div`,{className:`flex flex-col items-center gap-1 overflow-hidden compact:gap-0.5`,children:e.sessions.map(e=>(0,X.jsx)(`div`,{draggable:!0,onDragStart:t=>{let n=vm(x,d.ids,e.id);t.dataTransfer.setData(`application/x-puddle-tab`,nu({type:`terminal`,session:e.id})),t.dataTransfer.setData(`application/x-puddle-sessions`,ym(n)),t.dataTransfer.effectAllowed=`copyMove`,n.length>1&&Vm(t,n.length),d.ids.has(e.id)||d.onSelectOnly(e.id),m({sourceId:e.id,sessionIds:n})},onDragEnd:()=>m(null),onDragOver:t=>{t.preventDefault(),p?.sessionIds.length===1&&p.sourceId!==e.id&&C(p.sourceId,e.id)},className:K(`transition-opacity`,p?.sessionIds.includes(e.id)&&`opacity-50`),children:(0,X.jsx)(Jm,{session:e,accountLabel:e.account_id===null?void 0:b.get(e.account_id),activeSessionId:n,onPromote:i,onArchived:l,selectedIds:S,selection:d})},e.id))})})]},e.projectId))}),(0,X.jsx)(Wm,{onArchiveDrop:u,onExpand:a})]})}function Xm({session:e,activeSessionId:t,accountLabel:n,onPromote:r,onArchived:i,selectedIds:a,selection:o,ellipsis:s,lastActive:c=!1}){let l=vn(),u=o?.ids.has(e.id)??!1,d=o&&u&&a&&a.length>1?{sessionIds:a,archiveAll:o.onArchive}:void 0,f=e.kind===`terminal`?`terminal`:e.agent_type??`agent`,p=c?e.last_activity_at===null?``:` · ${He(e.last_activity_at)}`:e.account_id!==null&&n.has(e.account_id)?` · ${n.get(e.account_id)}`:``;return(0,X.jsx)(fm,{session:e,onArchived:i,batch:d,children:n=>(0,X.jsxs)(jt,{draggable:!1,onClick:t=>{if(!o)return;let n=t.shiftKey||t.metaKey||t.ctrlKey;o.onSelect(e.id,{shift:t.shiftKey,toggle:t.metaKey||t.ctrlKey}),n&&t.preventDefault()},onDoubleClick:r&&(()=>r(e.id)),onContextMenu:()=>{o&&!u&&o.onSelectOnly(e.id)},to:`/project/${e.project_id}/session/${e.id}`,"data-sidebar-motion":`sessions-item-${e.id}`,"data-session-hover":!0,"data-session-active":e.id===t||void 0,"aria-selected":o?u:void 0,className:K(`session-hover-row sidebar-row group relative flex items-center gap-[var(--ui-item-gap)] px-2 py-2 transition-colors compact:py-1.5`,u?`bg-explorer-selection`:e.id===t&&`bg-explorer-hover`),children:[(0,X.jsx)(tm,{status:e.status,kind:e.kind,agentType:e.agent_type,detectedAgentType:e.detected_agent_type,stale:e.stale_running}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(bc,{text:l(e),className:`font-sans text-xs text-fg`,hoverClass:Bm}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-2xs text-fg-muted`,children:[(0,X.jsx)(ci,{className:`size-3 shrink-0 text-fg-gold`}),(0,X.jsx)(bc,{text:e.branch,hoverClass:Bm})]}),(0,X.jsx)(`span`,{className:`flex items-center gap-1 text-2xs text-fg-muted`,children:(0,X.jsx)(bc,{text:`${f}${p}`,hoverClass:Bm})})]}),e.skip_permissions&&(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(wi,{className:`size-3.5 shrink-0 text-warning`})}),(0,X.jsx)(U,{children:`Running with permission prompts skipped`})]}),e.worktree_missing&&(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(si,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,X.jsx)(U,{children:`Worktree directory is gone — archive only`})]}),e.conversation_missing&&(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(gi,{className:`size-3.5 shrink-0 text-interrupted`})}),(0,X.jsx)(U,{children:`Native conversation is missing — resume unavailable`})]}),e.native_sync===`fallback`&&e.status!==`archived`&&(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(Nn,{className:`size-3.5 shrink-0 text-fg-muted`})}),(0,X.jsx)(U,{children:`In-agent conversation switches are not synchronised`})]}),s&&(0,X.jsx)(`span`,{className:`absolute right-2 top-1/2 z-10 -translate-y-1/2 opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto focus-within:opacity-100 focus-within:pointer-events-auto has-[[data-state=open]]:opacity-100 has-[[data-state=open]]:pointer-events-auto pointer-coarse:opacity-100 pointer-coarse:pointer-events-auto`,children:(0,X.jsx)(dm,{menu:n})})]})})}function Zm({searching:e,setSearching:t,groups:n,accounts:r,activeSessionId:i,onReorder:a,onPromote:o,archived:s,onNewSession:c,onNewTerminal:l,onCollapse:u,onArchived:d,onArchiveDrop:f,selection:p,projectActions:m}){let[h,g]=(0,Z.useState)(``),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e&&v.current?.focus()},[e]);let y=()=>{t(!1),g(``),requestAnimationFrame(()=>{_.current?.querySelector(`[aria-label="New sessions"] > button:last-child`)?.focus()})};return(0,X.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,X.jsx)(Qm,{header:(0,X.jsxs)(`div`,{ref:_,className:`session-sidebar-controls pointer-events-none z-10 col-start-1 row-start-1 self-start`,"data-searching":e,children:[!e&&(0,X.jsx)(`div`,{className:`pointer-events-auto flex items-center`,children:(0,X.jsx)(Km,{icon:bi,label:`Hide sessions`,onClick:u})}),(0,X.jsx)(Pr,{label:e?`Search sessions`:`New sessions`,variant:`selection`,className:`session-sidebar-search-tray pointer-events-auto`,children:e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ar,{className:`ml-1 size-4 shrink-0 text-fg-muted`}),(0,X.jsx)(`input`,{ref:v,type:`search`,"aria-label":`Search displayed sessions`,placeholder:`Search sessions…`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),y())},className:`h-[var(--ui-control-height)] min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`}),(0,X.jsx)(Km,{icon:Kt,label:`Close session search`,onClick:y})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Km,{icon:Qn,label:`New agent`,onClick:c}),(0,X.jsx)(Km,{icon:At,label:`New terminal`,onClick:l}),(0,X.jsx)(Km,{icon:Ar,label:`Search sessions`,onClick:()=>t(!0)})]})})]}),query:h,groups:n,accounts:r,activeSessionId:i,onReorder:a,onPromote:o,archived:s,onArchived:d,onArchiveDrop:f,selection:p,projectActions:m})})}function Qm({header:e,query:t,groups:n,accounts:r,activeSessionId:i,onReorder:a,onPromote:o,archived:s,onArchived:c,onArchiveDrop:l,selection:u,projectActions:d}){let[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),b=Um(`list`,l),x=km(),S=f!==null||x?.type===`terminal`,C=k(),w=Ie(`palette.toggle`),T=new Map(r.map(e=>[e.id,e.label])),E=vn(),D=t.toLocaleLowerCase().trim().split(/\s+/).filter(Boolean),O=(e,t=!1)=>D.length===0?e:e.map(e=>({...e,sessions:e.sessions.filter(n=>{let r=[e.name,E(n),n.branch,n.kind===`terminal`?`terminal`:n.agent_type??`agent`,t?n.last_activity_at===null?``:He(n.last_activity_at):n.account_id===null?``:T.get(n.account_id)].join(` `).toLocaleLowerCase();return D.every(e=>r.includes(e))})})).filter(e=>e.sessions.length>0),A=O(n),ee=n.reduce((e,t)=>e+t.sessions.length,0),j=(0,Z.useMemo)(()=>A.flatMap(e=>e.sessions.map(e=>e.id)),[A]),M=j.filter(e=>u.ids.has(e)),{height:N,handle:te}=hc(`sessions-archived`,200,{sized:`below`,min:96}),P=O((0,Z.useMemo)(()=>{let e=new Set,t=n.map(t=>{let n=s.filter(e=>e.project_id===t.projectId);for(let t of n)e.add(t.id);return{...t,sessions:n}}),r=s.filter(t=>!e.has(t.id));return[...t.filter(e=>e.sessions.length>0),...r.length>0?[{projectId:``,name:``,abbrev:``,colour:null,repoId:-1,sessions:r}]:[]]},[n,s]),!0),ne=D.length>0&&A.length===0&&(!v||P.length===0),re=(e,t)=>{let r=Ft(n,e,t);r&&a(r)},ie=(e,t)=>{_(null);let n=t.trim();!n||n===e.name||C.mutate({id:e.projectId,name:n},{onError:e=>Ir(e)})};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`workspace-surface island-outline grid min-h-0 flex-1 grid-cols-1 grid-rows-[minmax(0,1fr)] bg-surface`,children:[e,(0,X.jsxs)(Ju,{className:`no-scrollbar col-start-1 row-start-1 min-h-0 overflow-y-auto overscroll-contain pb-1.5 pt-[calc(var(--ui-control-height)+1.5rem)]`,children:[D.length===0&&ee===0&&s.length===0&&(0,X.jsxs)(`p`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[`No sessions yet — press `,w,` to start one.`]}),ne&&(0,X.jsx)(`p`,{role:`status`,className:`px-3 py-3 text-xs text-fg-muted`,children:`No matching sessions.`}),A.map(e=>(0,X.jsxs)(`div`,{className:`mx-2 border-t border-border py-1 first:border-t-0`,onDragOver:t=>{m&&(t.preventDefault(),m!==e.projectId&&d.onMoveProject(m,e.projectId))},children:[g===e.projectId?(0,X.jsx)(Fn,{initial:e.name,maxLength:100,className:`block w-full px-3 pb-1 pt-2 text-2xs font-medium tracking-wide text-fg`,onCommit:t=>ie(e,t),onCancel:()=>_(null)}):(0,X.jsxs)(Xn,{children:[(0,X.jsx)(Un,{asChild:!0,children:(0,X.jsx)(jt,{to:`/project/${e.projectId}`,"data-sidebar-motion":`sessions-project-${e.projectId}`,...Kn(),draggable:!0,onDragStart:t=>{t.dataTransfer.setData(zm,e.projectId),h(e.projectId)},onDragEnd:()=>h(null),className:K(`block truncate px-3 pb-1 pt-2 text-2xs font-medium uppercase tracking-wide transition-colors compact:pb-0.5 compact:pt-1.5`,_e(e.colour)?K(_e(e.colour),`hover:opacity-75`):`text-fg-gold hover:text-fg`,m===e.projectId&&`opacity-50`),children:e.name})}),(0,X.jsx)(Hm,{projectId:e.projectId,name:e.name,colour:e.colour,actions:d,editLabel:{label:`Change project name`,onSelect:()=>_(e.projectId)}})]}),(0,X.jsx)(Gm,{collapsed:m!==null,children:(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 overflow-hidden compact:gap-0`,children:e.sessions.map(e=>(0,X.jsx)(`li`,{draggable:!0,onDragStart:t=>{let n=vm(j,u.ids,e.id);t.dataTransfer.setData(tu,nu({type:`terminal`,session:e.id})),t.dataTransfer.setData(mm,ym(n)),t.dataTransfer.effectAllowed=`copyMove`,n.length>1&&Vm(t,n.length),u.ids.has(e.id)||u.onSelectOnly(e.id),p({sourceId:e.id,sessionIds:n})},onDragEnd:()=>p(null),onDragOver:t=>{t.preventDefault(),f?.sessionIds.length===1&&f.sourceId!==e.id&&re(f.sourceId,e.id)},className:K(`transition-opacity`,f?.sessionIds.includes(e.id)&&`opacity-50`),children:(0,X.jsx)(Xm,{session:e,activeSessionId:i,accountLabel:T,onPromote:o,onArchived:c,selectedIds:M,selection:u,ellipsis:!0})},e.id))})})]},e.projectId))]})]}),(s.length>0||S)&&(0,X.jsxs)(X.Fragment,{children:[!v&&(0,X.jsx)(`div`,{className:`h-[var(--ui-surface-gap)] shrink-0`}),v&&(0,X.jsx)(gc,{handle:te,label:`Resize the archived sessions`}),(0,X.jsxs)(`div`,{className:`workspace-surface island-outline flex shrink-0 flex-col bg-surface pb-1.5`,style:v?{height:N,maxHeight:`70%`}:void 0,children:[(0,X.jsxs)(`button`,{"data-sidebar-motion":`sessions-archive`,ref:b.setNodeRef,type:`button`,onClick:()=>y(e=>!e),...b.props,className:K(`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`,b.armed&&`bg-selection text-fg`),children:[(0,X.jsx)(Xt,{className:K(`size-3 transition-transform`,v&&`rotate-90`)}),(0,X.jsx)(Zn,{className:`size-3`}),(0,X.jsx)(`span`,{children:`Archived`}),(0,X.jsx)(`span`,{className:`ml-auto tabular-nums`,children:s.length})]}),v&&(0,X.jsx)(Ju,{className:`no-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:P.map(e=>(0,X.jsxs)(`div`,{className:`mx-2 border-t border-border py-1 first:border-t-0`,children:[e.name!==``&&(0,X.jsx)(`div`,{className:K(`truncate px-3 pb-0.5 pt-1.5 text-2xs font-medium uppercase tracking-wide`,_e(e.colour)?K(_e(e.colour),`opacity-70`):`text-fg-muted`),children:e.name}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-0.5 compact:gap-0`,children:e.sessions.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Xm,{session:e,activeSessionId:i,accountLabel:T,onArchived:c,ellipsis:!0,lastActive:!0})},e.id))})]},e.projectId))})]})]})]})}function $m({className:e}){return(0,X.jsx)(`svg`,{viewBox:`0 0 2000 2000`,fill:`none`,"aria-hidden":`true`,className:e,children:(0,X.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:110,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,X.jsx)(`line`,{x1:`491.66`,y1:`1916.78`,x2:`1558.47`,y2:`83.22`}),(0,X.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,X.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,X.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 eh=[`running`,`waiting_input`];function th({sessionId:e,status:t}){let n=eh.includes(t),{data:r}=S(e,n),i=r?.vars??[];if(!n||i.length===0)return null;let a=async(e,t)=>{try{await navigator.clipboard.writeText(t),V.success(`${e} value copied`)}catch{V.error(`Couldn't copy ${e} value`)}};return(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3 font-mono text-xs`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:`env`}),(0,X.jsx)(`div`,{className:`no-scrollbar min-w-0 flex-1 overflow-x-auto`,children:(0,X.jsx)(`div`,{className:`flex w-max items-center gap-1 whitespace-nowrap`,children:i.map(e=>{let t=e.value;return(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:t===void 0?(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-fg-secondary`,children:e.name}):(0,X.jsx)(`button`,{type:`button`,"aria-label":`Copy ${e.name} environment variable value`,onClick:()=>void a(e.name,t),className:`cursor-pointer rounded px-1.5 py-0.5 text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,children:e.name})}),(0,X.jsxs)(U,{children:[e.bytes,` B ·`,` `,t===void 0?`value unavailable from this daemon`:`click to copy value`]})]},e.name)})})})]})}function nh(e,t,n){return`ssh -L ${e}:127.0.0.1:${e} ${t}@${n}`}var rh=[`running`,`waiting_input`];function ih({sessionId:e,status:t}){let n=rh.includes(t),{data:r}=h(e,n),i=r?.ports??[];return!n||i.length===0?null:(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3 text-xs`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:`ports`}),(0,X.jsx)(`div`,{className:`no-scrollbar min-w-0 flex-1 overflow-x-auto`,children:(0,X.jsx)(`div`,{className:`flex w-max items-center gap-1 whitespace-nowrap`,children:i.map(t=>(0,X.jsx)(ah,{sessionId:e,port:t},t.port))})})]})}function ah({sessionId:e,port:t}){let n=ee().data;return(0,X.jsxs)(yt,{children:[(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(Tt,{asChild:!0,children:(0,X.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,X.jsxs)(U,{children:[t.command,` · pid `,t.pid]})]}),(0,X.jsxs)(lt,{align:`start`,children:[Dr()===null?(0,X.jsx)(tt,{asChild:!0,children:(0,X.jsx)(`a`,{href:`http://localhost:${t.port}`,target:`_blank`,rel:`noopener noreferrer`,children:`Open localhost`})}):(0,X.jsx)(tt,{onSelect:()=>{Re(`/forward/${e}/${t.port}`).catch(Ir)},children:`Open via proxy`}),(0,X.jsx)(tt,{onSelect:()=>{n&&navigator.clipboard.writeText(nh(t.port,n.username,n.hostname)).then(()=>V.success(`Copied`))},children:`Copy ssh -L`})]})]})}var oh=[`interrupted`,`exited`];function sh({session:e}){let t=w(`resume`),n=Lt();return oh.includes(e.status)&&!e.worktree_missing&&!e.conversation_missing?(0,X.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 right-3 z-10`,children:(0,X.jsxs)(J,{size:`sm`,className:`pointer-events-auto`,disabled:t.isPending,onClick:()=>t.mutate(e.id,{onError:e=>{let t=Fr(e);t?n(`/project/${t.projectId}/session/${t.sessionId}`):Ir(e)}}),children:[(0,X.jsx)(bt,{}),`Resume`]})}):null}function ch(e,t,n){if(e.kind===`untitled`||t===void 0)return e.path;let r=Fo(t,e.path);return n?Io(n,r)??r:r}function lh({tab:e,directory:t,onReveal:n,onCompilationSettings:r,onRename:i,editing:a,children:o}){let s=ee(),c=l().data?.protocol,u=Pl(),d=Jl(e.session,e.root,t),f=(0,Z.useMemo)(()=>({sid:e.session,root:e.root,directory:t,host:El(s.data)}),[e.session,e.root,t,s.data]),p=e.root!==void 0&&!te(c),m=u!==null&&Ol(u.source,f),h=u!==null&&Dl(u.source,f),_=!p&&(m&&h||u!==null&&kl(u.source,f)&&g(c)),[v,y]=(0,Z.useState)(!1),b=Fo(t,e.path),x=()=>{!u||!_||d.paste(u,jo(e.path)).then(e=>{u.mode===`cut`&&jl(u.id,e)})},S=t=>{navigator.clipboard.writeText(t?e.path:b),V.success(t?`Relative path copied`:`Path copied`)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Xn,{children:[(0,X.jsx)(Un,{asChild:!0,children:o}),(0,X.jsx)(qn,{onCloseAutoFocus:e=>{a&&e.preventDefault()},children:(0,X.jsx)(su,{absolutePath:b,readOnly:p,canPaste:_,onCut:()=>Al([e.path],`cut`,f),onCopy:()=>Al([e.path],`copy`,f),onPaste:x,onCopyPath:()=>S(!1),onCopyRelativePath:()=>S(!0),onReveal:n,onCompilationSettings:r,onRename:i,onDelete:()=>y(!0),onDownload:()=>{Xe(e.session,e.path,e.root).catch(e=>V.error(e instanceof Error?e.message:`Download failed`))}})})]}),(0,X.jsx)(Gt,{open:v,onOpenChange:y,children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(Ht,{children:[(0,X.jsxs)(Wt,{children:[`Delete “`,Ao(e.path),`”?`]}),(0,X.jsxs)(Vt,{children:[`This permanently removes it from `,t,`. There is no undo.`]})]}),(0,X.jsxs)(Bt,{children:[(0,X.jsx)(J,{variant:`ghost`,onClick:()=>y(!1),children:`Cancel`}),(0,X.jsx)(J,{variant:`danger`,onClick:()=>{y(!1),d.remove([e.path])},children:`Delete`})]})]})})]})}var uh=`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg disabled:cursor-not-allowed disabled:opacity-50 group-hover:inline-flex pointer-coarse:inline-flex`;function dh({session:e,onArchived:t}){let n=e.status===`starting`||e.status===`running`||e.status===`waiting_input`,r=w(n?`kill`:`resume`),i=c(),a=Lt(),o=r.isPending||i.isPending,s=e.worktree_missing?`Worktree directory is gone — resume unavailable`:e.conversation_missing?`Native conversation is missing — resume unavailable`:void 0;return e.status===`archived`?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:o||!n&&!!s,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:async t=>{t.stopPropagation();try{await r.mutateAsync(e.id)}catch(e){let t=!n&&Fr(e);t?a(`/project/${t.projectId}/session/${t.sessionId}`):Ir(e)}},className:uh,"aria-label":n?`Stop session`:`Resume session`,title:n?`Stop session`:s??`Resume session`,children:n?(0,X.jsx)(mt,{className:`size-3`}):(0,X.jsx)(bt,{className:`size-3`})}),!n&&(0,X.jsx)(`button`,{type:`button`,disabled:o,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:async n=>{n.stopPropagation();try{await i.mutateAsync(e.id),t(e.id)}catch(e){Ir(e)}},className:uh,"aria-label":`Archive session`,title:`Archive session`,children:(0,X.jsx)(Zn,{className:`size-3`})})]})}var fh=`group relative flex min-w-[calc(var(--spacing)*28.8)] max-w-52 cursor-pointer select-none items-center gap-1.5 rounded-[var(--ui-radius)] px-2.5 text-xs transition-colors`,ph=`group-hover:[transform:translateX(var(--tail))]`;function mh({leaf:e,filetreeRoot:t,sessions:n,onActivate:r,onClose:i,onPromote:a,onArchived:o,onSetView:s,compilableExtensions:c,compilationProviders:l,compilationRunningKeys:u,onRunCompilation:d,onSetCompilationMode:f,onOpenCompilationSettings:p,onNewFile:m,onRevealFile:h,onRenameFile:g}){let _=e.tabs.length===1,v=new Map(n.map(e=>[e.id,e.branch])),y=new Map(n.map(e=>[e.id,e.worktree_path])),b=e.tabs.flatMap(e=>e.type===`editor`?[e.tab]:[]),x=Tm(),S=Rp({id:`pane:${e.id}`,data:{paneId:e.id,tabCount:e.tabs.length}}),C=x?.leafId===e.id&&x.index!==void 0?x.index:null,{setNodeRef:w}=Hp({id:`strip:${e.id}`,data:{leafId:e.id,count:e.tabs.length}}),T=e=>{let t=Hr(e.path,e.session,b,v,e.root,y);return kr(e)===`diff`?`${t} (diff)`:kr(e)===`commit`?`${t} @${(e.sha??``).slice(0,7)}`:t};return(0,X.jsxs)(`div`,{ref:e=>{w(e),S.setNodeRef(e)},"data-pane-drag-handle":e.id,onPointerDown:e=>{e.target===e.currentTarget&&S.listeners?.onPointerDown?.(e)},"data-pane-single-edge":_||void 0,className:_?`pane-single-tab-edge cursor-grab`:`flex h-[var(--ui-tab-strip-height)] shrink-0 cursor-grab items-stretch gap-1 overflow-x-auto bg-surface p-1 active:cursor-grabbing`,onDoubleClick:e=>{e.target===e.currentTarget&&m()},children:[e.tabs.map((m,v)=>(0,X.jsxs)(Z.Fragment,{children:[C===v&&(0,X.jsx)(hh,{}),(0,X.jsx)(Sh,{tab:m,single:_,filetreeRoot:t,leafId:e.id,index:v,active:H(m)===e.activeKey,preview:H(m)===e.previewKey,session:m.type===`terminal`?n.find(e=>e.id===m.session):void 0,fileSession:m.type===`editor`&&m.tab.root===void 0?n.find(e=>e.id===m.tab.session):void 0,fileDirectory:m.type===`editor`&&(kr(m.tab)===`file`||kr(m.tab)===`external`)?m.tab.root??n.find(e=>e.id===m.tab.session)?.worktree_path:void 0,label:m.type===`editor`?T(m.tab):``,onActivate:()=>r(m),onClose:()=>i(m),onPromote:()=>a(m),onArchived:o,onSetView:e=>s(m,e),compilable:Wo(m.type===`editor`?m.tab.path:``,c),provider:m.type===`editor`?l.find(e=>e.extensions.includes(Uo(m.tab.path)??``)):void 0,compilationRunning:m.type===`editor`&&u.has(Go(m.tab.session,m.tab.path,m.tab.root)),onRunCompilation:()=>{m.type===`editor`&&(r(m),requestAnimationFrame(()=>d(m.tab)))},onSetCompilationMode:e=>{m.type===`editor`&&(r(m),requestAnimationFrame(()=>f(m.tab,e)))},onOpenCompilationSettings:m.type===`editor`&&p?()=>p({session:m.tab.session,path:m.tab.path,...m.tab.root===void 0?{}:{root:m.tab.root}}):void 0,onRevealFile:()=>m.type===`editor`&&h(m.tab),onRenameFile:e=>m.type===`editor`?g(m.tab,e):Promise.resolve(!1)})]},H(m))),C===e.tabs.length&&(0,X.jsx)(hh,{})]})}function hh(){return(0,X.jsx)(`div`,{className:`w-0.5 shrink-0 self-stretch rounded-full bg-accent`})}function gh({children:e}){let t=(0,Z.useRef)(null);return(0,X.jsxs)(`span`,{ref:t,className:`pane-tab-controls sliding-hover-tray island-outline pointer-events-none absolute right-1 top-1/2 z-10 flex -translate-y-1/2 items-center gap-1 rounded-full bg-elevated px-1 py-1 shadow-sm opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 focus-within:pointer-events-auto focus-within:opacity-100 pointer-coarse:pointer-events-auto pointer-coarse:opacity-100 [&_button]:size-5 [&_button]:items-center [&_button]:justify-center [&_button]:rounded-full`,children:[(0,X.jsx)(`span`,{ref:Nr(t),"aria-hidden":!0,className:`tray-hover-surface`}),e]})}var _h={source:`preview`,preview:`linked`,linked:`locked`,locked:`source`},vh={source:ii,preview:hr,linked:fi,locked:hi},yh={source:`Source — switch to preview`,preview:`Preview — switch to linked preview`,linked:`Linked preview — switch to locked preview`,locked:`Locked preview — switch to source`};function bh({view:e,notebook:t=!1,onSetView:n}){let r=vh[e],i=t?e===`source`?`Show notebook`:`Show JSON source`:yh[e];return(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:(0,X.jsx)(`button`,{onClick:r=>{r.stopPropagation(),n(t?e===`source`?`preview`:`source`:_h[e])},className:`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg group-hover:inline-flex group-focus-within:inline-flex pointer-coarse:inline-flex`,"aria-label":i,children:(0,X.jsx)(r,{className:`size-3`})})}),(0,X.jsx)(U,{side:`bottom`,collisionPadding:8,children:i})]})}function xh({mode:e,running:t,onRun:n,onSetMode:r,provider:i}){let a=e===`eager`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:t,onClick:e=>{e.stopPropagation(),n()},className:K(`hidden rounded-sm p-0.5 transition-colors hover:text-fg disabled:cursor-wait group-hover:inline-flex group-focus-within:inline-flex pointer-coarse:inline-flex`,a?`text-fg-muted`:`text-accent`),"aria-label":i?.terminal?`Run in terminal`:i?.action===`run`?`Run file`:`Compile on demand`,title:i?.terminal?`Run in terminal`:i?.action===`run`?`Run file`:`Compile on demand`,children:t&&!a?(0,X.jsx)(mi,{className:`size-3 animate-spin`}):(0,X.jsx)(bt,{className:`size-3`})}),i?.eager&&(0,X.jsx)(`button`,{type:`button`,disabled:t,onClick:e=>{e.stopPropagation(),r(a?`on_demand`:`eager`)},className:K(`hidden rounded-sm p-0.5 transition-colors hover:text-fg disabled:cursor-wait group-hover:inline-flex group-focus-within:inline-flex pointer-coarse:inline-flex`,a?`text-accent`:`text-fg-muted`),"aria-label":a?`Disable eager compilation`:`Enable eager compilation`,title:a?`Eager compilation — switch to on demand`:`Compile eagerly on disk changes`,children:t&&a?(0,X.jsx)(mi,{className:`size-3 animate-spin`}):(0,X.jsx)(nr,{className:`size-3`})})]})}function Sh({tab:e,single:t,filetreeRoot:n,leafId:r,index:i,active:a,preview:o,session:s,fileSession:c,fileDirectory:l,label:u,onActivate:d,onClose:f,onPromote:p,onArchived:m,onSetView:h,compilable:g,provider:_,compilationRunning:v,onRunCompilation:y,onSetCompilationMode:b,onOpenCompilationSettings:x,onRevealFile:S,onRenameFile:C}){let[w,T]=(0,Z.useState)(!1),E=vn(),D=H(e),{attributes:O,listeners:k,setNodeRef:A,isDragging:ee}=Rp({id:`drag:${r}:${D}`,data:{ref:e,fromLeafId:r}}),{setNodeRef:j}=Hp({id:`tabdrop:${r}:${D}`,data:{leafId:r,index:i}}),M=e=>{A(e),j(e)},N=K(t?`pane-single-tab group relative flex h-2 w-full cursor-grab items-center text-xs`:fh,!t&&(a?`bg-ground text-fg`:`text-fg-secondary hover:bg-elevated`),o&&`italic`,ee&&`opacity-40`),te=(0,X.jsx)(`div`,{ref:M,...w?{}:O,...w?{}:k,onClick:d,onDoubleClick:p,className:K(N,w&&`pane-tab-renaming cursor-text select-text`),"data-pane-tab":D,"aria-label":t?e.type===`editor`?ch(e.tab,l,n):s?E(s):e.session:void 0,children:e.type===`terminal`?(0,X.jsxs)(X.Fragment,{children:[s&&(0,X.jsx)(tm,{status:s.status,kind:s.kind,agentType:s.agent_type,detectedAgentType:s.detected_agent_type,stale:s.stale_running}),(0,X.jsx)(`span`,{className:`truncate`,children:s?E(s):e.session.slice(0,8)}),(0,X.jsxs)(gh,{children:[s&&(0,X.jsx)(dh,{session:s,onArchived:m}),(0,X.jsx)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),f()},className:`hidden rounded-sm p-0.5 text-fg-muted transition-colors hover:text-fg group-hover:inline-flex group-focus-within:inline-flex pointer-coarse:inline-flex`,"aria-label":`Close tab`,children:(0,X.jsx)(Kt,{className:`size-3`})})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Hc,{name:kr(e.tab)===`untitled`?u:e.tab.path.split(`/`).pop()??e.tab.path,className:`size-4`}),w?(0,X.jsx)(Ch,{initial:e.tab.path.split(`/`).pop()??e.tab.path,onCommit:C,onCancel:()=>T(!1),onCommitted:()=>T(!1)}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(bc,{text:u,hoverClass:ph,containerClassName:`flex-[0_1_auto]`,className:(kr(e.tab)===`file`||kr(e.tab)===`external`)&&(Or(e.tab.path)!==null||g)?`-mr-20 pr-20`:`-mr-11 pr-11`}),(0,X.jsx)(fs,{session:e.tab.session,path:e.tab.path,kind:kr(e.tab),root:e.tab.root}),(0,X.jsxs)(gh,{children:[(kr(e.tab)===`file`||kr(e.tab)===`external`)&&Or(e.tab.path)!==null&&(0,X.jsx)(bh,{notebook:Or(e.tab.path)===`notebook`,view:e.tab.view??`source`,onSetView:h}),(kr(e.tab)===`file`||kr(e.tab)===`external`)&&g&&!e.tab.generated_by&&(0,X.jsx)(xh,{provider:_,mode:e.tab.compile_mode??`on_demand`,running:v,onRun:y,onSetMode:b}),(0,X.jsx)(ms,{session:e.tab.session,path:e.tab.path,kind:kr(e.tab),root:e.tab.root,label:u,onClose:f})]})]})]})}),P=(0,X.jsx)(U,{side:`bottom`,className:`max-w-[calc(100vw-2rem)] break-all`,children:(0,X.jsx)(Fu,{name:e.type===`terminal`?s?E(s):e.session:t?ch(e.tab,l,n):u,session:e.type===`terminal`?s:c})});return e.type===`terminal`&&s?(0,X.jsxs)(W,{children:[(0,X.jsx)(fm,{session:s,onArchived:()=>m(e.session),children:(0,X.jsx)(G,{asChild:!0,children:te})}),P]}):e.type===`editor`&&l!==void 0&&(kr(e.tab)===`file`||kr(e.tab)===`external`)?(0,X.jsxs)(W,{open:!w&&void 0,children:[(0,X.jsx)(lh,{tab:e.tab,directory:l,onReveal:S,onCompilationSettings:g?x:void 0,onRename:()=>T(!0),editing:w,children:(0,X.jsx)(G,{asChild:!0,children:te})}),P]}):(0,X.jsxs)(W,{children:[(0,X.jsx)(G,{asChild:!0,children:te}),P]})}function Ch({initial:e,onCommit:t,onCommitted:n,onCancel:r}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let t=i.current;if(!t)return;let n=()=>{t.focus();let n=e.lastIndexOf(`.`);t.setSelectionRange(0,n>0?n:e.length)};n();let r=requestAnimationFrame(()=>{document.activeElement!==t&&n()});return()=>cancelAnimationFrame(r)},[e]);let o=()=>{a.current||(a.current=!0,t(i.current?.value??``).then(e=>{if(e){n();return}a.current=!1,requestAnimationFrame(()=>i.current?.focus())}))};return(0,X.jsx)(`input`,{ref:i,defaultValue:e,spellCheck:!1,"aria-label":`Rename ${e}`,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?o():e.key===`Escape`&&(a.current=!0,r())},onBlur:o,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none`,style:{width:`${Math.max(8,Math.min(e.length,24))}ch`}})}function wh(e,t,n){return{focus:e===`press`,driveScroll:t&&n!==`linked`}}function Th({leaf:e,filetreeRoot:t,sessions:n,reveal:r,onActivateTab:i,onCloseTab:a,onPromoteTab:o,onArchived:s,onFocusLeaf:c,onScrollDrive:l,onDropTab:u,onSetTabView:d,compilableExtensions:f,compilationProviders:p,compilationRunningKeys:m,onRunCompilation:h,onSetCompilationMode:g,onOpenCompilationSettings:_,onRevealPreviewSource:v,onRevealCompiledSource:y,onNewUntitled:b,onRevealFile:x,onRenameFile:S,focused:C,scrollDriver:w,scrollChannel:T}){let E=e.tabs.find(t=>H(t)===e.activeKey)??null,D=E?.type===`terminal`?H(E):null,O=E?.type===`terminal`?n.find(e=>e.id===E.session)??null:null,k=_s(D),{setNodeRef:A}=Hp({id:`leaf:${e.id}`}),ee=Tm(),j=Om(),M=Ie(`palette.toggle`),N=E?.type===`editor`?E.tab:null,te=N?.view??`source`,P=N!==null&&(kr(N)===`file`||kr(N)===`external`)&&Or(N.path)!==null,ne=w&&P&&te!==`linked`,re=!ne&&(te===`locked`||P&&te===`source`),ie=t=>{let n=wh(t,P,te);n.focus&&c(e.id),n.driveScroll&&l(e.id)},ae=(0,Z.useRef)(null),oe=(0,Z.useRef)(()=>void 0);oe.current=()=>{E&&i(e.id,E)},(0,Z.useEffect)(()=>{let e=ae.current;if(!e)return;let t=()=>oe.current();return e.addEventListener(`mousedown`,t,!0),()=>e.removeEventListener(`mousedown`,t,!0)},[]);let[se,ce]=(0,Z.useState)(null),F=(0,Z.useRef)(u);return F.current=u,(0,Z.useEffect)(()=>{let t=ae.current;if(!t)return;let n=e=>e.dataTransfer!==null&&iu(e.dataTransfer.types),r=e=>{let n=t.getBoundingClientRect();return Sm({width:n.width,height:n.height},{x:e.clientX-n.left,y:e.clientY-n.top})},i=e=>{n(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),ce(r(e)))},a=e=>{t.contains(e.relatedTarget)||ce(null)},o=t=>{if(!n(t))return;t.preventDefault(),t.stopPropagation(),ce(null);let i=ru(t.dataTransfer?.getData(`application/x-puddle-tab`)??``);i&&F.current(e.id,i,r(t))},s=()=>ce(null);return t.addEventListener(`dragenter`,i,!0),t.addEventListener(`dragover`,i,!0),t.addEventListener(`dragleave`,a,!0),t.addEventListener(`drop`,o,!0),window.addEventListener(`dragend`,s),()=>{t.removeEventListener(`dragenter`,i,!0),t.removeEventListener(`dragover`,i,!0),t.removeEventListener(`dragleave`,a,!0),t.removeEventListener(`drop`,o,!0),window.removeEventListener(`dragend`,s)}},[e.id]),(0,X.jsxs)(`div`,{className:`workspace-surface island-outline relative flex h-full flex-col bg-surface`,"data-single-tab":e.tabs.length===1||void 0,onMouseDownCapture:()=>ie(`press`),onWheelCapture:()=>ie(`scroll`),children:[e.tabs.length>0&&(0,X.jsx)(mh,{leaf:e,filetreeRoot:t,sessions:n,onActivate:t=>i(e.id,t),onClose:t=>a(e.id,t),onPromote:o,onArchived:s,onSetView:(t,n)=>d(e.id,t,n),compilableExtensions:f,compilationProviders:p,compilationRunningKeys:m,onRunCompilation:t=>h(e.id,t),onSetCompilationMode:g,onOpenCompilationSettings:_,onNewFile:()=>b(e),onRevealFile:x,onRenameFile:S}),(0,X.jsxs)(`div`,{ref:e=>{ae.current=e,A(e)},"data-editor-surface":E?.type===`editor`||void 0,className:K(`relative min-h-0 flex-1`,e.tabs.length===1&&`mt-1`,E&&`mx-1 mb-1 overflow-hidden rounded-[var(--ui-radius)] bg-ground`),children:[E?.type===`editor`&&(0,X.jsx)(`div`,{className:`absolute inset-1 overflow-hidden rounded-[var(--ui-radius)]`,children:(0,X.jsx)(Rr.Provider,{value:JSON.stringify([T,e.id,H(E)]),children:(0,X.jsx)(cs,{tab:E.tab,onRunCompilation:f.has(Uo(E.tab.path)??``)?t=>h(e.id,E.tab,t):void 0,compilationRunning:m.has(Go(E.tab.session,E.tab.path,E.tab.root)),reveal:r,focused:C,scrollDriver:ne,scrollReceiver:re,scrollChannel:T,onRevealSource:N?.view===`linked`||N?.view===`locked`?t=>v(e.id,N,t):void 0,onRevealCompiledSource:t=>y(e.id,t)})})}),(0,X.jsx)(`div`,{ref:k,className:K(`absolute inset-0 py-1 pl-4 pr-2`,!D&&`hidden`)}),j&&(0,X.jsx)(`div`,{className:`absolute inset-0 z-10 cursor-grabbing`,"aria-hidden":`true`}),ee?.leafId===e.id&&ee.index===void 0&&(0,X.jsx)(Dh,{zone:ee.zone}),se!==null&&(0,X.jsx)(Dh,{zone:se}),O&&(0,X.jsx)(sh,{session:O}),!E&&(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-6 text-center`,children:[(0,X.jsx)($m,{className:`size-24 text-fg-muted/40`}),(0,X.jsx)(`button`,{type:`button`,onClick:$t,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:M})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 pb-1 empty:hidden`,children:[O&&(0,X.jsx)(th,{sessionId:O.id,status:O.status}),O&&(0,X.jsx)(ih,{sessionId:O.id,status:O.status})]})]})}var Eh={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 Dh({zone:e}){return(0,X.jsx)(`div`,{className:K(`pointer-events-none absolute z-20 bg-accent/20`,Eh[e])})}function Oh({tree:e,...t}){let n=(0,Z.useMemo)(()=>{let t=new Set,n=[];for(let r of rn(e)){if(r.type!==`editor`||![`file`,`diff`,`external`].includes(kr(r.tab)))continue;let e=`${r.tab.session}\0${r.tab.path}\0${r.tab.root??``}`;t.has(e)||(t.add(e),n.push({session:r.tab.session,path:r.tab.path,root:r.tab.root}))}return n},[e]);return(0,X.jsxs)(X.Fragment,{children:[n.length>0&&(0,X.jsx)(us,{buffers:n}),(0,X.jsx)(kh,{node:e,...t})]})}function kh({node:e,...t}){if(e.kind===`leaf`)return(0,X.jsx)(Th,{leaf:e,filetreeRoot:t.filetreeRoot,sessions:t.sessions,reveal:t.reveal,onActivateTab:t.onActivateTab,onCloseTab:t.onCloseTab,onPromoteTab:t.onPromoteTab,onArchived:t.onArchived,onFocusLeaf:t.onFocusLeaf,onScrollDrive:t.onScrollDrive,onDropTab:t.onDropTab,onSetTabView:t.onSetTabView,compilableExtensions:t.compilableExtensions,compilationProviders:t.compilationProviders,compilationRunningKeys:t.compilationRunningKeys,onRunCompilation:t.onRunCompilation,onSetCompilationMode:t.onSetCompilationMode,onOpenCompilationSettings:t.onOpenCompilationSettings,onRevealPreviewSource:t.onRevealPreviewSource,onRevealCompiledSource:t.onRevealCompiledSource,onNewUntitled:t.onNewUntitled,onRevealFile:t.onRevealFile,onRenameFile:t.onRenameFile,focused:e.id===t.focusedLeafId,scrollDriver:e.id===t.scrollDriverLeafId,scrollChannel:t.scrollChannel});let n=e.direction===`row`?`horizontal`:`vertical`;return(0,X.jsx)(xo,{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,X.jsxs)(Z.Fragment,{children:[r>0&&(0,X.jsx)(ko,{className:n===`horizontal`?`workspace-divider-vertical`:`workspace-divider-horizontal`}),(0,X.jsx)(wo,{id:e.id,minSize:64,children:(0,X.jsx)(kh,{node:e,...t})})]},e.id))},e.id)}function Ah(e,t){return e.session===t.session&&e.path===t.path&&(e.root??``)===(t.root??``)&&kr(e)===kr(t)}function jh(e,t=`profile`){let n=e.snapshot,r=(0,Z.useRef)(null),i=(0,Z.useRef)(null),a=(0,Z.useRef)(t),o=(0,Z.useRef)(!1);a.current!==t&&(a.current=t,r.current=null,i.current=null,o.current=!1),!n.layout_tree&&!r.current&&(r.current=Sn(n));let s=n.layout_tree??r.current??en([]),c=(0,Z.useMemo)(()=>hn(s),[s]),l=(0,Z.useCallback)(t=>e.update({layout_tree:t}),[e]),u=(0,Z.useRef)(l);u.current=l,(0,Z.useEffect)(()=>{o.current||e.loaded&&!n.layout_tree&&r.current&&(o.current=!0,rn(r.current).length>0&&u.current(r.current))},[e.loaded,n.layout_tree]),(0,Z.useEffect)(()=>{e.loaded&&c!==s&&n.layout_tree&&u.current(c)},[e.loaded,c,s,n.layout_tree]);let[d,f]=(0,Z.useState)(null),p=(d?gn(c,d):null)??Ln(c)[0]??en([]),m=p.tabs.find(e=>H(e)===p.activeKey)??null,h=m?.type===`editor`?m.tab:null,g=(e,t)=>{let n=On(t);n&&(i.current={leafId:e,target:n})};return(0,Z.useMemo)(()=>({tree:c,focusedLeaf:p,activeEditorTab:h,focusLeaf:e=>f(e),activate:(e,t)=>{f(e),g(e,t);let n=H(t),r=gn(c,e)?.activeKey===n,i=sn(r?c:nn(c,e,n),t);r&&i===c||l(i)},close:(e,t)=>{let n=zn(c,e,H(t)),r=gn(n,e),i=r?.tabs.find(e=>H(e)===r.activeKey);i&&g(e,i),l(i?sn(n,i):n)},openEditor:(e,t)=>{let n=p.id;f(n);let r={type:`editor`,tab:e};g(n,r);let i=t?.preview?Dn(c,n,r):bn(c,n,r);l(sn(i,r))},openEditorInLeaf:(e,t,n)=>{let r={type:`editor`,tab:t},i=H(r),a=n?.activate??!0,o=n?.dedupeAcrossTree?dn(c,i):null;if(o){let e=_n(c,o.id,r);return a&&(f(o.id),e=nn(e,o.id,i)),o.previewKey===i&&(e=ln(e,i)),e!==c&&l(e),o.id}let s=gn(c,e)?.id??p.id;return a?(f(s),g(s,r),l(sn(bn(c,s,r),r))):l(wn(c,s,r)),s},setCompileMode:(e,t)=>{let n=cn(c,e,t);n!==c&&l(n)},ensureTerminal:(e,t)=>{let n=`term:${e}`,r=dn(c,n);if(r){f(r.id);let e=r.activeKey!==n,i=!t?.preview&&r.previewKey===n;if(e||i){let t=c;e&&(t=nn(t,r.id,n)),i&&(t=ln(t,n)),l(t)}}else{let n=p.id;f(n);let r={type:`terminal`,session:e};l(t?.preview?Dn(c,n,r):bn(c,n,r))}},promote:e=>l(ln(c,H(e))),setView:(e,t,n)=>{g(e,t);let r=mn(c,e,H(t),n),i=gn(r,e),a=i?.tabs.find(e=>H(e)===i.activeKey);l(a?sn(r,a):r)},revealSource:(e,t)=>{let n=i.current,r=n&&Ah(n.target,t)?n:null,a=r&&Vn(c,t,r.leafId)?r.leafId:void 0,o=Vn(c,t,a);if(o){f(o.leafId);let e=mn(c,o.leafId,H(o.ref),`source`);return e=nn(e,o.leafId,H(o.ref)),i.current={leafId:o.leafId,target:t},e!==c&&l(e),o.leafId}let s=(r?gn(c,r.leafId):null)?.id??gn(c,e)?.id??p.id,u={type:`editor`,tab:{session:t.session,path:t.path,...t.kind===void 0?{}:{kind:t.kind},...t.root===void 0?{}:{root:t.root},view:`source`}};return f(s),i.current={leafId:s,target:t},l(bn(c,s,u)),s},renameFile:(e,t)=>{let n=fn(c,e,t);n!==c&&l(n)},removeTerminal:t=>{let n=e.current().layout_tree??c,r=dn(n,`term:${t}`);r&&l(zn(n,r.id,`term:${t}`))},pruneSessions:e=>l(un(c,Bn(e))),resize:(e,t)=>l(an(c,e,t)),drop:e=>{f(e.toLeafId),g(e.toLeafId,e.ref),l(sn(Rn(c,e),e.ref))},dropPane:e=>{let t=tn(c,e);t!==c&&(f(e.fromLeafId),l(t))}}),[c,p,h,l])}function Mh(e,t,n){return n>0?`● ${n} waiting — ${e} (${t})`:`${e} — ${t}`}function Nh(){return(0,X.jsx)(jr,{children:(0,X.jsx)(_t,{children:(0,X.jsx)(Ph,{})})})}function Ph(){let e=Pt(),t=Lt(),n=s(),r=e.id??``,o=/^[0-9a-f]{10}$/.test(r),u=e.sid??null,p=Mt(),m=p.state?.notificationSession===u?p.key:null,h=N(o?r:void 0),g=h.data?.project.id===r?h.data:void 0,y=d(h.data?.project.profile_id).data??[],b=vn(),x=Ie(`editor.save`),S=l().data?.protocol,C=f(),w=Wr(T(S)),E=j(S),O=qr(),[k,te]=(0,Z.useState)(null),[ne,ae]=(0,Z.useState)(null),[oe,se]=(0,Z.useState)(()=>new Set),ce=(0,Z.useMemo)(()=>{let e=new Set(oe);return ne&&e.add(ne),e},[oe,ne]),F=(0,Z.useMemo)(()=>w.data?.providers.filter(e=>e.available)??[],[w.data]),le=(0,Z.useMemo)(()=>new Set(F.flatMap(e=>e.extensions.map(e=>e.toLowerCase()))),[F]),de=An(),fe=a(),I=(0,Z.useMemo)(()=>g?.sessions??fe.data?.filter(e=>e.project_id===r)??[],[g,fe.data,r]),L=fe.data??I,pe=Ee(),me=pe.projectBasedLayout,he=pe.showAllProjectSessions,ge=me&&de.snapshot.layout_mode===`project`,R=Pn(de,r,ge),_e=(0,Z.useRef)(de);_e.current=de;let ve=(0,Z.useRef)(fe.data);ve.current=fe.data;let z=h.data?.project.profile_id,xe=v(z),Se=_(z),Ce=P(z??``),we=g?.project??xe.data?.find(e=>e.id===r),Te=(0,Z.useMemo)(()=>Rt((xe.data??(we?[we]:[])).filter(e=>!e.archived),Se.data?.projectOrder??[]),[xe.data,we,Se.data]),ke=(0,Z.useMemo)(()=>{let e=e=>e.status!==`archived`,t=fe.data??I;return Te.map(n=>({projectId:n.id,name:n.name,abbrev:ye(n),colour:n.colour,repoId:n.repo_id,sessions:Rt(t.filter(t=>t.project_id===n.id&&e(t)&&(he||n.id===r)),R.snapshot.session_order)}))},[he,I,r,R.snapshot.session_order,Te,fe.data]),je=(0,Z.useMemo)(()=>ke.flatMap(e=>e.sessions.map(e=>e.id)),[ke]),[Me,Ne]=(0,Z.useState)(()=>new Set),Pe=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{Ne(e=>_m(e,je)),Pe.current!==null&&!je.includes(Pe.current)&&(Pe.current=null)},[je]);let Fe=(0,Z.useCallback)((e,t)=>{Ne(n=>{let r=gm(je,n,Pe.current,e,t);return Pe.current=r.anchor,r.selection})},[je]),Re=(0,Z.useCallback)(e=>{Pe.current=e,Ne(new Set([e]))},[]),ze=(0,Z.useCallback)((e,t)=>{let n=Te.map(e=>e.id),r=Nt(n,e,t);r.some((e,t)=>e!==n[t])&&Ce.mutate({projectOrder:r})},[Te,Ce]),Ve=(0,Z.useMemo)(()=>{let e=e=>Date.parse(e.last_activity_at??e.created_at)||0,t=t=>t.sort((t,n)=>e(n)-e(t)),n=e=>e.status===`archived`;if(ge||!he)return t(I.filter(n));let r=fe.data??I;return Te.flatMap(e=>t(r.filter(t=>t.project_id===e.id&&n(t))))},[he,ge,I,fe.data,Te]),He=(0,Z.useRef)(Te);He.current=Te;let Ue=(0,Z.useRef)(xe.data);Ue.current=xe.data,(0,Z.useEffect)(()=>{let e=_e.current;if(!e.loaded)return;let t=e.current(),n=t.layout_mode??`profile`;if(me&&n!==`project`){if(!fe.data||!xe.data)return;let n=new Map(fe.data.map(e=>[e.id,e.project_id])),i=Cn(t,xe.data.map(e=>e.id),n,r);e.update({...i,project_layouts:xn(i.project_layouts??{},t.project_layouts)})}else!me&&n===`project`&&e.update(kn(t,[r,...He.current.map(e=>e.id)]))},[me,de.loaded,fe.data,xe.data,r]);let We=ge?`project:${r}`:`profile`,B=jh(R,We),[Ge,Ke]=(0,Z.useState)(null),Je=(0,Z.useCallback)(e=>Ke({scopeKey:We,leafId:e}),[We]),Ye=(Ge?.scopeKey===We?gn(B.tree,Ge.leafId):null)?.id??B.focusedLeaf.id;(0,Z.useEffect)(()=>{Je(B.focusedLeaf.id)},[Je,B.focusedLeaf.id,B.focusedLeaf.activeKey]);let Xe=(0,Z.useCallback)(e=>{B.focusLeaf(e),Je(e)},[B,Je]),Qe=de.snapshot.project_layouts,$e=(0,Z.useMemo)(()=>ge?jn(Qe,r):[],[ge,Qe,r]),et=(0,Z.useRef)(B);et.current=B;let tt=(0,Z.useCallback)(e=>{let t=Uo(e.path);return t===null?void 0:F.find(e=>e.extensions.includes(t))},[F]),nt=(0,Z.useCallback)(e=>tt(e)?.id,[tt]),rt=(0,Z.useCallback)(e=>z===void 0?null:{profile_id:z,project_id:L.find(t=>t.id===e)?.project_id??r},[z,r,L]),it=(0,Z.useCallback)(e=>{let t=nt(e),n=rt(e.session);return{source:{session:e.session,path:e.path,...e.root===void 0?{}:{root:e.root}},...t===void 0?{}:{provider:t},...n??{}}},[rt,nt]),at=(0,Z.useCallback)(e=>{if(!E||z===void 0)return;let t=Uo(e.path),n=t===null?void 0:F.find(e=>e.extensions.includes(t)),r=rt(e.session);!n||!r||te({source:e,provider:n.id,...r})},[F,E,rt,z]),lt=(0,Z.useCallback)((e,t,n)=>{let r=t.artifacts.find(e=>e.role===`preview`);r&&(Ct(r.file.session,r.file.path,r.file.root),C.invalidateQueries({queryKey:r.file.root===void 0?[`wt-file`,r.file.session,r.file.path]:[`wt-file`,r.file.session,r.file.path,r.file.root],exact:!0}),et.current.openEditorInLeaf(e,{session:r.file.session,path:r.file.path,...r.file.root===void 0?{kind:`file`}:{kind:`external`,root:r.file.root},generated_by:t.provider,...Or(r.file.path)?{view:`preview`}:{}},{dedupeAcrossTree:!0,activate:n}))},[C]),ut=(0,Z.useCallback)(async(e,n,r=!1)=>{if(!r&&n.path.toLowerCase().endsWith(`.ipynb`)&&ot({session:n.session,path:n.path,...n.root?{root:n.root}:{}})||ne!==null)return;let i=it(n),a=tt(n);if(!a)return;let o=Go(n.session,n.path,n.root);ae(o);try{if(!await Be(i.source,new Set(a.input_extensions))){V.error(`Run cancelled because an input could not be saved`);return}(n.compile_mode??`on_demand`)===`eager`&&(et.current.setCompileMode(n,`on_demand`),await Jr({...i,mode:`on_demand`}));let r=await O.mutateAsync(i);if(qe(Go(r.source.session,r.source.path,r.source.root)),r.terminal){await C.invalidateQueries({queryKey:[`sessions`]}),C.invalidateQueries({queryKey:[`project`,r.terminal.project_id]}),et.current.ensureTerminal(r.terminal.id),t(`/project/${r.terminal.project_id}/session/${r.terminal.id}`);return}lt(e,r,!0),V.success(`${a.action===`run`?`Ran`:`Compiled`} ${Ao(r.source.path)}`)}catch(e){Ko(o,e)}finally{ae(null)}},[ne,tt,it,lt,O,C,t]),dt=(0,Z.useCallback)(async(e,t)=>{let n=e.compile_mode??`on_demand`;if(n===t)return;let r=tt(e);if(!r||t===`eager`&&!r.eager)return;let i=it(e);if(t===`eager`&&!await Be(i.source,new Set(r.input_extensions))){V.error(`Eager compilation was not enabled because an input could not be saved`);return}et.current.setCompileMode(e,t),t===`on_demand`&&Jr({...i,mode:t}).catch(t=>{et.current.setCompileMode(e,n),Ir(t)})},[tt,it]),ft=(0,Z.useMemo)(()=>{let e=new Map;for(let t of Ln(B.tree))for(let n of t.tabs){if(n.type!==`editor`||n.tab.compile_mode!==`eager`||!nt(n.tab)||!tt(n.tab)?.eager)continue;let r=Go(n.tab.session,n.tab.path,n.tab.root);e.has(r)||e.set(r,{leafId:t.id,target:it(n.tab)})}return[...e.entries()].map(([e,t])=>({key:e,...t}))},[B.tree,it,nt,tt]),pt=(0,Z.useCallback)((e,t,n)=>{qe(Go(n.source.session,n.source.path,n.source.root)),lt(t,n,!1)},[lt]),mt=(0,Z.useCallback)((e,t)=>Ko(e,t),[]),ht=(0,Z.useCallback)((e,t)=>{se(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),gt=(0,Z.useRef)(R);gt.current=R;let _t=(0,Z.useCallback)(e=>gt.current.update({session_order:zt(e,gt.current.snapshot.session_order)}),[]),vt=uc(dc),[yt,bt]=(0,Z.useState)(null),[xt,St]=(0,Z.useState)([]),wt=(0,Z.useRef)(vt);wt.current=vt;let[Tt,Et]=(0,Z.useState)(!1),[At,jt]=(0,Z.useState)(!1),[Ft,It]=(0,Z.useState)(null),Kt=Ft===r,[qt,Jt]=(0,Z.useState)(!1),[Yt,Xt]=(0,Z.useState)(`agent`),[Zt,Qt]=(0,Z.useState)(void 0),[$t,en]=(0,Z.useState)(null),tn=(0,Z.useCallback)((e=`agent`,t)=>{Qt(void 0),en(t??null),Xt(e),Jt(!0)},[]),nn=(0,Z.useCallback)((e,t)=>{let n=Te.find(e=>e.id===t);tn(e,n?{projectId:n.id,repoId:n.repo_id}:void 0)},[Te,tn]),an=(0,Z.useRef)(null),sn=(0,Z.useRef)(null),{setHandler:cn}=yn();(0,Z.useEffect)(()=>{!o||!D(S)||i(r).catch(()=>void 0)},[S,r,o]),(0,Z.useEffect)(()=>Lr.onSessionSwitched(e=>{e.source_session===u&&(sn.current={session:e.target_session,pin:!1},e.target_project===r&&et.current.ensureTerminal(e.target_session,{preview:!0}),t(`/project/${e.target_project}/session/${e.target_session}`))}),[u,t,r]);let[ln,dn]=(0,Z.useState)(null),fn=(0,Z.useCallback)((e,t)=>{let n=et.current.openEditorInLeaf(e,{session:t.session,path:t.path,...t.root===void 0?{kind:`file`}:{kind:`external`,root:t.root}},{dedupeAcrossTree:!0});Je(n),dn({session:t.session,path:t.path,...t.root===void 0?{}:{root:t.root},line:t.line,column:t.column,nonce:Date.now()})},[Je]),mn=(0,Z.useCallback)((e,t,n)=>{Je(B.focusedLeaf.id),B.openEditor(e,{preview:n?.preview}),wt.current&&Et(!1),t&&[`file`,`external`].includes(e.kind??`file`)&&dn({session:e.session,path:e.path,...e.root===void 0?{}:{root:e.root},line:t.line,column:t.column,nonce:Date.now()})},[B,Je]),hn=(0,Z.useCallback)((e,t,n,r)=>mn({...r?.root===void 0?{kind:`file`,session:e,path:t}:{kind:`external`,session:e,path:t,root:r.root},...r?.view?{view:r.view}:!n&&Or(t)===`notebook`?{view:`preview`}:{}},n,r),[mn]);ct(hn);let _n=(0,Z.useCallback)((e,t,n)=>{let r=B.revealSource(e,t);Je(r),dn({session:t.session,path:t.path,...t.root===void 0?{}:{root:t.root},line:n.line,column:n.column,nonce:Date.now()})},[B,Je]),[bn,U]=(0,Z.useState)(null),Sn=(0,Z.useRef)(null),[wn,W]=(0,Z.useState)(null),Dn=(0,Z.useCallback)(e=>{Sn.current=e,W(e)},[]),On=(0,Z.useCallback)((e,t,n)=>hn(e,t,void 0,{preview:n?.preview??!0}),[hn]),Mn=(0,Z.useCallback)((e,r)=>{let i=I.find(t=>t.id===e);i&&n.mutate({project_id:i.project_id,kind:`terminal`,separate_branch:!1,separate_worktree:!1,join_worktree:i.worktree_path,cwd:r},{onSuccess:e=>void t(`/project/${e.project_id}/session/${e.id}`),onError:e=>Ir(e)})},[I,n,t]),Nn=(0,Z.useCallback)(e=>B.promote(e),[B]),G=(0,Z.useCallback)((e,t,n,r)=>mn({kind:`external`,session:e,path:t,root:n},void 0,{preview:r?.preview??!0}),[mn]),Fn=re(S),Rn=(0,Z.useCallback)(e=>{if(z!==void 0){if(!Fn){V.error(`Untitled drafts need a newer daemon — refresh the connection to update it`);return}Dt(z).then(({name:e})=>mn({kind:`untitled`,session:ue,path:e})).catch(e=>V.error(e instanceof Error?e.message:`Could not create a draft`))}},[mn,z,Fn]),[zn,Vn]=(0,Z.useState)(null);(0,Z.useEffect)(()=>(Ot(Vn),()=>Ot(null)),[]);let[K,q]=(0,Z.useState)(null),Hn=()=>{let e=K;if(q(null),!e||e.ref.type!==`editor`)return;let t=e.ref.tab.path;z!==void 0&&Ze(z,t).catch(()=>void 0),st(t),B.close(e.leafId,e.ref)},Un=(e,t,n,r)=>{Vn(null);let i={type:`editor`,tab:{kind:`untitled`,session:ue,path:e}},a=H(i);for(let e of Ln(et.current.tree))e.tabs.some(e=>H(e)===a)&&et.current.close(e.id,i);C.invalidateQueries({queryKey:[`wt-tree`,t]}),setTimeout(()=>{et.current.openEditor(r===void 0?{kind:`file`,session:t,path:n}:{kind:`external`,session:t,path:n,root:r})},0)};(0,Z.useEffect)(()=>(cn(e=>{Qt(e?.accountId),Xt(e?.kind??`agent`),Jt(!0)}),()=>cn(null)),[cn]);let[Wn,Gn]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!R.loaded)return;let e=rn(et.current.tree);Promise.all([e.some(e=>e.type===`terminal`)?be():void 0,e.some(e=>e.type===`editor`)?os():void 0]).finally(()=>Gn(!0))},[R.loaded,We]),(0,Z.useEffect)(()=>{if(Kt||!R.loaded||!g)return;It(r);let e=R.snapshot.active_session,n=I.find(t=>t.id===e);!u&&n&&n.status!==`archived`&&t(`/project/${r}/session/${n.id}`,{replace:!0})},[Kt,R,g,I,u,t,r]);let Kn=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(Kn.current||!R.loaded||!fe.data)return;Kn.current=!0;let e=new Set(fe.data.filter(e=>e.status!==`archived`).map(e=>e.id));et.current.pruneSessions(e);let t=_e.current,n=t.current().project_layouts;if(Object.keys(n).length>0){let r=Bn(e);t.update({project_layouts:Object.fromEntries(Object.entries(n).map(([t,n])=>[t,{...n,layout_tree:n.layout_tree?un(n.layout_tree,r):null,active_session:n.active_session!==null&&e.has(n.active_session)?n.active_session:null}]))})}let r=gt.current.snapshot.session_order,i=r.filter(t=>e.has(t));i.length!==r.length&>.current.update({session_order:i})},[R.loaded,fe.data]),(0,Z.useEffect)(()=>{if(!Kt)return;if(wt.current){u&&(bt(u),St(e=>e.includes(u)?e:[...e,u])),jt(!1);return}if(jt(!1),!u){an.current=null;return}if(u===an.current&&!m)return;an.current=null;let e=sn.current;sn.current=null,et.current.ensureTerminal(u,{preview:e?.session!==u||!e.pin});let t=gt.current;t.snapshot.active_session!==u&&t.update({active_session:u})},[Kt,u,m]);let qn=ee();(0,Z.useEffect)(()=>{let e=ie(qn.data)??`Puddle`,t=I.filter(e=>e.status===`waiting_input`).length,n=we?.name??`Puddle`;return document.title=Mh(n,e,t),()=>{document.title=e}},[I,we?.name,qn.data]);let Jn=(0,Z.useCallback)(e=>{let n=u===e;n&&(an.current=e),B.removeTerminal(e),n&&(R.update({active_session:null}),t(`/project/${r}`))},[B,R,u,t,r]),Y=c(),Yn=(0,Z.useCallback)(async e=>{let t=[...new Set(e)],n=await Promise.allSettled(t.map(e=>Y.mutateAsync(e))),r=t.filter((e,t)=>n[t]?.status===`fulfilled`);for(let e of r)Jn(e);r.length>0&&(Ne(e=>{let t=new Set(e);for(let e of r)t.delete(e);return t}),Pe.current!==null&&r.includes(Pe.current)&&(Pe.current=null));let i=n.filter(e=>e.status===`rejected`),a=i[0];i.length===1&&a?Ir(a.reason):i.length>1&&V.error(`Couldn’t archive ${i.length} of ${t.length} sessions`)},[Y,Jn]),Xn={ids:Me,onSelect:Fe,onSelectOnly:Re,onArchive:e=>void Yn(e)},Zn=(0,Z.useCallback)((e,n)=>{if(Je(e),B.activate(e,n),n.type===`terminal`&&n.session!==u){let e=L.find(e=>e.id===n.session)?.project_id;e&&t(`/project/${e}/session/${n.session}`)}},[B,t,L,u,Je]),Qn=(0,Z.useCallback)((e,n)=>{if(n.type===`editor`&&kr(n.tab)===`untitled`){q({leafId:e,ref:n});return}let i=gn(B.tree,e)?.tabs.findIndex(e=>H(e)===H(n))??-1;cc(We,{leafId:e,index:Math.max(0,i),ref:n}),B.close(e,n),n.type===`terminal`&&n.session===u&&(an.current=n.session,R.update({active_session:null}),t(`/project/${r}`))},[B,u,R,t,r,We]),$n=(0,Z.useCallback)(()=>{let e=ve.current,n=e?new Set(e.filter(e=>e.status!==`archived`).map(e=>e.id)):null,r=lc(We,e=>{if(n===null)return!0;let t=e.type===`terminal`?e.session:e.tab.session;return n.has(t)});if(!r)return;let{ref:i}=r,a=gn(B.tree,r.leafId),o=a?r.leafId:B.focusedLeaf.id,s=a?r.index:void 0;if(B.drop({ref:i,fromLeafId:o,toLeafId:o,edge:`center`,index:s}),i.type===`terminal`&&i.session!==u){let e=L.find(e=>e.id===i.session)?.project_id;e&&t(`/project/${e}/session/${i.session}`)}},[B,We,u,L,t]),er=(0,Z.useCallback)((e,n,i)=>{let a=n.type===`terminal`?L.find(e=>e.id===n.session)?.project_id:void 0;if(ge&&a!==void 0&&a!==r&&n.type===`terminal`){sn.current={session:n.session,pin:!0},t(`/project/${a}/session/${n.session}`);return}B.drop({ref:n,fromLeafId:e,toLeafId:e,edge:i,copy:!0}),n.type===`terminal`&&n.session!==u&&a!==void 0&&t(`/project/${a}/session/${n.session}`)},[B,u,L,t,ge,r]),tr=B.focusedLeaf.tabs.find(e=>H(e)===B.focusedLeaf.activeKey)??null,nr=tr===null?null:tr.type===`terminal`?tr.session:tr.tab.session,rr=nr===`00000000-0000-0000-0000-000000000000`?null:nr,ir=A().data?.find(e=>e.id===we?.repo_id),ar=(0,Z.useMemo)(()=>M(S)&&ir&&we?{path:ir.path,projectId:we.id,name:we.name,defaultBranch:ir.default_base_branch}:null,[S,ir,we]),or=ns(L,rr??u,R,ar),sr=or.session,cr=or.root,lr=(0,Z.useCallback)(e=>{let t=L.find(t=>t.id===e.session);if(e.root===void 0&&!t)return;let n=Sn.current??cr??sr?.worktree_path??null,r=rs(e,t?.worktree_path??e.root??``,n);if(wt.current&&Et(!0),R.update({sidebar_mode:`files`,...wt.current?{}:{sidebar_collapsed:!1}}),r.browseRoot!==void 0){let n=t?.id??sr?.id??e.session;U({session:n,root:r.browseRoot,nonce:Date.now()})}else n!==r.directory&&or.pin(e.session);rc({path:r.path,directory:r.directory})},[or,L,cr,sr?.worktree_path,R]),ur=(0,Z.useCallback)(async(e,t)=>{let n=t.trim();if(n===``||n===Ao(e.path))return!0;let r=Po(jo(e.path),n);try{let{rekeyBuffer:t}=await Ae(async()=>{let{rekeyBuffer:e}=await import(`./buffer-store-DIOiWz9q.js`).then(e=>e.n);return{rekeyBuffer:e}},__vite__mapDeps([42,1,2,9,10,11,4,8,5,12,16,17,43,44,45])),n=await kt(e.session,e.path,r,e.root),i=t(e.session,e.path,n.path,e.root);return et.current.renameFile(e,n.path),C.invalidateQueries({queryKey:[`wt-tree`,e.session]}),C.invalidateQueries({queryKey:[`wt-git-status`,e.session]}),setTimeout(()=>{(i?.dirty?Br(e.session,n.path,i.content,i.baseMtimeMs,e.root):Promise.resolve()).then(()=>Vr(e.session,e.path,e.root))},0),!0}catch(e){return Ir(e),!1}},[C]),dr=(0,Z.useCallback)((e,t)=>{if(t.kind===`dir`){wt.current&&Et(!0),R.update({sidebar_mode:`files`,...wt.current?{}:{sidebar_collapsed:!1}}),U({session:e,root:t.path,nonce:Date.now()});return}let n=_r(t,cr);n!==null&&U({session:e,root:n,nonce:Date.now()}),hn(e,t.path,t.line===void 0?void 0:{line:t.line,column:t.column},t.root===void 0?void 0:{root:t.root})},[hn,R,cr]),fr=sr?.id??null,pr=(0,Z.useCallback)(async e=>{if(fr===null)throw Error(`No worktree is available for this project.`);let t=await Sr(fr,e,{root:cr}),n=t.kind===`file`&&t.root===void 0&&cr!==void 0?{...t,root:cr}:t;if(n.kind===`dir`&&n.relativePath!==void 0){wt.current&&Et(!0),R.update({sidebar_mode:`files`,...wt.current?{}:{sidebar_collapsed:!1}}),rc({path:n.relativePath,root:cr,expandTarget:!0});return}dr(fr,n)},[fr,cr,dr]);(0,Z.useEffect)(()=>pn(pr),[pr]);let mr=Vu(R.snapshot.sidebar_mode),hr=R.snapshot.sidebar_collapsed,gr=R.snapshot.sessions_collapsed,[vr,yr]=(0,Z.useState)(!1),br=(0,Z.useCallback)(e=>{let t=B.focusedLeaf,n=t.tabs.find(e=>H(e)===t.activeKey)??null;if(!n||n.type!==`terminal`){V.error(`Focus a terminal or agent to insert`);return}Lr.write(n.session,`agent`,`\x1b[200~${e}\x1b[201~`)},[B]);(0,Z.useEffect)(()=>(on(br),()=>on(null)),[br]);let xr=(0,Z.useCallback)(e=>{let t=_e.current,n=ve.current,i=Ue.current;if(!t.loaded||!n||!i)return!1;let{patch:a,projectBased:o}=En(t.current(),e,{alive:new Set(n.filter(e=>e.status!==`archived`).map(e=>e.id)),sessionProject:new Map(n.map(e=>[e.id,e.project_id])),projectIds:i.map(e=>e.id),currentProject:r});return t.update(a),Oe().projectBasedLayout!==o&&De({projectBasedLayout:o}),!0},[r]),Cr=ge?`project`:`profile`,wr=R.snapshot.layout_tree,Tr=R.snapshot.layout_ref,Er=de.snapshot.project_layouts;(0,Z.useEffect)(()=>{de.loaded&&In({scope:Cr,projectId:r,layoutRef:Tr,signature:Tn(wr),slices:Object.fromEntries(Object.entries(Er).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:Tn(t.layout_tree)}])),capture:()=>{let e=gt.current.current();return{layout_tree:e.layout_tree,active_session:e.active_session}},apply:xr})},[de.loaded,Cr,r,wr,Tr,Er,xr]),(0,Z.useEffect)(()=>()=>In(null),[]);let Dr=(0,Z.useRef)({}),Ar=e=>{let t=B.focusedLeaf;if(t.tabs.length<2)return;let n=t.tabs.findIndex(e=>H(e)===t.activeKey),r=n===-1?e===1?0:t.tabs.length-1:n+e,i=t.tabs[(r+t.tabs.length)%t.tabs.length];i&&Zn(t.id,i)},jr=e=>{vt?(R.update({sidebar_mode:e}),Mi(()=>Et(!0))):R.update({sidebar_mode:e,sidebar_collapsed:!1})};Dr.current={"tab.close":()=>{let e=B.focusedLeaf,t=e.tabs.find(t=>H(t)===e.activeKey);t&&Qn(e.id,t)},"tab.reopen":$n,"tab.newUntitled":()=>Rn(B.focusedLeaf),"tab.next":()=>Ar(1),"tab.prev":()=>Ar(-1),"editor.save":()=>{Zo(B.activeEditorTab)},"sidebar.left":()=>Mi(vt?()=>Et(e=>!e):()=>R.update({sidebar_collapsed:!R.snapshot.sidebar_collapsed})),"sidebar.right":()=>Mi(vt?()=>jt(e=>!e):()=>R.update({sessions_collapsed:!R.snapshot.sessions_collapsed})),"nav.files":()=>jr(`files`),"nav.search":()=>jr(`search`),"nav.changes":()=>jr(`changes`),"nav.worktrees":()=>jr(`worktrees`),"session.newAgent":()=>tn(`agent`),"session.newTerminal":()=>tn(`terminal`)},(0,Z.useEffect)(()=>{let e=Object.keys(Dr.current).map(e=>Le(e,()=>Dr.current[e]?.()));return()=>e.forEach(e=>e())},[]);let Mr=B.activeEditorTab,Nr=Mr?.kind===`diff`&&sr&&Mr.session===sr.id?Mr.path:null,Pr=Mr&&(Mr.kind??`file`)===`file`&&sr&&Mr.session===sr.id?Mr.path:null,Fr=Mr?.kind===`external`&&Mr.root!==void 0?{path:Mr.path,root:Mr.root}:null,Rr=e=>({preview:e?.preview??!0}),zr=(e,t)=>{if(sr){let n=t?.root??cr,r=n===void 0?{}:{root:n};mn({kind:`diff`,session:sr.id,path:e,...r,...t?.gitArea===void 0?{}:{git_area:t.gitArea}},void 0,Rr(t))}},Hr=(e,t,n)=>{if(sr){let r=n?.root??cr,i=r===void 0?{}:{root:r};mn({kind:`commit`,session:sr.id,path:e,sha:t,...i},void 0,Rr(n))}},Ur=(e,t,n)=>{if(!sr)return;let r=t===void 0?void 0:{line:t,column:1};if(cr!==void 0){mn({kind:`external`,session:sr.id,path:e,root:cr},r,Rr(n));return}hn(sr.id,e,r,Rr(n))},Gr=(0,Z.useCallback)(e=>R.update({layout:{...R.snapshot.layout,...e}}),[R]),Kr=fc(R.snapshot.layout,[...hr?[]:[`nav`],`main`,...gr?[]:[`sessions`]]);if(!o)return null;if(!R.loaded||!we||!Wn)return(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-fg-muted`,children:`…`});let Yr=e=>(0,X.jsx)(Uu,{mode:mr,onModeChange:e=>R.update({sidebar_mode:e}),onCollapse:e,projectId:r,repoId:we.repo_id,sessions:I,target:or,browseRequest:bn,onFiletreeRootChange:Dn,compilableExtensions:le,onOpenCompilationSettings:E?at:void 0,onOpenFile:On,onOpenExternalFile:G,onOpenTerminalIn:Mn,activeFilePath:Pr,activeExternalTab:Fr,activeDiffPath:Nr,onOpenDiff:zr,onOpenCommitFile:Hr,onOpenSearchFile:Ur}),Xr={onNewSessionIn:e=>nn(`agent`,e),onNewTerminalIn:e=>nn(`terminal`,e),onMoveProject:ze},Zr=e=>(0,X.jsx)(Zm,{searching:vr,setSearching:yr,groups:ke,accounts:y,activeSessionId:u,onReorder:_t,onPromote:e=>B.ensureTerminal(e),archived:Ve,onNewSession:()=>tn(`agent`),onNewTerminal:()=>tn(`terminal`),onCollapse:e,onArchived:Jn,onArchiveDrop:e=>void Yn(e),selection:Xn,projectActions:Xr}),Qr=I.find(e=>e.id===yt)?.id??I.find(e=>e.id===u)?.id??null,$r=vt?(0,X.jsx)(ec,{sessions:I,selected:Qr,select:e=>{bt(e),St(t=>t.includes(e)?t:[...t,e])}}):(0,X.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[ft.map(({key:e,leafId:t,target:n})=>(0,X.jsx)(Yo,{sourceKey:e,leafId:t,target:n,onResult:pt,onError:mt,onRunningChange:ht},e)),(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(Oh,{tree:B.tree,filetreeRoot:wn??cr??sr?.worktree_path??null,sessions:L,reveal:ln,onActivateTab:Zn,onCloseTab:Qn,onPromoteTab:Nn,onArchived:Jn,onFocusLeaf:Xe,onScrollDrive:Je,onResize:B.resize,onDropTab:er,onSetTabView:B.setView,compilableExtensions:le,compilationProviders:F,compilationRunningKeys:ce,onRunCompilation:(e,t,n)=>void ut(e,t,n),onSetCompilationMode:dt,onOpenCompilationSettings:E?at:void 0,onRevealPreviewSource:_n,onRevealCompiledSource:fn,onNewUntitled:Rn,onRevealFile:lr,onRenameFile:ur,focusedLeafId:B.focusedLeaf.id,scrollDriverLeafId:Ye,scrollChannel:`${z??``}:${We}`})})]});return(0,X.jsx)(gs,{tree:B.tree,parked:[...$e,...xt,...Qr?[Qr]:[]],onOpenFile:dr,children:(0,X.jsx)(Fm,{onDrop:B.drop,onDropPane:B.dropPane,onArchive:e=>void Yn([e]),renderOverlay:e=>{let t=e.type===`terminal`?L.find(t=>t.id===e.session):void 0;return(0,X.jsx)(`div`,{className:`rounded-md bg-elevated px-2.5 py-1 text-xs text-fg shadow-lg`,children:e.type===`terminal`?t?b(t):e.session.slice(0,8):e.tab.path.split(`/`).pop()??e.tab.path})},children:(0,X.jsxs)(`div`,{className:`relative flex h-full min-h-0 gap-[var(--ui-surface-gap)] overflow-hidden p-[var(--ui-surface-gap)]`,children:[vt?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Hu,{mode:mr,onExpand:()=>Mi(()=>Et(!0)),onSelect:e=>{R.update({sidebar_mode:e}),Mi(()=>Et(!0))}}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:$r}),(0,X.jsx)(Ym,{groups:ke,accounts:y,activeSessionId:u,onReorder:_t,onPromote:e=>B.ensureTerminal(e),onExpand:()=>Mi(()=>jt(!0)),onSearch:()=>{yr(!0),Mi(()=>jt(!0))},onNewTerminal:()=>tn(`terminal`),onNewSession:()=>tn(`agent`),onArchived:Jn,onArchiveDrop:e=>void Yn(e),selection:Xn,projectActions:Xr}),Tt&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Close the navigator`,className:`absolute inset-0 z-30 bg-ground/60`,onClick:()=>Mi(()=>Et(!1))}),(0,X.jsx)(`div`,{style:{viewTransitionName:`workspace-navigator`},className:`absolute inset-y-1.5 left-11 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:Yr(()=>Mi(()=>Et(!1)))})]}),At&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Close the session list`,className:`absolute inset-0 z-30 bg-ground/60`,onClick:()=>Mi(()=>jt(!1))}),(0,X.jsx)(`div`,{style:{viewTransitionName:`workspace-sessions`},className:`absolute inset-y-1.5 right-11 z-40 w-[min(20rem,calc(100%-4.5rem))] shadow-xl`,children:Zr(()=>Mi(()=>jt(!1)))})]})]}):(0,X.jsxs)(X.Fragment,{children:[hr&&(0,X.jsx)(`div`,{className:`flex h-full shrink-0`,style:{viewTransitionName:`workspace-navigator`},children:(0,X.jsx)(Hu,{mode:mr,onExpand:()=>Mi(()=>R.update({sidebar_collapsed:!1})),onSelect:e=>Mi(()=>R.update({sidebar_collapsed:!1,sidebar_mode:e}))})}),(0,X.jsxs)(xo,{orientation:`horizontal`,className:`h-full min-w-0 flex-1`,defaultLayout:Kr,onLayoutChanged:Gr,children:[!hr&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(wo,{id:`nav`,defaultSize:280,minSize:200,maxSize:560,style:{viewTransitionName:`workspace-navigator`},children:Yr(()=>Mi(()=>R.update({sidebar_collapsed:!0})))}),(0,X.jsx)(ko,{className:`workspace-divider-vertical`})]}),(0,X.jsx)(wo,{id:`main`,children:(0,X.jsx)(`div`,{"data-sidebar-main":!0,className:`h-full w-full`,children:$r})}),!gr&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ko,{className:`workspace-divider-vertical`}),(0,X.jsx)(wo,{id:`sessions`,defaultSize:260,minSize:180,maxSize:480,style:{viewTransitionName:`workspace-sessions`},children:Zr(()=>Mi(()=>R.update({sessions_collapsed:!0})))})]})]}),gr&&(0,X.jsx)(`div`,{className:`flex h-full shrink-0`,style:{viewTransitionName:`workspace-sessions`},children:(0,X.jsx)(Ym,{groups:ke,accounts:y,activeSessionId:u,onReorder:_t,onPromote:e=>B.ensureTerminal(e),onExpand:()=>Mi(()=>R.update({sessions_collapsed:!1})),onSearch:()=>{yr(!0),Mi(()=>R.update({sessions_collapsed:!1}))},onNewTerminal:()=>tn(`terminal`),onNewSession:()=>tn(`agent`),onArchived:Jn,onArchiveDrop:e=>void Yn(e),selection:Xn,projectActions:Xr})})]}),(0,X.jsx)(Ku,{projectId:$t?.projectId??r,repoId:$t?.repoId??we.repo_id,open:qt,kind:Yt,seedAccountId:Zt,onOpenChange:Jt,onCreated:e=>void t(`/project/${e.project_id}/session/${e.id}`)}),(0,X.jsx)(Qo,{request:zn,targetSession:sr,targetRoot:cr,targetLabel:sr===null?``:cr===void 0?sr.branch:cr,profileId:z,onClose:()=>Vn(null),onSaved:Un}),(0,X.jsx)(Xo,{request:k,onOpenChange:e=>!e&&te(null)}),(0,X.jsx)(Gt,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,X.jsxs)(Ut,{children:[(0,X.jsxs)(Ht,{children:[(0,X.jsx)(Wt,{children:`Discard this draft?`}),(0,X.jsxs)(Vt,{children:[`Closing an untitled tab deletes its draft — `,x,` saves it into the worktree instead.`]})]}),(0,X.jsxs)(Bt,{children:[(0,X.jsx)(J,{variant:`ghost`,onClick:()=>q(null),children:`Keep editing`}),(0,X.jsx)(J,{variant:`danger`,onClick:Hn,children:`Discard`})]})]})})]})})})}export{Nh as Workspace};
|