@mrpatronz/nexusflow 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/core/brand-config.d.ts +24 -0
  2. package/dist/core/brand-config.d.ts.map +1 -1
  3. package/dist/core/brand-config.js +24 -0
  4. package/dist/core/brand-config.js.map +1 -1
  5. package/dist/gui/assets/{AgentsPage-Y1c-bjuA.js → AgentsPage-DV_punfQ.js} +1 -1
  6. package/dist/gui/assets/{DashboardPage-BsIOxFRD.js → DashboardPage-BYZVYud6.js} +1 -1
  7. package/dist/gui/assets/{GettingStartedPage-4aZxBNta.js → GettingStartedPage-Dt8Yvwne.js} +1 -1
  8. package/dist/gui/assets/{MonacoDiffAdapter-BySeTVcR.js → MonacoDiffAdapter-DMJLY8qy.js} +1 -1
  9. package/dist/gui/assets/{ProjectsPage-DG2GUKNr.js → ProjectsPage-Sms4nFOj.js} +1 -1
  10. package/dist/gui/assets/{ScaffoldRepoInline-Ba6O_x1U.js → ScaffoldRepoInline-CKPXlEqf.js} +1 -1
  11. package/dist/gui/assets/{SettingsPage-Bfyjs9me.js → SettingsPage-C4xz97IH.js} +1 -1
  12. package/dist/gui/assets/{SkillsPage-6v38Y90n.js → SkillsPage-BtNxUbSe.js} +1 -1
  13. package/dist/gui/assets/{StartWorkPage-CWsbmJ6A.js → StartWorkPage-CeKMd7LJ.js} +1 -1
  14. package/dist/gui/assets/{StrategiesPage-CjbKoInX.js → StrategiesPage-BqqJPjQ9.js} +1 -1
  15. package/dist/gui/assets/{WorkroomsPage-bDcLMa5h.js → WorkroomsPage-B2zeWWiH.js} +1 -1
  16. package/dist/gui/assets/{WorkspacesPage-ChgMem8T.js → WorkspacesPage-CCt9VzcZ.js} +1 -1
  17. package/dist/gui/assets/{alert-dialog-7Tmml6C4.js → alert-dialog-BLt_CqTk.js} +1 -1
  18. package/dist/gui/assets/{index-CQHHxwAN.js → index-BxUZKLC0.js} +35 -35
  19. package/dist/gui/assets/index-Dv0bQLfl.css +2 -0
  20. package/dist/gui/assets/{tabs-C9XODOED.js → tabs-8D2uSv1C.js} +1 -1
  21. package/dist/gui/favicon-forest.svg +8 -0
  22. package/dist/gui/favicon-glacier.svg +8 -0
  23. package/dist/gui/favicon-nebula.svg +8 -0
  24. package/dist/gui/index.html +10 -4
  25. package/package.json +1 -1
  26. package/dist/gui/assets/index-D836ldaj.css +0 -2
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-DE3RlOCf.js";import{A as r,C as i,F as a,Gn as o,Gt as s,H as c,Ht as l,I as u,J as d,Kn as f,L as p,M as m,Mn as h,N as g,O as _,P as v,R as y,Vn as b,Wt as x,X as S,Xt as C,Y as w,Yn as T,Yt as E,Z as D,_ as O,_n as k,at as A,bn as j,cn as M,g as N,in as P,j as F,k as I,n as L,nn as ee,nt as R,q as z,qn as te,qt as ne,sn as B,t as V,tt as re,v as H,yt as U,z as W}from"./badge-BObbahyU.js";import{$ as ie,A as ae,D as G,E as oe,F as se,G as ce,H as le,I as ue,M as de,R as fe,U as pe,_ as me,a as he,et as ge,i as _e,j as ve,k as ye,m as be,n as xe,r as Se,t as Ce,u as we,v as Te,x as Ee,z as De}from"./queries-DdbBkqm6.js";import{c as Oe,h as K,i as ke,l as Ae,m as q,p as J,t as Y}from"./button-BrcP8Wxx.js";import{t as je}from"./chevron-down-Dy03VL1q.js";import{_ as Me,a as Ne,d as Pe,f as Fe,g as Ie,l as Le,n as Re,o as ze,s as Be,u as Ve,x as He}from"./isElementDisabled-BONWqXlb.js";import{a as Ue,i as We,n as Ge,o as Ke,r as qe,s as Je,t as Ye}from"./square-check-big-DpHMT26q.js";import{a as Xe,g as Ze,i as Qe,m as $e,n as et,r as tt,s as nt}from"./status-CKOvrZ16.js";import{t as rt}from"./shield-check-FLrrAOFP.js";import{n as it,r as at,t as ot}from"./vsc-EOWFTqft.js";import{t as st}from"./trash-2-BrrLX4tD.js";import{a as ct,i as lt,n as ut,r as dt,t as ft}from"./tabs-C9XODOED.js";import{d as pt,o as mt,t as ht}from"./brand-hHByyyzq.js";import{n as X}from"./client-B5szthbF.js";import{$t as gt,A as _t,At as vt,Bt as yt,C as bt,Ct as xt,D as Z,Dt as St,E as Ct,Et as wt,F as Tt,Ft as Et,Gt as Dt,H as Ot,Ht as kt,It as At,Kt as jt,Lt as Mt,M as Nt,Mt as Pt,N as Ft,Nt as It,O as Lt,P as Rt,Qt as zt,Rt as Bt,S as Vt,T as Ht,Tt as Ut,U as Wt,Ut as Gt,V as Kt,Vt as qt,W as Jt,Wt as Yt,Xt,Yt as Zt,Zt as Qt,_t as $t,a as en,b as tn,bt as nn,c as rn,ct as an,d as on,dt as sn,en as cn,f as ln,ft as un,gt as dn,h as fn,ht as pn,i as mn,it as hn,j as gn,jt as _n,k as vn,l as yn,mt as bn,n as xn,nn as Sn,nt as Cn,o as wn,ot as Tn,p as En,pt as Dn,qt as On,r as kn,rt as An,s as jn,t as Mn,tn as Nn,w as Pn,wt as Fn,x as In,xt as Ln,yt as Rn,zt as zn}from"./index-CQHHxwAN.js";import{t as Bn}from"./card-BMggHY3n.js";import{t as Vn}from"./label-C610MHwq.js";var Hn=K(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Un=K(`building-2`,[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]]),Wn=K(`calendar`,[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),Gn=K(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),Kn=K(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),qn=K(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),Jn=K(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Yn=K(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Xn=K(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Zn=K(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Qn=K(`git-compare`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]),$n=K(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),er=K(`navigation`,[[`polygon`,{points:`3 11 22 2 13 21 11 13 3 11`,key:`1ltx0t`}]]),tr=K(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),nr=K(`puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),rr=K(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),ir=K(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),ar=K(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),or=K(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),sr=K(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),cr=K(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Q=e(t(),1);function lr(e){let{popupElement:t,positionerElement:n,content:r,mounted:i,onMeasureLayout:a,onMeasureLayoutComplete:o,side:c,direction:l}=e,u=s(t,!0),d=ne(),f=Q.useRef(null),p=Q.useRef(!0),m=Q.useRef(Ae),h=M(a),g=M(o),_=Q.useMemo(()=>ur(c,l),[c,l]);B(()=>{if(!i){m.current=Ae,p.current=!0,f.current=null;return}if(!t||!n)return;m.current=fr(t,_),pr(t,`auto`);let e=dr(t,`position`,`static`),r=dr(t,`transform`,`none`),a=dr(t,`scale`,`1`),o=fr(n,{"--available-width":`max-content`,"--available-height":`max-content`});function s(){e(),r(),o()}function c(){s(),a()}if(h?.(),p.current||f.current===null){mr(n,`max-content`);let e=ct(t);return f.current=e,mr(n,e),c(),g?.(null,e),p.current=!1,()=>{m.current(),m.current=Ae}}mr(n,`max-content`);let l=f.current,v=ct(t);f.current=v,pr(t,l),c(),g?.(l,v),mr(n,v);let y=new AbortController;return d.request(()=>{pr(t,v),u(()=>{t.style.setProperty(`--popup-width`,`auto`),t.style.setProperty(`--popup-height`,`auto`)},y.signal)}),()=>{y.abort(),d.cancel(),m.current(),m.current=Ae}},[r,t,n,u,d,i,h,g,_])}function ur(e,t){let n=e===`top`,r=e===`left`||e===(t===`rtl`?`inline-end`:`inline-start`);return!n&&!r?Oe:{position:`absolute`,[n?`bottom`:`top`]:`0`,[r?`right`:`left`]:`0`}}function dr(e,t,n){let r=e.style.getPropertyValue(t);return e.style.setProperty(t,n),()=>{e.style.setProperty(t,r)}}function fr(e,t){let n=[];for(let[r,i]of Object.entries(t))n.push(dr(e,r,i));return n.length?()=>{n.forEach(e=>e())}:Ae}function pr(e,t){let n=t===`auto`?`auto`:`${t.width}px`,r=t===`auto`?`auto`:`${t.height}px`;e.style.setProperty(`--popup-width`,n),e.style.setProperty(`--popup-height`,r)}function mr(e,t){let n=t===`max-content`?`max-content`:`${t.width}px`,r=t===`max-content`?`max-content`:`${t.height}px`;e.style.setProperty(`--positioner-width`,n),e.style.setProperty(`--positioner-height`,r)}var hr={name:`adaptiveOrigin`,async fn(e){let{x:t,y:n,rects:{floating:r},elements:{floating:i},platform:a,strategy:o,placement:s}=e,c=k(i),l=c.getComputedStyle(i);if(l.transitionDuration===`0s`||l.transitionDuration===``)return{x:t,y:n,data:Ve};let u=await a.getOffsetParent?.(i),d={width:0,height:0};if(o===`fixed`&&c?.visualViewport)d={width:c.visualViewport.width,height:c.visualViewport.height};else if(u===c){let e=P(i);d={width:e.documentElement.clientWidth,height:e.documentElement.clientHeight}}else await a.isElement?.(u)&&(d=await a.getDimensions(u));let f=Me(s),p=t,m=n;f===`left`&&(p=d.width-(t+r.width)),f===`top`&&(m=d.height-(n+r.height));let h=f===`left`?`right`:Ve.sideX,g=f===`top`?`bottom`:Ve.sideY;return{x:p,y:m,data:{sideX:h,sideY:g}}}},gr=e(T(),1),$=n(),_r={activationDirection:e=>e?{"data-activation-direction":e}:null};function vr(e){let{store:t,side:n,children:r}=e,i=O(),a=t.useState(`activeTriggerElement`),o=t.useState(`activeTriggerId`),c=t.useState(`open`),l=t.useState(`payload`),u=t.useState(`mounted`),d=t.useState(`popupElement`),f=t.useState(`positionerElement`),p=Re(c?a:null),m=Sr(o,l),h=Q.useRef(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),b=Q.useRef(null),x=Q.useRef(null),S=s(b,!0),C=ne(),w=Q.useRef(null),[T,E]=Q.useState(null),[D,k]=Q.useState(!1);B(()=>(t.set(`adaptiveOrigin`,hr),()=>{t.set(`adaptiveOrigin`,void 0)}),[t]);let A=M(()=>{b.current?.style.setProperty(`animation`,`none`),b.current?.style.setProperty(`transition`,`none`),x.current?.style.setProperty(`display`,`none`)}),j=M(e=>{b.current?.style.removeProperty(`animation`),b.current?.style.removeProperty(`transition`),x.current?.style.removeProperty(`display`),e&&E(e)}),N=M(()=>{w.current?.abort();let e=new AbortController;w.current=e,S(()=>{_(null),E(null),h.current=null},e.signal)}),F=Q.useRef(null);B(()=>{(!c||!u)&&(F.current=null)},[c,u]),B(()=>{if(a&&p&&a!==p&&F.current!==a&&h.current){_(h.current),k(!0);let e=xr(p,a);y(e),F.current=a}},[a,p]),B(()=>{g!=null&&(w.current?.abort(),k(!0),C.request(()=>{gr.flushSync(()=>{k(!1)}),N()}))},[m,g,N,C]),B(()=>{let e=b.current;if(!e)return;let t=P(e).createElement(`div`);for(let n of Array.from(e.childNodes))t.appendChild(n.cloneNode(!0));h.current=t});let I=g!=null,L;L=I?(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(`div`,{"data-previous":!0,inert:H(!0),ref:x,style:{...T?{"--popup-width":`${T.width}px`,"--popup-height":`${T.height}px`}:null,position:`absolute`},"data-ending-style":D?void 0:``},`previous`),(0,$.jsx)(`div`,{"data-current":!0,ref:b,"data-starting-style":D?``:void 0,children:r},m)]}):(0,$.jsx)(`div`,{"data-current":!0,ref:b,children:r},m),B(()=>{let e=x.current;!e||!g||e.replaceChildren(...Array.from(g.childNodes))},[g]),lr({popupElement:d,positionerElement:f,mounted:u,content:l,onMeasureLayout:A,onMeasureLayoutComplete:j,side:n,direction:i});let ee={activationDirection:yr(v),transitioning:I};return{children:L,state:ee}}function yr(e){if(e)return`${br(e.horizontal,5,`right`,`left`)} ${br(e.vertical,5,`down`,`up`)}`}function br(e,t,n,r){return e>t?n:e<-t?r:``}function xr(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i={x:n.left+n.width/2,y:n.top+n.height/2},a={x:r.left+r.width/2,y:r.top+r.height/2};return{horizontal:a.x-i.x,vertical:a.y-i.y}}function Sr(e,t){let[n,r]=Q.useState(0),i=Q.useRef(e),a=Q.useRef(t),o=Q.useRef(!1);return B(()=>{let n=i.current,s=a.current,c=e!==n,l=t!==s;c?(r(e=>e+1),o.current=!l):o.current&&l&&(r(e=>e+1),o.current=!1),i.current=e,a.current=t},[e,t]),`${e??`current`}-${n}`}function Cr({ws:e}){let t=e.branchName,n=fe(t),r=ye(t),i=Te(t),a=n.data,o=(0,Q.useMemo)(()=>a?.services??[],[a]),s=(0,Q.useMemo)(()=>a?.runningState??[],[a]),c=a?.orchestrationTools??[],l=(0,Q.useMemo)(()=>a?.runningOrchestrators??[],[a]),u=(0,Q.useMemo)(()=>l.filter(e=>e.mode===`pm2`&&e.logName),[l]),[d,f]=(0,Q.useState)(`classic`),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=[...o.map(e=>e.name),...u.map(e=>e.logName)];e.length===0?h!==null&&g(null):(!h||!e.includes(h))&&g(e[0])},[o,u]);let{logs:_,connected:v,clear:y}=Kt(t,h,!0),b=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{b.current?.scrollIntoView({behavior:`smooth`})},[_]);let x=(0,Q.useMemo)(()=>new Set(s.filter(e=>e.pid>0).map(e=>e.name)),[s]),S=(0,Q.useMemo)(()=>new Set(l.map(e=>e.id)),[l]),C=x.size>0,w=d===`matrix`?`term-matrix`:d===`dracula`?`term-dracula`:`term-classic`,T=r.isPending||i.isPending;return(0,$.jsxs)(`div`,{className:`animate-fade-in`,children:[n.isLoading&&(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-[10px] text-primary`,children:[(0,$.jsx)(Z,{className:`size-3`}),(0,$.jsx)(`span`,{className:`font-semibold tracking-wider uppercase`,children:`Scanning service configurations...`})]}),n.isError&&(0,$.jsxs)(`div`,{className:`mb-4 flex items-center justify-between rounded-md border border-destructive/30 bg-destructive/10 p-3 text-xs text-destructive`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(xt,{size:14}),(0,$.jsxs)(`span`,{children:[`Failed to load services: `,n.error?.message||`Unknown error`]})]}),(0,$.jsx)(Y,{size:`xs`,variant:`outline`,onClick:()=>n.refetch(),children:`Retry`})]}),(r.isError||i.isError)&&(0,$.jsxs)(`div`,{className:`mb-4 flex items-center justify-between rounded-md border border-destructive/30 bg-destructive/10 p-3 text-xs text-destructive`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(xt,{size:14}),(0,$.jsxs)(`span`,{children:[`Action failed: `,r.error?.message||i.error?.message||`Operation failed`]})]}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:()=>{r.reset(),i.reset()},children:`Dismiss`})]}),!n.isLoading&&!n.isError&&o.length===0&&c.length===0&&(0,$.jsxs)(`div`,{className:`rounded-md border border-border/80 bg-card p-6 text-center surface-card`,children:[(0,$.jsx)(Fn,{size:24,className:`mx-auto mb-2 text-muted-foreground/60`}),(0,$.jsx)(`h4`,{className:`text-xs font-bold text-foreground`,children:`No Services Detected`}),(0,$.jsxs)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:[`ContextSpace scans for runnable background services in `,(0,$.jsx)(`code`,{className:`font-mono text-[10px]`,children:`package.json`}),` scripts (such as `,(0,$.jsx)(`code`,{className:`font-mono text-[10px]`,children:`start`}),`, `,(0,$.jsx)(`code`,{className:`font-mono text-[10px]`,children:`dev`}),`), `,(0,$.jsx)(`code`,{className:`font-mono text-[10px]`,children:`docker-compose.yml`}),`, or `,(0,$.jsx)(`code`,{className:`font-mono text-[10px]`,children:`Procfile`}),`.`]})]}),c.length>0&&(0,$.jsxs)(`div`,{className:`mb-4 rounded-md border border-border/80 bg-card p-4 surface-card`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-[10px] font-bold uppercase tracking-wider text-muted-foreground`,children:[(0,$.jsx)(xt,{size:12,className:`text-info`}),` Orchestration tools`]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map(e=>{let t=S.has(e.id);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border/60 bg-muted/20 p-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full ${t?`bg-success`:`bg-muted-foreground/40`}`}),(0,$.jsx)(`span`,{className:`text-xs font-bold text-foreground`,children:e.tool}),(0,$.jsx)(Ct,{tone:`idle`,dot:!1,children:e.mode})]}),(0,$.jsx)(`code`,{className:`mt-1 block truncate font-mono text-[9px] text-muted-foreground`,children:e.configPath})]}),(0,$.jsx)(`div`,{className:`shrink-0`,children:t?(0,$.jsxs)(Y,{size:`xs`,variant:`destructive`,"aria-label":`Stop ${e.tool}`,disabled:T,onClick:()=>i.mutate({action:`stop`,id:e.id}),children:[(0,$.jsx)(wt,{size:12}),` Stop`]}):(0,$.jsxs)(Y,{size:`xs`,"aria-label":`Start ${e.tool}`,disabled:T,onClick:()=>i.mutate({action:`start`,id:e.id}),children:[(0,$.jsx)(It,{size:12}),` Start`]})})]},e.id)})})]}),(0,$.jsxs)(`div`,{className:`mb-4 rounded-md border border-border/80 bg-card p-4 surface-card`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between text-xs font-semibold text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:`Workspace Status`}),(0,$.jsx)(Ct,{tone:C?`running`:`idle`,children:C?`Active`:`Standby`})]}),(0,$.jsx)(`div`,{className:`mb-3 text-xs font-semibold text-foreground`,children:C?`${x.size} process${x.size===1?``:`es`} active`:`All processes offline`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(Y,{size:`sm`,disabled:C||T,onClick:()=>r.mutate({action:`start`}),children:[(0,$.jsx)(It,{size:13}),` Start All Services`]}),(0,$.jsxs)(Y,{size:`sm`,variant:`destructive`,disabled:!C||T,onClick:()=>r.mutate({action:`stop`}),children:[(0,$.jsx)(wt,{size:13}),` Stop All`]})]})]}),(o.length>0||u.length>0)&&(0,$.jsxs)(`div`,{className:`grid grid-cols-1 overflow-hidden rounded-md border border-border/80 bg-card shadow-xs lg:grid-cols-12 surface-card`,children:[(0,$.jsxs)(`div`,{className:`border-b border-border/80 bg-muted/20 p-4 lg:col-span-4 lg:border-b-0 lg:border-r`,children:[(0,$.jsxs)(`h4`,{className:`mb-4 flex items-center gap-1.5 border-b border-border pb-2 text-[10px] font-bold uppercase tracking-wider text-muted-foreground`,children:[(0,$.jsx)(Fn,{size:12,className:`text-primary`}),` Background Services`]}),(0,$.jsxs)(`div`,{className:`flex max-h-[400px] flex-col gap-2 overflow-y-auto pr-1`,children:[o.map(e=>{let t=h===e.name,n=x.has(e.name);return(0,$.jsxs)(`div`,{className:q(`flex cursor-pointer flex-col rounded-xl border p-3 transition-colors`,t?`border-primary/40 bg-primary/10 text-foreground`:`border-border bg-card text-muted-foreground hover:border-foreground/15 hover:bg-accent/50 hover:text-foreground`),onClick:()=>g(e.name),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${n?`bg-success`:`bg-destructive`}`}),(0,$.jsx)(`span`,{className:`truncate text-xs font-bold`,children:e.name})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,onClick:e=>e.stopPropagation(),children:n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{size:`icon-xs`,variant:`ghost`,"aria-label":`Restart ${e.name}`,disabled:T,onClick:()=>r.mutate({action:`restart`,service:e.name}),children:(0,$.jsx)(ar,{})}),(0,$.jsx)(Y,{size:`icon-xs`,variant:`ghost`,"aria-label":`Stop ${e.name}`,disabled:T,onClick:()=>r.mutate({action:`stop`,service:e.name}),children:(0,$.jsx)(wt,{})})]}):(0,$.jsx)(Y,{size:`icon-xs`,variant:`ghost`,"aria-label":`Start ${e.name}`,disabled:T,onClick:()=>r.mutate({action:`start`,service:e.name}),children:(0,$.jsx)(It,{})})})]}),e.port?(0,$.jsxs)(`span`,{className:`mt-2 w-fit rounded border border-border bg-background px-2 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`Port: `,e.port]}):null,(0,$.jsxs)(`code`,{className:`mt-2 block truncate rounded border border-border bg-muted/40 p-1.5 font-mono text-[9px] text-muted-foreground`,children:[e.command,` `,e.args.join(` `)]})]},e.name)}),u.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-2 border-t border-border pt-3 text-[9px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Orchestrators`}),u.map(e=>{let t=e.logName;return(0,$.jsxs)(`div`,{className:q(`flex cursor-pointer items-center gap-2 rounded-xl border p-3 transition-colors`,h===t?`border-primary/40 bg-primary/10 text-foreground`:`border-border bg-card text-muted-foreground hover:border-foreground/15 hover:bg-accent/50 hover:text-foreground`),onClick:()=>g(t),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-success`}),(0,$.jsx)(`span`,{className:`truncate text-xs font-bold`,children:e.tool}),(0,$.jsx)(Ct,{tone:`idle`,dot:!1,children:e.mode})]},e.id)})]})]})]}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col bg-background lg:col-span-8`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-border bg-muted/40 px-5 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-xs font-bold text-primary`,children:h||`no-service`}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`|`}),(0,$.jsx)(Ct,{tone:v?`running`:`idle`,children:v?`streaming`:`idle`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 self-end sm:self-auto`,children:[(0,$.jsx)(`div`,{className:`flex rounded-lg border border-border bg-card p-0.5 text-[9px] font-semibold text-muted-foreground`,children:[`classic`,`matrix`,`dracula`].map(e=>(0,$.jsx)(`button`,{className:q(`cursor-pointer rounded-md px-2 py-1 capitalize transition-colors`,d===e?`bg-primary/10 font-bold text-primary`:`hover:text-foreground`),onClick:()=>f(e),children:e},e))}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(`button`,{onClick:y,className:`cursor-pointer rounded-lg border border-border bg-card p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:`Clear Console`,children:(0,$.jsx)(st,{size:13})}),(0,$.jsx)(`button`,{onClick:()=>m(!p),className:`cursor-pointer rounded-lg border border-border bg-card p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:p?`Minimize Console`:`Expand Console`,children:p?(0,$.jsx)(Et,{size:13}):(0,$.jsx)(Bt,{size:13})})]})]})]}),(0,$.jsxs)(`div`,{className:q(`relative overflow-y-auto whitespace-pre-wrap p-5 font-mono text-[10.5px] leading-relaxed selection:bg-primary/20`,w,p?`h-[520px]`:`h-80`),children:[_.trim()?_:(0,$.jsx)(`span`,{className:`font-mono italic text-muted-foreground`,children:`(no log content yet)`}),(0,$.jsx)(`div`,{ref:b})]})]})]})]})}var wr=({workspaceTitle:e,workspaceDescription:t,activeWorktree:n,iterations:r,activeIterationId:i,onSelectIteration:a,activeStage:o,onSelectStage:s,diffViewMode:c,onToggleDiffMode:l,isZenMode:u,onToggleZenMode:d,gateStatus:f={overallStatus:`idle`,summaryText:`No verification gate run yet`},onNewIteration:p,showToast:m})=>{let[h,g]=(0,Q.useState)(!1),_=(0,Q.useCallback)(async(e,t)=>{t.stopPropagation(),await Ht(e)&&(g(!0),m?.(`Copied branch "${e}" to clipboard`,`success`),setTimeout(()=>g(!1),1500))},[m]),v=n?.commitInfo?.shortSha||n?.commitSha?.slice(0,7)||`unknown`;return(0,$.jsxs)(`header`,{className:`w-full shrink-0 border-b border-border/80 bg-card/85 backdrop-blur-md z-20 select-none`,children:[(0,$.jsxs)(`div`,{className:`h-8 px-3 flex items-center justify-between border-b border-border/60 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`font-semibold text-foreground tracking-tight truncate max-w-[240px] cursor-default`,title:t||e,children:e}),(0,$.jsx)(Qt,{size:11,className:`text-muted-foreground/40 shrink-0`}),n?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-foreground truncate max-w-[280px] flex items-center gap-1 text-xs`,title:n.intent||n.title,children:[(0,$.jsx)(Ut,{size:12,className:`text-primary shrink-0`}),n.title]}),(0,$.jsxs)(`button`,{type:`button`,onClick:e=>_(n.branchName,e),title:`Click to copy branch`,className:`inline-flex items-center gap-1 font-mono text-[10px] text-muted-foreground bg-muted/60 hover:bg-muted/90 px-1.5 py-0.5 rounded border border-border/50 hover:border-primary/40 transition-colors cursor-pointer`,children:[(0,$.jsx)(kt,{size:10,className:`text-primary/70 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-[150px]`,children:n.branchName}),h?(0,$.jsx)(zt,{size:10,className:`text-emerald-400 shrink-0`}):(0,$.jsx)(Dt,{size:9,className:`opacity-50 shrink-0`})]}),(0,$.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground/70 hidden sm:inline`,title:`Head commit: ${n.commitInfo?.commitMessage||n.commitSha}`,children:[`@`,v]}),n.dirtyFilesCount===null?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Status unavailable`}):n.dirtyFilesCount>0?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(`diff`),className:`font-mono text-[10px] font-bold text-amber-400 bg-amber-500/15 border border-amber-500/30 px-1.5 py-0.5 rounded flex items-center gap-1 cursor-pointer hover:bg-amber-500/25 transition-colors`,title:`View uncommitted modified files`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-400 animate-pulse`}),(0,$.jsxs)(`span`,{children:[`±`,n.dirtyFilesCount,` dirty`]})]}):(0,$.jsxs)(`span`,{className:`font-mono text-[10px] font-medium text-emerald-400 bg-emerald-500/10 border border-emerald-500/25 px-1.5 py-0.5 rounded flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-emerald-400`}),(0,$.jsx)(`span`,{children:`clean`})]}),n.isPinned&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 font-mono text-[10px] text-primary/80 bg-primary/10 px-1 py-0.5 rounded`,title:`Worktree locked against pruning`,children:[(0,$.jsx)(zn,{size:10}),(0,$.jsx)(`span`,{children:`pinned`})]})]}):(0,$.jsx)(`span`,{className:`text-muted-foreground text-xs italic`,children:`No active worktree`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[f&&(0,$.jsxs)(`div`,{className:q(`inline-flex items-center gap-1 font-mono text-[10px] font-semibold px-2 py-0.5 rounded border`,f.overallStatus===`pass`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-400`:f.overallStatus===`fail`?`border-rose-500/30 bg-rose-500/15 text-rose-400 animate-pulse`:f.overallStatus===`running`?`border-sky-500/25 bg-sky-500/10 text-sky-400`:`border-border/60 bg-muted/20 text-muted-foreground`),title:f.summaryText||`Automated verification gate proof`,children:[f.overallStatus===`pass`?(0,$.jsx)(Zt,{size:11,className:`text-emerald-400`}):f.overallStatus===`fail`?(0,$.jsx)(Xt,{size:11,className:`text-rose-400`}):f.overallStatus===`running`?(0,$.jsx)(Yn,{size:11,className:`text-sky-400 animate-spin`}):(0,$.jsx)(Yn,{size:11,className:`text-muted-foreground/60`}),(0,$.jsxs)(`span`,{children:[`Gate:`,` `,f.overallStatus===`pass`?`PASS (${f.durationMs??120}ms)`:f.overallStatus===`fail`?`FAILED ✗`:f.overallStatus===`running`?`RUNNING…`:`IDLE ○`]})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:l,className:`inline-flex items-center gap-1 font-mono text-[10px] font-medium px-2 py-0.5 rounded border border-border bg-card/60 hover:bg-accent text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Toggle Diff Mode (Split / Unified)`,children:[(0,$.jsx)(jt,{size:11}),(0,$.jsx)(`span`,{children:c===`side-by-side`?`Split`:`Unified`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:d,className:q(`inline-flex items-center gap-1 font-mono text-[10px] px-1.5 py-0.5 rounded border transition-colors cursor-pointer`,u?`border-primary/40 bg-primary/10 text-primary font-bold`:`border-border bg-card/60 text-muted-foreground hover:text-foreground hover:bg-accent`),title:`Toggle Zen Review Mode (Shortcut: z)`,children:[u?(0,$.jsx)(Et,{size:11}):(0,$.jsx)(Bt,{size:11}),(0,$.jsx)(`span`,{children:`Zen (z)`})]})]})]}),!u&&(0,$.jsxs)(`div`,{className:`h-7 px-3 flex items-center justify-between border-b border-border/40 bg-muted/20 text-xs`,children:[r.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto custom-scrollbar min-w-0 flex-1 pr-3`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[10px] font-bold uppercase tracking-wider text-muted-foreground/60 shrink-0`,children:`Iterations:`}),r.length===0?(0,$.jsx)(`span`,{className:`text-muted-foreground/70 italic text-[11px] px-1`,children:`No iterations defined`}):r.map(e=>{let t=e.id===i;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),className:q(`inline-flex items-center gap-1.5 h-5 px-2 rounded text-xs font-medium whitespace-nowrap transition-all cursor-pointer shrink-0`,t?`bg-primary/15 text-foreground font-semibold border border-primary/40 shadow-2xs`:`bg-card/50 hover:bg-accent/80 text-muted-foreground hover:text-foreground border border-border/60`),title:e.goal||e.title,children:[(0,$.jsx)(Ut,{size:11,className:q(t?`text-primary`:`text-muted-foreground/70`)}),(0,$.jsx)(`span`,{children:e.title}),e.status===`review_ready`?(0,$.jsxs)(`span`,{className:`font-mono text-[9px] px-1 py-0.2 rounded bg-amber-500/20 text-amber-400 font-bold border border-amber-500/30`,children:[`Review Ready `,e.changesCount?`(±${e.changesCount})`:``]}):e.status===`agent_running`?(0,$.jsxs)(`span`,{className:`font-mono text-[9px] px-1 py-0.2 rounded bg-sky-500/20 text-sky-400 font-bold border border-sky-500/30 flex items-center gap-0.5`,children:[(0,$.jsx)(Rn,{size:9,className:`text-sky-400`}),`Active ⚡`]}):e.status===`done`?(0,$.jsx)(`span`,{className:`font-mono text-[9px] px-1 py-0.2 rounded bg-emerald-500/20 text-emerald-400 font-bold border border-emerald-500/30`,children:`Done ✓`}):(0,$.jsx)(`span`,{className:`font-mono text-[9px] px-1 py-0.2 rounded bg-muted/80 text-muted-foreground border border-border/40`,children:`Planned ○`})]},e.id)}),p&&(0,$.jsxs)(`button`,{type:`button`,onClick:p,className:`inline-flex items-center gap-1 h-5 px-2 rounded text-[11px] font-medium text-muted-foreground hover:text-primary hover:bg-primary/10 border border-dashed border-border/80 hover:border-primary/30 transition-colors cursor-pointer shrink-0`,children:[(0,$.jsx)(Pt,{size:10}),(0,$.jsx)(`span`,{children:`New Iteration`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 font-mono text-[10px]`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(`diff`),className:q(`px-2 py-0.5 rounded transition-colors cursor-pointer`,o===`diff`?`bg-primary/15 text-primary font-bold border border-primary/30`:`text-muted-foreground hover:text-foreground hover:bg-accent/60`),children:`Diff Review`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(`plan`),className:q(`px-2 py-0.5 rounded transition-colors cursor-pointer`,o===`plan`?`bg-primary/15 text-primary font-bold border border-primary/30`:`text-muted-foreground hover:text-foreground hover:bg-accent/60`),children:`Process DAG`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(`knowledge`),className:q(`px-2 py-0.5 rounded transition-colors cursor-pointer`,o===`knowledge`?`bg-primary/15 text-primary font-bold border border-primary/30`:`text-muted-foreground hover:text-foreground hover:bg-accent/60`),children:`Knowledge`})]})]})]})},Tr=Q.createContext(void 0);function Er(e){let t=Q.useContext(Tr);if(t===void 0&&!e)throw Error(J(47));return t}var Dr={...$t,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Or=class extends c{constructor(e,t,n){let r=new _;super(kr(e,r,t,n),Ar(r),Dr)}setOpen=(e,t)=>{let n=t.reason===b,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=F(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n={open:e,openChangeReason:t.reason};g(n,e,t.trigger,a()),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),gr.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function kr(e,t,n,r=!1){let i={...pn(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i.floatingRootContext=dn(t,n,r),i}function Ar(e){return{popupRef:Q.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:Q.createRef(),beforeContentFocusGuardRef:Q.createRef(),stickIfOpenTimeout:new l,triggerElements:e}}function jr({props:e}){let{children:t,open:n,defaultOpen:i=!1,onOpenChange:o,onOpenChangeComplete:s,modal:c=!1,handle:l,triggerId:u,defaultTriggerId:d=null}=e,f=Nr(l,{modal:c,open:i,openProp:n,activeTriggerId:d,triggerIdProp:u});f.useControlledProp(`openProp`,n),f.useControlledProp(`triggerIdProp`,u);let p=f.useState(`open`),m=f.useState(`mounted`),g=f.useState(`payload`);f.useContextCallback(`onOpenChange`,o),f.useContextCallback(`onOpenChangeComplete`,s),y(f,p),v(f);let{forceUnmount:_}=a(p,f,()=>{f.update({stickIfOpen:!0,openChangeReason:null})});f.useSyncedValues({modal:c}),Q.useEffect(()=>{p||f.context.stickIfOpenTimeout.clear()},[f,p]),Q.useImperativeHandle(e.actionsRef,()=>({unmount:_,close:()=>f.setOpen(!1,E(h))}),[_,f]);let b=p||m;return(0,$.jsxs)(Tr.Provider,{value:f,children:[l&&(0,$.jsx)(r,{handle:l,store:f}),b&&(0,$.jsx)(Pr,{store:f,modal:c}),typeof t==`function`?t({payload:g}):t]})}function Mr(e){return Er(!0)?(0,$.jsx)(jr,{props:e}):(0,$.jsx)(S,{children:(0,$.jsx)(jr,{props:e})})}function Nr(e,t){let n=p((e,n)=>new Or(t,e,n));return Q.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function Pr({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=z(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return u(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}var Fr=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:p,...m}=e,h=Er(!0),g=bn(s)??h;if(!g)throw Error(J(74));let _=C(p),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),b=g.useState(`isOpenedByTrigger`,_),x=g.useState(`triggerPopupId`,_),S=Q.useRef(null),{registerTrigger:w,isMountedByThisTrigger:T}=W(_,S,g,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),E=g.useState(`openChangeReason`),D=g.useState(`stickIfOpen`),O=g.useState(`openMethod`),k=g.useState(`focusManagerModal`),A=un(y,{enabled:!a&&l&&(O!==`touch`||E!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:sn(),restMs:u,delay:{close:d},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),j=Ie(y,{stickIfOpen:D}),M=Ne(()=>g.select(`open`),e=>{g.set(`openMethod`,e)}),N=g.useState(`triggerProps`,T),{getButtonProps:P,buttonRef:F}=ee({disabled:a,native:o}),I={open(e){return e&&E===`trigger-press`?f.open(e):te.open(e)}},{preFocusGuardRef:L,handlePreFocusGuardFocus:z,handleFocusTargetFocus:ne}=an(g,S),B=ke(`button`,e,{state:{disabled:a,open:b},ref:[F,t,w,S],props:[j.reference,A,N,M,{[R]:``,id:_,"aria-haspopup":`dialog`,"aria-expanded":b,"aria-controls":x},m,P],stateAttributesMapping:I}),V=(0,$.jsx)(Q.Fragment,{children:B},_);return T&&!k?(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(U,{ref:L,onFocus:z}),V,(0,$.jsx)(U,{ref:g.context.triggerFocusTargetRef,onFocus:ne})]}):V}),Ir=Q.createContext(void 0);function Lr(){let e=Q.useContext(Ir);if(e===void 0)throw Error(J(45));return e}var Rr=Q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Er().useState(`mounted`)||n?(0,$.jsx)(Ir.Provider,{value:n,children:(0,$.jsx)(re,{ref:t,...r})}):null}),zr=Q.createContext(void 0);function Br(){let e=Q.useContext(zr);if(!e)throw Error(J(46));return e}var Vr=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:c,align:l,sideOffset:u,alignOffset:d,collisionBoundary:f=`clipping-ancestors`,collisionPadding:p,arrowPadding:m,sticky:h,disableAnchorTracking:g=!1,collisionAvoidance:_=A,...v}=e,y=Er(),b=Lr(),x=D(),S=y.useState(`floatingRootContext`),C=y.useState(`mounted`),T=y.useState(`open`),E=y.useState(`openChangeReason`),O=y.useState(`activeTriggerElement`),k=y.useState(`modal`),j=y.useState(`openMethod`),M=y.useState(`positionerElement`),P=y.useState(`instantType`),F=y.useState(`transitionStatus`),I=y.useState(`adaptiveOrigin`),L=Q.useRef(null),ee=s(M),R=Le({anchor:a,floatingRootContext:S,positionMethod:o,mounted:C,side:c,sideOffset:u,align:l,alignOffset:d,arrowPadding:m,collisionBoundary:f,collisionPadding:p,sticky:h,disableAnchorTracking:g,keepMounted:b,nodeId:x,collisionAvoidance:_,adaptiveOrigin:I}),z=S.useState(`domReferenceElement`);B(()=>{let e=z,t=L.current;if(e&&(L.current=e),t&&e&&e!==t){y.set(`instantType`,void 0);let e=new AbortController;return ee(()=>{y.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[z,ee,y]);let te=k===!0&&E!==`trigger-hover`;ze(T&&te,j===`touch`,M,O);let ne=y.useStateSetter(`positionerElement`),V={open:T,side:R.side,align:R.align,anchorHidden:R.anchorHidden,instant:P},re=Be(e,V,{styles:R.positionerStyles,transitionStatus:F,props:v,refs:[t,ne],hidden:!C,inert:!T});return(0,$.jsxs)(zr.Provider,{value:R,children:[C&&te&&(0,$.jsx)(N,{inert:H(!T),cutout:O}),(0,$.jsx)(w,{id:x,children:re})]})}),Hr=Q.createContext(void 0);function Ur(){let[e,t]=Q.useState(0),n=M(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:Q.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var Wr=Q.forwardRef(function(e,t){let{render:n,className:r,style:a,initialFocus:s,finalFocus:c,...l}=e,u=Er(),f=Br(),p=Fe(!0)!=null,{context:h,hasClosePart:g}=Ur(),_=u.useState(`open`),v=u.useState(`openMethod`),y=u.useState(`instantType`),b=u.useState(`transitionStatus`),S=u.useState(`popupProps`),C=u.useState(`titleElementId`),w=u.useState(`descriptionElementId`),T=u.useState(`modal`),E=u.useState(`mounted`),D=u.useState(`openChangeReason`),O=u.useState(`activeTriggerElement`),k=u.useState(`floatingRootContext`),A=k.useState(`floatingId`),M=u.useState(`disabled`),N=u.useState(`openOnHover`),P=u.useState(`closeDelay`);x({open:_,ref:u.context.popupRef,onComplete(){_&&u.context.onOpenChangeComplete?.(!0)}}),Dn(k,{enabled:N&&!M,closeDelay:P});let F=s===void 0?m(u.context.popupRef):s,L=T!==!1&&g;u.useSyncedValue(`focusManagerModal`,L);let ee=u.useStateSetter(`popupElement`),R={open:_,side:f.side,align:f.align,instant:y,transitionStatus:b},z=ke(`div`,e,{state:R,ref:[t,u.context.popupRef,ee],props:[S,{id:A,role:`dialog`,...I,"aria-labelledby":C,"aria-describedby":w,onKeyDown(e){p&&i.has(e.key)&&e.stopPropagation()}},Pe(b),l],stateAttributesMapping:o});return(0,$.jsx)(d,{context:k,openInteractionType:v,modal:L,disabled:!E||D===`trigger-hover`,initialFocus:F,returnFocus:c,restoreFocus:`popup`,previousFocusableElement:j(O)?O:void 0,nextFocusableElement:u.context.triggerFocusTargetRef,beforeContentFocusGuardRef:u.context.beforeContentFocusGuardRef,children:(0,$.jsx)(Hr.Provider,{value:h,children:z})})}),Gr=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=Er(),{side:c}=Br(),l=s.useState(`instantType`),{children:u,state:d}=vr({store:s,side:c,children:a}),f={activationDirection:d.activationDirection,transitioning:d.transitioning,instant:l};return ke(`div`,e,{state:f,ref:t,props:[o,{children:u}],stateAttributesMapping:_r})}),Kr=Mr;function qr({className:e,children:t,...n}){return(0,$.jsx)(Fr,{className:e,"data-slot":`popover-trigger`,...n,children:t})}function Jr({children:e,className:t,viewportClassName:n,side:r=`bottom`,align:i=`center`,sideOffset:a=4,alignOffset:o=0,tooltipStyle:s=!1,anchor:c,...l}){return(0,$.jsx)(Rr,{children:(0,$.jsx)(Vr,{align:i,alignOffset:o,anchor:c,className:`z-50 h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom,transform] data-instant:transition-none`,"data-slot":`popover-positioner`,side:r,sideOffset:a,children:(0,$.jsx)(Wr,{className:q(`relative flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) rounded-lg border bg-popover not-dark:bg-clip-padding text-popover-foreground shadow-lg/5 outline-none transition-[width,height,scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] has-data-[slot=calendar]:rounded-xl has-data-[slot=calendar]:before:rounded-[calc(var(--radius-xl)-1px)] data-starting-style:scale-98 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`,s&&`w-fit text-balance rounded-md text-xs shadow-md/5 before:rounded-[calc(var(--radius-md)-1px)]`,t),"data-slot":`popover-popup`,...l,children:(0,$.jsx)(Gr,{className:q(`relative size-full max-h-(--available-height) overflow-clip px-(--viewport-inline-padding) py-4 [--viewport-inline-padding:--spacing(4)] has-data-[slot=calendar]:p-2 data-instant:transition-none **:data-current:data-ending-style:opacity-0 **:data-current:data-starting-style:opacity-0 **:data-previous:data-ending-style:opacity-0 **:data-previous:data-starting-style:opacity-0 **:data-current:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-previous:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-current:opacity-100 **:data-previous:opacity-100 **:data-current:transition-opacity **:data-previous:transition-opacity`,s?`py-1 [--viewport-inline-padding:--spacing(2)]`:`not-data-transitioning:overflow-y-auto`,n),"data-slot":`popover-viewport`,children:e})})})})}function Yr({repos:e,disabled:t,onAdd:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=(0,Q.useMemo)(()=>{let t=a.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.path.toLowerCase().includes(t)):e},[e,a]);return(0,$.jsxs)(Kr,{open:r,onOpenChange:e=>{e&&o(``),i(e)},children:[(0,$.jsx)(qr,{render:(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,disabled:t,className:`h-8 text-xs text-muted-foreground`,children:[(0,$.jsx)(Pt,{size:14}),` Add repository`]})}),(0,$.jsxs)(Jr,{align:`end`,className:`w-[320px]`,viewportClassName:`p-0`,children:[(0,$.jsx)(`div`,{className:`border-b border-border p-2`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(ie,{className:`absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(L,{autoFocus:!0,value:a,onChange:e=>o(e.target.value),placeholder:`Search repositories`,className:`pl-8`,"aria-label":`Search repositories`})]})}),(0,$.jsx)(`div`,{role:`listbox`,className:`max-h-64 overflow-y-auto py-1`,children:s.length===0?(0,$.jsx)(`div`,{className:`px-3 py-4 text-center text-sm text-muted-foreground`,children:`No repositories found.`}):s.map(e=>(0,$.jsxs)(`button`,{role:`option`,"aria-selected":!1,onClick:()=>{i(!1),n(e.path)},className:`flex w-full cursor-pointer items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-accent`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`block truncate font-mono text-xs text-muted-foreground`,children:e.path})]}),(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:e.defaultBranch})]},e.path))})]})]})}var Xr=(e,t)=>{switch(e){case`antigravity`:return`agy --conversation ${t}`;case`claude`:return`claude --resume ${t}`;case`codex`:return`codex resume ${t}`;case`copilot`:return`copilot --resume ${t}`;case`cursor`:return`cursor-agent --resume ${t}`;default:return`agy --conversation ${t}`}},Zr=e=>{switch(e){case`antigravity`:return(0,$.jsx)(`span`,{className:`grid size-5.5 place-items-center rounded-md bg-card border border-border/80 shadow-2xs p-0.5 shrink-0`,title:`Google Antigravity`,children:(0,$.jsx)(Qe,{className:`size-3.5`})});case`claude`:return(0,$.jsx)(`span`,{className:`grid size-5.5 place-items-center rounded-md bg-[#D97757] text-white font-bold text-[9px] shadow-2xs shrink-0`,title:`Claude Code`,children:(0,$.jsx)(Xe,{className:`size-2.5`})});case`codex`:return(0,$.jsx)(`span`,{className:`grid size-5.5 place-items-center rounded-md bg-foreground text-background font-bold text-[9px] shadow-2xs shrink-0`,title:`OpenAI Codex`,children:(0,$.jsx)($e,{className:`size-2.5`})});case`copilot`:return(0,$.jsx)(`span`,{className:`grid size-5.5 place-items-center rounded-md bg-gradient-to-tr from-purple-600 via-indigo-500 to-blue-600 text-white font-bold text-[9px] shadow-2xs shrink-0`,title:`GitHub Copilot`,children:(0,$.jsx)(nt,{className:`size-2.5`})});default:return null}},Qr=({ws:e,sessions:t,sessionsLoading:n,setActiveSession:r,setTranscript:i,fetchSessionTranscript:a,handleOpenDesktopSession:o,showToast:s})=>{let[c,l]=(0,Q.useState)(!1),u=(0,Q.useMemo)(()=>t.filter(e=>c||e.threadKind!==`subagent`),[t,c]),d=t.filter(e=>e.threadKind===`subagent`).length,f=se(),p=me(),m=xe(),h=m.data?.find(e=>e.name===`antigravity`)?.detected??!0,g=!!m.data?.find(e=>e.name===`claude`)?.detected,_=!!m.data?.find(e=>e.name===`codex`)?.detected,v=!!m.data?.find(e=>e.name===`copilot`)?.command,y=!!f.data?.some(e=>e.id===`antigravity`&&e.available),b=!!f.data?.some(e=>e.id===`codex-desktop`&&e.available),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(`updated-desc`),[j,M]=(0,Q.useState)(`harness`),[N,P]=(0,Q.useState)(``),[F,I]=(0,Q.useState)(`all`),[L,ee]=(0,Q.useState)({antigravity:!1,claude:!1,codex:!1,copilot:!1}),R=e=>{ee(t=>({...t,[e]:!t[e]}))},z=(0,Q.useRef)(!1),te=(0,Q.useRef)(null),ne=async t=>{try{await X(`/api/workspace/${encodeURIComponent(e.branchName)}/launch`,{method:`POST`,body:JSON.stringify({targetId:t})}),s?.(`Launched ${t===`claude-desktop`?`Claude Desktop`:t===`codex-desktop`?`Codex Desktop`:t} for workspace ${e.branchName}`,`success`)}catch(e){let t=e instanceof Error?e.message:`Failed to launch desktop application`;s?.(t,`error`)}},B=async t=>{if(!T){E(t);try{await p.mutateAsync({workspaceId:e.branchName,assistant:t}),O({assistant:t,cmd:t===`antigravity`?`agy`:t===`claude`?`claude`:t===`codex`?`codex`:`copilot`,timestamp:new Date}),s?.(`Opened ${t} inside ContextSpace`,`success`)}catch(e){let t=e instanceof Error?e.message:`Failed to launch terminal`;s?.(t,`error`)}finally{E(null)}}},V=async(t,n,r)=>{if(!z.current){z.current=!0,w(t);try{await p.mutateAsync({workspaceId:e.branchName,sessionId:t,assistant:n,cwd:r});let i=Xr(n,t);O({assistant:n,cmd:i,timestamp:new Date}),s?.(`Opened ${n} resume inside ContextSpace`,`success`)}catch{let e=Xr(n,t);await Ht(e),s?.(`Copied resume command to clipboard: ${e}`,`info`)}finally{w(null),z.current=!1}}},re=async t=>{if(!(!b||te.current)){te.current=t,S(t);try{await o(e,t,`codex`)}finally{te.current=null,S(null)}}},H=(e,t)=>[...e].sort((e,n)=>{switch(t){case`created-desc`:{let t=new Date(e.createdAt||e.updatedAt||0).getTime();return new Date(n.createdAt||n.updatedAt||0).getTime()-t}case`created-asc`:return new Date(e.createdAt||e.updatedAt||0).getTime()-new Date(n.createdAt||n.updatedAt||0).getTime();case`updated-desc`:{let t=Date.parse(e.updatedAt)||0;return(Date.parse(n.updatedAt)||0)-t}case`messages-desc`:return(n.messageCount||0)-(e.messageCount||0);case`title-asc`:return(e.title||``).localeCompare(n.title||``);default:return 0}}),U=(0,Q.useMemo)(()=>{let e=u;if(F!==`all`&&(e=e.filter(e=>e.assistant===F)),N.trim()){let t=N.toLowerCase();e=e.filter(e=>`${e.title} ${e.id} ${e.assistant}`.toLowerCase().includes(t))}return H(e,k)},[u,F,N,k]),W=(0,Q.useMemo)(()=>H(u.filter(e=>e.assistant===`antigravity`),k),[u,k]),ae=(0,Q.useMemo)(()=>H(u.filter(e=>e.assistant===`claude`),k),[u,k]),G=(0,Q.useMemo)(()=>H(u.filter(e=>e.assistant===`codex`),k),[u,k]),oe=(0,Q.useMemo)(()=>H(u.filter(e=>e.assistant===`copilot`),k),[u,k]),ce=(0,Q.useCallback)(t=>e.assistants?.includes(t)??!1,[e.assistants]),le=(0,Q.useMemo)(()=>[{id:`antigravity`,name:`Google Antigravity`,cliCommand:`agy`,isDetected:h,isConfigured:ce(`antigravity`),hasApp:y,appName:`IDE`,appTargetId:`antigravity`,sessions:W,icon:(0,$.jsx)(`span`,{className:`grid size-6 place-items-center rounded-md bg-card border border-border/80 shadow-2xs p-0.5`,children:(0,$.jsx)(Qe,{className:`size-4`})})},{id:`claude`,name:`Claude Code`,cliCommand:`claude`,isDetected:g,isConfigured:ce(`claude`),hasApp:!1,appName:`App`,appTargetId:`claude`,sessions:ae,icon:(0,$.jsx)(`span`,{className:`grid size-6 place-items-center rounded-md bg-[#D97757] text-white font-bold text-[10px] shadow-2xs`,children:(0,$.jsx)(Xe,{className:`size-3`})})},{id:`codex`,name:`OpenAI Codex`,cliCommand:`codex`,isDetected:_,isConfigured:ce(`codex`),hasApp:b,appName:`Desktop`,appTargetId:`codex-desktop`,sessions:G,icon:(0,$.jsx)(`span`,{className:`grid size-6 place-items-center rounded-md bg-foreground text-background font-bold text-[10px] shadow-2xs`,children:(0,$.jsx)($e,{className:`size-3`})})},{id:`copilot`,name:`GitHub Copilot`,cliCommand:`copilot`,isDetected:v,isConfigured:ce(`copilot`),hasApp:!1,appName:`App`,appTargetId:`copilot`,sessions:oe,icon:(0,$.jsx)(`span`,{className:`grid size-6 place-items-center rounded-md bg-gradient-to-tr from-purple-600 via-indigo-500 to-blue-600 text-white font-bold text-[10px] shadow-2xs`,children:(0,$.jsx)(nt,{className:`size-3`})})}],[h,g,_,v,y,b,ce,W,ae,G,oe]),ue=(0,Q.useMemo)(()=>le.filter(e=>e.isDetected||e.sessions.length>0),[le]);return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between bg-card/60 p-2 rounded-md border border-border/80`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1 min-w-0 max-w-xs`,children:[(0,$.jsx)(ie,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 size-3 text-muted-foreground`}),(0,$.jsx)(`input`,{type:`text`,value:N,onChange:e=>P(e.target.value),placeholder:`Search chat sessions...`,className:`w-full pl-7 pr-6 py-1 text-xs rounded border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-primary`}),N&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>P(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground text-[10px] cursor-pointer`,children:`✕`})]}),(0,$.jsxs)(`div`,{className:`hidden md:flex items-center gap-1`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>I(`all`),className:q(`px-2 py-0.5 text-[11px] rounded font-medium transition-colors cursor-pointer`,F===`all`?`bg-primary text-primary-foreground font-semibold shadow-2xs`:`bg-muted/60 text-muted-foreground hover:text-foreground hover:bg-muted`),children:[`All (`,u.length,`)`]}),ue.map(e=>{let t=e.sessions.length;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>I(F===e.id?`all`:e.id),className:q(`px-2 py-0.5 text-[11px] rounded font-medium capitalize transition-colors cursor-pointer`,F===e.id?`bg-primary text-primary-foreground font-semibold shadow-2xs`:`bg-muted/60 text-muted-foreground hover:text-foreground hover:bg-muted`),children:[e.name.replace(`Google `,``).replace(`OpenAI `,``).replace(`GitHub `,``),` (`,t,`)`]},e.id)})]}),n&&(0,$.jsx)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground shrink-0 pl-1`,children:(0,$.jsx)(Z,{className:`size-3`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(Cn,{children:[(0,$.jsxs)(Tn,{className:`flex items-center gap-1.5 px-2 py-1 text-xs font-medium rounded border border-border bg-card text-foreground hover:bg-accent cursor-pointer shadow-2xs transition-colors`,children:[(0,$.jsx)(Sn,{size:11,className:`text-muted-foreground`}),(0,$.jsx)(`span`,{children:{"created-desc":`Newest`,"created-asc":`Oldest`,"updated-desc":`Recently active`,"messages-desc":`Most turns`,"title-asc":`A–Z`}[k]}),(0,$.jsx)(je,{size:10,className:`text-muted-foreground opacity-70`})]}),(0,$.jsxs)(hn,{align:`end`,className:`w-48`,children:[(0,$.jsx)(`div`,{className:`px-2 py-1 text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:`Order Chats By`}),(0,$.jsxs)(An,{onClick:()=>A(`created-desc`),className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{children:`Newest created`}),k===`created-desc`&&(0,$.jsx)(zt,{size:12,className:`text-primary`})]}),(0,$.jsxs)(An,{onClick:()=>A(`created-asc`),className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{children:`Oldest created`}),k===`created-asc`&&(0,$.jsx)(zt,{size:12,className:`text-primary`})]}),(0,$.jsxs)(An,{onClick:()=>A(`updated-desc`),className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{children:`Recently active`}),k===`updated-desc`&&(0,$.jsx)(zt,{size:12,className:`text-primary`})]}),(0,$.jsxs)(An,{onClick:()=>A(`messages-desc`),className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{children:`Most turns`}),k===`messages-desc`&&(0,$.jsx)(zt,{size:12,className:`text-primary`})]}),(0,$.jsxs)(An,{onClick:()=>A(`title-asc`),className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{children:`Title (A–Z)`}),k===`title-asc`&&(0,$.jsx)(zt,{size:12,className:`text-primary`})]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center rounded border border-border bg-card p-0.5 shadow-2xs`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>M(`harness`),title:`Group chats by AI Harness`,className:q(`px-2 py-0.5 text-xs rounded font-medium transition-colors cursor-pointer`,j===`harness`?`bg-primary text-primary-foreground font-semibold shadow-2xs`:`text-muted-foreground hover:text-foreground`),children:`Grouped`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>M(`timeline`),title:`Unified Chronological Timeline`,className:q(`px-2 py-0.5 text-xs rounded font-medium transition-colors cursor-pointer`,j===`timeline`?`bg-primary text-primary-foreground font-semibold shadow-2xs`:`text-muted-foreground hover:text-foreground`),children:`Timeline`})]})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(`p`,{children:`Main threads are your conversations. Subagents are delegated tasks that report back to them.`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked)}),`Include subagent sessions`,d?` (${d})`:``]})]}),D&&(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 p-2.5 rounded-md bg-emerald-500/10 border border-emerald-500/30 text-xs animate-fade-in`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground min-w-0`,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full bg-emerald-500 animate-pulse shrink-0`}),(0,$.jsxs)(`span`,{className:`truncate`,children:[(0,$.jsx)(`strong`,{children:`Opened in ContextSpace:`}),` `,(0,$.jsx)(`code`,{className:`font-mono bg-background/80 px-1.5 py-0.5 rounded text-emerald-400`,children:D.cmd})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:async()=>{await Ht(D.cmd),s?.(`Command copied to clipboard!`,`success`)},className:`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium rounded border border-emerald-500/40 bg-emerald-500/15 text-emerald-400 hover:bg-emerald-500/25 transition-colors cursor-pointer`,children:[(0,$.jsx)(Dt,{size:11}),` Copy`]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`text-muted-foreground hover:text-foreground cursor-pointer text-xs px-1`,title:`Dismiss banner`,children:`✕`})]})]}),j===`timeline`?(0,$.jsx)(Bn,{className:`divide-y divide-border overflow-hidden surface-card`,children:U.length===0?(0,$.jsx)(`div`,{className:`py-8 text-center text-xs text-muted-foreground`,children:N?`No chat sessions match your search filter.`:`No chat sessions recorded yet.`}):U.map(e=>(0,$.jsxs)(`div`,{className:`group flex flex-col gap-2 p-3 hover:bg-accent/40 transition-colors sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[Zr(e.assistant),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground mb-0.5`,children:[(0,$.jsx)(`span`,{className:`font-semibold capitalize text-foreground`,children:e.assistant===`antigravity`?`Antigravity`:e.assistant===`claude`?`Claude`:e.assistant===`codex`?`Codex`:`Copilot`}),(0,$.jsx)(`span`,{children:`•`}),(0,$.jsx)(`span`,{className:`font-mono text-muted-foreground/80`,children:e.id.slice(0,8)}),(0,$.jsx)(jn,{session:e}),(0,$.jsx)(`span`,{children:`•`}),(0,$.jsx)(yn,{session:e}),(0,$.jsx)(`span`,{children:`•`}),(0,$.jsxs)(`span`,{className:`font-mono`,children:[e.messageCount,` `,e.messageCount===1?`turn`:`turns`]})]}),(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground truncate`,title:e.title,children:e.title})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 pl-8 sm:pl-0`,children:[(0,$.jsxs)(Y,{size:`xs`,variant:`default`,disabled:C===e.id||!rn(e,t),onClick:()=>{let n=rn(e,t);n&&V(n.id,n.assistant,n.workspacePath)},title:e.threadKind===`subagent`?`Resume the main conversation instead of the delegated task`:`Resume session in terminal (${e.id})`,children:[C===e.id?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(Fn,{size:12}),(0,$.jsx)(`span`,{children:e.threadKind===`subagent`?`Main thread`:`Resume`})]}),(0,$.jsxs)(Y,{size:`xs`,variant:`outline`,onClick:()=>{r(e),i([]),a(e.assistant,e.id)},title:`Inspect transcript log`,children:[(0,$.jsx)(Mt,{size:12}),(0,$.jsx)(`span`,{children:`Logs`})]}),e.assistant===`codex`&&b&&(0,$.jsxs)(Y,{size:`xs`,variant:`outline`,disabled:x===e.id,onClick:()=>void re(e.id),title:`Open in Codex Desktop`,children:[x===e.id?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(Ze,{size:12}),(0,$.jsx)(`span`,{children:`Desktop`})]}),(0,$.jsx)(Y,{size:`icon-xs`,variant:`ghost`,onClick:async()=>{let t=Xr(e.assistant,e.id);await Ht(t),s?.(`Copied: ${t}`,`success`)},title:`Copy CLI resume command`,children:(0,$.jsx)(Dt,{size:12})})]})]},e.id))}):(0,$.jsx)(`div`,{className:`space-y-2.5`,children:ue.map(e=>{let n=L[e.id]??!1,o=e.sessions.filter(e=>{if(!N.trim())return!0;let t=N.toLowerCase();return`${e.title} ${e.id}`.toLowerCase().includes(t)});return(0,$.jsxs)(Bn,{className:`overflow-hidden surface-card`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between bg-muted/20 hover:bg-muted/35 transition-colors cursor-pointer select-none`,onClick:()=>R(e.id),children:[(0,$.jsxs)(`div`,{className:`flex flex-1 items-center gap-2.5 min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground transition-transform`,children:n?(0,$.jsx)(je,{size:14}):(0,$.jsx)(Qt,{size:14})}),e.icon,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 min-w-0`,children:[(0,$.jsx)(`span`,{className:`font-bold text-xs text-foreground`,children:e.name}),(0,$.jsxs)(Ct,{tone:e.isDetected?`success`:`neutral`,dot:e.isDetected,children:[`CLI: `,e.cliCommand]}),e.hasApp&&(0,$.jsx)(Ct,{tone:`running`,children:e.appName}),(0,$.jsxs)(`span`,{className:`text-[11px] text-muted-foreground font-mono`,children:[`(`,o.length,`)`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 pl-6 sm:pl-0`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(Y,{size:`xs`,variant:`default`,disabled:T===e.id,onClick:()=>void B(e.id),title:`Launch new ${e.cliCommand} session in terminal`,children:[T===e.id?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(Pt,{size:12}),(0,$.jsx)(`span`,{children:`New Session`})]}),e.hasApp&&(0,$.jsxs)(Y,{size:`xs`,variant:`outline`,onClick:()=>void ne(e.appTargetId),title:`Open in ${e.appName}`,children:[(0,$.jsx)(Ze,{size:12}),(0,$.jsx)(`span`,{children:e.appName})]})]})]}),n&&(0,$.jsx)(`div`,{className:`divide-y divide-border/60 border-t border-border`,children:o.length===0?(0,$.jsxs)(`div`,{className:`p-4 text-center text-xs text-muted-foreground flex items-center justify-center gap-2`,children:[(0,$.jsx)(`span`,{children:N?`No sessions match your search query.`:`No previous sessions recorded for ${e.name}.`}),!N&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void B(e.id),className:`text-primary font-semibold hover:underline cursor-pointer inline-flex items-center gap-1 text-xs`,children:[(0,$.jsx)(Pt,{size:11}),` Start session`]})]}):o.map(e=>(0,$.jsxs)(`div`,{className:`group flex flex-col gap-1.5 px-3.5 py-2.5 hover:bg-accent/40 transition-colors sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-0.5 text-[11px] text-muted-foreground font-mono`,children:[(0,$.jsx)(`span`,{children:e.id.slice(0,8)}),(0,$.jsx)(jn,{session:e}),(0,$.jsx)(`span`,{children:`•`}),(0,$.jsx)(yn,{session:e}),(0,$.jsx)(`span`,{children:`•`}),(0,$.jsxs)(`span`,{children:[e.messageCount,` `,e.messageCount===1?`turn`:`turns`]})]}),(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground truncate`,title:e.title,children:e.title})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,$.jsxs)(Y,{size:`xs`,variant:`default`,disabled:C===e.id||!rn(e,t),onClick:()=>{let n=rn(e,t);n&&V(n.id,n.assistant,n.workspacePath)},title:e.threadKind===`subagent`?`Resume the main conversation instead of the delegated task`:`Resume session in terminal (${e.id})`,children:[C===e.id?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(Fn,{size:12}),(0,$.jsx)(`span`,{children:e.threadKind===`subagent`?`Main thread`:`Resume`})]}),(0,$.jsxs)(Y,{size:`xs`,variant:`outline`,onClick:()=>{r(e),i([]),a(e.assistant,e.id)},title:`Inspect transcript log`,children:[(0,$.jsx)(Mt,{size:12}),(0,$.jsx)(`span`,{children:`Logs`})]}),e.assistant===`codex`&&b&&(0,$.jsxs)(Y,{size:`xs`,variant:`outline`,disabled:x===e.id,onClick:()=>void re(e.id),title:`Open in Codex Desktop`,children:[x===e.id?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(Ze,{size:12}),(0,$.jsx)(`span`,{children:`Desktop`})]}),(0,$.jsx)(Y,{size:`icon-xs`,variant:`ghost`,onClick:async()=>{let t=Xr(e.assistant,e.id);await Ht(t),s?.(`Copied: ${t}`,`success`)},title:`Copy CLI resume command`,children:(0,$.jsx)(Dt,{size:12})})]})]},e.id))})]},e.id)})})]})},$r=({ws:e,gitChanges:t,gitChangesLoading:n,syncLoading:r,syncResults:i,commitMessage:a,showCommitModal:o,commitLoading:s,commitResults:c,setSyncResults:l,setCommitResults:u,setCommitMessage:d,setShowCommitModal:f,fetchGitChanges:p,handleSyncAll:m,handleCommitAll:h,showToast:g})=>{let[_,v]=(0,Q.useState)({}),[y,b]=(0,Q.useState)({}),[x,S]=(0,Q.useState)({}),[C,w]=(0,Q.useState)({}),[T,E]=(0,Q.useState)({}),[D,O]=(0,Q.useState)({}),[k,A]=(0,Q.useState)({}),[j,M]=(0,Q.useState)({}),[N,P]=(0,Q.useState)(0),[F,I]=(0,Q.useState)(``),[ee,R]=(0,Q.useState)(0),[z,te]=(0,Q.useState)({}),[ne,B]=(0,Q.useState)(!1),V=_e().data?.config,re=Jt(),H=V?.defaultEditor,U=tn(H),W=fn(),ie=t.filter(e=>e.files&&e.files.length>0),ae=ie.reduce((e,t)=>e+t.files.length,0);(0,Q.useEffect)(()=>{S({}),w({}),E({}),O({}),b({}),M({}),te({}),En.clear()},[e.branchName]),(0,Q.useEffect)(()=>{if(!t||t.length===0){En.clear();return}let n=!1,r=new Set;for(let e of t)for(let t of e.files||[])r.add(`${e.repoName}/${t.file}`);for(let e of En.getAllSymbols())r.has(`${e.repoName}/${e.filePath}`)||En.removeFile(e.repoName,e.filePath);return(async()=>{try{let t=encodeURIComponent(e.branchName),r=await fetch(`/api/workspace/${t}/changes/symbols`);if(r.ok&&!n){let e=await r.json();if(e.symbols&&Array.isArray(e.symbols)){let t={};for(let n of e.symbols){let e=`${n.repoName}/${n.filePath}`;t[e]||(t[e]={repoName:n.repoName,filePath:n.filePath,repoPath:n.repoPath,symbols:[]}),t[e].symbols.push(n)}for(let e of Object.values(t)){if(n)break;O(t=>({...t,[`${e.repoName}/${e.filePath}`]:e.symbols})),En.indexFile(e.repoName,e.filePath,``,[],e.repoPath,e.symbols)}}}}catch{}})(),()=>{n=!0}},[t,e.branchName]);let G=(0,Q.useMemo)(()=>{let e=[];for(let t of ie)for(let n of t.files||[])e.push({repoName:t.repoName,repoPath:t.repoPath,file:n.file,type:n.type,additions:n.additions||0,deletions:n.deletions||0});return e},[ie]),oe=e=>_[e]??!0,se=e=>{v(t=>({...t,[e]:!oe(e)}))},ce=()=>{let e={};t.forEach(t=>{e[t.repoName]=!1}),v(e)},ue=()=>{let e={};t.forEach(t=>{e[t.repoName]=!0}),v(e),b({})},de=(0,Q.useCallback)(async(n,r)=>{let i=`${n}/${r}`,a=!y[i];if(b(e=>({...e,[i]:a})),a&&!x[i]){A(e=>({...e,[i]:!0})),M(e=>({...e,[i]:``}));try{let a=encodeURIComponent(e.branchName),o=await fetch(`/api/workspace/${a}/changes/diff?repo=${encodeURIComponent(n)}&file=${encodeURIComponent(r)}`);if(!o.ok)throw Error(`Failed to load diff: ${o.statusText}`);let s=await o.json();if(S(e=>({...e,[i]:s.diff||``})),s.fileContent&&w(e=>({...e,[i]:s.fileContent})),s.originalContent&&E(e=>({...e,[i]:s.originalContent})),s.symbols&&O(e=>({...e,[i]:s.symbols})),s.diff){let e=Vt(s.diff),i=s.fileContent||e.modifiedContent,a=t.find(e=>e.repoName===n);En.indexFile(n,r,i,e.hunks,a?.repoPath,s.symbols)}}catch(e){M(t=>({...t,[i]:e.message||`Unknown error`}))}finally{A(e=>({...e,[i]:!1}))}}},[y,x,e.branchName,t]),fe=(0,Q.useCallback)(async(e,t)=>{if(e<0||e>=G.length)return;P(e);let n=G[e];I(`${n.repoName}/${n.file}`),R(e=>e+1);let r=`${n.repoName}/${n.file}`;v(e=>({...e,[n.repoName]:!1})),t!==void 0&&te(e=>({...e,[r]:t})),y[r]||await de(n.repoName,n.file);let i=`file-diff-${n.repoName}-${n.file.replace(/[^a-zA-Z0-9_-]/g,`_`)}`;setTimeout(()=>{let e=document.getElementById(i);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})},50)},[G,y,de]),pe=(n,r,i)=>{let a=r.replace(/\\/g,`/`).replace(/^\//,``),o=G.findIndex(e=>{let t=e.file.replace(/\\/g,`/`).replace(/^\//,``);return(e.repoName===n||n===`workspace`||!n)&&(t===a||t.endsWith(a)||a.endsWith(t))});if(o!==-1)fe(o,i),g?.(`Navigated to ${r}${i?`:${i}`:``}`,`info`);else{g?.(`Opening ${r}${i?`:${i}`:``} in ${U}`,`info`);let a=t.find(e=>e.repoName===n)?.repoPath||e.repos&&e.repos.find(e=>e.endsWith(n))||n;In(a,r,i||1,1,H)}};(0,Q.useEffect)(()=>{let e=e=>{let t=e.target;if(!(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)){if(e.altKey&&(e.key===`ArrowDown`||e.key===`Down`)){if(e.preventDefault(),G.length>0){let e=(N+1)%G.length;fe(e)}}else if(e.altKey&&(e.key===`ArrowUp`||e.key===`Up`)&&(e.preventDefault(),G.length>0)){let e=(N-1+G.length)%G.length;fe(e)}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,G,fe]);let me=G[N]||null;return(0,$.jsxs)(`div`,{className:`animate-fade-in`,children:[(0,$.jsxs)(`header`,{className:`flex justify-between items-center mb-4 flex-wrap gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,$.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-bold text-foreground`,children:[(0,$.jsx)(ge,{size:16,className:`text-primary`}),` Active Workspace Git Diffs`]}),ie.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 pl-2 border-l border-border/80`,children:[(0,$.jsxs)(Y,{variant:`ghost`,size:`xs`,onClick:ue,title:`Collapse all repositories and file diffs`,className:`text-xs text-muted-foreground hover:text-foreground h-7 px-2 gap-1 font-semibold`,children:[(0,$.jsx)(Gn,{size:12}),(0,$.jsx)(`span`,{children:`Collapse All`})]}),(0,$.jsxs)(Y,{variant:`ghost`,size:`xs`,onClick:ce,title:`Expand all repositories`,className:`text-xs text-muted-foreground hover:text-foreground h-7 px-2 gap-1 font-semibold`,children:[(0,$.jsx)(Kn,{size:12}),(0,$.jsx)(`span`,{children:`Expand All`})]})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>p(e.branchName),disabled:n,children:[(0,$.jsx)(_n,{size:11,className:n?`animate-spin text-primary`:``}),` Refresh Changes`]}),e.mode!==`in-place`&&(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>m(e.branchName),disabled:r,children:[r?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(_n,{size:11}),` Sync All`]}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>f(!0),disabled:ae===0||s,children:`Commit & Push All`})]})]}),G.length>0&&(0,$.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-center justify-between gap-2.5 rounded-xl border border-border/90 bg-card/75 p-2.5 px-3.5 backdrop-blur-md shadow-xs select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`span`,{className:`grid size-6 place-items-center rounded-md bg-primary/10 text-primary shrink-0`,children:(0,$.jsx)(er,{size:12})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 font-mono text-xs font-semibold text-foreground`,children:[(0,$.jsx)(`span`,{children:`File`}),(0,$.jsx)(`span`,{className:`rounded bg-primary/15 border border-primary/25 px-1.5 py-0.2 text-primary`,children:N+1}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`of `,G.length]})]}),(0,$.jsx)(`select`,{value:N,onChange:e=>void fe(Number(e.target.value)),className:`ml-2 max-w-[240px] sm:max-w-[360px] rounded-lg border border-border bg-background/80 px-2 py-1 font-mono text-[11px] text-foreground focus:outline-hidden focus:ring-1 focus:ring-primary truncate`,children:G.map((e,t)=>(0,$.jsxs)(`option`,{value:t,children:[`[`,e.type.slice(0,3),`] `,e.repoName,`: `,e.file,` (+`,e.additions,` -`,e.deletions,`)`]},`${e.repoName}/${e.file}`))})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{let e=(N-1+G.length)%G.length;fe(e)},className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-border bg-card hover:bg-accent font-mono text-[10px] text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Jump to previous modified file (Shortcut: Alt+Up)`,children:[(0,$.jsx)(He,{size:12}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Prev (Alt+↑)`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{let e=(N+1)%G.length;fe(e)},className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-border bg-card hover:bg-accent font-mono text-[10px] text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Jump to next modified file (Shortcut: Alt+Down)`,children:[(0,$.jsx)(je,{size:12}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Next (Alt+↓)`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>B(e=>!e),className:q(`inline-flex items-center gap-1 px-2 py-1 rounded border font-mono text-[10px] transition-colors cursor-pointer`,ne?`border-primary/50 bg-primary/15 text-primary font-bold`:`border-border bg-card hover:bg-accent text-muted-foreground hover:text-foreground`),title:`Toggle Global Changeset Symbol Explorer`,children:[(0,$.jsx)(yt,{size:12}),(0,$.jsxs)(`span`,{children:[`Symbols (`,W.length,`)`]})]}),me&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{In(me.repoPath,me.file,1,1,H),g?.(`Opened ${me.file} in ${U}`,`success`)},className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-border bg-card hover:bg-accent font-mono text-[10px] text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Open selected file in desktop ${U}`,children:[(0,$.jsx)(Ze,{size:11}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:U})]})]})]}),ne&&(0,$.jsx)(`div`,{className:`mb-5`,children:(0,$.jsx)(ln,{symbols:W,activeFilePath:me?.file,editorLabel:U,onSelectSymbol:e=>{pe(e.repoName,e.filePath,e.lineNumber)},onOpenInVsCode:e=>{let n=G.find(t=>t.repoName===e.repoName&&t.file===e.filePath)||G.find(t=>t.file===e.filePath),r=e.repoPath||n?.repoPath||t.find(t=>t.repoName===e.repoName)?.repoPath||e.repoName;In(r,e.filePath,e.lineNumber,e.column,H),g?.(`Opened ${e.filePath}:${e.lineNumber} in ${U}`,`success`)},onClose:()=>B(!1)})}),i&&e.mode!==`in-place`&&(0,$.jsxs)(`div`,{className:`relative mb-5 rounded-xl border border-info/25 bg-info/10 p-5 text-info-foreground shadow-sm`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between border-b border-info/20 pb-2`,children:[(0,$.jsx)(`h5`,{className:`font-mono text-xs font-bold text-foreground`,children:`Rebase / Sync Action Logs`}),(0,$.jsx)(`button`,{className:`cursor-pointer text-[10px] font-bold text-info-foreground hover:text-foreground`,onClick:()=>l(null),children:`Dismiss`})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:i.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-card p-2 font-mono text-[10px]`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.repoName}),(0,$.jsx)(`span`,{className:e.success?`font-bold text-success-foreground`:`font-bold text-destructive-foreground`,children:e.success?`✓ Synced (${e.message})`:`✗ Conflict: ${e.message}`})]},e.repoName))})]}),c&&(0,$.jsxs)(`div`,{className:`relative mb-5 rounded-xl border border-success/25 bg-success/10 p-5 text-success-foreground shadow-sm`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between border-b border-success/20 pb-2`,children:[(0,$.jsx)(`h5`,{className:`font-mono text-xs font-bold text-foreground`,children:`Commit & Push Results`}),(0,$.jsx)(`button`,{className:`cursor-pointer text-[10px] font-bold text-success-foreground hover:text-foreground`,onClick:()=>u(null),children:`Dismiss`})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:c.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-card p-2 font-mono text-[10px]`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.repoName}),(0,$.jsx)(`span`,{className:e.success?`font-bold text-success-foreground`:`font-bold text-destructive-foreground`,children:e.success?`✓ Committed ${e.filesChanged} file(s) (${e.commitHash?e.commitHash.slice(0,7):`no hash`})`:`✗ Error: ${e.message}`})]},e.repoName))})]}),o&&(0,$.jsxs)(`div`,{className:`relative mb-6 rounded-xl border border-border bg-card p-6 shadow-sm animate-rise`,children:[(0,$.jsxs)(`h5`,{className:`mb-3 flex items-center gap-1.5 text-xs font-bold text-foreground`,children:[(0,$.jsx)(vt,{size:13,className:`text-primary`}),` Enter Commit Message`]}),(0,$.jsx)(L,{type:`text`,className:`mb-4 font-mono text-xs`,placeholder:`feat: implement multi-repo logic...`,value:a,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Enter`&&a.trim()&&h(e.branchName)}}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2.5`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>{f(!1),d(``)},disabled:s,children:`Cancel`}),(0,$.jsxs)(Y,{size:`sm`,onClick:()=>h(e.branchName),disabled:s||!a.trim(),children:[s?(0,$.jsx)(Z,{className:`size-3`}):null,s?`Committing...`:`Commit & Push All`]})]})]}),n?(0,$.jsx)(`div`,{className:`flex justify-center py-20`,children:(0,$.jsx)(Z,{className:`size-6 text-primary`})}):(0,$.jsx)(`div`,{className:`space-y-4`,children:ie.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-border bg-card py-16 text-center shadow-xs`,children:[(0,$.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-full border border-success/25 bg-success/10 text-success-foreground shadow-sm`,children:(0,$.jsx)(zt,{size:20})}),(0,$.jsx)(`h5`,{className:`text-sm font-bold text-foreground`,children:`No Uncommitted Changes`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Workspace repositories are completely in sync with Git feature branches.`})]}):ie.map(t=>{let n=t.files.length,r=t.files.reduce((e,t)=>e+(t.additions||0),0),i=t.files.reduce((e,t)=>e+(t.deletions||0),0),a=oe(t.repoName);return(0,$.jsxs)(`div`,{className:`relative rounded-xl border border-border/80 bg-card/80 backdrop-blur-md transition-all shadow-xs overflow-hidden`,children:[(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>se(t.repoName),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),se(t.repoName))},className:q(`flex justify-between items-center px-5 py-4 cursor-pointer select-none transition-colors`,a?`hover:bg-accent/40`:`bg-muted/20 border-b border-border/60 hover:bg-muted/30`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap min-w-0`,children:[(0,$.jsx)(`span`,{className:`grid size-6 place-items-center rounded-md bg-primary/10 text-primary border border-primary/20 shrink-0`,children:a?(0,$.jsx)(Qt,{size:14,className:`shrink-0 text-muted-foreground`}):(0,$.jsx)(je,{size:14,className:`shrink-0 text-primary`})}),(0,$.jsx)(`h5`,{className:`font-mono text-sm font-bold text-foreground truncate`,children:t.repoName}),(0,$.jsxs)(Ct,{tone:`warning`,dot:!1,children:[n,` file`,n===1?``:`s`,` changed`]}),(r>0||i>0)&&(0,$.jsxs)(`span`,{className:`rounded-md border border-border bg-muted/60 px-2 py-0.5 font-mono text-[10px] font-bold`,children:[(0,$.jsxs)(`span`,{className:`font-bold text-success-foreground`,children:[`+`,r]}),` `,(0,$.jsxs)(`span`,{className:`font-bold text-destructive-foreground`,children:[`-`,i]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,$.jsx)(`span`,{className:`max-w-[280px] truncate font-mono text-[10px] text-muted-foreground hidden md:inline`,title:t.repoPath,children:t.repoPath}),(0,$.jsx)(`span`,{className:`text-[11px] font-bold text-primary hover:underline`,children:a?`Expand Files`:`Collapse`})]})]}),!a&&(0,$.jsx)(`div`,{className:`p-5 flex flex-col gap-3 bg-card/40`,children:(0,$.jsx)(Pn,{label:`${t.repoName} changed files`,files:t.files,revealPath:F.startsWith(`${t.repoName}/`)?F.slice(t.repoName.length+1):void 0,revealKey:ee,renderFile:n=>{let r=`${t.repoName}/${n.file}`,i=!!y[r],a=!!k[r],o=x[r]||``,s=j[r]||``,c=`file-diff-${t.repoName}-${n.file.replace(/[^a-zA-Z0-9_-]/g,`_`)}`;return(0,$.jsxs)(`div`,{id:c,className:`overflow-hidden rounded transition-colors`,children:[(0,$.jsxs)(`div`,{className:`flex cursor-pointer select-none items-center justify-between px-2 py-1.5 transition-colors hover:bg-accent/50`,role:`button`,tabIndex:0,"aria-expanded":i,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),de(t.repoName,n.file))},onClick:()=>de(t.repoName,n.file),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[i?(0,$.jsx)(je,{size:14,className:`shrink-0 text-primary`}):(0,$.jsx)(Qt,{size:14,className:`shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`max-w-[240px] truncate font-mono text-[11px] text-foreground sm:max-w-[480px] font-semibold`,title:n.file,children:n.file.split(`/`).at(-1)}),(n.additions>0||n.deletions>0)&&(0,$.jsxs)(`span`,{className:`ml-1 shrink-0 font-mono text-[9px] font-bold text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`text-success-foreground`,children:[`+`,n.additions]}),` /`,` `,(0,$.jsxs)(`span`,{className:`text-destructive-foreground`,children:[`-`,n.deletions]})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2.5 shrink-0`,children:(0,$.jsx)(`span`,{className:`rounded border px-2 py-0.5 text-[8px] font-bold uppercase tracking-wider ${n.type===`added`?`border-success/25 bg-success/10 text-success-foreground`:n.type===`deleted`?`border-destructive/25 bg-destructive/10 text-destructive-foreground`:`border-warning/25 bg-warning/10 text-warning-foreground`}`,children:n.type})})]}),i&&(0,$.jsx)(`div`,{className:`border-t border-border bg-background p-3`,children:a?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-2 font-mono text-[10px] text-primary`,children:[(0,$.jsx)(Z,{className:`size-3`}),` Loading diff...`]}):s?(0,$.jsxs)(`div`,{className:`p-2 font-mono text-[10px] text-destructive-foreground`,children:[`Error: `,s]}):(0,$.jsx)(bt,{filePath:n.file,fallbackContent:o,children:(0,$.jsx)(on,{filePath:n.file,repoName:t.repoName,repoPath:t.repoPath,patchText:o,fullFileContent:C[r],fullOriginalContent:T[r],preExtractedSymbols:D[r],defaultEditor:H,viewMode:re.diffViewMode,onToggleViewMode:re.toggleDiffMode,onRequestRefine:(r,i)=>{le.openDraft(e.branchName,[`Refine ${t.repoName}/${n.file} at line ${r.startLineModified}.`,i,`Selected diff hunk:`,r.patchHeader,...r.lines].join(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-DE3RlOCf.js";import{A as r,C as i,F as a,Gn as o,Gt as s,H as c,Ht as l,I as u,J as d,Kn as f,L as p,M as m,Mn as h,N as g,O as _,P as v,R as y,Vn as b,Wt as x,X as S,Xt as C,Y as w,Yn as T,Yt as E,Z as D,_ as O,_n as k,at as A,bn as j,cn as M,g as N,in as P,j as F,k as I,n as L,nn as ee,nt as R,q as z,qn as te,qt as ne,sn as B,t as V,tt as re,v as H,yt as U,z as W}from"./badge-BObbahyU.js";import{$ as ie,A as ae,D as G,E as oe,F as se,G as ce,H as le,I as ue,M as de,R as fe,U as pe,_ as me,a as he,et as ge,i as _e,j as ve,k as ye,m as be,n as xe,r as Se,t as Ce,u as we,v as Te,x as Ee,z as De}from"./queries-DdbBkqm6.js";import{c as Oe,h as K,i as ke,l as Ae,m as q,p as J,t as Y}from"./button-BrcP8Wxx.js";import{t as je}from"./chevron-down-Dy03VL1q.js";import{_ as Me,a as Ne,d as Pe,f as Fe,g as Ie,l as Le,n as Re,o as ze,s as Be,u as Ve,x as He}from"./isElementDisabled-BONWqXlb.js";import{a as Ue,i as We,n as Ge,o as Ke,r as qe,s as Je,t as Ye}from"./square-check-big-DpHMT26q.js";import{a as Xe,g as Ze,i as Qe,m as $e,n as et,r as tt,s as nt}from"./status-CKOvrZ16.js";import{t as rt}from"./shield-check-FLrrAOFP.js";import{n as it,r as at,t as ot}from"./vsc-EOWFTqft.js";import{t as st}from"./trash-2-BrrLX4tD.js";import{a as ct,i as lt,n as ut,r as dt,t as ft}from"./tabs-8D2uSv1C.js";import{d as pt,o as mt,t as ht}from"./brand-hHByyyzq.js";import{n as X}from"./client-B5szthbF.js";import{$t as gt,A as _t,At as vt,Bt as yt,C as bt,Ct as xt,D as Z,Dt as St,E as Ct,Et as wt,F as Tt,Ft as Et,Gt as Dt,H as Ot,Ht as kt,It as At,Kt as jt,Lt as Mt,M as Nt,Mt as Pt,N as Ft,Nt as It,O as Lt,P as Rt,Qt as zt,Rt as Bt,S as Vt,T as Ht,Tt as Ut,U as Wt,Ut as Gt,V as Kt,Vt as qt,W as Jt,Wt as Yt,Xt,Yt as Zt,Zt as Qt,_t as $t,a as en,b as tn,bt as nn,c as rn,ct as an,d as on,dt as sn,en as cn,f as ln,ft as un,gt as dn,h as fn,ht as pn,i as mn,it as hn,j as gn,jt as _n,k as vn,l as yn,mt as bn,n as xn,nn as Sn,nt as Cn,o as wn,ot as Tn,p as En,pt as Dn,qt as On,r as kn,rt as An,s as jn,t as Mn,tn as Nn,w as Pn,wt as Fn,x as In,xt as Ln,yt as Rn,zt as zn}from"./index-BxUZKLC0.js";import{t as Bn}from"./card-BMggHY3n.js";import{t as Vn}from"./label-C610MHwq.js";var Hn=K(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Un=K(`building-2`,[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]]),Wn=K(`calendar`,[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]),Gn=K(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),Kn=K(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),qn=K(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),Jn=K(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Yn=K(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Xn=K(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Zn=K(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Qn=K(`git-compare`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]),$n=K(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),er=K(`navigation`,[[`polygon`,{points:`3 11 22 2 13 21 11 13 3 11`,key:`1ltx0t`}]]),tr=K(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),nr=K(`puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),rr=K(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),ir=K(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),ar=K(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),or=K(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),sr=K(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),cr=K(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Q=e(t(),1);function lr(e){let{popupElement:t,positionerElement:n,content:r,mounted:i,onMeasureLayout:a,onMeasureLayoutComplete:o,side:c,direction:l}=e,u=s(t,!0),d=ne(),f=Q.useRef(null),p=Q.useRef(!0),m=Q.useRef(Ae),h=M(a),g=M(o),_=Q.useMemo(()=>ur(c,l),[c,l]);B(()=>{if(!i){m.current=Ae,p.current=!0,f.current=null;return}if(!t||!n)return;m.current=fr(t,_),pr(t,`auto`);let e=dr(t,`position`,`static`),r=dr(t,`transform`,`none`),a=dr(t,`scale`,`1`),o=fr(n,{"--available-width":`max-content`,"--available-height":`max-content`});function s(){e(),r(),o()}function c(){s(),a()}if(h?.(),p.current||f.current===null){mr(n,`max-content`);let e=ct(t);return f.current=e,mr(n,e),c(),g?.(null,e),p.current=!1,()=>{m.current(),m.current=Ae}}mr(n,`max-content`);let l=f.current,v=ct(t);f.current=v,pr(t,l),c(),g?.(l,v),mr(n,v);let y=new AbortController;return d.request(()=>{pr(t,v),u(()=>{t.style.setProperty(`--popup-width`,`auto`),t.style.setProperty(`--popup-height`,`auto`)},y.signal)}),()=>{y.abort(),d.cancel(),m.current(),m.current=Ae}},[r,t,n,u,d,i,h,g,_])}function ur(e,t){let n=e===`top`,r=e===`left`||e===(t===`rtl`?`inline-end`:`inline-start`);return!n&&!r?Oe:{position:`absolute`,[n?`bottom`:`top`]:`0`,[r?`right`:`left`]:`0`}}function dr(e,t,n){let r=e.style.getPropertyValue(t);return e.style.setProperty(t,n),()=>{e.style.setProperty(t,r)}}function fr(e,t){let n=[];for(let[r,i]of Object.entries(t))n.push(dr(e,r,i));return n.length?()=>{n.forEach(e=>e())}:Ae}function pr(e,t){let n=t===`auto`?`auto`:`${t.width}px`,r=t===`auto`?`auto`:`${t.height}px`;e.style.setProperty(`--popup-width`,n),e.style.setProperty(`--popup-height`,r)}function mr(e,t){let n=t===`max-content`?`max-content`:`${t.width}px`,r=t===`max-content`?`max-content`:`${t.height}px`;e.style.setProperty(`--positioner-width`,n),e.style.setProperty(`--positioner-height`,r)}var hr={name:`adaptiveOrigin`,async fn(e){let{x:t,y:n,rects:{floating:r},elements:{floating:i},platform:a,strategy:o,placement:s}=e,c=k(i),l=c.getComputedStyle(i);if(l.transitionDuration===`0s`||l.transitionDuration===``)return{x:t,y:n,data:Ve};let u=await a.getOffsetParent?.(i),d={width:0,height:0};if(o===`fixed`&&c?.visualViewport)d={width:c.visualViewport.width,height:c.visualViewport.height};else if(u===c){let e=P(i);d={width:e.documentElement.clientWidth,height:e.documentElement.clientHeight}}else await a.isElement?.(u)&&(d=await a.getDimensions(u));let f=Me(s),p=t,m=n;f===`left`&&(p=d.width-(t+r.width)),f===`top`&&(m=d.height-(n+r.height));let h=f===`left`?`right`:Ve.sideX,g=f===`top`?`bottom`:Ve.sideY;return{x:p,y:m,data:{sideX:h,sideY:g}}}},gr=e(T(),1),$=n(),_r={activationDirection:e=>e?{"data-activation-direction":e}:null};function vr(e){let{store:t,side:n,children:r}=e,i=O(),a=t.useState(`activeTriggerElement`),o=t.useState(`activeTriggerId`),c=t.useState(`open`),l=t.useState(`payload`),u=t.useState(`mounted`),d=t.useState(`popupElement`),f=t.useState(`positionerElement`),p=Re(c?a:null),m=Sr(o,l),h=Q.useRef(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),b=Q.useRef(null),x=Q.useRef(null),S=s(b,!0),C=ne(),w=Q.useRef(null),[T,E]=Q.useState(null),[D,k]=Q.useState(!1);B(()=>(t.set(`adaptiveOrigin`,hr),()=>{t.set(`adaptiveOrigin`,void 0)}),[t]);let A=M(()=>{b.current?.style.setProperty(`animation`,`none`),b.current?.style.setProperty(`transition`,`none`),x.current?.style.setProperty(`display`,`none`)}),j=M(e=>{b.current?.style.removeProperty(`animation`),b.current?.style.removeProperty(`transition`),x.current?.style.removeProperty(`display`),e&&E(e)}),N=M(()=>{w.current?.abort();let e=new AbortController;w.current=e,S(()=>{_(null),E(null),h.current=null},e.signal)}),F=Q.useRef(null);B(()=>{(!c||!u)&&(F.current=null)},[c,u]),B(()=>{if(a&&p&&a!==p&&F.current!==a&&h.current){_(h.current),k(!0);let e=xr(p,a);y(e),F.current=a}},[a,p]),B(()=>{g!=null&&(w.current?.abort(),k(!0),C.request(()=>{gr.flushSync(()=>{k(!1)}),N()}))},[m,g,N,C]),B(()=>{let e=b.current;if(!e)return;let t=P(e).createElement(`div`);for(let n of Array.from(e.childNodes))t.appendChild(n.cloneNode(!0));h.current=t});let I=g!=null,L;L=I?(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(`div`,{"data-previous":!0,inert:H(!0),ref:x,style:{...T?{"--popup-width":`${T.width}px`,"--popup-height":`${T.height}px`}:null,position:`absolute`},"data-ending-style":D?void 0:``},`previous`),(0,$.jsx)(`div`,{"data-current":!0,ref:b,"data-starting-style":D?``:void 0,children:r},m)]}):(0,$.jsx)(`div`,{"data-current":!0,ref:b,children:r},m),B(()=>{let e=x.current;!e||!g||e.replaceChildren(...Array.from(g.childNodes))},[g]),lr({popupElement:d,positionerElement:f,mounted:u,content:l,onMeasureLayout:A,onMeasureLayoutComplete:j,side:n,direction:i});let ee={activationDirection:yr(v),transitioning:I};return{children:L,state:ee}}function yr(e){if(e)return`${br(e.horizontal,5,`right`,`left`)} ${br(e.vertical,5,`down`,`up`)}`}function br(e,t,n,r){return e>t?n:e<-t?r:``}function xr(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i={x:n.left+n.width/2,y:n.top+n.height/2},a={x:r.left+r.width/2,y:r.top+r.height/2};return{horizontal:a.x-i.x,vertical:a.y-i.y}}function Sr(e,t){let[n,r]=Q.useState(0),i=Q.useRef(e),a=Q.useRef(t),o=Q.useRef(!1);return B(()=>{let n=i.current,s=a.current,c=e!==n,l=t!==s;c?(r(e=>e+1),o.current=!l):o.current&&l&&(r(e=>e+1),o.current=!1),i.current=e,a.current=t},[e,t]),`${e??`current`}-${n}`}function Cr({ws:e}){let t=e.branchName,n=fe(t),r=ye(t),i=Te(t),a=n.data,o=(0,Q.useMemo)(()=>a?.services??[],[a]),s=(0,Q.useMemo)(()=>a?.runningState??[],[a]),c=a?.orchestrationTools??[],l=(0,Q.useMemo)(()=>a?.runningOrchestrators??[],[a]),u=(0,Q.useMemo)(()=>l.filter(e=>e.mode===`pm2`&&e.logName),[l]),[d,f]=(0,Q.useState)(`classic`),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=[...o.map(e=>e.name),...u.map(e=>e.logName)];e.length===0?h!==null&&g(null):(!h||!e.includes(h))&&g(e[0])},[o,u]);let{logs:_,connected:v,clear:y}=Kt(t,h,!0),b=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{b.current?.scrollIntoView({behavior:`smooth`})},[_]);let x=(0,Q.useMemo)(()=>new Set(s.filter(e=>e.pid>0).map(e=>e.name)),[s]),S=(0,Q.useMemo)(()=>new Set(l.map(e=>e.id)),[l]),C=x.size>0,w=d===`matrix`?`term-matrix`:d===`dracula`?`term-dracula`:`term-classic`,T=r.isPending||i.isPending;return(0,$.jsxs)(`div`,{className:`animate-fade-in`,children:[n.isLoading&&(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 text-[10px] text-primary`,children:[(0,$.jsx)(Z,{className:`size-3`}),(0,$.jsx)(`span`,{className:`font-semibold tracking-wider uppercase`,children:`Scanning service configurations...`})]}),n.isError&&(0,$.jsxs)(`div`,{className:`mb-4 flex items-center justify-between rounded-md border border-destructive/30 bg-destructive/10 p-3 text-xs text-destructive`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(xt,{size:14}),(0,$.jsxs)(`span`,{children:[`Failed to load services: `,n.error?.message||`Unknown error`]})]}),(0,$.jsx)(Y,{size:`xs`,variant:`outline`,onClick:()=>n.refetch(),children:`Retry`})]}),(r.isError||i.isError)&&(0,$.jsxs)(`div`,{className:`mb-4 flex items-center justify-between rounded-md border border-destructive/30 bg-destructive/10 p-3 text-xs text-destructive`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(xt,{size:14}),(0,$.jsxs)(`span`,{children:[`Action failed: `,r.error?.message||i.error?.message||`Operation failed`]})]}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:()=>{r.reset(),i.reset()},children:`Dismiss`})]}),!n.isLoading&&!n.isError&&o.length===0&&c.length===0&&(0,$.jsxs)(`div`,{className:`rounded-md border border-border/80 bg-card p-6 text-center surface-card`,children:[(0,$.jsx)(Fn,{size:24,className:`mx-auto mb-2 text-muted-foreground/60`}),(0,$.jsx)(`h4`,{className:`text-xs font-bold text-foreground`,children:`No Services Detected`}),(0,$.jsxs)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:[`ContextSpace scans for runnable background services in `,(0,$.jsx)(`code`,{className:`font-mono text-[10px]`,children:`package.json`}),` scripts (such as `,(0,$.jsx)(`code`,{className:`font-mono text-[10px]`,children:`start`}),`, `,(0,$.jsx)(`code`,{className:`font-mono text-[10px]`,children:`dev`}),`), `,(0,$.jsx)(`code`,{className:`font-mono text-[10px]`,children:`docker-compose.yml`}),`, or `,(0,$.jsx)(`code`,{className:`font-mono text-[10px]`,children:`Procfile`}),`.`]})]}),c.length>0&&(0,$.jsxs)(`div`,{className:`mb-4 rounded-md border border-border/80 bg-card p-4 surface-card`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-[10px] font-bold uppercase tracking-wider text-muted-foreground`,children:[(0,$.jsx)(xt,{size:12,className:`text-info`}),` Orchestration tools`]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map(e=>{let t=S.has(e.id);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border/60 bg-muted/20 p-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full ${t?`bg-success`:`bg-muted-foreground/40`}`}),(0,$.jsx)(`span`,{className:`text-xs font-bold text-foreground`,children:e.tool}),(0,$.jsx)(Ct,{tone:`idle`,dot:!1,children:e.mode})]}),(0,$.jsx)(`code`,{className:`mt-1 block truncate font-mono text-[9px] text-muted-foreground`,children:e.configPath})]}),(0,$.jsx)(`div`,{className:`shrink-0`,children:t?(0,$.jsxs)(Y,{size:`xs`,variant:`destructive`,"aria-label":`Stop ${e.tool}`,disabled:T,onClick:()=>i.mutate({action:`stop`,id:e.id}),children:[(0,$.jsx)(wt,{size:12}),` Stop`]}):(0,$.jsxs)(Y,{size:`xs`,"aria-label":`Start ${e.tool}`,disabled:T,onClick:()=>i.mutate({action:`start`,id:e.id}),children:[(0,$.jsx)(It,{size:12}),` Start`]})})]},e.id)})})]}),(0,$.jsxs)(`div`,{className:`mb-4 rounded-md border border-border/80 bg-card p-4 surface-card`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between text-xs font-semibold text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:`Workspace Status`}),(0,$.jsx)(Ct,{tone:C?`running`:`idle`,children:C?`Active`:`Standby`})]}),(0,$.jsx)(`div`,{className:`mb-3 text-xs font-semibold text-foreground`,children:C?`${x.size} process${x.size===1?``:`es`} active`:`All processes offline`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(Y,{size:`sm`,disabled:C||T,onClick:()=>r.mutate({action:`start`}),children:[(0,$.jsx)(It,{size:13}),` Start All Services`]}),(0,$.jsxs)(Y,{size:`sm`,variant:`destructive`,disabled:!C||T,onClick:()=>r.mutate({action:`stop`}),children:[(0,$.jsx)(wt,{size:13}),` Stop All`]})]})]}),(o.length>0||u.length>0)&&(0,$.jsxs)(`div`,{className:`grid grid-cols-1 overflow-hidden rounded-md border border-border/80 bg-card shadow-xs lg:grid-cols-12 surface-card`,children:[(0,$.jsxs)(`div`,{className:`border-b border-border/80 bg-muted/20 p-4 lg:col-span-4 lg:border-b-0 lg:border-r`,children:[(0,$.jsxs)(`h4`,{className:`mb-4 flex items-center gap-1.5 border-b border-border pb-2 text-[10px] font-bold uppercase tracking-wider text-muted-foreground`,children:[(0,$.jsx)(Fn,{size:12,className:`text-primary`}),` Background Services`]}),(0,$.jsxs)(`div`,{className:`flex max-h-[400px] flex-col gap-2 overflow-y-auto pr-1`,children:[o.map(e=>{let t=h===e.name,n=x.has(e.name);return(0,$.jsxs)(`div`,{className:q(`flex cursor-pointer flex-col rounded-xl border p-3 transition-colors`,t?`border-primary/40 bg-primary/10 text-foreground`:`border-border bg-card text-muted-foreground hover:border-foreground/15 hover:bg-accent/50 hover:text-foreground`),onClick:()=>g(e.name),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${n?`bg-success`:`bg-destructive`}`}),(0,$.jsx)(`span`,{className:`truncate text-xs font-bold`,children:e.name})]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,onClick:e=>e.stopPropagation(),children:n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{size:`icon-xs`,variant:`ghost`,"aria-label":`Restart ${e.name}`,disabled:T,onClick:()=>r.mutate({action:`restart`,service:e.name}),children:(0,$.jsx)(ar,{})}),(0,$.jsx)(Y,{size:`icon-xs`,variant:`ghost`,"aria-label":`Stop ${e.name}`,disabled:T,onClick:()=>r.mutate({action:`stop`,service:e.name}),children:(0,$.jsx)(wt,{})})]}):(0,$.jsx)(Y,{size:`icon-xs`,variant:`ghost`,"aria-label":`Start ${e.name}`,disabled:T,onClick:()=>r.mutate({action:`start`,service:e.name}),children:(0,$.jsx)(It,{})})})]}),e.port?(0,$.jsxs)(`span`,{className:`mt-2 w-fit rounded border border-border bg-background px-2 py-0.5 font-mono text-[9px] text-muted-foreground`,children:[`Port: `,e.port]}):null,(0,$.jsxs)(`code`,{className:`mt-2 block truncate rounded border border-border bg-muted/40 p-1.5 font-mono text-[9px] text-muted-foreground`,children:[e.command,` `,e.args.join(` `)]})]},e.name)}),u.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mt-2 border-t border-border pt-3 text-[9px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Orchestrators`}),u.map(e=>{let t=e.logName;return(0,$.jsxs)(`div`,{className:q(`flex cursor-pointer items-center gap-2 rounded-xl border p-3 transition-colors`,h===t?`border-primary/40 bg-primary/10 text-foreground`:`border-border bg-card text-muted-foreground hover:border-foreground/15 hover:bg-accent/50 hover:text-foreground`),onClick:()=>g(t),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-success`}),(0,$.jsx)(`span`,{className:`truncate text-xs font-bold`,children:e.tool}),(0,$.jsx)(Ct,{tone:`idle`,dot:!1,children:e.mode})]},e.id)})]})]})]}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col bg-background lg:col-span-8`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-border bg-muted/40 px-5 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-xs font-bold text-primary`,children:h||`no-service`}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`|`}),(0,$.jsx)(Ct,{tone:v?`running`:`idle`,children:v?`streaming`:`idle`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 self-end sm:self-auto`,children:[(0,$.jsx)(`div`,{className:`flex rounded-lg border border-border bg-card p-0.5 text-[9px] font-semibold text-muted-foreground`,children:[`classic`,`matrix`,`dracula`].map(e=>(0,$.jsx)(`button`,{className:q(`cursor-pointer rounded-md px-2 py-1 capitalize transition-colors`,d===e?`bg-primary/10 font-bold text-primary`:`hover:text-foreground`),onClick:()=>f(e),children:e},e))}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(`button`,{onClick:y,className:`cursor-pointer rounded-lg border border-border bg-card p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:`Clear Console`,children:(0,$.jsx)(st,{size:13})}),(0,$.jsx)(`button`,{onClick:()=>m(!p),className:`cursor-pointer rounded-lg border border-border bg-card p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,title:p?`Minimize Console`:`Expand Console`,children:p?(0,$.jsx)(Et,{size:13}):(0,$.jsx)(Bt,{size:13})})]})]})]}),(0,$.jsxs)(`div`,{className:q(`relative overflow-y-auto whitespace-pre-wrap p-5 font-mono text-[10.5px] leading-relaxed selection:bg-primary/20`,w,p?`h-[520px]`:`h-80`),children:[_.trim()?_:(0,$.jsx)(`span`,{className:`font-mono italic text-muted-foreground`,children:`(no log content yet)`}),(0,$.jsx)(`div`,{ref:b})]})]})]})]})}var wr=({workspaceTitle:e,workspaceDescription:t,activeWorktree:n,iterations:r,activeIterationId:i,onSelectIteration:a,activeStage:o,onSelectStage:s,diffViewMode:c,onToggleDiffMode:l,isZenMode:u,onToggleZenMode:d,gateStatus:f={overallStatus:`idle`,summaryText:`No verification gate run yet`},onNewIteration:p,showToast:m})=>{let[h,g]=(0,Q.useState)(!1),_=(0,Q.useCallback)(async(e,t)=>{t.stopPropagation(),await Ht(e)&&(g(!0),m?.(`Copied branch "${e}" to clipboard`,`success`),setTimeout(()=>g(!1),1500))},[m]),v=n?.commitInfo?.shortSha||n?.commitSha?.slice(0,7)||`unknown`;return(0,$.jsxs)(`header`,{className:`w-full shrink-0 border-b border-border/80 bg-card/85 backdrop-blur-md z-20 select-none`,children:[(0,$.jsxs)(`div`,{className:`h-8 px-3 flex items-center justify-between border-b border-border/60 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`font-semibold text-foreground tracking-tight truncate max-w-[240px] cursor-default`,title:t||e,children:e}),(0,$.jsx)(Qt,{size:11,className:`text-muted-foreground/40 shrink-0`}),n?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-foreground truncate max-w-[280px] flex items-center gap-1 text-xs`,title:n.intent||n.title,children:[(0,$.jsx)(Ut,{size:12,className:`text-primary shrink-0`}),n.title]}),(0,$.jsxs)(`button`,{type:`button`,onClick:e=>_(n.branchName,e),title:`Click to copy branch`,className:`inline-flex items-center gap-1 font-mono text-[10px] text-muted-foreground bg-muted/60 hover:bg-muted/90 px-1.5 py-0.5 rounded border border-border/50 hover:border-primary/40 transition-colors cursor-pointer`,children:[(0,$.jsx)(kt,{size:10,className:`text-primary/70 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-[150px]`,children:n.branchName}),h?(0,$.jsx)(zt,{size:10,className:`text-emerald-400 shrink-0`}):(0,$.jsx)(Dt,{size:9,className:`opacity-50 shrink-0`})]}),(0,$.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground/70 hidden sm:inline`,title:`Head commit: ${n.commitInfo?.commitMessage||n.commitSha}`,children:[`@`,v]}),n.dirtyFilesCount===null?(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`Status unavailable`}):n.dirtyFilesCount>0?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(`diff`),className:`font-mono text-[10px] font-bold text-amber-400 bg-amber-500/15 border border-amber-500/30 px-1.5 py-0.5 rounded flex items-center gap-1 cursor-pointer hover:bg-amber-500/25 transition-colors`,title:`View uncommitted modified files`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-400 animate-pulse`}),(0,$.jsxs)(`span`,{children:[`±`,n.dirtyFilesCount,` dirty`]})]}):(0,$.jsxs)(`span`,{className:`font-mono text-[10px] font-medium text-emerald-400 bg-emerald-500/10 border border-emerald-500/25 px-1.5 py-0.5 rounded flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-emerald-400`}),(0,$.jsx)(`span`,{children:`clean`})]}),n.isPinned&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 font-mono text-[10px] text-primary/80 bg-primary/10 px-1 py-0.5 rounded`,title:`Worktree locked against pruning`,children:[(0,$.jsx)(zn,{size:10}),(0,$.jsx)(`span`,{children:`pinned`})]})]}):(0,$.jsx)(`span`,{className:`text-muted-foreground text-xs italic`,children:`No active worktree`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[f&&(0,$.jsxs)(`div`,{className:q(`inline-flex items-center gap-1 font-mono text-[10px] font-semibold px-2 py-0.5 rounded border`,f.overallStatus===`pass`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-400`:f.overallStatus===`fail`?`border-rose-500/30 bg-rose-500/15 text-rose-400 animate-pulse`:f.overallStatus===`running`?`border-sky-500/25 bg-sky-500/10 text-sky-400`:`border-border/60 bg-muted/20 text-muted-foreground`),title:f.summaryText||`Automated verification gate proof`,children:[f.overallStatus===`pass`?(0,$.jsx)(Zt,{size:11,className:`text-emerald-400`}):f.overallStatus===`fail`?(0,$.jsx)(Xt,{size:11,className:`text-rose-400`}):f.overallStatus===`running`?(0,$.jsx)(Yn,{size:11,className:`text-sky-400 animate-spin`}):(0,$.jsx)(Yn,{size:11,className:`text-muted-foreground/60`}),(0,$.jsxs)(`span`,{children:[`Gate:`,` `,f.overallStatus===`pass`?`PASS (${f.durationMs??120}ms)`:f.overallStatus===`fail`?`FAILED ✗`:f.overallStatus===`running`?`RUNNING…`:`IDLE ○`]})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:l,className:`inline-flex items-center gap-1 font-mono text-[10px] font-medium px-2 py-0.5 rounded border border-border bg-card/60 hover:bg-accent text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Toggle Diff Mode (Split / Unified)`,children:[(0,$.jsx)(jt,{size:11}),(0,$.jsx)(`span`,{children:c===`side-by-side`?`Split`:`Unified`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:d,className:q(`inline-flex items-center gap-1 font-mono text-[10px] px-1.5 py-0.5 rounded border transition-colors cursor-pointer`,u?`border-primary/40 bg-primary/10 text-primary font-bold`:`border-border bg-card/60 text-muted-foreground hover:text-foreground hover:bg-accent`),title:`Toggle Zen Review Mode (Shortcut: z)`,children:[u?(0,$.jsx)(Et,{size:11}):(0,$.jsx)(Bt,{size:11}),(0,$.jsx)(`span`,{children:`Zen (z)`})]})]})]}),!u&&(0,$.jsxs)(`div`,{className:`h-7 px-3 flex items-center justify-between border-b border-border/40 bg-muted/20 text-xs`,children:[r.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto custom-scrollbar min-w-0 flex-1 pr-3`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[10px] font-bold uppercase tracking-wider text-muted-foreground/60 shrink-0`,children:`Iterations:`}),r.length===0?(0,$.jsx)(`span`,{className:`text-muted-foreground/70 italic text-[11px] px-1`,children:`No iterations defined`}):r.map(e=>{let t=e.id===i;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),className:q(`inline-flex items-center gap-1.5 h-5 px-2 rounded text-xs font-medium whitespace-nowrap transition-all cursor-pointer shrink-0`,t?`bg-primary/15 text-foreground font-semibold border border-primary/40 shadow-2xs`:`bg-card/50 hover:bg-accent/80 text-muted-foreground hover:text-foreground border border-border/60`),title:e.goal||e.title,children:[(0,$.jsx)(Ut,{size:11,className:q(t?`text-primary`:`text-muted-foreground/70`)}),(0,$.jsx)(`span`,{children:e.title}),e.status===`review_ready`?(0,$.jsxs)(`span`,{className:`font-mono text-[9px] px-1 py-0.2 rounded bg-amber-500/20 text-amber-400 font-bold border border-amber-500/30`,children:[`Review Ready `,e.changesCount?`(±${e.changesCount})`:``]}):e.status===`agent_running`?(0,$.jsxs)(`span`,{className:`font-mono text-[9px] px-1 py-0.2 rounded bg-sky-500/20 text-sky-400 font-bold border border-sky-500/30 flex items-center gap-0.5`,children:[(0,$.jsx)(Rn,{size:9,className:`text-sky-400`}),`Active ⚡`]}):e.status===`done`?(0,$.jsx)(`span`,{className:`font-mono text-[9px] px-1 py-0.2 rounded bg-emerald-500/20 text-emerald-400 font-bold border border-emerald-500/30`,children:`Done ✓`}):(0,$.jsx)(`span`,{className:`font-mono text-[9px] px-1 py-0.2 rounded bg-muted/80 text-muted-foreground border border-border/40`,children:`Planned ○`})]},e.id)}),p&&(0,$.jsxs)(`button`,{type:`button`,onClick:p,className:`inline-flex items-center gap-1 h-5 px-2 rounded text-[11px] font-medium text-muted-foreground hover:text-primary hover:bg-primary/10 border border-dashed border-border/80 hover:border-primary/30 transition-colors cursor-pointer shrink-0`,children:[(0,$.jsx)(Pt,{size:10}),(0,$.jsx)(`span`,{children:`New Iteration`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 font-mono text-[10px]`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(`diff`),className:q(`px-2 py-0.5 rounded transition-colors cursor-pointer`,o===`diff`?`bg-primary/15 text-primary font-bold border border-primary/30`:`text-muted-foreground hover:text-foreground hover:bg-accent/60`),children:`Diff Review`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(`plan`),className:q(`px-2 py-0.5 rounded transition-colors cursor-pointer`,o===`plan`?`bg-primary/15 text-primary font-bold border border-primary/30`:`text-muted-foreground hover:text-foreground hover:bg-accent/60`),children:`Process DAG`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(`knowledge`),className:q(`px-2 py-0.5 rounded transition-colors cursor-pointer`,o===`knowledge`?`bg-primary/15 text-primary font-bold border border-primary/30`:`text-muted-foreground hover:text-foreground hover:bg-accent/60`),children:`Knowledge`})]})]})]})},Tr=Q.createContext(void 0);function Er(e){let t=Q.useContext(Tr);if(t===void 0&&!e)throw Error(J(47));return t}var Dr={...$t,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Or=class extends c{constructor(e,t,n){let r=new _;super(kr(e,r,t,n),Ar(r),Dr)}setOpen=(e,t)=>{let n=t.reason===b,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=F(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n={open:e,openChangeReason:t.reason};g(n,e,t.trigger,a()),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),gr.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function kr(e,t,n,r=!1){let i={...pn(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i.floatingRootContext=dn(t,n,r),i}function Ar(e){return{popupRef:Q.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:Q.createRef(),beforeContentFocusGuardRef:Q.createRef(),stickIfOpenTimeout:new l,triggerElements:e}}function jr({props:e}){let{children:t,open:n,defaultOpen:i=!1,onOpenChange:o,onOpenChangeComplete:s,modal:c=!1,handle:l,triggerId:u,defaultTriggerId:d=null}=e,f=Nr(l,{modal:c,open:i,openProp:n,activeTriggerId:d,triggerIdProp:u});f.useControlledProp(`openProp`,n),f.useControlledProp(`triggerIdProp`,u);let p=f.useState(`open`),m=f.useState(`mounted`),g=f.useState(`payload`);f.useContextCallback(`onOpenChange`,o),f.useContextCallback(`onOpenChangeComplete`,s),y(f,p),v(f);let{forceUnmount:_}=a(p,f,()=>{f.update({stickIfOpen:!0,openChangeReason:null})});f.useSyncedValues({modal:c}),Q.useEffect(()=>{p||f.context.stickIfOpenTimeout.clear()},[f,p]),Q.useImperativeHandle(e.actionsRef,()=>({unmount:_,close:()=>f.setOpen(!1,E(h))}),[_,f]);let b=p||m;return(0,$.jsxs)(Tr.Provider,{value:f,children:[l&&(0,$.jsx)(r,{handle:l,store:f}),b&&(0,$.jsx)(Pr,{store:f,modal:c}),typeof t==`function`?t({payload:g}):t]})}function Mr(e){return Er(!0)?(0,$.jsx)(jr,{props:e}):(0,$.jsx)(S,{children:(0,$.jsx)(jr,{props:e})})}function Nr(e,t){let n=p((e,n)=>new Or(t,e,n));return Q.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function Pr({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=z(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return u(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}var Fr=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:p,...m}=e,h=Er(!0),g=bn(s)??h;if(!g)throw Error(J(74));let _=C(p),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),b=g.useState(`isOpenedByTrigger`,_),x=g.useState(`triggerPopupId`,_),S=Q.useRef(null),{registerTrigger:w,isMountedByThisTrigger:T}=W(_,S,g,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),E=g.useState(`openChangeReason`),D=g.useState(`stickIfOpen`),O=g.useState(`openMethod`),k=g.useState(`focusManagerModal`),A=un(y,{enabled:!a&&l&&(O!==`touch`||E!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:sn(),restMs:u,delay:{close:d},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),j=Ie(y,{stickIfOpen:D}),M=Ne(()=>g.select(`open`),e=>{g.set(`openMethod`,e)}),N=g.useState(`triggerProps`,T),{getButtonProps:P,buttonRef:F}=ee({disabled:a,native:o}),I={open(e){return e&&E===`trigger-press`?f.open(e):te.open(e)}},{preFocusGuardRef:L,handlePreFocusGuardFocus:z,handleFocusTargetFocus:ne}=an(g,S),B=ke(`button`,e,{state:{disabled:a,open:b},ref:[F,t,w,S],props:[j.reference,A,N,M,{[R]:``,id:_,"aria-haspopup":`dialog`,"aria-expanded":b,"aria-controls":x},m,P],stateAttributesMapping:I}),V=(0,$.jsx)(Q.Fragment,{children:B},_);return T&&!k?(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(U,{ref:L,onFocus:z}),V,(0,$.jsx)(U,{ref:g.context.triggerFocusTargetRef,onFocus:ne})]}):V}),Ir=Q.createContext(void 0);function Lr(){let e=Q.useContext(Ir);if(e===void 0)throw Error(J(45));return e}var Rr=Q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Er().useState(`mounted`)||n?(0,$.jsx)(Ir.Provider,{value:n,children:(0,$.jsx)(re,{ref:t,...r})}):null}),zr=Q.createContext(void 0);function Br(){let e=Q.useContext(zr);if(!e)throw Error(J(46));return e}var Vr=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:c,align:l,sideOffset:u,alignOffset:d,collisionBoundary:f=`clipping-ancestors`,collisionPadding:p,arrowPadding:m,sticky:h,disableAnchorTracking:g=!1,collisionAvoidance:_=A,...v}=e,y=Er(),b=Lr(),x=D(),S=y.useState(`floatingRootContext`),C=y.useState(`mounted`),T=y.useState(`open`),E=y.useState(`openChangeReason`),O=y.useState(`activeTriggerElement`),k=y.useState(`modal`),j=y.useState(`openMethod`),M=y.useState(`positionerElement`),P=y.useState(`instantType`),F=y.useState(`transitionStatus`),I=y.useState(`adaptiveOrigin`),L=Q.useRef(null),ee=s(M),R=Le({anchor:a,floatingRootContext:S,positionMethod:o,mounted:C,side:c,sideOffset:u,align:l,alignOffset:d,arrowPadding:m,collisionBoundary:f,collisionPadding:p,sticky:h,disableAnchorTracking:g,keepMounted:b,nodeId:x,collisionAvoidance:_,adaptiveOrigin:I}),z=S.useState(`domReferenceElement`);B(()=>{let e=z,t=L.current;if(e&&(L.current=e),t&&e&&e!==t){y.set(`instantType`,void 0);let e=new AbortController;return ee(()=>{y.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[z,ee,y]);let te=k===!0&&E!==`trigger-hover`;ze(T&&te,j===`touch`,M,O);let ne=y.useStateSetter(`positionerElement`),V={open:T,side:R.side,align:R.align,anchorHidden:R.anchorHidden,instant:P},re=Be(e,V,{styles:R.positionerStyles,transitionStatus:F,props:v,refs:[t,ne],hidden:!C,inert:!T});return(0,$.jsxs)(zr.Provider,{value:R,children:[C&&te&&(0,$.jsx)(N,{inert:H(!T),cutout:O}),(0,$.jsx)(w,{id:x,children:re})]})}),Hr=Q.createContext(void 0);function Ur(){let[e,t]=Q.useState(0),n=M(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:Q.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var Wr=Q.forwardRef(function(e,t){let{render:n,className:r,style:a,initialFocus:s,finalFocus:c,...l}=e,u=Er(),f=Br(),p=Fe(!0)!=null,{context:h,hasClosePart:g}=Ur(),_=u.useState(`open`),v=u.useState(`openMethod`),y=u.useState(`instantType`),b=u.useState(`transitionStatus`),S=u.useState(`popupProps`),C=u.useState(`titleElementId`),w=u.useState(`descriptionElementId`),T=u.useState(`modal`),E=u.useState(`mounted`),D=u.useState(`openChangeReason`),O=u.useState(`activeTriggerElement`),k=u.useState(`floatingRootContext`),A=k.useState(`floatingId`),M=u.useState(`disabled`),N=u.useState(`openOnHover`),P=u.useState(`closeDelay`);x({open:_,ref:u.context.popupRef,onComplete(){_&&u.context.onOpenChangeComplete?.(!0)}}),Dn(k,{enabled:N&&!M,closeDelay:P});let F=s===void 0?m(u.context.popupRef):s,L=T!==!1&&g;u.useSyncedValue(`focusManagerModal`,L);let ee=u.useStateSetter(`popupElement`),R={open:_,side:f.side,align:f.align,instant:y,transitionStatus:b},z=ke(`div`,e,{state:R,ref:[t,u.context.popupRef,ee],props:[S,{id:A,role:`dialog`,...I,"aria-labelledby":C,"aria-describedby":w,onKeyDown(e){p&&i.has(e.key)&&e.stopPropagation()}},Pe(b),l],stateAttributesMapping:o});return(0,$.jsx)(d,{context:k,openInteractionType:v,modal:L,disabled:!E||D===`trigger-hover`,initialFocus:F,returnFocus:c,restoreFocus:`popup`,previousFocusableElement:j(O)?O:void 0,nextFocusableElement:u.context.triggerFocusTargetRef,beforeContentFocusGuardRef:u.context.beforeContentFocusGuardRef,children:(0,$.jsx)(Hr.Provider,{value:h,children:z})})}),Gr=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=Er(),{side:c}=Br(),l=s.useState(`instantType`),{children:u,state:d}=vr({store:s,side:c,children:a}),f={activationDirection:d.activationDirection,transitioning:d.transitioning,instant:l};return ke(`div`,e,{state:f,ref:t,props:[o,{children:u}],stateAttributesMapping:_r})}),Kr=Mr;function qr({className:e,children:t,...n}){return(0,$.jsx)(Fr,{className:e,"data-slot":`popover-trigger`,...n,children:t})}function Jr({children:e,className:t,viewportClassName:n,side:r=`bottom`,align:i=`center`,sideOffset:a=4,alignOffset:o=0,tooltipStyle:s=!1,anchor:c,...l}){return(0,$.jsx)(Rr,{children:(0,$.jsx)(Vr,{align:i,alignOffset:o,anchor:c,className:`z-50 h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom,transform] data-instant:transition-none`,"data-slot":`popover-positioner`,side:r,sideOffset:a,children:(0,$.jsx)(Wr,{className:q(`relative flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) rounded-lg border bg-popover not-dark:bg-clip-padding text-popover-foreground shadow-lg/5 outline-none transition-[width,height,scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] has-data-[slot=calendar]:rounded-xl has-data-[slot=calendar]:before:rounded-[calc(var(--radius-xl)-1px)] data-starting-style:scale-98 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`,s&&`w-fit text-balance rounded-md text-xs shadow-md/5 before:rounded-[calc(var(--radius-md)-1px)]`,t),"data-slot":`popover-popup`,...l,children:(0,$.jsx)(Gr,{className:q(`relative size-full max-h-(--available-height) overflow-clip px-(--viewport-inline-padding) py-4 [--viewport-inline-padding:--spacing(4)] has-data-[slot=calendar]:p-2 data-instant:transition-none **:data-current:data-ending-style:opacity-0 **:data-current:data-starting-style:opacity-0 **:data-previous:data-ending-style:opacity-0 **:data-previous:data-starting-style:opacity-0 **:data-current:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-previous:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-current:opacity-100 **:data-previous:opacity-100 **:data-current:transition-opacity **:data-previous:transition-opacity`,s?`py-1 [--viewport-inline-padding:--spacing(2)]`:`not-data-transitioning:overflow-y-auto`,n),"data-slot":`popover-viewport`,children:e})})})})}function Yr({repos:e,disabled:t,onAdd:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),s=(0,Q.useMemo)(()=>{let t=a.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.path.toLowerCase().includes(t)):e},[e,a]);return(0,$.jsxs)(Kr,{open:r,onOpenChange:e=>{e&&o(``),i(e)},children:[(0,$.jsx)(qr,{render:(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,disabled:t,className:`h-8 text-xs text-muted-foreground`,children:[(0,$.jsx)(Pt,{size:14}),` Add repository`]})}),(0,$.jsxs)(Jr,{align:`end`,className:`w-[320px]`,viewportClassName:`p-0`,children:[(0,$.jsx)(`div`,{className:`border-b border-border p-2`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(ie,{className:`absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(L,{autoFocus:!0,value:a,onChange:e=>o(e.target.value),placeholder:`Search repositories`,className:`pl-8`,"aria-label":`Search repositories`})]})}),(0,$.jsx)(`div`,{role:`listbox`,className:`max-h-64 overflow-y-auto py-1`,children:s.length===0?(0,$.jsx)(`div`,{className:`px-3 py-4 text-center text-sm text-muted-foreground`,children:`No repositories found.`}):s.map(e=>(0,$.jsxs)(`button`,{role:`option`,"aria-selected":!1,onClick:()=>{i(!1),n(e.path)},className:`flex w-full cursor-pointer items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-accent`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`block truncate font-mono text-xs text-muted-foreground`,children:e.path})]}),(0,$.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:e.defaultBranch})]},e.path))})]})]})}var Xr=(e,t)=>{switch(e){case`antigravity`:return`agy --conversation ${t}`;case`claude`:return`claude --resume ${t}`;case`codex`:return`codex resume ${t}`;case`copilot`:return`copilot --resume ${t}`;case`cursor`:return`cursor-agent --resume ${t}`;default:return`agy --conversation ${t}`}},Zr=e=>{switch(e){case`antigravity`:return(0,$.jsx)(`span`,{className:`grid size-5.5 place-items-center rounded-md bg-card border border-border/80 shadow-2xs p-0.5 shrink-0`,title:`Google Antigravity`,children:(0,$.jsx)(Qe,{className:`size-3.5`})});case`claude`:return(0,$.jsx)(`span`,{className:`grid size-5.5 place-items-center rounded-md bg-[#D97757] text-white font-bold text-[9px] shadow-2xs shrink-0`,title:`Claude Code`,children:(0,$.jsx)(Xe,{className:`size-2.5`})});case`codex`:return(0,$.jsx)(`span`,{className:`grid size-5.5 place-items-center rounded-md bg-foreground text-background font-bold text-[9px] shadow-2xs shrink-0`,title:`OpenAI Codex`,children:(0,$.jsx)($e,{className:`size-2.5`})});case`copilot`:return(0,$.jsx)(`span`,{className:`grid size-5.5 place-items-center rounded-md bg-gradient-to-tr from-purple-600 via-indigo-500 to-blue-600 text-white font-bold text-[9px] shadow-2xs shrink-0`,title:`GitHub Copilot`,children:(0,$.jsx)(nt,{className:`size-2.5`})});default:return null}},Qr=({ws:e,sessions:t,sessionsLoading:n,setActiveSession:r,setTranscript:i,fetchSessionTranscript:a,handleOpenDesktopSession:o,showToast:s})=>{let[c,l]=(0,Q.useState)(!1),u=(0,Q.useMemo)(()=>t.filter(e=>c||e.threadKind!==`subagent`),[t,c]),d=t.filter(e=>e.threadKind===`subagent`).length,f=se(),p=me(),m=xe(),h=m.data?.find(e=>e.name===`antigravity`)?.detected??!0,g=!!m.data?.find(e=>e.name===`claude`)?.detected,_=!!m.data?.find(e=>e.name===`codex`)?.detected,v=!!m.data?.find(e=>e.name===`copilot`)?.command,y=!!f.data?.some(e=>e.id===`antigravity`&&e.available),b=!!f.data?.some(e=>e.id===`codex-desktop`&&e.available),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(`updated-desc`),[j,M]=(0,Q.useState)(`harness`),[N,P]=(0,Q.useState)(``),[F,I]=(0,Q.useState)(`all`),[L,ee]=(0,Q.useState)({antigravity:!1,claude:!1,codex:!1,copilot:!1}),R=e=>{ee(t=>({...t,[e]:!t[e]}))},z=(0,Q.useRef)(!1),te=(0,Q.useRef)(null),ne=async t=>{try{await X(`/api/workspace/${encodeURIComponent(e.branchName)}/launch`,{method:`POST`,body:JSON.stringify({targetId:t})}),s?.(`Launched ${t===`claude-desktop`?`Claude Desktop`:t===`codex-desktop`?`Codex Desktop`:t} for workspace ${e.branchName}`,`success`)}catch(e){let t=e instanceof Error?e.message:`Failed to launch desktop application`;s?.(t,`error`)}},B=async t=>{if(!T){E(t);try{await p.mutateAsync({workspaceId:e.branchName,assistant:t}),O({assistant:t,cmd:t===`antigravity`?`agy`:t===`claude`?`claude`:t===`codex`?`codex`:`copilot`,timestamp:new Date}),s?.(`Opened ${t} inside ContextSpace`,`success`)}catch(e){let t=e instanceof Error?e.message:`Failed to launch terminal`;s?.(t,`error`)}finally{E(null)}}},V=async(t,n,r)=>{if(!z.current){z.current=!0,w(t);try{await p.mutateAsync({workspaceId:e.branchName,sessionId:t,assistant:n,cwd:r});let i=Xr(n,t);O({assistant:n,cmd:i,timestamp:new Date}),s?.(`Opened ${n} resume inside ContextSpace`,`success`)}catch{let e=Xr(n,t);await Ht(e),s?.(`Copied resume command to clipboard: ${e}`,`info`)}finally{w(null),z.current=!1}}},re=async t=>{if(!(!b||te.current)){te.current=t,S(t);try{await o(e,t,`codex`)}finally{te.current=null,S(null)}}},H=(e,t)=>[...e].sort((e,n)=>{switch(t){case`created-desc`:{let t=new Date(e.createdAt||e.updatedAt||0).getTime();return new Date(n.createdAt||n.updatedAt||0).getTime()-t}case`created-asc`:return new Date(e.createdAt||e.updatedAt||0).getTime()-new Date(n.createdAt||n.updatedAt||0).getTime();case`updated-desc`:{let t=Date.parse(e.updatedAt)||0;return(Date.parse(n.updatedAt)||0)-t}case`messages-desc`:return(n.messageCount||0)-(e.messageCount||0);case`title-asc`:return(e.title||``).localeCompare(n.title||``);default:return 0}}),U=(0,Q.useMemo)(()=>{let e=u;if(F!==`all`&&(e=e.filter(e=>e.assistant===F)),N.trim()){let t=N.toLowerCase();e=e.filter(e=>`${e.title} ${e.id} ${e.assistant}`.toLowerCase().includes(t))}return H(e,k)},[u,F,N,k]),W=(0,Q.useMemo)(()=>H(u.filter(e=>e.assistant===`antigravity`),k),[u,k]),ae=(0,Q.useMemo)(()=>H(u.filter(e=>e.assistant===`claude`),k),[u,k]),G=(0,Q.useMemo)(()=>H(u.filter(e=>e.assistant===`codex`),k),[u,k]),oe=(0,Q.useMemo)(()=>H(u.filter(e=>e.assistant===`copilot`),k),[u,k]),ce=(0,Q.useCallback)(t=>e.assistants?.includes(t)??!1,[e.assistants]),le=(0,Q.useMemo)(()=>[{id:`antigravity`,name:`Google Antigravity`,cliCommand:`agy`,isDetected:h,isConfigured:ce(`antigravity`),hasApp:y,appName:`IDE`,appTargetId:`antigravity`,sessions:W,icon:(0,$.jsx)(`span`,{className:`grid size-6 place-items-center rounded-md bg-card border border-border/80 shadow-2xs p-0.5`,children:(0,$.jsx)(Qe,{className:`size-4`})})},{id:`claude`,name:`Claude Code`,cliCommand:`claude`,isDetected:g,isConfigured:ce(`claude`),hasApp:!1,appName:`App`,appTargetId:`claude`,sessions:ae,icon:(0,$.jsx)(`span`,{className:`grid size-6 place-items-center rounded-md bg-[#D97757] text-white font-bold text-[10px] shadow-2xs`,children:(0,$.jsx)(Xe,{className:`size-3`})})},{id:`codex`,name:`OpenAI Codex`,cliCommand:`codex`,isDetected:_,isConfigured:ce(`codex`),hasApp:b,appName:`Desktop`,appTargetId:`codex-desktop`,sessions:G,icon:(0,$.jsx)(`span`,{className:`grid size-6 place-items-center rounded-md bg-foreground text-background font-bold text-[10px] shadow-2xs`,children:(0,$.jsx)($e,{className:`size-3`})})},{id:`copilot`,name:`GitHub Copilot`,cliCommand:`copilot`,isDetected:v,isConfigured:ce(`copilot`),hasApp:!1,appName:`App`,appTargetId:`copilot`,sessions:oe,icon:(0,$.jsx)(`span`,{className:`grid size-6 place-items-center rounded-md bg-gradient-to-tr from-purple-600 via-indigo-500 to-blue-600 text-white font-bold text-[10px] shadow-2xs`,children:(0,$.jsx)(nt,{className:`size-3`})})}],[h,g,_,v,y,b,ce,W,ae,G,oe]),ue=(0,Q.useMemo)(()=>le.filter(e=>e.isDetected||e.sessions.length>0),[le]);return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between bg-card/60 p-2 rounded-md border border-border/80`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1 min-w-0 max-w-xs`,children:[(0,$.jsx)(ie,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 size-3 text-muted-foreground`}),(0,$.jsx)(`input`,{type:`text`,value:N,onChange:e=>P(e.target.value),placeholder:`Search chat sessions...`,className:`w-full pl-7 pr-6 py-1 text-xs rounded border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-primary`}),N&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>P(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground text-[10px] cursor-pointer`,children:`✕`})]}),(0,$.jsxs)(`div`,{className:`hidden md:flex items-center gap-1`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>I(`all`),className:q(`px-2 py-0.5 text-[11px] rounded font-medium transition-colors cursor-pointer`,F===`all`?`bg-primary text-primary-foreground font-semibold shadow-2xs`:`bg-muted/60 text-muted-foreground hover:text-foreground hover:bg-muted`),children:[`All (`,u.length,`)`]}),ue.map(e=>{let t=e.sessions.length;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>I(F===e.id?`all`:e.id),className:q(`px-2 py-0.5 text-[11px] rounded font-medium capitalize transition-colors cursor-pointer`,F===e.id?`bg-primary text-primary-foreground font-semibold shadow-2xs`:`bg-muted/60 text-muted-foreground hover:text-foreground hover:bg-muted`),children:[e.name.replace(`Google `,``).replace(`OpenAI `,``).replace(`GitHub `,``),` (`,t,`)`]},e.id)})]}),n&&(0,$.jsx)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground shrink-0 pl-1`,children:(0,$.jsx)(Z,{className:`size-3`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(Cn,{children:[(0,$.jsxs)(Tn,{className:`flex items-center gap-1.5 px-2 py-1 text-xs font-medium rounded border border-border bg-card text-foreground hover:bg-accent cursor-pointer shadow-2xs transition-colors`,children:[(0,$.jsx)(Sn,{size:11,className:`text-muted-foreground`}),(0,$.jsx)(`span`,{children:{"created-desc":`Newest`,"created-asc":`Oldest`,"updated-desc":`Recently active`,"messages-desc":`Most turns`,"title-asc":`A–Z`}[k]}),(0,$.jsx)(je,{size:10,className:`text-muted-foreground opacity-70`})]}),(0,$.jsxs)(hn,{align:`end`,className:`w-48`,children:[(0,$.jsx)(`div`,{className:`px-2 py-1 text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:`Order Chats By`}),(0,$.jsxs)(An,{onClick:()=>A(`created-desc`),className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{children:`Newest created`}),k===`created-desc`&&(0,$.jsx)(zt,{size:12,className:`text-primary`})]}),(0,$.jsxs)(An,{onClick:()=>A(`created-asc`),className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{children:`Oldest created`}),k===`created-asc`&&(0,$.jsx)(zt,{size:12,className:`text-primary`})]}),(0,$.jsxs)(An,{onClick:()=>A(`updated-desc`),className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{children:`Recently active`}),k===`updated-desc`&&(0,$.jsx)(zt,{size:12,className:`text-primary`})]}),(0,$.jsxs)(An,{onClick:()=>A(`messages-desc`),className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{children:`Most turns`}),k===`messages-desc`&&(0,$.jsx)(zt,{size:12,className:`text-primary`})]}),(0,$.jsxs)(An,{onClick:()=>A(`title-asc`),className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{children:`Title (A–Z)`}),k===`title-asc`&&(0,$.jsx)(zt,{size:12,className:`text-primary`})]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center rounded border border-border bg-card p-0.5 shadow-2xs`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>M(`harness`),title:`Group chats by AI Harness`,className:q(`px-2 py-0.5 text-xs rounded font-medium transition-colors cursor-pointer`,j===`harness`?`bg-primary text-primary-foreground font-semibold shadow-2xs`:`text-muted-foreground hover:text-foreground`),children:`Grouped`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>M(`timeline`),title:`Unified Chronological Timeline`,className:q(`px-2 py-0.5 text-xs rounded font-medium transition-colors cursor-pointer`,j===`timeline`?`bg-primary text-primary-foreground font-semibold shadow-2xs`:`text-muted-foreground hover:text-foreground`),children:`Timeline`})]})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(`p`,{children:`Main threads are your conversations. Subagents are delegated tasks that report back to them.`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked)}),`Include subagent sessions`,d?` (${d})`:``]})]}),D&&(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 p-2.5 rounded-md bg-emerald-500/10 border border-emerald-500/30 text-xs animate-fade-in`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-foreground min-w-0`,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full bg-emerald-500 animate-pulse shrink-0`}),(0,$.jsxs)(`span`,{className:`truncate`,children:[(0,$.jsx)(`strong`,{children:`Opened in ContextSpace:`}),` `,(0,$.jsx)(`code`,{className:`font-mono bg-background/80 px-1.5 py-0.5 rounded text-emerald-400`,children:D.cmd})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:async()=>{await Ht(D.cmd),s?.(`Command copied to clipboard!`,`success`)},className:`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium rounded border border-emerald-500/40 bg-emerald-500/15 text-emerald-400 hover:bg-emerald-500/25 transition-colors cursor-pointer`,children:[(0,$.jsx)(Dt,{size:11}),` Copy`]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`text-muted-foreground hover:text-foreground cursor-pointer text-xs px-1`,title:`Dismiss banner`,children:`✕`})]})]}),j===`timeline`?(0,$.jsx)(Bn,{className:`divide-y divide-border overflow-hidden surface-card`,children:U.length===0?(0,$.jsx)(`div`,{className:`py-8 text-center text-xs text-muted-foreground`,children:N?`No chat sessions match your search filter.`:`No chat sessions recorded yet.`}):U.map(e=>(0,$.jsxs)(`div`,{className:`group flex flex-col gap-2 p-3 hover:bg-accent/40 transition-colors sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[Zr(e.assistant),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground mb-0.5`,children:[(0,$.jsx)(`span`,{className:`font-semibold capitalize text-foreground`,children:e.assistant===`antigravity`?`Antigravity`:e.assistant===`claude`?`Claude`:e.assistant===`codex`?`Codex`:`Copilot`}),(0,$.jsx)(`span`,{children:`•`}),(0,$.jsx)(`span`,{className:`font-mono text-muted-foreground/80`,children:e.id.slice(0,8)}),(0,$.jsx)(jn,{session:e}),(0,$.jsx)(`span`,{children:`•`}),(0,$.jsx)(yn,{session:e}),(0,$.jsx)(`span`,{children:`•`}),(0,$.jsxs)(`span`,{className:`font-mono`,children:[e.messageCount,` `,e.messageCount===1?`turn`:`turns`]})]}),(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground truncate`,title:e.title,children:e.title})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 pl-8 sm:pl-0`,children:[(0,$.jsxs)(Y,{size:`xs`,variant:`default`,disabled:C===e.id||!rn(e,t),onClick:()=>{let n=rn(e,t);n&&V(n.id,n.assistant,n.workspacePath)},title:e.threadKind===`subagent`?`Resume the main conversation instead of the delegated task`:`Resume session in terminal (${e.id})`,children:[C===e.id?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(Fn,{size:12}),(0,$.jsx)(`span`,{children:e.threadKind===`subagent`?`Main thread`:`Resume`})]}),(0,$.jsxs)(Y,{size:`xs`,variant:`outline`,onClick:()=>{r(e),i([]),a(e.assistant,e.id)},title:`Inspect transcript log`,children:[(0,$.jsx)(Mt,{size:12}),(0,$.jsx)(`span`,{children:`Logs`})]}),e.assistant===`codex`&&b&&(0,$.jsxs)(Y,{size:`xs`,variant:`outline`,disabled:x===e.id,onClick:()=>void re(e.id),title:`Open in Codex Desktop`,children:[x===e.id?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(Ze,{size:12}),(0,$.jsx)(`span`,{children:`Desktop`})]}),(0,$.jsx)(Y,{size:`icon-xs`,variant:`ghost`,onClick:async()=>{let t=Xr(e.assistant,e.id);await Ht(t),s?.(`Copied: ${t}`,`success`)},title:`Copy CLI resume command`,children:(0,$.jsx)(Dt,{size:12})})]})]},e.id))}):(0,$.jsx)(`div`,{className:`space-y-2.5`,children:ue.map(e=>{let n=L[e.id]??!1,o=e.sessions.filter(e=>{if(!N.trim())return!0;let t=N.toLowerCase();return`${e.title} ${e.id}`.toLowerCase().includes(t)});return(0,$.jsxs)(Bn,{className:`overflow-hidden surface-card`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between bg-muted/20 hover:bg-muted/35 transition-colors cursor-pointer select-none`,onClick:()=>R(e.id),children:[(0,$.jsxs)(`div`,{className:`flex flex-1 items-center gap-2.5 min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground transition-transform`,children:n?(0,$.jsx)(je,{size:14}):(0,$.jsx)(Qt,{size:14})}),e.icon,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 min-w-0`,children:[(0,$.jsx)(`span`,{className:`font-bold text-xs text-foreground`,children:e.name}),(0,$.jsxs)(Ct,{tone:e.isDetected?`success`:`neutral`,dot:e.isDetected,children:[`CLI: `,e.cliCommand]}),e.hasApp&&(0,$.jsx)(Ct,{tone:`running`,children:e.appName}),(0,$.jsxs)(`span`,{className:`text-[11px] text-muted-foreground font-mono`,children:[`(`,o.length,`)`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 pl-6 sm:pl-0`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(Y,{size:`xs`,variant:`default`,disabled:T===e.id,onClick:()=>void B(e.id),title:`Launch new ${e.cliCommand} session in terminal`,children:[T===e.id?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(Pt,{size:12}),(0,$.jsx)(`span`,{children:`New Session`})]}),e.hasApp&&(0,$.jsxs)(Y,{size:`xs`,variant:`outline`,onClick:()=>void ne(e.appTargetId),title:`Open in ${e.appName}`,children:[(0,$.jsx)(Ze,{size:12}),(0,$.jsx)(`span`,{children:e.appName})]})]})]}),n&&(0,$.jsx)(`div`,{className:`divide-y divide-border/60 border-t border-border`,children:o.length===0?(0,$.jsxs)(`div`,{className:`p-4 text-center text-xs text-muted-foreground flex items-center justify-center gap-2`,children:[(0,$.jsx)(`span`,{children:N?`No sessions match your search query.`:`No previous sessions recorded for ${e.name}.`}),!N&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void B(e.id),className:`text-primary font-semibold hover:underline cursor-pointer inline-flex items-center gap-1 text-xs`,children:[(0,$.jsx)(Pt,{size:11}),` Start session`]})]}):o.map(e=>(0,$.jsxs)(`div`,{className:`group flex flex-col gap-1.5 px-3.5 py-2.5 hover:bg-accent/40 transition-colors sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-0.5 text-[11px] text-muted-foreground font-mono`,children:[(0,$.jsx)(`span`,{children:e.id.slice(0,8)}),(0,$.jsx)(jn,{session:e}),(0,$.jsx)(`span`,{children:`•`}),(0,$.jsx)(yn,{session:e}),(0,$.jsx)(`span`,{children:`•`}),(0,$.jsxs)(`span`,{children:[e.messageCount,` `,e.messageCount===1?`turn`:`turns`]})]}),(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground truncate`,title:e.title,children:e.title})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,$.jsxs)(Y,{size:`xs`,variant:`default`,disabled:C===e.id||!rn(e,t),onClick:()=>{let n=rn(e,t);n&&V(n.id,n.assistant,n.workspacePath)},title:e.threadKind===`subagent`?`Resume the main conversation instead of the delegated task`:`Resume session in terminal (${e.id})`,children:[C===e.id?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(Fn,{size:12}),(0,$.jsx)(`span`,{children:e.threadKind===`subagent`?`Main thread`:`Resume`})]}),(0,$.jsxs)(Y,{size:`xs`,variant:`outline`,onClick:()=>{r(e),i([]),a(e.assistant,e.id)},title:`Inspect transcript log`,children:[(0,$.jsx)(Mt,{size:12}),(0,$.jsx)(`span`,{children:`Logs`})]}),e.assistant===`codex`&&b&&(0,$.jsxs)(Y,{size:`xs`,variant:`outline`,disabled:x===e.id,onClick:()=>void re(e.id),title:`Open in Codex Desktop`,children:[x===e.id?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(Ze,{size:12}),(0,$.jsx)(`span`,{children:`Desktop`})]}),(0,$.jsx)(Y,{size:`icon-xs`,variant:`ghost`,onClick:async()=>{let t=Xr(e.assistant,e.id);await Ht(t),s?.(`Copied: ${t}`,`success`)},title:`Copy CLI resume command`,children:(0,$.jsx)(Dt,{size:12})})]})]},e.id))})]},e.id)})})]})},$r=({ws:e,gitChanges:t,gitChangesLoading:n,syncLoading:r,syncResults:i,commitMessage:a,showCommitModal:o,commitLoading:s,commitResults:c,setSyncResults:l,setCommitResults:u,setCommitMessage:d,setShowCommitModal:f,fetchGitChanges:p,handleSyncAll:m,handleCommitAll:h,showToast:g})=>{let[_,v]=(0,Q.useState)({}),[y,b]=(0,Q.useState)({}),[x,S]=(0,Q.useState)({}),[C,w]=(0,Q.useState)({}),[T,E]=(0,Q.useState)({}),[D,O]=(0,Q.useState)({}),[k,A]=(0,Q.useState)({}),[j,M]=(0,Q.useState)({}),[N,P]=(0,Q.useState)(0),[F,I]=(0,Q.useState)(``),[ee,R]=(0,Q.useState)(0),[z,te]=(0,Q.useState)({}),[ne,B]=(0,Q.useState)(!1),V=_e().data?.config,re=Jt(),H=V?.defaultEditor,U=tn(H),W=fn(),ie=t.filter(e=>e.files&&e.files.length>0),ae=ie.reduce((e,t)=>e+t.files.length,0);(0,Q.useEffect)(()=>{S({}),w({}),E({}),O({}),b({}),M({}),te({}),En.clear()},[e.branchName]),(0,Q.useEffect)(()=>{if(!t||t.length===0){En.clear();return}let n=!1,r=new Set;for(let e of t)for(let t of e.files||[])r.add(`${e.repoName}/${t.file}`);for(let e of En.getAllSymbols())r.has(`${e.repoName}/${e.filePath}`)||En.removeFile(e.repoName,e.filePath);return(async()=>{try{let t=encodeURIComponent(e.branchName),r=await fetch(`/api/workspace/${t}/changes/symbols`);if(r.ok&&!n){let e=await r.json();if(e.symbols&&Array.isArray(e.symbols)){let t={};for(let n of e.symbols){let e=`${n.repoName}/${n.filePath}`;t[e]||(t[e]={repoName:n.repoName,filePath:n.filePath,repoPath:n.repoPath,symbols:[]}),t[e].symbols.push(n)}for(let e of Object.values(t)){if(n)break;O(t=>({...t,[`${e.repoName}/${e.filePath}`]:e.symbols})),En.indexFile(e.repoName,e.filePath,``,[],e.repoPath,e.symbols)}}}}catch{}})(),()=>{n=!0}},[t,e.branchName]);let G=(0,Q.useMemo)(()=>{let e=[];for(let t of ie)for(let n of t.files||[])e.push({repoName:t.repoName,repoPath:t.repoPath,file:n.file,type:n.type,additions:n.additions||0,deletions:n.deletions||0});return e},[ie]),oe=e=>_[e]??!0,se=e=>{v(t=>({...t,[e]:!oe(e)}))},ce=()=>{let e={};t.forEach(t=>{e[t.repoName]=!1}),v(e)},ue=()=>{let e={};t.forEach(t=>{e[t.repoName]=!0}),v(e),b({})},de=(0,Q.useCallback)(async(n,r)=>{let i=`${n}/${r}`,a=!y[i];if(b(e=>({...e,[i]:a})),a&&!x[i]){A(e=>({...e,[i]:!0})),M(e=>({...e,[i]:``}));try{let a=encodeURIComponent(e.branchName),o=await fetch(`/api/workspace/${a}/changes/diff?repo=${encodeURIComponent(n)}&file=${encodeURIComponent(r)}`);if(!o.ok)throw Error(`Failed to load diff: ${o.statusText}`);let s=await o.json();if(S(e=>({...e,[i]:s.diff||``})),s.fileContent&&w(e=>({...e,[i]:s.fileContent})),s.originalContent&&E(e=>({...e,[i]:s.originalContent})),s.symbols&&O(e=>({...e,[i]:s.symbols})),s.diff){let e=Vt(s.diff),i=s.fileContent||e.modifiedContent,a=t.find(e=>e.repoName===n);En.indexFile(n,r,i,e.hunks,a?.repoPath,s.symbols)}}catch(e){M(t=>({...t,[i]:e.message||`Unknown error`}))}finally{A(e=>({...e,[i]:!1}))}}},[y,x,e.branchName,t]),fe=(0,Q.useCallback)(async(e,t)=>{if(e<0||e>=G.length)return;P(e);let n=G[e];I(`${n.repoName}/${n.file}`),R(e=>e+1);let r=`${n.repoName}/${n.file}`;v(e=>({...e,[n.repoName]:!1})),t!==void 0&&te(e=>({...e,[r]:t})),y[r]||await de(n.repoName,n.file);let i=`file-diff-${n.repoName}-${n.file.replace(/[^a-zA-Z0-9_-]/g,`_`)}`;setTimeout(()=>{let e=document.getElementById(i);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})},50)},[G,y,de]),pe=(n,r,i)=>{let a=r.replace(/\\/g,`/`).replace(/^\//,``),o=G.findIndex(e=>{let t=e.file.replace(/\\/g,`/`).replace(/^\//,``);return(e.repoName===n||n===`workspace`||!n)&&(t===a||t.endsWith(a)||a.endsWith(t))});if(o!==-1)fe(o,i),g?.(`Navigated to ${r}${i?`:${i}`:``}`,`info`);else{g?.(`Opening ${r}${i?`:${i}`:``} in ${U}`,`info`);let a=t.find(e=>e.repoName===n)?.repoPath||e.repos&&e.repos.find(e=>e.endsWith(n))||n;In(a,r,i||1,1,H)}};(0,Q.useEffect)(()=>{let e=e=>{let t=e.target;if(!(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)){if(e.altKey&&(e.key===`ArrowDown`||e.key===`Down`)){if(e.preventDefault(),G.length>0){let e=(N+1)%G.length;fe(e)}}else if(e.altKey&&(e.key===`ArrowUp`||e.key===`Up`)&&(e.preventDefault(),G.length>0)){let e=(N-1+G.length)%G.length;fe(e)}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,G,fe]);let me=G[N]||null;return(0,$.jsxs)(`div`,{className:`animate-fade-in`,children:[(0,$.jsxs)(`header`,{className:`flex justify-between items-center mb-4 flex-wrap gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,$.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-bold text-foreground`,children:[(0,$.jsx)(ge,{size:16,className:`text-primary`}),` Active Workspace Git Diffs`]}),ie.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 pl-2 border-l border-border/80`,children:[(0,$.jsxs)(Y,{variant:`ghost`,size:`xs`,onClick:ue,title:`Collapse all repositories and file diffs`,className:`text-xs text-muted-foreground hover:text-foreground h-7 px-2 gap-1 font-semibold`,children:[(0,$.jsx)(Gn,{size:12}),(0,$.jsx)(`span`,{children:`Collapse All`})]}),(0,$.jsxs)(Y,{variant:`ghost`,size:`xs`,onClick:ce,title:`Expand all repositories`,className:`text-xs text-muted-foreground hover:text-foreground h-7 px-2 gap-1 font-semibold`,children:[(0,$.jsx)(Kn,{size:12}),(0,$.jsx)(`span`,{children:`Expand All`})]})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>p(e.branchName),disabled:n,children:[(0,$.jsx)(_n,{size:11,className:n?`animate-spin text-primary`:``}),` Refresh Changes`]}),e.mode!==`in-place`&&(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:()=>m(e.branchName),disabled:r,children:[r?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(_n,{size:11}),` Sync All`]}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>f(!0),disabled:ae===0||s,children:`Commit & Push All`})]})]}),G.length>0&&(0,$.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-center justify-between gap-2.5 rounded-xl border border-border/90 bg-card/75 p-2.5 px-3.5 backdrop-blur-md shadow-xs select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`span`,{className:`grid size-6 place-items-center rounded-md bg-primary/10 text-primary shrink-0`,children:(0,$.jsx)(er,{size:12})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 font-mono text-xs font-semibold text-foreground`,children:[(0,$.jsx)(`span`,{children:`File`}),(0,$.jsx)(`span`,{className:`rounded bg-primary/15 border border-primary/25 px-1.5 py-0.2 text-primary`,children:N+1}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`of `,G.length]})]}),(0,$.jsx)(`select`,{value:N,onChange:e=>void fe(Number(e.target.value)),className:`ml-2 max-w-[240px] sm:max-w-[360px] rounded-lg border border-border bg-background/80 px-2 py-1 font-mono text-[11px] text-foreground focus:outline-hidden focus:ring-1 focus:ring-primary truncate`,children:G.map((e,t)=>(0,$.jsxs)(`option`,{value:t,children:[`[`,e.type.slice(0,3),`] `,e.repoName,`: `,e.file,` (+`,e.additions,` -`,e.deletions,`)`]},`${e.repoName}/${e.file}`))})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{let e=(N-1+G.length)%G.length;fe(e)},className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-border bg-card hover:bg-accent font-mono text-[10px] text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Jump to previous modified file (Shortcut: Alt+Up)`,children:[(0,$.jsx)(He,{size:12}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Prev (Alt+↑)`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{let e=(N+1)%G.length;fe(e)},className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-border bg-card hover:bg-accent font-mono text-[10px] text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Jump to next modified file (Shortcut: Alt+Down)`,children:[(0,$.jsx)(je,{size:12}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Next (Alt+↓)`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>B(e=>!e),className:q(`inline-flex items-center gap-1 px-2 py-1 rounded border font-mono text-[10px] transition-colors cursor-pointer`,ne?`border-primary/50 bg-primary/15 text-primary font-bold`:`border-border bg-card hover:bg-accent text-muted-foreground hover:text-foreground`),title:`Toggle Global Changeset Symbol Explorer`,children:[(0,$.jsx)(yt,{size:12}),(0,$.jsxs)(`span`,{children:[`Symbols (`,W.length,`)`]})]}),me&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{In(me.repoPath,me.file,1,1,H),g?.(`Opened ${me.file} in ${U}`,`success`)},className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-border bg-card hover:bg-accent font-mono text-[10px] text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,title:`Open selected file in desktop ${U}`,children:[(0,$.jsx)(Ze,{size:11}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:U})]})]})]}),ne&&(0,$.jsx)(`div`,{className:`mb-5`,children:(0,$.jsx)(ln,{symbols:W,activeFilePath:me?.file,editorLabel:U,onSelectSymbol:e=>{pe(e.repoName,e.filePath,e.lineNumber)},onOpenInVsCode:e=>{let n=G.find(t=>t.repoName===e.repoName&&t.file===e.filePath)||G.find(t=>t.file===e.filePath),r=e.repoPath||n?.repoPath||t.find(t=>t.repoName===e.repoName)?.repoPath||e.repoName;In(r,e.filePath,e.lineNumber,e.column,H),g?.(`Opened ${e.filePath}:${e.lineNumber} in ${U}`,`success`)},onClose:()=>B(!1)})}),i&&e.mode!==`in-place`&&(0,$.jsxs)(`div`,{className:`relative mb-5 rounded-xl border border-info/25 bg-info/10 p-5 text-info-foreground shadow-sm`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between border-b border-info/20 pb-2`,children:[(0,$.jsx)(`h5`,{className:`font-mono text-xs font-bold text-foreground`,children:`Rebase / Sync Action Logs`}),(0,$.jsx)(`button`,{className:`cursor-pointer text-[10px] font-bold text-info-foreground hover:text-foreground`,onClick:()=>l(null),children:`Dismiss`})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:i.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-card p-2 font-mono text-[10px]`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.repoName}),(0,$.jsx)(`span`,{className:e.success?`font-bold text-success-foreground`:`font-bold text-destructive-foreground`,children:e.success?`✓ Synced (${e.message})`:`✗ Conflict: ${e.message}`})]},e.repoName))})]}),c&&(0,$.jsxs)(`div`,{className:`relative mb-5 rounded-xl border border-success/25 bg-success/10 p-5 text-success-foreground shadow-sm`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between border-b border-success/20 pb-2`,children:[(0,$.jsx)(`h5`,{className:`font-mono text-xs font-bold text-foreground`,children:`Commit & Push Results`}),(0,$.jsx)(`button`,{className:`cursor-pointer text-[10px] font-bold text-success-foreground hover:text-foreground`,onClick:()=>u(null),children:`Dismiss`})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:c.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-card p-2 font-mono text-[10px]`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.repoName}),(0,$.jsx)(`span`,{className:e.success?`font-bold text-success-foreground`:`font-bold text-destructive-foreground`,children:e.success?`✓ Committed ${e.filesChanged} file(s) (${e.commitHash?e.commitHash.slice(0,7):`no hash`})`:`✗ Error: ${e.message}`})]},e.repoName))})]}),o&&(0,$.jsxs)(`div`,{className:`relative mb-6 rounded-xl border border-border bg-card p-6 shadow-sm animate-rise`,children:[(0,$.jsxs)(`h5`,{className:`mb-3 flex items-center gap-1.5 text-xs font-bold text-foreground`,children:[(0,$.jsx)(vt,{size:13,className:`text-primary`}),` Enter Commit Message`]}),(0,$.jsx)(L,{type:`text`,className:`mb-4 font-mono text-xs`,placeholder:`feat: implement multi-repo logic...`,value:a,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Enter`&&a.trim()&&h(e.branchName)}}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2.5`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>{f(!1),d(``)},disabled:s,children:`Cancel`}),(0,$.jsxs)(Y,{size:`sm`,onClick:()=>h(e.branchName),disabled:s||!a.trim(),children:[s?(0,$.jsx)(Z,{className:`size-3`}):null,s?`Committing...`:`Commit & Push All`]})]})]}),n?(0,$.jsx)(`div`,{className:`flex justify-center py-20`,children:(0,$.jsx)(Z,{className:`size-6 text-primary`})}):(0,$.jsx)(`div`,{className:`space-y-4`,children:ie.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-border bg-card py-16 text-center shadow-xs`,children:[(0,$.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-full border border-success/25 bg-success/10 text-success-foreground shadow-sm`,children:(0,$.jsx)(zt,{size:20})}),(0,$.jsx)(`h5`,{className:`text-sm font-bold text-foreground`,children:`No Uncommitted Changes`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Workspace repositories are completely in sync with Git feature branches.`})]}):ie.map(t=>{let n=t.files.length,r=t.files.reduce((e,t)=>e+(t.additions||0),0),i=t.files.reduce((e,t)=>e+(t.deletions||0),0),a=oe(t.repoName);return(0,$.jsxs)(`div`,{className:`relative rounded-xl border border-border/80 bg-card/80 backdrop-blur-md transition-all shadow-xs overflow-hidden`,children:[(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:()=>se(t.repoName),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),se(t.repoName))},className:q(`flex justify-between items-center px-5 py-4 cursor-pointer select-none transition-colors`,a?`hover:bg-accent/40`:`bg-muted/20 border-b border-border/60 hover:bg-muted/30`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap min-w-0`,children:[(0,$.jsx)(`span`,{className:`grid size-6 place-items-center rounded-md bg-primary/10 text-primary border border-primary/20 shrink-0`,children:a?(0,$.jsx)(Qt,{size:14,className:`shrink-0 text-muted-foreground`}):(0,$.jsx)(je,{size:14,className:`shrink-0 text-primary`})}),(0,$.jsx)(`h5`,{className:`font-mono text-sm font-bold text-foreground truncate`,children:t.repoName}),(0,$.jsxs)(Ct,{tone:`warning`,dot:!1,children:[n,` file`,n===1?``:`s`,` changed`]}),(r>0||i>0)&&(0,$.jsxs)(`span`,{className:`rounded-md border border-border bg-muted/60 px-2 py-0.5 font-mono text-[10px] font-bold`,children:[(0,$.jsxs)(`span`,{className:`font-bold text-success-foreground`,children:[`+`,r]}),` `,(0,$.jsxs)(`span`,{className:`font-bold text-destructive-foreground`,children:[`-`,i]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,$.jsx)(`span`,{className:`max-w-[280px] truncate font-mono text-[10px] text-muted-foreground hidden md:inline`,title:t.repoPath,children:t.repoPath}),(0,$.jsx)(`span`,{className:`text-[11px] font-bold text-primary hover:underline`,children:a?`Expand Files`:`Collapse`})]})]}),!a&&(0,$.jsx)(`div`,{className:`p-5 flex flex-col gap-3 bg-card/40`,children:(0,$.jsx)(Pn,{label:`${t.repoName} changed files`,files:t.files,revealPath:F.startsWith(`${t.repoName}/`)?F.slice(t.repoName.length+1):void 0,revealKey:ee,renderFile:n=>{let r=`${t.repoName}/${n.file}`,i=!!y[r],a=!!k[r],o=x[r]||``,s=j[r]||``,c=`file-diff-${t.repoName}-${n.file.replace(/[^a-zA-Z0-9_-]/g,`_`)}`;return(0,$.jsxs)(`div`,{id:c,className:`overflow-hidden rounded transition-colors`,children:[(0,$.jsxs)(`div`,{className:`flex cursor-pointer select-none items-center justify-between px-2 py-1.5 transition-colors hover:bg-accent/50`,role:`button`,tabIndex:0,"aria-expanded":i,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),de(t.repoName,n.file))},onClick:()=>de(t.repoName,n.file),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[i?(0,$.jsx)(je,{size:14,className:`shrink-0 text-primary`}):(0,$.jsx)(Qt,{size:14,className:`shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`max-w-[240px] truncate font-mono text-[11px] text-foreground sm:max-w-[480px] font-semibold`,title:n.file,children:n.file.split(`/`).at(-1)}),(n.additions>0||n.deletions>0)&&(0,$.jsxs)(`span`,{className:`ml-1 shrink-0 font-mono text-[9px] font-bold text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`text-success-foreground`,children:[`+`,n.additions]}),` /`,` `,(0,$.jsxs)(`span`,{className:`text-destructive-foreground`,children:[`-`,n.deletions]})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2.5 shrink-0`,children:(0,$.jsx)(`span`,{className:`rounded border px-2 py-0.5 text-[8px] font-bold uppercase tracking-wider ${n.type===`added`?`border-success/25 bg-success/10 text-success-foreground`:n.type===`deleted`?`border-destructive/25 bg-destructive/10 text-destructive-foreground`:`border-warning/25 bg-warning/10 text-warning-foreground`}`,children:n.type})})]}),i&&(0,$.jsx)(`div`,{className:`border-t border-border bg-background p-3`,children:a?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-2 font-mono text-[10px] text-primary`,children:[(0,$.jsx)(Z,{className:`size-3`}),` Loading diff...`]}):s?(0,$.jsxs)(`div`,{className:`p-2 font-mono text-[10px] text-destructive-foreground`,children:[`Error: `,s]}):(0,$.jsx)(bt,{filePath:n.file,fallbackContent:o,children:(0,$.jsx)(on,{filePath:n.file,repoName:t.repoName,repoPath:t.repoPath,patchText:o,fullFileContent:C[r],fullOriginalContent:T[r],preExtractedSymbols:D[r],defaultEditor:H,viewMode:re.diffViewMode,onToggleViewMode:re.toggleDiffMode,onRequestRefine:(r,i)=>{le.openDraft(e.branchName,[`Refine ${t.repoName}/${n.file} at line ${r.startLineModified}.`,i,`Selected diff hunk:`,r.patchHeader,...r.lines].join(`
2
2
  `))},initialTargetLine:z[r],onOpenFile:pe,onSelectSymbol:e=>{pe(e.repoName,e.filePath,e.lineNumber)},showToast:g})})})]},n.file)}})})]},t.repoName)})})]})},ei=({ws:e,knowledgeContent:t,knowledgeLoading:n,knowledgeError:r,isEditingKnowledge:i,editedKnowledge:a,saveKnowledgeLoading:o,saveKnowledgeError:s,setEditedKnowledge:c,setIsEditingKnowledge:l,handleSaveKnowledge:u,handleRetryKnowledge:d})=>{let[f,p]=(0,Q.useState)(`preview`);return(0,$.jsxs)(`div`,{className:`rounded-xl border border-border/80 bg-card/70 backdrop-blur-md p-5 shadow-xs`,children:[(0,$.jsxs)(`header`,{className:`flex justify-between items-center mb-4`,children:[(0,$.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-bold text-foreground`,children:[(0,$.jsx)(Nn,{size:16,className:`text-primary`}),` Persistent Knowledge Memory (contextspace-knowledge.md)`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!i&&t&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted/50 p-0.5 rounded-md border border-border/60`,children:[(0,$.jsxs)(Y,{size:`xs`,variant:f===`preview`?`secondary`:`ghost`,onClick:()=>p(`preview`),className:`text-[11px] gap-1 px-2`,children:[(0,$.jsx)(Gt,{size:11}),` Preview`]}),(0,$.jsxs)(Y,{size:`xs`,variant:f===`raw`?`secondary`:`ghost`,onClick:()=>p(`raw`),className:`text-[11px] gap-1 px-2`,children:[(0,$.jsx)(Xn,{size:11}),` Raw`]})]}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,onClick:()=>{c(t),l(!1)},disabled:o,children:`Cancel`}),(0,$.jsxs)(Y,{size:`xs`,onClick:()=>u(e.branchName),disabled:o,children:[o?(0,$.jsx)(Z,{className:`size-3`}):(0,$.jsx)(vt,{size:10}),` `,s?`Retry save`:`Save`]})]}):(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,onClick:()=>l(!0),disabled:n,children:[(0,$.jsx)(sr,{size:10}),` Edit Knowledge`]})]})]}),r&&(0,$.jsxs)(`div`,{role:`alert`,className:`mb-4 flex flex-wrap items-center justify-between gap-3 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive-foreground`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(xt,{size:14,className:`shrink-0`}),(0,$.jsx)(`span`,{children:r})]}),(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,onClick:()=>void d(e.branchName),disabled:n,children:[(0,$.jsx)(_n,{size:11,className:n?`animate-spin`:``}),` Retry load`]})]}),s&&(0,$.jsxs)(`div`,{role:`alert`,className:`mb-4 flex items-center gap-2 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive-foreground`,children:[(0,$.jsx)(xt,{size:14,className:`shrink-0`}),(0,$.jsx)(`span`,{children:s})]}),i?(0,$.jsx)(wn,{"aria-label":`Knowledge editor`,className:`[&_[data-slot=textarea]]:h-96 [&_[data-slot=textarea]]:resize-y [&_[data-slot=textarea]]:font-mono [&_[data-slot=textarea]]:text-xs`,value:a,onChange:e=>c(e.target.value)}):n&&!t?(0,$.jsx)(`div`,{className:`flex justify-center py-10`,children:(0,$.jsx)(_n,{className:`animate-spin text-primary`,size:20})}):t?f===`preview`?(0,$.jsx)(`div`,{className:`max-h-[550px] overflow-auto rounded-xl border border-border/70 bg-card/40 backdrop-blur-xs p-4`,children:(0,$.jsx)(Tt,{content:t})}):(0,$.jsx)(`div`,{className:`max-h-[550px] overflow-auto whitespace-pre-wrap rounded-xl border border-border/70 bg-card/40 backdrop-blur-xs p-4 font-mono text-xs leading-relaxed text-muted-foreground`,children:t}):(0,$.jsx)(`div`,{className:`rounded-md border border-dashed border-border/80 bg-muted/20 p-6 text-center text-xs text-muted-foreground`,children:`No knowledge file generated yet.`})]})},ti=({planContent:e,planLoading:t,planError:n,handleRetryPlan:r,workspaceId:i,defaultViewMode:a=`flow`})=>{let[o,s]=(0,Q.useState)(a),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{a&&s(a)},[a]);let w=(0,Q.useCallback)(async()=>{if(i){p(!0);try{let e=await X(`/api/workspace/${encodeURIComponent(i)}/lifecycle`);d(e.lifecycle),e.plan!==void 0&&l(e.plan),e.report!==void 0&&y(e.report)}catch(e){console.warn(`Could not load workspace lifecycle:`,e)}finally{p(!1)}}},[i]);(0,Q.useEffect)(()=>{l(null),y(null),_(null),w()},[w]);let T=async()=>{if(i){h(!0),_(null);try{let e=(await X(`/api/workspace/${encodeURIComponent(i)}/verify`,{method:`POST`,body:JSON.stringify({})})).report;y(e);let t={pass:`Tests passed (${(e.durationMs/1e3).toFixed(1)}s, ${e.repos.length} repositories).${u?.steps.some(e=>e.id===u.currentStepId&&e.requiresVerification)?` Use Verify & Complete on the active gate to advance.`:``}`,pass_dirty:e.canProgress?`Tests passed with uncommitted changes. Review the changes before continuing.`:`Tests passed with uncommitted changes. Commit them and rerun verification before advancing.`,"no-tests":`No test command was found. Configure a verification command for this workspace and run it again.`,timeout:`Verification timed out. Check the command and output below, then retry.`,fail:`Verification failed. Review the repository details below, fix the problem, and retry.`,skipped:`Verification was skipped. Run verification before relying on a test result.`};_({status:e.overallStatus,text:t[e.overallStatus]}),await w()}catch(e){_({status:`fail`,text:`Verification failed: ${e.message}`})}finally{h(!1)}}},E=async(e,t)=>{if(i){x(e),_(null);try{let n=await X(`/api/workspace/${encodeURIComponent(i)}/lifecycle/step`,{method:`POST`,body:JSON.stringify({stepId:e,action:t})});d(n.lifecycle),await w()}catch(e){_({status:`fail`,text:e instanceof Error?e.message:`Unable to advance lifecycle.`}),await w()}finally{x(null)}}},D=/<!-- CONTEXTSPACE:MILESTONES:START -->[\s\S]*?<!-- CONTEXTSPACE:MILESTONES:END -->/,O=c===null?e:D.test(e)?e.replace(D,()=>c):`${c}\n\n${e}`,k=!!u?.steps.length,A=o===`flow`&&!k?`preview`:o;return(0,$.jsxs)(`div`,{className:`rounded-xl border border-border/80 bg-card/70 backdrop-blur-md p-5 shadow-xs`,children:[(0,$.jsxs)(`header`,{className:`flex flex-wrap justify-between items-center gap-3 mb-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ln,{size:18,className:`text-primary`}),(0,$.jsx)(`h4`,{className:`text-sm font-bold text-foreground`,children:k?`Lifecycle Flow & Implementation Plan`:`Plan & verification`}),k&&u&&(0,$.jsxs)(`span`,{className:`px-2 py-0.5 text-[11px] font-semibold rounded-full bg-primary/10 text-primary border border-primary/20 uppercase tracking-wider`,children:[u.flowType,` flow`]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-1 bg-muted/50 p-0.5 rounded-md border border-border/60`,children:[k&&(0,$.jsxs)(Y,{size:`xs`,variant:A===`flow`?`secondary`:`ghost`,onClick:()=>s(`flow`),className:`text-[11px] gap-1 px-2.5 font-medium`,children:[(0,$.jsx)(Ln,{size:12}),` Visual Flow`]}),(0,$.jsxs)(Y,{size:`xs`,variant:A===`preview`?`secondary`:`ghost`,onClick:()=>s(`preview`),className:`text-[11px] gap-1 px-2.5`,children:[(0,$.jsx)(Gt,{size:12}),` Markdown Plan`]}),(0,$.jsxs)(Y,{size:`xs`,variant:A===`raw`?`secondary`:`ghost`,onClick:()=>s(`raw`),className:`text-[11px] gap-1 px-2`,children:[(0,$.jsx)(Xn,{size:12}),` Raw`]})]})})]}),g&&(0,$.jsxs)(`div`,{role:`status`,className:`mb-4 flex items-center justify-between p-3 rounded-lg text-xs font-medium border ${g.status===`pass`?`bg-emerald-500/10 text-emerald-400 border-emerald-500/30`:[`pass_dirty`,`no-tests`,`skipped`].includes(g.status)?`bg-amber-500/10 text-amber-400 border-amber-500/30`:`bg-rose-500/10 text-rose-400 border-rose-500/30`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[g.status===`pass`?(0,$.jsx)(Zt,{size:15}):([`pass_dirty`,`no-tests`,`skipped`].includes(g.status),(0,$.jsx)(xt,{size:15})),(0,$.jsx)(`span`,{children:g.text})]}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:()=>_(null),className:`text-[10px] h-6 px-1.5`,children:`Dismiss`})]}),v&&(0,$.jsxs)(`details`,{className:`mb-4 rounded-lg border border-border p-3 text-xs`,open:v.overallStatus!==`pass`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer font-medium`,children:[`Verification details (`,v.overallStatus.replaceAll(`_`,` `),`)`]}),v.repos.map((e,t)=>(0,$.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-border pt-3`,children:[(0,$.jsxs)(`p`,{className:`font-semibold`,children:[e.repoName,`: `,e.status.replaceAll(`_`,` `)]}),(0,$.jsxs)(`p`,{className:`font-mono break-all`,children:[e.command,e.exitCode===null?``:` — exit code ${e.exitCode}`]}),e.status===`no-tests`&&(0,$.jsx)(`p`,{children:`No test command found. Configure a workspace verification command.`}),e.status===`timeout`&&(0,$.jsx)(`p`,{children:`The command exceeded its time limit. Check for a stalled test or split the suite, then retry.`}),e.error&&(0,$.jsx)(`p`,{className:`text-destructive`,children:e.error}),(e.stdout||e.stderr)&&(0,$.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words rounded bg-muted p-3`,children:[e.stdout,e.stderr].filter(Boolean).join(`
3
3
  `)})]},`${e.repoName}-${t}`))]}),n&&(0,$.jsxs)(`div`,{role:`alert`,className:`mb-4 flex flex-wrap items-center justify-between gap-3 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive-foreground`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(xt,{size:14,className:`shrink-0`}),(0,$.jsx)(`span`,{children:n})]}),i&&(0,$.jsxs)(Y,{variant:`outline`,size:`xs`,onClick:()=>void r(i),disabled:t,children:[(0,$.jsx)(_n,{size:11,className:t?`animate-spin`:``}),` Retry load`]})]}),(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[k&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Active Step:`}),(0,$.jsx)(`span`,{children:u?.currentStepId??`none`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[k&&(0,$.jsxs)(Y,{size:`xs`,variant:`outline`,onClick:()=>void w(),disabled:f,children:[(0,$.jsx)(_n,{size:12,className:f?`animate-spin`:``}),` Refresh Radar`]}),(0,$.jsxs)(Y,{size:`xs`,onClick:()=>void T(),disabled:!i||m||b!==null,children:[(0,$.jsx)(rt,{size:14,className:m?`animate-spin`:``}),m?`Running Tests...`:`Run verification`]})]})]}),A===`flow`?(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Vertical Slices & Milestones`}),(0,$.jsx)(`div`,{className:`grid gap-3`,children:u?.steps.map((e,t)=>{let n=e.id===u.currentStepId,r=e.requiresVerification||e.verificationCommand||e.lastVerificationStatus||[`verify_and_ship`,`step_verification`,`epic_slice_4`].includes(e.id);return(0,$.jsx)(`div`,{className:`relative p-4 rounded-xl border transition-all ${e.status===`completed`?`border-emerald-500/30 bg-emerald-500/5`:e.status===`verified`?`border-cyan-500/40 bg-cyan-500/5`:n||e.status===`in_progress`?`border-primary/50 bg-primary/5 ring-1 ring-primary/20 shadow-xs`:e.status===`blocked`?`border-border/40 bg-muted/10 opacity-75`:`border-border/70 bg-card/40`}`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:e.status===`completed`?(0,$.jsx)(Zt,{size:18,className:`text-emerald-400`}):e.status===`verified`?(0,$.jsx)(rt,{size:18,className:`text-cyan-400`}):e.status===`in_progress`?(0,$.jsx)(Jn,{size:18,className:`text-primary animate-pulse`}):e.status===`blocked`?(0,$.jsx)(zn,{size:18,className:`text-muted-foreground/60`}):(0,$.jsx)(Yn,{size:18,className:`text-amber-400/80`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-xs font-bold text-muted-foreground`,children:[`Slice `,t+1,`:`]}),(0,$.jsx)(`h5`,{className:`text-sm font-semibold text-foreground`,children:e.title}),e.status===`blocked`&&(0,$.jsxs)(`p`,{className:`w-full text-xs text-amber-500`,children:[`Blocked: `,e.unblockCondition||(e.dependsOn?.length?`Complete ${e.dependsOn.map(e=>u.steps.find(t=>t.id===e)?.title??e).join(`, `)}.`:`Set an unblock condition in Edit milestones.`)]}),e.owner&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium bg-muted text-muted-foreground`,children:[(0,$.jsx)(cr,{size:10}),` `,e.owner]}),e.repo&&(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Repo: `,e.repo]}),e.workItem&&(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground break-all`,children:[`Work item / PR: `,e.workItem]}),e.branch&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-mono text-cyan-400 bg-cyan-500/10 border border-cyan-500/20`,children:[(0,$.jsx)(kt,{size:10}),` `,e.branch]})]}),e.description&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.dependsOn&&e.dependsOn.length>0&&(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5 text-[11px] text-muted-foreground/80`,children:[(0,$.jsx)(`span`,{className:`font-semibold`,children:`Depends on:`}),e.dependsOn.map(e=>(0,$.jsx)(`span`,{className:`px-1.5 py-0.2 bg-muted/60 rounded text-[10px] font-mono`,children:e},e))]}),e.lastVerificationStatus&&(0,$.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 text-[11px] font-medium px-2 py-0.5 rounded border ${e.lastVerificationStatus===`pass`?`text-emerald-400 bg-emerald-500/10 border-emerald-500/20`:`text-amber-400 bg-amber-500/10 border-amber-500/20`}`,children:[(0,$.jsx)(rt,{size:12}),(0,$.jsxs)(`span`,{children:[`Gate: `,e.lastVerificationStatus.toUpperCase()]}),e.lastVerificationSha&&(0,$.jsxs)(`span`,{className:`font-mono text-[10px] opacity-80`,children:[`@`,e.lastVerificationSha.slice(0,7)]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(e.status===`in_progress`||e.status===`verified`)&&(0,$.jsxs)(Y,{size:`xs`,variant:`outline`,onClick:()=>void E(e.id,`complete`),disabled:m||b!==null,className:`text-[11px] gap-1 border-emerald-500/40 text-emerald-400 hover:bg-emerald-500/10`,children:[(0,$.jsx)(zt,{size:12}),` `,b===e.id?`Working...`:r?`Verify & Complete`:`Mark Complete`]}),e.status===`pending`&&(0,$.jsxs)(Y,{size:`xs`,variant:`ghost`,onClick:()=>void E(e.id,`start`),disabled:m||b!==null,className:`text-[11px] gap-1 text-primary hover:bg-primary/10`,children:[(0,$.jsx)(It,{size:12}),` Start`]}),(0,$.jsx)(`span`,{className:`text-[10px] uppercase font-bold px-2 py-0.5 rounded ${e.status===`completed`?`bg-emerald-500/20 text-emerald-400`:e.status===`verified`?`bg-cyan-500/20 text-cyan-400`:e.status===`in_progress`?`bg-primary/20 text-primary`:e.status===`blocked`?`bg-muted/40 text-muted-foreground`:`bg-amber-500/20 text-amber-400`}`,children:e.status.replace(`_`,` `)})]})]})},e.id)})})]}),u?.fleet&&u.fleet.length>0&&(0,$.jsxs)(`div`,{className:`space-y-3 pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>C(e=>!e),className:`flex items-center gap-1.5 text-xs font-semibold text-muted-foreground hover:text-foreground transition-colors uppercase tracking-wider cursor-pointer`,"aria-expanded":S,"aria-controls":`sister-branch-fleet-list`,children:[(0,$.jsx)(rr,{size:14,className:`text-cyan-400`}),(0,$.jsx)(`span`,{children:`Sister Branch Fleet & Collaborator Radar`})]}),(0,$.jsxs)(V,{variant:`outline`,className:`text-[10px] font-mono px-1.5 py-0 h-4.5`,children:[u.fleet.length,` `,u.fleet.length===1?`branch`:`branches`]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`hidden sm:inline text-[11px] text-muted-foreground`,children:`Tracking origin remote references`}),(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,onClick:()=>C(e=>!e),className:`h-6 px-2 text-[11px] gap-1 text-muted-foreground hover:text-foreground`,title:S?`Collapse fleet`:`Expand fleet`,"aria-expanded":S,"aria-controls":`sister-branch-fleet-list`,children:S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(je,{size:13}),(0,$.jsx)(`span`,{children:`Collapse`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Qt,{size:13}),(0,$.jsx)(`span`,{children:`Expand`})]})})]})]}),S&&(0,$.jsx)(`div`,{id:`sister-branch-fleet-list`,className:`grid gap-2`,children:u.fleet.map(e=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between p-3 rounded-lg border text-xs ${e.isCurrent?`border-primary/40 bg-primary/5`:`border-border/60 bg-card/30`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full shrink-0 ${e.isCurrent?`bg-emerald-400 ring-4 ring-emerald-400/20`:`bg-cyan-400`}`}),(0,$.jsx)(`span`,{className:`font-mono font-semibold text-foreground`,children:e.branch}),e.repoName&&new Set(u?.fleet?.map(e=>e.repoName)).size>1&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono bg-muted/60 px-1.5 py-0.2 rounded border border-border/40`,children:e.repoName}),e.isCurrent&&(0,$.jsx)(`span`,{className:`text-[10px] font-medium px-1.5 py-0.2 rounded bg-primary/20 text-primary`,children:`active worktree`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`font-mono text-[11px]`,children:[`+`,e.ahead,` / -`,e.behind]}),e.lastCommitAuthor&&(0,$.jsxs)(`span`,{className:`text-[11px] text-foreground/80`,children:[e.lastCommitAuthor,e.lastCommitDate&&(0,$.jsxs)(`span`,{className:`text-muted-foreground ml-1`,children:[`(`,Number.isNaN(Date.parse(e.lastCommitDate))?`Date unavailable — reload flow`:new Date(e.lastCommitDate).toLocaleString(),`)`]})]}),e.lastCommitMessage&&(0,$.jsxs)(`span`,{className:`truncate max-w-[240px] text-muted-foreground italic text-[11px]`,children:[`"`,e.lastCommitMessage,`"`]})]})]},`${e.repoName}:${e.branch}`))})]})]}):(0,$.jsx)(`div`,{children:t&&!O?(0,$.jsx)(`div`,{className:`flex justify-center py-10`,children:(0,$.jsx)(_n,{className:`animate-spin text-primary`,size:20})}):O?A===`preview`?(0,$.jsx)(`div`,{className:`max-h-[550px] overflow-auto rounded-xl border border-border/70 bg-card/40 backdrop-blur-xs p-4`,children:(0,$.jsx)(Tt,{content:O})}):(0,$.jsx)(`div`,{className:`max-h-[550px] overflow-auto whitespace-pre-wrap rounded-xl border border-border/70 bg-card/40 backdrop-blur-xs p-4 font-mono text-xs leading-relaxed text-muted-foreground`,children:O}):(0,$.jsx)(`div`,{className:`rounded-md border border-dashed border-border/80 bg-muted/20 p-6 text-center text-xs text-muted-foreground`,children:`No implementation plan generated yet.`})})]})};function ni({workspaceId:e}){let[t,n]=(0,Q.useState)([]),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(0),[d,f]=(0,Q.useState)(!0),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),x=`/api/workspace/${encodeURIComponent(e)}/documents`;(0,Q.useEffect)(()=>{let e=new AbortController;return f(!0),g(``),X(x,{signal:e.signal}).then(e=>{n(e.documents),i(t=>e.documents.some(e=>e.name===t)?t:null)}).catch(t=>{e.signal.aborted||g(t instanceof Error?t.message:`Unable to load documents.`)}).finally(()=>{e.signal.aborted||f(!1)}),()=>e.abort()},[x,l]),(0,Q.useEffect)(()=>{let e=new AbortController;return o(null),v(``),b(!1),r?(m(!0),X(`${x}/preview?name=${encodeURIComponent(r)}`,{signal:e.signal}).then(o).catch(t=>{e.signal.aborted||v(t instanceof Error?t.message:`Unable to open document.`)}).finally(()=>{e.signal.aborted||m(!1)}),()=>e.abort()):(m(!1),()=>e.abort())},[x,r,l]);let S=r?`${x}/file?name=${encodeURIComponent(r)}`:``,C=t.filter(e=>e.name.toLowerCase().includes(s.toLowerCase()));return(0,$.jsxs)(`section`,{"aria-label":`Workspace documents`,className:`space-y-4`,children:[(0,$.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Documents`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Files in the workspace root, including documents created by your agents.`})]}),(0,$.jsxs)(Y,{variant:`outline`,disabled:d||p,onClick:()=>u(e=>e+1),children:[(0,$.jsx)(_n,{size:14}),`Refresh documents`]})]}),h&&(0,$.jsxs)(`div`,{role:`alert`,className:`text-sm text-destructive`,children:[h,` `,(0,$.jsx)(Y,{variant:`outline`,onClick:()=>u(e=>e+1),children:`Retry documents`})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(200px,280px)_minmax(0,1fr)]`,children:[(0,$.jsxs)(`aside`,{className:`rounded-xl border border-border bg-card p-3 space-y-3`,children:[(0,$.jsx)(L,{"aria-label":`Filter documents`,placeholder:`Filter documents…`,value:s,onChange:e=>c(e.target.value)}),d?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading documents…`}):!h&&!t.length?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No documents in the workspace root yet. Refresh after a file is created.`}):!C.length&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No matching documents.`}),(0,$.jsx)(`ul`,{className:`max-h-[65vh] overflow-y-auto space-y-1`,children:C.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":r===e.name,className:`w-full rounded-lg p-2 text-left text-sm hover:bg-accent ${r===e.name?`bg-accent text-accent-foreground`:``}`,onClick:()=>i(e.name),children:[(0,$.jsxs)(`span`,{className:`flex gap-2 items-start`,children:[(0,$.jsx)(Gt,{size:15,className:`mt-0.5 shrink-0`}),(0,$.jsx)(`span`,{className:`break-all`,children:e.name})]}),(0,$.jsxs)(`span`,{className:`block pl-6 text-xs text-muted-foreground`,children:[Math.max(1,Math.ceil(e.size/1024)),` KB · `,new Date(e.modifiedAt).toLocaleDateString()]})]})},e.name))})]}),(0,$.jsx)(`article`,{"aria-label":`Document preview`,className:`min-w-0 rounded-xl border border-border bg-card p-4 space-y-4`,children:r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`h3`,{className:`font-semibold break-all`,children:r}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[a?.kind===`markdown`&&(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>b(e=>!e),children:y?`Rendered view`:`Raw text`}),(0,$.jsx)(`a`,{href:`${S}&download=1`,download:r,className:`text-primary underline`,children:`Download`}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>i(null),children:`Close document`})]})]}),p&&(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Opening document…`}),_&&(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[_,` `,(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>u(e=>e+1),children:`Retry preview`})]}),a&&(0,$.jsx)(`div`,{className:`max-h-[70vh] overflow-auto`,children:a.kind===`markdown`&&!y?(0,$.jsx)(Tt,{content:a.content??``}):a.content===void 0?a.kind===`pdf`?(0,$.jsx)(`iframe`,{title:`Preview of ${r}`,src:S,className:`h-[65vh] w-full rounded border-0`},`${r}-${l}`):a.kind===`image`?(0,$.jsx)(`img`,{src:`${S}&revision=${l}`,alt:r,className:`max-w-full h-auto`,onError:()=>v(`The image could not be displayed.`)}):(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Preview is unavailable for this format. Download the document to open it in its application.`}):(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-sm`,children:a.content})})]}):(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select a document to open it here.`})})]})]})}function ri({workspaceId:e}){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),d=`/api/workspace/${encodeURIComponent(e)}/planning-notes`,f=async e=>{u(!0),o(``),c(``);try{let t=await X(d,{signal:e});if(e?.aborted)return;n(t),i(t.content)}catch(t){e?.aborted||o(t instanceof Error?t.message:`Could not load planning notes.`)}finally{e?.aborted||u(!1)}};(0,Q.useEffect)(()=>{let e=new AbortController;return f(e.signal),()=>e.abort()},[d]);let p=async()=>{if(t){u(!0),o(``),c(``);try{let e=await X(d,{method:`PUT`,body:JSON.stringify({revision:t.revision,content:r})});n(e),c(`Delivery notes saved. Refresh will preserve them.`)}catch(e){o(`${e instanceof Error?e.message:`Could not save.`} Your draft is kept.`)}finally{u(!1)}}};return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Authored delivery order, open questions, existing work, and flag-only decisions. Edit the tables as Markdown; this document survives refresh. Use Edit milestones for gates and progress.`}),a&&(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}),s&&(0,$.jsx)(`p`,{role:`status`,className:`text-sm`,children:s}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Delivery notes`,(0,$.jsx)(wn,{"aria-label":`Delivery notes`,rows:20,style:{fieldSizing:`fixed`,height:`24rem`,resize:`vertical`},className:`mt-2 font-mono text-xs`,value:r,disabled:l||!t,onChange:e=>i(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Y,{disabled:l||!t||r===t.content,onClick:()=>void p(),children:`Save delivery notes`}),(0,$.jsx)(Y,{variant:`outline`,disabled:l,onClick:()=>void f(),children:`Reload delivery notes`})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Stored in contextspace-milestones.md. Reload replaces your draft with the saved document.`})]})}var ii=()=>({title:``,role:`requirements`,status:`draft`,scope:{},summary:``}),ai=`mt-1 w-full rounded-md border border-border bg-background p-2 text-sm`,oi=[`investigate`,`design`,`implement`,`verify`,`review`,`release`];function si({workspaceId:e,onPlanChanged:t}){let[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)([]),[c,l]=(0,Q.useState)(`assignment`),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(ii),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(`text`),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(``),[O,k]=(0,Q.useState)(null),A=`/api/workspace/${encodeURIComponent(e)}`,j=(0,Q.useCallback)(async()=>{_(``);try{let e=await X(`${A}/work`);r(e),a(e.guidance),s(e.lifecycle?.steps??[])}catch(e){_(e instanceof Error?e.message:`Unable to load work brief.`)}},[A]);(0,Q.useEffect)(()=>{j()},[j]);let M=async e=>{p(!0),_(``),h(``);try{await e()}catch(e){_(e instanceof Error?e.message:`The operation failed.`)}finally{p(!1)}},N=(0,$.jsx)($.Fragment,{children:n?.lifecycle?.steps.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.title},e.id))}),P=e=>a(t=>t&&{...t,assignment:{...t.assignment,...e}}),F=()=>M(async()=>{if(!n||!i)return;let e=await X(`${A}/work`,{method:`PUT`,body:JSON.stringify({revision:n.guidance.revision,workType:i.workType,size:i.size,assignment:i.assignment})});r(e),a(e.guidance),h(`AI assignment saved.`)}),I=()=>M(async()=>{if(!n)return;let e=await X(`${A}/work/documents${b?`/${b}`:``}`,{method:b?`PATCH`:`POST`,body:JSON.stringify({...v,revision:n.guidance.revision,...b?{}:S===`link`?{url:E}:{content:w}})});r(e),y(ii()),x(null),T(``),D(``),h(`Document saved. Its role, status, and scope now appear in AI context.`)}),ee=()=>M(async()=>{if(!n?.lifecycle)return;let e=await X(`${A}/lifecycle/plan`,{method:`PUT`,body:JSON.stringify({revision:n.lifecycle.revision??0,steps:o})});r({...n,lifecycle:e.lifecycle}),s(e.lifecycle.steps),t(),h(`Milestones saved. Visual Flow and the Markdown plan use these same steps.`)}),R=i&&n&&(i.workType!==n.guidance.workType||i.size!==n.guidance.size||JSON.stringify(i.assignment)!==JSON.stringify(n.guidance.assignment));return(0,$.jsxs)(`section`,{className:`mb-5 rounded-xl border border-border bg-card p-5 space-y-4`,"aria-label":`Work brief and sources`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`font-semibold`,children:`Work brief & sources`}),(0,$.jsx)(Y,{size:`sm`,variant:`outline`,disabled:f,onClick:()=>void j(),children:`Reload brief`})]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Keep source documents here and set the AI’s current assignment. Add milestones only when this feature needs them.`}),g&&(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[g,` Your draft is kept. Reload to review the latest saved version.`]}),m&&(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:m}),!n||!i?(0,$.jsx)(`p`,{className:`text-sm`,children:g?`Work brief unavailable.`:`Loading work brief…`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,"aria-label":`Brief sections`,children:[`assignment`,`documents`,`milestones`,`notes`].map(e=>(0,$.jsx)(Y,{size:`sm`,variant:c===e?`secondary`:`ghost`,"aria-pressed":c===e,onClick:()=>{l(e),e===`notes`&&d(!0)},children:e===`assignment`?`AI assignment`:e===`documents`?`Source documents`:e===`milestones`?n.lifecycle?.steps.length?`Edit milestones`:`Add milestones`:`Delivery notes & questions`},e))}),u&&(0,$.jsx)(`div`,{hidden:c!==`notes`,children:(0,$.jsx)(ri,{workspaceId:e},e)}),c===`assignment`&&(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,$.jsxs)(`label`,{className:`text-sm`,children:[`Work type`,(0,$.jsx)(`select`,{"aria-label":`Work type`,className:ai,value:i.workType,onChange:e=>a({...i,workType:e.target.value}),children:[`bug`,`feature`,`performance`,`refactor`,`rewrite`].map(e=>(0,$.jsx)(`option`,{value:e,children:e===`bug`?`Bug fix`:e[0].toUpperCase()+e.slice(1)},e))})]}),(0,$.jsxs)(`label`,{className:`text-sm`,children:[`Size`,(0,$.jsxs)(`select`,{"aria-label":`Size`,className:ai,value:i.size,onChange:e=>a({...i,size:e.target.value}),children:[(0,$.jsx)(`option`,{value:`small`,children:`Small task`}),(0,$.jsx)(`option`,{value:`standard`,children:`Standard change`}),(0,$.jsx)(`option`,{value:`epic`,children:`Epic / multiple deliverables`})]})]}),(0,$.jsxs)(`label`,{className:`text-sm`,children:[`Current stage`,(0,$.jsx)(`select`,{"aria-label":`Current stage`,className:ai,value:i.assignment.stage,onChange:e=>P({stage:e.target.value}),children:oi.map(e=>(0,$.jsx)(`option`,{value:e,children:e[0].toUpperCase()+e.slice(1)},e))})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Work type and size describe the task; they do not reset progress. Edit milestones to adapt the plan.`}),!!n.lifecycle?.steps.length&&(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Assignment scope`,(0,$.jsxs)(`select`,{"aria-label":`Assignment scope`,className:ai,value:i.assignment.milestoneId??``,onChange:e=>P({milestoneId:e.target.value||void 0}),children:[(0,$.jsx)(`option`,{value:``,children:`Whole workspace`}),N]})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Current objective`,(0,$.jsx)(wn,{className:`mt-1`,value:i.assignment.objective,onChange:e=>P({objective:e.target.value}),placeholder:`Investigate why invoice totals differ from line items.`})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Expected output`,(0,$.jsx)(wn,{className:`mt-1`,value:i.assignment.expectedOutput,onChange:e=>P({expectedOutput:e.target.value}),placeholder:`A reproduction, likely cause, and proposed test plan.`})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Stop when`,(0,$.jsx)(wn,{className:`mt-1`,value:i.assignment.stopCondition,onChange:e=>P({stopCondition:e.target.value}),placeholder:`The proposal is ready for review. Stop before implementation.`})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(Y,{disabled:f,onClick:()=>void F(),children:`Save AI assignment`}),(0,$.jsx)(Y,{variant:`outline`,disabled:f||!!R,onClick:()=>void M(async()=>{if(!await Ht(n.assignment))throw Error(`Could not copy the AI assignment. Check browser clipboard permissions.`);h(`AI assignment copied.`)}),children:`Copy AI assignment`})]}),R&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Save your changes before copying the assignment.`})]}),c===`documents`&&(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Attach Markdown/text or link to a document. Approved requirements define intended behavior; drafts remain proposals. Superseded documents stay available as history.`}),n.projectId&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Project sources are stored in the workspace where you add them. Keep that workspace while sources are active; supersede or copy them elsewhere before deleting it.`}),(0,$.jsx)(`ul`,{className:`space-y-2`,children:n.guidance.documents.map(e=>(0,$.jsx)(`li`,{className:`rounded-lg border border-border p-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-sm`,children:e.title}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.role,` · `,e.status,` · `,e.scope.project?`Entire project`:e.scope.milestoneId?n.lifecycle?.steps.find(t=>t.id===e.scope.milestoneId)?.title??e.scope.milestoneId:`Whole workspace`]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,disabled:f,onClick:()=>void M(async()=>{let t=await X(`${A}/work/documents/${e.id}`);k({title:t.document.title,content:t.content,location:t.location})}),children:[`Read `,e.title]}),(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:()=>{y(e),x(e.id)},children:[`Edit `,e.title]})]})]})},e.id))}),!!n.sharedDocuments?.length&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h4`,{className:`font-semibold text-sm`,children:`Shared project sources`}),n.sharedDocuments.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg border border-border p-3`,children:[(0,$.jsxs)(`p`,{className:`text-sm`,children:[e.title,(0,$.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.role,` · `,e.status,` · managed in `,e.workspaceId]})]}),(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,disabled:f,onClick:()=>void M(async()=>{let t=await X(`${A}/work/documents/${e.id}`);k({title:t.document.title,content:t.content,location:t.location})}),children:[`Read `,e.title]})]},e.id))]}),!n.guidance.documents.length&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No documents yet. Add only the sources this work needs.`}),O&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-border p-3 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`h4`,{className:`text-sm font-semibold`,children:O.title}),(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>k(null),children:`Close document`})]}),O.content===void 0?(0,$.jsx)(`a`,{className:`text-sm text-primary underline`,href:O.location,target:`_blank`,rel:`noopener noreferrer`,children:`Open source document`}):(0,$.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-xs`,children:O.content})]}),(0,$.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:b?`Edit document labels`:`Add source document`}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Document title`,(0,$.jsx)(L,{value:v.title,onChange:e=>y({...v,title:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-sm`,children:[`Document role`,(0,$.jsx)(`select`,{"aria-label":`Document role`,className:ai,value:v.role,onChange:e=>y({...v,role:e.target.value}),children:[`requirements`,`design`,`evidence`,`reference`].map(e=>(0,$.jsx)(`option`,{value:e,children:e[0].toUpperCase()+e.slice(1)},e))})]}),(0,$.jsxs)(`label`,{className:`text-sm`,children:[`Document status`,(0,$.jsxs)(`select`,{"aria-label":`Document status`,className:ai,value:v.status,onChange:e=>y({...v,status:e.target.value}),children:[(0,$.jsx)(`option`,{value:`draft`,children:`Draft`}),(0,$.jsx)(`option`,{value:`approved`,children:`Approved`}),(0,$.jsx)(`option`,{value:`superseded`,children:`Superseded`})]})]})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Document scope`,(0,$.jsxs)(`select`,{"aria-label":`Document scope`,className:ai,value:v.scope.project?`project`:v.scope.milestoneId?`milestone:${v.scope.milestoneId}`:``,onChange:e=>y({...v,scope:e.target.value===`project`?{project:!0}:{milestoneId:e.target.value.replace(/^milestone:/,``)||void 0}}),children:[(0,$.jsx)(`option`,{value:``,children:`Whole workspace`}),n.projectId&&(0,$.jsx)(`option`,{value:`project`,children:`Entire project (shared)`}),n.lifecycle?.steps.map(e=>(0,$.jsx)(`option`,{value:`milestone:${e.id}`,children:e.title},e.id))]})]}),!b&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Document source`,(0,$.jsxs)(`select`,{"aria-label":`Document source`,className:ai,value:S,onChange:e=>C(e.target.value),children:[(0,$.jsx)(`option`,{value:`text`,children:`Upload or paste Markdown/text`}),(0,$.jsx)(`option`,{value:`link`,children:`Link to a document`})]})]}),S===`link`?(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Document URL`,(0,$.jsx)(L,{type:`url`,value:E,onChange:e=>D(e.target.value),placeholder:`https://…`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Upload text document`,(0,$.jsx)(`input`,{type:`file`,className:`mt-1 block w-full text-sm`,accept:`.md,.markdown,.txt,text/plain,text/markdown`,onChange:e=>{let t=e.target.files?.[0];t&&M(async()=>{if(t.size>5e5||!/\.(md|markdown|txt)$/i.test(t.name))throw Error(`Choose a Markdown or text file up to 500 KB. Link to other document formats.`);T(await t.text()),y(e=>({...e,title:e.title||t.name}))})}})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Source text`,(0,$.jsx)(wn,{value:w,onChange:e=>T(e.target.value),rows:5})]})]})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Owner summary (optional)`,(0,$.jsx)(wn,{value:v.summary,onChange:e=>y({...v,summary:e.target.value}),placeholder:`Highlight what matters for this task. The original remains available.`})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Y,{disabled:f||!v.title.trim()||!b&&!(S===`link`?E.trim():w.trim()),onClick:()=>void I(),children:b?`Save document labels`:`Add document`}),b&&(0,$.jsx)(Y,{variant:`ghost`,onClick:()=>{x(null),y(ii())},children:`Cancel document edit`})]})]})]}),c===`milestones`&&(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Milestones are optional and unique to this feature. Name the outcomes you need, or remove all milestones to hide the flow.`}),o.map((e,t)=>(0,$.jsxs)(`fieldset`,{className:`rounded-lg border border-border p-3 space-y-3`,children:[(0,$.jsxs)(`legend`,{className:`px-1 text-xs text-muted-foreground`,children:[`Milestone `,t+1,` · `,e.status.replaceAll(`_`,` `)]}),(0,$.jsxs)(Y,{size:`sm`,variant:`ghost`,disabled:f,onClick:()=>s(o.filter(t=>t.id!==e.id).map(t=>({...t,dependsOn:t.dependsOn?.filter(t=>t!==e.id)}))),children:[`Remove milestone `,t+1]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Milestone `,t+1,` title`,(0,$.jsx)(L,{value:e.title,onChange:t=>s(o.map(n=>n.id===e.id?{...n,title:t.target.value}:n))})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Milestone `,t+1,` outcome`,(0,$.jsx)(wn,{value:e.description??``,onChange:t=>s(o.map(n=>n.id===e.id?{...n,description:t.target.value}:n))})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Milestone `,t+1,` branch (optional)`,(0,$.jsx)(L,{value:e.branch??``,placeholder:`feature/invoice-calculation`,onChange:t=>s(o.map(n=>n.id===e.id?{...n,branch:t.target.value}:n))})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Milestone `,t+1,` repository (optional)`,(0,$.jsx)(L,{value:e.repo??``,placeholder:`billing-api`,onChange:t=>s(o.map(n=>n.id===e.id?{...n,repo:t.target.value}:n))})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Milestone `,t+1,` work item / PR (optional)`,(0,$.jsx)(L,{value:e.workItem??``,placeholder:`PBI ID or URL`,onChange:t=>s(o.map(n=>n.id===e.id?{...n,workItem:t.target.value}:n))})]}),(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Milestone `,t+1,` unblock condition (optional)`,(0,$.jsx)(L,{value:e.unblockCondition??``,placeholder:`Dependency or decision needed before starting`,onChange:t=>s(o.map(n=>n.id===e.id?{...n,unblockCondition:t.target.value}:n))})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsxs)(`legend`,{className:`mb-2 text-sm`,children:[`Milestone `,t+1,` dependencies`]}),o.filter(t=>t.id!==e.id).map(t=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:!!e.dependsOn?.includes(t.id),onChange:n=>s(o.map(r=>r.id===e.id?{...r,dependsOn:n.target.checked?[...r.dependsOn??[],t.id]:(r.dependsOn??[]).filter(e=>e!==t.id)}:r))}),t.title||`Untitled milestone`]},t.id))]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:!!(e.requiresVerification||e.verificationCommand),disabled:e.status===`completed`,onChange:t=>s(o.map(n=>n.id===e.id?{...n,requiresVerification:t.target.checked,...t.target.checked?{}:{verificationCommand:``}}:n))}),`Verify before completing milestone `,t+1]}),(e.requiresVerification||e.verificationCommand)&&(0,$.jsxs)(`label`,{className:`block text-sm`,children:[`Milestone `,t+1,` verification command (optional)`,(0,$.jsx)(L,{value:e.verificationCommand??``,disabled:e.status===`completed`,placeholder:`Uses the workspace test command unless overridden`,onChange:t=>s(o.map(n=>n.id===e.id?{...n,verificationCommand:t.target.value}:n))})]})]},e.id)),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(Y,{variant:`outline`,disabled:f||o.length>=100,onClick:()=>s([...o,{id:`milestone-${crypto.randomUUID()}`,title:``,status:`pending`,dependsOn:[]}]),children:`Add milestone`}),(0,$.jsx)(Y,{disabled:f||o.some(e=>!e.title.trim()),onClick:()=>void ee(),children:`Save milestones`})]})]})]})]})}var ci={"git-pull-request":We,"flask-conical":Ue,package:qe,database:Je,"shield-check":rt,terminal:Fn,zap:Rn,cpu:Yt,layers:qt,boxes:gt};function li({ws:e,showToast:t}){let{data:n=[]}=ve(e.branchName),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)({}),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(`workspace`),[x,S]=(0,Q.useState)(!1),{data:C=[],isLoading:w}=ae(),{data:T=[],isLoading:E}=de(e.branchName),{data:D=[],isLoading:O}=Ce(),{data:k,isLoading:A,isError:j}=De(e.branchName),M=Se(),N=Ee(),P=G(),F=(0,Q.useMemo)(()=>new Set(s??k?.enabledSkills??[]),[s,k?.enabledSkills]),I=(0,Q.useMemo)(()=>new Set(l??k?.enabledAgents??[]),[l,k?.enabledAgents]);(0,Q.useEffect)(()=>{k&&(c([...k.enabledSkills??[]]),u([...k.enabledAgents??[]]))},[k]);let ee=(0,Q.useMemo)(()=>{if(!k||s===null||l===null)return!1;let e=new Set(k.enabledSkills??[]),t=new Set(k.enabledAgents??[]);return!!(s.length!==e.size||s.some(t=>!e.has(t))||l.length!==t.size||l.some(e=>!t.has(e)))},[k,s,l]),R=e=>{o(t=>({...t,[e]:!t[e]}))},z=e=>{if(s===null)return;let t=new Set(s);t.has(e)?t.delete(e):t.add(e),c(Array.from(t))},te=e=>{if(l===null)return;let t=new Set(l);t.has(e)?t.delete(e):t.add(e),u(Array.from(t))},ne=(e,t,n)=>{if(s===null)return;let r=new Set(s);for(let e of n)t?r.add(e.id):r.delete(e.id);c(Array.from(r))},B=async()=>{if(!(!k||s===null||l===null)){f(!0);try{await M.mutateAsync({workspaceId:e.branchName,expectedRevision:k.revision??0,enabledSkills:s,enabledAgents:l,enabledCategories:C.map(e=>e.id)}),await N.mutateAsync({workspaceId:e.branchName}),t?.(`Skills & agents deployed successfully to workspace context!`,`success`)}catch(e){t?.(e instanceof Error?e.message:`Failed to deploy skills`,`error`)}finally{f(!1)}}},re=(0,Q.useMemo)(()=>{if(!r.trim())return T;let e=r.toLowerCase();return T.filter(t=>t.title?.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.tags?.some(t=>t.toLowerCase().includes(e)))},[T,r]),H=(0,Q.useMemo)(()=>{if(!r.trim())return D;let e=r.toLowerCase();return D.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.category.toLowerCase().includes(e))},[D,r]),{displayCategories:U,uncategorizedSkills:W}=(0,Q.useMemo)(()=>{let e=new Set(C.map(e=>e.id)),t=C.filter(e=>e.id!==`general`),n=new Map;for(let t of re)if(t.category&&t.category!==`general`&&!e.has(t.category)&&!n.has(t.category)){let e=t.category.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `);n.set(t.category,{id:t.category,name:e,description:`Skills categorized under ${e}`,color:`#3b82f6`,icon:`boxes`})}t.push(...Array.from(n.values()));let r=new Set(t.map(e=>e.id));return{displayCategories:t,uncategorizedSkills:re.filter(e=>!e.category||!r.has(e.category))}},[C,re]),oe=(0,Q.useMemo)(()=>{let e={};for(let t of U)e[t.id]=re.filter(e=>e.category===t.id);return e},[U,re]),se=(e,t)=>{t.stopPropagation(),m(e)},le=(e,t)=>{t.stopPropagation(),v({...e}),b(e.scope===`workspace`?`workspace`:`global`),S(!0),g(!0)},ue=()=>{v({name:``,title:``,category:U[0]?.id||`general`,description:``,tags:[],content:`# Skill Title
4
4
 
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-DE3RlOCf.js";import{m as t}from"./button-BrcP8Wxx.js";import{$ as n,J as r,Q as i,X as a,Y as o,Z as s,et as c,tt as l}from"./index-CQHHxwAN.js";function u(e){return a(`alert-dialog`,e)}var d=e(),f=u,p=s;function m({className:e,...n}){return(0,d.jsx)(l,{forceRender:!0,className:t(`fixed inset-0 z-50 bg-background/60 backdrop-blur-xs transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0`,e),"data-slot":`alert-dialog-backdrop`,...n})}function h({className:e,...n}){return(0,d.jsx)(o,{className:t(`fixed inset-0 z-50 grid grid-rows-[1fr_auto_1fr] justify-items-center p-4`,e),"data-slot":`alert-dialog-viewport`,...n})}function g({className:e,bottomStickOnMobile:n=!0,...r}){return(0,d.jsxs)(p,{children:[(0,d.jsx)(m,{}),(0,d.jsx)(h,{className:t(n&&`max-sm:grid-rows-[1fr_auto] max-sm:p-0 max-sm:pt-12`),children:(0,d.jsx)(i,{className:t(`-translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border bg-popover not-dark:bg-clip-padding text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-lg/5 transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`,n&&`max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4 max-sm:before:hidden max-sm:before:rounded-none`,e),"data-slot":`alert-dialog-popup`,...r})})]})}function _({className:e,...n}){return(0,d.jsx)(`div`,{className:t(`flex flex-col gap-2 p-6 text-center max-sm:pb-4 sm:text-left`,e),"data-slot":`alert-dialog-header`,...n})}function v({className:e,variant:n=`default`,...r}){return(0,d.jsx)(`div`,{className:t(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,n==="default"&&`border-t bg-muted/72 py-4`,n===`bare`&&`pb-6`,e),"data-slot":`alert-dialog-footer`,...r})}function y({className:e,...n}){return(0,d.jsx)(r,{className:t(`font-heading font-semibold text-xl leading-none`,e),"data-slot":`alert-dialog-title`,...n})}function b({className:e,...r}){return(0,d.jsx)(n,{className:t(`text-muted-foreground text-sm`,e),"data-slot":`alert-dialog-description`,...r})}function x(e){return(0,d.jsx)(c,{"data-slot":`alert-dialog-close`,...e})}export{_ as a,v as i,x as n,g as o,b as r,y as s,f as t};
1
+ import{t as e}from"./jsx-runtime-DE3RlOCf.js";import{m as t}from"./button-BrcP8Wxx.js";import{$ as n,J as r,Q as i,X as a,Y as o,Z as s,et as c,tt as l}from"./index-BxUZKLC0.js";function u(e){return a(`alert-dialog`,e)}var d=e(),f=u,p=s;function m({className:e,...n}){return(0,d.jsx)(l,{forceRender:!0,className:t(`fixed inset-0 z-50 bg-background/60 backdrop-blur-xs transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0`,e),"data-slot":`alert-dialog-backdrop`,...n})}function h({className:e,...n}){return(0,d.jsx)(o,{className:t(`fixed inset-0 z-50 grid grid-rows-[1fr_auto_1fr] justify-items-center p-4`,e),"data-slot":`alert-dialog-viewport`,...n})}function g({className:e,bottomStickOnMobile:n=!0,...r}){return(0,d.jsxs)(p,{children:[(0,d.jsx)(m,{}),(0,d.jsx)(h,{className:t(n&&`max-sm:grid-rows-[1fr_auto] max-sm:p-0 max-sm:pt-12`),children:(0,d.jsx)(i,{className:t(`-translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border bg-popover not-dark:bg-clip-padding text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-lg/5 transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`,n&&`max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4 max-sm:before:hidden max-sm:before:rounded-none`,e),"data-slot":`alert-dialog-popup`,...r})})]})}function _({className:e,...n}){return(0,d.jsx)(`div`,{className:t(`flex flex-col gap-2 p-6 text-center max-sm:pb-4 sm:text-left`,e),"data-slot":`alert-dialog-header`,...n})}function v({className:e,variant:n=`default`,...r}){return(0,d.jsx)(`div`,{className:t(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,n==="default"&&`border-t bg-muted/72 py-4`,n===`bare`&&`pb-6`,e),"data-slot":`alert-dialog-footer`,...r})}function y({className:e,...n}){return(0,d.jsx)(r,{className:t(`font-heading font-semibold text-xl leading-none`,e),"data-slot":`alert-dialog-title`,...n})}function b({className:e,...r}){return(0,d.jsx)(n,{className:t(`text-muted-foreground text-sm`,e),"data-slot":`alert-dialog-description`,...r})}function x(e){return(0,d.jsx)(c,{"data-slot":`alert-dialog-close`,...e})}export{_ as a,v as i,x as n,g as o,b as r,y as s,f as t};